[PATCH] Allow filenames ending with a "." in managed mode

Igor Pechtchanski pechtcha@cs.nyu.edu
Wed Oct 29 00:44:00 GMT 2003


The attached patch allows creating and working with files ending in "."
(or multiple "."s) in managed mode.
	Igor
==============================================================================
ChangeLog:
2003-10-28  Igor Pechtchanski  <pechtcha@cs.nyu.edu>

	* path.cc (dot_special_chars): New global variable.
	(special_name): Make files ending in "." special.
	(fnunmunge): Allow encoded ".".
	(mount_item::fnmunge): Handle trailing ".".

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton
-------------- next part --------------
Index: winsup/cygwin/path.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/path.cc,v
retrieving revision 1.277
diff -u -p -r1.277 path.cc
--- winsup/cygwin/path.cc	25 Oct 2003 16:12:45 -0000	1.277
+++ winsup/cygwin/path.cc	29 Oct 2003 00:37:10 -0000
@@ -1141,7 +1141,8 @@ set_flags (unsigned *flags, unsigned val
     }
 }
 
-static char special_chars[] =
+static char dot_special_chars[] =
+    "."
     "\001" "\002" "\003" "\004" "\005" "\006" "\007" "\010"
     "\011" "\012" "\013" "\014" "\015" "\016" "\017" "\020"
     "\021" "\022" "\023" "\024" "\025" "\026" "\027" "\030"
@@ -1151,6 +1152,7 @@ static char special_chars[] =
     "I"    "J"    "K"    "L"    "M"    "N"    "O"    "P"
     "Q"    "R"    "S"    "T"    "U"    "V"    "W"    "X"
     "Y"    "Z";
+static char *special_chars = dot_special_chars + 1;
 static char special_introducers[] =
     "anpcl";
 
@@ -1178,6 +1180,11 @@ special_name (const char *s, int inc = 1
   if (strpbrk (s, special_chars))
     return !strncasematch (s, "%2f", 3);
 
+  if (strcasematch (s, ".") || strcasematch (s, ".."))
+    return false;
+  if (s[strlen (s)-1] == '.')
+    return true;
+
   const char *p;
   if (strcasematch (s, "conin$") || strcasematch (s, "conout$"))
     return -1;
@@ -1212,7 +1219,7 @@ fnunmunge (char *dst, const char *src)
     }
 
   while (*src)
-    if (!(c = special_char (src)))
+    if (!(c = special_char (src, dot_special_chars)))
       *dst++ = *src++;
     else
       {
@@ -1243,6 +1250,13 @@ mount_item::fnmunge (char *dst, const ch
 	  *d++ = *src++;
 	else
 	  d += __small_sprintf (d, "%%%02x", (unsigned char) *src++);
+
+      --d;
+      if (*d != '.')
+	d++;
+      else
+	d += __small_sprintf (d, "%%%02x", (unsigned char) '.');
+
       *d = *src;
     }
 


More information about the Cygwin-patches mailing list