replace the code related to << changes and <<< with cleaner code,

fixing a few bugs also (including new testcases, except x=<< issue)
This commit is contained in:
tg
2015-09-06 19:47:01 +00:00
parent 0f6aa7eaab
commit ed5cb56849
7 changed files with 63 additions and 97 deletions

18
syn.c
View File

@@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.103 2015/09/05 19:19:11 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.104 2015/09/06 19:47:01 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@@ -172,6 +172,8 @@ c_list(bool multi)
return (t);
}
static const char IONDELIM_delim[] = { CHAR, '<', CHAR, '<', EOS };
static struct ioword *
synio(int cf)
{
@@ -189,15 +191,19 @@ synio(int cf)
return (NULL);
ACCEPT;
iop = yylval.iop;
if (iop->ioflag & IONDELIM)
goto gotnulldelim;
ishere = (iop->ioflag & IOTYPE) == IOHERE;
musthave(LWORD, ishere ? HEREDELIM : 0);
if (iop->ioflag & IOHERESTR) {
musthave(LWORD, 0);
} else if (ishere && tpeek(HEREDELIM) == '\n') {
ACCEPT;
yylval.cp = wdcopy(IONDELIM_delim, ATEMP);
iop->ioflag |= IOEVAL | IONDELIM;
} else
musthave(LWORD, ishere ? HEREDELIM : 0);
if (ishere) {
iop->delim = yylval.cp;
if (*ident != 0) {
if (*ident != 0 && !(iop->ioflag & IOHERESTR)) {
/* unquoted */
gotnulldelim:
iop->ioflag |= IOEVAL;
}
if (herep > &heres[HERES - 1])