diff options
author | 2005-12-19 19:39:25 +0000 | |
---|---|---|
committer | 2005-12-19 19:39:25 +0000 | |
commit | ce2cbcd92a85adaeae5ffca2a22b5b8292b224b5 (patch) | |
tree | 18f6a65b72c54efff147f73400202a378acfbbb4 /lib/libc/stdio/vfscanf.c | |
parent | First attempt to have a table of known I2C slave devices that we (diff) | |
download | wireguard-openbsd-ce2cbcd92a85adaeae5ffca2a22b5b8292b224b5.tar.xz wireguard-openbsd-ce2cbcd92a85adaeae5ffca2a22b5b8292b224b5.zip |
Add %hhd to *printf and *scanf as well as %z to *scanf. This was
sent out and approved about 6 months ago and has been rotting in
my tree ever since.
Diffstat (limited to 'lib/libc/stdio/vfscanf.c')
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 0546c5c5145..b319271aecf 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfscanf.c,v 1.15 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: vfscanf.c,v 1.16 2005/12/19 19:39:25 millert Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -46,13 +46,15 @@ /* * Flags used during conversion. */ -#define LONG 0x01 /* l: long or double */ -#define LONGDBL 0x02 /* L: long double; unimplemented */ -#define SHORT 0x04 /* h: short */ -#define QUAD 0x08 /* q: quad */ -#define SUPPRESS 0x10 /* suppress assignment */ -#define POINTER 0x20 /* weird %p pointer (`fake hex') */ -#define NOSKIP 0x40 /* do not skip blanks */ +#define LONG 0x0001 /* l: long or double */ +#define LONGDBL 0x0002 /* L: long double; unimplemented */ +#define SHORT 0x0004 /* h: short */ +#define QUAD 0x0008 /* q: quad */ +#define SUPPRESS 0x0010 /* suppress assignment */ +#define POINTER 0x0020 /* weird %p pointer (`fake hex') */ +#define NOSKIP 0x0040 /* do not skip blanks */ +#define SHORTSHORT 0x0080 /* hh: 8 bit integer */ +#define SIZEINT 0x0100 /* z: (signed) size_t */ /* * The following are used in numeric conversions only: @@ -153,7 +155,12 @@ literal: flags |= LONGDBL; goto again; case 'h': - flags |= SHORT; + if (*fmt == 'h') { + fmt++; + flags |= SHORTSHORT; + } else { + flags |= SHORT; + } goto again; case 'l': if (*fmt == 'l') { @@ -166,6 +173,9 @@ literal: case 'q': flags |= QUAD; goto again; + case 'z': + flags |= SIZEINT; + goto again; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -252,10 +262,16 @@ literal: case 'n': if (flags & SUPPRESS) /* ??? */ continue; - if (flags & SHORT) + if (flags & SHORTSHORT) + *va_arg(ap, __signed char *) = nread; + else if (flags & SHORT) *va_arg(ap, short *) = nread; else if (flags & LONG) *va_arg(ap, long *) = nread; + else if (flags & QUAD) + *va_arg(ap, quad_t *) = nread; + else if (flags & SIZEINT) + *va_arg(ap, ssize_t *) = nread; else *va_arg(ap, int *) = nread; continue; @@ -537,12 +553,16 @@ literal: if (flags & POINTER) *va_arg(ap, void **) = (void *)(long)res; + else if (flags & SIZEINT) + *va_arg(ap, ssize_t *) = res; else if (flags & QUAD) *va_arg(ap, quad_t *) = res; else if (flags & LONG) *va_arg(ap, long *) = res; else if (flags & SHORT) *va_arg(ap, short *) = res; + else if (flags & SHORTSHORT) + *va_arg(ap, __signed char *) = res; else *va_arg(ap, int *) = res; nassigned++; |