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.
This commit is contained in:
parent
d341e762bb
commit
262fb20771
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3433
@ -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]);
|
||||
}
|
||||
|
@ -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]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user