dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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