diff options
author | bapt <bapt@FreeBSD.org> | 2015-11-09 22:06:22 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-11-09 22:06:22 +0000 |
commit | 439f8fc61698dfd5b293fb267a7709b048b4f3f3 (patch) | |
tree | cf4ba922cb9af391090f8c61b4c8cee01ce5360b /lib | |
parent | 33b03994ad53fe3c3ece88734649d72761b03710 (diff) | |
download | FreeBSD-src-439f8fc61698dfd5b293fb267a7709b048b4f3f3.zip FreeBSD-src-439f8fc61698dfd5b293fb267a7709b048b4f3f3.tar.gz |
locales: Enforce US-ASCII encoding (limited to 7-bit)
The US-ASCII format was getting treated identically to POSIX. It is
supposed to throw an ILSEQ errno if a value of 0x80 or greater is
encountered, so let's bring back the "ASCII" handling.
While here, change nl_codeset to return US-ASCII only when the encoding
really is "US-ASCII". Before "C" and "POSIX" encoding returned this
string, so now they return "POSIX".
Discussed with: ache
Submitted by: marino
Obtained from: DragonflyBSD
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/locale/Makefile.inc | 2 | ||||
-rw-r--r-- | lib/libc/locale/mblocal.h | 1 | ||||
-rw-r--r-- | lib/libc/locale/nl_langinfo.c | 2 | ||||
-rw-r--r-- | lib/libc/locale/setrunelocale.c | 4 |
4 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc index 08bc6e4..d28355b 100644 --- a/lib/libc/locale/Makefile.inc +++ b/lib/libc/locale/Makefile.inc @@ -4,7 +4,7 @@ # locale sources .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/locale ${LIBC_SRCTOP}/locale -SRCS+= big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c \ +SRCS+= ascii.c big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c \ gb18030.c gb2312.c gbk.c ctype.c isctype.c iswctype.c \ ldpart.c lmessages.c lmonetary.c lnumeric.c localeconv.c mblen.c \ mbrlen.c \ diff --git a/lib/libc/locale/mblocal.h b/lib/libc/locale/mblocal.h index d86fd55..75eab96 100644 --- a/lib/libc/locale/mblocal.h +++ b/lib/libc/locale/mblocal.h @@ -76,6 +76,7 @@ int _GB2312_init(struct xlocale_ctype *, _RuneLocale *); int _GBK_init(struct xlocale_ctype *, _RuneLocale *); int _BIG5_init(struct xlocale_ctype *, _RuneLocale *); int _MSKanji_init(struct xlocale_ctype *, _RuneLocale *); +int _ascii_init(struct xlocale_ctype *, _RuneLocale *); typedef size_t (*mbrtowc_pfn_t)(wchar_t * __restrict, const char * __restrict, size_t, mbstate_t * __restrict); diff --git a/lib/libc/locale/nl_langinfo.c b/lib/libc/locale/nl_langinfo.c index e3b370a..eeba8c3 100644 --- a/lib/libc/locale/nl_langinfo.c +++ b/lib/libc/locale/nl_langinfo.c @@ -71,6 +71,8 @@ nl_langinfo_l(nl_item item, locale_t loc) else if (strcmp(s, "MSKanji") == 0) ret = "SJIS"; else if (strcmp(s, "NONE") == 0) + ret = "POSIX"; + else if (strcmp(s, "NONE:US-ASCII") == 0) ret = "US-ASCII"; else if (strncmp(s, "NONE:", 5) == 0) ret = (char *)(s + 5); diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index 00e4d98..1ebfc38 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -129,7 +129,9 @@ __setrunelocale(struct xlocale_ctype *l, const char *encoding) rl->__sputrune = NULL; rl->__sgetrune = NULL; - if (strncmp(rl->__encoding, "NONE", 4) == 0) + if (strcmp(rl->__encoding, "NONE:US-ASCII") == 0) + ret = _ascii_init(l, rl); + else if (strncmp(rl->__encoding, "NONE", 4) == 0) ret = _none_init(l, rl); else if (strcmp(rl->__encoding, "UTF-8") == 0) ret = _UTF8_init(l, rl); |