freebsd-dev/lib/libc
Baptiste Daroussin d79cdd21de libc: Fix (and improve) nl_langinfo (CODESET)
The output of "locale charmap" is identical to the result of
nl_langinfo (CODESET) for any given locale.  The logic for returning the
codeset was very simplistic.  It just returned portion of the locale name
after the period (e.g. en_FR.ISO8859-1 returned "ISO8859-1").

When softlinks were added to locales, this broke.  e.g.:
   en_US returned ""
   en_FR.UTF8 returned "UTF8"
   en_FR.UTF-8 returned "UTF-8"
   zh_Hant_HK.Big5HKSCS returned "Big5HKSCS"
   zh_Hant_TW.Big5 returned "Big5"
   es_ES@euro returned ""

In order to fix this properly, the named locale cannot be used to
determine the encoding.  This information was almost available in the
rune data.  Unfortunately, all the single byte encodings were listed
as "NONE" encoding.

So I adjusted localedef tool to provide more information about the
encoding.  For example, instead of "NONE", the LC_CTYPE used by
fr_FR.ISO8859-15 is now encoded as "NONE:ISO8859-15".  The locale
handlers now check if the first four characters of the encoding is
"NONE" and if so, treats it as a single-byte encoding.

The nl_langinfo handling of CODESET was adjusting accordingly.  Now the
following is returned:
   en_US returns "ISO8859-1"
   fr_FR.UTF8 returns "UTF-8"
   fr_FR.UTF-8 returns "UTF-8"
   zh_Hant_HK.Big5HKSCS returns "Big5"
   zh_Hant_TW.Big5 returns "Big5"
   es_ES@euro returns "ISO8859-15"

as before, "C" and "POSIX" locales return "US-ASCII".  This is a big
improvement.  The result of nl_langinfo can never be a zero-length
string and it will always exclusively one of the values of the
character maps of /usr/src/tools/tools/locale/etc/final-maps.

Submitted by:	marino
Obtained from:	DragonflyBSD
2015-11-01 12:00:55 +00:00
..
aarch64 Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
amd64 Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
arm Annotate arm userspace assembler sources stating their tolerance to 2015-09-29 16:09:58 +00:00
capability
compat-43 Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:53:24 +00:00
db Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:55:00 +00:00
gdtoa Add missing include to eliminate -Wmissing-prototypes warning 2015-09-20 04:06:04 +00:00
gen wordexp: Rewrite to make WRDE_NOCMD reliable. 2015-09-30 21:32:29 +00:00
gmon Add declaration to eliminate -Wmissing-prototypes warning 2015-09-20 03:59:27 +00:00
i386 Switch libc from using _sig{procmask,action,suspend} symbols, which 2015-08-29 14:25:01 +00:00
iconv Fix improbable memory leak in _citrus_prop_read_str(). 2015-04-20 22:09:50 +00:00
include Switch libc from using _sig{procmask,action,suspend} symbols, which 2015-08-29 14:25:01 +00:00
inet Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:50:56 +00:00
isc Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-23 16:16:16 +00:00
locale libc: Fix (and improve) nl_langinfo (CODESET) 2015-11-01 12:00:55 +00:00
md Bring the md5 functions into libc for internal use only. 2014-08-12 12:25:56 +00:00
mips Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
nameser Add missing break. 2014-08-20 14:58:25 +00:00
net - address grammar 2015-10-05 18:09:43 +00:00
nls Use mdoc(7) macros to handle parenthesis 2015-04-26 10:54:52 +00:00
posix1e Remove names from some prototypes 2015-09-20 20:16:34 +00:00
powerpc Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
powerpc64 Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
quad Remove MK_ARM_EABI, the armeb issues have been fixed. The code to support 2014-10-01 08:26:51 +00:00
regex Revert r286465. Retesting it showed that it just works. it might have been 2015-08-09 21:32:05 +00:00
resolv resolver: automatically reload /etc/resolv.conf 2015-10-14 14:26:44 +00:00
rpc Use proper function prototypes. 2015-10-07 19:55:58 +00:00
secure Remove a stale comment and clarify the original where it was taken from 2015-08-14 14:58:04 +00:00
softfloat
sparc64 Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes warnings. 2015-09-20 04:59:01 +00:00
stdio Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:28:49 +00:00
stdlib Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:24:28 +00:00
stdtime Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:51:52 +00:00
string collate: Fix expansion substitions (broken upstream too) 2015-10-23 23:24:03 +00:00
sys Change the default setting of kern.ipc.shm_allow_removed from 0 to 1. 2015-10-10 09:29:47 +00:00
tests Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and 2015-10-12 08:16:03 +00:00
uuid
xdr Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. 2015-09-20 20:52:13 +00:00
yp
libc.ldscript
Makefile Move the stack protector to a new "secure" directory 2015-08-14 03:03:13 +00:00
Makefile.depend Update META_MODE dependencies. 2015-09-17 05:06:34 +00:00
Versions.def