Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Message-ID: <4249@goanna.cs.rmit.oz.au> Date: 12 Nov 90 12:58:59 GMT References: <11021@hubcap.clemson.edu> <152580@felix.UUCP> <1990Nov12.040933.5419@sq.sq.com> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 16 In article <1990Nov12.040933.5419@sq.sq.com>, msb@sq.sq.com (Mark Brader) writes: > # define IS_CTYPABLE(c) (((c) < UCHAR_MAX && (c) >= 0) || (c) == EOF) Knowing that EOF is -1, one could do this with one evaluation of (c) -- always a courteous thing to do in a macro -- # define IS_CTYPABLE(c) \ ((unsigned)((c)+EOF) < (unsigned)(UCHAR_MAX+EOF)) I've never used isascii() myself because I had always constructed the program so that I knew the codes were in range without needing a run- time test; if you've got something you _think_ is a character and it's outside the range that the ctype macros can handle what can you do but report an error, and why leave it that late to check? -- The problem about real life is that moving one's knight to QB3 may always be replied to with a lob across the net. --Alasdair Macintyre.