summaryrefslogtreecommitdiff
path: root/LibC/ctype.h
blob: 41178f5cb4ac4417eef89b08d5a86c0195d2cce3 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once

#include <sys/cdefs.h>

__BEGIN_DECLS

ALWAYS_INLINE int isascii(int ch)
{
    return (ch & ~0x7f) == 0;
}

ALWAYS_INLINE int isspace(int ch)
{
    return ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\v';
}

ALWAYS_INLINE int islower(int c)
{
    return c >= 'a' && c <= 'z';
}

ALWAYS_INLINE int isupper(int c)
{
    return c >= 'A' && c <= 'Z';
}

ALWAYS_INLINE int tolower(int c)
{
    if (isupper(c))
        return c | 0x20;
    return c;
}

ALWAYS_INLINE int toupper(int c)
{
    if (islower(c))
        return c & ~0x20;
    return c;
}

ALWAYS_INLINE int isdigit(int c)
{
    return c >= '0' && c <= '9';
}

int isalpha(int c);
int isalnum(int c);
int ispunct(int c);
int isprint(int c);
int iscntrl(int c);

__END_DECLS