bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Support for uppercase hex conversions


From: R. Masters
Subject: Support for uppercase hex conversions
Date: Tue, 31 Jan 2023 08:22:49 -0800

Uppercase hex number conversions fail for abtol, strtol, strtoul, strtoull, atoi, and abtod.

The following patch fixes it. This fix allows tcc to handle assembly language, which is necessary to build the Fiwix kernel as part of the kernel bootstrapping in progress for the live-bootstrap project.

diff --git a/lib/ctype/isxdigit.c b/lib/ctype/isxdigit.c
index 13f7a66d..b15546e2 100644
--- a/lib/ctype/isxdigit.c
+++ b/lib/ctype/isxdigit.c
@@ -24,5 +24,5 @@
 int
 isxdigit (int c)
 {
-  return isdigit (c) || (c >= 'a' && c <= 'f');
+  return isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
 }
diff --git a/lib/mes/abtol.c b/lib/mes/abtol.c
index 0fafb5c1..37889070 100644
--- a/lib/mes/abtol.c
+++ b/lib/mes/abtol.c
@@ -43,10 +43,15 @@ abtol (char const **p, int base)
   while (isnumber (s[0], base) != 0)
     {
       i = i * base;
-      if (s[0] > '9')
+      if (s[0] >= 'a')
         m = 'a' - 10;
       else
-        m = '0';
+        {
+          if (s[0] >= 'A')
+            m = 'A' - 10;
+          else
+            m = '0';
+        }
       i = i + s[0] - m;
       s = s + 1;
     }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]