search for: readtoken

Displaying 14 results from an estimated 14 matches for "readtoken".

Did you mean: readtoken1
2019 Jan 25
0
[klibc:update-dash] [PARSER] Simplify EOF/newline handling in list parser
.../parser.c +++ b/usr/dash/parser.c @@ -135,19 +135,13 @@ static inline int realeofmark(const char *eofmark) union node * parsecmd(int interact) { - int t; - tokpushback = 0; + checkkwd = 0; + heredoclist = 0; doprompt = interact; if (doprompt) setprompt(doprompt); needprompt = 0; - t = readtoken(); - if (t == TEOF) - return NEOF; - if (t == TNL) - return NULL; - tokpushback++; return list(1); } @@ -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;...
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Simplify EOF/newline handling in list parser
.../parser.c +++ b/usr/dash/parser.c @@ -135,19 +135,13 @@ static inline int realeofmark(const char *eofmark) union node * parsecmd(int interact) { - int t; - tokpushback = 0; + checkkwd = 0; + heredoclist = 0; doprompt = interact; if (doprompt) setprompt(doprompt); needprompt = 0; - t = readtoken(); - if (t == TEOF) - return NEOF; - if (t == TNL) - return NULL; - tokpushback++; return list(1); } @@ -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;...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Do not push token back before parseheredoc
...+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 resetting the tokpushback flag. This patch fixes it by doing the tokpushback after parseheredoc and setting lasttoken again if parseheredoc...
2019 Jan 25
0
[klibc:update-dash] parser: use pgetc_eatbnl() in more places
...----------------------- 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__((__noreturn__)); @@ -656,8 +657,10 @@ parseheredoc(void) if (need...
2020 Mar 28
0
[klibc:update-dash] dash: parser: use pgetc_eatbnl() in more places
...----------------------- 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__((__noreturn__)); @@ -656,8 +657,10 @@ parseheredoc(void) if (need...
2019 Jan 25
0
[klibc:update-dash] [SHELL] Optimize dash -c "command" to avoid a fork
...\"" last "\","; last = $3} END{print " \"" last "\"\n};"}' diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 6e076a59..572cbcd5 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -64,7 +64,7 @@ */ /* values returned by readtoken */ -#include "token.h" +#include "token_vars.h" @@ -86,7 +86,7 @@ struct heredoc *heredoclist; /* list of here documents to read */ int doprompt; /* if set, prompt the user */ int needprompt; /* true if interactive and at start of line */ int lasttoken; /* last to...
2020 Mar 28
0
[klibc:update-dash] dash: [SHELL] Optimize dash -c "command" to avoid a fork
...\"" last "\","; last = $3} END{print " \"" last "\"\n};"}' diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 6e076a59..572cbcd5 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -64,7 +64,7 @@ */ /* values returned by readtoken */ -#include "token.h" +#include "token_vars.h" @@ -86,7 +86,7 @@ struct heredoc *heredoclist; /* list of here documents to read */ int doprompt; /* if set, prompt the user */ int needprompt; /* true if interactive and at start of line */ int lasttoken; /* last to...
2019 Jan 25
0
[klibc:update-dash] parser: Fix incorrect eating of backslash newlines
...53,11 @@ static int pgetc_eatbnl(void) return c; } +static int pgetc_top(struct synstack *stack) +{ + return stack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl(); +} + static void synstack_push(struct synstack **stack, struct synstack *next, const char *syntax) { @@ -915,7 +920,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) attyline(); if (synstack->syntax == BASESYNTAX) return readtoken(); - c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl(); + c = pgetc_top(synstack); goto loop; } #endif @@ -929,7 +934,7 @@ readtoken1(int first...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Fix incorrect eating of backslash newlines
...53,11 @@ static int pgetc_eatbnl(void) return c; } +static int pgetc_top(struct synstack *stack) +{ + return stack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl(); +} + static void synstack_push(struct synstack **stack, struct synstack *next, const char *syntax) { @@ -915,7 +920,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) attyline(); if (synstack->syntax == BASESYNTAX) return readtoken(); - c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl(); + c = pgetc_top(synstack); goto loop; } #endif @@ -929,7 +934,7 @@ readtoken1(int first...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Save/restore here-documents in command substitution
...str = NULL; @@ -1432,6 +1433,9 @@ done: *nlpp = (struct nodelist *)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 - */ -...
2012 Oct 01
0
[klibc:master] Avoid overflow for very long variable name
...#5 0x000000000040c970 in ckmalloc (nbytes=18446744071562067984) at memalloc.c:57 #6 0x000000000040ca78 in stalloc (nbytes=18446744071562067972) at memalloc.c:132 #7 0x000000000040ece9 in grabstackblock (len=18446744071562067972) at memalloc.h:67 #8 0x00000000004106b5 in readtoken1 (firstc=118, syntax=0x419522 "", eofmark=0x0, striptabs=0) at parser.c:1040 #9 0x00000000004101a4 in xxreadtoken () at parser.c:826 #10 0x000000000040fe1d in readtoken () at parser.c:697 #11 0x000000000040edcc in parsecmd (interact=0) at parser.c:145 #12 0x000000000040c679...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Fix old-style command substitution here-document crash
...d-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/parser.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: Add syntax stack for recursive parsing
...nstack *next, + const char *syntax) +{ + memset(next, 0, sizeof(*next)); + next->syntax = syntax; + next->next = *stack; + (*stack)->prev = next; + *stack = next; +} + +static void synstack_pop(struct synstack **stack) +{ + *stack = (*stack)->next; +} + /* @@ -870,24 +897,15 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) size_t len; struct nodelist *bqlist; int quotef; - int dblquote; - int varnest; /* levels of variables expansion */ - int arinest; /* levels of arithmetic expansion */ - int parenlevel; /* levels of parens in arithmetic */ - int d...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Add syntax stack for recursive parsing
...nstack *next, + const char *syntax) +{ + memset(next, 0, sizeof(*next)); + next->syntax = syntax; + next->next = *stack; + (*stack)->prev = next; + *stack = next; +} + +static void synstack_pop(struct synstack **stack) +{ + *stack = (*stack)->next; +} + /* @@ -870,24 +897,15 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) size_t len; struct nodelist *bqlist; int quotef; - int dblquote; - int varnest; /* levels of variables expansion */ - int arinest; /* levels of arithmetic expansion */ - int parenlevel; /* levels of parens in arithmetic */ - int d...