Programming and international chara

Richard A. O'Keefe ok at quintus.uucp
Tue Nov 8 12:30:45 AEST 1988


In article <44200016 at uicsrd.csrd.uiuc.edu> mcdaniel at uicsrd.csrd.uiuc.edu writes:
>One possible
>macro implementation is:
>	#define iscntrl(c)	( (c) >= 0 && (c) <= 037 )
>
>(The first test is because implementations are permitted by dpANS to
>have signed characters.)  In this case, if "c" has side effects, the
>side effects will be performed twice.

A reasonably well-known hack, where L and U are constant integer expressions,
is	#define inrange(x,L,U) ((unsigned)((x)-(L)) <= (unsigned)((U)-(L)))
It has the virtue that x is evaluated only once.  In this case:
	*define iscntrl(c) ((unsigned)(c) < 32)
I say "*define" because the usual definition of iscntrl() for ASCII
includes DEL as one of the cntrl characters.



More information about the Comp.lang.c mailing list