diff options
author | tjr <tjr@FreeBSD.org> | 2002-09-22 05:59:00 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-09-22 05:59:00 +0000 |
commit | 66942d16196a10965c08f1bdfdea67bba8134550 (patch) | |
tree | 76b047271cf56936a6775126e3139bfdd2df1cab | |
parent | e54737666a584849daea897dbaf548d7ea1b8233 (diff) | |
download | FreeBSD-src-66942d16196a10965c08f1bdfdea67bba8134550.zip FreeBSD-src-66942d16196a10965c08f1bdfdea67bba8134550.tar.gz |
Add an unlocked version of ungetwc(), __ungetwc(), that __vfwscanf()
will need to use.
-rw-r--r-- | lib/libc/stdio/local.h | 1 | ||||
-rw-r--r-- | lib/libc/stdio/ungetwc.c | 30 |
2 files changed, 22 insertions, 9 deletions
diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index 309cc9c..290040b 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -71,6 +71,7 @@ extern int _fwalk(int (*)(FILE *)); extern int __swsetup(FILE *); extern int __sflags(const char *, int *); extern int __ungetc(int, FILE *); +extern wint_t __ungetwc(wchar_t, FILE *); extern int __vfprintf(FILE *, const char *, __va_list); extern int __vfwprintf(FILE *, const wchar_t *, __va_list); diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c index 7602718..5eeb8b1 100644 --- a/lib/libc/stdio/ungetwc.c +++ b/lib/libc/stdio/ungetwc.c @@ -36,28 +36,40 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" #include "local.h" +/* + * Non-MT-safe version. + */ wint_t -ungetwc(wint_t wc, FILE *fp) +__ungetwc(wint_t wc, FILE *fp) { char buf[MB_LEN_MAX]; mbstate_t mbs; size_t len; - FLOCKFILE(fp); - ORIENT(fp, 1); if (wc == WEOF) - goto error; + return (WEOF); memset(&mbs, 0, sizeof(mbs)); if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) - goto error; + return (WEOF); while (len-- != 0) if (__ungetc((unsigned char)buf[len], fp) == EOF) - goto error; - FUNLOCKFILE(fp); + return (WEOF); return (wc); +} + +/* + * MT-safe version. + */ +wint_t +ungetwc(wint_t wc, FILE *fp) +{ + wint_t r; -error: + FLOCKFILE(fp); + ORIENT(fp, 1); + r = __ungetwc(wc, fp); FUNLOCKFILE(fp); - return (WEOF); + + return (r); } |