2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 /* Move these symbols out of the way, because
7 * we're going to be using a slighty different
8 * definition of these for the static library
11 #define __ctype_b __ctype_b_external
12 #define __ctype_toupper __ctype_toupper_external
13 #define __ctype_tolower __ctype_tolower_external
15 #include <aros/symbolsets.h>
18 #include "__arosc_privdata.h"
21 #undef __ctype_toupper
22 #undef __ctype_tolower
24 static const unsigned short int __ctype_b_array
[256] =
34 _IScntrl
, /* Backspace */
35 _ISblank
|_IScntrl
|_ISspace
, /* 9 */
36 _IScntrl
|_ISspace
, /* LF */
37 _IScntrl
|_ISspace
, /* 11 */
38 _IScntrl
|_ISspace
, /* 12 */
39 _IScntrl
|_ISspace
, /* CR */
58 _ISblank
|_ISprint
|_ISspace
, /* Space */
59 _ISgraph
|_ISprint
|_ISpunct
, /* ! */
60 _ISgraph
|_ISprint
|_ISpunct
, /* " */
61 _ISgraph
|_ISprint
|_ISpunct
, /* # */
62 _ISgraph
|_ISprint
|_ISpunct
, /* $ */
63 _ISgraph
|_ISprint
|_ISpunct
, /* % */
64 _ISgraph
|_ISprint
|_ISpunct
, /* & */
65 _ISgraph
|_ISprint
|_ISpunct
, /* ' */
66 _ISgraph
|_ISprint
|_ISpunct
, /* ( */
67 _ISgraph
|_ISprint
|_ISpunct
, /* ) */
68 _ISgraph
|_ISprint
|_ISpunct
, /* * */
69 _ISgraph
|_ISprint
|_ISpunct
, /* + */
70 _ISgraph
|_ISprint
|_ISpunct
, /* , */
71 _ISgraph
|_ISprint
|_ISpunct
, /* - */
72 _ISgraph
|_ISprint
|_ISpunct
, /* . */
73 _ISgraph
|_ISprint
|_ISpunct
, /* / */
74 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 0 */
75 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 1 */
76 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 2 */
77 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 3 */
78 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 4 */
79 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 5 */
80 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 6 */
81 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 7 */
82 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 8 */
83 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 9 */
84 _ISgraph
|_ISprint
|_ISpunct
, /* : */
85 _ISgraph
|_ISprint
|_ISpunct
, /* ; */
86 _ISgraph
|_ISprint
|_ISpunct
, /* < */
87 _ISgraph
|_ISprint
|_ISpunct
, /* = */
88 _ISgraph
|_ISprint
|_ISpunct
, /* > */
89 _ISgraph
|_ISprint
|_ISpunct
, /* ? */
90 _ISgraph
|_ISprint
|_ISpunct
, /* @ */
91 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* A */
92 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* B */
93 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* C */
94 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* D */
95 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* E */
96 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* F */
97 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* G */
98 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* H */
99 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* I */
100 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* J */
101 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* K */
102 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* L */
103 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* M */
104 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* N */
105 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* O */
106 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* P */
107 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Q */
108 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* R */
109 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* S */
110 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* T */
111 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* U */
112 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* V */
113 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* W */
114 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* X */
115 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Y */
116 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Z */
117 _ISgraph
|_ISprint
|_ISpunct
, /* [ */
118 _ISgraph
|_ISprint
|_ISpunct
, /* \ */
119 _ISgraph
|_ISprint
|_ISpunct
, /* ] */
120 _ISgraph
|_ISprint
|_ISpunct
, /* ^ */
121 _ISgraph
|_ISprint
|_ISpunct
, /* _ */
122 _ISgraph
|_ISprint
|_ISpunct
, /* ` */
123 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* a */
124 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* b */
125 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* c */
126 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* d */
127 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* e */
128 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* f */
129 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* g */
130 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* h */
131 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* i */
132 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* j */
133 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* k */
134 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* l */
135 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* m */
136 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* n */
137 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* o */
138 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* p */
139 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* q */
140 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* r */
141 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* s */
142 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* t */
143 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* u */
144 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* v */
145 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* w */
146 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* x */
147 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* y */
148 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* z */
149 _ISgraph
|_ISprint
|_ISpunct
, /* { */
150 _ISgraph
|_ISprint
|_ISpunct
, /* | */
151 _ISgraph
|_ISprint
|_ISpunct
, /* } */
152 _ISgraph
|_ISprint
|_ISpunct
, /* ~ */
284 static const unsigned char __ctype_toupper_array
[256] =
286 0, 1, 2, 3, 4, 5, 6, 7,
287 8, 9, 10, 11, 12, 13, 14, 15,
288 16, 17, 18, 19, 20, 21, 22, 23,
289 24, 25, 26, 27, 28, 29, 30, 31,
290 ' ','!','"','#', '$','%','&','\'',
291 '(',')','*','+', ',','-','.','/',
292 '0','1','2','3', '4','5','6','7',
293 '8','9',':',';', '<','=','>','?',
294 '@','A','B','C', 'D','E','F','G',
295 'H','I','J','K', 'L','M','N','O',
296 'P','Q','R','S', 'T','U','V','W',
297 'X','Y','Z','[', '\\',']','^','_',
298 '`','A','B','C', 'D','E','F','G',
299 'H','I','J','K', 'L','M','N','O',
300 'P','Q','R','S', 'T','U','V','W',
301 'X','Y','Z','{', '|','}','~',127,
303 128,129,130,131, 132,133,134,135,
304 136,137,138,139, 140,141,142,143,
305 144,145,146,147, 148,149,150,151,
306 152,153,154,155, 156,157,158,159,
307 160,161,162,163, 164,165,166,167,
308 168,169,170,171, 172,173,174,175,
309 176,177,178,179, 180,181,182,183,
310 184,185,186,187, 188,189,190,191,
311 192,193,194,195, 196,197,198,199,
312 200,201,202,203, 204,205,206,207,
313 208,209,210,211, 212,213,214,215,
314 216,217,218,219, 220,221,222,223,
315 224,225,226,227, 228,229,230,231,
316 232,233,234,235, 236,237,238,239,
317 240,241,242,243, 244,245,246,247,
318 248,249,250,251, 252,253,254,255,
321 static const unsigned char __ctype_tolower_array
[256] =
323 0, 1, 2, 3, 4, 5, 6, 7,
324 8, 9, 10, 11, 12, 13, 14, 15,
325 16, 17, 18, 19, 20, 21, 22, 23,
326 24, 25, 26, 27, 28, 29, 30, 31,
327 ' ','!','"','#', '$','%','&','\'',
328 '(',')','*','+', ',','-','.','/',
329 '0','1','2','3', '4','5','6','7',
330 '8','9',':',';', '<','=','>','?',
331 '@','a','b','c', 'd','e','f','g',
332 'h','i','j','k', 'l','m','n','o',
333 'p','q','r','s', 't','u','v','w',
334 'x','y','z','[', '\\',']','^','_',
335 '`','a','b','c', 'd','e','f','g',
336 'h','i','j','k', 'l','m','n','o',
337 'p','q','r','s', 't','u','v','w',
338 'x','y','z','{', '|','}','~',127,
340 128,129,130,131, 132,133,134,135,
341 136,137,138,139, 140,141,142,143,
342 144,145,146,147, 148,149,150,151,
343 152,153,154,155, 156,157,158,159,
344 160,161,162,163, 164,165,166,167,
345 168,169,170,171, 172,173,174,175,
346 176,177,178,179, 180,181,182,183,
347 184,185,186,187, 188,189,190,191,
348 192,193,194,195, 196,197,198,199,
349 200,201,202,203, 204,205,206,207,
350 208,209,210,211, 212,213,214,215,
351 216,217,218,219, 220,221,222,223,
352 224,225,226,227, 228,229,230,231,
353 232,233,234,235, 236,237,238,239,
354 240,241,242,243, 244,245,246,247,
355 248,249,250,251, 252,253,254,255,
359 const unsigned short *__ctype_b
= &__ctype_b_array
[0];
360 const unsigned char *__ctype_toupper
= &__ctype_toupper_array
[0];
361 const unsigned char *__ctype_tolower
= &__ctype_tolower_array
[0];
363 const struct arosc_ctype
*__get_arosc_ctype(void)
365 return &__get_arosc_userdata()->acud_ctype
;
368 static int __ctype_init(struct ExecBase
*SysBase
)
370 struct arosc_userdata
*acud
= __get_arosc_userdata();
372 acud
->acud_ctype
.b
= __ctype_b
;
373 acud
->acud_ctype
.toupper
= __ctype_toupper
;
374 acud
->acud_ctype
.tolower
= __ctype_tolower
;
379 ADD2INIT(__ctype_init
, 20);
381 const unsigned short * const __ctype_b
= &__ctype_b_array
[0];
382 const unsigned char * const __ctype_toupper
= &__ctype_toupper_array
[0];
383 const unsigned char * const __ctype_tolower
= &__ctype_tolower_array
[0];
386 /*****************************************************************************
397 Test if a character is uppercase. Works for all characters between
398 -128 and 255 inclusive both.
401 c - The character to test.
404 != 0 if the character is uppercase, 0 otherwise.
409 isupper ('A') -> true
410 isupper ('a') -> false
411 isupper ('0') -> false
412 isupper ('.') -> false
413 isupper ('\n') -> false
414 isupper ('\001') -> false
415 isupper (EOF) -> false
423 ******************************************************************************/
424 /*****************************************************************************
435 Test if a character is lowercase. Works for all characters between
436 -128 and 255 inclusive both.
439 c - The character to test.
442 != 0 if the character is lowercase, 0 otherwise.
447 islower ('A') -> false
448 islower ('a') -> true
449 islower ('0') -> false
450 islower ('.') -> false
451 islower ('\n') -> false
452 islower ('\001') -> false
453 islower (EOF) -> false
461 ******************************************************************************/
462 /******************************************************************************
473 Test if a character is an alphabetic character. Works for all
474 characters between -128 and 255 inclusive both.
477 c - The character to test.
480 != 0 if the character is an alphabetic character, 0 otherwise.
485 isalpha ('A') -> true
486 isalpha ('a') -> true
487 isalpha ('0') -> false
488 isalpha ('.') -> false
489 isalpha ('\n') -> false
490 isalpha ('\001') -> false
491 isalpha (EOF) -> false
499 ******************************************************************************/
500 /*****************************************************************************
511 Test if a character is an alphabetic character or a digit. Works
512 for all characters between -128 and 255 inclusive both.
515 c - The character to test.
518 != 0 if the character is alphabetic character or a digit, 0 otherwise.
523 isalnum ('A') -> true
524 isalnum ('a') -> true
525 isalnum ('0') -> true
526 isalnum ('.') -> false
527 isalnum ('\n') -> false
528 isalnum ('\001') -> false
529 isalnum (EOF) -> false
537 ******************************************************************************/
538 /*****************************************************************************
549 Test if a character is an ascii character. Works for all characters
550 between -128 and 255 inclusive both.
553 c - The character to test.
556 != 0 if the character is an ascii character, 0 otherwise.
561 isascii ('A') -> true
562 isascii ('a') -> true
563 isascii ('0') -> true
564 isascii ('.') -> true
565 isascii ('\n') -> true
566 isascii ('\001') -> true
567 isascii (EOF) -> false
575 ******************************************************************************/
576 /*****************************************************************************
587 Test if a character is a space or a tab. Works for all characters
588 between -128 and 255 inclusive both.
591 c - The character to test.
594 != 0 if the character is a space or tab, 0 otherwise.
599 isblank ('A') -> false
600 isblank ('a') -> false
601 isblank ('0') -> false
602 isblank ('.') -> false
603 isblank (' ') -> true
604 isblank ('\n') -> false
605 isblank ('\001') -> false
606 isblank (EOF) -> false
614 ******************************************************************************/
615 /*****************************************************************************
626 Test if a character is a control character. Works for all
627 characters between -128 and 255 inclusive both.
630 c - The character to test.
633 != 0 if the character is a control character, 0 otherwise.
638 iscntrl ('A') -> false
639 iscntrl ('a') -> false
640 iscntrl ('0') -> false
641 iscntrl ('.') -> false
642 iscntrl ('\n') -> true
643 iscntrl ('\001') -> true
644 iscntrl (EOF) -> false
652 ******************************************************************************/
653 /*****************************************************************************
664 Test if a character is a digit. Works for all characters between
665 -128 and 255 inclusive both.
668 c - The character to test.
671 != 0 if the character is a digit, 0 otherwise.
676 isdigit ('A') -> false
677 isdigit ('a') -> false
678 isdigit ('0') -> true
679 isdigit ('.') -> false
680 isdigit ('\n') -> false
681 isdigit ('\001') -> false
682 isdigit (EOF) -> false
690 ******************************************************************************/
691 /*****************************************************************************
702 Test if a character is a printable character but no whitespace.
703 Works for all characters between -128 and 255 inclusive both.
706 c - The character to test.
709 != 0 if the character is a printable character but no whitespace, 0
715 isgraph ('A') -> true
716 isgraph ('a') -> true
717 isgraph ('0') -> true
718 isgraph ('.') -> true
719 isgraph ('\n') -> false
720 isgraph ('\001') -> false
721 isgraph (EOF) -> false
729 ******************************************************************************/
730 /*****************************************************************************
741 Test if a character is a printable character. Works for all
742 characters between -128 and 255 inclusive both.
745 c - The character to test.
748 != 0 if the character is a printable character, 0 otherwise.
753 isprint ('A') -> true
754 isprint ('a') -> true
755 isprint ('0') -> true
756 isprint ('.') -> true
757 isprint ('\n') -> true
758 isprint ('\001') -> false
759 isprint (EOF) -> false
767 ******************************************************************************/
768 /*****************************************************************************
779 Test if a character is whitespace. Works for all characters between
780 -128 and 255 inclusive both.
783 c - The character to test.
786 != 0 if the character is whitespace, 0 otherwise.
791 isspace ('A') -> false
792 isspace ('a') -> false
793 isspace ('0') -> false
794 isspace ('.') -> false
795 isspace ('\n') -> true
796 isspace ('\001') -> false
797 isspace (EOF) -> false
805 ******************************************************************************/
806 /*****************************************************************************
817 Test if a character is printable but not alphanumeric. Works for
818 all characters between -128 and 255 inclusive both.
821 c - The character to test.
824 != 0 if the character is printable but not alphanumeric, 0
830 ispunct ('A') -> false
831 ispunct ('a') -> false
832 ispunct ('0') -> false
833 ispunct ('.') -> true
834 ispunct ('\n') -> false
835 ispunct ('\001') -> false
836 ispunct (EOF) -> false
844 ******************************************************************************/
845 /*****************************************************************************
856 Test if a character is a hexadecimal digit. Works for all
857 characters between -128 and 255 inclusive both.
860 c - The character to test.
863 != 0 if the character is a hexadecimal digit, 0 otherwise.
868 isxdigit ('A') -> true
869 isxdigit ('a') -> true
870 isxdigit ('x') -> false
871 isxdigit ('0') -> true
872 isxdigit ('.') -> false
873 isxdigit ('\n') -> false
874 isxdigit ('\001') -> false
875 isxdigit (EOF) -> false
883 ******************************************************************************/