Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!icdoc!dds From: dds@doc.ic.ac.uk (Diomidis Spinellis) Newsgroups: comp.lang.c Subject: Re: isalpha in ctype.h Message-ID: <1991Mar26.105925.28785@doc.ic.ac.uk> Date: 26 Mar 91 10:59:25 GMT References: <1991Mar20.112543.5515@ericsson.se> Sender: usenet@doc.ic.ac.uk (News) Organization: Dept. of Computing, Imperial College, London, England Lines: 23 Nntp-Posting-Host: gould.doc.ic.ac.uk In article 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(); ...