From cd0f2012d3670c41aa369d6cac3ea509cff20cb2 Mon Sep 17 00:00:00 2001 From: tnozaki Date: Tue, 12 Aug 2008 21:59:27 +0000 Subject: SUSv3 says, if not printable wide-character exists, return -1. --- lib/libc/string/wcswidth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/libc/string') diff --git a/lib/libc/string/wcswidth.c b/lib/libc/string/wcswidth.c index 54fc98a3159..801089ef07f 100644 --- a/lib/libc/string/wcswidth.c +++ b/lib/libc/string/wcswidth.c @@ -1,4 +1,4 @@ -/* $NetBSD: wcswidth.c,v 1.4 2008/08/12 20:51:25 tnozaki Exp $ */ +/* $NetBSD: wcswidth.c,v 1.5 2008/08/12 21:59:27 tnozaki Exp $ */ /*- * Copyright (c)1999 Citrus Project, @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcswidth.c,v 1.4 2008/08/12 20:51:25 tnozaki Exp $"); +__RCSID("$NetBSD: wcswidth.c,v 1.5 2008/08/12 21:59:27 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -49,8 +49,9 @@ wcswidth(s, n) w = 0; while (n && *s) { x = wcwidth(*s); - if (x > 0) - w += x; + if (x < 0) + return -1; + w += x; s++; n--; } -- cgit