Return to BSD News archive
Path: sserve!manuel!munnari.oz.au!sgiblab!spool.mu.edu!uwm.edu!rutgers!modus!gear!am!alex From: alex@am.sublink.org (Alex Martelli) Newsgroups: comp.unix.bsd Subject: Re: 386BSD's non-standard C library Message-ID: <1992Oct04.090410.26720@am.sublink.org> Date: 4 Oct 92 09:04:10 GMT References: <1992Sep24.031603.21009@minyos.xx.rmit.oz.au> <wutcd.717452137@hadrian> Organization: Premiata Famiglia Martelli & Figli Lines: 23 wutcd@chemnitz.guug.de (Joerg Wunsch) writes: :>Oops, Kendall is quiet right with his remarks. Of course, the existing :>versions of tolower()/toupper() aren't right. The macros may be omitted, :>(does ANSI really state there must be _macros_ for this???), but the :>functions in /usr/src/lib/libc/gen/isctype.c do the same dirty job. :>They should be patched to test for isupper()/islower() before applying :>the diff value - but this value must be taken from the character class :>definition (as the is*() functions already do). :>If i have half an hour left, i'll post the diff's - all the other people :>surely will make this themself. I once benchmarked the is*() and to*() functions from ctype.h as macros using table-lookup instead and got huge speedups... that was in some PC C compiler long ago, but I believe a simple lookup will still be superior to a comparison, if and addition, and you need only pay a few hundred bytes (256 each for toupper(), tolower(), and is*() since the latter can make do with 1 byte/char by using the bits as flags for lowercase, uppercase, digit, etc, for example isalnum() will do the lookup and & the flag byte with (ISLOWER|ISUPPER|ISDIGIT)). -- Alex Martelli - alex@am.sublink.org - +39 (51) 250434 - Bologna, Italia