From 5f147b57ac73adde1143d270aae670782b431d38 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Sun, 22 Sep 2002 05:59:00 +0000 Subject: Add an unlocked version of ungetwc(), __ungetwc(), that __vfwscanf() will need to use. --- lib/libc/stdio/ungetwc.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'lib/libc/stdio/ungetwc.c') diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c index 760271824158..5eeb8b10db25 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); } -- cgit v1.2.3