Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/gen Fix from J.R. Oldroyd for wide chars > 2
details: https://anonhg.NetBSD.org/src/rev/7a2718389780
branches: trunk
changeset: 784898:7a2718389780
user: christos <christos%NetBSD.org@localhost>
date: Wed Feb 13 22:15:43 2013 +0000
description:
Fix from J.R. Oldroyd for wide chars > 2
diffstat:
lib/libc/gen/vis.c | 44 ++++++++++++++++++++------------------------
1 files changed, 20 insertions(+), 24 deletions(-)
diffs (78 lines):
diff -r 64aa4399f5ed -r 7a2718389780 lib/libc/gen/vis.c
--- a/lib/libc/gen/vis.c Wed Feb 13 18:45:20 2013 +0000
+++ b/lib/libc/gen/vis.c Wed Feb 13 22:15:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.49 2013/02/13 15:22:09 christos Exp $ */
+/* $NetBSD: vis.c,v 1.50 2013/02/13 22:15:43 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.49 2013/02/13 15:22:09 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.50 2013/02/13 22:15:43 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef __FBSDID
__FBSDID("$FreeBSD$");
@@ -288,10 +288,11 @@
int flag, const char *mbextra)
{
wchar_t *dst, *src, *pdst, *psrc, *start, *extra, *nextra;
- size_t len, olen, mbslength;
+ size_t len, olen;
wint_t c;
visfun_t f;
int clen, error = -1;
+ ssize_t mbslength;
_DIAGASSERT(mbdst != NULL);
_DIAGASSERT(mbsrc != NULL);
@@ -311,30 +312,25 @@
dst = pdst;
src = psrc;
- if (mblength > 1) {
- mbslength = mblength;
- while (mbslength) {
- clen = mbtowc(src, mbsrc, mbslength);
- if (clen < 0) {
- *src = (wint_t)(u_char)*mbsrc;
- clen = 1;
- }
- if (clen == 0)
- clen = 1;
- src++;
- mbsrc += clen;
- mbslength -= clen;
- }
- len = src - psrc;
- src = psrc;
- } else {
- len = mblength;
- src[0] = (wint_t)(u_char)mbsrc[0];
- src[1] = (wint_t)(u_char)mbsrc[1];
- }
if (mblength < len)
len = mblength;
+ mbslength = (ssize_t)mblength;
+ while (mbslength > 0) {
+ clen = mbtowc(src, mbsrc, MB_LEN_MAX);
+ if (clen < 0) {
+ *src = (wint_t)(u_char)*mbsrc;
+ clen = 1;
+ }`
+ if (clen == 0)
+ clen = 1;
+ src++;
+ mbsrc += clen;
+ mbslength -= clen;
+ }
+ len = src - psrc;
+ src = psrc;
+
mbstowcs(extra, mbextra, strlen(mbextra));
MAKEEXTRALIST(flag, nextra, extra);
if (!nextra) {
Home |
Main Index |
Thread Index |
Old Index