diff options
author | Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2004-08-07 05:14:56 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-08-07 05:14:56 -0700 |
commit | dc4d629f8c94848e15a618f6d9d0e8778cd319ff (patch) | |
tree | 0da297ec4176ce508948716a428e97ad636352c9 /lib | |
parent | 6244f13c51282d9f6203243b652839dff24b762f (diff) | |
download | history-dc4d629f8c94848e15a618f6d9d0e8778cd319ff.tar.gz |
[PATCH] Teach sscanf about 'hh' and 'll'
Adds support for 'hh' (store number in char *) and 'll' (proper C99 for
long long) modifiers to sscanf().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b1f5c9deede5f3..0b0935915066aa 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -668,8 +668,16 @@ int vsscanf(const char * buf, const char * fmt, va_list args) qualifier = -1; if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'Z' || *fmt == 'z') { - qualifier = *fmt; - fmt++; + qualifier = *fmt++; + if (unlikely(qualifier == *fmt)) { + if (qualifier == 'h') { + qualifier = 'H'; + fmt++; + } else if (qualifier == 'l') { + qualifier = 'L'; + fmt++; + } + } } base = 10; is_sign = 0; @@ -754,6 +762,15 @@ int vsscanf(const char * buf, const char * fmt, va_list args) break; switch(qualifier) { + case 'H': /* that's 'hh' in format */ + if (is_sign) { + signed char *s = (signed char *) va_arg(args,signed char *); + *s = (signed char) simple_strtol(str,&next,base); + } else { + unsigned char *s = (unsigned char *) va_arg(args, unsigned char *); + *s = (unsigned char) simple_strtoul(str, &next, base); + } + break; case 'h': if (is_sign) { short *s = (short *) va_arg(args,short *); |