Odd, is it not? mkdir 'e:\' cannot be undone by rmdir 'e:\' ...

Ken Brown kbrown@cornell.edu
Sat Sep 21 16:07:00 GMT 2019


On 9/20/2019 5:11 AM, Houder wrote:
> As I said already, the snippet should NOT be executed in general. Perhaps
> it is another left-over from old times that should have been deleted.

You're absolutely right. Prior to commit b0717aae0, the code looked like this:
 if (strncmp (path, "\\\\.\\", 4))
	{
	 /* Windows ignores trailing dots and spaces in the last path
	 component, and ignores exactly one trailing dot in inner
	 path components. */
	 char *tail = NULL;
 [...]
	 if (!tail || tail == path)
	 /* nothing */;
	 else if (tail[-1] != '\\')
	 {
	 *tail = '0円';
	 strip_tail = true;
	 }
	 else
	 {
	 error = ENOENT;
	 return;
	 }
	}
Note the use of a *local* tail variable. It's a pointer into path, as you can 
see by looking at the part I omitted.
In commit b0717aae0, Corinna intended to disable this code, but she 
inadvertently disabled only part of it. Here's the relevant part of that commit:
@@ -1170,6 +1225,7 @@ out:
 {
 if (strncmp (path, "\\\\.\\", 4))
 {
+#if 0
 /* Windows ignores trailing dots and spaces in the last path
 component, and ignores exactly one trailing dot in inner
 path components. */
@@ -1190,7 +1246,7 @@ out:
 tail = NULL;
 }
 }
-
+#endif
 if (!tail || tail == path)
 /* nothing */;
 else if (tail[-1] != '\\')
In particular, the declaration of the local tail variable is in the disabled 
code, so the cruft at the end is referring to the other tail, which points into 
path_copy.
[A later commit removed the disabled code.]
I'll fix this and then look at your patches to mkdir and rmdir. It would be 
very helpful if you would write these as a patch series with cover letter, using 
git format-patch, and send them to the cygwin-patches list.
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /