]> sourceware.org Git - newlib-cygwin.git/commitdiff
* path.cc (normalize_win32_path): Detect components with only dots. Remove a
authorChristopher Faylor <me@cgf.cx>
Tue, 4 May 2004 15:14:48 +0000 (15:14 +0000)
committerChristopher Faylor <me@cgf.cx>
Tue, 4 May 2004 15:14:48 +0000 (15:14 +0000)
final .  if it follows '\\'.
(mount_info::conv_to_win32_path): Only backslashify the path when no mount is
found.
(chdir): Do not look for components with only dots.

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

index 2662b87414dd4f6605b2b9222a91dcc8752e3601..91bc71d6c0c8ffbf5a6c34b02234820af9a4956c 100644 (file)
@@ -1,3 +1,11 @@
+2004-04-11  Pierre Humblet  <pierre.humblet@ieee.org>
+
+       * path.cc (normalize_win32_path): Detect components with only dots.
+       Remove a final .  if it follows '\\'.
+       (mount_info::conv_to_win32_path): Only backslashify the path when no
+       mount is found.
+       (chdir): Do not look for components with only dots.
+
 2004-04-20  Pierre Humblet <pierre.humblet@ieee.org>
            Christopher Faylor  <cgf@alum.bu.edu>
 
index 6944194ad02f920fce14cafcf14825ccf14032fc..a5b931c12c9cb009ae62f3c2ad1564f5d43573ef 100644 (file)
@@ -789,7 +789,7 @@ path_conv::check (const char *src, unsigned opt,
        }
 
      /* Copy the symlink contents to the end of tmp_buf.
-       Convert slashes.  FIXME? I think it's fine / Pierre */
+       Convert slashes. */
       for (char *p = sym.contents; *p; p++)
        *headptr++ = *p == '\\' ? '/' : *p;
       *headptr = '\0';
@@ -1007,18 +1007,26 @@ normalize_win32_path (const char *src, char *dst, char **tail)
       /* Backup if "..".  */
       else if (src[0] == '.' && src[1] == '.'
               /* dst must be greater than dst_start */
-              && dst[-1] == '\\'
-              && (isdirsep (src[2]) || src[2] == 0))
-       {
-         /* Back up over /, but not if it's the first one.  */
-         if (dst > dst_root_start + 1)
-           dst--;
-         /* Now back up to the next /.  */
-         while (dst > dst_root_start + 1 && dst[-1] != '\\' && dst[-2] != ':')
-           dst--;
-         src += 2;
-         if (isdirsep (*src))
-           src++;
+              && dst[-1] == '\\')
+        {
+         if (isdirsep (src[2]) || src[2] == 0)
+           {
+             /* Back up over /, but not if it's the first one.  */
+             if (dst > dst_root_start + 1)
+               dst--;
+             /* Now back up to the next /.  */
+             while (dst > dst_root_start + 1 && dst[-1] != '\\' && dst[-2] != ':')
+               dst--;
+             src += 2;
+             if (isdirsep (*src))
+               src++;
+           }
+         else
+           {
+             int n = strspn (src, ".");
+             if (!src[n] || isdirsep (src[n])) /* just dots... */
+               return ENOENT;
+           }
        }
       /* Otherwise, add char to result.  */
       else
@@ -1032,6 +1040,8 @@ normalize_win32_path (const char *src, char *dst, char **tail)
       if ((dst - dst_start) >= CYG_MAX_PATH)
        return ENAMETOOLONG;
     }
+   if (dst > dst_start + 1 && dst[-1] == '.' && dst[-2] == '\\')
+     dst--;
   *dst = '\0';
   *tail = dst;
   debug_printf ("%s = normalize_win32_path (%s)", dst_start, src_start);
@@ -1502,11 +1512,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
       chroot_ok = true;
     }
   else
-    {
-      if (strchr (src_path, ':') == NULL && !is_unc_share (src_path))
-       set_flags (flags, PATH_BINARY);
-      backslashify (src_path, dst, 0);
-    }
+    backslashify (src_path, dst, 0);
 
  out:
   MALLOC_CHECK;
@@ -3305,24 +3311,6 @@ chdir (const char *in_dir)
       return -1;
     }
 
-
-  /* Look for trailing path component consisting entirely of dots.  This
-     is needed only in case of chdir since Windows simply ignores count
-     of dots > 2 here instead of returning an error code.  Counts of dots
-     <= 2 are already eliminated by normalize_posix_path. */
-  const char *p = strrchr (dir, '/');
-  if (!p)
-    p = dir;
-  else
-    p++;
-
-  size_t len = strlen (p);
-  if (len > 2 && strspn (p, ".") == len)
-    {
-      set_errno (ENOENT);
-      return -1;
-    }
-
   const char *native_dir = path;
 
   /* Check to see if path translates to something like C:.
This page took 0.040213 seconds and 5 git commands to generate.