diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-09-22 05:59:00 +0000 |
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-09-22 05:59:00 +0000 |
| commit | 5f147b57ac73adde1143d270aae670782b431d38 (patch) | |
| tree | 76b047271cf56936a6775126e3139bfdd2df1cab /lib/libc | |
| parent | e3b6e33c07b11798e5e24baaa7d596902debdcba (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -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 309cc9c06e88..290040b238b2 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 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); } |
