From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1DksBn-0007GY-Nv for mharc-grub-devel@gnu.org; Tue, 21 Jun 2005 19:29:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DksBc-0007EA-FR for grub-devel@gnu.org; Tue, 21 Jun 2005 19:29:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DksBY-0007CL-Dq for grub-devel@gnu.org; Tue, 21 Jun 2005 19:29:42 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DksBX-00079g-KG for grub-devel@gnu.org; Tue, 21 Jun 2005 19:29:39 -0400 Received: from [207.69.195.71] (helo=pop-siberian.atl.sa.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Dks7e-0007dP-Jo for grub-devel@gnu.org; Tue, 21 Jun 2005 19:25:38 -0400 Received: from user-0vvde2g.cable.mindspring.com ([63.246.184.80] helo=miracle) by pop-siberian.atl.sa.earthlink.net with esmtp (Exim 3.36 #10) id 1Dks4h-00031a-00 for grub-devel@gnu.org; Tue, 21 Jun 2005 19:22:35 -0400 Received: from hollis by miracle with local (Exim 3.36 #1 (Debian)) id 1DkrwY-0006or-00 for ; Tue, 21 Jun 2005 18:14:10 -0500 Date: Tue, 21 Jun 2005 18:14:10 -0500 To: grub-devel@gnu.org Message-ID: <20050621231410.GA26213@miracle> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040907i From: Hollis Blanchard Subject: [patch] printf long format X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2005 23:29:47 -0000 Hmm, no idea what happened to the first mail. Debugging a partition map bug, I was adding more grub_dprintf messages... and re-discovered that our printf doesn't handle e.g. "%lx" format strings (yet gcc requires these when printing longs). This patch works for me, though I didn't check that it implements all "l" formating according to POSIX or SUS or whatever. Has not been tested on 64-bit platforms. Comments? -Hollis * kern/misc.c (grub_vsprintf): Add `longfmt'. If format string contains `l' modifier, get a long from va_arg(). Index: kern/misc.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/misc.c,v retrieving revision 1.19 diff -u -p -r1.19 misc.c --- kern/misc.c 9 May 2005 01:47:37 -0000 1.19 +++ kern/misc.c 21 Jun 2005 04:02:35 -0000 @@ -562,13 +562,14 @@ grub_vsprintf (char *str, const char *fm char zerofill = ' '; int rightfill = 0; int n; - + int longfmt = 0; + if (*fmt && *fmt =='-') { rightfill = 1; fmt++; } - + p = (char *) fmt; /* Read formatting parameters. */ while (*p && grub_isdigit (*p)) @@ -600,6 +601,11 @@ grub_vsprintf (char *str, const char *fm } c = *fmt++; + if (c == 'l') + { + longfmt = 1; + c = *fmt++; + } switch (c) { @@ -610,7 +616,10 @@ grub_vsprintf (char *str, const char *fm case 'x': case 'u': case 'd': - n = va_arg (args, int); + if (longfmt) + n = va_arg (args, long); + else + n = va_arg (args, int); grub_itoa (tmp, c, n); if (!rightfill && grub_strlen (tmp) < format1) write_fill (zerofill, format1 - grub_strlen (tmp));