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.
This commit is contained in:
Bruce Evans 1997-11-23 06:02:47 +00:00
parent cb0830ae3f
commit 8fddd06099
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31359

View File

@ -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;