apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: cvs commit: apr-util/strmatch apr_strmatch.c
Date Fri, 24 May 2002 14:03:15 GMT
Jeff Trawick <trawick@attglobal.net> writes:

> brianp@apache.org writes:
> 
> > brianp      02/05/23 18:07:47
> > 
> >   Modified:    strmatch apr_strmatch.c
> >   Log:
> >   Switched to unsigned chars in the searching functions to avoid
> >   problems when input strings contain character values > 127
> >   Reported by: Cliff Woolley
> 
> ouch, lots of compile errors with native compiler on AIX (invalid
> operations between pointers to char of different signed-ness)
> 
> I'll start playing with this in a minute...

I guess this patch is appropriate unless we want to change the API.
Darn signed chars :)

Index: srclib/apr-util/strmatch/apr_strmatch.c
===================================================================
RCS file: /home/cvs/apr-util/strmatch/apr_strmatch.c,v
retrieving revision 1.3
diff -u -r1.3 apr_strmatch.c
--- srclib/apr-util/strmatch/apr_strmatch.c	24 May 2002 01:07:47 -0000	1.3
+++ srclib/apr-util/strmatch/apr_strmatch.c	24 May 2002 13:56:12 -0000
@@ -108,12 +108,13 @@
     return s;
 }
 
-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(const apr_strmatch_pattern *this_pattern,
const char *s_in, apr_size_t slen)
 {
+    const unsigned char *s = (const unsigned char *)s_in;
     const unsigned char *s_end = s + slen;
     int *shift = (int *)(this_pattern->context);
     const unsigned char *s_next = s + this_pattern->length - 1;
-    const unsigned char *p_start = this_pattern->pattern;
+    const unsigned char *p_start = (const unsigned char *)this_pattern->pattern;
     const unsigned char *p_end = p_start + this_pattern->length - 1;
     while (s_next < s_end) {
         const unsigned char *s_tmp = s_next;
@@ -121,7 +122,7 @@
         while (*s_tmp == *p_tmp) {
             p_tmp--;
             if (p_tmp < p_start) {
-                return s_tmp;
+                return (const char *)s_tmp;
             }
             s_tmp--;
         }
@@ -130,12 +131,13 @@
     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)
+APU_DECLARE_NONSTD(const char *) match_boyer_moore_horspool_nocase(const apr_strmatch_pattern
*this_pattern, const char *s_in, apr_size_t slen)
 {
+    const unsigned char *s = (const unsigned char *)s_in;
     const unsigned char *s_end = s + slen;
     int *shift = (int *)(this_pattern->context);
     const unsigned char *s_next = s + this_pattern->length - 1;
-    const unsigned char *p_start = this_pattern->pattern;
+    const unsigned char *p_start = (const unsigned char *)this_pattern->pattern;
     const unsigned char *p_end = p_start + this_pattern->length - 1;
     while (s_next < s_end) {
         const unsigned char *s_tmp = s_next;
@@ -143,7 +145,7 @@
         while (apr_tolower(*s_tmp) == apr_tolower(*p_tmp)) {
             p_tmp--;
             if (p_tmp < p_start) {
-                return s_tmp;
+                return (const char *)s_tmp;
             }
             s_tmp--;
         }

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Mime
View raw message