From cagney@tpgi.com.au  Sun Nov 23 22:21:21 1997
Received: from oberon.tpgi.com.au (root@oberon.tpgi.com.au [203.12.160.2])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id WAA08024
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Nov 1997 22:21:19 -0800 (PST)
          (envelope-from cagney@tpgi.com.au)
Received: from b1.tpgi.com.au (mel-ppp-093.tpgi.com.au [203.12.163.93]) by oberon.tpgi.com.au (8.7.5/8.7.3) with ESMTP id RAA17700 for <FreeBSD-gnats-submit@freebsd.org>; Mon, 24 Nov 1997 17:21:08 +1100 (EST)
Received: (from cagney@localhost) by b1.tpgi.com.au (8.8.7/8.7.3) id NAA18459; Mon, 24 Nov 1997 13:20:27 +1100 (EST)
Message-Id: <199711240220.NAA18459@b1.tpgi.com.au>
Date: Mon, 24 Nov 1997 13:20:27 +1100 (EST)
From: Andrew Cagney <cagney@tpgi.com.au>
Reply-To: cagney@tpgi.com.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: scanf accepts %Lg but treates it as %g
X-Send-Pr-Version: 3.2

>Number:         5135
>Category:       bin
>Synopsis:       scanf accepts %Lg but treates it as %g
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 23 22:30:01 PST 1997
>Closed-Date:    Mon Nov 24 08:49:18 MET 1997
>Last-Modified:  Mon Nov 24 08:50:04 MET 1997
>Originator:     Andrew Cagney
>Release:        FreeBSD 2.2.5-RELEASE i386
>Organization:
>Environment:

Vanilla 2.2.5

>Description:

Burried away in the scanf documentation is:

     L       Indicates that the conversion will be efg and the next pointer is
             a pointer to long double. (This type is not implemented; the L
             flag is currently ignored.)

to be more precise, it assigns a `%g' value (32 bit float or single)
to a `%Lg' destination (80 bit long double).  I'm sorry but doing this
is worse than stupid!

>How-To-Repeat:

One example, all GDB floating point is broken:

        $ gdb
        ...
        (gdb) print 1.0
        $1 = 0

If you trace it through, c-exp.c:parse_number calls sscanf(...%Lg...).

>Fix:
	

For FreeBSD:

o       modify scanf so that for, %Lg (long double) it parses
        it as %lg (double) then extends/stores it as a long double.

o	Remove all support for %Lg in both printf and scanf.

	Some software (eg gdb) tests printf ("%Lg") and then assumes
	scanf also works.  Consequently it is an all or nothing afair
	:-)


For GDB:

I'll see if I can get GDB changed so that its configure script
separately checks for support of %Lg in scanf and printf.


Have a nice day.

			Andrew
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Mon Nov 24 08:49:18 MET 1997 
State-Changed-Why:  

Fixed by Bruce in rev 1.12 of src/lib/libc/stdio/vfscanf.c a couple of 
days ago (also merged to 2.2-stable). 
>Unformatted:
