2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
6 #include <aros/symbolsets.h>
7 #include <libraries/stdc.h>
11 static const unsigned short int __ctype_b_array
[256] =
21 _IScntrl
, /* Backspace */
22 _ISblank
|_IScntrl
|_ISspace
, /* 9 */
23 _IScntrl
|_ISspace
, /* LF */
24 _IScntrl
|_ISspace
, /* 11 */
25 _IScntrl
|_ISspace
, /* 12 */
26 _IScntrl
|_ISspace
, /* CR */
45 _ISblank
|_ISprint
|_ISspace
, /* Space */
46 _ISgraph
|_ISprint
|_ISpunct
, /* ! */
47 _ISgraph
|_ISprint
|_ISpunct
, /* " */
48 _ISgraph
|_ISprint
|_ISpunct
, /* # */
49 _ISgraph
|_ISprint
|_ISpunct
, /* $ */
50 _ISgraph
|_ISprint
|_ISpunct
, /* % */
51 _ISgraph
|_ISprint
|_ISpunct
, /* & */
52 _ISgraph
|_ISprint
|_ISpunct
, /* ' */
53 _ISgraph
|_ISprint
|_ISpunct
, /* ( */
54 _ISgraph
|_ISprint
|_ISpunct
, /* ) */
55 _ISgraph
|_ISprint
|_ISpunct
, /* * */
56 _ISgraph
|_ISprint
|_ISpunct
, /* + */
57 _ISgraph
|_ISprint
|_ISpunct
, /* , */
58 _ISgraph
|_ISprint
|_ISpunct
, /* - */
59 _ISgraph
|_ISprint
|_ISpunct
, /* . */
60 _ISgraph
|_ISprint
|_ISpunct
, /* / */
61 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 0 */
62 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 1 */
63 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 2 */
64 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 3 */
65 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 4 */
66 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 5 */
67 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 6 */
68 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 7 */
69 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 8 */
70 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 9 */
71 _ISgraph
|_ISprint
|_ISpunct
, /* : */
72 _ISgraph
|_ISprint
|_ISpunct
, /* ; */
73 _ISgraph
|_ISprint
|_ISpunct
, /* < */
74 _ISgraph
|_ISprint
|_ISpunct
, /* = */
75 _ISgraph
|_ISprint
|_ISpunct
, /* > */
76 _ISgraph
|_ISprint
|_ISpunct
, /* ? */
77 _ISgraph
|_ISprint
|_ISpunct
, /* @ */
78 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* A */
79 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* B */
80 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* C */
81 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* D */
82 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* E */
83 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* F */
84 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* G */
85 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* H */
86 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* I */
87 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* J */
88 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* K */
89 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* L */
90 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* M */
91 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* N */
92 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* O */
93 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* P */
94 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Q */
95 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* R */
96 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* S */
97 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* T */
98 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* U */
99 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* V */
100 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* W */
101 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* X */
102 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Y */
103 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Z */
104 _ISgraph
|_ISprint
|_ISpunct
, /* [ */
105 _ISgraph
|_ISprint
|_ISpunct
, /* \ */
106 _ISgraph
|_ISprint
|_ISpunct
, /* ] */
107 _ISgraph
|_ISprint
|_ISpunct
, /* ^ */
108 _ISgraph
|_ISprint
|_ISpunct
, /* _ */
109 _ISgraph
|_ISprint
|_ISpunct
, /* ` */
110 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* a */
111 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* b */
112 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* c */
113 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* d */
114 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* e */
115 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* f */
116 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* g */
117 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* h */
118 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* i */
119 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* j */
120 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* k */
121 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* l */
122 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* m */
123 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* n */
124 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* o */
125 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* p */
126 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* q */
127 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* r */
128 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* s */
129 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* t */
130 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* u */
131 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* v */
132 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* w */
133 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* x */
134 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* y */
135 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* z */
136 _ISgraph
|_ISprint
|_ISpunct
, /* { */
137 _ISgraph
|_ISprint
|_ISpunct
, /* | */
138 _ISgraph
|_ISprint
|_ISpunct
, /* } */
139 _ISgraph
|_ISprint
|_ISpunct
, /* ~ */
271 static const unsigned char __ctype_toupper_array
[256] =
273 0, 1, 2, 3, 4, 5, 6, 7,
274 8, 9, 10, 11, 12, 13, 14, 15,
275 16, 17, 18, 19, 20, 21, 22, 23,
276 24, 25, 26, 27, 28, 29, 30, 31,
277 ' ','!','"','#', '$','%','&','\'',
278 '(',')','*','+', ',','-','.','/',
279 '0','1','2','3', '4','5','6','7',
280 '8','9',':',';', '<','=','>','?',
281 '@','A','B','C', 'D','E','F','G',
282 'H','I','J','K', 'L','M','N','O',
283 'P','Q','R','S', 'T','U','V','W',
284 'X','Y','Z','[', '\\',']','^','_',
285 '`','A','B','C', 'D','E','F','G',
286 'H','I','J','K', 'L','M','N','O',
287 'P','Q','R','S', 'T','U','V','W',
288 'X','Y','Z','{', '|','}','~',127,
290 128,129,130,131, 132,133,134,135,
291 136,137,138,139, 140,141,142,143,
292 144,145,146,147, 148,149,150,151,
293 152,153,154,155, 156,157,158,159,
294 160,161,162,163, 164,165,166,167,
295 168,169,170,171, 172,173,174,175,
296 176,177,178,179, 180,181,182,183,
297 184,185,186,187, 188,189,190,191,
298 192,193,194,195, 196,197,198,199,
299 200,201,202,203, 204,205,206,207,
300 208,209,210,211, 212,213,214,215,
301 216,217,218,219, 220,221,222,223,
302 224,225,226,227, 228,229,230,231,
303 232,233,234,235, 236,237,238,239,
304 240,241,242,243, 244,245,246,247,
305 248,249,250,251, 252,253,254,255,
308 static const unsigned char __ctype_tolower_array
[256] =
310 0, 1, 2, 3, 4, 5, 6, 7,
311 8, 9, 10, 11, 12, 13, 14, 15,
312 16, 17, 18, 19, 20, 21, 22, 23,
313 24, 25, 26, 27, 28, 29, 30, 31,
314 ' ','!','"','#', '$','%','&','\'',
315 '(',')','*','+', ',','-','.','/',
316 '0','1','2','3', '4','5','6','7',
317 '8','9',':',';', '<','=','>','?',
318 '@','a','b','c', 'd','e','f','g',
319 'h','i','j','k', 'l','m','n','o',
320 'p','q','r','s', 't','u','v','w',
321 'x','y','z','[', '\\',']','^','_',
322 '`','a','b','c', 'd','e','f','g',
323 'h','i','j','k', 'l','m','n','o',
324 'p','q','r','s', 't','u','v','w',
325 'x','y','z','{', '|','}','~',127,
327 128,129,130,131, 132,133,134,135,
328 136,137,138,139, 140,141,142,143,
329 144,145,146,147, 148,149,150,151,
330 152,153,154,155, 156,157,158,159,
331 160,161,162,163, 164,165,166,167,
332 168,169,170,171, 172,173,174,175,
333 176,177,178,179, 180,181,182,183,
334 184,185,186,187, 188,189,190,191,
335 192,193,194,195, 196,197,198,199,
336 200,201,202,203, 204,205,206,207,
337 208,209,210,211, 212,213,214,215,
338 216,217,218,219, 220,221,222,223,
339 224,225,226,227, 228,229,230,231,
340 232,233,234,235, 236,237,238,239,
341 240,241,242,243, 244,245,246,247,
342 248,249,250,251, 252,253,254,255,
345 /* Pointers have to be available both when in static linklib and
346 internally to stdc.library also
348 const unsigned short int * const __ctype_b
= &__ctype_b_array
[0];
349 const unsigned char * const __ctype_toupper
= &__ctype_toupper_array
[0];
350 const unsigned char * const __ctype_tolower
= &__ctype_tolower_array
[0];
352 const unsigned short int * const * const __ctype_b_ptr
= &__ctype_b
;
353 const unsigned char * const * const __ctype_toupper_ptr
= &__ctype_toupper
;
354 const unsigned char * const * const __ctype_tolower_ptr
= &__ctype_tolower
;
357 static int __ctype_init(struct StdCBase
*StdCBase
)
359 /* Currently these values are the same for all libbases
360 but could in theory be changed in the future to make
363 StdCBase
->__ctype_b
= &__ctype_b_array
[0];
364 StdCBase
->__ctype_toupper
= &__ctype_toupper_array
[0];
365 StdCBase
->__ctype_tolower
= &__ctype_tolower_array
[0];
370 ADD2INITLIB(__ctype_init
, 20);
373 /*****************************************************************************
384 Test if a character is uppercase. Works for all characters between
385 -128 and 255 inclusive both.
388 c - The character to test.
391 != 0 if the character is uppercase, 0 otherwise.
396 isupper ('A') -> true
397 isupper ('a') -> false
398 isupper ('0') -> false
399 isupper ('.') -> false
400 isupper ('\n') -> false
401 isupper ('\001') -> false
402 isupper (EOF) -> false
410 ******************************************************************************/
411 /*****************************************************************************
422 Test if a character is lowercase. Works for all characters between
423 -128 and 255 inclusive both.
426 c - The character to test.
429 != 0 if the character is lowercase, 0 otherwise.
434 islower ('A') -> false
435 islower ('a') -> true
436 islower ('0') -> false
437 islower ('.') -> false
438 islower ('\n') -> false
439 islower ('\001') -> false
440 islower (EOF) -> false
448 ******************************************************************************/
449 /******************************************************************************
460 Test if a character is an alphabetic character. Works for all
461 characters between -128 and 255 inclusive both.
464 c - The character to test.
467 != 0 if the character is an alphabetic character, 0 otherwise.
472 isalpha ('A') -> true
473 isalpha ('a') -> true
474 isalpha ('0') -> false
475 isalpha ('.') -> false
476 isalpha ('\n') -> false
477 isalpha ('\001') -> false
478 isalpha (EOF) -> false
486 ******************************************************************************/
487 /*****************************************************************************
498 Test if a character is an alphabetic character or a digit. Works
499 for all characters between -128 and 255 inclusive both.
502 c - The character to test.
505 != 0 if the character is alphabetic character or a digit, 0 otherwise.
510 isalnum ('A') -> true
511 isalnum ('a') -> true
512 isalnum ('0') -> true
513 isalnum ('.') -> false
514 isalnum ('\n') -> false
515 isalnum ('\001') -> false
516 isalnum (EOF) -> false
524 ******************************************************************************/
525 /*****************************************************************************
536 Test if a character is an ascii character. Works for all characters
537 between -128 and 255 inclusive both.
540 c - The character to test.
543 != 0 if the character is an ascii character, 0 otherwise.
548 isascii ('A') -> true
549 isascii ('a') -> true
550 isascii ('0') -> true
551 isascii ('.') -> true
552 isascii ('\n') -> true
553 isascii ('\001') -> true
554 isascii (EOF) -> false
562 ******************************************************************************/
563 /*****************************************************************************
574 Test if a character is a space or a tab. Works for all characters
575 between -128 and 255 inclusive both.
578 c - The character to test.
581 != 0 if the character is a space or tab, 0 otherwise.
586 isblank ('A') -> false
587 isblank ('a') -> false
588 isblank ('0') -> false
589 isblank ('.') -> false
590 isblank (' ') -> true
591 isblank ('\n') -> false
592 isblank ('\001') -> false
593 isblank (EOF) -> false
601 ******************************************************************************/
602 /*****************************************************************************
613 Test if a character is a control character. Works for all
614 characters between -128 and 255 inclusive both.
617 c - The character to test.
620 != 0 if the character is a control character, 0 otherwise.
625 iscntrl ('A') -> false
626 iscntrl ('a') -> false
627 iscntrl ('0') -> false
628 iscntrl ('.') -> false
629 iscntrl ('\n') -> true
630 iscntrl ('\001') -> true
631 iscntrl (EOF) -> false
639 ******************************************************************************/
640 /*****************************************************************************
651 Test if a character is a digit. Works for all characters between
652 -128 and 255 inclusive both.
655 c - The character to test.
658 != 0 if the character is a digit, 0 otherwise.
663 isdigit ('A') -> false
664 isdigit ('a') -> false
665 isdigit ('0') -> true
666 isdigit ('.') -> false
667 isdigit ('\n') -> false
668 isdigit ('\001') -> false
669 isdigit (EOF) -> false
677 ******************************************************************************/
678 /*****************************************************************************
689 Test if a character is a printable character but no whitespace.
690 Works for all characters between -128 and 255 inclusive both.
693 c - The character to test.
696 != 0 if the character is a printable character but no whitespace, 0
702 isgraph ('A') -> true
703 isgraph ('a') -> true
704 isgraph ('0') -> true
705 isgraph ('.') -> true
706 isgraph ('\n') -> false
707 isgraph ('\001') -> false
708 isgraph (EOF) -> false
716 ******************************************************************************/
717 /*****************************************************************************
728 Test if a character is a printable character. Works for all
729 characters between -128 and 255 inclusive both.
732 c - The character to test.
735 != 0 if the character is a printable character, 0 otherwise.
740 isprint ('A') -> true
741 isprint ('a') -> true
742 isprint ('0') -> true
743 isprint ('.') -> true
744 isprint ('\n') -> true
745 isprint ('\001') -> false
746 isprint (EOF) -> false
754 ******************************************************************************/
755 /*****************************************************************************
766 Test if a character is whitespace. Works for all characters between
767 -128 and 255 inclusive both.
770 c - The character to test.
773 != 0 if the character is whitespace, 0 otherwise.
778 isspace ('A') -> false
779 isspace ('a') -> false
780 isspace ('0') -> false
781 isspace ('.') -> false
782 isspace ('\n') -> true
783 isspace ('\001') -> false
784 isspace (EOF) -> false
792 ******************************************************************************/
793 /*****************************************************************************
804 Test if a character is printable but not alphanumeric. Works for
805 all characters between -128 and 255 inclusive both.
808 c - The character to test.
811 != 0 if the character is printable but not alphanumeric, 0
817 ispunct ('A') -> false
818 ispunct ('a') -> false
819 ispunct ('0') -> false
820 ispunct ('.') -> true
821 ispunct ('\n') -> false
822 ispunct ('\001') -> false
823 ispunct (EOF) -> false
831 ******************************************************************************/
832 /*****************************************************************************
843 Test if a character is a hexadecimal digit. Works for all
844 characters between -128 and 255 inclusive both.
847 c - The character to test.
850 != 0 if the character is a hexadecimal digit, 0 otherwise.
855 isxdigit ('A') -> true
856 isxdigit ('a') -> true
857 isxdigit ('x') -> false
858 isxdigit ('0') -> true
859 isxdigit ('.') -> false
860 isxdigit ('\n') -> false
861 isxdigit ('\001') -> false
862 isxdigit (EOF) -> false
870 ******************************************************************************/