mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-04 08:30:54 +02:00
Changed the name of the "ret" variable in mb_niceformat() to "cnt"
because "ret" is usually used for a variable name to hold the return value of the function. Also, changed the test when checking for a \0 to only check if "cnt" is 0, since we must always change a value of 0 to 1.
This commit is contained in:
parent
cc890edcb5
commit
00465c76fb
1 changed files with 7 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue