diff options
author | ache <ache@FreeBSD.org> | 1994-10-08 17:36:44 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-10-08 17:36:44 +0000 |
commit | dcc191d798389eff4df036b2c92800febf349a22 (patch) | |
tree | 0305f53fcb381f666c660c15a38566248edcc01c /include | |
parent | 91339cb74c473eaf6210f73bcd3dfc2883b4a14e (diff) | |
download | FreeBSD-src-dcc191d798389eff4df036b2c92800febf349a22.zip FreeBSD-src-dcc191d798389eff4df036b2c92800febf349a22.tar.gz |
Handle EOF case in all macros by ANSI standard.
Cast all ints < 0 to (unsigned char) to fix common problem
with sign extention on signed char.
Diffstat (limited to 'include')
-rw-r--r-- | include/_ctype.h | 21 | ||||
-rw-r--r-- | include/ctype.h | 21 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/_ctype.h b/include/_ctype.h index a37fc1c..0a34886 100644 --- a/include/_ctype.h +++ b/include/_ctype.h @@ -103,9 +103,18 @@ __END_DECLS #endif #if defined(_USE_CTYPE_INLINE_) + +#ifndef EOF +#define EOF (-1) +#endif + static __inline int __istype(_BSD_RUNE_T_ c, unsigned long f) { + if (c == EOF) + return 0; + if (c < 0) + c = (unsigned char) c; return((((c & _CRMASK) ? ___runetype(c) : _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0); } @@ -113,6 +122,10 @@ __istype(_BSD_RUNE_T_ c, unsigned long f) static __inline int __isctype(_BSD_RUNE_T_ c, unsigned long f) { + if (c == EOF) + return 0; + if (c < 0) + c = (unsigned char) c; return((((c & _CRMASK) ? 0 : _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0); } @@ -122,6 +135,10 @@ __isctype(_BSD_RUNE_T_ c, unsigned long f) static __inline _BSD_RUNE_T_ toupper(_BSD_RUNE_T_ c) { + if (c == EOF) + return EOF; + if (c < 0) + c = (unsigned char) c; return((c & _CRMASK) ? ___toupper(c) : _CurrentRuneLocale->mapupper[c]); } @@ -129,6 +146,10 @@ toupper(_BSD_RUNE_T_ c) static __inline _BSD_RUNE_T_ tolower(_BSD_RUNE_T_ c) { + if (c == EOF) + return EOF; + if (c < 0) + c = (unsigned char) c; return((c & _CRMASK) ? ___tolower(c) : _CurrentRuneLocale->maplower[c]); } diff --git a/include/ctype.h b/include/ctype.h index a37fc1c..0a34886 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -103,9 +103,18 @@ __END_DECLS #endif #if defined(_USE_CTYPE_INLINE_) + +#ifndef EOF +#define EOF (-1) +#endif + static __inline int __istype(_BSD_RUNE_T_ c, unsigned long f) { + if (c == EOF) + return 0; + if (c < 0) + c = (unsigned char) c; return((((c & _CRMASK) ? ___runetype(c) : _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0); } @@ -113,6 +122,10 @@ __istype(_BSD_RUNE_T_ c, unsigned long f) static __inline int __isctype(_BSD_RUNE_T_ c, unsigned long f) { + if (c == EOF) + return 0; + if (c < 0) + c = (unsigned char) c; return((((c & _CRMASK) ? 0 : _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0); } @@ -122,6 +135,10 @@ __isctype(_BSD_RUNE_T_ c, unsigned long f) static __inline _BSD_RUNE_T_ toupper(_BSD_RUNE_T_ c) { + if (c == EOF) + return EOF; + if (c < 0) + c = (unsigned char) c; return((c & _CRMASK) ? ___toupper(c) : _CurrentRuneLocale->mapupper[c]); } @@ -129,6 +146,10 @@ toupper(_BSD_RUNE_T_ c) static __inline _BSD_RUNE_T_ tolower(_BSD_RUNE_T_ c) { + if (c == EOF) + return EOF; + if (c < 0) + c = (unsigned char) c; return((c & _CRMASK) ? ___tolower(c) : _CurrentRuneLocale->maplower[c]); } |