* libc/stdlib/mbtowc_r.c (__utf8_mbtowc): Fix incrementing n in case
of handling incomplete sequences.
This commit is contained in:
parent
8d641a5b46
commit
ecf5c883df
|
@ -1,3 +1,8 @@
|
||||||
|
2009-07-28 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* libc/stdlib/mbtowc_r.c (__utf8_mbtowc): Fix incrementing n in case
|
||||||
|
of handling incomplete sequences.
|
||||||
|
|
||||||
2009-07-22 Eric Blake <ebb9@byu.net>
|
2009-07-22 Eric Blake <ebb9@byu.net>
|
||||||
|
|
||||||
Avoid a fault from locking a closed standard file.
|
Avoid a fault from locking a closed standard file.
|
||||||
|
|
|
@ -220,11 +220,7 @@ _DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state),
|
||||||
if (state->__count == 0)
|
if (state->__count == 0)
|
||||||
ch = t[i++];
|
ch = t[i++];
|
||||||
else
|
else
|
||||||
{
|
ch = state->__value.__wchb[0];
|
||||||
if (n < (size_t)-1)
|
|
||||||
++n;
|
|
||||||
ch = state->__value.__wchb[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ch == '\0')
|
if (ch == '\0')
|
||||||
{
|
{
|
||||||
|
@ -244,7 +240,10 @@ _DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state),
|
||||||
{
|
{
|
||||||
/* two-byte sequence */
|
/* two-byte sequence */
|
||||||
state->__value.__wchb[0] = ch;
|
state->__value.__wchb[0] = ch;
|
||||||
state->__count = 1;
|
if (state->__count == 0)
|
||||||
|
state->__count = 1;
|
||||||
|
else if (n < (size_t)-1)
|
||||||
|
++n;
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return -2;
|
return -2;
|
||||||
ch = t[i++];
|
ch = t[i++];
|
||||||
|
@ -288,7 +287,10 @@ _DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state),
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
state->__value.__wchb[1] = ch;
|
state->__value.__wchb[1] = ch;
|
||||||
state->__count = 2;
|
if (state->__count == 1)
|
||||||
|
state->__count = 2;
|
||||||
|
else if (n < (size_t)-1)
|
||||||
|
++n;
|
||||||
if (n < 3)
|
if (n < 3)
|
||||||
return -2;
|
return -2;
|
||||||
ch = t[i++];
|
ch = t[i++];
|
||||||
|
@ -347,7 +349,10 @@ _DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state),
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
state->__value.__wchb[2] = ch;
|
state->__value.__wchb[2] = ch;
|
||||||
state->__count = 3;
|
if (state->__count == 2)
|
||||||
|
state->__count = 3;
|
||||||
|
else if (n < (size_t)-1)
|
||||||
|
++n;
|
||||||
if (n < 4)
|
if (n < 4)
|
||||||
return -2;
|
return -2;
|
||||||
ch = t[i++];
|
ch = t[i++];
|
||||||
|
|
Loading…
Reference in New Issue