summaryrefslogtreecommitdiff
path: root/core/include/ctype.h
blob: 6c7f57f4aae37393794179546addada607d2cb30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef CTYPE_H
#define CTYPE_H

/*
 * Small subset of <ctype.h> for parsing uses, only handles ASCII
 * and passes the rest through.
 */

static inline int toupper(int c)
{
    if (c >= 'a' && c <= 'z')
	c -= 0x20;

    return c;
}

static inline int tolower(int c)
{
    if (c >= 'A' && c <= 'Z')
	c += 0x20;

    return c;
}

static inline int isspace(int ch)
{
    int space = 0;
    if ((ch == ' ') ||
	(ch == '\f') ||
	(ch == '\n') ||
	(ch == '\r') ||
	(ch == '\t') ||
	(ch == '\v'))
	space = 1;
    return space;
}

#endif /* CTYPE_H */