eliminate legacy macros
This commit is contained in:
parent
91a3d6751e
commit
1080008a8f
96
edit.c
96
edit.c
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.325 2017/04/22 00:07:06 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.326 2017/04/27 19:33:46 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -589,7 +589,7 @@ x_locate_word(const char *buf, int buflen, int pos, int *startp,
|
|||||||
int p = start - 1;
|
int p = start - 1;
|
||||||
|
|
||||||
/* Figure out if this is a command */
|
/* Figure out if this is a command */
|
||||||
while (p >= 0 && ksh_isspace(buf[p]))
|
while (p >= 0 && ctype(buf[p], C_SPACE))
|
||||||
p--;
|
p--;
|
||||||
iscmd = p < 0 || vstrchr(";|&()`", buf[p]);
|
iscmd = p < 0 || vstrchr(";|&()`", buf[p]);
|
||||||
if (iscmd) {
|
if (iscmd) {
|
||||||
@ -1557,11 +1557,11 @@ x_bword(void)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
while (x_arg--) {
|
while (x_arg--) {
|
||||||
while (cp != xbuf && is_mfs(cp[-1])) {
|
while (cp != xbuf && ctype(cp[-1], C_MFS)) {
|
||||||
cp--;
|
cp--;
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
while (cp != xbuf && !is_mfs(cp[-1])) {
|
while (cp != xbuf && !ctype(cp[-1], C_MFS)) {
|
||||||
cp--;
|
cp--;
|
||||||
nb++;
|
nb++;
|
||||||
}
|
}
|
||||||
@ -1581,9 +1581,9 @@ x_fword(bool move)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
while (x_arg--) {
|
while (x_arg--) {
|
||||||
while (cp != xep && is_mfs(*cp))
|
while (cp != xep && ctype(*cp, C_MFS))
|
||||||
cp++;
|
cp++;
|
||||||
while (cp != xep && !is_mfs(*cp))
|
while (cp != xep && !ctype(*cp, C_MFS))
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
nc = x_nb2nc(cp - xcp);
|
nc = x_nb2nc(cp - xcp);
|
||||||
@ -3006,7 +3006,7 @@ x_set_arg(int c)
|
|||||||
|
|
||||||
/* strip command prefix */
|
/* strip command prefix */
|
||||||
c &= 255;
|
c &= 255;
|
||||||
while (c >= 0 && ksh_isdigit(c)) {
|
while (c >= 0 && ctype(c, C_DIGIT)) {
|
||||||
n = n * 10 + ksh_numdig(c);
|
n = n * 10 + ksh_numdig(c);
|
||||||
if (n > LINE)
|
if (n > LINE)
|
||||||
/* upper bound for repeat */
|
/* upper bound for repeat */
|
||||||
@ -3153,11 +3153,11 @@ x_prev_histword(int c MKSH_A_UNUSED)
|
|||||||
/*
|
/*
|
||||||
* ignore white-space after the last word
|
* ignore white-space after the last word
|
||||||
*/
|
*/
|
||||||
while (rcp > cp && is_cfs(*rcp))
|
while (rcp > cp && ctype(*rcp, C_CFS))
|
||||||
rcp--;
|
rcp--;
|
||||||
while (rcp > cp && !is_cfs(*rcp))
|
while (rcp > cp && !ctype(*rcp, C_CFS))
|
||||||
rcp--;
|
rcp--;
|
||||||
if (is_cfs(*rcp))
|
if (ctype(*rcp, C_CFS))
|
||||||
rcp++;
|
rcp++;
|
||||||
x_ins(rcp);
|
x_ins(rcp);
|
||||||
} else {
|
} else {
|
||||||
@ -3168,16 +3168,16 @@ x_prev_histword(int c MKSH_A_UNUSED)
|
|||||||
/*
|
/*
|
||||||
* ignore white-space at start of line
|
* ignore white-space at start of line
|
||||||
*/
|
*/
|
||||||
while (*rcp && is_cfs(*rcp))
|
while (*rcp && ctype(*rcp, C_CFS))
|
||||||
rcp++;
|
rcp++;
|
||||||
while (x_arg-- > 0) {
|
while (x_arg-- > 0) {
|
||||||
while (*rcp && !is_cfs(*rcp))
|
while (*rcp && !ctype(*rcp, C_CFS))
|
||||||
rcp++;
|
rcp++;
|
||||||
while (*rcp && is_cfs(*rcp))
|
while (*rcp && ctype(*rcp, C_CFS))
|
||||||
rcp++;
|
rcp++;
|
||||||
}
|
}
|
||||||
cp = rcp;
|
cp = rcp;
|
||||||
while (*rcp && !is_cfs(*rcp))
|
while (*rcp && !ctype(*rcp, C_CFS))
|
||||||
rcp++;
|
rcp++;
|
||||||
ch = *rcp;
|
ch = *rcp;
|
||||||
*rcp = '\0';
|
*rcp = '\0';
|
||||||
@ -3236,7 +3236,7 @@ x_fold_case(int c)
|
|||||||
/*
|
/*
|
||||||
* first skip over any white-space
|
* first skip over any white-space
|
||||||
*/
|
*/
|
||||||
while (cp != xep && is_mfs(*cp))
|
while (cp != xep && ctype(*cp, C_MFS))
|
||||||
cp++;
|
cp++;
|
||||||
/*
|
/*
|
||||||
* do the first char on its own since it may be
|
* do the first char on its own since it may be
|
||||||
@ -3254,7 +3254,7 @@ x_fold_case(int c)
|
|||||||
/*
|
/*
|
||||||
* now for the rest of the word
|
* now for the rest of the word
|
||||||
*/
|
*/
|
||||||
while (cp != xep && !is_mfs(*cp)) {
|
while (cp != xep && !ctype(*cp, C_MFS)) {
|
||||||
if (c == 'U')
|
if (c == 'U')
|
||||||
/* uppercase */
|
/* uppercase */
|
||||||
*cp = ksh_toupper(*cp);
|
*cp = ksh_toupper(*cp);
|
||||||
@ -3680,7 +3680,7 @@ vi_hook(int ch)
|
|||||||
return (1);
|
return (1);
|
||||||
cmdlen = 0;
|
cmdlen = 0;
|
||||||
argc1 = 0;
|
argc1 = 0;
|
||||||
if (ksh_isdigit(ch)) {
|
if (ctype(ch, C_DIGIT)) {
|
||||||
argc1 = ksh_numdig(ch);
|
argc1 = ksh_numdig(ch);
|
||||||
state = VARG1;
|
state = VARG1;
|
||||||
} else {
|
} else {
|
||||||
@ -3725,7 +3725,7 @@ vi_hook(int ch)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VARG1:
|
case VARG1:
|
||||||
if (ksh_isdigit(ch))
|
if (ctype(ch, C_DIGIT))
|
||||||
argc1 = argc1 * 10 + ksh_numdig(ch);
|
argc1 = argc1 * 10 + ksh_numdig(ch);
|
||||||
else {
|
else {
|
||||||
curcmd[cmdlen++] = ch;
|
curcmd[cmdlen++] = ch;
|
||||||
@ -3735,7 +3735,7 @@ vi_hook(int ch)
|
|||||||
|
|
||||||
case VEXTCMD:
|
case VEXTCMD:
|
||||||
argc2 = 0;
|
argc2 = 0;
|
||||||
if (ksh_isdigit(ch)) {
|
if (ctype(ch, C_DIGIT)) {
|
||||||
argc2 = ksh_numdig(ch);
|
argc2 = ksh_numdig(ch);
|
||||||
state = VARG2;
|
state = VARG2;
|
||||||
return (0);
|
return (0);
|
||||||
@ -3751,7 +3751,7 @@ vi_hook(int ch)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VARG2:
|
case VARG2:
|
||||||
if (ksh_isdigit(ch))
|
if (ctype(ch, C_DIGIT))
|
||||||
argc2 = argc2 * 10 + ksh_numdig(ch);
|
argc2 = argc2 * 10 + ksh_numdig(ch);
|
||||||
else {
|
else {
|
||||||
if (argc1 == 0)
|
if (argc1 == 0)
|
||||||
@ -4204,10 +4204,10 @@ vi_cmd(int argcnt, const char *cmd)
|
|||||||
return (-1);
|
return (-1);
|
||||||
if (*cmd == 'c' &&
|
if (*cmd == 'c' &&
|
||||||
(cmd[1] == 'w' || cmd[1] == 'W') &&
|
(cmd[1] == 'w' || cmd[1] == 'W') &&
|
||||||
!ksh_isspace(vs->cbuf[vs->cursor])) {
|
!ctype(vs->cbuf[vs->cursor], C_SPACE)) {
|
||||||
do {
|
do {
|
||||||
--ncursor;
|
--ncursor;
|
||||||
} while (ksh_isspace(vs->cbuf[ncursor]));
|
} while (ctype(vs->cbuf[ncursor], C_SPACE));
|
||||||
ncursor++;
|
ncursor++;
|
||||||
}
|
}
|
||||||
if (ncursor > vs->cursor) {
|
if (ncursor > vs->cursor) {
|
||||||
@ -4470,7 +4470,7 @@ vi_cmd(int argcnt, const char *cmd)
|
|||||||
if (histnum(-1) < 0)
|
if (histnum(-1) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
p = *histpos();
|
p = *histpos();
|
||||||
#define issp(c) (ksh_isspace(c) || (c) == '\n')
|
#define issp(c) (ctype(c, C_SPACE) || (c) == '\n')
|
||||||
if (argcnt) {
|
if (argcnt) {
|
||||||
while (*p && issp(*p))
|
while (*p && issp(*p))
|
||||||
p++;
|
p++;
|
||||||
@ -4524,11 +4524,11 @@ vi_cmd(int argcnt, const char *cmd)
|
|||||||
return (-1);
|
return (-1);
|
||||||
for (i = 0; i < argcnt; i++) {
|
for (i = 0; i < argcnt; i++) {
|
||||||
p = &vs->cbuf[vs->cursor];
|
p = &vs->cbuf[vs->cursor];
|
||||||
if (ksh_islower(*p)) {
|
if (ctype(*p, C_LOWER)) {
|
||||||
modified = 1;
|
modified = 1;
|
||||||
hnum = hlast;
|
hnum = hlast;
|
||||||
*p = ksh_toupper(*p);
|
*p = ksh_toupper(*p);
|
||||||
} else if (ksh_isupper(*p)) {
|
} else if (ctype(*p, C_UPPER)) {
|
||||||
modified = 1;
|
modified = 1;
|
||||||
hnum = hlast;
|
hnum = hlast;
|
||||||
*p = ksh_tolower(*p);
|
*p = ksh_tolower(*p);
|
||||||
@ -4695,7 +4695,7 @@ domove(int argcnt, const char *cmd, int sub)
|
|||||||
case '^':
|
case '^':
|
||||||
ncursor = 0;
|
ncursor = 0;
|
||||||
while (ncursor < vs->linelen - 1 &&
|
while (ncursor < vs->linelen - 1 &&
|
||||||
ksh_isspace(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
ncursor++;
|
ncursor++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4921,17 +4921,17 @@ forwword(int argcnt)
|
|||||||
|
|
||||||
ncursor = vs->cursor;
|
ncursor = vs->cursor;
|
||||||
while (ncursor < vs->linelen && argcnt--) {
|
while (ncursor < vs->linelen && argcnt--) {
|
||||||
if (ksh_isalnux(vs->cbuf[ncursor]))
|
if (ctype(vs->cbuf[ncursor], C_ALNUX))
|
||||||
while (ncursor < vs->linelen &&
|
while (ncursor < vs->linelen &&
|
||||||
ksh_isalnux(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_ALNUX))
|
||||||
ncursor++;
|
ncursor++;
|
||||||
else if (!ksh_isspace(vs->cbuf[ncursor]))
|
else if (!ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
while (ncursor < vs->linelen &&
|
while (ncursor < vs->linelen &&
|
||||||
!ksh_isalnux(vs->cbuf[ncursor]) &&
|
!ctype(vs->cbuf[ncursor], C_ALNUX) &&
|
||||||
!ksh_isspace(vs->cbuf[ncursor]))
|
!ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
ncursor++;
|
ncursor++;
|
||||||
while (ncursor < vs->linelen &&
|
while (ncursor < vs->linelen &&
|
||||||
ksh_isspace(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
ncursor++;
|
ncursor++;
|
||||||
}
|
}
|
||||||
return (ncursor);
|
return (ncursor);
|
||||||
@ -4944,17 +4944,17 @@ backword(int argcnt)
|
|||||||
|
|
||||||
ncursor = vs->cursor;
|
ncursor = vs->cursor;
|
||||||
while (ncursor > 0 && argcnt--) {
|
while (ncursor > 0 && argcnt--) {
|
||||||
while (--ncursor > 0 && ksh_isspace(vs->cbuf[ncursor]))
|
while (--ncursor > 0 && ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
if (ncursor > 0) {
|
if (ncursor > 0) {
|
||||||
if (ksh_isalnux(vs->cbuf[ncursor]))
|
if (ctype(vs->cbuf[ncursor], C_ALNUX))
|
||||||
while (--ncursor >= 0 &&
|
while (--ncursor >= 0 &&
|
||||||
ksh_isalnux(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_ALNUX))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
while (--ncursor >= 0 &&
|
while (--ncursor >= 0 &&
|
||||||
!ksh_isalnux(vs->cbuf[ncursor]) &&
|
!ctype(vs->cbuf[ncursor], C_ALNUX) &&
|
||||||
!ksh_isspace(vs->cbuf[ncursor]))
|
!ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
ncursor++;
|
ncursor++;
|
||||||
}
|
}
|
||||||
@ -4970,17 +4970,17 @@ endword(int argcnt)
|
|||||||
ncursor = vs->cursor;
|
ncursor = vs->cursor;
|
||||||
while (ncursor < vs->linelen && argcnt--) {
|
while (ncursor < vs->linelen && argcnt--) {
|
||||||
while (++ncursor < vs->linelen - 1 &&
|
while (++ncursor < vs->linelen - 1 &&
|
||||||
ksh_isspace(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
if (ncursor < vs->linelen - 1) {
|
if (ncursor < vs->linelen - 1) {
|
||||||
if (ksh_isalnux(vs->cbuf[ncursor]))
|
if (ctype(vs->cbuf[ncursor], C_ALNUX))
|
||||||
while (++ncursor < vs->linelen &&
|
while (++ncursor < vs->linelen &&
|
||||||
ksh_isalnux(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_ALNUX))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
while (++ncursor < vs->linelen &&
|
while (++ncursor < vs->linelen &&
|
||||||
!ksh_isalnux(vs->cbuf[ncursor]) &&
|
!ctype(vs->cbuf[ncursor], C_ALNUX) &&
|
||||||
!ksh_isspace(vs->cbuf[ncursor]))
|
!ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
ncursor--;
|
ncursor--;
|
||||||
}
|
}
|
||||||
@ -4996,10 +4996,10 @@ Forwword(int argcnt)
|
|||||||
ncursor = vs->cursor;
|
ncursor = vs->cursor;
|
||||||
while (ncursor < vs->linelen && argcnt--) {
|
while (ncursor < vs->linelen && argcnt--) {
|
||||||
while (ncursor < vs->linelen &&
|
while (ncursor < vs->linelen &&
|
||||||
!ksh_isspace(vs->cbuf[ncursor]))
|
!ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
ncursor++;
|
ncursor++;
|
||||||
while (ncursor < vs->linelen &&
|
while (ncursor < vs->linelen &&
|
||||||
ksh_isspace(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
ncursor++;
|
ncursor++;
|
||||||
}
|
}
|
||||||
return (ncursor);
|
return (ncursor);
|
||||||
@ -5012,9 +5012,9 @@ Backword(int argcnt)
|
|||||||
|
|
||||||
ncursor = vs->cursor;
|
ncursor = vs->cursor;
|
||||||
while (ncursor > 0 && argcnt--) {
|
while (ncursor > 0 && argcnt--) {
|
||||||
while (--ncursor >= 0 && ksh_isspace(vs->cbuf[ncursor]))
|
while (--ncursor >= 0 && ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
while (ncursor >= 0 && !ksh_isspace(vs->cbuf[ncursor]))
|
while (ncursor >= 0 && !ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
ncursor--;
|
ncursor--;
|
||||||
ncursor++;
|
ncursor++;
|
||||||
}
|
}
|
||||||
@ -5029,11 +5029,11 @@ Endword(int argcnt)
|
|||||||
ncursor = vs->cursor;
|
ncursor = vs->cursor;
|
||||||
while (ncursor < vs->linelen - 1 && argcnt--) {
|
while (ncursor < vs->linelen - 1 && argcnt--) {
|
||||||
while (++ncursor < vs->linelen - 1 &&
|
while (++ncursor < vs->linelen - 1 &&
|
||||||
ksh_isspace(vs->cbuf[ncursor]))
|
ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
if (ncursor < vs->linelen - 1) {
|
if (ncursor < vs->linelen - 1) {
|
||||||
while (++ncursor < vs->linelen &&
|
while (++ncursor < vs->linelen &&
|
||||||
!ksh_isspace(vs->cbuf[ncursor]))
|
!ctype(vs->cbuf[ncursor], C_SPACE))
|
||||||
;
|
;
|
||||||
ncursor--;
|
ncursor--;
|
||||||
}
|
}
|
||||||
|
8
eval.c
8
eval.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.204 2017/04/27 19:16:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.205 2017/04/27 19:33:47 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* string expansion
|
* string expansion
|
||||||
@ -1227,7 +1227,7 @@ varsub(Expand *xp, const char *sp, const char *word,
|
|||||||
} else if (ctype(c, C_SUB1)) {
|
} else if (ctype(c, C_SUB1)) {
|
||||||
slen += 2;
|
slen += 2;
|
||||||
stype |= c;
|
stype |= c;
|
||||||
} else if (ksh_issubop2(c)) {
|
} else if (ctype(c, C_SUB2)) {
|
||||||
/* Note: ksh88 allows :%, :%%, etc */
|
/* Note: ksh88 allows :%, :%%, etc */
|
||||||
slen += 2;
|
slen += 2;
|
||||||
stype = c;
|
stype = c;
|
||||||
@ -1335,7 +1335,7 @@ varsub(Expand *xp, const char *sp, const char *word,
|
|||||||
|
|
||||||
c = stype & 0x7F;
|
c = stype & 0x7F;
|
||||||
/* test the compiler's code generator */
|
/* test the compiler's code generator */
|
||||||
if (((stype < 0x100) && (ksh_issubop2(c) ||
|
if (((stype < 0x100) && (ctype(c, C_SUB2) ||
|
||||||
(((stype & 0x80) ? *xp->str == '\0' : xp->str == null) &&
|
(((stype & 0x80) ? *xp->str == '\0' : xp->str == null) &&
|
||||||
(state != XARG || (ifs0 || xp->split ?
|
(state != XARG || (ifs0 || xp->split ?
|
||||||
(xp->u.strv[0] == NULL) : !hasnonempty(xp->u.strv))) ?
|
(xp->u.strv[0] == NULL) : !hasnonempty(xp->u.strv))) ?
|
||||||
@ -1345,7 +1345,7 @@ varsub(Expand *xp, const char *sp, const char *word,
|
|||||||
/* expand word instead of variable value */
|
/* expand word instead of variable value */
|
||||||
state = XBASE;
|
state = XBASE;
|
||||||
if (Flag(FNOUNSET) && xp->str == null && !zero_ok &&
|
if (Flag(FNOUNSET) && xp->str == null && !zero_ok &&
|
||||||
(ksh_issubop2(c) || (state != XBASE && c != '+')))
|
(ctype(c, C_SUB2) || (state != XBASE && c != '+')))
|
||||||
errorf(Tf_parm, sp);
|
errorf(Tf_parm, sp);
|
||||||
*stypep = stype;
|
*stypep = stype;
|
||||||
*slenp = slen;
|
*slenp = slen;
|
||||||
|
12
expr.c
12
expr.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.93 2017/04/02 16:47:41 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/expr.c,v 1.94 2017/04/27 19:33:48 tg Exp $");
|
||||||
|
|
||||||
#define EXPRTOK_DEFNS
|
#define EXPRTOK_DEFNS
|
||||||
#include "exprtok.h"
|
#include "exprtok.h"
|
||||||
@ -558,7 +558,7 @@ exprtoken(Expr_state *es)
|
|||||||
|
|
||||||
/* skip whitespace */
|
/* skip whitespace */
|
||||||
skip_spaces:
|
skip_spaces:
|
||||||
while ((c = *cp), ksh_isspace(c))
|
while (ctype((c = *cp), C_SPACE))
|
||||||
++cp;
|
++cp;
|
||||||
if (es->tokp == es->expression && c == '#') {
|
if (es->tokp == es->expression && c == '#') {
|
||||||
/* expression begins with # */
|
/* expression begins with # */
|
||||||
@ -571,10 +571,10 @@ exprtoken(Expr_state *es)
|
|||||||
|
|
||||||
if (c == '\0')
|
if (c == '\0')
|
||||||
es->tok = END;
|
es->tok = END;
|
||||||
else if (ksh_isalphx(c)) {
|
else if (ctype(c, C_ALPHX)) {
|
||||||
do {
|
do {
|
||||||
c = *++cp;
|
c = *++cp;
|
||||||
} while (ksh_isalnux(c));
|
} while (ctype(c, C_ALNUX));
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@ -617,8 +617,8 @@ exprtoken(Expr_state *es)
|
|||||||
tvar[c] = '\0';
|
tvar[c] = '\0';
|
||||||
goto process_tvar;
|
goto process_tvar;
|
||||||
#endif
|
#endif
|
||||||
} else if (ksh_isdigit(c)) {
|
} else if (ctype(c, C_DIGIT)) {
|
||||||
while (c != '_' && (ksh_isalnux(c) || c == '#'))
|
while (c != '_' && (ctype(c, C_ALNUX) || c == '#'))
|
||||||
c = *cp++;
|
c = *cp++;
|
||||||
strndupx(tvar, es->tokp, --cp - es->tokp, ATEMP);
|
strndupx(tvar, es->tokp, --cp - es->tokp, ATEMP);
|
||||||
process_tvar:
|
process_tvar:
|
||||||
|
12
funcs.c
12
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.342 2017/04/21 19:50:07 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.343 2017/04/27 19:33:48 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -746,7 +746,7 @@ bool
|
|||||||
valid_alias_name(const char *cp)
|
valid_alias_name(const char *cp)
|
||||||
{
|
{
|
||||||
while (*cp)
|
while (*cp)
|
||||||
if (!ksh_isalias(*cp))
|
if (!ctype(*cp, C_ALIAS))
|
||||||
return (false);
|
return (false);
|
||||||
else
|
else
|
||||||
++cp;
|
++cp;
|
||||||
@ -1067,8 +1067,8 @@ c_kill(const char **wp)
|
|||||||
int i, n, rv, sig;
|
int i, n, rv, sig;
|
||||||
|
|
||||||
/* assume old style options if -digits or -UPPERCASE */
|
/* assume old style options if -digits or -UPPERCASE */
|
||||||
if ((p = wp[1]) && *p == '-' && (ksh_isdigit(p[1]) ||
|
if ((p = wp[1]) && *p == '-' && (ctype(p[1], C_DIGIT) ||
|
||||||
ksh_isupper(p[1]))) {
|
ctype(p[1], C_UPPER))) {
|
||||||
if (!(t = gettrap(p + 1, false, false))) {
|
if (!(t = gettrap(p + 1, false, false))) {
|
||||||
bi_errorf(Tbad_sig_s, p + 1);
|
bi_errorf(Tbad_sig_s, p + 1);
|
||||||
return (1);
|
return (1);
|
||||||
@ -1417,7 +1417,7 @@ c_umask(const char **wp)
|
|||||||
} else {
|
} else {
|
||||||
mode_t new_umask;
|
mode_t new_umask;
|
||||||
|
|
||||||
if (ksh_isdigit(*cp)) {
|
if (ctype(*cp, C_DIGIT)) {
|
||||||
new_umask = 0;
|
new_umask = 0;
|
||||||
while (asc(*cp) >= asc('0') && asc(*cp) <= asc('7')) {
|
while (asc(*cp) >= asc('0') && asc(*cp) <= asc('7')) {
|
||||||
new_umask = new_umask * 8 + ksh_numdig(*cp);
|
new_umask = new_umask * 8 + ksh_numdig(*cp);
|
||||||
@ -3345,7 +3345,7 @@ set_ulimit(const struct limits *l, const char *v, int how)
|
|||||||
* If this causes problems, will have to add parameter to
|
* If this causes problems, will have to add parameter to
|
||||||
* evaluate() to control if unset params are 0 or an error.
|
* evaluate() to control if unset params are 0 or an error.
|
||||||
*/
|
*/
|
||||||
if (!rval && !ksh_isdigit(v[0])) {
|
if (!rval && !ctype(v[0], C_DIGIT)) {
|
||||||
bi_errorf("invalid %s limit: %s", l->name, v);
|
bi_errorf("invalid %s limit: %s", l->name, v);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.160 2017/04/08 01:07:16 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.161 2017/04/27 19:33:49 tg Exp $");
|
||||||
|
|
||||||
Trap sigtraps[ksh_NSIG + 1];
|
Trap sigtraps[ksh_NSIG + 1];
|
||||||
static struct sigaction Sigact_ign;
|
static struct sigaction Sigact_ign;
|
||||||
@ -1114,7 +1114,7 @@ gettrap(const char *cs, bool igncase, bool allsigs)
|
|||||||
|
|
||||||
/* signal number (1..ksh_NSIG) or 0? */
|
/* signal number (1..ksh_NSIG) or 0? */
|
||||||
|
|
||||||
if (ksh_isdigit(*cs))
|
if (ctype(*cs, C_DIGIT))
|
||||||
return ((getn(cs, &i) && 0 <= i && i < ksh_NSIG) ?
|
return ((getn(cs, &i) && 0 <= i && i < ksh_NSIG) ?
|
||||||
(&sigtraps[i]) : NULL);
|
(&sigtraps[i]) : NULL);
|
||||||
|
|
||||||
|
4
jobs.c
4
jobs.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.121 2016/07/25 00:04:44 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.122 2017/04/27 19:33:50 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
#define mksh_killpg killpg
|
#define mksh_killpg killpg
|
||||||
@ -1651,7 +1651,7 @@ j_lookup(const char *cp, int *ecodep)
|
|||||||
size_t len;
|
size_t len;
|
||||||
int job = 0;
|
int job = 0;
|
||||||
|
|
||||||
if (ksh_isdigit(*cp) && getn(cp, &job)) {
|
if (ctype(*cp, C_DIGIT) && getn(cp, &job)) {
|
||||||
/* Look for last_proc->pid (what $! returns) first... */
|
/* Look for last_proc->pid (what $! returns) first... */
|
||||||
for (j = job_list; j != NULL; j = j->next)
|
for (j = job_list; j != NULL; j = j->next)
|
||||||
if (j->last_proc && j->last_proc->pid == job)
|
if (j->last_proc && j->last_proc->pid == job)
|
||||||
|
22
lex.c
22
lex.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.234 2017/04/06 01:59:55 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.235 2017/04/27 19:33:51 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@ -444,7 +444,7 @@ yylex(int cf)
|
|||||||
statep->ls_adelim.num = 1;
|
statep->ls_adelim.num = 1;
|
||||||
statep->nparen = 0;
|
statep->nparen = 0;
|
||||||
break;
|
break;
|
||||||
} else if (ksh_isdigit(c) ||
|
} else if (ctype(c, C_DIGIT) ||
|
||||||
c == '('/*)*/ || c == ' ' ||
|
c == '('/*)*/ || c == ' ' ||
|
||||||
/*XXX what else? */
|
/*XXX what else? */
|
||||||
c == '$') {
|
c == '$') {
|
||||||
@ -489,7 +489,7 @@ yylex(int cf)
|
|||||||
* If this is a trim operation,
|
* If this is a trim operation,
|
||||||
* treat (,|,) specially in STBRACE.
|
* treat (,|,) specially in STBRACE.
|
||||||
*/
|
*/
|
||||||
if (ksh_issubop2(c)) {
|
if (ctype(c, C_SUB2)) {
|
||||||
ungetsc(c);
|
ungetsc(c);
|
||||||
if (Flag(FSH))
|
if (Flag(FSH))
|
||||||
PUSH_STATE(STBRACEBOURNE);
|
PUSH_STATE(STBRACEBOURNE);
|
||||||
@ -503,14 +503,14 @@ yylex(int cf)
|
|||||||
else
|
else
|
||||||
PUSH_STATE(SBRACE);
|
PUSH_STATE(SBRACE);
|
||||||
}
|
}
|
||||||
} else if (ksh_isalphx(c)) {
|
} else if (ctype(c, C_ALPHX)) {
|
||||||
*wp++ = OSUBST;
|
*wp++ = OSUBST;
|
||||||
*wp++ = 'X';
|
*wp++ = 'X';
|
||||||
do {
|
do {
|
||||||
Xcheck(ws, wp);
|
Xcheck(ws, wp);
|
||||||
*wp++ = c;
|
*wp++ = c;
|
||||||
c = getsc();
|
c = getsc();
|
||||||
} while (ksh_isalnux(c));
|
} while (ctype(c, C_ALNUX));
|
||||||
*wp++ = '\0';
|
*wp++ = '\0';
|
||||||
*wp++ = CSUBST;
|
*wp++ = CSUBST;
|
||||||
*wp++ = 'X';
|
*wp++ = 'X';
|
||||||
@ -895,7 +895,7 @@ yylex(int cf)
|
|||||||
if (state == SBASE && (
|
if (state == SBASE && (
|
||||||
(c == '&' && !Flag(FSH) && !Flag(FPOSIX)) ||
|
(c == '&' && !Flag(FSH) && !Flag(FPOSIX)) ||
|
||||||
c == '<' || c == '>') && ((c2 = Xlength(ws, wp)) == 0 ||
|
c == '<' || c == '>') && ((c2 = Xlength(ws, wp)) == 0 ||
|
||||||
(c2 == 2 && dp[0] == CHAR && ksh_isdigit(dp[1])))) {
|
(c2 == 2 && dp[0] == CHAR && ctype(dp[1], C_DIGIT)))) {
|
||||||
struct ioword *iop = alloc(sizeof(struct ioword), ATEMP);
|
struct ioword *iop = alloc(sizeof(struct ioword), ATEMP);
|
||||||
|
|
||||||
iop->unit = c2 == 2 ? ksh_numdig(dp[1]) : c == '<' ? 0 : 1;
|
iop->unit = c2 == 2 ? ksh_numdig(dp[1]) : c == '<' ? 0 : 1;
|
||||||
@ -1275,7 +1275,7 @@ getsc_uu(void)
|
|||||||
source->flags |= s->flags & SF_ALIAS;
|
source->flags |= s->flags & SF_ALIAS;
|
||||||
s = source;
|
s = source;
|
||||||
} else if (*s->u.tblp->val.s &&
|
} else if (*s->u.tblp->val.s &&
|
||||||
(c = strnul(s->u.tblp->val.s)[-1], ksh_isspace(c))) {
|
(c = strnul(s->u.tblp->val.s)[-1], ctype(c, C_SPACE))) {
|
||||||
/* pop source stack */
|
/* pop source stack */
|
||||||
source = s = s->next;
|
source = s = s->next;
|
||||||
/*
|
/*
|
||||||
@ -1610,9 +1610,9 @@ get_brace_var(XString *wsp, char *wp)
|
|||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case PS_SAW_PERCENT:
|
case PS_SAW_PERCENT:
|
||||||
ps_common:
|
ps_common:
|
||||||
if (ksh_isalphx(c))
|
if (ctype(c, C_ALPHX))
|
||||||
state = PS_IDENT;
|
state = PS_IDENT;
|
||||||
else if (ksh_isdigit(c))
|
else if (ctype(c, C_DIGIT))
|
||||||
state = PS_NUMBER;
|
state = PS_NUMBER;
|
||||||
else if (ctype(c, C_VAR1))
|
else if (ctype(c, C_VAR1))
|
||||||
state = PS_VAR1;
|
state = PS_VAR1;
|
||||||
@ -1620,7 +1620,7 @@ get_brace_var(XString *wsp, char *wp)
|
|||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
case PS_IDENT:
|
case PS_IDENT:
|
||||||
if (!ksh_isalnux(c)) {
|
if (!ctype(c, C_ALNUX)) {
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
char *tmp, *p;
|
char *tmp, *p;
|
||||||
|
|
||||||
@ -1640,7 +1640,7 @@ get_brace_var(XString *wsp, char *wp)
|
|||||||
next:
|
next:
|
||||||
break;
|
break;
|
||||||
case PS_NUMBER:
|
case PS_NUMBER:
|
||||||
if (!ksh_isdigit(c))
|
if (!ctype(c, C_DIGIT))
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
case PS_VAR1:
|
case PS_VAR1:
|
||||||
|
60
main.c
60
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.336 2017/04/27 19:16:08 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.337 2017/04/27 19:33:51 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -410,62 +410,6 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
|||||||
/* for security */
|
/* for security */
|
||||||
typeset(TinitIFS, 0, 0, 0, 0);
|
typeset(TinitIFS, 0, 0, 0, 0);
|
||||||
|
|
||||||
#define dmpcf(a,f) do { \
|
|
||||||
int c = -1, lc = -3, il = 0; \
|
|
||||||
shellf("%s\t",a); \
|
|
||||||
while (++c < 256) { \
|
|
||||||
if (!f) continue; \
|
|
||||||
if (lc + 1 == c) { \
|
|
||||||
il = 1; \
|
|
||||||
} else { \
|
|
||||||
if (il) \
|
|
||||||
shellf("‥%02X", lc); \
|
|
||||||
il = 0; \
|
|
||||||
shellf(" %02X", c); \
|
|
||||||
} \
|
|
||||||
lc = c; \
|
|
||||||
} \
|
|
||||||
if (il) \
|
|
||||||
shellf("‥%02X", lc); \
|
|
||||||
shellf(" .\n"); \
|
|
||||||
} while (0)
|
|
||||||
#define dmpct(a,b) dmpcf(a,ctype(c,b))
|
|
||||||
dmpct("C_ALIAS",C_ALIAS);
|
|
||||||
dmpct("C_ALNUM",C_ALNUM);
|
|
||||||
dmpct("C_ALNUX",C_ALNUX);
|
|
||||||
dmpct("C_ALPHA",C_ALPHA);
|
|
||||||
dmpct("C_ALPHX",C_ALPHX);
|
|
||||||
dmpct("C_BLANK",C_BLANK);
|
|
||||||
dmpct("C_CFS",C_CFS);
|
|
||||||
dmpct("C_CNTRL",C_CNTRL);
|
|
||||||
dmpct("C_DIGIT",C_DIGIT);
|
|
||||||
dmpct("C_DOLAR",C_DOLAR);
|
|
||||||
dmpct("C_GRAPH",C_GRAPH);
|
|
||||||
dmpct("C_HEXLT",C_HEXLT);
|
|
||||||
dmpct("C_IFS",C_IFS);
|
|
||||||
dmpct("C_IFSWS",C_IFSWS);
|
|
||||||
dmpct("C_LEX1",C_LEX1);
|
|
||||||
dmpct("C_LF",C_LF);
|
|
||||||
dmpct("C_LOWER",C_LOWER);
|
|
||||||
dmpct("C_MFS",C_MFS);
|
|
||||||
dmpct("C_NL",C_NL);
|
|
||||||
dmpct("C_NUL",C_NUL);
|
|
||||||
dmpct("C_OCTAL",C_OCTAL);
|
|
||||||
dmpct("C_PRINT",C_PRINT);
|
|
||||||
dmpct("C_PUNCT",C_PUNCT);
|
|
||||||
dmpct("C_QC",C_QC);
|
|
||||||
dmpct("C_QUOTE",C_QUOTE);
|
|
||||||
dmpct("C_SEDEC",C_SEDEC);
|
|
||||||
dmpct("C_SPACE",C_SPACE);
|
|
||||||
dmpct("C_SPC",C_SPC);
|
|
||||||
dmpct("C_SUB1",C_SUB1);
|
|
||||||
dmpct("C_SUB2",C_SUB2);
|
|
||||||
dmpct("C_TAB",C_TAB);
|
|
||||||
dmpct("C_UNDER",C_UNDER);
|
|
||||||
dmpct("C_UPPER",C_UPPER);
|
|
||||||
dmpct("C_VAR1",C_VAR1);
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
/* assign default shell variable values */
|
/* assign default shell variable values */
|
||||||
typeset("PATHSEP=" MKSH_PATHSEPS, 0, 0, 0, 0);
|
typeset("PATHSEP=" MKSH_PATHSEPS, 0, 0, 0, 0);
|
||||||
substitute(initsubs, 0);
|
substitute(initsubs, 0);
|
||||||
@ -1604,7 +1548,7 @@ check_fd(const char *name, int mode, const char **emsgp)
|
|||||||
goto illegal_fd_name;
|
goto illegal_fd_name;
|
||||||
if (name[0] == 'p')
|
if (name[0] == 'p')
|
||||||
return (coproc_getfd(mode, emsgp));
|
return (coproc_getfd(mode, emsgp));
|
||||||
if (!ksh_isdigit(name[0])) {
|
if (!ctype(name[0], C_DIGIT)) {
|
||||||
illegal_fd_name:
|
illegal_fd_name:
|
||||||
if (emsgp)
|
if (emsgp)
|
||||||
*emsgp = "illegal file descriptor name";
|
*emsgp = "illegal file descriptor name";
|
||||||
|
14
misc.c
14
misc.c
@ -30,7 +30,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.259 2017/04/27 19:16:08 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.260 2017/04/27 19:33:52 tg Exp $");
|
||||||
|
|
||||||
#define KSH_CHVT_FLAG
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
@ -502,7 +502,7 @@ getn(const char *s, int *ai)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
c = *s++;
|
c = *s++;
|
||||||
} while (ksh_isspace(c));
|
} while (ctype(c, C_SPACE));
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
@ -514,7 +514,7 @@ getn(const char *s, int *ai)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!ksh_isdigit(c))
|
if (!ctype(c, C_DIGIT))
|
||||||
/* not numeric */
|
/* not numeric */
|
||||||
return (0);
|
return (0);
|
||||||
if (num.u > 214748364U)
|
if (num.u > 214748364U)
|
||||||
@ -1066,13 +1066,13 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp)
|
|||||||
* argument is missing.
|
* argument is missing.
|
||||||
*/
|
*/
|
||||||
if (argv[go->optind - 1][go->p]) {
|
if (argv[go->optind - 1][go->p]) {
|
||||||
if (ksh_isdigit(argv[go->optind - 1][go->p])) {
|
if (ctype(argv[go->optind - 1][go->p], C_DIGIT)) {
|
||||||
go->optarg = argv[go->optind - 1] + go->p;
|
go->optarg = argv[go->optind - 1] + go->p;
|
||||||
go->p = 0;
|
go->p = 0;
|
||||||
} else
|
} else
|
||||||
go->optarg = NULL;
|
go->optarg = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (argv[go->optind] && ksh_isdigit(argv[go->optind][0])) {
|
if (argv[go->optind] && ctype(argv[go->optind][0], C_DIGIT)) {
|
||||||
go->optarg = argv[go->optind++];
|
go->optarg = argv[go->optind++];
|
||||||
go->p = 0;
|
go->p = 0;
|
||||||
} else
|
} else
|
||||||
@ -2192,7 +2192,7 @@ unbksl(bool cstyle, int (*fg)(void), void (*fp)(int))
|
|||||||
wc = 0;
|
wc = 0;
|
||||||
i = 3;
|
i = 3;
|
||||||
while (i--)
|
while (i--)
|
||||||
if (ksh_isdigit((c = (*fg)())) && asc(c) <= asc('7'))
|
if (ctype((c = (*fg)()), C_DIGIT) && asc(c) <= asc('7'))
|
||||||
wc = (wc << 3) + ksh_numdig(c);
|
wc = (wc << 3) + ksh_numdig(c);
|
||||||
else {
|
else {
|
||||||
(*fp)(c);
|
(*fp)(c);
|
||||||
@ -2220,7 +2220,7 @@ unbksl(bool cstyle, int (*fg)(void), void (*fp)(int))
|
|||||||
n = 0;
|
n = 0;
|
||||||
while (n < i || i == -1) {
|
while (n < i || i == -1) {
|
||||||
wc <<= 4;
|
wc <<= 4;
|
||||||
if (ksh_isdigit((c = (*fg)())))
|
if (ctype((c = (*fg)()), C_DIGIT))
|
||||||
wc += ksh_numdig(c);
|
wc += ksh_numdig(c);
|
||||||
else if (asc(c) >= asc('A') && asc(c) <= asc('F'))
|
else if (asc(c) >= asc('A') && asc(c) <= asc('F'))
|
||||||
wc += ksh_numuc(c) + 10;
|
wc += ksh_numuc(c) + 10;
|
||||||
|
8
shf.c
8
shf.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.81 2017/04/27 19:16:10 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.82 2017/04/27 19:33:53 tg Exp $");
|
||||||
|
|
||||||
/* flags to shf_emptybuf() */
|
/* flags to shf_emptybuf() */
|
||||||
#define EB_READSW 0x01 /* about to switch to reading */
|
#define EB_READSW 0x01 /* about to switch to reading */
|
||||||
@ -874,11 +874,11 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
flags |= FL_SIZET;
|
flags |= FL_SIZET;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ksh_isdigit(c)) {
|
if (ctype(c, C_DIGIT)) {
|
||||||
bool overflowed = false;
|
bool overflowed = false;
|
||||||
|
|
||||||
tmp = ksh_numdig(c);
|
tmp = ksh_numdig(c);
|
||||||
while (c = *fmt++, ksh_isdigit(c))
|
while (ctype((c = *fmt++), C_DIGIT))
|
||||||
if (notok2mul(2147483647, tmp, 10))
|
if (notok2mul(2147483647, tmp, 10))
|
||||||
overflowed = true;
|
overflowed = true;
|
||||||
else
|
else
|
||||||
@ -899,7 +899,7 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
/* nasty format */
|
/* nasty format */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ksh_isupper(c)) {
|
if (ctype(c, C_UPPER)) {
|
||||||
flags |= FL_UPPER;
|
flags |= FL_UPPER;
|
||||||
c = ksh_tolower(c);
|
c = ksh_tolower(c);
|
||||||
}
|
}
|
||||||
|
8
syn.c
8
syn.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.120 2017/04/06 01:59:57 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.121 2017/04/27 19:33:53 tg Exp $");
|
||||||
|
|
||||||
struct nesting_state {
|
struct nesting_state {
|
||||||
int start_token; /* token than began nesting (eg, FOR) */
|
int start_token; /* token than began nesting (eg, FOR) */
|
||||||
@ -1079,7 +1079,7 @@ parse_usec(const char *s, struct timeval *tv)
|
|||||||
|
|
||||||
tv->tv_sec = 0;
|
tv->tv_sec = 0;
|
||||||
/* parse integral part */
|
/* parse integral part */
|
||||||
while (ksh_isdigit(*s)) {
|
while (ctype(*s, C_DIGIT)) {
|
||||||
tt.tv_sec = tv->tv_sec * 10 + ksh_numdig(*s++);
|
tt.tv_sec = tv->tv_sec * 10 + ksh_numdig(*s++);
|
||||||
/*XXX this overflow check maybe UB */
|
/*XXX this overflow check maybe UB */
|
||||||
if (tt.tv_sec / 10 != tv->tv_sec) {
|
if (tt.tv_sec / 10 != tv->tv_sec) {
|
||||||
@ -1101,14 +1101,14 @@ parse_usec(const char *s, struct timeval *tv)
|
|||||||
|
|
||||||
/* parse decimal fraction */
|
/* parse decimal fraction */
|
||||||
i = 100000;
|
i = 100000;
|
||||||
while (ksh_isdigit(*s)) {
|
while (ctype(*s, C_DIGIT)) {
|
||||||
tv->tv_usec += i * ksh_numdig(*s++);
|
tv->tv_usec += i * ksh_numdig(*s++);
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
break;
|
break;
|
||||||
i /= 10;
|
i /= 10;
|
||||||
}
|
}
|
||||||
/* check for junk after fractional part */
|
/* check for junk after fractional part */
|
||||||
while (ksh_isdigit(*s))
|
while (ctype(*s, C_DIGIT))
|
||||||
++s;
|
++s;
|
||||||
if (*s) {
|
if (*s) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
36
var.c
36
var.c
@ -28,7 +28,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.215 2017/04/22 00:07:10 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.216 2017/04/27 19:33:53 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -183,7 +183,7 @@ array_index_calc(const char *n, bool *arrayp, uint32_t *valp)
|
|||||||
*arrayp = false;
|
*arrayp = false;
|
||||||
redo_from_ref:
|
redo_from_ref:
|
||||||
p = skip_varname(n, false);
|
p = skip_varname(n, false);
|
||||||
if (innermost_refflag == SRF_NOP && (p != n) && ksh_isalphx(n[0])) {
|
if (innermost_refflag == SRF_NOP && (p != n) && ctype(n[0], C_ALPHX)) {
|
||||||
struct tbl *vp;
|
struct tbl *vp;
|
||||||
char *vn;
|
char *vn;
|
||||||
|
|
||||||
@ -249,14 +249,14 @@ isglobal(const char *n, bool docreate)
|
|||||||
vn = array_index_calc(n, &array, &val);
|
vn = array_index_calc(n, &array, &val);
|
||||||
h = hash(vn);
|
h = hash(vn);
|
||||||
c = (unsigned char)vn[0];
|
c = (unsigned char)vn[0];
|
||||||
if (!ksh_isalphx(c)) {
|
if (!ctype(c, C_ALPHX)) {
|
||||||
if (array)
|
if (array)
|
||||||
errorf(Tbadsubst);
|
errorf(Tbadsubst);
|
||||||
vp = vtemp;
|
vp = vtemp;
|
||||||
vp->flag = DEFINED;
|
vp->flag = DEFINED;
|
||||||
vp->type = 0;
|
vp->type = 0;
|
||||||
vp->areap = ATEMP;
|
vp->areap = ATEMP;
|
||||||
if (ksh_isdigit(c)) {
|
if (ctype(c, C_DIGIT)) {
|
||||||
if (getn(vn, &c)) {
|
if (getn(vn, &c)) {
|
||||||
/* main.c:main_init() says 12 */
|
/* main.c:main_init() says 12 */
|
||||||
shf_snprintf(vp->name, 12, Tf_d, c);
|
shf_snprintf(vp->name, 12, Tf_d, c);
|
||||||
@ -339,7 +339,7 @@ local(const char *n, bool copy)
|
|||||||
*/
|
*/
|
||||||
vn = array_index_calc(n, &array, &val);
|
vn = array_index_calc(n, &array, &val);
|
||||||
h = hash(vn);
|
h = hash(vn);
|
||||||
if (!ksh_isalphx(*vn)) {
|
if (!ctype(*vn, C_ALPHX)) {
|
||||||
vp = vtemp;
|
vp = vtemp;
|
||||||
vp->flag = DEFINED|RDONLY;
|
vp->flag = DEFINED|RDONLY;
|
||||||
vp->type = 0;
|
vp->type = 0;
|
||||||
@ -532,7 +532,7 @@ getint(struct tbl *vp, mksh_ari_u *nump, bool arith)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
c = (unsigned char)*s++;
|
c = (unsigned char)*s++;
|
||||||
} while (ksh_isspace(c));
|
} while (ctype(c, C_SPACE));
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
@ -549,7 +549,7 @@ getint(struct tbl *vp, mksh_ari_u *nump, bool arith)
|
|||||||
base = 16;
|
base = 16;
|
||||||
++s;
|
++s;
|
||||||
goto getint_c_style_base;
|
goto getint_c_style_base;
|
||||||
} else if (Flag(FPOSIX) && ksh_isdigit(s[0]) &&
|
} else if (Flag(FPOSIX) && ctype(s[0], C_DIGIT) &&
|
||||||
!(vp->flag & ZEROFIL)) {
|
!(vp->flag & ZEROFIL)) {
|
||||||
/* interpret as octal (deprecated) */
|
/* interpret as octal (deprecated) */
|
||||||
base = 8;
|
base = 8;
|
||||||
@ -586,11 +586,11 @@ getint(struct tbl *vp, mksh_ari_u *nump, bool arith)
|
|||||||
have_base = true;
|
have_base = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ksh_isdigit(c))
|
if (ctype(c, C_DIGIT))
|
||||||
c = ksh_numdig(c);
|
c = ksh_numdig(c);
|
||||||
else if (ksh_isupper(c))
|
else if (ctype(c, C_UPPER))
|
||||||
c = ksh_numuc(c) + 10;
|
c = ksh_numuc(c) + 10;
|
||||||
else if (ksh_islower(c))
|
else if (ctype(c, C_LOWER))
|
||||||
c = ksh_numlc(c) + 10;
|
c = ksh_numlc(c) + 10;
|
||||||
else
|
else
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -670,7 +670,7 @@ formatstr(struct tbl *vp, const char *s)
|
|||||||
qq = utf_skipcols(s, slen, &slen);
|
qq = utf_skipcols(s, slen, &slen);
|
||||||
|
|
||||||
/* strip trailing spaces (AT&T uses qq[-1] == ' ') */
|
/* strip trailing spaces (AT&T uses qq[-1] == ' ') */
|
||||||
while (qq > s && ksh_isspace(qq[-1])) {
|
while (qq > s && ctype(qq[-1], C_SPACE)) {
|
||||||
--qq;
|
--qq;
|
||||||
--slen;
|
--slen;
|
||||||
}
|
}
|
||||||
@ -700,7 +700,7 @@ formatstr(struct tbl *vp, const char *s)
|
|||||||
"%.*s", slen, s);
|
"%.*s", slen, s);
|
||||||
} else {
|
} else {
|
||||||
/* strip leading spaces/zeros */
|
/* strip leading spaces/zeros */
|
||||||
while (ksh_isspace(*s))
|
while (ctype(*s, C_SPACE))
|
||||||
s++;
|
s++;
|
||||||
if (vp->flag & ZEROFIL)
|
if (vp->flag & ZEROFIL)
|
||||||
while (*s == '0')
|
while (*s == '0')
|
||||||
@ -796,7 +796,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 1; i < len - 1; i++)
|
for (i = 1; i < len - 1; i++)
|
||||||
if (!ksh_isdigit(val[i]))
|
if (!ctype(val[i], C_DIGIT))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
val += len;
|
val += len;
|
||||||
@ -845,7 +845,7 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
|
|||||||
|
|
||||||
if (!(c = (unsigned char)qval[0]))
|
if (!(c = (unsigned char)qval[0]))
|
||||||
goto nameref_empty;
|
goto nameref_empty;
|
||||||
else if (ksh_isdigit(c) && getn(qval, &c))
|
else if (ctype(c, C_DIGIT) && getn(qval, &c))
|
||||||
goto nameref_rhs_checked;
|
goto nameref_rhs_checked;
|
||||||
else if (qval[1] == '\0') switch (c) {
|
else if (qval[1] == '\0') switch (c) {
|
||||||
case '$':
|
case '$':
|
||||||
@ -1064,10 +1064,10 @@ skip_varname(const char *s, bool aok)
|
|||||||
{
|
{
|
||||||
size_t alen;
|
size_t alen;
|
||||||
|
|
||||||
if (s && ksh_isalphx(*s)) {
|
if (s && ctype(*s, C_ALPHX)) {
|
||||||
do {
|
do {
|
||||||
++s;
|
++s;
|
||||||
} while (ksh_isalnux(*s));
|
} while (ctype(*s, C_ALNUX));
|
||||||
if (aok && *s == '[' && (alen = array_ref_len(s)))
|
if (aok && *s == '[' && (alen = array_ref_len(s)))
|
||||||
s += alen;
|
s += alen;
|
||||||
}
|
}
|
||||||
@ -1080,10 +1080,10 @@ skip_wdvarname(const char *s,
|
|||||||
/* skip array de-reference? */
|
/* skip array de-reference? */
|
||||||
bool aok)
|
bool aok)
|
||||||
{
|
{
|
||||||
if (s[0] == CHAR && ksh_isalphx(s[1])) {
|
if (s[0] == CHAR && ctype(s[1], C_ALPHX)) {
|
||||||
do {
|
do {
|
||||||
s += 2;
|
s += 2;
|
||||||
} while (s[0] == CHAR && ksh_isalnux(s[1]));
|
} while (s[0] == CHAR && ctype(s[1], C_ALNUX));
|
||||||
if (aok && s[0] == CHAR && s[1] == '[') {
|
if (aok && s[0] == CHAR && s[1] == '[') {
|
||||||
/* skip possible array de-reference */
|
/* skip possible array de-reference */
|
||||||
const char *p = s;
|
const char *p = s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user