| #
47e23bbe |
| 27-Feb-2016 |
schwarze <schwarze@openbsd.org> |
If an incomplete character is passed to mbtowc(3), set errno to EILSEQ. This is unambiguously required both by POSIX and by our own manual page.
It also makes a lot of sense because having a functio
If an incomplete character is passed to mbtowc(3), set errno to EILSEQ. This is unambiguously required both by POSIX and by our own manual page.
It also makes a lot of sense because having a function that can fail and that sets errno in some failure modes but does not set errno in other failure modes would be a terrible idea. Such a function would be ridiculously complicated to use. To detect the reason for failure, you would have to:
- save errno - reset errno to zero - call the function - inspect the return value to detect failure - inspect errno to decide about the reason for failure - if errno is zero, restore the saved errno
That is completely unreasonable, in particular for a seemingly innocous function like mbtowc(3). Next to no programmer would get that right in any real-world program.
Note that this bug is very widespread, it also affects NetBSD, FreeBSD, Solaris 11, and glibc. I will also send a note around to the other systems.
There may be fallout from programs using the interface incorrectly. If you run into any, please report that to me.
OK millert@
show more ...
|
| #
c9b8e388 |
| 27-Jul-2010 |
stsp <stsp@openbsd.org> |
Replace the single-byte placeholders for the multi-byte/wide-character conversion interfaces of libc (mbrtowc(3) and friends) with new implementations that internally call an API based on NetBSD's ci
Replace the single-byte placeholders for the multi-byte/wide-character conversion interfaces of libc (mbrtowc(3) and friends) with new implementations that internally call an API based on NetBSD's citrus. This allows us to support locales with multi-byte character encodings.
Provide two implementations of the citrus-based API: one based on the old single-byte placeholders for use with our existing single-byte character locales (C, ISO8859-*, KOI8, CP1251, etc.), and one that provides support for UTF-8 encoded characters (code based on FreeBSD's implementation).
Install the en_US.UTF-8 ctype locale support file, and allow the UTF-8 ctype locale to be enabled via setlocale(3) (export LC_CTYPE='en_US.UTF-8').
A lot of programs, especially from ports, will now start using UTF-8 if the UTF-8 locale is enabled. Use at your own risk, and please report any breakage. Note that ncurses-based programs cannot display UTF-8 right now, this is being worked on.
To prevent install media growth, add vfprintf(3) and mbrtowc(3) to libstubs. The mbrtowc stub was copied unchanged from its old single-byte placeholder. vfprintf.c doesn't need to be copied, just put in .PATH (hint by fgsch@).
Testing by myself, naddy, sthen, nicm, espie, armani, Dmitrij D. Czarkoff.
ok matthieu espie millert sthen nicm deraadt
show more ...
|