| 1 |
/* Get descriptor for a 32-bit wide character property. |
| 2 |
Copyright (C) 2011-2024 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This file is free software: you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU Lesser General Public License as |
| 6 |
published by the Free Software Foundation; either version 2.1 of the |
| 7 |
License, or (at your option) any later version. |
| 8 |
|
| 9 |
This file is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
/* Written by Bruno Haible <[email protected]>, 2023. */ |
| 18 |
|
| 19 |
#include <config.h> |
| 20 |
|
| 21 |
#define IN_C32_GET_TYPE_TEST |
| 22 |
/* Specification. */ |
| 23 |
#include <uchar.h> |
| 24 |
|
| 25 |
#include <string.h> |
| 26 |
#include <wctype.h> |
| 27 |
|
| 28 |
#if _GL_WCHAR_T_IS_UCS4 |
| 29 |
_GL_EXTERN_INLINE |
| 30 |
#endif |
| 31 |
c32_type_test_t |
| 32 |
c32_get_type_test (const char *name) |
| 33 |
{ |
| 34 |
#if _GL_WCHAR_T_IS_UCS4 |
| 35 |
return wctype (name); |
| 36 |
#else |
| 37 |
switch (name[0]) |
| 38 |
{ |
| 39 |
case 'a': |
| 40 |
switch (name[1]) |
| 41 |
{ |
| 42 |
case 'l': |
| 43 |
switch (name[2]) |
| 44 |
{ |
| 45 |
case 'n': |
| 46 |
if (strcmp (name + 3, "um") == 0) |
| 47 |
return c32isalnum; |
| 48 |
break; |
| 49 |
case 'p': |
| 50 |
if (strcmp (name + 3, "ha") == 0) |
| 51 |
return c32isalpha; |
| 52 |
break; |
| 53 |
default: |
| 54 |
break; |
| 55 |
} |
| 56 |
break; |
| 57 |
default: |
| 58 |
break; |
| 59 |
} |
| 60 |
break; |
| 61 |
case 'b': |
| 62 |
if (strcmp (name + 1, "lank") == 0) |
| 63 |
return c32isblank; |
| 64 |
break; |
| 65 |
case 'c': |
| 66 |
if (strcmp (name + 1, "ntrl") == 0) |
| 67 |
return c32iscntrl; |
| 68 |
break; |
| 69 |
case 'd': |
| 70 |
if (strcmp (name + 1, "igit") == 0) |
| 71 |
return c32isdigit; |
| 72 |
break; |
| 73 |
case 'g': |
| 74 |
if (strcmp (name + 1, "raph") == 0) |
| 75 |
return c32isgraph; |
| 76 |
break; |
| 77 |
case 'l': |
| 78 |
if (strcmp (name + 1, "ower") == 0) |
| 79 |
return c32islower; |
| 80 |
break; |
| 81 |
case 'p': |
| 82 |
switch (name[1]) |
| 83 |
{ |
| 84 |
case 'r': |
| 85 |
if (strcmp (name + 2, "int") == 0) |
| 86 |
return c32isprint; |
| 87 |
break; |
| 88 |
case 'u': |
| 89 |
if (strcmp (name + 2, "nct") == 0) |
| 90 |
return c32ispunct; |
| 91 |
break; |
| 92 |
default: |
| 93 |
break; |
| 94 |
} |
| 95 |
break; |
| 96 |
case 's': |
| 97 |
if (strcmp (name + 1, "pace") == 0) |
| 98 |
return c32isspace; |
| 99 |
break; |
| 100 |
case 'u': |
| 101 |
if (strcmp (name + 1, "pper") == 0) |
| 102 |
return c32isupper; |
| 103 |
break; |
| 104 |
case 'x': |
| 105 |
if (strcmp (name + 1, "digit") == 0) |
| 106 |
return c32isxdigit; |
| 107 |
break; |
| 108 |
default: |
| 109 |
break; |
| 110 |
} |
| 111 |
return (c32_type_test_t) 0; |
| 112 |
#endif |
| 113 |
} |