megadrive_test1
diff src/libc/ctype.c @ 6:862f8a034cae
expanding the megadrive code
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 11 Feb 2017 08:56:42 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/libc/ctype.c Sat Feb 11 08:56:42 2017 +0200 1.3 @@ -0,0 +1,60 @@ 1.4 +int isalpha(int c); 1.5 +int isdigit(int c); 1.6 +int islower(int c); 1.7 +int isupper(int c); 1.8 + 1.9 + 1.10 +int isalnum(int c) 1.11 +{ 1.12 + return isalpha(c) || isdigit(c); 1.13 +} 1.14 + 1.15 +int isalpha(int c) 1.16 +{ 1.17 + return isupper(c) || islower(c); 1.18 +} 1.19 + 1.20 +int isblank(int c) 1.21 +{ 1.22 + return c == ' ' || c == '\t'; 1.23 +} 1.24 + 1.25 +int isdigit(int c) 1.26 +{ 1.27 + return c >= '0' && c <= '9'; 1.28 +} 1.29 + 1.30 +int isupper(int c) 1.31 +{ 1.32 + return c >= 'A' && c <= 'Z'; 1.33 +} 1.34 + 1.35 +int islower(int c) 1.36 +{ 1.37 + return c >= 'a' && c <= 'z'; 1.38 +} 1.39 + 1.40 +int isgraph(int c) 1.41 +{ 1.42 + return c > ' ' && c <= '~'; 1.43 +} 1.44 + 1.45 +int isprint(int c) 1.46 +{ 1.47 + return isgraph(c) || c == ' '; 1.48 +} 1.49 + 1.50 +int isspace(int c) 1.51 +{ 1.52 + return isblank(c) || c == '\f' || c == '\n' || c == '\r' || c == '\v'; 1.53 +} 1.54 + 1.55 +int toupper(int c) 1.56 +{ 1.57 + return islower(c) ? (c + ('A' - 'a')) : c; 1.58 +} 1.59 + 1.60 +int tolower(int c) 1.61 +{ 1.62 + return isupper(c) ? (c + ('A' - 'a')) : c; 1.63 +}