615 remove support legacy 7-bit ASCII
628 minor perf enhancement for UTF-8
Reviewed by:
[email protected]
Approved by:
[email protected]
--- a/usr/src/cmd/localedef/wide.c Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/cmd/localedef/wide.c Thu Jan 13 21:05:28 2011 -0800
@@ -10,7 +10,7 @@
*/
/*
- * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -116,10 +116,6 @@
*/
{ "GB2312", "GB2312", 16, towide_gb2312, tomb_mbs },
- { "ASCII", "ASCII", 7, towide_none, tomb_none },
- { "US-ASCII", "ASCII", 7, towide_none, tomb_none },
- { "646", "ASCII", 7, towide_none, tomb_none },
-
{ NULL, NULL },
};
--- a/usr/src/lib/libc/amd64/Makefile Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/amd64/Makefile Thu Jan 13 21:05:28 2011 -0800
@@ -21,7 +21,7 @@
#
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
#
-# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -705,7 +705,6 @@
wcstoul_longlong.o
PORTLOCALE= \
- ascii.o \
big5.o \
btowc.o \
collate.o \
--- a/usr/src/lib/libc/i386/Makefile.com Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/i386/Makefile.com Thu Jan 13 21:05:28 2011 -0800
@@ -21,7 +21,7 @@
#
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
#
-# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -747,7 +747,6 @@
wcstoul_longlong.o
PORTLOCALE= \
- ascii.o \
big5.o \
btowc.o \
collate.o \
--- a/usr/src/lib/libc/port/locale/ascii.c Thu Jan 13 08:38:20 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
-/*
- * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Borman at Krystal Technologies.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "lint.h"
-#include <sys/types.h>
-#include <errno.h>
-#include <limits.h>
-#include "runetype.h"
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-#include <note.h>
-#include "mblocal.h"
-
-static size_t _ascii_mbrtowc(wchar_t *_RESTRICT_KYWD,
- const char *_RESTRICT_KYWD,
- size_t, mbstate_t *_RESTRICT_KYWD);
-static int _ascii_mbsinit(const mbstate_t *);
-static size_t _ascii_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst,
- const char **_RESTRICT_KYWD src, size_t nms, size_t len,
- mbstate_t *_RESTRICT_KYWD ps);
-static size_t _ascii_wcrtomb(char *_RESTRICT_KYWD, wchar_t,
- mbstate_t *_RESTRICT_KYWD);
-static size_t _ascii_wcsnrtombs(char *_RESTRICT_KYWD,
- const wchar_t **_RESTRICT_KYWD,
- size_t, size_t, mbstate_t *_RESTRICT_KYWD);
-
-int
-_ascii_init(_RuneLocale *rl)
-{
-
- __mbrtowc = _ascii_mbrtowc;
- __mbsinit = _ascii_mbsinit;
- __mbsnrtowcs = _ascii_mbsnrtowcs;
- __wcrtomb = _ascii_wcrtomb;
- __wcsnrtombs = _ascii_wcsnrtombs;
- _CurrentRuneLocale = rl;
- __ctype[520] = 1;
- charset_is_ascii = 1;
- return (0);
-}
-
-static int
-_ascii_mbsinit(const mbstate_t *ps)
-{
- _NOTE(ARGUNUSED(ps));
- /*
- * Encoding is not state dependent - we are always in the
- * initial state.
- */
- return (1);
-}
-
-static size_t
-_ascii_mbrtowc(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s,
- size_t n, mbstate_t *_RESTRICT_KYWD ps)
-{
- _NOTE(ARGUNUSED(ps));
- if (s == NULL)
- /* Reset to initial shift state (no-op) */
- return (0);
- if (n == 0)
- /* Incomplete multibyte sequence */
- return ((size_t)-2);
- if (*s & 0x80) {
- errno = EILSEQ;
- return ((size_t)-1);
- }
- if (pwc != NULL)
- *pwc = (unsigned char)*s;
- return (*s == '\0' ? 0 : 1);
-}
-
-static size_t
-_ascii_wcrtomb(char *_RESTRICT_KYWD s, wchar_t wc,
- mbstate_t *_RESTRICT_KYWD ps)
-{
- _NOTE(ARGUNUSED(ps));
-
- if (s == NULL)
- /* Reset to initial shift state (no-op) */
- return (1);
- if (wc < 0 || wc > 127) {
- errno = EILSEQ;
- return ((size_t)-1);
- }
- *s = (unsigned char)wc;
- return (1);
-}
-
-static size_t
-_ascii_mbsnrtowcs(wchar_t *_RESTRICT_KYWD dst, const char **_RESTRICT_KYWD src,
- size_t nms, size_t len, mbstate_t *_RESTRICT_KYWD ps)
-{
- const char *s;
- size_t nchr;
-
- _NOTE(ARGUNUSED(ps));
-
- if (dst == NULL) {
- for (s = *src; nms > 0 && *s != '\0'; s++, nms--) {
- if (*s & 0x80) {
- errno = EILSEQ;
- return ((size_t)-1);
- }
- }
- return (s - *src);
- }
-
- s = *src;
- nchr = 0;
- while (len-- > 0 && nms-- > 0) {
- if (*s & 0x80) {
- errno = EILSEQ;
- return ((size_t)-1);
- }
- if ((*dst++ = (unsigned char)*s++) == L'\0') {
- *src = NULL;
- return (nchr);
- }
- nchr++;
- }
- *src = s;
- return (nchr);
-}
-
-static size_t
-_ascii_wcsnrtombs(char *_RESTRICT_KYWD dst, const wchar_t **_RESTRICT_KYWD src,
- size_t nwc, size_t len, mbstate_t *_RESTRICT_KYWD ps)
-{
- const wchar_t *s;
- size_t nchr;
-
- _NOTE(ARGUNUSED(ps));
-
- if (dst == NULL) {
- for (s = *src; nwc > 0 && *s != L'\0'; s++, nwc--) {
- if (*s < 0 || *s > 127) {
- errno = EILSEQ;
- return ((size_t)-1);
- }
- }
- return (s - *src);
- }
-
- s = *src;
- nchr = 0;
- while (len-- > 0 && nwc-- > 0) {
- if (*s < 0 || *s > 127) {
- errno = EILSEQ;
- return ((size_t)-1);
- }
- if ((*dst++ = *s++) == '\0') {
- *src = NULL;
- return (nchr);
- }
- nchr++;
- }
- *src = s;
- return (nchr);
-}
--- a/usr/src/lib/libc/port/locale/mblocal.h Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/port/locale/mblocal.h Thu Jan 13 21:05:28 2011 -0800
@@ -34,7 +34,6 @@
* Rune initialization function prototypes.
*/
int _none_init(_RuneLocale *);
-int _ascii_init(_RuneLocale *);
int _UTF8_init(_RuneLocale *);
int _EUC_CN_init(_RuneLocale *);
int _EUC_JP_init(_RuneLocale *);
--- a/usr/src/lib/libc/port/locale/setrunelocale.c Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/port/locale/setrunelocale.c Thu Jan 13 21:05:28 2011 -0800
@@ -147,8 +147,6 @@
if (strcmp(rl->__encoding, "NONE") == 0)
ret = _none_init(rl);
- else if (strcmp(rl->__encoding, "ASCII") == 0)
- ret = _ascii_init(rl);
else if (strcmp(rl->__encoding, "UTF-8") == 0)
ret = _UTF8_init(rl);
else if (strcmp(rl->__encoding, "EUC-CN") == 0)
--- a/usr/src/lib/libc/port/locale/utf8.c Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/port/locale/utf8.c Thu Jan 13 21:05:28 2011 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2002-2004 Tim J. Robbins
* All rights reserved.
*
@@ -110,13 +110,6 @@
/* Incomplete multibyte sequence */
return ((size_t)-2);
- if (us->want == 0 && ((ch = (unsigned char)*s) & ~0x7f) == 0) {
- /* Fast path for plain ASCII characters. */
- if (pwc != NULL)
- *pwc = ch;
- return (ch != '\0' ? 1 : 0);
- }
-
if (us->want == 0) {
/*
* Determine the number of octets that make up this character
@@ -132,10 +125,12 @@
*/
ch = (unsigned char)*s;
if ((ch & 0x80) == 0) {
- mask = 0x7f;
- want = 1;
- lbound = 0;
- } else if ((ch & 0xe0) == 0xc0) {
+ /* Fast path for plain ASCII characters. */
+ if (pwc != NULL)
+ *pwc = ch;
+ return (ch != '\0' ? 1 : 0);
+ }
+ if ((ch & 0xe0) == 0xc0) {
mask = 0x1f;
want = 2;
lbound = 0x80;
@@ -312,12 +307,6 @@
/* Reset to initial shift state (no-op) */
return (1);
- if ((wc & ~0x7f) == 0) {
- /* Fast path for plain ASCII characters. */
- *s = (char)wc;
- return (1);
- }
-
/*
* Determine the number of octets needed to represent this character.
* We always output the shortest sequence possible. Also specify the
@@ -325,8 +314,9 @@
* about the sequence length.
*/
if ((wc & ~0x7f) == 0) {
- lead = 0;
- len = 1;
+ /* Fast path for plain ASCII characters. */
+ *s = (char)wc;
+ return (1);
} else if ((wc & ~0x7ff) == 0) {
lead = 0xc0;
len = 2;
--- a/usr/src/lib/libc/sparc/Makefile.com Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/sparc/Makefile.com Thu Jan 13 21:05:28 2011 -0800
@@ -21,7 +21,7 @@
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
#
-# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -780,7 +780,6 @@
wcstoul_longlong.o
PORTLOCALE= \
- ascii.o \
big5.o \
btowc.o \
collate.o \
--- a/usr/src/lib/libc/sparcv9/Makefile.com Thu Jan 13 08:38:20 2011 -0800
+++ b/usr/src/lib/libc/sparcv9/Makefile.com Thu Jan 13 21:05:28 2011 -0800
@@ -21,7 +21,7 @@
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
#
-# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -729,7 +729,6 @@
wcstoul_longlong.o
PORTLOCALE= \
- ascii.o \
big5.o \
btowc.o \
collate.o \