Sender: vheyndri AT rug DOT ac DOT be Message-Id: <34E00C85.57DE@rug.ac.be> Date: Tue, 10 Feb 1998 09:15:01 +0100 From: Vik Heyndrickx Mime-Version: 1.0 To: DJ Delorie Cc: djgpp-workers AT delorie DOT com Subject: Re: char != unsigned char... sometimes, sigh References: <199802092259 DOT RAA14332 AT delorie DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk The following is an ANSI compliant behaving macro, and it supports also 'signed char' It yields reasonably efficient hard-code. #define isupper(c) ({int t=(c);unsigned v;\ ++t;\ if(t<0)t+=256;\ v=__dj_ctype_flags[t];\ (v&__dj_ISUPPER)!=0;}) The following is an ANSI compliant behaving macro, it supports only 'unsigned char'. It yields the most efficient hard-code possible in many cases. #define isupper(c) ({int t=(c);unsigned v;\ ++t;\ v=__dj_ctype_flags[t];\ (v&__dj_ISUPPER)!=0;}) Note that ANY change you will make to these macro's will turn them less efficient. I know where I am talking about. Note that if the first macro I propose is used on an 'unsigned char', the test whether the value is negative is optimized out by the compiler. The function version could not have this feature of course. -- \ Vik /-_-_-_-_-_-_/ \___/ Heyndrickx / \ /-_-_-_-_-_-_/