Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
ctype.h
Go to the documentation of this file.
1#ifndef RBIMPL_CTYPE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_CTYPE_H
24
25#ifdef STDC_HEADERS
26# include <ctype.h>
27#endif
28
33
34#ifndef ISPRINT
35# define ISASCII rb_isascii
36# define ISPRINT rb_isprint
37# define ISGRAPH rb_isgraph
38# define ISSPACE rb_isspace
39# define ISUPPER rb_isupper
40# define ISLOWER rb_islower
41# define ISALNUM rb_isalnum
42# define ISALPHA rb_isalpha
43# define ISDIGIT rb_isdigit
44# define ISXDIGIT rb_isxdigit
45# define ISBLANK rb_isblank
46# define ISCNTRL rb_iscntrl
47# define ISPUNCT rb_ispunct
48#endif
49
50#define TOUPPER rb_toupper
51#define TOLOWER rb_tolower
52#define STRCASECMP st_locale_insensitive_strcasecmp
53#define STRNCASECMP st_locale_insensitive_strncasecmp
54#define STRTOUL ruby_strtoul
55
57/* locale insensitive functions */
59int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n);
60unsigned long ruby_strtoul(const char *str, char **endptr, int base);
62
63/*
64 * We are making the functions below to return `int` instead of `bool`. They
65 * have been as such since their birth at 5f237d79033b2109afb768bc889611fa9630.
66 */
67
71static inline int
72rb_isascii(int c)
73{
74 return '\0' <= c && c <= '\x7f';
75}
76
80static inline int
81rb_isupper(int c)
82{
83 return 'A' <= c && c <= 'Z';
84}
85
89static inline int
90rb_islower(int c)
91{
92 return 'a' <= c && c <= 'z';
93}
94
98static inline int
99rb_isalpha(int c)
100{
101 return rb_isupper(c) || rb_islower(c);
102}
103
107static inline int
108rb_isdigit(int c)
109{
110 return '0' <= c && c <= '9';
111}
112
116static inline int
117rb_isalnum(int c)
118{
119 return rb_isalpha(c) || rb_isdigit(c);
120}
121
125static inline int
126rb_isxdigit(int c)
127{
128 return rb_isdigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f');
129}
130
134static inline int
135rb_isblank(int c)
136{
137 return c == ' ' || c == '\t';
138}
139
143static inline int
144rb_isspace(int c)
145{
146 return c == ' ' || ('\t' <= c && c <= '\r');
147}
148
152static inline int
153rb_iscntrl(int c)
154{
155 return ('\0' <= c && c < ' ') || c == '\x7f';
156}
157
161static inline int
162rb_isprint(int c)
163{
164 return ' ' <= c && c <= '\x7e';
165}
166
170static inline int
171rb_ispunct(int c)
172{
173 return !rb_isalnum(c);
174}
175
179static inline int
180rb_isgraph(int c)
181{
182 return '!' <= c && c <= '\x7e';
183}
184
188static inline int
189rb_tolower(int c)
190{
191 return rb_isupper(c) ? (c|0x20) : c;
192}
193
197static inline int
198rb_toupper(int c)
199{
200 return rb_islower(c) ? (c&0x5f) : c;
201}
202
203#endif /* RBIMPL_CTYPE_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition: artificial.h:43
Defines RBIMPL_ATTR_CONST.
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition: const.h:36
RBIMPL_ATTR_CONSTEXPR.
#define RBIMPL_ATTR_CONSTEXPR(_)
Wraps (or simulates) C++11 constexpr.
Definition: constexpr.h:75
Our own, locale independent, character handling routines.
unsigned long ruby_strtoul(const char *str, char **endptr, int base)
Definition: util.c:134
Tewaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
Thin wrapper to ruby/config.h.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#define st_locale_insensitive_strncasecmp
Definition: st.h:170
#define st_locale_insensitive_strcasecmp
Definition: st.h:168
#define const
Definition: strftime.c:108