blob: 1509822b14b7f16ece0dc632273438a514e04372 [file] [log] [blame]
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07001/*
2 * Copyright (c) 2008 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <ctype.h>
24
25#if 0
26/* XXX unimplemented for now */
27int iscntrl(int c);
28int isgraph(int c);
29int isprint(int c);
30int ispunct(int c);
31#endif
32
33int isblank(int c)
34{
35 return (c == ' ' || c == '\t');
36}
37
38int isspace(int c)
39{
40 return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
41}
42
43int islower(int c)
44{
45 return ((c >= 'a') && (c <= 'z'));
46}
47
48int isupper(int c)
49{
50 return ((c >= 'A') && (c <= 'Z'));
51}
52
53int isdigit(int c)
54{
55 return ((c >= '0') && (c <= '9'));
56}
57
58int isalpha(int c)
59{
60 return isupper(c) || islower(c);
61}
62
63int isalnum(int c)
64{
65 return isalpha(c) || isdigit(c);
66}
67
68int isxdigit(int c)
69{
70 return isdigit(c) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'));
71}
72
73int tolower(int c)
74{
75 if ((c >= 'A') && (c <= 'Z'))
76 return c + ('a' - 'A');
77 return c;
78}
79
80int toupper(int c)
81{
82 if ((c >= 'a') && (c <= 'z'))
83 return c + ('A' - 'a');
84 return c;
85}
86