[Patch]: c:.

Pierre A. Humblet pierre@phumblet.no-ip.org
Sun May 16 02:38:00 GMT 2004


I have run more tests and noticed that c:. and c:..
are now interpreted as c:/
That's because of the new code that strips trailing dots
and spaces. 

A patch is attached. It works fine on WinME (ls, cd, etc...)
but I am wondering how NtCreateFile reacts to that syntax
as well as to c:xxxx 
Depending on the answer we may have to treat these forms in
a new way (perhaps just forbid them).

If we do not use the patch, then chdir must be tuned to
handle these paths appropriately (they are not recognized by
isabspath, although they are absolute).

Paths such as c:../.. are not handled properly, but that's
not a regression.

Windows never stops amazing me!

Pierre

2004-05-16  Pierre Humblet <pierre.humblet@ieee.org>

	* path.c {path_conv::check): Do not strip trailing dots in
	c:. and c:..

-------------- next part --------------
Index: path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.312
diff -u -p -r1.312 path.cc
--- path.cc	15 May 2004 15:55:43 -0000	1.312
+++ path.cc	16 May 2004 00:40:18 -0000
@@ -556,13 +556,18 @@ path_conv::check (const char *src, unsig
 	       tail--;
 	    }
           /* Remove trailing dots and spaces which are ignored by Win32 functions but
-	     not by native NT functions. */
-          while (tail[-1] == '.' || tail[-1] == ' ')
-	    tail--;
-          if (tail > path_copy + 1 && isslash (tail[-1]))
-            {
-	      error = ENOENT;
-              return;
+	     not by native NT functions, except c:. and c:.. */
+	  if (tail - path_copy > 4
+	      || !isdrive (path_copy)
+	      || !(path_copy[2] == '.' && (!path_copy[3] || path_copy[3] == '.')))
+	    {
+	      while (tail[-1] == '.' || tail[-1] == ' ')
+		tail--;
+	      if (tail > path_copy + 1 && isslash (tail[-1]))
+	        {
+		  error = ENOENT;
+		  return;
+		}
 	    }
         }
       path_end = tail;


More information about the Cygwin-patches mailing list