add ctype.h

This commit is contained in:
K. Lange 2018-05-04 12:17:32 +09:00
parent 300d5b78ca
commit f94a09f485
13 changed files with 55 additions and 0 deletions

View File

@ -1,2 +1,15 @@
#pragma once
extern int isalnum(int c);
extern int isalpha(int c);
extern int isdigit(int c);
extern int islower(int c);
extern int isgraph(int c);
extern int iscntrl(int c);
extern int isgraph(int c);
extern int ispunct(int c);
extern int isspace(int c);
extern int isupper(int c);
extern int isxdigit(int c);
extern int isascii(int c);

5
libc/ctype/isalnum.c Normal file
View File

@ -0,0 +1,5 @@
#include <ctype.h>
int isalnum(int c) {
return isalpha(c) || isdigit(c);
}

3
libc/ctype/isalpha.c Normal file
View File

@ -0,0 +1,3 @@
int isalpha(int c) {
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
}

3
libc/ctype/isascii.c Normal file
View File

@ -0,0 +1,3 @@
int isascii(int c) {
return (c <= 0x7f);
}

3
libc/ctype/iscntrl.c Normal file
View File

@ -0,0 +1,3 @@
int iscntrl(int c) {
return ((c >= 0 && c <= 0x1f) || (c == 0x7f));
}

3
libc/ctype/isdigit.c Normal file
View File

@ -0,0 +1,3 @@
int isdigit(int c) {
return (c >= '0' && c <= '9');
}

3
libc/ctype/isgraph.c Normal file
View File

@ -0,0 +1,3 @@
int isgraph(int c) {
return (c >= '!' && c <= '~');
}

3
libc/ctype/islower.c Normal file
View File

@ -0,0 +1,3 @@
int islower(int c) {
return (c >= 'a' && c <= 'z');
}

5
libc/ctype/isprint.c Normal file
View File

@ -0,0 +1,5 @@
#include <ctype.h>
int isprint(int c) {
return isgraph(c) || (c == ' ');
}

5
libc/ctype/ispunct.c Normal file
View File

@ -0,0 +1,5 @@
#include <ctype.h>
int ispunct(int c) {
return isgraph(c) && !isalnum(c);
}

3
libc/ctype/isspace.c Normal file
View File

@ -0,0 +1,3 @@
int isspace(int c) {
return (c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == ' ');
}

3
libc/ctype/isupper.c Normal file
View File

@ -0,0 +1,3 @@
int isupper(int c) {
return (c >= 'A' && c <= 'Z');
}

3
libc/ctype/isxdigit.c Normal file
View File

@ -0,0 +1,3 @@
int isxdigit(int c) {
return ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
}