1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-27 11:14:42 -05:00

<ctype.h>: tolower, toupper (#115)

This commit is contained in:
Alex Kotov 2022-11-27 21:03:56 +04:00 committed by GitHub
parent 5ea65b6b0c
commit 91bce08aa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -6,7 +6,12 @@ extern "C" {
#endif
int isdigit(int c);
int islower(int c);
int isspace(int c);
int isupper(int c);
int tolower(int c);
int toupper(int c);
#ifdef __cplusplus
}

View file

@ -9,7 +9,27 @@ int isdigit(const int c)
return (unsigned)c - '0' < 10;
}
int islower(const int c)
{
return (unsigned)c - 'a' < 26;
}
int isspace(const int c)
{
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;
}