cppfiles.c (remove_component_p): Don't assume lstat/stat will keep errno unchanged...
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 22 May 2001 11:57:21 +0000 (11:57 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 22 May 2001 11:57:21 +0000 (11:57 +0000)
* cppfiles.c (remove_component_p): Don't assume lstat/stat will
keep errno unchanged on success.

From-SVN: r42445

gcc/ChangeLog
gcc/cppfiles.c

index b9eeac7cf93878862afbae634b799595b0ae87f6..9d7135052065148a359ac2be990aae66d4864e7a 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-22  Alexandre Oliva  <aoliva@redhat.com>
+
+       * cppfiles.c (remove_component_p): Don't assume lstat/stat will
+       keep errno unchanged on success.
+
 2001-05-22  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * c-lex.c (lex_number): If pedantic and not C99, pedwarn exactly
index dea6dd6677e17e704155bea5d59bff364c9f3974..137882b340c231159a673df5144fbc796069dc97 100644 (file)
@@ -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;
+
   return result == 0 && S_ISDIR (s.st_mode);
 }