diff options
author | das <das@FreeBSD.org> | 2012-04-22 21:28:14 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2012-04-22 21:28:14 +0000 |
commit | 114cb5b35711a06874931458aaef95050d4f3e5d (patch) | |
tree | 3cb9e3e1475221ff0fd9273e1c40045fd33aba6f /lib | |
parent | 243d0c2d4a9b09326e5d94a24d31419db71a13d5 (diff) | |
download | FreeBSD-src-114cb5b35711a06874931458aaef95050d4f3e5d.zip FreeBSD-src-114cb5b35711a06874931458aaef95050d4f3e5d.tar.gz |
Bugfix: Correctly count the number of characters read for %l[ conversions.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index f9b7e55..6a6b19c 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -248,12 +248,12 @@ convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab) { mbstate_t mbs; wchar_t twc; - int n, nchars, nconv, nread; + int n, nchars, nconv; char buf[MB_CUR_MAX]; if (wcp == SUPPRESS_PTR) wcp = &twc; - n = nread = 0; + n = 0; nchars = 0; while (width != 0) { if (n == MB_CUR_MAX) { @@ -279,7 +279,6 @@ convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab) } break; } - nread += n; width--; if (wcp != &twc) wcp++; @@ -298,12 +297,10 @@ convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab) fp->_flags |= __SERR; return (-1); } - n = nchars; - if (n == 0) + if (nchars == 0) return (0); *wcp = L'\0'; - /* XXX This matches historical behavior, but it's wrong. */ - return (nread + n); + return (nchars); } static __inline int |