zsh-workers
 help / color / mirror / code / Atom feed
* num_in_chars incremented after each mbrtowc()
@ 2015-12-06  9:37 Sebastian Gniazdowski
  2015-12-06 10:24 ` Sebastian Gniazdowski
  2015-12-06 15:49 ` Peter Stephenson
  0 siblings, 2 replies; 8+ messages in thread
From: Sebastian Gniazdowski @ 2015-12-06  9:37 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

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

[-- Attachment #2: num_in_char.diff --]
[-- Type: text/plain, Size: 503 bytes --]

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));

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-12-06 17:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-06  9:37 num_in_chars incremented after each mbrtowc() Sebastian Gniazdowski
2015-12-06 10:24 ` Sebastian Gniazdowski
2015-12-06 15:49 ` Peter Stephenson
2015-12-06 16:40   ` Sebastian Gniazdowski
2015-12-06 17:13     ` Peter Stephenson
2015-12-06 17:03   ` Sebastian Gniazdowski
2015-12-06 17:33     ` Peter Stephenson
2015-12-06 17:40       ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).