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