diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/utils.c | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index aab22b0c9..2c7b5ad94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-12-06 Peter Stephenson <p.w.stephenson@ntlworld.com> + * 37326: Src/utils.c: comment how counting for multibyte string + lengths and widths is supposed to work. + * 37314: Src/utils.c, Src/zsh.h: upgrade quotedzputs() to use nicechar() where necessary. Regularise nicechar() etc. to prodduce $'...' compatible output. diff --git a/Src/utils.c b/Src/utils.c index d1313837d..45f8286df 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -5179,6 +5179,17 @@ mb_metastrlenend(char *ptr, int width, char *eptr) ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate); if (ret == MB_INCOMPLETE) { + /* + * "num_in_char" is only used for incomplete characters. The + * assumption is that we will output this ocatet as a single + * character (of single width) if we don't get a complete + * character; if we do get a complete character, num_in_char + * becomes irrelevant and is set to zero. + * + * This is in contrast to "num" which counts the characters + * or widths in complete characters. The two are summed, + * so we don't count characters twice. + */ num_in_char++; } else { if (ret == MB_INVALID) { |