Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Oct 2004 08:50:26 -0400
From:      Thomas Dickey <dickey@radix.net>
To:        current@freebsd.org
Subject:   Re: nitpicking on strcasestr.c
Message-ID:  <20041013125026.GA10241@saltmine.radix.net>
In-Reply-To: <20041013122854.GA53717@webcom.it>
References:  <20041013122854.GA53717@webcom.it>

next in thread | previous in thread | raw e-mail | index | archive | help

--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 13, 2004 at 02:28:54PM +0200, Andrea Campi wrote:
=20
> 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?

man tolower (Solaris - but if FreeBSD differs, someone has a problem):

NAME
     tolower - transliterate upper-case characters to lower-case

SYNOPSIS
     #include <ctype.h>

     int tolower(int c);
=20
> 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....

Noting that tolower() returns an int, and char's sign is unspecified,
either changing the type for c (to int) or adding a cast is a good
idea.  Adding casts is generally a bad idea.

--=20
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

--FCuugMFkClbJLl1L
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (SunOS)
Comment: For info see http://www.gnupg.org

iD8DBQFBbSSLtIqByHxlDocRAkyiAJ9y6PBJyYrr7NtJmzQRrKuP6nIgkACcCYFj
2ZuCwuXask1t6r5PdCOjC7U=
=q4bD
-----END PGP SIGNATURE-----

--FCuugMFkClbJLl1L--



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