AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

Index

Loading...
Searching...
No Matches
ctype.h
Go to the documentation of this file.
1/* Copyright (c) 2002,2007 Michael Stumpf
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in
12 the documentation and/or other materials provided with the
13 distribution.
14
15 * Neither the name of the copyright holders nor the names of
16 contributors may be used to endorse or promote products derived
17 from this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 POSSIBILITY OF SUCH DAMAGE. */
30
31/*
32 ctype.h - character conversion macros and ctype macros
33
34 Author : Michael Stumpf
35 Michael.Stumpf@t-online.de
36*/
37
38#ifndef __CTYPE_H_
39#define __CTYPE_H_ 1
40
41#include <bits/attribs.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/** \file */
48/** \defgroup ctype <ctype.h>: Character Operations
49 These functions perform various operations on characters.
50
51 \code #include <ctype.h>\endcode
52
53*/
54
55/** \name Character classification routines
56
57 These functions perform character classification. They return true or
58 false status depending whether the character passed to the function falls
59 into the function's classification (i.e. isdigit() returns true if its
60 argument is any value '0' though '9', inclusive). If the input is not
61 an unsigned char value, all of this function return false. */
62
63/**@{*/
64
65/** \ingroup ctype
66
67 Checks for an alphanumeric character. It is equivalent to <tt>(isalpha(c)
68 || isdigit(c))</tt>. */
69
70extern int isalnum(int __c);
71
72#ifndef __DOXYGEN__
73extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
74int isalnum(int __c)
75{
76 register int __r24 __asm("r24") = __c;
77 __asm ("%~call isalnum" : "+r" (__r24));
78 return __r24;
79}
80#endif
81
82/** \ingroup ctype
83
84 Checks for an alphabetic character. It is equivalent to <tt>(isupper(c) ||
85 islower(c))</tt>. */
86
87extern int isalpha(int __c);
88
89#ifndef __DOXYGEN__
90extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
91int isalpha(int __c)
92{
93 register int __r24 __asm("r24") = __c;
94 __asm ("%~call isalpha" : "+r" (__r24));
95 return __r24;
96}
97#endif
98
99/** \ingroup ctype
100
101 Checks whether \c c is a 7-bit unsigned char value that fits into the
102 ASCII character set. */
103
104extern int isascii(int __c);
105
106#ifndef __DOXYGEN__
107extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
108int isascii(int __c)
109{
110 register int __r24 __asm("r24") = __c;
111 __asm ("%~call isascii" : "+r" (__r24));
112 return __r24;
113}
114#endif
115
116/** \ingroup ctype
117
118 Checks for a blank character, that is, a space or a tab. */
119
120extern int isblank(int __c);
121
122#ifndef __DOXYGEN__
123extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
124int isblank(int __c)
125{
126 register int __r24 __asm("r24") = __c;
127 __asm ("%~call isblank" : "+r" (__r24));
128 return __r24;
129}
130#endif
131
132/** \ingroup ctype
133
134 Checks for a control character. */
135
136extern int iscntrl(int __c);
137
138#ifndef __DOXYGEN__
139extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
140int iscntrl(int __c)
141{
142 register int __r24 __asm("r24") = __c;
143 __asm ("%~call iscntrl" : "+r" (__r24));
144 return __r24;
145}
146#endif
147
148/** \ingroup ctype
149
150 Checks for a digit (0 through 9). */
151
152extern int isdigit(int __c);
153
154#ifndef __DOXYGEN__
155extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
156int isdigit(int __c)
157{
158 register int __r24 __asm("r24") = __c;
159 __asm ("%~call isdigit" : "+r" (__r24));
160 return __r24;
161}
162#endif
163
164/** \ingroup ctype
165
166 Checks for any printable character except space. */
167
168extern int isgraph(int __c);
169
170#ifndef __DOXYGEN__
171extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
172int isgraph(int __c)
173{
174 register int __r24 __asm("r24") = __c;
175 __asm ("%~call isgraph" : "+r" (__r24));
176 return __r24;
177}
178#endif
179
180/** \ingroup ctype
181
182 Checks for a lower-case character. */
183
184extern int islower(int __c);
185
186#ifndef __DOXYGEN__
187extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
188int islower(int __c)
189{
190 register int __r24 __asm("r24") = __c;
191 __asm ("%~call islower" : "+r" (__r24));
192 return __r24;
193}
194#endif
195
196/** \ingroup ctype
197
198 Checks for any printable character including space. */
199
200extern int isprint(int __c);
201
202#ifndef __DOXYGEN__
203extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
204int isprint(int __c)
205{
206 register int __r24 __asm("r24") = __c;
207 __asm ("%~call isprint" : "+r" (__r24));
208 return __r24;
209}
210#endif
211
212/** \ingroup ctype
213
214 Checks for any printable character which is not a space or an alphanumeric
215 character. */
216
217extern int ispunct(int __c);
218
219#ifndef __DOXYGEN__
220extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
221int ispunct(int __c)
222{
223 register int __r24 __asm("r24") = __c;
224 __asm ("%~call ispunct" : "+r" (__r24));
225 return __r24;
226}
227#endif
228
229/** \ingroup ctype
230
231 Checks for white-space characters. For the AVR-LibC library, these are:
232 space, form-feed ('\\f'), newline ('\\n'), carriage return ('\\r'),
233 horizontal tab ('\\t'), and vertical tab ('\\v'). */
234
235extern int isspace(int __c);
236
237#ifndef __DOXYGEN__
238extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
239int isspace(int __c)
240{
241 register int __r24 __asm("r24") = __c;
242 __asm ("%~call isspace" : "+r" (__r24));
243 return __r24;
244}
245#endif
246
247/** \ingroup ctype
248
249 Checks for an uppercase letter. */
250
251extern int isupper(int __c);
252
253#ifndef __DOXYGEN__
254extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
255int isupper(int __c)
256{
257 register int __r24 __asm("r24") = __c;
258 __asm ("%~call isupper" : "+r" (__r24));
259 return __r24;
260}
261#endif
262
263/** \ingroup ctype
264
265 Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 8 9 a b c d e
266 f A B C D E F. */
267
268extern int isxdigit(int __c);
269
270#ifndef __DOXYGEN__
271extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
272int isxdigit(int __c)
273{
274 register int __r24 __asm("r24") = __c;
275 __asm ("%~call isxdigit" : "+r" (__r24));
276 return __r24;
277}
278#endif
279
280/**@}*/
281
282/** \name Character conversion routines
283
284 This realization permits all possible values of integer argument.
285 The toascii() function clears all highest bits. The tolower() and
286 toupper() functions return an input argument as is, if it is not an
287 unsigned char value. */
288
289/**@{*/
290
291/** \ingroup ctype
292
293 Converts \c c to a 7-bit unsigned char value that fits into the ASCII
294 character set, by clearing the high-order bits.
295
296 \warning Many people will be unhappy if you use this function. This
297 function will convert accented letters into random characters. */
298
299extern int toascii(int __c);
300
301#ifndef __DOXYGEN__
302extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
303int toascii(int __c)
304{
305 register int __r24 __asm("r24") = __c;
306 __asm ("%~call toascii" : "+r" (__r24));
307 return __r24;
308}
309#endif
310
311/** \ingroup ctype
312
313 Converts the letter \c c to lower case, if possible. */
314
315extern int tolower(int __c);
316
317#ifndef __DOXYGEN__
318extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
319int tolower(int __c)
320{
321 register int __r24 __asm("r24") = __c;
322 __asm ("%~call tolower" : "+r" (__r24));
323 return __r24;
324}
325#endif
326
327/** \ingroup ctype
328
329 Converts the letter \c c to upper case, if possible. */
330
331extern int toupper(int __c);
332
333#ifndef __DOXYGEN__
334extern __ATTR_ALWAYS_INLINE__ __ATTR_GNU_INLINE__
335int toupper(int __c)
336{
337 register int __r24 __asm("r24") = __c;
338 __asm ("%~call toupper" : "+r" (__r24));
339 return __r24;
340}
341#endif
342
343/**@}*/
344
345#ifdef __cplusplus
346}
347#endif
348
349#endif
int isxdigit(int __c)
int isupper(int __c)
int isspace(int __c)
int toascii(int __c)
int isascii(int __c)
int isdigit(int __c)
int iscntrl(int __c)
int isalpha(int __c)
int toupper(int __c)
int tolower(int __c)
int isprint(int __c)
int ispunct(int __c)
int isblank(int __c)
int islower(int __c)
int isalnum(int __c)
int isgraph(int __c)