Newsgroup: comp.lang.c


Article 29982 of comp.lang.c:
Newsgroups: comp.lang.c
Path: icdoc!dds
From: dds@doc.ic.ac.uk (Diomidis Spinellis)
Subject: Re: isalpha in ctype.h
Message-ID: <1991Mar26.105925.28785@doc.ic.ac.uk>
Sender: usenet@doc.ic.ac.uk (News)
Nntp-Posting-Host: gould.doc.ic.ac.uk
Organization: Dept. of Computing, Imperial College, London, England
References: <1991Mar20.112543.5515@ericsson.se> <collinsa.669647114@p4.cs.man.ac.uk>
Date: Tue, 26 Mar 1991 10:59:25 GMT
Content-Length: 1103
In article <collinsa.669647114@p4.cs.man.ac.uk> collinsa@p4.cs.man.ac.uk (Adrian Collins) writes:
>In <1991Mar20.112543.5515@ericsson.se> etxnisj@eos8c21.ericsson.se (Niklas Sjovall) writes:
>
[...]
>>#define	isalpha(c)	((_ctype_+1)[c]&(_U|_L))
> 
>>It's the part (_ctype_+1)[c] i don't understand. Could there be any
>>segmentation errors using this?
[...]
> For some reason the first entry in the array isn't used for holding
> character type information (beats me why), in which case the array is
> probably 257 in length presuming it isn't null terminated.

In this particular implementation _ctype_[0] holds the type value of
the special constant, defined in stdio.h, EOF which happens to have
the value of -1.  Thus _ctype_[0] has the type information for EOF (-1),
_ctype_[1] has the type information for character 0 etc.

Diomidis
-- 
Diomidis Spinellis                  Internet:                 dds@doc.ic.ac.uk
Department of Computing             UUCP:                    ...!ukc!icdoc!dds
Imperial College, London SW7        #define O(b,f,u,s,c,a)b(){int o=f(); ...




Newsgroup comp.lang.c contents
Newsgroup list
Diomidis Spinellis home page

Creative Commons License Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.