Fix error in wcstombs: byte count not counted
Remove unneded casts in sgetrune/sputrune Submitted by: wcstombs fix by Mihoko Tanaka <m_tonaka@pa.yokogawa.co.jp>
This commit is contained in:
parent
39413a2c2a
commit
c0ea8ed12f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15286
@ -53,7 +53,7 @@ mblen(s, n)
|
||||
if (s == 0 || *s == 0)
|
||||
return (0); /* No support for state dependent encodings. */
|
||||
|
||||
if (sgetrune(s, (int)n, &e) == _INVALID_RUNE)
|
||||
if (sgetrune(s, n, &e) == _INVALID_RUNE)
|
||||
return (s - e);
|
||||
return (e - s);
|
||||
}
|
||||
@ -70,7 +70,7 @@ mbtowc(pwc, s, n)
|
||||
if (s == 0 || *s == 0)
|
||||
return (0); /* No support for state dependent encodings. */
|
||||
|
||||
if ((r = sgetrune(s, (int)n, &e)) == _INVALID_RUNE)
|
||||
if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE)
|
||||
return (s - e);
|
||||
if (pwc)
|
||||
*pwc = r;
|
||||
@ -137,11 +137,12 @@ wcstombs(s, pwcs, n)
|
||||
*s = 0;
|
||||
break;
|
||||
}
|
||||
if (!sputrune(*pwcs++, s, (int)n, &e))
|
||||
if (!sputrune(*pwcs++, s, n, &e))
|
||||
return (-1); /* encoding error */
|
||||
if (!e) /* too long */
|
||||
return (cnt);
|
||||
cnt += e - s;
|
||||
n -= e - s;
|
||||
s = e;
|
||||
}
|
||||
return (cnt);
|
||||
|
Loading…
Reference in New Issue
Block a user