httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c
Date Sun, 03 Aug 2003 20:15:50 GMT
nd          2003/08/03 13:15:50

  Modified:    modules/mappers mod_rewrite.c
  Log:
  cleanup compare_lexicography function.
  - improve readability
  - make sure that unsigned chars are compared
  - use apr_size_t for string lengths
  
  Revision  Changes    Path
  1.215     +14 -18    httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.214
  retrieving revision 1.215
  diff -u -r1.214 -r1.215
  --- mod_rewrite.c	3 Aug 2003 19:50:26 -0000	1.214
  +++ mod_rewrite.c	3 Aug 2003 20:15:50 -0000	1.215
  @@ -3216,28 +3216,24 @@
    */
   
   /* Lexicographic Compare */
  -static APR_INLINE int compare_lexicography(char *cpNum1, char *cpNum2)
  +static APR_INLINE int compare_lexicography(char *a, char *b)
   {
  -    int i;
  -    int n1, n2;
  +    apr_size_t i, lena, lenb;
   
  -    n1 = strlen(cpNum1);
  -    n2 = strlen(cpNum2);
  -    if (n1 > n2) {
  -        return 1;
  -    }
  -    if (n1 < n2) {
  -        return -1;
  -    }
  -    for (i = 0; i < n1; i++) {
  -        if (cpNum1[i] > cpNum2[i]) {
  -            return 1;
  -        }
  -        if (cpNum1[i] < cpNum2[i]) {
  -            return -1;
  +    lena = strlen(a);
  +    lenb = strlen(b);
  +
  +    if (lena == lenb) {
  +        for (i = 0; i < lena; ++i) {
  +            if (a[i] != b[i]) {
  +                return ((unsigned char)a[i] > (unsigned char)b[i]) ? 1 : -1;
  +            }
           }
  +
  +        return 0;
       }
  -    return 0;
  +
  +    return ((lena > lenb) ? 1 : -1);
   }
   
   /*
  
  
  

Mime
View raw message