klibc-bot for Herbert Xu
2020-Mar-28 21:48 UTC
[klibc] [klibc:update-dash] dash: [PARSER] Add nlprompt/nlnoprompt helpers
Commit-ID: 25465e7d5b75f8d62d668c2e45be202111d5f027 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=25465e7d5b75f8d62d668c2e45be202111d5f027 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Mon, 29 Sep 2014 22:53:53 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [PARSER] Add nlprompt/nlnoprompt helpers [ dash commit 6df87cf1d4b7c0c490ab1803b863de10579df92e ] This patch adds the nlprompt/nlnoprompt helpers to isolate code dealing with newlines and prompting. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/parser.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index 2b07437e..f6c43be0 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -743,6 +743,19 @@ out: return (t); } +static void nlprompt(void) +{ + plinno++; + if (doprompt) + setprompt(2); +} + +static void nlnoprompt(void) +{ + plinno++; + needprompt = doprompt; +} + /* * Read the next input token. @@ -786,16 +799,13 @@ xxreadtoken(void) continue; case '\\': if (pgetc() == '\n') { - plinno++; - if (doprompt) - setprompt(2); + nlprompt(); continue; } pungetc(); goto breakloop; case '\n': - plinno++; - needprompt = doprompt; + nlnoprompt(); RETURN(TNL); case PEOF: RETURN(TEOF); @@ -837,9 +847,7 @@ static int pgetc_eatbnl(void) break; } - plinno++; - if (doprompt) - setprompt(2); + nlprompt(); } return c; @@ -913,9 +921,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) if (syntax == BASESYNTAX) goto endword; /* exit outer loop */ USTPUTC(c, out); - plinno++; - if (doprompt) - setprompt(2); + nlprompt(); c = pgetc(); goto loop; /* continue outer loop */ case CWORD: @@ -934,9 +940,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) USTPUTC('\\', out); pungetc(); } else if (c == '\n') { - plinno++; - if (doprompt) - setprompt(2); + nlprompt(); } else { if ( dblquote && @@ -1092,8 +1096,7 @@ checkend: { if (c == '\n' || c == PEOF) { c = PEOF; - plinno++; - needprompt = doprompt; + nlnoprompt(); } else { int len; @@ -1342,9 +1345,7 @@ parsebackq: { case '\\': if ((pc = pgetc()) == '\n') { - plinno++; - if (doprompt) - setprompt(2); + nlprompt(); /* * If eating a newline, avoid putting * the newline into the new character @@ -1366,8 +1367,7 @@ parsebackq: { synerror("EOF in backquote substitution"); case '\n': - plinno++; - needprompt = doprompt; + nlnoprompt(); break; default:
Possibly Parallel Threads
- [klibc:update-dash] [PARSER] Add nlprompt/nlnoprompt helpers
- [klibc:update-dash] parser: use pgetc_eatbnl() in more places
- [klibc:update-dash] dash: parser: use pgetc_eatbnl() in more places
- [klibc:update-dash] [PARSER] Simplify EOF/newline handling in list parser
- [klibc:update-dash] dash: [PARSER] Simplify EOF/newline handling in list parser