This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: Ignore attempt to #include directory


On Saturday 09 June 2007 20:41, Tom Tromey wrote:
> >>>>> "Vladimir" == Vladimir Prus <vladimir@codesourcery.com> writes:
> 
> Vladimir> The attached patch, approved off-list by Mark Mitchell and checked
> Vladimir> in to mainline, fixes this problem.
> 
> BTW, this was PR 11242.

Ah, ok.

> Vladimir> +      /* On most UNIX systems, open succeeds on a directory.  Above,
> Vladimir> +         we check if we have opened a directory and if so, set errno
> Vladimir> +         to ENOENT.  However, on Windows, opening a directory
> Vladimir> +         fails with EACCESS.  We want to return ENOENT in that
> Vladimir> +         case too.  */
> Vladimir> +      if (stat (file->path, &file->st) == 0
> Vladimir> +          && S_ISDIR (file->st.st_mode))
> Vladimir> +        errno = ENOENT;
> 
> This changes errno if stat fails.  I suppose this is a "shouldn't
> happen" condition.

Indeed, the errno can change. I'm not sure this is big problem in practice --
the error from opening a file is likely to be as good as error from stat for
purposes of reporting the problem to the user.

- Volodya


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