httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Douglass <miked...@texas.net>
Subject Re: Too soon for 1.2 commits ??
Date Thu, 11 Jul 1996 17:05:54 GMT
On Thu, 11 Jul 1996, Ben Laurie wrote:

> > Heck, if you were really concerned about time and all, why not write it
> > like this:
> > 
> > char *strcasestr( const char *s1, const char s2) {
> >   int len = strlen(s2)
> >   char *ptr = s1 + len;
> > 
> >   while( s1 < ptr ) {
> >     if ( !strncasecmp( s1, s2, len ) )
> >       return s1;
> >     s1++;
> >   }
> > 
> >   return NULL;
> > }
> 
> Because it doesn't work?

Ok ok ok.. I wrote that really early in the morning... It would
be more like ptr = s1 + strlen(s1) - len ;  That way you stop once
you reach the point that you *know* you won't find it due to the length
of s2...  Oh, and I guess you'd have to make sure that ptr >= s1 so
you don't have an s2 that's larger than s1.. :)

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"


Mime
View raw message