ctype bug

Joerg Sonnenberger joerg at britannica.bec.de
Wed Jul 6 17:25:36 PDT 2005


On Wed, Jul 06, 2005 at 05:09:40PM -0700, Matthew Dillon wrote:
> 
> :Matt, the ctype macros ALWAYS worked like this, at the very least back to
> :the days of 4.4BSD. THIS IS NOT NEW. Just because some programmers don't like
> :reading the documentation and follow what is clearly written there, doesn't mean
> :that arbitrary changes are correct.
> :
> :Joerg
> 
>     No, they never worked like this.  Go back and look at rev 1.1 of
>     ctype.h in the FreeBSD source repository.  Guess what it does?  It
>     does a range check.

Where? It masks the high bits off, there by mapping 255 and -1 to the same value.
That's not correct.

Just to go back a bit in time, Sys V7 doesn't have any boundary checks:
http://minnie.tuhs.org/UnixTree/V7/usr/include/ctype.h.html
http://minnie.tuhs.org/UnixTree/V7/usr/src/libc/gen/ctype_.c.html

3BSD doesn't have it. http://unix-archive.kalwun.de/4BSD/Distributions/3bsd.tar.gz

Net/2 doesn't have it. http://unix-archive.kalwun.de/4BSD/Distributions/Net2/net2.tar.gz

NetBSD never changed that, either.

So we are talking about a pure FreeBSDism here. And as I pointed out more than once,
they implemented it incorrectly for anything but the C locale in the past.

Joerg





More information about the Commits mailing list