dc: Remove lower case hexa digits - sbase - suckless unix tools
HTML git clone git://git.suckless.org/sbase
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 9f27b727a20b65145b872cad55205460a31b4f96
DIR parent 608f88f08fcb049f30a1963f2bc72e429a63ba42
HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Wed, 14 Jan 2026 18:26:11 +0100
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.
Diffstat:
M dc.1 | 9 +++------
M dc.c | 6 +++---
2 files changed, 6 insertions(+), 9 deletions(-)
---
DIR diff --git a/dc.1 b/dc.1
@@ -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.
DIR diff --git a/dc.c b/dc.c
@@ -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);