diff options
| author | cvs2svn <cvs2svn@FreeBSD.org> | 1999-01-21 00:55:32 +0000 |
|---|---|---|
| committer | cvs2svn <cvs2svn@FreeBSD.org> | 1999-01-21 00:55:32 +0000 |
| commit | 76b5366091f76c9bc73570149ef5055648fc2c39 (patch) | |
| tree | 590d020e0f2a5bea6e09d66d951a674443b21d67 /lib/libc/locale/ansi.c | |
| parent | 4b4d01da6f07f7754ff6a6e4f5223e9f0984d1a6 (diff) | |
Diffstat (limited to 'lib/libc/locale/ansi.c')
| -rw-r--r-- | lib/libc/locale/ansi.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/libc/locale/ansi.c b/lib/libc/locale/ansi.c index c0871fea6daca..a5a3362d8adf1 100644 --- a/lib/libc/locale/ansi.c +++ b/lib/libc/locale/ansi.c @@ -127,24 +127,22 @@ wcstombs(s, pwcs, n) size_t n; { char *e; - int cnt, nb; + int cnt = 0; - if (!pwcs || !s || n > INT_MAX) + if (!pwcs || !s) return (-1); - nb = n; - cnt = 0; - while (nb > 0) { + while (n > 0) { if (*pwcs == 0) { *s = 0; break; } - if (!sputrune(*pwcs++, s, nb, &e)) + if (!sputrune(*pwcs++, s, n, &e)) return (-1); /* encoding error */ if (!e) /* too long */ return (cnt); cnt += e - s; - nb -= e - s; + n -= e - s; s = e; } return (cnt); |
