nitpicking on strcasestr.c
Andrea Campi
andrea+freebsd_current at webcom.it
Wed Oct 13 05:28:56 PDT 2004
Hi,
I just noticed a couple of things in strcasestr.c which cause
warnings on ${OTHER_OS}, but still apply to us:
char *
strcasestr(s, find)
const char *s, *find;
{
char c, sc;
size_t len;
if ((c = *find++) != 0) {
c = tolower((unsigned char)c);
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
} while ((char)tolower((unsigned char)sc) != c);
} while (strncasecmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
We have two calls to tolower(); the first doesn't cast the result
at all, the second one casts it to char. Shouldn't the first one be
changed also?
Actually, my first feeling was to change both to unsigned char, but
I'm sure somebody could go to great lenghts to explain to me how the
code as it stands is carefully crafted to work whether chars are signed
or unsigned....
Bye,
Andrea
--
Speak softly and carry a cellular phone.
More information about the freebsd-current
mailing list