apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr-util/strmatch apr_strmatch.c
Date Sat, 25 May 2002 00:04:57 GMT
jwoolley    02/05/24 17:04:57

  Modified:    strmatch apr_strmatch.c
  Log:
  These functions should be static.
  
  Reported by:  William Rowe
  
  Revision  Changes    Path
  1.5       +48 -45    apr-util/strmatch/apr_strmatch.c
  
  Index: apr_strmatch.c
  ===================================================================
  RCS file: /home/cvs/apr-util/strmatch/apr_strmatch.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -d -u -r1.4 -r1.5
  --- apr_strmatch.c	24 May 2002 14:33:22 -0000	1.4
  +++ apr_strmatch.c	25 May 2002 00:04:57 -0000	1.5
  @@ -60,55 +60,18 @@
   
   #define NUM_CHARS  256
   
  -/* String searching functions
  +/*
  + * String searching functions
    */
  -APU_DECLARE_NONSTD(const char *) match_no_op(const apr_strmatch_pattern *this_pattern,
const char *s, apr_size_t slen);
  -APU_DECLARE_NONSTD(const char *) match_boyer_moore_horspool(const apr_strmatch_pattern
*this_pattern, const char *s, apr_size_t slen);
  -APU_DECLARE_NONSTD(const char *) match_boyer_moore_horspool_nocase(const apr_strmatch_pattern
*this_pattern, const char *s, apr_size_t slen);
  -
  -APU_DECLARE(const apr_strmatch_pattern *)
  -     apr_strmatch_precompile(apr_pool_t *p, const char *s, int case_sensitive)
  -{
  -    apr_strmatch_pattern *pattern;
  -    apr_size_t i;
  -    int *shift;
  -
  -    pattern = apr_palloc(p, sizeof(*pattern));
  -    pattern->pattern = s;
  -    pattern->length = strlen(s);
  -    if (pattern->length == 0) {
  -        pattern->compare = match_no_op;
  -        pattern->context = NULL;
  -        return pattern;
  -    }
  -
  -    shift = (int *)apr_palloc(p, sizeof(int) * NUM_CHARS);
  -    for (i = 0; i < NUM_CHARS; i++) {
  -        shift[i] = pattern->length;
  -    }
  -    if (case_sensitive) {
  -        pattern->compare = match_boyer_moore_horspool;
  -        for (i = 0; i < pattern->length - 1; i++) {
  -            shift[(int)s[i]] = pattern->length - i - 1;
  -        }
  -    }
  -    else {
  -        pattern->compare = match_boyer_moore_horspool_nocase;
  -        for (i = 0; i < pattern->length - 1; i++) {
  -            shift[apr_tolower(s[i])] = pattern->length - i - 1;
  -        }
  -    }
  -    pattern->context = shift;
  -
  -    return pattern;
  -}
  -
  -APU_DECLARE_NONSTD(const char *) match_no_op(const apr_strmatch_pattern *this_pattern,
const char *s, apr_size_t slen)
  +static const char *match_no_op(const apr_strmatch_pattern *this_pattern,
  +                               const char *s, apr_size_t slen)
   {
       return s;
   }
   
  -APU_DECLARE_NONSTD(const char *) match_boyer_moore_horspool(const apr_strmatch_pattern
*this_pattern, const char *s, apr_size_t slen)
  +static const char *match_boyer_moore_horspool(
  +                               const apr_strmatch_pattern *this_pattern,
  +                               const char *s, apr_size_t slen)
   {
       const char *s_end = s + slen;
       int *shift = (int *)(this_pattern->context);
  @@ -130,7 +93,9 @@
       return NULL;
   }
   
  -APU_DECLARE_NONSTD(const char *) match_boyer_moore_horspool_nocase(const apr_strmatch_pattern
*this_pattern, const char *s, apr_size_t slen)
  +static const char *match_boyer_moore_horspool_nocase(
  +                               const apr_strmatch_pattern *this_pattern,
  +                               const char *s, apr_size_t slen)
   {
       const char *s_end = s + slen;
       int *shift = (int *)(this_pattern->context);
  @@ -150,4 +115,42 @@
           s_next += shift[(int)*((const unsigned char *)s_next)];
       }
       return NULL;
  +}
  +
  +APU_DECLARE(const apr_strmatch_pattern *) apr_strmatch_precompile(
  +                                              apr_pool_t *p, const char *s,
  +                                              int case_sensitive)
  +{
  +    apr_strmatch_pattern *pattern;
  +    apr_size_t i;
  +    int *shift;
  +
  +    pattern = apr_palloc(p, sizeof(*pattern));
  +    pattern->pattern = s;
  +    pattern->length = strlen(s);
  +    if (pattern->length == 0) {
  +        pattern->compare = match_no_op;
  +        pattern->context = NULL;
  +        return pattern;
  +    }
  +
  +    shift = (int *)apr_palloc(p, sizeof(int) * NUM_CHARS);
  +    for (i = 0; i < NUM_CHARS; i++) {
  +        shift[i] = pattern->length;
  +    }
  +    if (case_sensitive) {
  +        pattern->compare = match_boyer_moore_horspool;
  +        for (i = 0; i < pattern->length - 1; i++) {
  +            shift[(int)s[i]] = pattern->length - i - 1;
  +        }
  +    }
  +    else {
  +        pattern->compare = match_boyer_moore_horspool_nocase;
  +        for (i = 0; i < pattern->length - 1; i++) {
  +            shift[apr_tolower(s[i])] = pattern->length - i - 1;
  +        }
  +    }
  +    pattern->context = shift;
  +
  +    return pattern;
   }
  
  
  

Mime
View raw message