dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0098-Add-X-option-to-printf-functions.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
f725e3
Date: Tue, 27 Nov 2012 16:58:39 -0200
f725e3
Subject: [PATCH] Add %X option to printf functions.
f725e3
f725e3
---
f725e3
 grub-core/kern/misc.c | 7 +++++--
f725e3
 1 file changed, 5 insertions(+), 2 deletions(-)
f725e3
f725e3
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
f725e3
index c5c815d8d13..a56cfe78994 100644
f725e3
--- a/grub-core/kern/misc.c
f725e3
+++ b/grub-core/kern/misc.c
f725e3
@@ -762,7 +762,7 @@ __umoddi3 (grub_uint64_t a, grub_uint64_t b)
f725e3
 static inline char *
f725e3
 grub_lltoa (char *str, int c, unsigned long long n)
f725e3
 {
f725e3
-  unsigned base = (c == 'x') ? 16 : 10;
f725e3
+  unsigned base = ((c == 'x') || (c == 'X')) ? 16 : 10;
f725e3
   char *p;
f725e3
 
f725e3
   if ((long long) n < 0 && c == 'd')
f725e3
@@ -777,7 +777,7 @@ grub_lltoa (char *str, int c, unsigned long long n)
f725e3
     do
f725e3
       {
f725e3
 	unsigned d = (unsigned) (n & 0xf);
f725e3
-	*p++ = (d > 9) ? d + 'a' - 10 : d + '0';
f725e3
+	*p++ = (d > 9) ? d + ((c == 'x') ? 'a' : 'A') - 10 : d + '0';
f725e3
       }
f725e3
     while (n >>= 4);
f725e3
   else
f725e3
@@ -850,6 +850,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
f725e3
 	{
f725e3
 	case 'p':
f725e3
 	case 'x':
f725e3
+	case 'X':
f725e3
 	case 'u':
f725e3
 	case 'd':
f725e3
 	case 'c':
f725e3
@@ -930,6 +931,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
f725e3
       switch (c)
f725e3
 	{
f725e3
 	case 'x':
f725e3
+	case 'X':
f725e3
 	case 'u':
f725e3
 	  args->ptr[curn].type = UNSIGNED_INT + longfmt;
f725e3
 	  break;
f725e3
@@ -1067,6 +1069,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
f725e3
 	  c = 'x';
f725e3
 	  /* Fall through. */
f725e3
 	case 'x':
f725e3
+	case 'X':
f725e3
 	case 'u':
f725e3
 	case 'd':
f725e3
 	  {