lib: Support uppercase hex conversions.

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

The following patch fixes it.  This 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.

* lib/ctype/isxdigit.c (isxdigit): Also allow A-F.
* lib/mes/abtol.c (abtol): Also cater for A-F.
This commit is contained in:
R. Masters 2023-01-31 08:22:49 -08:00 committed by Jan (janneke) Nieuwenhuizen
parent 1e14c26305
commit b28f42de07
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
3 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2023 Rick Masters <grick23@gmail.com>
*
* This file is part of GNU Mes.
*

View file

@ -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');
}

View file

@ -1,7 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2022 Rick Masters <grick23@gmail.com>
* Copyright © 2022,2023 Rick Masters <grick23@gmail.com>
*
* This file is part of GNU Mes.
*
@ -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
{
if (s[0] >= 'A')
m = 'A' - 10;
else
m = '0';
}
i = i + s[0] - m;
s = s + 1;
}