diff options
author | bde <bde@FreeBSD.org> | 1997-11-23 06:02:47 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-11-23 06:02:47 +0000 |
commit | 4037ac32c7a48bc16ba2d0eab7e580d38e305ea7 (patch) | |
tree | 95bc0df6d99a9d7509cd915eb3023b16f05ca074 /lib | |
parent | 5ea849a098d83426d6c2ec640f72a8e8e0706c72 (diff) | |
download | FreeBSD-src-4037ac32c7a48bc16ba2d0eab7e580d38e305ea7.zip FreeBSD-src-4037ac32c7a48bc16ba2d0eab7e580d38e305ea7.tar.gz |
Fixed long double formats. They were mostly not implemented except
on systems where long doubles are just doubles. FreeBSD hasn't
been such a system since it started using gcc-2.5 many years ago.
The fix is of low quality. It loses precision.
scanf() of long doubles doesn't seem to be used much, but gdb-4.16
uses %Lg format in its expression parser if it thinks that the
system supports printf'ing of long doubles. The symptom was that
floating point literals were usually interpreted to be 0.0.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index 0df3720..ba4be5c 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: vfscanf.c,v 1.10 1997/04/04 19:07:02 ache Exp $"; + "$Id: vfscanf.c,v 1.11 1997/07/01 17:46:39 jkh Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -64,7 +64,7 @@ static const char rcsid[] = * Flags used during conversion. */ #define LONG 0x01 /* l: long or double */ -#define LONGDBL 0x02 /* L: long double; unimplemented */ +#define LONGDBL 0x02 /* L: long double */ #define SHORT 0x04 /* h: short */ #define SUPPRESS 0x08 /* suppress assignment */ #define POINTER 0x10 /* weird %p pointer (`fake hex') */ @@ -655,8 +655,11 @@ literal: double res; *p = 0; - res = strtod(buf,(char **) NULL); - if (flags & LONG) + /* XXX this loses precision for long doubles. */ + res = strtod(buf, (char **) NULL); + if (flags & LONGDBL) + *va_arg(ap, long double *) = res; + else if (flags & LONG) *va_arg(ap, double *) = res; else *va_arg(ap, float *) = res; |