summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ungetwc.c
diff options
context:
space:
mode:
authorstsp <stsp@openbsd.org>2011-10-16 13:20:51 +0000
committerstsp <stsp@openbsd.org>2011-10-16 13:20:51 +0000
commit2d31a56b68087b9e21ffea3c52867eaab57593ae (patch)
tree7a4b16fe3cbf8188c25fe2433f23dbf409091dcf /lib/libc/stdio/ungetwc.c
parentRemove a bunch of useless assignments, (diff)
downloadwireguard-openbsd-2d31a56b68087b9e21ffea3c52867eaab57593ae.tar.xz
wireguard-openbsd-2d31a56b68087b9e21ffea3c52867eaab57593ae.zip
Add wscanf(3) and friends. Based on our scanf(3) implementation, with wide
character support changes based on code from FreeBSD. ok espie guenther; man page help from schwarze
Diffstat (limited to 'lib/libc/stdio/ungetwc.c')
-rw-r--r--lib/libc/stdio/ungetwc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c
index 60bee069f52..c0321e9e1e5 100644
--- a/lib/libc/stdio/ungetwc.c
+++ b/lib/libc/stdio/ungetwc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ungetwc.c,v 1.4 2009/11/09 00:18:27 kurt Exp $ */
+/* $OpenBSD: ungetwc.c,v 1.5 2011/10/16 13:20:51 stsp Exp $ */
/* $NetBSD: ungetwc.c,v 1.2 2003/01/18 11:29:59 thorpej Exp $ */
/*-
@@ -35,14 +35,13 @@
#include "local.h"
wint_t
-ungetwc(wint_t wc, FILE *fp)
+__ungetwc(wint_t wc, FILE *fp)
{
struct wchar_io_data *wcio;
if (wc == WEOF)
return WEOF;
- FLOCKFILE(fp);
_SET_ORIENTATION(fp, 1);
/*
* XXX since we have no way to transform a wchar string to
@@ -52,19 +51,27 @@ ungetwc(wint_t wc, FILE *fp)
wcio = WCIO_GET(fp);
if (wcio == 0) {
- FUNLOCKFILE(fp);
errno = ENOMEM; /* XXX */
return WEOF;
}
if (wcio->wcio_ungetwc_inbuf >= WCIO_UNGETWC_BUFSIZE) {
- FUNLOCKFILE(fp);
return WEOF;
}
wcio->wcio_ungetwc_buf[wcio->wcio_ungetwc_inbuf++] = wc;
__sclearerr(fp);
- FUNLOCKFILE(fp);
return wc;
}
+
+wint_t
+ungetwc(wint_t wc, FILE *fp)
+{
+ wint_t r;
+
+ FLOCKFILE(fp);
+ r = __ungetwc(wc, fp);
+ FUNLOCKFILE(fp);
+ return (r);
+}