diff options
author | tjr <tjr@FreeBSD.org> | 2003-11-05 08:20:45 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2003-11-05 08:20:45 +0000 |
commit | 736d21ee30829ad50145dc4f69a99891c824c68f (patch) | |
tree | c35ab994daf990dee6de564c4d51c99e38cf895a | |
parent | 34fe8a239a2d7322d283dd54a19e4319cd74244f (diff) | |
download | FreeBSD-src-736d21ee30829ad50145dc4f69a99891c824c68f.zip FreeBSD-src-736d21ee30829ad50145dc4f69a99891c824c68f.tar.gz |
Pass NULL instead of a pointer to a zeroed mbstate_t object.
-rw-r--r-- | lib/libc/stdio/vfprintf.c | 13 | ||||
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 10 | ||||
-rw-r--r-- | lib/libc/stdio/vfwprintf.c | 7 | ||||
-rw-r--r-- | lib/libc/stdio/vfwscanf.c | 16 | ||||
-rw-r--r-- | lib/libc/stdio/vswprintf.c | 4 | ||||
-rw-r--r-- | lib/libc/stdio/vswscanf.c | 4 |
6 files changed, 17 insertions, 37 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index 6125db3..19ce151 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -345,18 +345,16 @@ __wcsconv(wchar_t *wcsarg, int prec) wchar_t *p; char *convbuf, *mbp; size_t clen, nbytes; - mbstate_t mbs; /* * Determine the number of bytes to output and allocate space for * the output. */ - memset(&mbs, 0, sizeof(mbs)); if (prec >= 0) { nbytes = 0; p = wcsarg; for (;;) { - clen = wcrtomb(buf, *p++, &mbs); + clen = wcrtomb(buf, *p++, NULL); if (clen == 0 || clen == (size_t)-1 || nbytes + clen > prec) break; @@ -364,7 +362,7 @@ __wcsconv(wchar_t *wcsarg, int prec) } } else { p = wcsarg; - nbytes = wcsrtombs(NULL, (const wchar_t **)&p, 0, &mbs); + nbytes = wcsrtombs(NULL, (const wchar_t **)&p, 0, NULL); if (nbytes == (size_t)-1) return (NULL); } @@ -377,9 +375,8 @@ __wcsconv(wchar_t *wcsarg, int prec) */ mbp = convbuf; p = wcsarg; - memset(&mbs, 0, sizeof(mbs)); while (mbp - convbuf < nbytes) { - clen = wcrtomb(mbp, *p++, &mbs); + clen = wcrtomb(mbp, *p++, NULL); if (clen == 0 || clen == (size_t)-1) break; mbp += clen; @@ -795,12 +792,10 @@ reswitch: switch (ch) { /*FALLTHROUGH*/ case 'c': if (flags & LONGINT) { - mbstate_t mbs; size_t mbseqlen; - memset(&mbs, 0, sizeof(mbs)); mbseqlen = wcrtomb(cp = buf, - (wchar_t)GETARG(wint_t), &mbs); + (wchar_t)GETARG(wint_t), NULL); if (mbseqlen == (size_t)-1) { fp->_flags |= __SERR; goto error; diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index b6f7571..41bb822 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -140,7 +140,6 @@ __svfscanf(FILE *fp, const char *fmt0, va_list ap) char buf[BUF]; /* buffer for numeric and mb conversions */ wchar_t *wcp; /* handy wide character pointer */ wchar_t *wcp0; /* saves original value of wcp */ - mbstate_t mbs; /* multibyte conversion state */ size_t nconv; /* length of multibyte sequence converted */ /* `basefix' is used to avoid `if' tests in the integer scanner */ @@ -367,8 +366,7 @@ literal: buf[n++] = *fp->_p; fp->_p++; fp->_r--; - memset(&mbs, 0, sizeof(mbs)); - nconv = mbrtowc(wcp, buf, n, &mbs); + nconv = mbrtowc(wcp, buf, n, NULL); if (nconv == (size_t)-1) { fp->_flags |= __SERR; goto input_failure; @@ -447,8 +445,7 @@ literal: buf[n++] = *fp->_p; fp->_p++; fp->_r--; - memset(&mbs, 0, sizeof(mbs)); - nconv = mbrtowc(wcp, buf, n, &mbs); + nconv = mbrtowc(wcp, buf, n, NULL); if (nconv == (size_t)-1) { fp->_flags |= __SERR; goto input_failure; @@ -548,8 +545,7 @@ literal: buf[n++] = *fp->_p; fp->_p++; fp->_r--; - memset(&mbs, 0, sizeof(mbs)); - nconv = mbrtowc(wcp, buf, n, &mbs); + nconv = mbrtowc(wcp, buf, n, NULL); if (nconv == (size_t)-1) { fp->_flags |= __SERR; goto input_failure; diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index 3c2392b..3be9365 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -328,7 +328,6 @@ __mbsconv(char *mbsarg, int prec) wchar_t *convbuf, *wcp; const char *p; size_t insize, nchars, nconv; - mbstate_t mbs; if (mbsarg == NULL) return (NULL); @@ -342,11 +341,10 @@ __mbsconv(char *mbsarg, int prec) * String is not guaranteed to be NUL-terminated. Find the * number of characters to print. */ - memset(&mbs, 0, sizeof(mbs)); p = mbsarg; insize = nchars = 0; while (nchars != (size_t)prec) { - nconv = mbrlen(p, MB_CUR_MAX, &mbs); + nconv = mbrlen(p, MB_CUR_MAX, NULL); if (nconv == 0 || nconv == (size_t)-1 || nconv == (size_t)-2) break; @@ -369,9 +367,8 @@ __mbsconv(char *mbsarg, int prec) return (NULL); wcp = convbuf; p = mbsarg; - memset(&mbs, 0, sizeof(mbs)); while (insize != 0) { - nconv = mbrtowc(wcp, p, insize, &mbs); + nconv = mbrtowc(wcp, p, insize, NULL); if (nconv == 0 || nconv == (size_t)-1 || nconv == (size_t)-2) break; wcp++; diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c index 990555c..4d02810 100644 --- a/lib/libc/stdio/vfwscanf.c +++ b/lib/libc/stdio/vfwscanf.c @@ -146,7 +146,6 @@ __vfwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, va_list ap) wint_t wi; /* handy wint_t */ char *mbp; /* multibyte string pointer for %c %s %[ */ size_t nconv; /* number of bytes in mb. conversion */ - mbstate_t mbs; /* multibyte state */ char mbbuf[MB_LEN_MAX]; /* temporary mb. character buffer */ /* `basefix' is used to avoid `if' tests in the integer scanner */ @@ -379,17 +378,16 @@ literal: if (!(flags & SUPPRESS)) mbp = va_arg(ap, char *); n = 0; - memset(&mbs, 0, sizeof(mbs)); while (width != 0 && (wi = __fgetwc(fp)) != WEOF) { if (width >= MB_CUR_MAX && !(flags & SUPPRESS)) { - nconv = wcrtomb(mbp, wi, &mbs); + nconv = wcrtomb(mbp, wi, NULL); if (nconv == (size_t)-1) goto input_failure; } else { nconv = wcrtomb(mbbuf, wi, - &mbs); + NULL); if (nconv == (size_t)-1) goto input_failure; if (nconv > width) { @@ -444,17 +442,16 @@ literal: if (!(flags & SUPPRESS)) mbp = va_arg(ap, char *); n = 0; - memset(&mbs, 0, sizeof(mbs)); while ((wi = __fgetwc(fp)) != WEOF && width != 0 && INCCL(wi)) { if (width >= MB_CUR_MAX && !(flags & SUPPRESS)) { - nconv = wcrtomb(mbp, wi, &mbs); + nconv = wcrtomb(mbp, wi, NULL); if (nconv == (size_t)-1) goto input_failure; } else { nconv = wcrtomb(mbbuf, wi, - &mbs); + NULL); if (nconv == (size_t)-1) goto input_failure; if (nconv > width) @@ -505,18 +502,17 @@ literal: } else { if (!(flags & SUPPRESS)) mbp = va_arg(ap, char *); - memset(&mbs, 0, sizeof(mbs)); while ((wi = __fgetwc(fp)) != WEOF && width != 0 && !iswspace(wi)) { if (width >= MB_CUR_MAX && !(flags & SUPPRESS)) { - nconv = wcrtomb(mbp, wi, &mbs); + nconv = wcrtomb(mbp, wi, NULL); if (nconv == (size_t)-1) goto input_failure; } else { nconv = wcrtomb(mbbuf, wi, - &mbs); + NULL); if (nconv == (size_t)-1) goto input_failure; if (nconv > width) diff --git a/lib/libc/stdio/vswprintf.c b/lib/libc/stdio/vswprintf.c index 44e7fc9..a9fdaf3 100644 --- a/lib/libc/stdio/vswprintf.c +++ b/lib/libc/stdio/vswprintf.c @@ -45,7 +45,6 @@ vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt, { FILE f; struct __sFILEX ext; - mbstate_t mbs; char *mbp; int ret, sverrno; @@ -73,12 +72,11 @@ vswprintf(wchar_t * __restrict s, size_t n, const wchar_t * __restrict fmt, } *f._p = '\0'; mbp = f._bf._base; - memset(&mbs, 0, sizeof(mbs)); /* * XXX Undo the conversion from wide characters to multibyte that * fputwc() did in __vfwprintf(). */ - if (mbsrtowcs(s, (const char **)&mbp, n, &mbs) == (size_t)-1) { + if (mbsrtowcs(s, (const char **)&mbp, n, NULL) == (size_t)-1) { free(f._bf._base); errno = EILSEQ; return (-1); diff --git a/lib/libc/stdio/vswscanf.c b/lib/libc/stdio/vswscanf.c index a5f0a89..128e1a4 100644 --- a/lib/libc/stdio/vswscanf.c +++ b/lib/libc/stdio/vswscanf.c @@ -65,7 +65,6 @@ vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt, va_list ap) { FILE f; - mbstate_t mbs; struct __sFILEX ext; char *mbstr; size_t mlen; @@ -77,8 +76,7 @@ vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt, */ if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL) return (EOF); - memset(&mbs, 0, sizeof(mbs)); - if ((mlen = wcsrtombs(mbstr, &str, SIZE_T_MAX, &mbs)) == (size_t)-1) { + if ((mlen = wcsrtombs(mbstr, &str, SIZE_T_MAX, NULL)) == (size_t)-1) { free(mbstr); return (EOF); } |