mirror of https://github.com/tailix/libkernaux.git
`<ctype.h>`: `tolower`, `toupper` (#115)
This commit is contained in:
parent
5ea65b6b0c
commit
91bce08aa3
|
@ -6,7 +6,12 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int isdigit(int c);
|
int isdigit(int c);
|
||||||
|
int islower(int c);
|
||||||
int isspace(int c);
|
int isspace(int c);
|
||||||
|
int isupper(int c);
|
||||||
|
|
||||||
|
int tolower(int c);
|
||||||
|
int toupper(int c);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,27 @@ int isdigit(const int c)
|
||||||
return (unsigned)c - '0' < 10;
|
return (unsigned)c - '0' < 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int islower(const int c)
|
||||||
|
{
|
||||||
|
return (unsigned)c - 'a' < 26;
|
||||||
|
}
|
||||||
|
|
||||||
int isspace(const int c)
|
int isspace(const int c)
|
||||||
{
|
{
|
||||||
return c == ' ' || (unsigned)c - '\t' < 5;
|
return c == ' ' || (unsigned)c - '\t' < 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isupper(const int c)
|
||||||
|
{
|
||||||
|
return (unsigned)c - 'A' < 26;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tolower(const int c)
|
||||||
|
{
|
||||||
|
return isupper(c) ? (c + ('a' - 'A')) : c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int toupper(const int c)
|
||||||
|
{
|
||||||
|
return islower(c) ? (c - ('a' - 'A')) : c;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue