Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jun 2001 14:03:22 +0300
From:      Peter Pentchev <roam@orbitel.bg>
To:        arch@FreeBSD.org
Cc:        audit@FreeBSD.org, freebsd-standards@bostonradio.org
Subject:   Re: patch for '%lld' handling in *scanf(3)
Message-ID:  <20010627140322.C19162@ringworld.oblivion.bg>
In-Reply-To: <20010623160748.C497@ringworld.oblivion.bg>; from roam@orbitel.bg on Sat, Jun 23, 2001 at 04:07:48PM %2B0300
References:  <20010623151310.A497@ringworld.oblivion.bg> <20010623160748.C497@ringworld.oblivion.bg>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Jun 23, 2001 at 04:07:48PM +0300, Peter Pentchev wrote:
> On Sat, Jun 23, 2001 at 03:13:10PM +0300, Peter Pentchev wrote:
> > Hi,
> > 
> > scanf(3) does not understand %lld for 'long long', it only understands
> > %qd, and it treats %lld as plain %ld.  printf(3) prints out %lld just fine.
> > The fix needed is just three lines of code, which have been in both NetBSD
> > and OpenBSD for some time.
> [snip]
> > The patch is attached.
> > 
> > OK, so maybe this patch is not quite semantically correct; it tends
> > to assume that 'long long' is the same as 'quad', or at least, that
> > the programmer asked for 'quad' by using %lld.  A 'real' fix would
> > be defining a LONGLONG flag for scanf().
> 
> Well, here's a patch that implements %lld the proper way :)

Somebody told me in private mail that this change should be accompanied
by an update to the scanf(3) manual page.  At a quick look at the manual
page, the 'q' modifier is documented as providing a 'long long int' value.
Thus, it seems that 'q' and 'll' should be equivalent, if 'q' is documented
as doing exactly what 'll' should do.

What to do now?  Use my first patch (with 'll' adding QUAD to the flag),
or define the new LONGLONG type?  If the latter, should 'q' retain the QUAD
type, or use the LONGLONG type?  In any case, how should the manpage
be worded (WRT both 'll' and 'q')?

FWIW, here's a chart of the current situation in the several BSD's:

	LONGLONG flag	QUAD flag	%lld type	%qd type

FreeBSD		no	no		none		quad_t
OpenBSD		no	yes		quad		quad_t
NetBSD		yes	yes		long long	quad_t

All the manpages document 'q' as producing a 'long long', and none
of the manpages mention 'll'.

G'luck,
Peter (in a state of utter confuzzlement)

-- 
No language can express every thought unambiguously, least of all this one.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010627140322.C19162>