OSDN Git Service

* path.cc (normalize_posix_path): Remove unneeded check for dots.
authorcgf <cgf>
Mon, 20 Dec 2004 16:31:16 +0000 (16:31 +0000)
committercgf <cgf>
Mon, 20 Dec 2004 16:31:16 +0000 (16:31 +0000)
(path_conv::set_normalized_path): Strip trailing dots, similarly to what had
previously been done for the win32 path.

winsup/cygwin/ChangeLog
winsup/cygwin/path.cc

index 5c7d0d9..f65841b 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-20  Christopher Faylor  <cgf@timesys.com>
+
+       * path.cc (normalize_posix_path): Remove unneeded check for dots.
+       (path_conv::set_normalized_path): Strip trailing dots, similarly to
+       what had previously been done for the win32 path.
+
 2004-12-18  Christopher Faylor  <cgf@timesys.com>
 
        * path.cc (normalize_win32_path): Make third arg pass-by reference.
index dad90c3..f1c25c4 100644 (file)
@@ -250,18 +250,7 @@ normalize_posix_path (const char *src, char *dst, char *&tail)
                    break;
                }
              else if (src[2] && !isslash (src[2]))
-               {
-                 if (src[2] == '.')
-                   {
-                     /* Is this a run of dots? That would be an invalid
-                        filename.  A bunch of leading dots would be ok,
-                        though. */
-                     int n = strspn (src, ".");
-                     if (!src[n] || isslash (src[n])) /* just dots... */
-                       return ENOENT;
-                   }
-                 break;
-               }
+               break;
              else
                {
                  while (tail > dst && !isslash (*--tail))
@@ -438,7 +427,18 @@ void
 path_conv::set_normalized_path (const char *path_copy)
 {
   char *eopath = strchr (path, '\0');
-  size_t n = strlen (path_copy) + 1;
+  size_t n;
+
+  if (dev.devn != FH_FS || strncmp (path_copy, "//./", 4) == 0)
+    n = strlen (path_copy) + 1;
+  else
+    {
+      char *p = strchr (path_copy, '\0');
+      while (*--p == '.' || *p == ' ')
+       continue;
+      p[1] = '\0';
+      n = 2 + p - path_copy;
+    }
 
   normalized_path = path + sizeof (path) - n;
   if (normalized_path > eopath)
@@ -448,6 +448,7 @@ path_conv::set_normalized_path (const char *path_copy)
       normalized_path = (char *) cmalloc (HEAP_STR, n);
       normalized_path_size = 0;
     }
+
   memcpy (normalized_path, path_copy, n);
 }