svn commit: r234587 - head/lib/libc/stdio
David Schultz
das at FreeBSD.org
Sun Apr 22 21:28:15 UTC 2012
Author: das
Date: Sun Apr 22 21:28:14 2012
New Revision: 234587
URL: http://svn.freebsd.org/changeset/base/234587
Log:
Bugfix: Correctly count the number of characters read for %l[ conversions.
Modified:
head/lib/libc/stdio/vfscanf.c
Modified: head/lib/libc/stdio/vfscanf.c
==============================================================================
--- head/lib/libc/stdio/vfscanf.c Sun Apr 22 21:22:14 2012 (r234586)
+++ head/lib/libc/stdio/vfscanf.c Sun Apr 22 21:28:14 2012 (r234587)
@@ -248,12 +248,12 @@ convert_wccl(FILE *fp, wchar_t *wcp, int
{
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
}
break;
}
- nread += n;
width--;
if (wcp != &twc)
wcp++;
@@ -298,12 +297,10 @@ convert_wccl(FILE *fp, wchar_t *wcp, int
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
More information about the svn-src-head
mailing list