Support Dave Korn’s alternative 「'a'」 (or 「'…'」) form for base-one

integers in addition to my 「1#a」 (or 「1#…」), which also allows for
finer end-of-character checking. Note that this is locale-dependent in
ksh93, set ±U dependent in mksh, and mksh’s OPTU-16 encoding is used.
This commit is contained in:
tg
2009-09-06 17:55:55 +00:00
parent 9531e12b36
commit 9dd98da40d
4 changed files with 48 additions and 6 deletions

16
expr.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.33 2009/08/28 21:01:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.34 2009/09/06 17:55:54 tg Exp $");
/* The order of these enums is constrained by the order of opinfo[] */
enum token {
@ -528,6 +528,20 @@ exprtoken(Expr_state *es)
cp += utf_ptradj(cp);
strndupx(tvar, es->tokp, cp - es->tokp, ATEMP);
goto process_tvar;
} else if (c == '\'') {
++cp;
cp += utf_ptradj(cp);
if (*cp++ != '\'')
evalerr(es, ET_STR,
"multi-character character constant");
/* 'x' -> 1#x (x = one multibyte character) */
c = cp - es->tokp;
tvar = alloc(c + /* NUL */ 1, ATEMP);
tvar[0] = '1';
tvar[1] = '#';
memcpy(tvar + 2, es->tokp + 1, c - 2);
tvar[c] = '\0';
goto process_tvar;
} else if (ksh_isdigit(c)) {
while (c != '_' && (ksh_isalnux(c) || c == '#'))
c = *cp++;