Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: num_in_chars incremented after each mbrtowc()



Found one other missing incrementation of num_in_char. Diff against
utils.c with the previous patch applied

Best regards,
Sebastian Gniazdowski


On 6 December 2015 at 10:37, Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
> 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 b0a6625..d42d5c3 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5066,9 +5066,10 @@ mb_metastrlenend(char *ptr, int width, char *eptr)
 
     memset(&mb_shiftstate, 0, sizeof(mb_shiftstate));
     while (*ptr && !(eptr && ptr >= eptr)) {
-	if (*ptr == Meta)
+	if (*ptr == Meta) {
 	    inchar = *++ptr ^ 32;
-	else
+            num_in_char++;
+        } else
 	    inchar = *ptr;
 	ptr++;
 	ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate);


Messages sorted by: Reverse Date, Date, Thread, Author