summaryrefslogtreecommitdiff
path: root/include/wchar.h (follow)
AgeCommit message (Collapse)Author
2025-11-10Remove wctombjvoisin
It's unfortunately valid to pass a buffer smaller than MB_CUR_MAX to wctomb, so let's not trap on this. Moreover, it's supposed to be implemented in stdlib.h and not wchar.h anyway.
2025-10-31add initial clang supportDaniel Kolesa
Co-Authored-By: jvoisin <julien.voisin@dustri.org>
2025-10-31avoid __extension__ with clangDaniel Kolesa
It seems useless and triggers 'error: expected external declaration'
2025-10-31Make use of __builtin_dynamic_object_sizejvoisin
GCC and Clang provide __builtin_dynamic_object_size (see documentation: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html), so we should make use of it when its available.
2019-03-07wctomb, wcrtomb: guard slow/trap path with MB_LEN_MAXinfo@mobile-stream.com
This allows the compiler to optimize out the slow/trap path at all for the typical correct code: char buf[MB_LEN_MAX]; r = wctomb(buf, c); The change tries to keep the "unknown object size" case handling in wcrtomb() as is even if it seems redundant and not helping (we copy __buf to possibly undersized __s in any case) and inconsistent with wctomb() (where we let the original library method itself overwrite the possibly undersized __s).
2019-02-25Make use of builtins whenever possiblesin
2018-07-24Don't use __extension__ in C++ codeA. Wilcox
A few important notes: * __extension__ is a GNU C "alternate" keyword, not a C++ keyword.[1] * __extension__ is designed to work on "expressions"; it does work on #include_next in C mode, but it has no effect in C++ mode; the warning will still appear, if enabled, even with __extension__ preceding #include_next. This is because #include_next is not considered an expression in C++, so the compiler attaches __extension__ to the first expression of the header. All of this leads us to a build failure while building at least all Mozilla software. Moz has an alternate -isystem dir searched before /usr/include that overrides some headers, including <features.h>. The first statement in each of these headers is a #pragma, and since __extension__ is looking for an expression, and #pragma is a "null" expression, we end up with the following error: dist/system_wrappers/features.h:1:9: error: '#pragma' is not allowed here Since __extension__ has no effect on #include_next in C++ mode anyway, and since it can cause breakage, this commit omits __extension__ in C++ mode. [1]: https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Alternate-Keywords.html
2017-08-22Don't trap if an encoding error occurs in wcrtomb()sin
The POSIX definition of wcrtomb (http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcrtomb.html) states: "When wc is not a valid wide character, an encoding error shall occur. In this case, the function shall store the value of the macro [EILSEQ] in errno and shall return (size_t)-1; the conversion state shall be undefined." The fortify-headers implementation of wcrtomb interprets the result -1 as 18446744073709551615 bytes. Since this is the highest 64-bit number possible, it is pretty safe to say this will always be larger than any buffer provided to wcrtomb. Therefore, it traps. Fixes bug https://bugs.alpinelinux.org/issues/7681. Patch by A. Wilcox <AWilcox@Wilcox-Tech.com>
2016-09-10Bump copyright yearsin
2015-07-15Fix wcrtomb() checksin
This was breaking valid code, example: char c; wcrtomb(&c, L'0', st);
2015-06-25Add __extension__ mark to include_next to silence -pedanticSteven Barth
Signed-off-by: Steven Barth <steven@midlink.org>
2015-06-03Use namespace-safe macro, param and variable namesTrutz Behn
2015-05-13Wrap some overly long linessin
2015-05-13Add LICENSE headersin
2015-05-13Add fortify_fn() helper in fortify-headers.hsin
2015-04-01Add feature-test guards for mbsnrtowcs() and wcsnrtombs()sin
2015-03-14Use __typeof__ to in part avoid replicating function typesTrutz Behn
2015-03-14Add __artificial__ to aid in debuggingsin
2015-03-13Restore C++ supportsin
2015-03-13Fix typo againsin
2015-03-13Rework fortify implementation to use extern inlinesin
Overriding functions with macros is legal in C but a lot of software is not prepared for it. Use the extern inline method to achieve the same result.
2015-03-11Put include guards in the reserved namespaceTrutz Behn
fortify-headers is considered part of the implementation.
2015-03-11Ignore C++ for nowsin
It is not legal to override standard functions using macros in C++. We may have to revisit this in the future.
2015-03-11Add ifdef guards for C++ codesin
2015-03-06Fix some checks in wchar.hsin
Some of these functions allow the destination pointer to be NULL. Do not trap in that case as nothing will be written to the destination buffer.
2015-03-05Fix mbsnrtowcs() and wcsnrtombs() checkssin
2015-03-04Fix wcsrtombs() checksin
2015-03-04Fix mbsrtowcs() checksin
2015-03-04Handle early termination in wcsnrtombs() and mbsnrtowcs()sin
2015-03-04Add wctomb() checksin
2015-03-04Add wcstombs() checksin
2015-03-04Add wcsnrtombs() and wcsrtombs() checkssin
2015-03-04Add wcsncat() and wcsncpy() checkssin
2015-03-04Add wcrtomb(), wcscat() and wcscpy() checkssin
2015-03-03Style fixsin
2015-03-03Add mbstowcs() checksin
2015-03-03Add mbsnrtowcs() and mbsrtowcs() checkssin
2015-03-03Add wmemcpy() and wmemmove() checkssin
2015-03-03Add wmemset() checksin
2015-03-03Add fgetws() checksin