From owner-freebsd-arch Wed Jun 27 3:58:44 2001 Delivered-To: freebsd-arch@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.13]) by hub.freebsd.org (Postfix) with SMTP id 16C6137B405 for ; Wed, 27 Jun 2001 03:58:38 -0700 (PDT) (envelope-from roam@orbitel.bg) Received: (qmail 23242 invoked by uid 1000); 27 Jun 2001 11:03:22 -0000 Date: Wed, 27 Jun 2001 14:03:22 +0300 From: Peter Pentchev 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> Mail-Followup-To: arch@FreeBSD.org, audit@FreeBSD.org, freebsd-standards@bostonradio.org References: <20010623151310.A497@ringworld.oblivion.bg> <20010623160748.C497@ringworld.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010623160748.C497@ringworld.oblivion.bg>; from roam@orbitel.bg on Sat, Jun 23, 2001 at 04:07:48PM +0300 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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