From cvs-return-16744-apmail-httpd-cvs-archive=httpd.apache.org@httpd.apache.org Sun Aug 03 20:15:40 2003 Return-Path: Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 43915 invoked by uid 500); 3 Aug 2003 20:15:40 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 43904 invoked by uid 500); 3 Aug 2003 20:15:39 -0000 Delivered-To: apmail-httpd-2.0-cvs@apache.org Date: 3 Aug 2003 20:15:50 -0000 Message-ID: <20030803201550.26819.qmail@minotaur.apache.org> From: nd@apache.org To: httpd-2.0-cvs@apache.org Subject: cvs commit: httpd-2.0/modules/mappers mod_rewrite.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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); } /*