diff options
author | tjr <tjr@FreeBSD.org> | 2004-07-09 15:12:10 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2004-07-09 15:12:10 +0000 |
commit | e224905046c4623318e94424834fcfbc63f106bd (patch) | |
tree | b485d5062b856a17856503cf3ae613a48e0373ba | |
parent | 2210d0e6071bcbdbbfe8bed564cd4e0ce7d285b9 (diff) | |
download | FreeBSD-src-e224905046c4623318e94424834fcfbc63f106bd.zip FreeBSD-src-e224905046c4623318e94424834fcfbc63f106bd.tar.gz |
Slightly reorganize and simplify.
-rw-r--r-- | lib/libc/stdio/fgetwc.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c index eb7426d..d8b10a1 100644 --- a/lib/libc/stdio/fgetwc.c +++ b/lib/libc/stdio/fgetwc.c @@ -36,28 +36,6 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" #include "local.h" -static __inline wint_t __fgetwc_nbf(FILE *); - -/* - * Non-MT-safe version. - */ -wint_t -__fgetwc(FILE *fp) -{ - wint_t wc; - - if (MB_CUR_MAX == 1) { - /* - * Assume we're using a single-byte locale. A safer test - * might be to check _CurrentRuneLocale->encoding. - */ - wc = (wint_t)__sgetc(fp); - } else - wc = __fgetwc_nbf(fp); - - return (wc); -} - /* * MT-safe version. */ @@ -74,14 +52,23 @@ fgetwc(FILE *fp) return (r); } -static __inline wint_t -__fgetwc_nbf(FILE *fp) +/* + * Non-MT-safe version. + */ +wint_t +__fgetwc(FILE *fp) { wchar_t wc; size_t nconv; if (fp->_r <= 0 && __srefill(fp)) return (WEOF); + if (MB_CUR_MAX == 1) { + /* Fast path for single-byte encodings. */ + wc = *fp->_p++; + fp->_r--; + return (wc); + } do { nconv = mbrtowc(&wc, fp->_p, fp->_r, &fp->_extra->mbstate); if (nconv == (size_t)-1) |