[BACK]Return to str.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/str.c between version 1.23 and 1.24

version 1.23, 2007/09/16 15:24:53 version 1.24, 2007/09/17 09:28:36
Line 49 
Line 49 
 static bool star_match(const char *, const char *, const char *, const char *);  static bool star_match(const char *, const char *, const char *, const char *);
   
 char *  char *
 Str_concati(const char *s1, const char *e1, const char *s2, const char *e2,  Str_concati(const char *s1, const char *e1, const char *s2, const char *e2,
     int sep)      int sep)
 {  {
         size_t len1, len2;          size_t len1, len2;
Line 151 
Line 151 
                         *t++ = '\0';                          *t++ = '\0';
                         if (argc == argmax) {                          if (argc == argmax) {
                                 argmax *= 2;    /* ramp up fast */                                  argmax *= 2;    /* ramp up fast */
                                 argv = erealloc(argv,                                  argv = erealloc(argv,
                                     (argmax + 1) * sizeof(char *));                                      (argmax + 1) * sizeof(char *));
                         }                          }
                         argv[argc++] = start;                          argv[argc++] = start;
Line 235 
Line 235 
 }  }
   
 static bool  static bool
 star_match(const char *string, const char *estring,  star_match(const char *string, const char *estring,
     const char *pattern, const char *epattern)      const char *pattern, const char *epattern)
 {  {
         /* '*' matches any substring.  We handle this by calling ourselves          /* '*' matches any substring.  We handle this by calling ourselves
          * recursively for each postfix of string, until either we match or           * recursively for each postfix of string, until either we match or
          * we reach the end of the string.  */           * we reach the end of the string.  */
         pattern++;          pattern++;
         /* Skip over contiguous  sequences of `?*', so that          /* Skip over contiguous  sequences of `?*', so that
          * recursive calls only occur on `real' characters.  */           * recursive calls only occur on `real' characters.  */
         while (pattern != epattern &&          while (pattern != epattern &&
                 (*pattern == '?' || *pattern == '*')) {                  (*pattern == '?' || *pattern == '*')) {
                 if (*pattern == '?') {                  if (*pattern == '?') {
                         if (string == estring)                          if (string == estring)
Line 257 
Line 257 
         if (pattern == epattern)          if (pattern == epattern)
                 return true;                  return true;
         for (; string != estring; string++)          for (; string != estring; string++)
                 if (Str_Matchi(string, estring, pattern,                  if (Str_Matchi(string, estring, pattern,
                     epattern))                      epattern))
                         return true;                          return true;
         return false;          return false;
Line 269 
Line 269 
         if (*ppat == epattern) {          if (*ppat == epattern) {
                 if (c == '[')                  if (c == '[')
                         return true;                          return true;
                 else                  else
                         return false;                          return false;
         }          }
         if (**ppat == '!' || **ppat == '^') {          if (**ppat == '!' || **ppat == '^') {
                 (*ppat)++;                  (*ppat)++;
                 return !range_match(c, ppat, epattern);                  return !range_match(c, ppat, epattern);
         }          }
         for (;;) {          for (;;) {
                 if (**ppat == '\\') {                  if (**ppat == '\\') {
                         if (++(*ppat) == epattern)                          if (++(*ppat) == epattern)
Line 293 
Line 293 
                         *ppat += 3;                          *ppat += 3;
                 } else                  } else
                         (*ppat)++;                          (*ppat)++;
                 /* The test for ']' is done at the end                  /* The test for ']' is done at the end
                  * so that ']' can be used at the                   * so that ']' can be used at the
                  * start of the range without '\' */                   * start of the range without '\' */
                 if (*ppat == epattern || **ppat == ']')                  if (*ppat == epattern || **ppat == ']')
                         return false;                          return false;
         }          }
         /* Found matching character, skip over rest          /* Found matching character, skip over rest
          * of class.  */           * of class.  */
         while (**ppat != ']') {          while (**ppat != ']') {
                 if (**ppat == '\\')                  if (**ppat == '\\')
                         (*ppat)++;                          (*ppat)++;
                 /* A non-terminated character class                  /* A non-terminated character class
                  * is ok. */                   * is ok. */
                 if (*ppat == epattern)                  if (*ppat == epattern)
                         break;                          break;
Line 314 
Line 314 
 }  }
   
 bool  bool
 Str_Matchi(const char *string, const char *estring,  Str_Matchi(const char *string, const char *estring,
     const char *pattern, const char *epattern)      const char *pattern, const char *epattern)
 {  {
         while (pattern != epattern) {          while (pattern != epattern) {
Line 334 
Line 334 
                 }                  }
                 /* '?' matches any single character, so shunt test.  */                  /* '?' matches any single character, so shunt test.  */
                 else if (*pattern != '?') {                  else if (*pattern != '?') {
                         /* If the next pattern character is '\', just strip                          /* If the next pattern character is '\', just strip
                          * off the '\' so we do exact matching on the                           * off the '\' so we do exact matching on the
                          * character that follows.  */                           * character that follows.  */
                         if (*pattern == '\\') {                          if (*pattern == '\\') {
                                 if (++pattern == epattern)                                  if (++pattern == epattern)

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24