Hi,

I committed the attached patch to fix the handling of paths consisting
only of a double separator character. Our normalization would previously
turn this into an empty string, instead of a single separator character.
This happened both on Windows and on *nix.

Regards,
Jeroen

2006-08-21  Jeroen Frijters  <[EMAIL PROTECTED]>

        * java/io/File.java (normalizePath): Fixed handling of "//" and
"\\".
Index: java/io/File.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/File.java,v
retrieving revision 1.66
diff -u -r1.66 File.java
--- java/io/File.java   21 Aug 2006 09:23:01 -0000      1.66
+++ java/io/File.java   21 Aug 2006 12:46:42 -0000
@@ -286,7 +286,8 @@
         // example, is a valid and minimal path).
         if (plen > 1 && p.charAt (plen - 1) == separatorChar)
          {
-           if (! (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':'))
+           if (! (separatorChar == '\\' && ((plen == 3 && p.charAt(1) == ':')
+                || (plen == 2 && p.charAt(0) == separatorChar))))
              return p.substring (0, plen - 1);
          }
        else
@@ -303,7 +304,16 @@
          {
            dupIndex++;
            if (dupIndex == plen)
-             return newpath.toString();
+              {
+                if ((separatorChar == '\\'
+                    && newpath.length() == 2
+                    && newpath.charAt(1) == ':')
+                    || (separatorChar != '\\' && newpath.length() == 0))
+                  {
+                    newpath.append(separatorChar);
+                  }
+               return newpath.toString();
+              }
          }
        newpath.append(separatorChar);
        last = dupIndex;
@@ -315,7 +325,9 @@
     int end;
     if (plen > 1 && p.charAt (plen - 1) == separatorChar)
     {
-      if (separatorChar == '\\' && plen == 3 && p.charAt (1) == ':')
+      if (separatorChar == '\\'
+        && ((plen == 3 && p.charAt(1) == ':')
+            || (plen == 2 && p.charAt(0) == separatorChar)))
         end = plen;
       else
         end = plen - 1;

Reply via email to