2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 #include <aros/symbolsets.h>
9 #include "__arosc_privdata.h"
11 const unsigned short int __ctype_b_array
[384] =
149 _IScntrl
, /* Backspace */
150 _ISblank
|_IScntrl
|_ISspace
, /* 9 */
151 _IScntrl
|_ISspace
, /* LF */
152 _IScntrl
|_ISspace
, /* 11 */
153 _IScntrl
|_ISspace
, /* 12 */
154 _IScntrl
|_ISspace
, /* CR */
173 _ISblank
|_ISprint
|_ISspace
, /* Space */
174 _ISgraph
|_ISprint
|_ISpunct
, /* ! */
175 _ISgraph
|_ISprint
|_ISpunct
, /* " */
176 _ISgraph
|_ISprint
|_ISpunct
, /* # */
177 _ISgraph
|_ISprint
|_ISpunct
, /* $ */
178 _ISgraph
|_ISprint
|_ISpunct
, /* % */
179 _ISgraph
|_ISprint
|_ISpunct
, /* & */
180 _ISgraph
|_ISprint
|_ISpunct
, /* ' */
181 _ISgraph
|_ISprint
|_ISpunct
, /* ( */
182 _ISgraph
|_ISprint
|_ISpunct
, /* ) */
183 _ISgraph
|_ISprint
|_ISpunct
, /* * */
184 _ISgraph
|_ISprint
|_ISpunct
, /* + */
185 _ISgraph
|_ISprint
|_ISpunct
, /* , */
186 _ISgraph
|_ISprint
|_ISpunct
, /* - */
187 _ISgraph
|_ISprint
|_ISpunct
, /* . */
188 _ISgraph
|_ISprint
|_ISpunct
, /* / */
189 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 0 */
190 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 1 */
191 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 2 */
192 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 3 */
193 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 4 */
194 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 5 */
195 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 6 */
196 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 7 */
197 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 8 */
198 _ISdigit
|_ISgraph
|_ISprint
|_ISxdigit
, /* 9 */
199 _ISgraph
|_ISprint
|_ISpunct
, /* : */
200 _ISgraph
|_ISprint
|_ISpunct
, /* ; */
201 _ISgraph
|_ISprint
|_ISpunct
, /* < */
202 _ISgraph
|_ISprint
|_ISpunct
, /* = */
203 _ISgraph
|_ISprint
|_ISpunct
, /* > */
204 _ISgraph
|_ISprint
|_ISpunct
, /* ? */
205 _ISgraph
|_ISprint
|_ISpunct
, /* @ */
206 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* A */
207 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* B */
208 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* C */
209 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* D */
210 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* E */
211 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* F */
212 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* G */
213 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* H */
214 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* I */
215 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* J */
216 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* K */
217 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* L */
218 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* M */
219 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* N */
220 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* O */
221 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* P */
222 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Q */
223 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* R */
224 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* S */
225 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* T */
226 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* U */
227 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* V */
228 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* W */
229 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* X */
230 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Y */
231 _ISupper
|_ISalpha
|_ISgraph
|_ISprint
, /* Z */
232 _ISgraph
|_ISprint
|_ISpunct
, /* [ */
233 _ISgraph
|_ISprint
|_ISpunct
, /* \ */
234 _ISgraph
|_ISprint
|_ISpunct
, /* ] */
235 _ISgraph
|_ISprint
|_ISpunct
, /* ^ */
236 _ISgraph
|_ISprint
|_ISpunct
, /* _ */
237 _ISgraph
|_ISprint
|_ISpunct
, /* ` */
238 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* a */
239 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* b */
240 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* c */
241 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* d */
242 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* e */
243 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
|_ISxdigit
, /* f */
244 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* g */
245 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* h */
246 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* i */
247 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* j */
248 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* k */
249 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* l */
250 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* m */
251 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* n */
252 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* o */
253 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* p */
254 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* q */
255 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* r */
256 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* s */
257 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* t */
258 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* u */
259 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* v */
260 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* w */
261 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* x */
262 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* y */
263 _ISlower
|_ISalpha
|_ISgraph
|_ISprint
, /* z */
264 _ISgraph
|_ISprint
|_ISpunct
, /* { */
265 _ISgraph
|_ISprint
|_ISpunct
, /* | */
266 _ISgraph
|_ISprint
|_ISpunct
, /* } */
267 _ISgraph
|_ISprint
|_ISpunct
, /* ~ */
399 const int __ctype_toupper_array
[384] =
402 128,129,130,131, 132,133,134,135,
403 136,137,138,139, 140,141,142,143,
404 144,145,146,147, 148,149,150,151,
405 152,153,154,155, 156,157,158,159,
406 160,161,162,163, 164,165,166,167,
407 168,169,170,171, 172,173,174,175,
408 176,177,178,179, 180,181,182,183,
409 184,185,186,187, 188,189,190,191,
410 192,193,194,195, 196,197,198,199,
411 200,201,202,203, 204,205,206,207,
412 208,209,210,211, 212,213,214,215,
413 216,217,218,219, 220,221,222,223,
414 224,225,226,227, 228,229,230,231,
415 232,233,234,235, 236,237,238,239,
416 240,241,242,243, 244,245,246,247,
417 248,249,250,251, 252,253,254,255,
419 0, 1, 2, 3, 4, 5, 6, 7,
420 8, 9, 10, 11, 12, 13, 14, 15,
421 16, 17, 18, 19, 20, 21, 22, 23,
422 24, 25, 26, 27, 28, 29, 30, 31,
423 ' ','!','"','#', '$','%','&','\'',
424 '(',')','*','+', ',','-','.','/',
425 '0','1','2','3', '4','5','6','7',
426 '8','9',':',';', '<','=','>','?',
427 '@','A','B','C', 'D','E','F','G',
428 'H','I','J','K', 'L','M','N','O',
429 'P','Q','R','S', 'T','U','V','W',
430 'X','Y','Z','[', '\\',']','^','_',
431 '`','A','B','C', 'D','E','F','G',
432 'H','I','J','K', 'L','M','N','O',
433 'P','Q','R','S', 'T','U','V','W',
434 'X','Y','Z','{', '|','}','~',127,
436 128,129,130,131, 132,133,134,135,
437 136,137,138,139, 140,141,142,143,
438 144,145,146,147, 148,149,150,151,
439 152,153,154,155, 156,157,158,159,
440 160,161,162,163, 164,165,166,167,
441 168,169,170,171, 172,173,174,175,
442 176,177,178,179, 180,181,182,183,
443 184,185,186,187, 188,189,190,191,
444 192,193,194,195, 196,197,198,199,
445 200,201,202,203, 204,205,206,207,
446 208,209,210,211, 212,213,214,215,
447 216,217,218,219, 220,221,222,223,
448 224,225,226,227, 228,229,230,231,
449 232,233,234,235, 236,237,238,239,
450 240,241,242,243, 244,245,246,247,
451 248,249,250,251, 252,253,254,255,
454 const int __ctype_tolower_array
[384] =
456 128,129,130,131, 132,133,134,135,
457 136,137,138,139, 140,141,142,143,
458 144,145,146,147, 148,149,150,151,
459 152,153,154,155, 156,157,158,159,
460 160,161,162,163, 164,165,166,167,
461 168,169,170,171, 172,173,174,175,
462 176,177,178,179, 180,181,182,183,
463 184,185,186,187, 188,189,190,191,
464 192,193,194,195, 196,197,198,199,
465 200,201,202,203, 204,205,206,207,
466 208,209,210,211, 212,213,214,215,
467 216,217,218,219, 220,221,222,223,
468 224,225,226,227, 228,229,230,231,
469 232,233,234,235, 236,237,238,239,
470 240,241,242,243, 244,245,246,247,
471 248,249,250,251, 252,253,254,255,
473 0, 1, 2, 3, 4, 5, 6, 7,
474 8, 9, 10, 11, 12, 13, 14, 15,
475 16, 17, 18, 19, 20, 21, 22, 23,
476 24, 25, 26, 27, 28, 29, 30, 31,
477 ' ','!','"','#', '$','%','&','\'',
478 '(',')','*','+', ',','-','.','/',
479 '0','1','2','3', '4','5','6','7',
480 '8','9',':',';', '<','=','>','?',
481 '@','a','b','c', 'd','e','f','g',
482 'h','i','j','k', 'l','m','n','o',
483 'p','q','r','s', 't','u','v','w',
484 'x','y','z','[', '\\',']','^','_',
485 '`','a','b','c', 'd','e','f','g',
486 'h','i','j','k', 'l','m','n','o',
487 'p','q','r','s', 't','u','v','w',
488 'x','y','z','{', '|','}','~',127,
490 128,129,130,131, 132,133,134,135,
491 136,137,138,139, 140,141,142,143,
492 144,145,146,147, 148,149,150,151,
493 152,153,154,155, 156,157,158,159,
494 160,161,162,163, 164,165,166,167,
495 168,169,170,171, 172,173,174,175,
496 176,177,178,179, 180,181,182,183,
497 184,185,186,187, 188,189,190,191,
498 192,193,194,195, 196,197,198,199,
499 200,201,202,203, 204,205,206,207,
500 208,209,210,211, 212,213,214,215,
501 216,217,218,219, 220,221,222,223,
502 224,225,226,227, 228,229,230,231,
503 232,233,234,235, 236,237,238,239,
504 240,241,242,243, 244,245,246,247,
505 248,249,250,251, 252,253,254,255,
509 const struct arosc_ctype
*__get_arosc_ctype(void)
511 return &__get_arosc_userdata()->acud_ctype
;
514 static int __ctype_init(void)
516 struct arosc_userdata
*acud
= __get_arosc_userdata();
518 acud
->acud_ctype
.b
= &__ctype_b_array
[128];
519 acud
->acud_ctype
.toupper
= &__ctype_toupper_array
[128];
520 acud
->acud_ctype
.tolower
= &__ctype_tolower_array
[128];
525 ADD2INIT(__ctype_init
, 20);
528 /* Pointers have to be available both when in static linklib and
529 internally to arosc.library also
531 const unsigned short int * const __ctype_b
= &__ctype_b_array
[128];
532 const int * const __ctype_toupper
= &__ctype_toupper_array
[128];
533 const int * const __ctype_tolower
= &__ctype_tolower_array
[128];
535 /*****************************************************************************
546 Test if a character is uppercase. Works for all characters between
547 -128 and 255 inclusive both.
550 c - The character to test.
553 != 0 if the character is uppercase, 0 otherwise.
558 isupper ('A') -> true
559 isupper ('a') -> false
560 isupper ('0') -> false
561 isupper ('.') -> false
562 isupper ('\n') -> false
563 isupper ('\001') -> false
564 isupper (EOF) -> false
572 ******************************************************************************/
573 /*****************************************************************************
584 Test if a character is lowercase. Works for all characters between
585 -128 and 255 inclusive both.
588 c - The character to test.
591 != 0 if the character is lowercase, 0 otherwise.
596 islower ('A') -> false
597 islower ('a') -> true
598 islower ('0') -> false
599 islower ('.') -> false
600 islower ('\n') -> false
601 islower ('\001') -> false
602 islower (EOF) -> false
610 ******************************************************************************/
611 /******************************************************************************
622 Test if a character is an alphabetic character. Works for all
623 characters between -128 and 255 inclusive both.
626 c - The character to test.
629 != 0 if the character is an alphabetic character, 0 otherwise.
634 isalpha ('A') -> true
635 isalpha ('a') -> true
636 isalpha ('0') -> false
637 isalpha ('.') -> false
638 isalpha ('\n') -> false
639 isalpha ('\001') -> false
640 isalpha (EOF) -> false
648 ******************************************************************************/
649 /*****************************************************************************
660 Test if a character is an alphabetic character or a digit. Works
661 for all characters between -128 and 255 inclusive both.
664 c - The character to test.
667 != 0 if the character is alphabetic character or a digit, 0 otherwise.
672 isalnum ('A') -> true
673 isalnum ('a') -> true
674 isalnum ('0') -> true
675 isalnum ('.') -> false
676 isalnum ('\n') -> false
677 isalnum ('\001') -> false
678 isalnum (EOF) -> false
686 ******************************************************************************/
687 /*****************************************************************************
698 Test if a character is an ascii character. Works for all characters
699 between -128 and 255 inclusive both.
702 c - The character to test.
705 != 0 if the character is an ascii character, 0 otherwise.
710 isascii ('A') -> true
711 isascii ('a') -> true
712 isascii ('0') -> true
713 isascii ('.') -> true
714 isascii ('\n') -> true
715 isascii ('\001') -> true
716 isascii (EOF) -> false
724 ******************************************************************************/
725 /*****************************************************************************
736 Test if a character is a space or a tab. Works for all characters
737 between -128 and 255 inclusive both.
740 c - The character to test.
743 != 0 if the character is a space or tab, 0 otherwise.
748 isblank ('A') -> false
749 isblank ('a') -> false
750 isblank ('0') -> false
751 isblank ('.') -> false
752 isblank (' ') -> true
753 isblank ('\n') -> false
754 isblank ('\001') -> false
755 isblank (EOF) -> false
763 ******************************************************************************/
764 /*****************************************************************************
775 Test if a character is a control character. Works for all
776 characters between -128 and 255 inclusive both.
779 c - The character to test.
782 != 0 if the character is a control character, 0 otherwise.
787 iscntrl ('A') -> false
788 iscntrl ('a') -> false
789 iscntrl ('0') -> false
790 iscntrl ('.') -> false
791 iscntrl ('\n') -> true
792 iscntrl ('\001') -> true
793 iscntrl (EOF) -> false
801 ******************************************************************************/
802 /*****************************************************************************
813 Test if a character is a digit. Works for all characters between
814 -128 and 255 inclusive both.
817 c - The character to test.
820 != 0 if the character is a digit, 0 otherwise.
825 isdigit ('A') -> false
826 isdigit ('a') -> false
827 isdigit ('0') -> true
828 isdigit ('.') -> false
829 isdigit ('\n') -> false
830 isdigit ('\001') -> false
831 isdigit (EOF) -> false
839 ******************************************************************************/
840 /*****************************************************************************
851 Test if a character is a printable character but no whitespace.
852 Works for all characters between -128 and 255 inclusive both.
855 c - The character to test.
858 != 0 if the character is a printable character but no whitespace, 0
864 isgraph ('A') -> true
865 isgraph ('a') -> true
866 isgraph ('0') -> true
867 isgraph ('.') -> true
868 isgraph ('\n') -> false
869 isgraph ('\001') -> false
870 isgraph (EOF) -> false
878 ******************************************************************************/
879 /*****************************************************************************
890 Test if a character is a printable character. Works for all
891 characters between -128 and 255 inclusive both.
894 c - The character to test.
897 != 0 if the character is a printable character, 0 otherwise.
902 isprint ('A') -> true
903 isprint ('a') -> true
904 isprint ('0') -> true
905 isprint ('.') -> true
906 isprint ('\n') -> true
907 isprint ('\001') -> false
908 isprint (EOF) -> false
916 ******************************************************************************/
917 /*****************************************************************************
928 Test if a character is whitespace. Works for all characters between
929 -128 and 255 inclusive both.
932 c - The character to test.
935 != 0 if the character is whitespace, 0 otherwise.
940 isspace ('A') -> false
941 isspace ('a') -> false
942 isspace ('0') -> false
943 isspace ('.') -> false
944 isspace ('\n') -> true
945 isspace ('\001') -> false
946 isspace (EOF) -> false
954 ******************************************************************************/
955 /*****************************************************************************
966 Test if a character is printable but not alphanumeric. Works for
967 all characters between -128 and 255 inclusive both.
970 c - The character to test.
973 != 0 if the character is printable but not alphanumeric, 0
979 ispunct ('A') -> false
980 ispunct ('a') -> false
981 ispunct ('0') -> false
982 ispunct ('.') -> true
983 ispunct ('\n') -> false
984 ispunct ('\001') -> false
985 ispunct (EOF) -> false
993 ******************************************************************************/
994 /*****************************************************************************
1005 Test if a character is a hexadecimal digit. Works for all
1006 characters between -128 and 255 inclusive both.
1009 c - The character to test.
1012 != 0 if the character is a hexadecimal digit, 0 otherwise.
1017 isxdigit ('A') -> true
1018 isxdigit ('a') -> true
1019 isxdigit ('x') -> false
1020 isxdigit ('0') -> true
1021 isxdigit ('.') -> false
1022 isxdigit ('\n') -> false
1023 isxdigit ('\001') -> false
1024 isxdigit (EOF) -> false
1032 ******************************************************************************/