From b5174f925f439c60c61602dbd4e0930d1386aaee Mon Sep 17 00:00:00 2001 From: tnozaki Date: Tue, 12 Aug 2008 20:51:25 +0000 Subject: SUSv3 says, wcwidth(wc) returns: 1) wc is nul wide-character, return 0. 2) wc is printable wide-character, return column width. 3) else, return -1. but our implementation, case 3) returns 0. it's wrong! --- lib/libc/string/wcswidth.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/libc/string') diff --git a/lib/libc/string/wcswidth.c b/lib/libc/string/wcswidth.c index bb7531badb7..54fc98a3159 100644 --- a/lib/libc/string/wcswidth.c +++ b/lib/libc/string/wcswidth.c @@ -1,4 +1,4 @@ -/* $NetBSD: wcswidth.c,v 1.3 2005/02/09 21:35:47 kleink Exp $ */ +/* $NetBSD: wcswidth.c,v 1.4 2008/08/12 20:51:25 tnozaki Exp $ */ /*- * Copyright (c)1999 Citrus Project, @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcswidth.c,v 1.3 2005/02/09 21:35:47 kleink Exp $"); +__RCSID("$NetBSD: wcswidth.c,v 1.4 2008/08/12 20:51:25 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -42,13 +42,15 @@ wcswidth(s, n) const wchar_t *s; size_t n; { - int w; + int w, x; _DIAGASSERT(s != NULL); w = 0; while (n && *s) { - w += wcwidth(*s); + x = wcwidth(*s); + if (x > 0) + w += x; s++; n--; } -- cgit