summaryrefslogtreecommitdiffstats
path: root/lib/libc/citrus
AgeCommit message (Collapse)AuthorFilesLines
2016-09-07Trivial cleanup: Pass pointers of the correct types to the privateschwarze1-9/+7
functions and delete a macro that is used in only one place; no functional change. This completes the audit of the citrus directory (only 3 files left).
2016-09-07trivial cleanup: delete inline attribute on static function,schwarze1-3/+3
leave that decision to the compiler; no functional change
2016-09-07trivial cleanup:schwarze2-79/+70
- delete unused headers - add missing function prototype - delete needless casts of return values - KNF: return is not a function - KNF: do not use a pointer as a boolean - consistent wording in comments: s/octets/bytes/ OK gcc: no object change after strip -g
2016-09-05Delete some abstraction that we don't and won't need.schwarze8-289/+41
Declare functions rather than generating declarations with macros. Just call functions rather than mainting function pointer tables. Purge unused arguments. Simplify mbstate_t casting. Garbage collect one empty and one unused function. As a bonus, make mbsinit(3) work at all, it returned garbage in the past due to a missing cast when passing mbstate_t. Apart from that, no functional change. No libc bump needed; only private functions are removed and change prototype and only private structs change size. OK stsp@ mpi@; deraadt@ likes the general direction.
2015-11-01delete old lint ARGSUSED commentsguenther2-12/+2
2015-10-13Tighten the ranges in wcrtomb(3).bentley1-2/+2
By definition, the range of valid Unicode code points is the union of U+0000..U+D7FF and U+E000..U+10FFFF (see Unicode 8.0.0, chapter 3.9). In UTF-16, the encoded values that would represent U+D800..U+DFFF are used for surrogate pairs. UTF-8 has no concept of surrogate pairs; attempting to treat them as regular code points violates the standard and makes no sense besides. ok stsp@
2015-10-12Make wcrtomb() more readable by weeding out range errors up front,schwarze1-14/+11
doing ASCII handling once rather than twice, and using <= rather than ((&~)==) obfuscation (which already caused a bug in the past). No functional change. Joint work with and OK stsp@ semarie@ bentley@
2015-10-10Code points U+10000 to U+fffff are valid, too.schwarze1-2/+2
Fixing a regression in wcrtomb(3) found with the mandoc testsuite that was caused by the last commit. OK semarie@ bentley@
2015-09-26correct a range problem in citrus-utf8 version of wcrtomb(3), in order to matchsemarie1-2/+2
RFC 3629 (limiting the range of UTF-8 to 0x10FFFF). it is the counterpart of a previous commit correcting mbrtowc(3). problem spotted by stsp ok bentley@ stsp@
2015-09-05off-by-one for the previous patch. the limit is inclusive: 0x10ffff is a valid codepoint.semarie1-2/+2
ok stsp@
2015-09-05check for limiting the range of UTF-8 to 0x10FFFF, as requested by RFC 3629.semarie1-1/+8
ok stsp@
2015-08-27Use static and __{BEGIN,ENV}_HIDDEN_DECLS to hide a bunch of internalguenther4-5/+11
symbols that are not longer exported. (This improves the generated code.) ok deraadt@
2015-01-16Move to the <limits.h> universe.deraadt1-3/+4
review by millert, binary checking process with doug, concept with guenther
2014-05-03Noncharacters 0xFFFE and 0xFFFF don't render a UTF-8 string invalidstsp1-3/+2
so stop rejecting them in our citrus UTF-8 parser. This is a common misinterpretation of the Unicode standard which resulted in a corrigendum last year: http://www.unicode.org/versions/corrigendum9.html Pointed out by jilles@freebsd (via pfg@freebsd), thanks!
2013-05-03Fix resetting MB_CUR_MAX when switching locales away from a UTF-8 locale.stsp2-4/+5
Patch by Vladimir Támara Patiño <vtamara@pasosdeJesus.org> ok mpi millert
2013-03-07Fix return value of wcrtomb() in single-byte locales if the s argument is NULL.stsp1-2/+2
wcrtomb() must pretend to store one byte (NUL-terminator) in this case. Patch by Vladimir Tamara Patino. ok guenther
2012-12-05Remove excessive sys/cdefs.h inclusionderaadt3-6/+3
ok guenther millert kettenis
2012-06-06Add support for mbsnrtowcs() and wcsnrtombs() to libc.matthew3-169/+172
Bulk build test by naddy.
2011-04-21Don't use 'n' for the length of multibyte chars, because it is the lengthyasuoka1-2/+3
of wide characters. This will fix a problem of uim-fep pre-edit display. OK stsp@
2010-08-05The UTF-8 decoder should not accept byte sequences which decode to unicodestsp1-1/+9
code positions U+D800 to U+DFFF (UTF-16 surrogates), U+FFFE, and U+FFFF. http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 http://unicode.org/faq/utf_bom.html#utf8-4 ok phessler, millert, miod, deraadt
2010-08-03When the target pointer 'pwcs' passed to mbsrtowcs() is NULL, mbsrtowcs()stsp1-15/+9
is supposed to ignore the 'n' parameter and return the number of wide characters needed to represent the given multi-byte character sequence. However, in the special case where 'pwcs' is NULL and 'n' is zero, our mbsrtowcs() implementation for single-byte locales mistakenly returned zero. Before the UTF-8 locale was added, this bug was invisible to callers of mbstowcs() because mbstowcs() handled this special case itself. But our new mbstowcs() implementation simply forwards to the locale-specific mbsrtowcs() implementation and expects it to do the right thing. The "awesome" window manager's "Run:" command prompt uses mbstowcs() to measure how many (possibly multi-byte) characters a user has typed, and due to this bug would always be tricked into thinking the user had entered zero characters when a single-byte locale was used. Found after prodding by dcoppa. ok deraadt sthen espie
2010-08-01add missing header needed by strcmp()chl2-2/+6
add missing prototype ok stsp@
2010-07-29Remove stray newline, fix $OpenBSD$; ok deraadtstsp2-3/+2
2010-07-27Replace the single-byte placeholders for the multi-byte/wide-characterstsp8-6/+765
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
2005-08-07commit LC_CTYPE files from NetBSD/citrus, not yet linked in.espie2-0/+72
okay deraadt@