From: Alexandre Oliva Date: Tue, 22 May 2001 11:57:21 +0000 (+0000) Subject: cppfiles.c (remove_component_p): Don't assume lstat/stat will keep errno unchanged... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d75ad04d0f89e21f9c68682067442ae21f9a980;p=gcc.git cppfiles.c (remove_component_p): Don't assume lstat/stat will keep errno unchanged on success. * cppfiles.c (remove_component_p): Don't assume lstat/stat will keep errno unchanged on success. From-SVN: r42445 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b9eeac7cf93..9d713505206 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2001-05-22 Alexandre Oliva + + * cppfiles.c (remove_component_p): Don't assume lstat/stat will + keep errno unchanged on success. + 2001-05-22 Joseph S. Myers * c-lex.c (lex_number): If pedantic and not C99, pedwarn exactly diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index dea6dd6677e..137882b340c 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -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); }