diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/zle_utils.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index f4f3869b8..c4abad69d 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -275,36 +275,35 @@ stringaszleline(char *instr, int incs, int *outll, int *outsz, int *outcs) memset(&ps, '\0', sizeof(ps)); while (ll > 0) { - size_t ret = mbrtowc(outptr, inptr, ll, &ps); + size_t cnt = mbrtowc(outptr, inptr, ll, &ps); /* * At this point we don't handle either incomplete (-2) or * invalid (-1) multibyte sequences. Use the current length * and return. */ - if (ret == (size_t)-1 || ret == (size_t)-2) + if (cnt == (size_t)-1 || cnt == (size_t)-2) break; /* * Careful: converting a wide NUL returns zero, but we * want to treat NULs as regular characters. - * The NUL does get converted, however, so test that. * Assume it was represented by a single ASCII NUL; * certainly true for Unicode and unlikely to be false * in any non-pathological multibyte representation. */ - if (*outptr == L'\0' && ret == 0) - ret = 1; + if (cnt == 0) + cnt = 1; if (outcs) { int offs = inptr - instr; - if (offs <= incs && incs < offs + (int)ret) + if (offs <= incs && incs < offs + (int)cnt) *outcs = outptr - outstr; } - inptr += ret; + inptr += cnt; outptr++; - ll -= ret; + ll -= cnt; } if (outcs && inptr <= instr + incs) *outcs = outptr - outstr; |