🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #47013

Re: Free reliable wordcount utility available (final version)

#47013
From: Richard Heathfield
Date: Wed, 13 Nov 2002 18:02
95 lines
5570 bytes
"Thomas J. Boschloo" wrote:
> 
> Phil Carmody wrote:
> >
> > On Fri, 08 Nov 2002 15:23:32 +0100, Thomas J. Boschloo wrote:
> > > ISO is not such a big deal to me. I just want my code to be portable and
> > > be able to compile on a lot of different platforms (Solaris and Windows
> > > 2000 at least). I own neither.
> > >
> >
> > and
> >
> > > Have you notices _ctype[] is an array of ints? Do you think it is wise
> > > to waste at least (256+1)*2 bytes of valuable 64kb segmented memory on?
> >
> > There's nothing like consistancy to make an argument more persuasive.
> > And sure enough - that's _nothing_ like consistency.
> 
> You are putting the horse behind the cart, you make sure your program
> runs on ALL platforms, that means you have to make it run on the WORSE
> possible type of computer + compiler.

Yes, that makes sense.

> Not the BEST because not every C
> compiler implements all of ISO.

You'd be hard-pressed to find a C compiler not conforming to ISO/IEC
9899:1990 nowadays (although I don't deny it's possible).

> I think I am talking to deaf mans ears
> here, but I am giving you the benefit of the doubt.
> 
> Can you point out the ANSI-C specs where it says a computer must have
> more than 64kb of memory for its data

It doesn't. The 1990 ISO Standard (which is effectively identical to the
1989 ANSI C Standard) guarantees that a conforming hosted implementation
will allow you at least one object at least 32767 bytes in size. (In
1999, this was increased to 65535, but of course that will only affect
implementations written to conform to the new Standard.)

> and that the isalpha function must
> not be implemented as a memory expensive array of integers

The Standard has nothing to say on this matter. It's a QoI (Quality of
Implementation) issue, not a Standard issue.

> with all
> possible ISO character sets ever forced upon the world by some noisy
> self-important professors and professionals? It's a fast implementation,
> sure, only one memory word access combined with a single logical AND
> function. I couldn't do that much faster myself, but I could do it in a
> lot less memory and a lot more portable than you are forcing on to other
> programmers here. I bet that isalpha just uses [A..Z][a..z][0..9] in
> turbo C (my prefered ANSI-C compiler), my function does a lot more and
> there will be no confusion for people that read it or compiler surprises
> from coding it this way. And also, tell me of a single character set for
> computers that doesn't use the 7-bit ANSI character set.

I think you mean ASCII here; ASCII is a 7-bit character set, but the
so-called "ANSI character set" is an 8-bit character set defined by
ANSI/ISO 8859-1-1987 ("8-bit Single-Byte Coded Graphic Character Sets -
Part 1: Latin Alphabet No 1"), also known more simply as "Latin 1".

> Your point
> about isalpha being better than { if(c>='A' && c<='Z' || c>='a' &&
> c<='z') } is pretty moot to an elite coder as myself (something you will
> never be).

Well, an elite coder would realise that the Standard does not guarantee
that the numeric equivalents of alphabetic characters are contiguous, or
even *ordered*. In EBCDIC, for example, they are not contiguous
(although, thank heaven, they are at least ordered). So if your program
is run on a mainframe, it will flag some characters as letters even
though they are not in fact letters.


> Also, by testing these values cleverly it can be nearly as
> fast as what you in your infinite wisdom are forcing upon other C coders
> in sci.crypt.

He's not forcing anything on anyone. *You* made a portability claim, and
Phil simply pointed out that to use isalpha() is a more portable
technique than if(c >= 'A' etc etc.


<snip>


-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Technical Details
Message-ID: <3DD293CC.6D80A752@eton.powernet.co.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.security.pgp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!peer1.news.newnet.co.uk!lon1-news.nildram.net!195.60.31.14.MISMATCH!news2.power.net.uk!news.power.net.uk
References: <3DC1596C.6D2B55BD@hccnet.nl.invalid> <3DC526FC.CBCFE9B6@hccnet.nl.invalid> <3DC5451F.DBF3CDDA@eton.powernet.co.uk> <pan.2002.11.03.17.05.02.482162@yahoo.co.uk> <3DC81975.45915377@hccnet.nl.invalid> <3DC98ABC.27E67263@eton.powernet.co.uk> <3DCBC8E4.3933993A@hccnet.nl.invalid> <pan.2002.11.11.19.02.32.116865@yahoo.co.uk> <3DD2556C.E1C531B9@hccnet.nl.invalid>

Show Full Headers
Complete Article Headers
Message-ID: <3DD293CC.6D80A752@eton.powernet.co.uk>
Subject: Re: Free reliable wordcount utility available (final version)
Date: Wed, 13 Nov 2002 18:02:52 +0000
From: Richard Heathfield <binary@eton.powernet.co.uk>
References: <3DC1596C.6D2B55BD@hccnet.nl.invalid> <3DC526FC.CBCFE9B6@hccnet.nl.invalid> <3DC5451F.DBF3CDDA@eton.powernet.co.uk> <pan.2002.11.03.17.05.02.482162@yahoo.co.uk> <3DC81975.45915377@hccnet.nl.invalid> <3DC98ABC.27E67263@eton.powernet.co.uk> <3DCBC8E4.3933993A@hccnet.nl.invalid> <pan.2002.11.11.19.02.32.116865@yahoo.co.uk> <3DD2556C.E1C531B9@hccnet.nl.invalid>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.security.pgp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!peer1.news.newnet.co.uk!lon1-news.nildram.net!195.60.31.14.MISMATCH!news2.power.net.uk!news.power.net.uk
Organization: Eton Computer Systems Ltd
X-Mailer: Mozilla 4.6 [en-gb]C-CCK-MCD NetscapeOnline.co.uk (WinNT; I)
X-Accept-Language: en-GB,en
MIME-Version: 1.0
Newsgroups: alt.privacy.anon-server,sci.crypt,alt.fan.cult-dead-cow,alt.security.pgp
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 195.60.5.7
X-Trace: news.power.net.uk 1037212721 195.60.5.7 (13 Nov 2002 18:38:41 GMT)
Lines: 97