Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Oct 1997 15:03:07 +0300 (MSK)
From:      =?KOI8-R?B?4c7E0sXKIP7F0s7P1w==?= <ache@nagual.pp.ru>
To:        Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: cvs commit: src/gnu/usr.bin/diff system.h
Message-ID:  <Pine.BSF.3.96.971026145508.3606A-100000@lsd.relcom.eu.net>
In-Reply-To: <199710261149.MAA07531@rvc1.informatik.ba-stuttgart.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 26 Oct 1997, Wolfgang Helbig wrote:

> > ache        1997/10/22 19:22:52 PDT
> > 
> >   Modified files:
> >     gnu/usr.bin/diff     system.h 
> >   Log:
> >   Add (unsigned char) cast to ctype macros
> >   
> >   Revision  Changes    Path
> >   1.4       +5 -5      src/gnu/usr.bin/diff/system.h
> 
> Should all char arguments to all ctype macros (isspace, isdigit
> ...) in our source tree be cast to unsigned char?
> 
> Quite a lot of them aren't.

Those ctype macros are pain. General rule is that only EOF,0..255 range
is allowed per POSIX and ANSI. It means that ctype(char) is illegal
if char have 8bit set, because negative sign extension happens. Possible
workarounds:
1) If the program assumes ASCII-only, test isascii() before any ctype
macro call.
2) Add (unsigned char) cast to all ctype macros calls. Direct cast mask
possible programmer errors like ctype(s) instead of ctype(*s).
3) Add -funsigned-char to CFLAGS, it seems to be best way unless some
programs assume that char is signed somewhere. Many old BSD programs does.

-- 
Andrey A. Chernov
<ache@nietzsche.net>
http://www.nagual.pp.ru/~ache/




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.971026145508.3606A-100000>