This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] [mingw32] fix regresion with trailing backslashes in -Iinclude dir
- From: Danny Smith <dannysmith at clear dot net dot nz>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 30 May 2004 02:40:45 +0100
- Subject: Re: [Patch] [mingw32] fix regresion with trailing backslashes in -Iinclude dir
- References: <000b01c4453b$7304fbf0$a04861cb@DANNY><877juv954j.fsf@taltos.codesourcery.com>
- Reply-to: Danny Smith <dannysmith at users dot sourceforge dot net>
From: "Zack Weinberg" <zack@codesourcery.com>
| Danny Smith <dannysmith@clear.net.nz> writes:
|
| > Hello,
| >
| > On mingw32, with a command-line -I include option ending with a
| > backslash gcc fails to recognise an existing directory. For example,
| > '-I..\include\' reports a non-existent directory while '-I..\include' works.
| > This is a regression from 3.3.3 and is observed on both 3.4 and and
| > trunk.
| >
| > Trailing forward slashes cause no problems.
| >
| > For some strange reason, the stat function in MS runtime accepts
| > POSIX-style '/' but not DOS-style '\\' as final character for a
| > directory name
| ...
|
| > * c-incpath.c (add_path): Canonicalize paths to use '/' if
| > HAVE_DOS_BASED_FILESYSTEM.
|
| This is OK, but please add a comment explaining what you just
| discovered, so someone doesn't take it back out again.
|
Is this sufficient? Is OK for trunk only or for 3.4.1 as well.
Danny
--- c-incpath.c 30 May 2004 01:39:46 -0000
*************** add_path (char *path, int chain, int cxx
*** 321,326 ****
--- 321,336 ----
{
cpp_dir *p;
+ #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Convert all backslashes to slashes. The native CRT stat()
+ function does not recognise a directory that ends in a backslash
+ (unless it is a drive root dir, such "c:\"). Forward slashes,
+ trailing or otherwise, cause no problems for stat(). */
+ char* c;
+ for (c = path; *c; c++)
+ if (*c == '\\') *c = '/';
+ #endif
+
p = xmalloc (sizeof (cpp_dir));
p->next = NULL;
p->name = path;
| zw