From: vischne AT ibm DOT net Subject: Re: ctype.h and serious programming 17 Feb 1998 17:18:25 -0800 Message-ID: <199802171815.SAA09220.cygnus.gnu-win32@out4.ibm.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: gnu-win32 AT cygnus DOT com > Earnie Boyd (earnie_boyd AT hotmail DOT com) > Tue, 17 Feb 1998 05:40:27 PST >>From: vischne AT ibm DOT net >>Date: Tue, 17 Feb 1998 02:42:09 GMT >>If you've done some porting to cygwin, you'll notice that ctype.h often >>gives syntax errors. Out of curiosity, I substituted >>from the linux kernel source for the cygwin version (leaving the cygwin >>headers in place), and got much cleaner compiles. Is there a technical >>reason why , which is a pure macro version, shouldn't >>replace cygwin's ? > >It appears that ctype.h as supplied by cygnus needs some work with the >#ifdef __GNUC__ ... #endif logic. Based on the comment "non-gcc >versions will get the library versions, and will be slightly slower" the >code should be structured as follows: > >#ifdef __GNUC__ > >#define MACROS > >#else > >int _EXFUN(...) > >#endif > I used your idea to rewrite ctype.h, and it seems to work, at least with tkman1-5, which crashed with earlier versions of ctype.h. I wonder what it takes to get it included with the next release? ========================================================================= ========================================================================= #ifndef _CTYPE_H_ #ifdef __cplusplus extern "C" { #endif #define _CTYPE_H_ #ifdef __GNUC__ #define _U 0x01 /* upper */ #define _L 0x02 /* lower */ #define _D 0x04 /* digit */ #define _C 0x08 /* cntrl */ #define _P 0x10 /* punct */ #define _S 0x20 /* white space (space/lf/tab) */ #define _X 0x40 /* hex digit */ #define _SP 0x80 /* hard space (0x20) */ #define isalnum(c) (((unsigned)(c))&(_U|_L|_D)) #define isalpha(c) (((unsigned)(c))&(_U|_L)) #define iscntrl(c) (((unsigned)(c))&(_C)) #define isdigit(c) (((unsigned)(c))&(_D)) #define isgraph(c) (((unsigned)(c))&(_P|_U|_L|_D)) #define islower(c) (((unsigned)(c))&(_L)) #define isprint(c) (((unsigned)(c))&(_P|_U|_L|_D|_SP)) #define ispunct(c) (((unsigned)(c))&(_P)) #define isspace(c) (((unsigned)(c))&(_S)) #define isupper(c) (((unsigned)(c))&(_U)) #define isxdigit(c) (((unsigned)(c))&(_D|_X)) #define isascii(c) (((unsigned)(c))<=0x7f) #define toascii(c) (((unsigned)(c))&0x7f) #define tolower(c) (isupper(c)?((c)-('A'-'a')):(c)) #define toupper(c) (islower(c)?((c)-('a'-'A')):(c)) #else /* !GNUC */ #include "_ansi.h" int _EXFUN(isalnum, (int c)); int _EXFUN(isalpha, (int c)); int _EXFUN(iscntrl, (int c)); int _EXFUN(isdigit, (int c)); int _EXFUN(isgraph, (int c)); int _EXFUN(islower, (int c)); int _EXFUN(isprint, (int c)); int _EXFUN(ispunct, (int c)); int _EXFUN(isspace, (int c)); int _EXFUN(isupper, (int c)); int _EXFUN(isxdigit,(int c)); int _EXFUN(tolower, (int c)); int _EXFUN(toupper, (int c)); #ifndef _STRICT_ANSI int _EXFUN(isascii, (int c)); int _EXFUN(toascii, (int c)); int _EXFUN(_tolower, (int c)); int _EXFUN(_toupper, (int c)); #endif #endif /* GNUC */ #ifdef __cplusplus } #endif #endif /* _CTYPE_H_ */ - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".