Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: isalpha in ctype.h Message-ID: <5019@goanna.cs.rmit.oz.au> Date: 21 Mar 91 04:04:03 GMT References: <1991Mar20.112543.5515@ericsson.se> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 24 In article <1991Mar20.112543.5515@ericsson.se>, etxnisj@eos8c21.ericsson.se (Niklas Sjovall) writes: > I want to use a macro defined in ctype.h on a Sun4 (4.03), but i don't > fully understand it. You should read the manual page. That tells you everything you need to know in order to USE the macro. In UNIX, it used to be the case that the macros were defined for EOF (-1) and for the integers which satisfy isascii(). In ANSI C, the macros are defined for EOF and for any value representable as unsigned char. Think -1..255. > It's the part (_ctype_+1)[c] i don't understand. Could there be any > segmentation errors using this? (_ctype_+1)[c] is identical to *((_ctype_+1)+(c)) which is identical to _ctype_[(c)+1]. The +1 is there to map the lowest legal value EOF (-1) to 0 (the lowest element of the array). If you had full sources you'd probably find char _ctype_[257]; somewhere. Yes, of course there can be segmentation errors using this, if the value of c is outside the range -1 .. UCHAR_MAX, but you have to keep your subscripts in range for _any_ C array. -- Seen from an MVS perspective, UNIX and MS-DOS are hard to tell apart.