From owner-freebsd-current@FreeBSD.ORG Wed Oct 13 12:28:56 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 15DBA16A4CE for ; Wed, 13 Oct 2004 12:28:56 +0000 (GMT) Received: from acampi.inet.it (acampi.inet.it [213.92.1.165]) by mx1.FreeBSD.org (Postfix) with ESMTP id C4CE443D2F for ; Wed, 13 Oct 2004 12:28:55 +0000 (GMT) (envelope-from andrea@acampi.inet.it) Received: by acampi.inet.it (Postfix, from userid 1000) id 7F4BC23; Wed, 13 Oct 2004 14:28:54 +0200 (CEST) Date: Wed, 13 Oct 2004 14:28:54 +0200 From: Andrea Campi To: current@freebsd.org Message-ID: <20041013122854.GA53717@webcom.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i Subject: nitpicking on strcasestr.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2004 12:28:56 -0000 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.