Date: Thu, 03 Sep 2009 15:25:26 +0200 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Joerg Sonnenberger <joerg@britannica.bec.de> Cc: svn-src-all@freebsd.org Subject: Re: svn commit: r196752 - head/lib/libc/stdtime Message-ID: <86vdk0upmh.fsf@ds4.des.no> In-Reply-To: <20090903115416.GB448@britannica.bec.de> (Joerg Sonnenberger's message of "Thu, 3 Sep 2009 13:54:16 %2B0200") References: <200909020456.n824uUqQ082136@svn.freebsd.org> <20090902070808.GA1290@arthur.nitro.dk> <20090902084002.GA17325@nagual.pp.ru> <867hwgcwvo.fsf@ds4.des.no> <20090903084325.GA65192@nagual.pp.ru> <86zl9c9z05.fsf@ds4.des.no> <20090903115416.GB448@britannica.bec.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Joerg Sonnenberger <joerg@britannica.bec.de> writes: > Dag-Erling Sm=C3=B8rgrav <des@des.no> writes: > > @@ -65,6 +65,15 @@ > > .It "\&031\ EM \t032\ SUB \t033\ ESC \t034\ FS \t035\ GS" > > .It "\&036\ RS \t037\ US \t177\ DEL" > > .El > > +.Pp > > +.Em NOTE : > > +if the value passed to the > > +.Fn iscntrl > > +function is a > > +.Vt signed char , > > +as is usually the case, it must be cast to an > > +.Vt unsigned char > > +to avoid sign-extension errors. > > .Sh RETURN VALUES > > The > > .Fn iscntrl > This is actually not good enough. ISO C doesn't specify whether plain > char is signed or unsigned. This is FreeBSD. Our char is signed. On systems where it isn't (IRIX is the only one I know of), the cast is a no-op. > Also, isascii is the only exception to this rule, so the change for that > is wrong. No. The fact that isascii() accidentally returns the correct answer even in the absence of a cast is irrelevant. Passing a signed char to isascii() invokes undefined behavior. 7.4 Character handling <ctype.h> 1 The header <ctype.h> declares several functions useful for classifying and mapping characters.166) In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86vdk0upmh.fsf>