feat: some extensions to kernel standard c library. Other minor
improvements and formats
This commit is contained in:
81
kernel/libc/ctype.c
Normal file
81
kernel/libc/ctype.c
Normal file
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// Created by rick on 25-03-21.
|
||||
//
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
int tolower(int c) {
|
||||
if (c > 0xFF) {
|
||||
// uh own
|
||||
return c;
|
||||
}
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
return c - 'A' + 'a';
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int toupper(int c) {
|
||||
if (c > 0xFF) {
|
||||
// uh own
|
||||
return c;
|
||||
}
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
return c - 'a' + 'A';
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
int isascii(int c) {
|
||||
return c <= 0x7F;
|
||||
}
|
||||
|
||||
int isblank(int c) {
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
int iscntrl(int c) {
|
||||
return c <= 0x1F || c == 0x7F;
|
||||
}
|
||||
|
||||
int isdigit(int c) {
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
int isgraph(int c) {
|
||||
return c > ' ' && c < 0x7F;
|
||||
}
|
||||
|
||||
int islower(int c) {
|
||||
return c >= 'a' && c <= 'z';
|
||||
}
|
||||
|
||||
int isprint(int c) {
|
||||
return c >= ' ' && c < 0x7F;
|
||||
}
|
||||
|
||||
int ispunct(int c) {
|
||||
return (c > ' ' && c <= '@')
|
||||
|| (c >= '[' && c <= '`')
|
||||
|| (c >= '{' && c <= '~');
|
||||
}
|
||||
|
||||
int isspace(int c) {
|
||||
return c == ' ' || (c >= '\t' && c <= '\r');
|
||||
}
|
||||
|
||||
int isupper(int c) {
|
||||
return c >= 'A' && c <= 'Z';
|
||||
}
|
||||
|
||||
int isxdigit(int c) {
|
||||
return isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
int isalpha(int c) {
|
||||
return isupper(c) | islower(c);
|
||||
}
|
||||
|
||||
int isalnum(int c) {
|
||||
return isalpha(c) || isdigit(c);
|
||||
}
|
||||
Reference in New Issue
Block a user