[U-Boot] PATCH-add "0X" hexadecimal prefix to simple_strtoul

Rob Alexander w04893 at motorola.com
Tue Feb 8 17:38:05 CET 2011


Added support to simple_strtoul to support the standard 0X hex notation. This issue
was causing operational bug in U-boot console commands where "0X" hex numbers were being
misinterpreted as decimal.

Signed-off-by: Rob Alexander<robert.b.alexander at motorola.com>
--- vsprintf.org.c	2011-02-08 10:12:35.954644500 -0600
+++ vsprintf.c	2011-02-08 10:26:01.708224300 -0600
@@ -41,8 +41,9 @@
  	unsigned long result = 0,value;

  	if (*cp == '0') {
-		cp++;
-		if ((*cp == 'x')&&  isxdigit(cp[1])) {
+		cp++;
+		//support both 0X and 0x notation
+		if ((tolower(*cp) == 'x')&&  isxdigit(cp[1])) {
  			base = 16;
  			cp++;
  		}
@@ -99,7 +100,8 @@

  	if (*cp == '0') {
  		cp++;
-		if ((*cp == 'x')&&  isxdigit (cp[1])) {
+    //support both 0X and 0x notation
+		if ((tolower(*cp) == 'x')&&  isxdigit(cp[1]))
  			base = 16;
  			cp++;
  		}




More information about the U-Boot mailing list