exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / c32_get_type_test.c
blob90bee394e7361e3be9df7a04552a3ac1b7a42ee3
1 /* Get descriptor for a 32-bit wide character property.
2 Copyright (C) 2011-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2023. */
19 #include <config.h>
21 #define IN_C32_GET_TYPE_TEST
22 /* Specification. */
23 #include <uchar.h>
25 #include <string.h>
26 #include <wctype.h>
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)
34 #if _GL_WCHAR_T_IS_UCS4
35 return wctype (name);
36 #else
37 switch (name[0])
39 case 'a':
40 switch (name[1])
42 case 'l':
43 switch (name[2])
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;
56 break;
57 default:
58 break;
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])
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;
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;
111 return (c32_type_test_t) 0;
112 #endif