coar        98/06/20 06:12:36

  Modified:    src/main fnmatch.c
  Log:
        Sincethis has been modified for Apache, modify it some more
        (cosmetically) to meet our style guide.
  
  Revision  Changes    Path
  1.10      +50 -36    apache-1.3/src/main/fnmatch.c
  
  Index: fnmatch.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/fnmatch.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- fnmatch.c 1998/04/11 12:00:28     1.9
  +++ fnmatch.c 1998/06/20 13:12:36     1.10
  @@ -51,76 +51,84 @@
   
   static const char *rangematch(const char *, int, int);
   
  -API_EXPORT(int) ap_fnmatch(pattern, string, flags)
  -     const char *pattern, *string;
  -     int flags;
  +API_EXPORT(int) ap_fnmatch(const char *pattern, const char *string, int 
flags)
   {
       const char *stringstart;
       char c, test;
   
  -    for (stringstart = string;;)
  +    for (stringstart = string;;) {
        switch (c = *pattern++) {
        case EOS:
            return (*string == EOS ? 0 : FNM_NOMATCH);
        case '?':
  -         if (*string == EOS)
  +         if (*string == EOS) {
                return (FNM_NOMATCH);
  -         if (*string == '/' && (flags & FNM_PATHNAME))
  +         }
  +         if (*string == '/' && (flags & FNM_PATHNAME)) {
                return (FNM_NOMATCH);
  +         }
            if (*string == '.' && (flags & FNM_PERIOD) &&
                (string == stringstart ||
  -              ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
  +              ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
                return (FNM_NOMATCH);
  +         }
            ++string;
            break;
        case '*':
            c = *pattern;
            /* Collapse multiple stars. */
  -         while (c == '*')
  +         while (c == '*') {
                c = *++pattern;
  +         }
   
            if (*string == '.' && (flags & FNM_PERIOD) &&
                (string == stringstart ||
  -              ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
  +              ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
                return (FNM_NOMATCH);
  +         }
   
            /* Optimize for pattern with * at end or before /. */
            if (c == EOS) {
                if (flags & FNM_PATHNAME) {
  -                 return (strchr(string, '/') == NULL ?
  -                         0 : FNM_NOMATCH);
  +                 return (strchr(string, '/') == NULL ? 0 : FNM_NOMATCH);
                }
                else {
                    return (0);
                }
            }
            else if (c == '/' && flags & FNM_PATHNAME) {
  -             if ((string = strchr(string, '/')) == NULL)
  +             if ((string = strchr(string, '/')) == NULL) {
                    return (FNM_NOMATCH);
  +             }
                break;
            }
   
            /* General case, use recursion. */
            while ((test = *string) != EOS) {
  -             if (!ap_fnmatch(pattern, string, flags & ~FNM_PERIOD))
  +             if (!ap_fnmatch(pattern, string, flags & ~FNM_PERIOD)) {
                    return (0);
  -             if (test == '/' && flags & FNM_PATHNAME)
  +             }
  +             if (test == '/' && flags & FNM_PATHNAME) {
                    break;
  +             }
                ++string;
            }
            return (FNM_NOMATCH);
        case '[':
  -         if (*string == EOS)
  +         if (*string == EOS) {
                return (FNM_NOMATCH);
  -         if (*string == '/' && flags & FNM_PATHNAME)
  +         }
  +         if (*string == '/' && flags & FNM_PATHNAME) {
                return (FNM_NOMATCH);
  +         }
            if (*string == '.' && (flags & FNM_PERIOD) &&
                (string == stringstart ||
  -             ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
  -                 return (FNM_NOMATCH);
  -         if ((pattern =
  -              rangematch(pattern, *string, flags)) == NULL)
  +              ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
  +             return (FNM_NOMATCH);
  +         }
  +         if ((pattern = rangematch(pattern, *string, flags)) == NULL) {
                return (FNM_NOMATCH);
  +         }
            ++string;
            break;
        case '\\':
  @@ -131,18 +139,17 @@
                }
            }
            /* FALLTHROUGH */
  -         default:
  -             if (c != *string++)
  +     default:
  +         if (c != *string++) {
                return (FNM_NOMATCH);
  +         }
            break;
        }
       /* NOTREACHED */
  +    }
   }
   
  -static const char *
  -     rangematch(pattern, test, flags)
  -     const char *pattern;
  -     int test, flags;
  +static const char *rangematch(const char *pattern, int test, int flags)
   {
       int negate, ok;
       char c, c2;
  @@ -154,26 +161,32 @@
        * consistency with the regular expression syntax.
        * J.T. Conklin ([EMAIL PROTECTED])
        */
  -    if ((negate = (*pattern == '!' || *pattern == '^')))
  +    if ((negate = (*pattern == '!' || *pattern == '^'))) {
        ++pattern;
  +    }
   
       for (ok = 0; (c = *pattern++) != ']';) {
  -     if (c == '\\' && !(flags & FNM_NOESCAPE))
  +        if (c == '\\' && !(flags & FNM_NOESCAPE)) {
            c = *pattern++;
  -     if (c == EOS)
  +     }
  +     if (c == EOS) {
            return (NULL);
  -     if (*pattern == '-'
  -         && (c2 = *(pattern + 1)) != EOS && c2 != ']') {
  +     }
  +     if (*pattern == '-' && (c2 = *(pattern + 1)) != EOS && c2 != ']') {
            pattern += 2;
  -         if (c2 == '\\' && !(flags & FNM_NOESCAPE))
  +         if (c2 == '\\' && !(flags & FNM_NOESCAPE)) {
                c2 = *pattern++;
  -         if (c2 == EOS)
  +         }
  +         if (c2 == EOS) {
                return (NULL);
  -         if (c <= test && test <= c2)
  +         }
  +         if (c <= test && test <= c2) {
                ok = 1;
  +         }
        }
  -     else if (c == test)
  +     else if (c == test) {
            ok = 1;
  +     }
       }
       return (ok == negate ? NULL : pattern);
   }
  @@ -203,8 +216,9 @@
            break;
   
        case ']':
  -         if (nesting)
  +         if (nesting) {
                return 1;
  +         }
            break;
        }
        ++pattern;
  
  
  

Reply via email to