Subject: misc/3527: *printf(3) and %lld
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bgrayson@ece.utexas.edu>
List: netbsd-bugs
Date: 04/24/1997 11:09:54
>Number:         3527
>Category:       misc
>Synopsis:       printf(3) doesn't mention that %lld is equivalent to %q
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 24 09:20:01 1997
>Last-Modified:
>Originator:     Brian Grayson
>Organization:
	Parallel and Distributed Systems
	Electrical and Computer Engineering
	The University of Texas at Austin
>Release:        April 20, 1997
>Environment:
System: NetBSD marvin 1.2D NetBSD 1.2D (MARVIN) #24: Wed Apr 23 09:29:29 CDT 1997 root@data:/a/orac/home/orac/src/sys/arch/i386/compile/MARVIN i386


>Description:
	The man page for printf() and friends mentions the use of
	a single 'l' modifier, and also mentions the %q format.
	However, it does not mention that _two_ 'l's can be used
	to specify a 'long long'.  In other words, %lld is
	equivalent to %q.

	I don't know whether the use of 'll' is POSIX or ANSI or
	whatever, but it's a little more portable than %q, in my
	very-limited experience (i.e., %lld works on an
	UltraSparc around here, but %q doesn't, and neither works
	on an AIX box we have).

>How-To-Repeat:
	Look at the source code:
	  /usr/src/lib/libc/stdio/vfprintf.c, around line 369,
	  shows that if an 'l' is encountered, and if the next
	  character is also an 'l', QUADINT is set.
	
>Fix:
	Here's a patch to the man page.  Someone in-the-know
	ought to add a note about which is preferred for
	NetBSD-only source (presumably %q), and which is more
	likely to be portable (%lld?  I really don't know), etc.
--- printf.3    Thu Apr 24 10:52:13 1997
+++ printf.3.mod        Thu Apr 24 11:01:15 1997
@@ -346,6 +346,31 @@
 conversion corresponds to a pointer to a
 .Em long int
 argument.
+.Bl -hyphen
+.It
+If two consecutive
+.Cm l
+(ell) characters are used, a following 
+.Cm d ,
+.Cm i ,
+.Cm o ,
+.Cm u ,
+.Cm x ,
+or
+.Cm X
+conversion applies to a pointer to a
+.Em long long int (quad int)
+or
+.Em unsigned long long int (unsigned quad int)
+argument, or that a following
+.Cm n
+conversion corresponds to a pointer to a
+.Em long long int (quad int)
+argument.
+.\"  Which is preferred, %q or %lld?  Which is more likely to be
+.\"  portable?  Is this worth discussing here?
+.El
+
 .It
 The optional character
 .Cm q ,
>Audit-Trail:
>Unformatted: