summaryrefslogtreecommitdiff
path: root/libc/misc/ctype/ctype.c
blob: 1063f443db7f20d40b2405e1686c3f9f3b2947e9 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* ctype.c	
 * Character classification and conversion
 * Copyright (C) 2000 Lineo, Inc.
 * Written by Erik Andersen
 * This file is part of the uC-Libc C library and is distributed
 * under the GNU Library General Public License.
 */

#define USE_CTYPE_C_FUNCTIONS
#include <ctype.h>

int
isalnum( int c )
{
    return (isalpha(c) || isdigit(c));
}

int
isalpha( int c )
{
    return (isupper(c) || islower(c));
}

int
isascii( int c )
{
    return (c > 0 && c <= 0x7f);
}

int
iscntrl( int c )
{
    return ((c > 0) && ((c <= 0x1f) || (c == 0x7f)));
}

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

int
isgraph( int c )
{
    return (c != ' ' && isprint(c));
}

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

int
isprint( int c )
{
    return (c >= ' ' && c <= '~');
}

int
ispunct( int c )
{
    return ((c > ' ' && c <= '~') && !isalnum(c));
}

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

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

int
isxdigit( int c )
{
    return (isxupper(c) || isxlower(c));
}

int
isxlower( int c )
{
    return (isdigit(c) || (c >= 'a' && c <= 'f'));
}

int
isxupper( int c )
{
    return (isdigit(c) || (c >= 'A' && c <= 'F'));
}

int
toascii( int c )
{
    return (c & 0x7f);
}

int
tolower( int c )
{
    return (isupper(c) ? ( c - 'A' + 'a') : (c));
}

int
toupper( int c )
{
    return (islower(c) ? (c - 'a' + 'A') : (c));
}