| 1 | /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
|
|---|
| 2 |
|
|---|
| 3 | Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
|---|
| 4 |
|
|---|
| 5 | This file is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU Lesser General Public License as
|
|---|
| 7 | published by the Free Software Foundation; either version 2.1 of the
|
|---|
| 8 | License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This file is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU Lesser General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Lesser General Public License
|
|---|
| 16 | along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|---|
| 17 |
|
|---|
| 18 | /* Written by Bruno Haible and Paul Eggert. */
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | * ISO C 99 <wctype.h> for platforms that lack it.
|
|---|
| 22 | * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html>
|
|---|
| 23 | *
|
|---|
| 24 | * iswctype, towctrans, towlower, towupper, wctrans, wctype,
|
|---|
| 25 | * wctrans_t, and wctype_t are not yet implemented.
|
|---|
| 26 | */
|
|---|
| 27 |
|
|---|
| 28 | #if __GNUC__ >= 3
|
|---|
| 29 | @PRAGMA_SYSTEM_HEADER@
|
|---|
| 30 | #endif
|
|---|
| 31 | @PRAGMA_COLUMNS@
|
|---|
| 32 |
|
|---|
| 33 | #if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
|
|---|
| 34 |
|
|---|
| 35 | /* Special invocation convention:
|
|---|
| 36 | - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
|
|---|
| 37 | <wctype.h> is being processed, which doesn't include the idempotency
|
|---|
| 38 | guard. */
|
|---|
| 39 |
|
|---|
| 40 | #@INCLUDE_NEXT@ @NEXT_WCTYPE_H@
|
|---|
| 41 |
|
|---|
| 42 | #else
|
|---|
| 43 | /* Normal invocation convention. */
|
|---|
| 44 |
|
|---|
| 45 | #ifndef _@GUARD_PREFIX@_WCTYPE_H
|
|---|
| 46 |
|
|---|
| 47 | #if @HAVE_WINT_T@
|
|---|
| 48 | /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
|---|
| 49 | # include <wchar.h>
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | /* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
|
|---|
| 53 | isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include
|
|---|
| 54 | <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
|
|---|
| 55 | declarations. */
|
|---|
| 56 | #if defined _WIN32 && ! defined __CYGWIN__
|
|---|
| 57 | # include <ctype.h>
|
|---|
| 58 | # include <wchar.h>
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | /* Include the original <wctype.h> if it exists.
|
|---|
| 62 | BeOS 5 has the functions but no <wctype.h>. */
|
|---|
| 63 | /* The include_next requires a split double-inclusion guard. */
|
|---|
| 64 | #if @HAVE_WCTYPE_H@
|
|---|
| 65 | # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
|
|---|
| 66 | #endif
|
|---|
| 67 |
|
|---|
| 68 | #ifndef _@GUARD_PREFIX@_WCTYPE_H
|
|---|
| 69 | #define _@GUARD_PREFIX@_WCTYPE_H
|
|---|
| 70 |
|
|---|
| 71 | #ifndef _GL_INLINE_HEADER_BEGIN
|
|---|
| 72 | #error "Please include config.h first."
|
|---|
| 73 | #endif
|
|---|
| 74 | _GL_INLINE_HEADER_BEGIN
|
|---|
| 75 | #ifndef _GL_WCTYPE_INLINE
|
|---|
| 76 | # define _GL_WCTYPE_INLINE _GL_INLINE
|
|---|
| 77 | #endif
|
|---|
| 78 |
|
|---|
| 79 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
|---|
| 80 |
|
|---|
| 81 | /* The definition of _GL_WARN_ON_USE is copied here. */
|
|---|
| 82 |
|
|---|
| 83 | /* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
|
|---|
| 84 | #defines a number of identifiers in the application namespace. Revert
|
|---|
| 85 | these #defines. */
|
|---|
| 86 | #ifdef __sun
|
|---|
| 87 | # undef multibyte
|
|---|
| 88 | # undef eucw1
|
|---|
| 89 | # undef eucw2
|
|---|
| 90 | # undef eucw3
|
|---|
| 91 | # undef scrw1
|
|---|
| 92 | # undef scrw2
|
|---|
| 93 | # undef scrw3
|
|---|
| 94 | #endif
|
|---|
| 95 |
|
|---|
| 96 | /* Define wint_t and WEOF. (Also done in wchar.in.h.) */
|
|---|
| 97 | #if !@HAVE_WINT_T@ && !defined wint_t
|
|---|
| 98 | # define wint_t int
|
|---|
| 99 | # ifndef WEOF
|
|---|
| 100 | # define WEOF -1
|
|---|
| 101 | # endif
|
|---|
| 102 | #else
|
|---|
| 103 | /* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
|
|---|
| 104 | <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
|
|---|
| 105 | wint_t must be "unchanged by default argument promotions". Override it. */
|
|---|
| 106 | # if @GNULIBHEADERS_OVERRIDE_WINT_T@
|
|---|
| 107 | # if !GNULIB_defined_wint_t
|
|---|
| 108 | # if @HAVE_CRTDEFS_H@
|
|---|
| 109 | # include <crtdefs.h>
|
|---|
| 110 | # else
|
|---|
| 111 | # include <stddef.h>
|
|---|
| 112 | # endif
|
|---|
| 113 | typedef unsigned int rpl_wint_t;
|
|---|
| 114 | # undef wint_t
|
|---|
| 115 | # define wint_t rpl_wint_t
|
|---|
| 116 | # define GNULIB_defined_wint_t 1
|
|---|
| 117 | # endif
|
|---|
| 118 | # endif
|
|---|
| 119 | # ifndef WEOF
|
|---|
| 120 | # define WEOF ((wint_t) -1)
|
|---|
| 121 | # endif
|
|---|
| 122 | #endif
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | #if !GNULIB_defined_wctype_functions
|
|---|
| 126 |
|
|---|
| 127 | /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
|
|---|
| 128 | Linux libc5 has <wctype.h> and the functions but they are broken.
|
|---|
| 129 | mingw and MSVC have <wctype.h> and the functions but they take a wchar_t
|
|---|
| 130 | as argument, not an rpl_wint_t.
|
|---|
| 131 | Assume all 11 functions (all isw* except iswblank) are implemented the
|
|---|
| 132 | same way, or not at all. */
|
|---|
| 133 | # if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
|
|---|
| 134 |
|
|---|
| 135 | # if @GNULIBHEADERS_OVERRIDE_WINT_T@ /* implies @REPLACE_ISWCNTRL@ */
|
|---|
| 136 |
|
|---|
| 137 | _GL_WCTYPE_INLINE int
|
|---|
| 138 | rpl_iswalnum (wint_t wc)
|
|---|
| 139 | {
|
|---|
| 140 | return ((wchar_t) wc == wc ? iswalnum ((wchar_t) wc) : 0);
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | _GL_WCTYPE_INLINE int
|
|---|
| 144 | rpl_iswalpha (wint_t wc)
|
|---|
| 145 | {
|
|---|
| 146 | return ((wchar_t) wc == wc ? iswalpha ((wchar_t) wc) : 0);
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | _GL_WCTYPE_INLINE int
|
|---|
| 150 | rpl_iswblank (wint_t wc)
|
|---|
| 151 | {
|
|---|
| 152 | return ((wchar_t) wc == wc ? iswblank ((wchar_t) wc) : 0);
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | _GL_WCTYPE_INLINE int
|
|---|
| 156 | rpl_iswcntrl (wint_t wc)
|
|---|
| 157 | {
|
|---|
| 158 | return ((wchar_t) wc == wc ? iswcntrl ((wchar_t) wc) : 0);
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | _GL_WCTYPE_INLINE int
|
|---|
| 162 | rpl_iswdigit (wint_t wc)
|
|---|
| 163 | {
|
|---|
| 164 | return ((wchar_t) wc == wc ? wc >= '0' && wc <= '9' : 0);
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | _GL_WCTYPE_INLINE int
|
|---|
| 168 | rpl_iswgraph (wint_t wc)
|
|---|
| 169 | {
|
|---|
| 170 | return ((wchar_t) wc == wc ? iswgraph ((wchar_t) wc) : 0);
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | _GL_WCTYPE_INLINE int
|
|---|
| 174 | rpl_iswlower (wint_t wc)
|
|---|
| 175 | {
|
|---|
| 176 | return ((wchar_t) wc == wc ? iswlower ((wchar_t) wc) : 0);
|
|---|
| 177 | }
|
|---|
| 178 |
|
|---|
| 179 | _GL_WCTYPE_INLINE int
|
|---|
| 180 | rpl_iswprint (wint_t wc)
|
|---|
| 181 | {
|
|---|
| 182 | return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0);
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | _GL_WCTYPE_INLINE int
|
|---|
| 186 | rpl_iswpunct (wint_t wc)
|
|---|
| 187 | {
|
|---|
| 188 | return ((wchar_t) wc == wc ? iswpunct ((wchar_t) wc) : 0);
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | _GL_WCTYPE_INLINE int
|
|---|
| 192 | rpl_iswspace (wint_t wc)
|
|---|
| 193 | {
|
|---|
| 194 | return ((wchar_t) wc == wc ? iswspace ((wchar_t) wc) : 0);
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | _GL_WCTYPE_INLINE int
|
|---|
| 198 | rpl_iswupper (wint_t wc)
|
|---|
| 199 | {
|
|---|
| 200 | return ((wchar_t) wc == wc ? iswupper ((wchar_t) wc) : 0);
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | _GL_WCTYPE_INLINE int
|
|---|
| 204 | rpl_iswxdigit (wint_t wc)
|
|---|
| 205 | {
|
|---|
| 206 | return ((wchar_t) wc == wc
|
|---|
| 207 | ? (wc >= '0' && wc <= '9')
|
|---|
| 208 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')
|
|---|
| 209 | : 0);
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | _GL_WCTYPE_INLINE wint_t
|
|---|
| 213 | rpl_towlower (wint_t wc)
|
|---|
| 214 | {
|
|---|
| 215 | return ((wchar_t) wc == wc ? (wchar_t) towlower ((wchar_t) wc) : wc);
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | _GL_WCTYPE_INLINE wint_t
|
|---|
| 219 | rpl_towupper (wint_t wc)
|
|---|
| 220 | {
|
|---|
| 221 | return ((wchar_t) wc == wc ? (wchar_t) towupper ((wchar_t) wc) : wc);
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 225 | # undef iswalnum
|
|---|
| 226 | # undef iswalpha
|
|---|
| 227 | # undef iswblank
|
|---|
| 228 | # undef iswcntrl
|
|---|
| 229 | # undef iswdigit
|
|---|
| 230 | # undef iswgraph
|
|---|
| 231 | # undef iswlower
|
|---|
| 232 | # undef iswprint
|
|---|
| 233 | # undef iswpunct
|
|---|
| 234 | # undef iswspace
|
|---|
| 235 | # undef iswupper
|
|---|
| 236 | # undef iswxdigit
|
|---|
| 237 | # undef towlower
|
|---|
| 238 | # undef towupper
|
|---|
| 239 | # define iswalnum rpl_iswalnum
|
|---|
| 240 | # define iswalpha rpl_iswalpha
|
|---|
| 241 | # define iswblank rpl_iswblank
|
|---|
| 242 | # define iswcntrl rpl_iswcntrl
|
|---|
| 243 | # define iswdigit rpl_iswdigit
|
|---|
| 244 | # define iswgraph rpl_iswgraph
|
|---|
| 245 | # define iswlower rpl_iswlower
|
|---|
| 246 | # define iswprint rpl_iswprint
|
|---|
| 247 | # define iswpunct rpl_iswpunct
|
|---|
| 248 | # define iswspace rpl_iswspace
|
|---|
| 249 | # define iswupper rpl_iswupper
|
|---|
| 250 | # define iswxdigit rpl_iswxdigit
|
|---|
| 251 | # define towlower rpl_towlower
|
|---|
| 252 | # define towupper rpl_towupper
|
|---|
| 253 | # endif
|
|---|
| 254 |
|
|---|
| 255 | # else
|
|---|
| 256 |
|
|---|
| 257 | /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
|
|---|
| 258 | undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
|
|---|
| 259 | refer to system functions like _iswctype that are not in the
|
|---|
| 260 | standard C library. Rather than try to get ancient buggy
|
|---|
| 261 | implementations like this to work, just disable them. */
|
|---|
| 262 | # undef iswalnum
|
|---|
| 263 | # undef iswalpha
|
|---|
| 264 | # undef iswblank
|
|---|
| 265 | # undef iswcntrl
|
|---|
| 266 | # undef iswdigit
|
|---|
| 267 | # undef iswgraph
|
|---|
| 268 | # undef iswlower
|
|---|
| 269 | # undef iswprint
|
|---|
| 270 | # undef iswpunct
|
|---|
| 271 | # undef iswspace
|
|---|
| 272 | # undef iswupper
|
|---|
| 273 | # undef iswxdigit
|
|---|
| 274 | # undef towlower
|
|---|
| 275 | # undef towupper
|
|---|
| 276 |
|
|---|
| 277 | /* Linux libc5 has <wctype.h> and the functions but they are broken. */
|
|---|
| 278 | # if @REPLACE_ISWCNTRL@
|
|---|
| 279 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 280 | # define iswalnum rpl_iswalnum
|
|---|
| 281 | # define iswalpha rpl_iswalpha
|
|---|
| 282 | # define iswblank rpl_iswblank
|
|---|
| 283 | # define iswcntrl rpl_iswcntrl
|
|---|
| 284 | # define iswdigit rpl_iswdigit
|
|---|
| 285 | # define iswgraph rpl_iswgraph
|
|---|
| 286 | # define iswlower rpl_iswlower
|
|---|
| 287 | # define iswprint rpl_iswprint
|
|---|
| 288 | # define iswpunct rpl_iswpunct
|
|---|
| 289 | # define iswspace rpl_iswspace
|
|---|
| 290 | # define iswupper rpl_iswupper
|
|---|
| 291 | # define iswxdigit rpl_iswxdigit
|
|---|
| 292 | # endif
|
|---|
| 293 | # endif
|
|---|
| 294 | # if @REPLACE_TOWLOWER@
|
|---|
| 295 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 296 | # define towlower rpl_towlower
|
|---|
| 297 | # define towupper rpl_towupper
|
|---|
| 298 | # endif
|
|---|
| 299 | # endif
|
|---|
| 300 |
|
|---|
| 301 | _GL_WCTYPE_INLINE int
|
|---|
| 302 | # if @REPLACE_ISWCNTRL@
|
|---|
| 303 | rpl_iswalnum
|
|---|
| 304 | # else
|
|---|
| 305 | iswalnum
|
|---|
| 306 | # endif
|
|---|
| 307 | (wint_t wc)
|
|---|
| 308 | {
|
|---|
| 309 | return ((wc >= '0' && wc <= '9')
|
|---|
| 310 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | _GL_WCTYPE_INLINE int
|
|---|
| 314 | # if @REPLACE_ISWCNTRL@
|
|---|
| 315 | rpl_iswalpha
|
|---|
| 316 | # else
|
|---|
| 317 | iswalpha
|
|---|
| 318 | # endif
|
|---|
| 319 | (wint_t wc)
|
|---|
| 320 | {
|
|---|
| 321 | return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | _GL_WCTYPE_INLINE int
|
|---|
| 325 | # if @REPLACE_ISWCNTRL@
|
|---|
| 326 | rpl_iswblank
|
|---|
| 327 | # else
|
|---|
| 328 | iswblank
|
|---|
| 329 | # endif
|
|---|
| 330 | (wint_t wc)
|
|---|
| 331 | {
|
|---|
| 332 | return wc == ' ' || wc == '\t';
|
|---|
| 333 | }
|
|---|
| 334 |
|
|---|
| 335 | _GL_WCTYPE_INLINE int
|
|---|
| 336 | # if @REPLACE_ISWCNTRL@
|
|---|
| 337 | rpl_iswcntrl
|
|---|
| 338 | # else
|
|---|
| 339 | iswcntrl
|
|---|
| 340 | # endif
|
|---|
| 341 | (wint_t wc)
|
|---|
| 342 | {
|
|---|
| 343 | return (wc & ~0x1f) == 0 || wc == 0x7f;
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | _GL_WCTYPE_INLINE int
|
|---|
| 347 | # if @REPLACE_ISWDIGIT@
|
|---|
| 348 | rpl_iswdigit
|
|---|
| 349 | # else
|
|---|
| 350 | iswdigit
|
|---|
| 351 | # endif
|
|---|
| 352 | (wint_t wc)
|
|---|
| 353 | {
|
|---|
| 354 | return wc >= '0' && wc <= '9';
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | _GL_WCTYPE_INLINE int
|
|---|
| 358 | # if @REPLACE_ISWCNTRL@
|
|---|
| 359 | rpl_iswgraph
|
|---|
| 360 | # else
|
|---|
| 361 | iswgraph
|
|---|
| 362 | # endif
|
|---|
| 363 | (wint_t wc)
|
|---|
| 364 | {
|
|---|
| 365 | return wc >= '!' && wc <= '~';
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | _GL_WCTYPE_INLINE int
|
|---|
| 369 | # if @REPLACE_ISWCNTRL@
|
|---|
| 370 | rpl_iswlower
|
|---|
| 371 | # else
|
|---|
| 372 | iswlower
|
|---|
| 373 | # endif
|
|---|
| 374 | (wint_t wc)
|
|---|
| 375 | {
|
|---|
| 376 | return wc >= 'a' && wc <= 'z';
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | _GL_WCTYPE_INLINE int
|
|---|
| 380 | # if @REPLACE_ISWCNTRL@
|
|---|
| 381 | rpl_iswprint
|
|---|
| 382 | # else
|
|---|
| 383 | iswprint
|
|---|
| 384 | # endif
|
|---|
| 385 | (wint_t wc)
|
|---|
| 386 | {
|
|---|
| 387 | return wc >= ' ' && wc <= '~';
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | _GL_WCTYPE_INLINE int
|
|---|
| 391 | # if @REPLACE_ISWCNTRL@
|
|---|
| 392 | rpl_iswpunct
|
|---|
| 393 | # else
|
|---|
| 394 | iswpunct
|
|---|
| 395 | # endif
|
|---|
| 396 | (wint_t wc)
|
|---|
| 397 | {
|
|---|
| 398 | return (wc >= '!' && wc <= '~'
|
|---|
| 399 | && !((wc >= '0' && wc <= '9')
|
|---|
| 400 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | _GL_WCTYPE_INLINE int
|
|---|
| 404 | # if @REPLACE_ISWCNTRL@
|
|---|
| 405 | rpl_iswspace
|
|---|
| 406 | # else
|
|---|
| 407 | iswspace
|
|---|
| 408 | # endif
|
|---|
| 409 | (wint_t wc)
|
|---|
| 410 | {
|
|---|
| 411 | return (wc == ' ' || wc == '\t'
|
|---|
| 412 | || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
|
|---|
| 413 | }
|
|---|
| 414 |
|
|---|
| 415 | _GL_WCTYPE_INLINE int
|
|---|
| 416 | # if @REPLACE_ISWCNTRL@
|
|---|
| 417 | rpl_iswupper
|
|---|
| 418 | # else
|
|---|
| 419 | iswupper
|
|---|
| 420 | # endif
|
|---|
| 421 | (wint_t wc)
|
|---|
| 422 | {
|
|---|
| 423 | return wc >= 'A' && wc <= 'Z';
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | _GL_WCTYPE_INLINE int
|
|---|
| 427 | # if @REPLACE_ISWXDIGIT@
|
|---|
| 428 | rpl_iswxdigit
|
|---|
| 429 | # else
|
|---|
| 430 | iswxdigit
|
|---|
| 431 | # endif
|
|---|
| 432 | (wint_t wc)
|
|---|
| 433 | {
|
|---|
| 434 | return ((wc >= '0' && wc <= '9')
|
|---|
| 435 | || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | _GL_WCTYPE_INLINE wint_t
|
|---|
| 439 | # if @REPLACE_TOWLOWER@
|
|---|
| 440 | rpl_towlower
|
|---|
| 441 | # else
|
|---|
| 442 | towlower
|
|---|
| 443 | # endif
|
|---|
| 444 | (wint_t wc)
|
|---|
| 445 | {
|
|---|
| 446 | return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | _GL_WCTYPE_INLINE wint_t
|
|---|
| 450 | # if @REPLACE_TOWLOWER@
|
|---|
| 451 | rpl_towupper
|
|---|
| 452 | # else
|
|---|
| 453 | towupper
|
|---|
| 454 | # endif
|
|---|
| 455 | (wint_t wc)
|
|---|
| 456 | {
|
|---|
| 457 | return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 | # endif
|
|---|
| 461 |
|
|---|
| 462 | # else
|
|---|
| 463 | /* Only some of the functions are missing or broken. */
|
|---|
| 464 |
|
|---|
| 465 | # if @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
|
|---|
| 466 | /* Only the iswblank function is missing. */
|
|---|
| 467 | # if @REPLACE_ISWBLANK@
|
|---|
| 468 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 469 | # define iswblank rpl_iswblank
|
|---|
| 470 | # endif
|
|---|
| 471 | _GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
|
|---|
| 472 | # else
|
|---|
| 473 | _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
|
|---|
| 474 | # endif
|
|---|
| 475 | # endif
|
|---|
| 476 |
|
|---|
| 477 | # if @GNULIB_ISWDIGIT@
|
|---|
| 478 | # if @REPLACE_ISWDIGIT@
|
|---|
| 479 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 480 | # undef iswdigit
|
|---|
| 481 | # define iswdigit rpl_iswdigit
|
|---|
| 482 | # endif
|
|---|
| 483 | _GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc));
|
|---|
| 484 | # endif
|
|---|
| 485 | # endif
|
|---|
| 486 |
|
|---|
| 487 | # if @GNULIB_ISWXDIGIT@
|
|---|
| 488 | # if @REPLACE_ISWXDIGIT@
|
|---|
| 489 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 490 | # undef iswxdigit
|
|---|
| 491 | # define iswxdigit rpl_iswxdigit
|
|---|
| 492 | # endif
|
|---|
| 493 | _GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc));
|
|---|
| 494 | # endif
|
|---|
| 495 | # endif
|
|---|
| 496 |
|
|---|
| 497 | # endif
|
|---|
| 498 |
|
|---|
| 499 | # if defined __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@
|
|---|
| 500 |
|
|---|
| 501 | /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
|
|---|
| 502 | The functions towlower and towupper are implemented in the MSVCRT library
|
|---|
| 503 | to take a wchar_t argument and return a wchar_t result. mingw declares
|
|---|
| 504 | these functions to take a wint_t argument and return a wint_t result.
|
|---|
| 505 | This means that:
|
|---|
| 506 | 1. When the user passes an argument outside the range 0x0000..0xFFFF, the
|
|---|
| 507 | function will look only at the lower 16 bits. This is allowed according
|
|---|
| 508 | to POSIX.
|
|---|
| 509 | 2. The return value is returned in the lower 16 bits of the result register.
|
|---|
| 510 | The upper 16 bits are random: whatever happened to be in that part of the
|
|---|
| 511 | result register. We need to fix this by adding a zero-extend from
|
|---|
| 512 | wchar_t to wint_t after the call. */
|
|---|
| 513 |
|
|---|
| 514 | _GL_WCTYPE_INLINE wint_t
|
|---|
| 515 | rpl_towlower (wint_t wc)
|
|---|
| 516 | {
|
|---|
| 517 | return (wint_t) (wchar_t) towlower (wc);
|
|---|
| 518 | }
|
|---|
| 519 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 520 | # define towlower rpl_towlower
|
|---|
| 521 | # endif
|
|---|
| 522 |
|
|---|
| 523 | _GL_WCTYPE_INLINE wint_t
|
|---|
| 524 | rpl_towupper (wint_t wc)
|
|---|
| 525 | {
|
|---|
| 526 | return (wint_t) (wchar_t) towupper (wc);
|
|---|
| 527 | }
|
|---|
| 528 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 529 | # define towupper rpl_towupper
|
|---|
| 530 | # endif
|
|---|
| 531 |
|
|---|
| 532 | # endif /* __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@ */
|
|---|
| 533 |
|
|---|
| 534 | # define GNULIB_defined_wctype_functions 1
|
|---|
| 535 | #endif
|
|---|
| 536 |
|
|---|
| 537 | #if @REPLACE_ISWCNTRL@
|
|---|
| 538 | _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
|
|---|
| 539 | #else
|
|---|
| 540 | _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
|
|---|
| 541 | #endif
|
|---|
| 542 | #if @REPLACE_ISWCNTRL@
|
|---|
| 543 | _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
|
|---|
| 544 | #else
|
|---|
| 545 | _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
|
|---|
| 546 | #endif
|
|---|
| 547 | #if @REPLACE_ISWCNTRL@
|
|---|
| 548 | _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
|
|---|
| 549 | #else
|
|---|
| 550 | _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
|
|---|
| 551 | #endif
|
|---|
| 552 | #if @GNULIB_ISWDIGIT@
|
|---|
| 553 | # if @REPLACE_ISWDIGIT@
|
|---|
| 554 | _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
|
|---|
| 555 | # else
|
|---|
| 556 | _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
|
|---|
| 557 | # endif
|
|---|
| 558 | #endif
|
|---|
| 559 | #if @REPLACE_ISWCNTRL@
|
|---|
| 560 | _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
|
|---|
| 561 | #else
|
|---|
| 562 | _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
|
|---|
| 563 | #endif
|
|---|
| 564 | #if @REPLACE_ISWCNTRL@
|
|---|
| 565 | _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
|
|---|
| 566 | #else
|
|---|
| 567 | _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
|
|---|
| 568 | #endif
|
|---|
| 569 | #if @REPLACE_ISWCNTRL@
|
|---|
| 570 | _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
|
|---|
| 571 | #else
|
|---|
| 572 | _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
|
|---|
| 573 | #endif
|
|---|
| 574 | #if @REPLACE_ISWCNTRL@
|
|---|
| 575 | _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
|
|---|
| 576 | #else
|
|---|
| 577 | _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
|
|---|
| 578 | #endif
|
|---|
| 579 | #if @REPLACE_ISWCNTRL@
|
|---|
| 580 | _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
|
|---|
| 581 | #else
|
|---|
| 582 | _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
|
|---|
| 583 | #endif
|
|---|
| 584 | #if @REPLACE_ISWCNTRL@
|
|---|
| 585 | _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
|
|---|
| 586 | #else
|
|---|
| 587 | _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
|
|---|
| 588 | #endif
|
|---|
| 589 | #if @GNULIB_ISWXDIGIT@
|
|---|
| 590 | # if @REPLACE_ISWXDIGIT@
|
|---|
| 591 | _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
|
|---|
| 592 | # else
|
|---|
| 593 | _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
|
|---|
| 594 | # endif
|
|---|
| 595 | #endif
|
|---|
| 596 | #if __GLIBC__ >= 2
|
|---|
| 597 | _GL_CXXALIASWARN (iswalnum);
|
|---|
| 598 | _GL_CXXALIASWARN (iswalpha);
|
|---|
| 599 | _GL_CXXALIASWARN (iswcntrl);
|
|---|
| 600 | _GL_CXXALIASWARN (iswdigit);
|
|---|
| 601 | _GL_CXXALIASWARN (iswgraph);
|
|---|
| 602 | _GL_CXXALIASWARN (iswlower);
|
|---|
| 603 | _GL_CXXALIASWARN (iswprint);
|
|---|
| 604 | _GL_CXXALIASWARN (iswpunct);
|
|---|
| 605 | _GL_CXXALIASWARN (iswspace);
|
|---|
| 606 | _GL_CXXALIASWARN (iswupper);
|
|---|
| 607 | _GL_CXXALIASWARN (iswxdigit);
|
|---|
| 608 | #endif
|
|---|
| 609 |
|
|---|
| 610 | #if @GNULIB_ISWBLANK@
|
|---|
| 611 | # if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
|
|---|
| 612 | _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
|
|---|
| 613 | # else
|
|---|
| 614 | _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
|
|---|
| 615 | # endif
|
|---|
| 616 | # if __GLIBC__ >= 2
|
|---|
| 617 | _GL_CXXALIASWARN (iswblank);
|
|---|
| 618 | # endif
|
|---|
| 619 | #endif
|
|---|
| 620 |
|
|---|
| 621 | #if !@HAVE_WCTYPE_T@
|
|---|
| 622 | # if !GNULIB_defined_wctype_t
|
|---|
| 623 | typedef void * wctype_t;
|
|---|
| 624 | # define GNULIB_defined_wctype_t 1
|
|---|
| 625 | # endif
|
|---|
| 626 | #endif
|
|---|
| 627 |
|
|---|
| 628 | /* Get a descriptor for a wide character property. */
|
|---|
| 629 | #if @GNULIB_WCTYPE@
|
|---|
| 630 | # if !@HAVE_WCTYPE_T@
|
|---|
| 631 | _GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
|
|---|
| 632 | # endif
|
|---|
| 633 | _GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
|
|---|
| 634 | # if __GLIBC__ >= 2
|
|---|
| 635 | _GL_CXXALIASWARN (wctype);
|
|---|
| 636 | # endif
|
|---|
| 637 | #elif defined GNULIB_POSIXCHECK
|
|---|
| 638 | # undef wctype
|
|---|
| 639 | # if HAVE_RAW_DECL_WCTYPE
|
|---|
| 640 | _GL_WARN_ON_USE (wctype, "wctype is unportable - "
|
|---|
| 641 | "use gnulib module wctype for portability");
|
|---|
| 642 | # endif
|
|---|
| 643 | #endif
|
|---|
| 644 |
|
|---|
| 645 | /* Test whether a wide character has a given property.
|
|---|
| 646 | The argument WC must be either a wchar_t value or WEOF.
|
|---|
| 647 | The argument DESC must have been returned by the wctype() function. */
|
|---|
| 648 | #if @GNULIB_ISWCTYPE@
|
|---|
| 649 | # if @GNULIBHEADERS_OVERRIDE_WINT_T@
|
|---|
| 650 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
|---|
| 651 | # undef iswctype
|
|---|
| 652 | # define iswctype rpl_iswctype
|
|---|
| 653 | # endif
|
|---|
| 654 | _GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc));
|
|---|
| 655 | _GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc));
|
|---|
| 656 | # else
|
|---|
| 657 | # if !@HAVE_WCTYPE_T@
|
|---|
| 658 | _GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
|
|---|
| 659 | # endif
|
|---|
| 660 | _GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
|
|---|
| 661 | # endif
|
|---|
| 662 | # if __GLIBC__ >= 2
|
|---|
| 663 | _GL_CXXALIASWARN (iswctype);
|
|---|
| 664 | # endif
|
|---|
| 665 | #elif defined GNULIB_POSIXCHECK
|
|---|
| 666 | # undef iswctype
|
|---|
| 667 | # if HAVE_RAW_DECL_ISWCTYPE
|
|---|
| 668 | _GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
|
|---|
| 669 | "use gnulib module iswctype for portability");
|
|---|
| 670 | # endif
|
|---|
| 671 | #endif
|
|---|
| 672 |
|
|---|
| 673 | #if @REPLACE_TOWLOWER@ || defined __MINGW32__
|
|---|
| 674 | _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
|
|---|
| 675 | _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
|
|---|
| 676 | #else
|
|---|
| 677 | _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
|
|---|
| 678 | _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
|
|---|
| 679 | #endif
|
|---|
| 680 | #if __GLIBC__ >= 2
|
|---|
| 681 | _GL_CXXALIASWARN (towlower);
|
|---|
| 682 | _GL_CXXALIASWARN (towupper);
|
|---|
| 683 | #endif
|
|---|
| 684 |
|
|---|
| 685 | #if !@HAVE_WCTRANS_T@
|
|---|
| 686 | # if !GNULIB_defined_wctrans_t
|
|---|
| 687 | typedef void * wctrans_t;
|
|---|
| 688 | # define GNULIB_defined_wctrans_t 1
|
|---|
| 689 | # endif
|
|---|
| 690 | #endif
|
|---|
| 691 |
|
|---|
| 692 | /* Get a descriptor for a wide character case conversion. */
|
|---|
| 693 | #if @GNULIB_WCTRANS@
|
|---|
| 694 | # if !@HAVE_WCTRANS_T@
|
|---|
| 695 | _GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
|
|---|
| 696 | # endif
|
|---|
| 697 | _GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
|
|---|
| 698 | # if __GLIBC__ >= 2
|
|---|
| 699 | _GL_CXXALIASWARN (wctrans);
|
|---|
| 700 | # endif
|
|---|
| 701 | #elif defined GNULIB_POSIXCHECK
|
|---|
| 702 | # undef wctrans
|
|---|
| 703 | # if HAVE_RAW_DECL_WCTRANS
|
|---|
| 704 | _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
|
|---|
| 705 | "use gnulib module wctrans for portability");
|
|---|
| 706 | # endif
|
|---|
| 707 | #endif
|
|---|
| 708 |
|
|---|
| 709 | /* Perform a given case conversion on a wide character.
|
|---|
| 710 | The argument WC must be either a wchar_t value or WEOF.
|
|---|
| 711 | The argument DESC must have been returned by the wctrans() function. */
|
|---|
| 712 | #if @GNULIB_TOWCTRANS@
|
|---|
| 713 | # if !@HAVE_WCTRANS_T@
|
|---|
| 714 | _GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
|
|---|
| 715 | # endif
|
|---|
| 716 | _GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
|
|---|
| 717 | # if __GLIBC__ >= 2
|
|---|
| 718 | _GL_CXXALIASWARN (towctrans);
|
|---|
| 719 | # endif
|
|---|
| 720 | #elif defined GNULIB_POSIXCHECK
|
|---|
| 721 | # undef towctrans
|
|---|
| 722 | # if HAVE_RAW_DECL_TOWCTRANS
|
|---|
| 723 | _GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
|
|---|
| 724 | "use gnulib module towctrans for portability");
|
|---|
| 725 | # endif
|
|---|
| 726 | #endif
|
|---|
| 727 |
|
|---|
| 728 | _GL_INLINE_HEADER_END
|
|---|
| 729 |
|
|---|
| 730 | #endif /* _@GUARD_PREFIX@_WCTYPE_H */
|
|---|
| 731 | #endif /* _@GUARD_PREFIX@_WCTYPE_H */
|
|---|
| 732 | #endif
|
|---|