summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/sscanf.c
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2005-04-30 09:25:17 +0000
committerespie <espie@openbsd.org>2005-04-30 09:25:17 +0000
commit685aea3ce6ed0cd7feff41ab14280ea9d93c3718 (patch)
tree04651561fbab26ee3dc6f113131ba97c7e5bb1dc /lib/libc/stdio/sscanf.c
parentisw* classification functions from citrus, with a `stub' implementation (diff)
downloadwireguard-openbsd-685aea3ce6ed0cd7feff41ab14280ea9d93c3718.tar.xz
wireguard-openbsd-685aea3ce6ed0cd7feff41ab14280ea9d93c3718.zip
Change internals of FILE: reuse the unget buffer field to access an
extended attribute data structure (pimpl idiom). Idea taken from citrus. Much discussion with deraadt@, otto@, millert@... This is the least disruptive way to extend FILE, since its size can't really change without this being a flag day. So the size doesn't change. Actual additions to the structure will come in separate steps, since this change is nasty enough on its own. Tests by otto@ and others, careful reading of code by otto@ and millert@. This is definitely a major bump, and has been checked to not impact a full ports build.
Diffstat (limited to 'lib/libc/stdio/sscanf.c')
-rw-r--r--lib/libc/stdio/sscanf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c
index b529cb762a6..0104e941e03 100644
--- a/lib/libc/stdio/sscanf.c
+++ b/lib/libc/stdio/sscanf.c
@@ -31,7 +31,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: sscanf.c,v 1.8 2005/03/31 18:36:29 pat Exp $";
+static char rcsid[] = "$OpenBSD: sscanf.c,v 1.9 2005/04/30 09:25:17 espie Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -53,12 +53,14 @@ sscanf(const char *str, const char *fmt, ...)
int ret;
va_list ap;
FILE f;
+ struct __sfileext fext;
+ _FILEEXT_SETUP(&f, &fext);
f._flags = __SRD;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._r = strlen(str);
f._read = eofread;
- f._ub._base = NULL;
+ _UB(&f)._base = NULL;
f._lb._base = NULL;
va_start(ap, fmt);
ret = __svfscanf(&f, fmt, ap);