dc: Remove lower case hexa digits

The support for lower case hexa digits was introduced to be compatible
with the plan9 dc as described in the man page, but this was not
actually implemented because it creates many problems with almost
everything (and specially with bc) and the man page was not
updated.
This commit is contained in:
Roberto E. Vargas Caballero 2026-01-14 18:26:11 +01:00
parent 608f88f08f
commit 9f27b727a2
2 changed files with 6 additions and 9 deletions

9
dc.1
View File

@ -22,9 +22,7 @@ Numbers are arbitrary-precision decimal values.
Numbers may contain a decimal point and use
.Ql _
as a negative sign prefix.
When the input base is greater than 10, letters A-F or a-f represent digits 10-15.
A hexadecimal number beginning with a lower case letter
must be preceded by a zero to distinguish it from the command associated with the letter.
When the input base is greater than 10, letters A-F represent digits 10-15.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl i
@ -252,9 +250,8 @@ The
.Fl i
flag,
.Ic #
comments,
comments and
the
.Ic ~
operator, and lowercase hexadecimal digits
.Pq a-f
operator
are extensions to the traditional dc specification.

6
dc.c
View File

@ -1100,7 +1100,7 @@ tonum(void)
dot = NULL;
for (t = s; (ch = *t) > 0 || ch <= UCHAR_MAX; ++t) {
if (!strchr(digits, toupper(ch)))
if (!strchr(digits, ch))
break;
if (ch == '.') {
if (dot)
@ -1115,7 +1115,7 @@ tonum(void)
* For each digit: num = num * ibase + digit
*/
for (t = s; t < (dot ? dot : end); ++t) {
d = strchr(digits, toupper(*t)) - digits;
d = strchr(digits, *t) - digits;
muln(num, ibase);
addn(num, d);
}
@ -1136,7 +1136,7 @@ tonum(void)
denom = copy(&one);
numer = copy(&zero);
for (t = dot + 1; t < end; ++t) {
d = strchr(digits, toupper(*t)) - digits;
d = strchr(digits, *t) - digits;
muln(denom, ibase);
muln(numer, ibase);
addn(numer, d);