]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
URLStreamHandler.java (parseURL): If original file ends with "/", so must canonical...
authorTom Tromey <tromey@redhat.com>
Fri, 12 Sep 2003 01:08:18 +0000 (01:08 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Fri, 12 Sep 2003 01:08:18 +0000 (01:08 +0000)
* java/net/URLStreamHandler.java (parseURL): If original file
ends with "/", so must canonical result.
* java/io/natFilePosix.cc (getCanonicalPath): Clean up snafus
with nul-termination and finding previous "/".

From-SVN: r71327

libjava/ChangeLog
libjava/java/io/natFilePosix.cc
libjava/java/net/URLStreamHandler.java

index de054fde953b67f180dd0212a530fa4811754310..6dbfa3c2fc21c50290dffff51e9cfe70b7928f87 100644 (file)
@@ -1,3 +1,10 @@
+2003-09-11  Tom Tromey  <tromey@redhat.com>
+
+       * java/net/URLStreamHandler.java (parseURL): If original file
+       ends with "/", so must canonical result.
+       * java/io/natFilePosix.cc (getCanonicalPath): Clean up snafus
+       with nul-termination and finding previous "/".
+
 2003-09-11  Michael Koch  <konqueror@gmx.de>
 
        * acconfig.h: Removed most items.
index a1eb1c74b80424455eeff26e81bfd6f4718579dc..580b5955ac0546782b8dd6197078bb6472a2b936 100644 (file)
@@ -164,7 +164,7 @@ java::io::File::getCanonicalPath (void)
              // Found ".." component, lop off last part from existing
              // buffer.
              --out_idx;
-             while (out_idx > 0 && buf[out_idx] != '/')
+             while (out_idx > 0 && buf2[out_idx] != '/')
                --out_idx;
              // Can't go up past "/".
              if (out_idx == 0)
@@ -179,7 +179,8 @@ java::io::File::getCanonicalPath (void)
              out_idx += len;
            }
        }
-      buf[out_idx] = '\0';
+
+      buf2[out_idx] = '\0';
     }
 
   // FIXME: what encoding to assume for file names?  This affects many
index 93a8ab278148cd71e13ddd10f4b7ba9de123501c..61b466cce6d5d4e1ff60827394c1fddcb8e7209c 100644 (file)
@@ -196,7 +196,11 @@ public abstract class URLStreamHandler
             // need to canonicalise the file path.
             try
               {
+               boolean endsWithSlash = file.charAt(file.length() - 1) == '/';
                 file = new File (file).getCanonicalPath ();
+               if (endsWithSlash
+                   && file.charAt(file.length() - 1) != '/')
+                 file += '/';
               }
             catch (IOException e)
               {