search for: parseheredoc

Displaying 11 results from an estimated 11 matches for "parseheredoc".

2020 Mar 28
0
[klibc:update-dash] dash: parser: Do not push token back before parseheredoc
...94b6379eb4db14efb17de19c411ea53d778fca3 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Mon, 19 Nov 2018 18:43:58 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [klibc] dash: parser: Do not push token back before parseheredoc [ dash commit 2c3ba509eb8117894d515e8fffc94aa099f38f8a ] When we read the first token in list() we use peektoken instead of readtoken as the following code needs to use the same token again. However, this is wrong when we're in a here-document as it will clobber the saved token without reset...
2019 Jan 25
0
[klibc:update-dash] [PARSER] Simplify EOF/newline handling in list parser
...@@ -158,11 +152,27 @@ list(int nlflag) union node *n1, *n2, *n3; int tok; - checkkwd = CHKNL | CHKKWD | CHKALIAS; - if (nlflag == 2 && tokendlist[peektoken()]) - return NULL; n1 = NULL; for (;;) { + switch (peektoken()) { + case TNL: + if (!(nlflag & 1)) + break; + parseheredoc(); + return n1; + + case TEOF: + if (!n1 && (nlflag & 1)) + n1 = NEOF; + parseheredoc(); + return n1; + } + + checkkwd = CHKNL | CHKKWD | CHKALIAS; + if (nlflag == 2 && tokendlist[peektoken()]) + return n1; + nlflag |= 2; + n2 = andor(); tok = readtoken()...
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Simplify EOF/newline handling in list parser
...@@ -158,11 +152,27 @@ list(int nlflag) union node *n1, *n2, *n3; int tok; - checkkwd = CHKNL | CHKKWD | CHKALIAS; - if (nlflag == 2 && tokendlist[peektoken()]) - return NULL; n1 = NULL; for (;;) { + switch (peektoken()) { + case TNL: + if (!(nlflag & 1)) + break; + parseheredoc(); + return n1; + + case TEOF: + if (!n1 && (nlflag & 1)) + n1 = NEOF; + parseheredoc(); + return n1; + } + + checkkwd = CHKNL | CHKKWD | CHKALIAS; + if (nlflag == 2 && tokendlist[peektoken()]) + return n1; + nlflag |= 2; + n2 = andor(); tok = readtoken()...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Fix old-style command substitution here-document crash
...arser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 1f9e8ec0..4bda42e8 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -1451,9 +1451,9 @@ done: if (readtoken() != TRP) synexpect(TRP); setinputstring(nullstr); - parseheredoc(); } + parseheredoc(); heredoclist = saveheredoclist; (*nlpp)->n = n;
2019 Jan 25
0
[klibc:update-dash] parser: use pgetc_eatbnl() in more places
...--- usr/dash/parser.c | 59 ++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 382658e7..8b945e36 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -106,6 +106,7 @@ STATIC void parseheredoc(void); STATIC int peektoken(void); STATIC int readtoken(void); STATIC int xxreadtoken(void); +STATIC int pgetc_eatbnl(); STATIC int readtoken1(int, char const *, char *, int); STATIC void synexpect(int) __attribute__((__noreturn__)); STATIC void synerror(const char *) __attribute__((__noretur...
2020 Mar 28
0
[klibc:update-dash] dash: parser: use pgetc_eatbnl() in more places
...--- usr/dash/parser.c | 59 ++++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 382658e7..8b945e36 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -106,6 +106,7 @@ STATIC void parseheredoc(void); STATIC int peektoken(void); STATIC int readtoken(void); STATIC int xxreadtoken(void); +STATIC int pgetc_eatbnl(); STATIC int readtoken1(int, char const *, char *, int); STATIC void synexpect(int) __attribute__((__noreturn__)); STATIC void synerror(const char *) __attribute__((__noretur...
2019 Jan 25
0
[klibc:update-dash] [PARSER] Removed unnecessary pungetc on EOF from parser
...;ben at decadent.org.uk> --- usr/dash/parser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index f6c43be0..f0c919d5 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -208,8 +208,6 @@ list(int nlflag) case TEOF: if (heredoclist) parseheredoc(); - else - pungetc(); /* push back EOF on input */ tokpushback++; return n1; default:
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Removed unnecessary pungetc on EOF from parser
...;ben at decadent.org.uk> --- usr/dash/parser.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index f6c43be0..f0c919d5 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -208,8 +208,6 @@ list(int nlflag) case TEOF: if (heredoclist) parseheredoc(); - else - pungetc(); /* push back EOF on input */ tokpushback++; return n1; default:
2020 Mar 28
0
[klibc:update-dash] dash: parser: Save/restore here-documents in command substitution
...)stalloc(sizeof (struct nodelist)); (*nlpp)->next = NULL; + saveheredoclist = heredoclist; + heredoclist = NULL; + if (oldstyle) { saveprompt = doprompt; doprompt = 0; @@ -1444,17 +1448,18 @@ done: else { if (readtoken() != TRP) synexpect(TRP); + setinputstring(nullstr); + parseheredoc(); } + heredoclist = saveheredoclist; + (*nlpp)->n = n; - if (oldstyle) { - /* - * Start reading from old file again, ignoring any pushed back - * tokens left from the backquote parsing - */ - popfile(); + /* Start reading from old file again. */ + popfile(); +...
2019 Jan 25
0
[klibc:update-dash] [SHELL] Optimize dash -c "command" to avoid a fork
.../ int lasttoken; /* last token read */ -MKINIT int tokpushback; /* last token pushed back */ +int tokpushback; /* last token pushed back */ char *wordtext; /* text of last word returned by readtoken */ int checkkwd; struct nodelist *backquotelist; @@ -210,6 +210,7 @@ list(int nlflag) parseheredoc(); else pungetc(); /* push back EOF on input */ + tokpushback++; return n1; default: if (nlflag == 1) diff --git a/usr/dash/parser.h b/usr/dash/parser.h index e6caed63..2875cce6 100644 --- a/usr/dash/parser.h +++ b/usr/dash/parser.h @@ -34,6 +34,8 @@ * @(#)parser.h 8.3 (Ber...
2020 Mar 28
0
[klibc:update-dash] dash: [SHELL] Optimize dash -c "command" to avoid a fork
.../ int lasttoken; /* last token read */ -MKINIT int tokpushback; /* last token pushed back */ +int tokpushback; /* last token pushed back */ char *wordtext; /* text of last word returned by readtoken */ int checkkwd; struct nodelist *backquotelist; @@ -210,6 +210,7 @@ list(int nlflag) parseheredoc(); else pungetc(); /* push back EOF on input */ + tokpushback++; return n1; default: if (nlflag == 1) diff --git a/usr/dash/parser.h b/usr/dash/parser.h index e6caed63..2875cce6 100644 --- a/usr/dash/parser.h +++ b/usr/dash/parser.h @@ -34,6 +34,8 @@ * @(#)parser.h 8.3 (Ber...