• make EXPRSUB not initiate an ASCIIZ string any more but a wdstring

(token stream, lexer output / parser input), EOS terminated, let
  SASPAREN use the same lexing as SBASE (e.g. COMSUB recursively)
• make wdstrip recursive
• fix processing of COMSUB in wdstrip
⇒ pass comsub-1 test
• expose another debugging function
This commit is contained in:
tg
2011-03-12 21:41:15 +00:00
parent fb1392fb6b
commit 17dbd3bd83
4 changed files with 67 additions and 50 deletions

21
eval.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.95 2011/03/07 20:30:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.96 2011/03/12 21:41:13 tg Exp $");
/*
* string expansion
@ -291,15 +291,19 @@ expand(const char *cp, /* input word */
newlines = 0;
}
continue;
case EXPRSUB:
case EXPRSUB: {
char *xp;
xp = wdstrip(sp, true, false);
sp = wdscan(sp, EOS);
word = IFS_WORD;
tilde_ok = 0;
if (f & DONTRUNCOMMAND) {
c = strlen(xp);
*dp++ = '$'; *dp++ = '('; *dp++ = '(';
while (*sp != '\0') {
Xcheck(ds, dp);
*dp++ = *sp++;
}
XcheckN(ds, dp, c + 2);
memcpy(dp, xp, c);
dp += c;
*dp++ = ')'; *dp++ = ')';
} else {
struct tbl v;
@ -309,15 +313,16 @@ expand(const char *cp, /* input word */
/* not default */
v.type = 10;
v.name[0] = '\0';
v_evaluate(&v, substitute(sp, 0),
v_evaluate(&v, substitute(xp, 0),
KSH_UNWIND_ERROR, true);
sp = strnul(sp) + 1;
for (p = str_val(&v); *p; ) {
Xcheck(ds, dp);
*dp++ = *p++;
}
}
afree(xp, ATEMP);
continue;
}
case OSUBST: {
/* ${{#}var{:}[=+-?#%]word} */
/*-