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:
18
syn.c
18
syn.c
@@ -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])
|
||||
|
Reference in New Issue
Block a user