Skip to content

Commit de91735

Browse files
Chris Friedtkartben
authored andcommitted
libc: minimal: add missing ctype.h functions
Add the functions below to the minimal libc ctype.h since they are missing, and are required as of C89 (C99 for `isblank()`) * `isblank()` * `islower()` * `ispunct()` Signed-off-by: Chris Friedt <[email protected]>
1 parent 6b6a259 commit de91735

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/libc/minimal/include/ctype.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ static inline int isalpha(int c)
2626
return (('a' <= c) && (c <= 'z'));
2727
}
2828

29+
static inline int isblank(int c)
30+
{
31+
return ((c == ' ') || (c == '\t'));
32+
}
33+
2934
static inline int isspace(int c)
3035
{
3136
return ((c == ' ') || (('\t' <= c) && (c <= '\r')));
@@ -46,6 +51,11 @@ static inline int isdigit(int a)
4651
return (('0' <= a) && (a <= '9'));
4752
}
4853

54+
static inline int islower(int c)
55+
{
56+
return (('a' <= c) && (c <= 'z'));
57+
}
58+
4959
static inline int isxdigit(int a)
5060
{
5161
if (isdigit(a) != 0) {
@@ -73,6 +83,11 @@ static inline int isalnum(int chr)
7383
return (isalpha(chr) || isdigit(chr));
7484
}
7585

86+
static inline int ispunct(int c)
87+
{
88+
return (isgraph(c) && !isalnum(c));
89+
}
90+
7691
static inline int iscntrl(int c)
7792
{
7893
return ((((unsigned int)c) <= 31U) || (((unsigned int)c) == 127U));

0 commit comments

Comments
 (0)