make ord() result unsigned int; add asc() which is:

• not designed to be emitted, only used in comparisons with
  other asc() results
• on EBCDIC platforms, the mapping of an EBCDIC octet to their
  corresponding ASCII or Unicode/UCS-4 codepoint or, if there
  is no mapping, a distinct value above all valid Unicode codepoints
• on nōn-EBCDIC platforms, just the identity mapping of the input
  octet into their ord() value

Intended use are ASCII-ish character ops, including ranges (“A-Z”),
mapping from those to the corresponding digit offset, and sorting
of things in an ASCIIbetical way
This commit is contained in:
tg
2017-04-21 19:50:09 +00:00
parent 36ea8e6171
commit e18a509a80
4 changed files with 25 additions and 23 deletions

View File

@@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.341 2017/04/17 19:51:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.342 2017/04/21 19:50:07 tg Exp $");
#if HAVE_KILLPG
/*
@@ -1419,7 +1419,7 @@ c_umask(const char **wp)
if (ksh_isdigit(*cp)) {
new_umask = 0;
while (*cp >= ord('0') && *cp <= ord('7')) {
while (asc(*cp) >= asc('0') && asc(*cp) <= asc('7')) {
new_umask = new_umask * 8 + ksh_numdig(*cp);
++cp;
}