nalika / rpms / grub2

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