Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Oct 2004 14:28:54 +0200
From:      Andrea Campi <andrea+freebsd_current@webcom.it>
To:        current@freebsd.org
Subject:   nitpicking on strcasestr.c
Message-ID:  <20041013122854.GA53717@webcom.it>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041013122854.GA53717>