diff options
Diffstat (limited to 'src/lib/libc/string/wcswidth.c')
| -rw-r--r-- | src/lib/libc/string/wcswidth.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/libc/string/wcswidth.c b/src/lib/libc/string/wcswidth.c index cd240897b5..8ea1bdf6e6 100644 --- a/src/lib/libc/string/wcswidth.c +++ b/src/lib/libc/string/wcswidth.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: wcswidth.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ | 1 | /* $OpenBSD: wcswidth.c,v 1.4 2011/04/04 18:16:24 stsp Exp $ */ |
| 2 | /* $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | 2 | /* $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ |
| 3 | 3 | ||
| 4 | /*- | 4 | /*- |
| @@ -34,11 +34,14 @@ | |||
| 34 | int | 34 | int |
| 35 | wcswidth(const wchar_t *s, size_t n) | 35 | wcswidth(const wchar_t *s, size_t n) |
| 36 | { | 36 | { |
| 37 | int w; | 37 | int w, q; |
| 38 | 38 | ||
| 39 | w = 0; | 39 | w = 0; |
| 40 | while (n && *s) { | 40 | while (n && *s) { |
| 41 | w += wcwidth(*s); | 41 | q = wcwidth(*s); |
| 42 | if (q == -1) | ||
| 43 | return (-1); | ||
| 44 | w += q; | ||
| 42 | s++; | 45 | s++; |
| 43 | n--; | 46 | n--; |
| 44 | } | 47 | } |
