From owner-freebsd-hackers Mon Oct 16 06:43:48 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id GAA08154 for hackers-outgoing; Mon, 16 Oct 1995 06:43:48 -0700 Received: from sovcom.kiae.su (sovcom.kiae.su [144.206.136.1]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id GAA08145 for ; Mon, 16 Oct 1995 06:43:23 -0700 Received: by sovcom.kiae.su id AA19029 (5.65.kiae-1 ); Mon, 16 Oct 1995 16:34:14 +0300 Received: by sovcom.KIAE.su (UUMAIL/2.0); Mon, 16 Oct 95 16:34:14 +0300 Received: (from ache@localhost) by ache.dialup.demos.ru (8.6.11/8.6.9) id QAA07072; Mon, 16 Oct 1995 16:32:25 +0300 To: bde@zeta.org.au, j@uriah.heep.sax.de Cc: hackers@freefall.freebsd.org, kaleb@x.org References: <199510161316.XAA28075@godzilla.zeta.org.au> In-Reply-To: <199510161316.XAA28075@godzilla.zeta.org.au>; from Bruce Evans at Mon, 16 Oct 1995 23:16:52 +1000 Message-Id: Organization: Olahm Ha-Yetzirah Date: Mon, 16 Oct 1995 16:32:25 +0300 (MSK) X-Mailer: Mail/@ [v2.40 FreeBSD] From: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?= (aka Andrey A. Chernov, Black Mage) X-Class: Fast Subject: Re: A couple problems in FreeBSD 2.1.0-950922-SNAP Lines: 64 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Length: 2295 Sender: owner-hackers@FreeBSD.org Precedence: bulk In message <199510161316.XAA28075@godzilla.zeta.org.au> Bruce Evans writes: >>>programs in /bin and /sbin - grep shows "ctype.h" in only 25 out of 80 >>>programs in /usr/src/[s]bin. >>It isn't accurate results. Many libc functions calls ctype >>indirecly, i.e. strtol, atoi, etc. You additionly need >>to grep ctype through libc and then grep function you got >>through bin/sbin. I suspect that 100% of programs use ctype >>for accurate results. >strtoul etc. assume the C locale, not to mention the ASCII collating >sequence for alpha characters. From strtoul.c: > register unsigned char c; > ... > if (!isascii(c)) > break; > if (isdigit(c)) > c -= '0'; > else if (isalpha(c)) > c -= isupper(c) ? 'A' - 10 : 'a' - 10; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > else > break; > if (c >= base) > break; >The man page says that the base must be <= 36, but this isn't checked for. >The above would be less incorrect if it checked for c in the range >[a-z] or [A-Z]. Then it would only be assuming an ASCII collating sequence >and not the C locale. Well, it is somewhat inaccurate again :-) Drums............ strtol uses isspace()!!! Even ISO8859-1 have additional space != ' ' (a0 if I remember right). CP866 have additional space too. Probably it doesn't play big role when number enters from terminal, but when some document parsed, it can easily contains various kinds of spaces. >>>[bloat] >>3) I don't see proper way to avoid it for statically compiled >>pgms, so I don't understand what we can discuss here. Yes >>it isn't very good. Alternatives? >Perhaps something can be done using linker tricks. We need: > if (ctype is really used (strtoul etc. don't count :-)) > link to current _startup_setlocale > else > link to dummy _startup_setlocale I agree with this proposal, but we need to count pure-ASCII ctype functions first before doing that. I suspect (I am not prove it yet :-) that pure-ASCII functions are rare thing. strtol isn't pure-ASCII f.e. -- Andrey A. Chernov : And I rest so composedly, /Now, in my bed, ache@astral.msk.su : That any beholder /Might fancy me dead - FidoNet: 2:5020/230.3 : Might start at beholding me, /Thinking me dead. RELCOM Team,FreeBSD Team : E.A.Poe From "For Annie" 1849