summaryrefslogtreecommitdiffstats
path: root/lib/libc/locale/ansi.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-04-18 07:01:46 +0000
committerache <ache@FreeBSD.org>1996-04-18 07:01:46 +0000
commit6d0f739b3c11e254bc25da5910233572731d453d (patch)
tree7232f293bde9f9f9cde0c55cac94e426fd34a534 /lib/libc/locale/ansi.c
parent2e949bee1224d37001f11cd0529983d607d11686 (diff)
downloadFreeBSD-src-6d0f739b3c11e254bc25da5910233572731d453d.zip
FreeBSD-src-6d0f739b3c11e254bc25da5910233572731d453d.tar.gz
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>
Diffstat (limited to 'lib/libc/locale/ansi.c')
-rw-r--r--lib/libc/locale/ansi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/locale/ansi.c b/lib/libc/locale/ansi.c
index e5c8e8f..a5a3362 100644
--- a/lib/libc/locale/ansi.c
+++ b/lib/libc/locale/ansi.c
@@ -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);
OpenPOWER on IntegriCloud