httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Douglass <>
Subject Re: Closing strcasestr discussion...
Date Fri, 12 Jul 1996 14:47:02 GMT
On Fri, 12 Jul 1996, Roy T. Fielding wrote:

>   char *strcasestr( char *s1, char *s2 )
>   {
>       int len1 = strlen(s1);
>       int len2 = strlen(s2);
>       while (*s1 && (len1 >= len2)) {
>           if (!strncasecmp(s1, s2, len2))
>               return s1;
>           s1++;
>           len1--;
>       }
>       return NULL;
>   }

That's a point I brought up, but in actual testing there was again zero
difference between this particular method and the method where it uses
strncasecmp on the entire s1 string.  I would tend to believe that the
first thing str[ncase]cmp does is make sure that the string sizes match?
At least possibly in the gnu libs.  Like I said, I'm going to have to
go look at the actual implementation of strncasecmp() to see exactly
what they are doing in the libs.

Michael Douglass
Texas Networking, Inc.

  "To be a saint is to be an exception; to be a true man is the rule.
   Err, fail, sin if you must, but be upright.  To sin as little as
   possible is the law for men; to sin not at all is a dream for angels."

              - Victor Hugo, "Les Miserables"

View raw message