diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2001-03-12 10:09:06 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2001-03-12 10:09:06 +0000 |
commit | 485ed9315e18b58ba686c3eb9e8c285c549dc98a (patch) | |
tree | 3850e425f8dd469b716fd8042b6f521e86627b8f /libc/stdio/scanf.c | |
parent | ffba231886579aa74a21710e815b2025caf15e87 (diff) |
Hack long long support into scanf. For now, will fail for unsigned long longs
that are greater that long long max, but works well enough to support interface
in busybox. Just a temporary measure until scanf.c is rewritten.
Diffstat (limited to 'libc/stdio/scanf.c')
-rw-r--r-- | libc/stdio/scanf.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/libc/stdio/scanf.c b/libc/stdio/scanf.c index 5ed7f8366..9e7ccef3c 100644 --- a/libc/stdio/scanf.c +++ b/libc/stdio/scanf.c @@ -169,7 +169,11 @@ register const char *fmt; va_list ap; { +#if WANT_LONG_LONG + long long n; +#else register long n; +#endif register int c, width, lval, cnt = 0; int store, neg, base, wide1, endnull, rngflag, c2; register unsigned char *p; @@ -219,9 +223,13 @@ va_list ap; case '*': endnull = store = 0; goto fmtnxt; - case 'l': /* long data */ lval = 1; +#if WANT_LONG_LONG + if (*fmt == 'L') { /* long long data */ + lval = 2; + } +#endif goto fmtnxt; case 'h': /* short data */ lval = 0; @@ -250,8 +258,10 @@ va_list ap; case 'u': /* unsigned decimal */ numfmt:skip(); +#if 0 if (isupper(*fmt)) lval = 1; +#endif if (!base) { base = 10; @@ -300,7 +310,13 @@ va_list ap; if (store) { if (neg == 1) n = -n; - if (lval) +#if WANT_LONG_LONG + if (lval == 2) + *va_arg(ap, long long *) = n; + + else +#endif + if (lval == 1) *va_arg(ap, long *) = n; else @@ -316,9 +332,10 @@ va_list ap; case 'g': skip(); fprintf(stderr, "LIBM:SCANF"); - +#if 0 if (isupper(*fmt)) lval = 1; +#endif fstate = FS_INIT; neg = 0; |