[vlc-devel] commit: Simplify, fix and inline strcasecmp and strncasecmp ( Rémi Denis-Courmont )

Rémi Denis-Courmont rdenis at simphalempin.com
Tue May 27 17:04:17 CEST 2008


Le Tuesday 27 May 2008 13:21:21 Hannes Domani, vous avez écrit :
> > +static inline int strcasecmp (const char *s1, const
> > char *s2)
> > +{
> > +    for (size_t i = 0;; i++)
> > +    {
> > +        int d = tolower (s1[i]) - tolower (s2[i]);
> > +        if (d) return d;
> > +    }
> > +    return 0;
> > +}
>
> what if s1 and s2 are equal?

Fixed, thanks.

> possible solution:
> for (size_t i = 0; s1[i] || s2[i]; i++)

No. That would yield incorrect results if a string is shorter than the other.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list