5dc55b7
From 57d2bab2505883efe87bab31a80c42984671e4ac Mon Sep 17 00:00:00 2001
481bf3b
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
481bf3b
Date: Tue, 27 Nov 2012 16:58:39 -0200
5dc55b7
Subject: [PATCH 11/34] Add %X option to printf functions.
481bf3b
481bf3b
---
481bf3b
 grub-core/kern/misc.c | 7 +++++--
481bf3b
 1 file changed, 5 insertions(+), 2 deletions(-)
481bf3b
481bf3b
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
481bf3b
index 54db2e1..50f7f53 100644
481bf3b
--- a/grub-core/kern/misc.c
481bf3b
+++ b/grub-core/kern/misc.c
481bf3b
@@ -759,7 +759,7 @@ __umoddi3 (grub_uint64_t a, grub_uint64_t b)
481bf3b
 static inline char *
481bf3b
 grub_lltoa (char *str, int c, unsigned long long n)
481bf3b
 {
481bf3b
-  unsigned base = (c == 'x') ? 16 : 10;
481bf3b
+  unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10;
481bf3b
   char *p;
481bf3b
 
481bf3b
   if ((long long) n < 0 && c == 'd')
481bf3b
@@ -774,7 +774,7 @@ grub_lltoa (char *str, int c, unsigned long long n)
481bf3b
     do
481bf3b
       {
481bf3b
 	unsigned d = (unsigned) (n & 0xf);
481bf3b
-	*p++ = (d > 9) ? d + 'a' - 10 : d + '0';
481bf3b
+	*p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0';
481bf3b
       }
481bf3b
     while (n >>= 4);
481bf3b
   else
481bf3b
@@ -847,6 +847,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
481bf3b
 	{
481bf3b
 	case 'p':
481bf3b
 	case 'x':
481bf3b
+	case 'X':
481bf3b
 	case 'u':
481bf3b
 	case 'd':
481bf3b
 	case 'c':
481bf3b
@@ -927,6 +928,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
481bf3b
       switch (c)
481bf3b
 	{
481bf3b
 	case 'x':
481bf3b
+	case 'X':
481bf3b
 	case 'u':
481bf3b
 	  args->ptr[curn].type = UNSIGNED_INT + longfmt;
481bf3b
 	  break;
481bf3b
@@ -1064,6 +1066,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
481bf3b
 	  c = 'x';
481bf3b
 	  /* Fall through. */
481bf3b
 	case 'x':
481bf3b
+	case 'X':
481bf3b
 	case 'u':
481bf3b
 	case 'd':
481bf3b
 	  {
481bf3b
-- 
481bf3b
1.8.4.2
481bf3b