update_path should match only on entire directory names

Thomas Quinot quinot@act-europe.fr
Tue Apr 20 13:51:00 GMT 2004


* Thomas Quinot, 2004-04-19 :

> Please consider it for integration in the mainline GCC repository.

Below is a new version of this patch, including the style fixes
suggested by Richard.

Thomas.

*** gcc-3.2.3.dist/gcc/prefix.c	2001-10-11 05:15:55.000000000 +0200
--- gcc-3.2.3/gcc/prefix.c	2004-04-20 15:29:24.000000000 +0200
***************
*** 242,250 ****
    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.  */
  
  char *
  update_path (path, key)
--- 242,250 ----
    while (*string++);
  }
  
! /* 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 (path, key)
***************
*** 252,259 ****
    const char *key;
  {
    char *result;
  
!   if (! strncmp (path, std_prefix, strlen (std_prefix)) && key != 0)
      {
        bool free_key = false;
  
--- 252,266 ----
    const char *key;
  {
    char *result;
+   const int len = strlen (std_prefix);
  
!   if (! strncmp (path, std_prefix, len)
!       && (path[len] == '/'
! #ifdef DIR_SEPARATOR
!           || path[len] == DIR_SEPARATOR
! #endif
!           || path[len] == '\0')
!       && key != 0)
      {
        bool free_key = false;
  
***************
*** 263,269 ****
  	  free_key = true;
  	}
  
!       result = concat (key, &path[strlen (std_prefix)], NULL);
        if (free_key)
  	free ((char *) key);
        result = translate_name (result);
--- 270,276 ----
  	  free_key = true;
  	}
  
!       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



More information about the Gcc-patches mailing list