From 815cc9fc0d8b6af3674eb9ea7971c1a5ce79b77e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sat, 27 Mar 2010 19:04:35 +0000 Subject: rationalise widths of non-printing characters to zero. --- Src/utils.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 38c820f29..1d7b3109a 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -4406,6 +4406,8 @@ mb_metacharlenconv(const char *s, wint_t *wcp) * until end of string. * * If width is 1, return total character width rather than number. + * If width is greater than 1, return 1 if character has non-zero width, + * else 0. */ /**/ @@ -4444,13 +4446,15 @@ mb_metastrlen(char *ptr, int width) } else if (width) { /* * Returns -1 if not a printable character. We - * turn this into 1 for backward compatibility. + * turn this into 0. */ int wcw = WCWIDTH(wc); - if (wcw >= 0) - num += wcw; - else - num++; + if (wcw > 0) { + if (width == 1) + num += wcw; + else + num++; + } } else num++; laststart = ptr; @@ -5859,8 +5863,8 @@ privasserted(void) cap_free(caps); return 1; } - cap_free(caps); } + cap_free(caps); } #endif /* HAVE_CAP_GET_PROC */ return 0; -- cgit 1.4.1