diff options
Diffstat (limited to 'gl/wchar.in.h')
| -rw-r--r-- | gl/wchar.in.h | 376 |
1 files changed, 360 insertions, 16 deletions
diff --git a/gl/wchar.in.h b/gl/wchar.in.h index 09c9185f..a33a10f7 100644 --- a/gl/wchar.in.h +++ b/gl/wchar.in.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. | 1 | /* A substitute for ISO C99 <wchar.h>, for platforms that have issues. |
| 2 | 2 | ||
| 3 | Copyright (C) 2007-2023 Free Software Foundation, Inc. | 3 | Copyright (C) 2007-2024 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -84,6 +84,13 @@ | |||
| 84 | #ifndef _@GUARD_PREFIX@_WCHAR_H | 84 | #ifndef _@GUARD_PREFIX@_WCHAR_H |
| 85 | #define _@GUARD_PREFIX@_WCHAR_H | 85 | #define _@GUARD_PREFIX@_WCHAR_H |
| 86 | 86 | ||
| 87 | /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, | ||
| 88 | _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, | ||
| 89 | HAVE_RAW_DECL_*. */ | ||
| 90 | #if !_GL_CONFIG_H_INCLUDED | ||
| 91 | #error "Please include config.h first." | ||
| 92 | #endif | ||
| 93 | |||
| 87 | /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers | 94 | /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers |
| 88 | that can be freed by passing them as the Ith argument to the | 95 | that can be freed by passing them as the Ith argument to the |
| 89 | function F. */ | 96 | function F. */ |
| @@ -130,6 +137,28 @@ | |||
| 130 | # endif | 137 | # endif |
| 131 | #endif | 138 | #endif |
| 132 | 139 | ||
| 140 | /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. | ||
| 141 | */ | ||
| 142 | #ifndef _GL_ATTRIBUTE_NOTHROW | ||
| 143 | # if defined __cplusplus | ||
| 144 | # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 | ||
| 145 | # if __cplusplus >= 201103L | ||
| 146 | # define _GL_ATTRIBUTE_NOTHROW noexcept (true) | ||
| 147 | # else | ||
| 148 | # define _GL_ATTRIBUTE_NOTHROW throw () | ||
| 149 | # endif | ||
| 150 | # else | ||
| 151 | # define _GL_ATTRIBUTE_NOTHROW | ||
| 152 | # endif | ||
| 153 | # else | ||
| 154 | # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__ | ||
| 155 | # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) | ||
| 156 | # else | ||
| 157 | # define _GL_ATTRIBUTE_NOTHROW | ||
| 158 | # endif | ||
| 159 | # endif | ||
| 160 | #endif | ||
| 161 | |||
| 133 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | 162 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| 134 | 163 | ||
| 135 | /* The definition of _GL_ARG_NONNULL is copied here. */ | 164 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
| @@ -188,7 +217,11 @@ typedef int rpl_mbstate_t; | |||
| 188 | # if (@REPLACE_FREE@ && !defined free \ | 217 | # if (@REPLACE_FREE@ && !defined free \ |
| 189 | && !(defined __cplusplus && defined GNULIB_NAMESPACE)) | 218 | && !(defined __cplusplus && defined GNULIB_NAMESPACE)) |
| 190 | /* We can't do '#define free rpl_free' here. */ | 219 | /* We can't do '#define free rpl_free' here. */ |
| 220 | # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) | ||
| 221 | _GL_EXTERN_C void rpl_free (void *) _GL_ATTRIBUTE_NOTHROW; | ||
| 222 | # else | ||
| 191 | _GL_EXTERN_C void rpl_free (void *); | 223 | _GL_EXTERN_C void rpl_free (void *); |
| 224 | # endif | ||
| 192 | # undef _GL_ATTRIBUTE_DEALLOC_FREE | 225 | # undef _GL_ATTRIBUTE_DEALLOC_FREE |
| 193 | # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) | 226 | # define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) |
| 194 | # else | 227 | # else |
| @@ -200,7 +233,7 @@ _GL_EXTERN_C | |||
| 200 | void __cdecl free (void *); | 233 | void __cdecl free (void *); |
| 201 | # else | 234 | # else |
| 202 | # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) | 235 | # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) |
| 203 | _GL_EXTERN_C void free (void *) throw (); | 236 | _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; |
| 204 | # else | 237 | # else |
| 205 | _GL_EXTERN_C void free (void *); | 238 | _GL_EXTERN_C void free (void *); |
| 206 | # endif | 239 | # endif |
| @@ -215,13 +248,20 @@ _GL_EXTERN_C | |||
| 215 | void __cdecl free (void *); | 248 | void __cdecl free (void *); |
| 216 | # else | 249 | # else |
| 217 | # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) | 250 | # if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) |
| 218 | _GL_EXTERN_C void free (void *) throw (); | 251 | _GL_EXTERN_C void free (void *) _GL_ATTRIBUTE_NOTHROW; |
| 219 | # else | 252 | # else |
| 220 | _GL_EXTERN_C void free (void *); | 253 | _GL_EXTERN_C void free (void *); |
| 221 | # endif | 254 | # endif |
| 222 | # endif | 255 | # endif |
| 223 | #endif | 256 | #endif |
| 224 | 257 | ||
| 258 | |||
| 259 | #if @GNULIB_MBSZERO@ | ||
| 260 | /* Get memset(). */ | ||
| 261 | # include <string.h> | ||
| 262 | #endif | ||
| 263 | |||
| 264 | |||
| 225 | /* Convert a single-byte character to a wide character. */ | 265 | /* Convert a single-byte character to a wide character. */ |
| 226 | #if @GNULIB_BTOWC@ | 266 | #if @GNULIB_BTOWC@ |
| 227 | # if @REPLACE_BTOWC@ | 267 | # if @REPLACE_BTOWC@ |
| @@ -278,7 +318,7 @@ _GL_WARN_ON_USE (wctob, "wctob is unportable - " | |||
| 278 | #endif | 318 | #endif |
| 279 | 319 | ||
| 280 | 320 | ||
| 281 | /* Test whether *PS is in the initial state. */ | 321 | /* Test whether *PS is in an initial state. */ |
| 282 | #if @GNULIB_MBSINIT@ | 322 | #if @GNULIB_MBSINIT@ |
| 283 | # if @REPLACE_MBSINIT@ | 323 | # if @REPLACE_MBSINIT@ |
| 284 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 324 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| @@ -305,6 +345,208 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " | |||
| 305 | #endif | 345 | #endif |
| 306 | 346 | ||
| 307 | 347 | ||
| 348 | /* Put *PS into an initial state. */ | ||
| 349 | #if @GNULIB_MBSZERO@ | ||
| 350 | /* ISO C 23 ยง 7.31.6.(3) says that zeroing an mbstate_t is a way to put the | ||
| 351 | mbstate_t into an initial state. However, on many platforms an mbstate_t | ||
| 352 | is large, and it is possible - as an optimization - to get away with zeroing | ||
| 353 | only part of it. So, instead of | ||
| 354 | |||
| 355 | mbstate_t state = { 0 }; | ||
| 356 | |||
| 357 | or | ||
| 358 | |||
| 359 | mbstate_t state; | ||
| 360 | memset (&state, 0, sizeof (mbstate_t)); | ||
| 361 | |||
| 362 | we can write this faster code: | ||
| 363 | |||
| 364 | mbstate_t state; | ||
| 365 | mbszero (&state); | ||
| 366 | */ | ||
| 367 | /* _GL_MBSTATE_INIT_SIZE describes how mbsinit() behaves: It is the number of | ||
| 368 | bytes at the beginning of an mbstate_t that need to be zero, for mbsinit() | ||
| 369 | to return true. | ||
| 370 | _GL_MBSTATE_ZERO_SIZE is the number of bytes at the beginning of an mbstate_t | ||
| 371 | that need to be zero, | ||
| 372 | - for mbsinit() to return true, and | ||
| 373 | - for all other multibyte-aware functions to operate properly. | ||
| 374 | 0 < _GL_MBSTATE_INIT_SIZE <= _GL_MBSTATE_ZERO_SIZE <= sizeof (mbstate_t). | ||
| 375 | These values are determined by source code inspection, where possible, and | ||
| 376 | by running the gnulib unit tests. | ||
| 377 | We need _GL_MBSTATE_INIT_SIZE because if we define _GL_MBSTATE_ZERO_SIZE | ||
| 378 | without considering what mbsinit() does, we get test failures such as | ||
| 379 | assertion "mbsinit (&iter->state)" failed | ||
| 380 | */ | ||
| 381 | # if GNULIB_defined_mbstate_t /* AIX, IRIX */ | ||
| 382 | /* mbstate_t has at least 4 bytes. They are used as coded in | ||
| 383 | gnulib/lib/mbrtowc.c. */ | ||
| 384 | # define _GL_MBSTATE_INIT_SIZE 1 | ||
| 385 | /* define _GL_MBSTATE_ZERO_SIZE 4 | ||
| 386 | does not work: it causes test failures. | ||
| 387 | So, use the safe fallback value, below. */ | ||
| 388 | # elif __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 /* glibc */ | ||
| 389 | /* mbstate_t is defined in <bits/types/__mbstate_t.h>. | ||
| 390 | For more details, see glibc/iconv/skeleton.c. */ | ||
| 391 | # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (((mbstate_t) {0}).__count) */ | ||
| 392 | # define _GL_MBSTATE_ZERO_SIZE /* 8 */ sizeof (mbstate_t) | ||
| 393 | # elif defined MUSL_LIBC /* musl libc */ | ||
| 394 | /* mbstate_t is defined in <bits/alltypes.h>. | ||
| 395 | It is an opaque aligned 8-byte struct, of which at most the first | ||
| 396 | 4 bytes are used. | ||
| 397 | For more details, see src/multibyte/mbrtowc.c. */ | ||
| 398 | # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (unsigned) */ | ||
| 399 | # define _GL_MBSTATE_ZERO_SIZE 4 | ||
| 400 | # elif defined __APPLE__ && defined __MACH__ /* macOS */ | ||
| 401 | /* On macOS, mbstate_t is defined in <machine/_types.h>. | ||
| 402 | It is an opaque aligned 128-byte struct, of which at most the first | ||
| 403 | 12 bytes are used. | ||
| 404 | For more details, see the __mbsinit implementations in | ||
| 405 | Libc-<version>/locale/FreeBSD/ | ||
| 406 | {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8,utf2}.c. */ | ||
| 407 | /* File INIT_SIZE ZERO_SIZE | ||
| 408 | ascii.c 0 0 | ||
| 409 | none.c 0 0 | ||
| 410 | euc.c 12 12 | ||
| 411 | mskanji.c 4 4 | ||
| 412 | big5.c 4 4 | ||
| 413 | gb2312.c 4 6 | ||
| 414 | gbk.c 4 4 | ||
| 415 | gb18030.c 4 8 | ||
| 416 | utf8.c 8 10 | ||
| 417 | utf2.c 8 12 */ | ||
| 418 | # define _GL_MBSTATE_INIT_SIZE 12 | ||
| 419 | # define _GL_MBSTATE_ZERO_SIZE 12 | ||
| 420 | # elif defined __FreeBSD__ /* FreeBSD */ | ||
| 421 | /* On FreeBSD, mbstate_t is defined in src/sys/sys/_types.h. | ||
| 422 | It is an opaque aligned 128-byte struct, of which at most the first | ||
| 423 | 12 bytes are used. | ||
| 424 | For more details, see the __mbsinit implementations in | ||
| 425 | src/lib/libc/locale/ | ||
| 426 | {ascii,none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */ | ||
| 427 | /* File INIT_SIZE ZERO_SIZE | ||
| 428 | ascii.c 0 0 | ||
| 429 | none.c 0 0 | ||
| 430 | euc.c 12 12 | ||
| 431 | mskanji.c 4 4 | ||
| 432 | big5.c 4 4 | ||
| 433 | gb2312.c 4 6 | ||
| 434 | gbk.c 4 4 | ||
| 435 | gb18030.c 4 8 | ||
| 436 | utf8.c 8 12 */ | ||
| 437 | # define _GL_MBSTATE_INIT_SIZE 12 | ||
| 438 | # define _GL_MBSTATE_ZERO_SIZE 12 | ||
| 439 | # elif defined __NetBSD__ /* NetBSD */ | ||
| 440 | /* On NetBSD, mbstate_t is defined in src/sys/sys/ansi.h. | ||
| 441 | It is an opaque aligned 128-byte struct, of which at most the first | ||
| 442 | 28 bytes are used. | ||
| 443 | For more details, see the *State types in | ||
| 444 | src/lib/libc/citrus/modules/citrus_*.c | ||
| 445 | (ignoring citrus_{hz,iso2022,utf7,viqr,zw}.c, since these implement | ||
| 446 | stateful encodings, not usable as locale encodings). */ | ||
| 447 | /* File ZERO_SIZE | ||
| 448 | citrus/citrus_none.c 0 | ||
| 449 | citrus/modules/citrus_euc.c 8 | ||
| 450 | citrus/modules/citrus_euctw.c 8 | ||
| 451 | citrus/modules/citrus_mskanji.c 8 | ||
| 452 | citrus/modules/citrus_big5.c 8 | ||
| 453 | citrus/modules/citrus_gbk2k.c 8 | ||
| 454 | citrus/modules/citrus_dechanyu.c 8 | ||
| 455 | citrus/modules/citrus_johab.c 6 | ||
| 456 | citrus/modules/citrus_utf8.c 12 */ | ||
| 457 | /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test | ||
| 458 | failures for values < 28. */ | ||
| 459 | # define _GL_MBSTATE_ZERO_SIZE 28 | ||
| 460 | # elif defined __OpenBSD__ /* OpenBSD */ | ||
| 461 | /* On OpenBSD, mbstate_t is defined in src/sys/sys/_types.h. | ||
| 462 | It is an opaque aligned 128-byte struct, of which at most the first | ||
| 463 | 12 bytes are used. | ||
| 464 | For more details, see src/lib/libc/citrus/citrus_*.c. */ | ||
| 465 | /* File INIT_SIZE ZERO_SIZE | ||
| 466 | citrus_none.c 0 0 | ||
| 467 | citrus_utf8.c 12 12 */ | ||
| 468 | # define _GL_MBSTATE_INIT_SIZE 12 | ||
| 469 | # define _GL_MBSTATE_ZERO_SIZE 12 | ||
| 470 | # elif defined __minix /* Minix */ | ||
| 471 | /* On Minix, mbstate_t is defined in sys/sys/ansi.h. | ||
| 472 | It is an opaque aligned 128-byte struct. | ||
| 473 | For more details, see the *State types in | ||
| 474 | lib/libc/citrus/citrus_*.c. */ | ||
| 475 | /* File INIT_SIZE ZERO_SIZE | ||
| 476 | citrus_none.c 0 0 */ | ||
| 477 | /* But 1 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test | ||
| 478 | failures for values < 4. */ | ||
| 479 | # define _GL_MBSTATE_ZERO_SIZE 4 | ||
| 480 | # elif defined __sun /* Solaris */ | ||
| 481 | /* On Solaris, mbstate_t is defined in <wchar_impl.h>. | ||
| 482 | It is an opaque aligned 24-byte or 32-byte struct, of which at most the first | ||
| 483 | 20 or 28 bytes are used. | ||
| 484 | For more details on OpenSolaris derivatives, see the *State types in | ||
| 485 | illumos-gate/usr/src/lib/libc/port/locale/ | ||
| 486 | {none,euc,mskanji,big5,gb2312,gbk,gb18030,utf8}.c. */ | ||
| 487 | /* File INIT_SIZE ZERO_SIZE | ||
| 488 | none.c 0 0 | ||
| 489 | euc.c 12 12 | ||
| 490 | mskanji.c 4 4 | ||
| 491 | big5.c 4 4 | ||
| 492 | gb2312.c 4 6 | ||
| 493 | gbk.c 4 4 | ||
| 494 | gb18030.c 4 8 | ||
| 495 | utf8.c 12 12 */ | ||
| 496 | /* But 12 is not the correct value for _GL_MBSTATE_ZERO_SIZE: we get test | ||
| 497 | failures | ||
| 498 | - in OpenIndiana and OmniOS: for values < 16, | ||
| 499 | - in Solaris 10 and 11: for values < 20 (in 32-bit mode) | ||
| 500 | or < 28 (in 64-bit mode). | ||
| 501 | Since we don't have a good way to distinguish the OpenSolaris derivatives | ||
| 502 | from the proprietary Solaris versions, and can't inspect the Solaris source | ||
| 503 | code, use the safe fallback values, below. */ | ||
| 504 | # elif defined __CYGWIN__ /* Cygwin */ | ||
| 505 | /* On Cygwin, mbstate_t is defined in <sys/_types.h>. | ||
| 506 | For more details, see newlib/libc/stdlib/mbtowc_r.c and | ||
| 507 | winsup/cygwin/strfuncs.cc. */ | ||
| 508 | # define _GL_MBSTATE_INIT_SIZE 4 /* sizeof (int) */ | ||
| 509 | # define _GL_MBSTATE_ZERO_SIZE 8 | ||
| 510 | # elif defined _WIN32 && !defined __CYGWIN__ /* Native Windows. */ | ||
| 511 | /* MSVC defines 'mbstate_t' as an aligned 8-byte struct. | ||
| 512 | On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined | ||
| 513 | as an aligned 8-byte struct, of which the first 4 bytes matter. | ||
| 514 | Use the safe values, below. */ | ||
| 515 | # elif defined __ANDROID__ /* Android */ | ||
| 516 | /* Android defines 'mbstate_t' in <bits/mbstate_t.h>. | ||
| 517 | It is an opaque 4-byte or 8-byte struct. | ||
| 518 | For more details, see | ||
| 519 | bionic/libc/private/bionic_mbstate.h | ||
| 520 | bionic/libc/bionic/mbrtoc32.cpp | ||
| 521 | bionic/libc/bionic/mbrtoc16.cpp | ||
| 522 | */ | ||
| 523 | # define _GL_MBSTATE_INIT_SIZE 4 | ||
| 524 | # define _GL_MBSTATE_ZERO_SIZE 4 | ||
| 525 | # endif | ||
| 526 | /* Use safe values as defaults. */ | ||
| 527 | # ifndef _GL_MBSTATE_INIT_SIZE | ||
| 528 | # define _GL_MBSTATE_INIT_SIZE sizeof (mbstate_t) | ||
| 529 | # endif | ||
| 530 | # ifndef _GL_MBSTATE_ZERO_SIZE | ||
| 531 | # define _GL_MBSTATE_ZERO_SIZE sizeof (mbstate_t) | ||
| 532 | # endif | ||
| 533 | _GL_BEGIN_C_LINKAGE | ||
| 534 | # if defined IN_MBSZERO | ||
| 535 | _GL_EXTERN_INLINE | ||
| 536 | # else | ||
| 537 | _GL_INLINE | ||
| 538 | # endif | ||
| 539 | _GL_ARG_NONNULL ((1)) void | ||
| 540 | mbszero (mbstate_t *ps) | ||
| 541 | { | ||
| 542 | memset (ps, 0, _GL_MBSTATE_ZERO_SIZE); | ||
| 543 | } | ||
| 544 | _GL_END_C_LINKAGE | ||
| 545 | _GL_CXXALIAS_SYS (mbszero, void, (mbstate_t *ps)); | ||
| 546 | _GL_CXXALIASWARN (mbszero); | ||
| 547 | #endif | ||
| 548 | |||
| 549 | |||
| 308 | /* Convert a multibyte character to a wide character. */ | 550 | /* Convert a multibyte character to a wide character. */ |
| 309 | #if @GNULIB_MBRTOWC@ | 551 | #if @GNULIB_MBRTOWC@ |
| 310 | # if @REPLACE_MBRTOWC@ | 552 | # if @REPLACE_MBRTOWC@ |
| @@ -441,7 +683,9 @@ _GL_CXXALIAS_SYS (mbsnrtowcs, size_t, | |||
| 441 | const char **restrict srcp, size_t srclen, size_t len, | 683 | const char **restrict srcp, size_t srclen, size_t len, |
| 442 | mbstate_t *restrict ps)); | 684 | mbstate_t *restrict ps)); |
| 443 | # endif | 685 | # endif |
| 686 | # if __GLIBC__ >= 2 | ||
| 444 | _GL_CXXALIASWARN (mbsnrtowcs); | 687 | _GL_CXXALIASWARN (mbsnrtowcs); |
| 688 | # endif | ||
| 445 | #elif defined GNULIB_POSIXCHECK | 689 | #elif defined GNULIB_POSIXCHECK |
| 446 | # undef mbsnrtowcs | 690 | # undef mbsnrtowcs |
| 447 | # if HAVE_RAW_DECL_MBSNRTOWCS | 691 | # if HAVE_RAW_DECL_MBSNRTOWCS |
| @@ -629,13 +873,25 @@ _GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - " | |||
| 629 | 873 | ||
| 630 | /* Compare N wide characters of S1 and S2. */ | 874 | /* Compare N wide characters of S1 and S2. */ |
| 631 | #if @GNULIB_WMEMCMP@ | 875 | #if @GNULIB_WMEMCMP@ |
| 632 | # if !@HAVE_WMEMCMP@ | 876 | # if @REPLACE_WMEMCMP@ |
| 877 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 878 | # undef wmemcmp | ||
| 879 | # define wmemcmp rpl_wmemcmp | ||
| 880 | # endif | ||
| 881 | _GL_FUNCDECL_RPL (wmemcmp, int, | ||
| 882 | (const wchar_t *s1, const wchar_t *s2, size_t n) | ||
| 883 | _GL_ATTRIBUTE_PURE); | ||
| 884 | _GL_CXXALIAS_RPL (wmemcmp, int, | ||
| 885 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | ||
| 886 | # else | ||
| 887 | # if !@HAVE_WMEMCMP@ | ||
| 633 | _GL_FUNCDECL_SYS (wmemcmp, int, | 888 | _GL_FUNCDECL_SYS (wmemcmp, int, |
| 634 | (const wchar_t *s1, const wchar_t *s2, size_t n) | 889 | (const wchar_t *s1, const wchar_t *s2, size_t n) |
| 635 | _GL_ATTRIBUTE_PURE); | 890 | _GL_ATTRIBUTE_PURE); |
| 636 | # endif | 891 | # endif |
| 637 | _GL_CXXALIAS_SYS (wmemcmp, int, | 892 | _GL_CXXALIAS_SYS (wmemcmp, int, |
| 638 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | 893 | (const wchar_t *s1, const wchar_t *s2, size_t n)); |
| 894 | # endif | ||
| 639 | # if __GLIBC__ >= 2 | 895 | # if __GLIBC__ >= 2 |
| 640 | _GL_CXXALIASWARN (wmemcmp); | 896 | _GL_CXXALIASWARN (wmemcmp); |
| 641 | # endif | 897 | # endif |
| @@ -694,14 +950,27 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - " | |||
| 694 | /* Copy N wide characters of SRC to DEST. | 950 | /* Copy N wide characters of SRC to DEST. |
| 695 | Return pointer to wide characters after the last written wide character. */ | 951 | Return pointer to wide characters after the last written wide character. */ |
| 696 | #if @GNULIB_WMEMPCPY@ | 952 | #if @GNULIB_WMEMPCPY@ |
| 697 | # if !@HAVE_WMEMPCPY@ | 953 | # if @REPLACE_WMEMPCPY@ |
| 954 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 955 | # undef wmempcpy | ||
| 956 | # define wmempcpy rpl_wmempcpy | ||
| 957 | # endif | ||
| 958 | _GL_FUNCDECL_RPL (wmempcpy, wchar_t *, | ||
| 959 | (wchar_t *restrict dest, | ||
| 960 | const wchar_t *restrict src, size_t n)); | ||
| 961 | _GL_CXXALIAS_RPL (wmempcpy, wchar_t *, | ||
| 962 | (wchar_t *restrict dest, | ||
| 963 | const wchar_t *restrict src, size_t n)); | ||
| 964 | # else | ||
| 965 | # if !@HAVE_WMEMPCPY@ | ||
| 698 | _GL_FUNCDECL_SYS (wmempcpy, wchar_t *, | 966 | _GL_FUNCDECL_SYS (wmempcpy, wchar_t *, |
| 699 | (wchar_t *restrict dest, | 967 | (wchar_t *restrict dest, |
| 700 | const wchar_t *restrict src, size_t n)); | 968 | const wchar_t *restrict src, size_t n)); |
| 701 | # endif | 969 | # endif |
| 702 | _GL_CXXALIAS_SYS (wmempcpy, wchar_t *, | 970 | _GL_CXXALIAS_SYS (wmempcpy, wchar_t *, |
| 703 | (wchar_t *restrict dest, | 971 | (wchar_t *restrict dest, |
| 704 | const wchar_t *restrict src, size_t n)); | 972 | const wchar_t *restrict src, size_t n)); |
| 973 | # endif | ||
| 705 | # if __GLIBC__ >= 2 | 974 | # if __GLIBC__ >= 2 |
| 706 | _GL_CXXALIASWARN (wmempcpy); | 975 | _GL_CXXALIASWARN (wmempcpy); |
| 707 | # endif | 976 | # endif |
| @@ -901,11 +1170,21 @@ _GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - " | |||
| 901 | 1170 | ||
| 902 | /* Compare S1 and S2. */ | 1171 | /* Compare S1 and S2. */ |
| 903 | #if @GNULIB_WCSCMP@ | 1172 | #if @GNULIB_WCSCMP@ |
| 904 | # if !@HAVE_WCSCMP@ | 1173 | # if @REPLACE_WCSCMP@ |
| 1174 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1175 | # undef wcscmp | ||
| 1176 | # define wcscmp rpl_wcscmp | ||
| 1177 | # endif | ||
| 1178 | _GL_FUNCDECL_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) | ||
| 1179 | _GL_ATTRIBUTE_PURE); | ||
| 1180 | _GL_CXXALIAS_RPL (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); | ||
| 1181 | # else | ||
| 1182 | # if !@HAVE_WCSCMP@ | ||
| 905 | _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) | 1183 | _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2) |
| 906 | _GL_ATTRIBUTE_PURE); | 1184 | _GL_ATTRIBUTE_PURE); |
| 907 | # endif | 1185 | # endif |
| 908 | _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); | 1186 | _GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); |
| 1187 | # endif | ||
| 909 | # if __GLIBC__ >= 2 | 1188 | # if __GLIBC__ >= 2 |
| 910 | _GL_CXXALIASWARN (wcscmp); | 1189 | _GL_CXXALIASWARN (wcscmp); |
| 911 | # endif | 1190 | # endif |
| @@ -920,13 +1199,25 @@ _GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - " | |||
| 920 | 1199 | ||
| 921 | /* Compare no more than N wide characters of S1 and S2. */ | 1200 | /* Compare no more than N wide characters of S1 and S2. */ |
| 922 | #if @GNULIB_WCSNCMP@ | 1201 | #if @GNULIB_WCSNCMP@ |
| 923 | # if !@HAVE_WCSNCMP@ | 1202 | # if @REPLACE_WCSNCMP@ |
| 1203 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1204 | # undef wcsncmp | ||
| 1205 | # define wcsncmp rpl_wcsncmp | ||
| 1206 | # endif | ||
| 1207 | _GL_FUNCDECL_RPL (wcsncmp, int, | ||
| 1208 | (const wchar_t *s1, const wchar_t *s2, size_t n) | ||
| 1209 | _GL_ATTRIBUTE_PURE); | ||
| 1210 | _GL_CXXALIAS_RPL (wcsncmp, int, | ||
| 1211 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | ||
| 1212 | # else | ||
| 1213 | # if !@HAVE_WCSNCMP@ | ||
| 924 | _GL_FUNCDECL_SYS (wcsncmp, int, | 1214 | _GL_FUNCDECL_SYS (wcsncmp, int, |
| 925 | (const wchar_t *s1, const wchar_t *s2, size_t n) | 1215 | (const wchar_t *s1, const wchar_t *s2, size_t n) |
| 926 | _GL_ATTRIBUTE_PURE); | 1216 | _GL_ATTRIBUTE_PURE); |
| 927 | # endif | 1217 | # endif |
| 928 | _GL_CXXALIAS_SYS (wcsncmp, int, | 1218 | _GL_CXXALIAS_SYS (wcsncmp, int, |
| 929 | (const wchar_t *s1, const wchar_t *s2, size_t n)); | 1219 | (const wchar_t *s1, const wchar_t *s2, size_t n)); |
| 1220 | # endif | ||
| 930 | # if __GLIBC__ >= 2 | 1221 | # if __GLIBC__ >= 2 |
| 931 | _GL_CXXALIASWARN (wcsncmp); | 1222 | _GL_CXXALIASWARN (wcsncmp); |
| 932 | # endif | 1223 | # endif |
| @@ -1035,9 +1326,16 @@ _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); | |||
| 1035 | namespace, not in the global namespace. So, force a declaration in | 1326 | namespace, not in the global namespace. So, force a declaration in |
| 1036 | the global namespace. */ | 1327 | the global namespace. */ |
| 1037 | # if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 | 1328 | # if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11 |
| 1329 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | ||
| 1330 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, | ||
| 1331 | (const wchar_t *s) | ||
| 1332 | _GL_ATTRIBUTE_NOTHROW | ||
| 1333 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | ||
| 1334 | # else | ||
| 1038 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, | 1335 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, |
| 1039 | (const wchar_t *s) | 1336 | (const wchar_t *s) |
| 1040 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 1337 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 1338 | # endif | ||
| 1041 | # endif | 1339 | # endif |
| 1042 | _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); | 1340 | _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); |
| 1043 | # endif | 1341 | # endif |
| @@ -1045,9 +1343,16 @@ _GL_CXXALIASWARN (wcsdup); | |||
| 1045 | #else | 1343 | #else |
| 1046 | # if __GNUC__ >= 11 && !defined wcsdup | 1344 | # if __GNUC__ >= 11 && !defined wcsdup |
| 1047 | /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ | 1345 | /* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */ |
| 1346 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | ||
| 1048 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, | 1347 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, |
| 1049 | (const wchar_t *s) | 1348 | (const wchar_t *s) |
| 1349 | _GL_ATTRIBUTE_NOTHROW | ||
| 1050 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 1350 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 1351 | # else | ||
| 1352 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, | ||
| 1353 | (const wchar_t *s) | ||
| 1354 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | ||
| 1355 | # endif | ||
| 1051 | # endif | 1356 | # endif |
| 1052 | # if defined GNULIB_POSIXCHECK | 1357 | # if defined GNULIB_POSIXCHECK |
| 1053 | # undef wcsdup | 1358 | # undef wcsdup |
| @@ -1066,9 +1371,16 @@ _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " | |||
| 1066 | # endif | 1371 | # endif |
| 1067 | _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); | 1372 | _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s)); |
| 1068 | # else | 1373 | # else |
| 1374 | # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 | ||
| 1069 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, | 1375 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, |
| 1070 | (const wchar_t *s) | 1376 | (const wchar_t *s) |
| 1377 | _GL_ATTRIBUTE_NOTHROW | ||
| 1071 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | 1378 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); |
| 1379 | # else | ||
| 1380 | _GL_FUNCDECL_SYS (wcsdup, wchar_t *, | ||
| 1381 | (const wchar_t *s) | ||
| 1382 | _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); | ||
| 1383 | # endif | ||
| 1072 | # if @HAVE_DECL_WCSDUP@ | 1384 | # if @HAVE_DECL_WCSDUP@ |
| 1073 | _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); | 1385 | _GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); |
| 1074 | # endif | 1386 | # endif |
| @@ -1140,7 +1452,7 @@ _GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - " | |||
| 1140 | #endif | 1452 | #endif |
| 1141 | 1453 | ||
| 1142 | 1454 | ||
| 1143 | /* Return the length of the initial segmet of WCS which consists entirely | 1455 | /* Return the length of the initial segment of WCS which consists entirely |
| 1144 | of wide characters not in REJECT. */ | 1456 | of wide characters not in REJECT. */ |
| 1145 | #if @GNULIB_WCSCSPN@ | 1457 | #if @GNULIB_WCSCSPN@ |
| 1146 | # if !@HAVE_WCSCSPN@ | 1458 | # if !@HAVE_WCSCSPN@ |
| @@ -1160,7 +1472,7 @@ _GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - " | |||
| 1160 | #endif | 1472 | #endif |
| 1161 | 1473 | ||
| 1162 | 1474 | ||
| 1163 | /* Return the length of the initial segmet of WCS which consists entirely | 1475 | /* Return the length of the initial segment of WCS which consists entirely |
| 1164 | of wide characters in ACCEPT. */ | 1476 | of wide characters in ACCEPT. */ |
| 1165 | #if @GNULIB_WCSSPN@ | 1477 | #if @GNULIB_WCSSPN@ |
| 1166 | # if !@HAVE_WCSSPN@ | 1478 | # if !@HAVE_WCSSPN@ |
| @@ -1215,12 +1527,25 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - " | |||
| 1215 | 1527 | ||
| 1216 | /* Find the first occurrence of NEEDLE in HAYSTACK. */ | 1528 | /* Find the first occurrence of NEEDLE in HAYSTACK. */ |
| 1217 | #if @GNULIB_WCSSTR@ | 1529 | #if @GNULIB_WCSSTR@ |
| 1218 | # if !@HAVE_WCSSTR@ | 1530 | # if @REPLACE_WCSSTR@ |
| 1531 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1532 | # undef wcsstr | ||
| 1533 | # define wcsstr rpl_wcsstr | ||
| 1534 | # endif | ||
| 1535 | _GL_FUNCDECL_RPL (wcsstr, wchar_t *, | ||
| 1536 | (const wchar_t *restrict haystack, | ||
| 1537 | const wchar_t *restrict needle) | ||
| 1538 | _GL_ATTRIBUTE_PURE); | ||
| 1539 | _GL_CXXALIAS_RPL (wcsstr, wchar_t *, | ||
| 1540 | (const wchar_t *restrict haystack, | ||
| 1541 | const wchar_t *restrict needle)); | ||
| 1542 | # else | ||
| 1543 | # if !@HAVE_WCSSTR@ | ||
| 1219 | _GL_FUNCDECL_SYS (wcsstr, wchar_t *, | 1544 | _GL_FUNCDECL_SYS (wcsstr, wchar_t *, |
| 1220 | (const wchar_t *restrict haystack, | 1545 | (const wchar_t *restrict haystack, |
| 1221 | const wchar_t *restrict needle) | 1546 | const wchar_t *restrict needle) |
| 1222 | _GL_ATTRIBUTE_PURE); | 1547 | _GL_ATTRIBUTE_PURE); |
| 1223 | # endif | 1548 | # endif |
| 1224 | /* On some systems, this function is defined as an overloaded function: | 1549 | /* On some systems, this function is defined as an overloaded function: |
| 1225 | extern "C++" { | 1550 | extern "C++" { |
| 1226 | const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); | 1551 | const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *); |
| @@ -1231,6 +1556,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcsstr, | |||
| 1231 | (const wchar_t *restrict, const wchar_t *restrict), | 1556 | (const wchar_t *restrict, const wchar_t *restrict), |
| 1232 | const wchar_t *, | 1557 | const wchar_t *, |
| 1233 | (const wchar_t *restrict, const wchar_t *restrict)); | 1558 | (const wchar_t *restrict, const wchar_t *restrict)); |
| 1559 | # endif | ||
| 1234 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ | 1560 | # if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ |
| 1235 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | 1561 | && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) |
| 1236 | _GL_CXXALIASWARN1 (wcsstr, wchar_t *, | 1562 | _GL_CXXALIASWARN1 (wcsstr, wchar_t *, |
| @@ -1358,6 +1684,24 @@ _GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - " | |||
| 1358 | #endif | 1684 | #endif |
| 1359 | 1685 | ||
| 1360 | 1686 | ||
| 1687 | #if @GNULIB_WGETCWD@ && (defined _WIN32 && !defined __CYGWIN__) | ||
| 1688 | /* Gets the name of the current working directory. | ||
| 1689 | (a) If BUF is non-NULL, it is assumed to have room for SIZE wide characters. | ||
| 1690 | This function stores the working directory (NUL-terminated) in BUF and | ||
| 1691 | returns BUF. | ||
| 1692 | (b) If BUF is NULL, an array is allocated with 'malloc'. The array is SIZE | ||
| 1693 | wide characters long, unless SIZE == 0, in which case it is as big as | ||
| 1694 | necessary. | ||
| 1695 | If the directory couldn't be determined or SIZE was too small, this function | ||
| 1696 | returns NULL and sets errno. For a directory of length LEN, SIZE should be | ||
| 1697 | >= LEN + 3 in case (a) or >= LEN + 1 in case (b). | ||
| 1698 | Possible errno values include: | ||
| 1699 | - ERANGE if SIZE is too small. | ||
| 1700 | - ENOMEM if the memory could no be allocated. */ | ||
| 1701 | _GL_FUNCDECL_SYS (wgetcwd, wchar_t *, (wchar_t *buf, size_t size)); | ||
| 1702 | #endif | ||
| 1703 | |||
| 1704 | |||
| 1361 | #endif /* _@GUARD_PREFIX@_WCHAR_H */ | 1705 | #endif /* _@GUARD_PREFIX@_WCHAR_H */ |
| 1362 | #endif /* _@GUARD_PREFIX@_WCHAR_H */ | 1706 | #endif /* _@GUARD_PREFIX@_WCHAR_H */ |
| 1363 | #endif | 1707 | #endif |
