diff options
author | bapt <bapt@FreeBSD.org> | 2016-04-21 07:36:11 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2016-04-21 07:36:11 +0000 |
commit | eaf20188e5e1b9d323add5e7026948e8e159c659 (patch) | |
tree | 5731ac8aa9dd7fb30296bc47f41b35dc292d2915 /lib/libc | |
parent | b3fe4144487aedced177175834215d3e72f50721 (diff) | |
download | FreeBSD-src-eaf20188e5e1b9d323add5e7026948e8e159c659.zip FreeBSD-src-eaf20188e5e1b9d323add5e7026948e8e159c659.tar.gz |
Restore the original ascii.c from prior to r290494
It was doing the right thing, there was no need to "fail" to reinvent it from
none.c
Pointy hat: bapt
Submitted by: ache
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/locale/ascii.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/libc/locale/ascii.c b/lib/libc/locale/ascii.c index a550c70..784814d 100644 --- a/lib/libc/locale/ascii.c +++ b/lib/libc/locale/ascii.c @@ -1,6 +1,4 @@ -/* - * Copyright 2013 Garrett D'Amore <garrett@damore.org> - * 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. @@ -36,8 +34,6 @@ * 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. - * - * @(#)none.c 8.1 (Berkeley) 6/4/93 */ #include <sys/cdefs.h> @@ -65,7 +61,7 @@ static size_t _ascii_wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, size_t, mbstate_t * __restrict); int -_ascii_init(struct xlocale_ctype *l, _RuneLocale *rl) +_ascii_init(struct xlocale_ctype *l,_RuneLocale *rl) { l->__mbrtowc = _ascii_mbrtowc; @@ -82,6 +78,7 @@ _ascii_init(struct xlocale_ctype *l, _RuneLocale *rl) static int _ascii_mbsinit(const mbstate_t *ps __unused) { + /* * Encoding is not state dependent - we are always in the * initial state. @@ -93,6 +90,7 @@ static size_t _ascii_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s, size_t n, mbstate_t * __restrict ps __unused) { + if (s == NULL) /* Reset to initial shift state (no-op) */ return (0); @@ -132,13 +130,11 @@ _ascii_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src, size_t nchr; if (dst == NULL) { - s = memchr(*src, '\0', nms); - if (s == NULL) - return (nms); - - if (*s & 0x80) { - errno = EILSEQ; - return ((size_t)-1); + for (s = *src; nms > 0 && *s != '\0'; s++, nms--) { + if (*s & 0x80) { + errno = EILSEQ; + return ((size_t)-1); + } } return (s - *src); } @@ -193,3 +189,4 @@ _ascii_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, *src = s; return (nchr); } + |