This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Preprocessor problem on Cygwin
- To: gcc-patches at gcc dot gnu dot org
- Subject: Preprocessor problem on Cygwin
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 22 May 2001 07:03:00 -0300
- Organization: GCC Team, Red Hat
Every now and then, I try my (bad) luck on Cygwin. This time, I fell
prey of an apparent bug in the version of the Cygwin dll I had
installed: it sets errno even when lstat() succeeds, which breaks
cpp's pathname simplification code.
Even though I believe this is actually a bug in Cygwin, I thought I'd
work around the problem, that might well be present in other OSs, with
this simple patch in GCC. Ok for mainline? Ok for branch?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* cppfiles.c (remove_component_p): Don't assume lstat/stat will
keep errno unchanged on success.
Index: gcc/cppfiles.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppfiles.c,v
retrieving revision 1.117
diff -u -p -r1.117 cppfiles.c
--- gcc/cppfiles.c 2001/05/05 11:12:19 1.117
+++ gcc/cppfiles.c 2001/05/22 09:49:39
@@ -1027,6 +1027,12 @@ remove_component_p (path)
result = stat (path, &s);
#endif
+ /* There's no guarantee that errno will be unchanged, even on
+ success. Cygwin's lstat(), for example, will often set errno to
+ ENOSYS. In case of success, reset errno to zero. */
+ if (result == 0 && errno != 0)
+ errno = 0;
+
return result == 0 && S_ISDIR (s.st_mode);
}
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me