more low-hanging fruits for EBCDIC; notes:

• ord() new, From: Daniel Richard G. <skunk@iSKUNK.ORG>
  ‣ used in some places
• (c - '0') → ksh_numdig(c)	# may take *x++ argument
• (c - 'A') → ksh_numuc(c)	# may NOT take *x+= argument
  ‣ idem for ksh_numlc(c) and 'a'
  ‣ these need changing for EBCDIC
  ‣ add testsuite for this
• use macros more, they exist already often
• use digits_lc[foo] instead of ('0' + foo), especially for letters
• caught another ksh_eq case…
• also caught a maybe-UB overflow check, but we don’t have TIME_T_MAX ☹
This commit is contained in:
tg
2015-04-29 20:07:35 +00:00
parent 3eb806b72b
commit 609b311919
10 changed files with 90 additions and 74 deletions

8
var.c
View File

@ -28,7 +28,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.191 2015/04/29 18:38:54 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.192 2015/04/29 20:07:35 tg Exp $");
/*-
* Variables
@ -553,11 +553,11 @@ getint(struct tbl *vp, mksh_ari_u *nump, bool arith)
continue;
}
if (ksh_isdigit(c))
c -= '0';
c = ksh_numdig(c);
else if (ksh_isupper(c))
c -= 'A' - 10;
c = ksh_numuc(c) + 10;
else if (ksh_islower(c))
c -= 'a' - 10;
c = ksh_numlc(c) + 10;
else
return (-1);
if (c >= base)