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]

Re: [dave@hiauly1.hia.nrc.ca: Incorrect file name simplication]


> On Fri, Mar 30, 2001 at 01:21:35PM -0500, John David Anglin wrote:
> > Anyhow, since the simplification appears to be optional, shouldn't
> > _cpp_simplify_pathname just return if VMS is defined?  There may be
> > better solutions but until there is interest this would be better
> > than doing something totally wrong.
> 
> Seems reasonable, yeah.

This is the patch which I am testing.  It's successfully past fix-proto.
Maybe it will help Neil a bit with his lstat patch.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

20010330  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* cppfiles.c (_cpp_simplify_pathname):  Don't simplify `foo/bar/../quux'
	in absolute paths.  Don't simplify VMS file specifications.

--- cppfiles.c.orig	Tue Mar 27 11:08:45 2001
+++ cppfiles.c	Fri Mar 30 16:08:38 2001
@@ -1020,8 +1020,10 @@
 _cpp_simplify_pathname (path)
     char *path;
 {
+#ifndef VMS
     char *from, *to;
     char *base;
+    char *start = NULL;
     int absolute = 0;
 
 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
@@ -1053,6 +1055,7 @@
 		/* On some hosts // differs from /; Posix allows this.  */
 		to++;
 	}
+        start = from;
     }
     base = to;
     
@@ -1069,7 +1072,7 @@
 	{
 	    if (base == to)
 	    {
-		if (absolute)
+		if (start == from)
 		    from += 3;
 		else
 		{
@@ -1081,11 +1084,21 @@
 	    }
 	    else
 	    {
-		to -= 2;
-		while (to > base && *to != '/') to--;
-		if (*to == '/')
-		    to++;
-		from += 3;
+		if (!absolute)
+		{
+		    to -= 2;
+		    while (to > base && *to != '/') to--;
+		    if (*to == '/')
+		        to++;
+		    from += 3;
+		}
+		else
+		{
+		    *to++ = *from++;
+		    *to++ = *from++;
+		    *to++ = *from++;
+		    base = to;
+		}
 	    }
 	}
 	else if (from[0] == '.' && from[1] == '.' && from[2] == '\0')
@@ -1131,6 +1144,7 @@
       *to++ = '.';
     
     *to = '\0';
+#endif /* VMS */
 
     return path;
 }


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