This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA] update_path should match only on entire directory names
- From: Thomas Quinot <quinot at act-europe dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Apr 2004 19:28:12 +0200
- Subject: [RFA] update_path should match only on entire directory names
As advised by Richard and Geert, I have done a full build of the GCC
head with this patch, and ran a make check whose output did not show any
unexpected regressions.
Could the powers-that-be please review it, and approve and commit it if
it passes the review?
Thanks!
Thomas.
----- Forwarded message from Thomas Quinot <quinot@act-europe.fr> -----
Date: Tue, 20 Apr 2004 16:49:16 +0200
From: Thomas Quinot <quinot@act-europe.fr>
To: Geert Bosch <bosch@gnat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: update_path should match only on entire directory names
In-Reply-To: <CB9853C5-92D6-11D8-B9F9-000A959A128E@gnat.com>
* Geert Bosch, 2004-04-20 :
> I'd think you should be using IS_DIR_SEPARATOR instead. I
> notice \ that your patch is relative to GCC 3.2.3, but this
> branch is long dead and most likely you'd want submit a patch
> for mainline GCC. Also, don't forget to include a properly
> formatted ChangeLog entry and a note on the testing you did.
Here is an updated diff. ChangeLog entry:
2004-04-20 Thomas Quinot <quinot@act-europe.fr>
* prefix.c (update_path): Replace PREFIX with KEY only
when it matches a full directory name in PATH.
Testing: this change has been in the Ada Core diff for several years.
Thomas.
Index: prefix.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/prefix.c,v
retrieving revision 1.41
diff -u -r1.41 prefix.c
--- prefix.c 19 Jul 2003 14:47:07 -0000 1.41
+++ prefix.c 20 Apr 2004 14:42:16 -0000
@@ -238,16 +238,20 @@
while (*string++);
}
-/* Update PATH using KEY if PATH starts with PREFIX. The returned
- string is always malloc-ed, and the caller is responsible for
- freeing it. */
+/* Update PATH using KEY if PATH starts with PREFIX as a directory.
+ The returned string is always malloc-ed, and the caller is
+ responsible for freeing it. */
char *
update_path (const char *path, const char *key)
{
char *result, *p;
+ const int len = strlen (std_prefix);
- if (! strncmp (path, std_prefix, strlen (std_prefix)) && key != 0)
+ if (! strncmp (path, std_prefix, len)
+ && (IS_DIR_SEPARATOR(path[len])
+ || path[len] == '\0')
+ && key != 0)
{
bool free_key = false;
@@ -257,7 +261,7 @@
free_key = true;
}
- result = concat (key, &path[strlen (std_prefix)], NULL);
+ result = concat (key, &path[len], NULL);
if (free_key)
free ((char *) key);
result = translate_name (result);
--
Thomas Quinot ** quinot@act-europe.fr ** Software and Network Engineer
ACT Europe -- Paris, France *** Ada Core Technologies -- New York, USA
----- End forwarded message -----
--
Thomas Quinot ** quinot@act-europe.fr ** Software and Network Engineer
ACT Europe -- Paris, France *** Ada Core Technologies -- New York, USA