libclayer/src/ctype.c

36 lines
592 B
C
Raw Normal View History

2022-12-25 08:58:00 +00:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2022-12-27 09:05:30 +00:00
#include <libclayer/ctype.h>
2022-12-25 08:58:00 +00:00
2022-12-25 11:23:09 +00:00
int LIBCLAYER(isdigit)(const int c)
2022-12-25 08:58:00 +00:00
{
return (unsigned)c - '0' < 10;
}
2022-12-25 11:23:09 +00:00
int LIBCLAYER(islower)(const int c)
2022-12-25 08:58:00 +00:00
{
return (unsigned)c - 'a' < 26;
}
2022-12-25 11:23:09 +00:00
int LIBCLAYER(isspace)(const int c)
2022-12-25 08:58:00 +00:00
{
return c == ' ' || (unsigned)c - '\t' < 5;
}
2022-12-25 11:23:09 +00:00
int LIBCLAYER(isupper)(const int c)
2022-12-25 08:58:00 +00:00
{
return (unsigned)c - 'A' < 26;
}
2022-12-25 11:23:09 +00:00
int LIBCLAYER(tolower)(const int c)
2022-12-25 08:58:00 +00:00
{
2022-12-25 11:23:09 +00:00
return LIBCLAYER(isupper)(c) ? (c + ('a' - 'A')) : c;
2022-12-25 08:58:00 +00:00
}
2022-12-25 11:23:09 +00:00
int LIBCLAYER(toupper)(const int c)
2022-12-25 08:58:00 +00:00
{
2022-12-25 11:23:09 +00:00
return LIBCLAYER(islower)(c) ? (c - ('a' - 'A')) : c;
2022-12-25 08:58:00 +00:00
}