From 87670fb011b638e5bde744a33a047305d17d95c2 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 6 Dec 2015 16:39:57 +0000 Subject: 37326: comment only: multibyte string lenght/width counting --- Src/utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Src/utils.c') 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) { -- cgit 1.4.1