summaryrefslogtreecommitdiff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-03-27 19:04:35 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-03-27 19:04:35 +0000
commit815cc9fc0d8b6af3674eb9ea7971c1a5ce79b77e (patch)
tree0b9c4ecd66aae8bc3b958522ced9388a4d9d69ee /Src/utils.c
parent691be6d0fcf43bf21a9c4c3122380fb4f92db055 (diff)
downloadzsh-815cc9fc0d8b6af3674eb9ea7971c1a5ce79b77e.tar.gz
zsh-815cc9fc0d8b6af3674eb9ea7971c1a5ce79b77e.zip
rationalise widths of non-printing characters to zero.
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c16
1 files changed, 10 insertions, 6 deletions
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;