Skip to content

Commit 2960508

Browse files
committed
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 <cfriedt@tenstorrent.com>
1 parent 3cf7b20 commit 2960508

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
@@ -23,6 +23,11 @@ static inline int isalpha(int c)
2323
return (int)((((unsigned)c|32u)-(unsigned)'a') < 26U);
2424
}
2525

26+
static inline int isblank(int c)
27+
{
28+
return (int)((c == (int)' ') || (c == (int)'\t'));
29+
}
30+
2631
static inline int isspace(int c)
2732
{
2833
return (int)(c == (int)' ' || ((unsigned)c-(unsigned)'\t') < 5U);
@@ -45,6 +50,11 @@ static inline int isdigit(int a)
4550
return (int)(((unsigned)(a)-(unsigned)'0') < 10U);
4651
}
4752

53+
static inline int islower(int c)
54+
{
55+
return (int)(((unsigned)(c) - (unsigned)'a') < 26U);
56+
}
57+
4858
static inline int isxdigit(int a)
4959
{
5060
unsigned int ua = (unsigned int)a;
@@ -69,6 +79,11 @@ static inline int isalnum(int chr)
6979
return (int)(isalpha(chr) || isdigit(chr));
7080
}
7181

82+
static inline int ispunct(int c)
83+
{
84+
return (int)(isgraph(c) && !isalnum(c));
85+
}
86+
7287
static inline int iscntrl(int c)
7388
{
7489
return (int)((((unsigned int)c) <= 31U) || (((unsigned int)c) == 127U));

0 commit comments

Comments
 (0)