This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

cpp leading / vs // bug


Current code in simplify_filename uses the following test to see if it
should strip leading double slashes from a filename:

  stat ("/", &s) == 0 && stat ("//", &s) == 0 && [rest]

I cannot find any reference to what ``stat ("//", &s)'' should return in 
either POSIX or Susv2 (please yell if you know more about this ...), other 
than telling us that double leading slash is implementation dependent.

This unfortunately breaks Cygwin, where leading "//" is special, but stat
returns 0 for it, and also the same inode and so on. The result is that
cpp reduces to a single slash and valid UNC pathnames fail.

Why does it work for other windows32 targets where '//' is special?
Because stat in all runtimes but Cygwin return -1 for // and the 
conditional evaluates to the expected value.

fixes?
  
  - leave leading // alone. However, reduce 3 or more to a single slash as
    POSIX tells us and as it is done now. This involves removing the test
    that set slashslash_vs_slash altogether.

  - #ifdef __CYGWIN__ slashslash_vs_slash = -1 #else ... #endif to be safe.

  - Add a variable in xm-target (yuk) that deals with this.

I don't see any such munging in cppfiles/cpplib, but I haven't looked hard
enough yet.

Comments please.

Remember the freeze deadline ;-)

Regards,
Mumit



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]