Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
num_in_chars incremented after each mbrtowc()
- X-seq: zsh-workers 37323
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: num_in_chars incremented after each mbrtowc()
- Date: Sun, 6 Dec 2015 10:37:21 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=PoT6csrpaEDPAjDyghGARaJL7ky3VsOuNxf/MLyKXXs=; b=vP4+6FzOu6a8DpVwJunzesTlQw0srxXAekZaso0VJqvgBV8YZFVP3K5luiLSdeYFHN qVL9tDwqE46FuDrf1Ag9wVOeR5GmD+VLRxpj3a15wdintuNgjjbg+0wZRraBoDSVQESe g2ftqCQ6tIbWAcpj5TbP6ysCb8YVceI84fjoiSHDQmsgUanwaEqsyP+BzTuRrDe0CtnS ujQ3NF2ja1599ynPHm8G2FawOkizRA+PhNhgiP52UGs4AdMT2q+KcP/laGweblJipqa9 FC2nhbTqrIjcfZK4hUmhFrxZ0iiKVcLfvRY4yJ0v6SkKWy65Z9yC8s57cthUYIQmnHVA EL9Q==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hello,
while working my hands off on implementing display width handling in
params.c rather than subst.c I encountered a bug in mb_metastrlenend.
It will reveal itself only on improper unicode strings.
Best regards,
Sebastian Gniazdowski
diff --git a/Src/utils.c b/Src/utils.c
index ca810de..b0a6625 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5072,10 +5072,9 @@ mb_metastrlenend(char *ptr, int width, char *eptr)
inchar = *ptr;
ptr++;
ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate);
+ num_in_char++;
- if (ret == MB_INCOMPLETE) {
- num_in_char++;
- } else {
+ if (ret != MB_INCOMPLETE) {
if (ret == MB_INVALID) {
/* Reset, treat as single character */
memset(&mb_shiftstate, 0, sizeof(mb_shiftstate));
Messages sorted by:
Reverse Date,
Date,
Thread,
Author