dcavalca / rpms / grub2

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