diff options
author | Tom Tromey <tromey@redhat.com> | 2002-06-12 17:01:02 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2002-06-12 17:01:02 +0000 |
commit | 6e32abbfc25930c079b643a85750472d50baac00 (patch) | |
tree | c84cab82af76c730cffbb3b575a903dc2a03634d /libjava | |
parent | d65cb654adaeecfc8d7533e0fb08ea89a60751a2 (diff) | |
download | gcc-6e32abbfc25930c079b643a85750472d50baac00.zip gcc-6e32abbfc25930c079b643a85750472d50baac00.tar.gz gcc-6e32abbfc25930c079b643a85750472d50baac00.tar.bz2 |
re PR libgcj/6652 (new java.io.File("").getCanonicalFile() throws exception)
* java/io/natFilePosix.cc (getCanonicalPath): Treat "" like ".".
Fixes PR libgcj/6652.
From-SVN: r54558
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/io/natFilePosix.cc | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 072c7b5..26bd707 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2002-06-12 Tom Tromey <tromey@redhat.com> + + * java/io/natFilePosix.cc (getCanonicalPath): Treat "" like ".". + Fixes PR libgcj/6652. + 2002-06-10 Tom Tromey <tromey@redhat.com> * java/lang/Class.h (Class::desiredAssertionStatus): Declare. diff --git a/libjava/java/io/natFilePosix.cc b/libjava/java/io/natFilePosix.cc index cd04571..f9fe78e 100644 --- a/libjava/java/io/natFilePosix.cc +++ b/libjava/java/io/natFilePosix.cc @@ -104,9 +104,16 @@ java::io::File::attr (jint query) jstring java::io::File::getCanonicalPath (void) { - char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1); + // We use `+2' here because we might need to use `.' for our special + // case. + char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 2); char buf2[MAXPATHLEN]; jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf); + + // Special case: treat "" the same as ".". + if (total == 0) + buf[total++] = '.'; + buf[total] = '\0'; #ifdef HAVE_REALPATH |