From owner-svn-src-all@freebsd.org Mon Nov 9 22:06:23 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE827A2A037; Mon, 9 Nov 2015 22:06:23 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85BB5157F; Mon, 9 Nov 2015 22:06:23 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA9M6McI060115; Mon, 9 Nov 2015 22:06:22 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA9M6MlV060111; Mon, 9 Nov 2015 22:06:22 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201511092206.tA9M6MlV060111@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Mon, 9 Nov 2015 22:06:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290618 - head/lib/libc/locale X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 22:06:23 -0000 Author: bapt Date: Mon Nov 9 22:06:22 2015 New Revision: 290618 URL: https://svnweb.freebsd.org/changeset/base/290618 Log: 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 Modified: head/lib/libc/locale/Makefile.inc head/lib/libc/locale/mblocal.h head/lib/libc/locale/nl_langinfo.c head/lib/libc/locale/setrunelocale.c Modified: head/lib/libc/locale/Makefile.inc ============================================================================== --- head/lib/libc/locale/Makefile.inc Mon Nov 9 21:53:39 2015 (r290617) +++ head/lib/libc/locale/Makefile.inc Mon Nov 9 22:06:22 2015 (r290618) @@ -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 \ Modified: head/lib/libc/locale/mblocal.h ============================================================================== --- head/lib/libc/locale/mblocal.h Mon Nov 9 21:53:39 2015 (r290617) +++ head/lib/libc/locale/mblocal.h Mon Nov 9 22:06:22 2015 (r290618) @@ -76,6 +76,7 @@ int _GB2312_init(struct xlocale_ctype *, 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); Modified: head/lib/libc/locale/nl_langinfo.c ============================================================================== --- head/lib/libc/locale/nl_langinfo.c Mon Nov 9 21:53:39 2015 (r290617) +++ head/lib/libc/locale/nl_langinfo.c Mon Nov 9 22:06:22 2015 (r290618) @@ -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); Modified: head/lib/libc/locale/setrunelocale.c ============================================================================== --- head/lib/libc/locale/setrunelocale.c Mon Nov 9 21:53:39 2015 (r290617) +++ head/lib/libc/locale/setrunelocale.c Mon Nov 9 22:06:22 2015 (r290618) @@ -129,7 +129,9 @@ __setrunelocale(struct xlocale_ctype *l, 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);