mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibC: Make isalum/isalpha/etc. functions instead of macros
These are supposed to be both functions and macros. I'm not sure how to provide the functions at the same time as the macros, as they collide with each other and cause compile errors. However, some ports fully expect them to be functions. For example, OpenSSH stores them into structures as function pointers.
This commit is contained in:
parent
9266006349
commit
1ec59f28ce
Notes:
sideshowbarker
2024-07-19 02:11:02 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/1ec59f28cea Pull-request: https://github.com/SerenityOS/serenity/pull/3454 Reviewed-by: https://github.com/bugaevc
1 changed files with 54 additions and 22 deletions
|
@ -45,29 +45,61 @@ extern const char _ctype_[256];
|
|||
|
||||
int tolower(int);
|
||||
int toupper(int);
|
||||
int isalnum(int);
|
||||
int isalpha(int);
|
||||
int iscntrl(int);
|
||||
int isdigit(int);
|
||||
int isxdigit(int);
|
||||
int isspace(int);
|
||||
int ispunct(int);
|
||||
int isprint(int);
|
||||
int isgraph(int);
|
||||
int islower(int);
|
||||
int isupper(int);
|
||||
|
||||
#define isalnum(c) (_ctype_[(unsigned char)(c)] & (_U | _L | _N))
|
||||
#define isalpha(c) (_ctype_[(unsigned char)(c)] & (_U | _L))
|
||||
#define iscntrl(c) (_ctype_[(unsigned char)(c)] & (_C))
|
||||
#define isdigit(c) (_ctype_[(unsigned char)(c)] & (_N))
|
||||
#define isxdigit(c) (_ctype_[(unsigned char)(c)] & (_N | _X))
|
||||
#define isspace(c) (_ctype_[(unsigned char)(c)] & (_S))
|
||||
#define ispunct(c) (_ctype_[(unsigned char)(c)] & (_P))
|
||||
#define isprint(c) (_ctype_[(unsigned char)(c)] & (_P | _U | _L | _N | _B))
|
||||
#define isgraph(c) (_ctype_[(unsigned char)(c)] & (_P | _U | _L | _N))
|
||||
#define islower(c) ((_ctype_[(unsigned char)(c)] & (_U | _L)) == _L)
|
||||
#define isupper(c) ((_ctype_[(unsigned char)(c)] & (_U | _L)) == _U)
|
||||
static inline int isalnum(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_U | _L | _N));
|
||||
}
|
||||
|
||||
static inline int isalpha(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_U | _L));
|
||||
}
|
||||
|
||||
static inline int iscntrl(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_C));
|
||||
}
|
||||
|
||||
static inline int isdigit(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_N));
|
||||
}
|
||||
|
||||
static inline int isxdigit(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_N | _X));
|
||||
}
|
||||
|
||||
static inline int isspace(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_S));
|
||||
}
|
||||
|
||||
static inline int ispunct(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_P));
|
||||
}
|
||||
|
||||
static inline int isprint(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_P | _U | _L | _N | _B));
|
||||
}
|
||||
|
||||
static inline int isgraph(int c)
|
||||
{
|
||||
return (_ctype_[(unsigned char)(c)] & (_P | _U | _L | _N));
|
||||
}
|
||||
|
||||
static inline int islower(int c)
|
||||
{
|
||||
return ((_ctype_[(unsigned char)(c)] & (_U | _L)) == _L);
|
||||
}
|
||||
|
||||
static inline int isupper(int c)
|
||||
{
|
||||
return ((_ctype_[(unsigned char)(c)] & (_U | _L)) == _U);
|
||||
}
|
||||
|
||||
#define isascii(c) ((unsigned)c <= 127)
|
||||
#define toascii(c) ((c)&127)
|
||||
|
|
Loading…
Reference in a new issue