search for: pgetc

Displaying 18 results from an estimated 18 matches for "pgetc".

Did you mean: fgetc
2019 Jan 25
0
[klibc:update-dash] parser: use pgetc_eatbnl() in more places
.../?p=libs/klibc/klibc.git;a=commit;h=acd0936c5f8b4f5d94065ca46714d17e6a882cf2 Author: Harald van Dijk <harald at gigawatt.nl> AuthorDate: Thu, 8 Mar 2018 08:37:11 +0100 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] parser: use pgetc_eatbnl() in more places dash has a pgetc_eatbnl function in parser.c which skips any backslash-newline combinations. It's not used everywhere it could be. There is also some duplicated backslash-newline handling elsewhere in parser.c. Replace most of the calls to pgetc() with calls to pgetc_ea...
2020 Mar 28
0
[klibc:update-dash] dash: parser: use pgetc_eatbnl() in more places
...bs/klibc/klibc.git;a=commit;h=a4659bfa776f24f790c3ec071c5c9ef9459cdb70 Author: Harald van Dijk <harald at gigawatt.nl> AuthorDate: Thu, 8 Mar 2018 08:37:11 +0100 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: parser: use pgetc_eatbnl() in more places [ dash commit 6bbc71d84bea101370830dc3272f51c5ec1a7a78 ] dash has a pgetc_eatbnl function in parser.c which skips any backslash-newline combinations. It's not used everywhere it could be. There is also some duplicated backslash-newline handling elsewhere in parser.c. R...
2019 Jan 25
0
[klibc:update-dash] [PARSER] Handle backslash newlines properly after dollar sign
...sh/parser.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index c4eaae2b..2b07437e 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -827,6 +827,24 @@ breakloop: #undef RETURN } +static int pgetc_eatbnl(void) +{ + int c; + + while ((c = pgetc()) == '\\') { + if (pgetc() != '\n') { + pungetc(); + break; + } + + plinno++; + if (doprompt) + setprompt(2); + } + + return c; +} + /* @@ -1179,7 +1197,7 @@ parsesub: { char *p; static const char types[] = "}-+...
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Handle backslash newlines properly after dollar sign
...sh/parser.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/usr/dash/parser.c b/usr/dash/parser.c index c4eaae2b..2b07437e 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -827,6 +827,24 @@ breakloop: #undef RETURN } +static int pgetc_eatbnl(void) +{ + int c; + + while ((c = pgetc()) == '\\') { + if (pgetc() != '\n') { + pungetc(); + break; + } + + plinno++; + if (doprompt) + setprompt(2); + } + + return c; +} + /* @@ -1179,7 +1197,7 @@ parsesub: { char *p; static const char types[] = "}-+...
2019 Jan 25
0
[klibc:update-dash] [INPUT] Kill pgetc_macro
...bs/klibc/klibc.git;a=commit;h=7d9c9eed5207db8959f18272365d31093b9d2fab Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Mon, 29 Sep 2014 17:05:53 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [INPUT] Kill pgetc_macro pgetc_macro is identical to pgetc except that it's a macro and pgetc isn't. Since there is very little performance difference on modern systems it's time to kill pgetc_macro. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben a...
2020 Mar 28
0
[klibc:update-dash] dash: [INPUT] Kill pgetc_macro
...bc/klibc.git;a=commit;h=d23eb0c786db8c7816a30978609ce6351e3b8583 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Mon, 29 Sep 2014 17:05:53 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [INPUT] Kill pgetc_macro [ dash commit 339b9c0781cca7afb0964c6a655cda8ad9cf9fc2 ] pgetc_macro is identical to pgetc except that it's a macro and pgetc isn't. Since there is very little performance difference on modern systems it's time to kill pgetc_macro. Signed-off-by: Herbert Xu <herbert at gond...
2019 Jan 25
0
[klibc:update-dash] parser: Fix incorrect eating of backslash newlines
...ng of backslash newlines With the introduction of synstack->syntax, a number of references to the syntax variable was missed during the conversion. This causes backslash newlines to be incorrectly removed in single quote context. This patch also combines these calls into a new helper function pgetc_top. Fixes: ab1cecb40478 ("parser: Add syntax stack for recursive...") Reported-by: Leah Neukirchen <leah at vuxu.org> 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 | 11 ++++++++-...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Fix incorrect eating of backslash newlines
...571172898ab29430319d4a ] With the introduction of synstack->syntax, a number of references to the syntax variable was missed during the conversion. This causes backslash newlines to be incorrectly removed in single quote context. This patch also combines these calls into a new helper function pgetc_top. Fixes: ab1cecb40478 ("parser: Add syntax stack for recursive...") Reported-by: Leah Neukirchen <leah at vuxu.org> 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 | 11 ++++++++-...
2019 Jan 25
0
[klibc:update-dash] input: Allow two consecutive calls to pungetc
...dash/input.c | 30 ++++++++++++++++++++++-------- usr/dash/input.h | 12 ++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/usr/dash/input.c b/usr/dash/input.c index 6223a735..06c08d49 100644 --- a/usr/dash/input.c +++ b/usr/dash/input.c @@ -102,10 +102,20 @@ RESET { int pgetc(void) { + int c; + + if (parsefile->unget) + return parsefile->lastc[--parsefile->unget]; + if (--parsefile->nleft >= 0) - return (signed char)*parsefile->nextc++; + c = (signed char)*parsefile->nextc++; else - return preadbuffer(); + c = preadbuffer(); + + parsefile-...
2020 Mar 28
0
[klibc:update-dash] dash: input: Allow two consecutive calls to pungetc
...dash/input.c | 30 ++++++++++++++++++++++-------- usr/dash/input.h | 12 ++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/usr/dash/input.c b/usr/dash/input.c index 6223a735..06c08d49 100644 --- a/usr/dash/input.c +++ b/usr/dash/input.c @@ -102,10 +102,20 @@ RESET { int pgetc(void) { + int c; + + if (parsefile->unget) + return parsefile->lastc[--parsefile->unget]; + if (--parsefile->nleft >= 0) - return (signed char)*parsefile->nextc++; + c = (signed char)*parsefile->nextc++; else - return preadbuffer(); + c = preadbuffer(); + + parsefile-...
2019 Jan 25
0
[klibc:update-dash] [PARSER] Add nlprompt/nlnoprompt helpers
...ut: 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 @@ s...
2020 Mar 28
0
[klibc:update-dash] dash: [PARSER] Add nlprompt/nlnoprompt helpers
...ut: 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 @@ s...
2019 Jan 25
0
[klibc:update-dash] input: Move all input state into parsefile
...83,12 @@ INCLUDE "error.h" INIT { basepf.nextc = basepf.buf = basebuf; + basepf.linno = 1; } RESET { - parselleft = parsenleft = 0; /* clear input buffer */ + /* clear input buffer */ + basepf.lleft = basepf.nleft = 0; popallfiles(); } #endif @@ -131,8 +102,8 @@ RESET { int pgetc(void) { - if (--parsenleft >= 0) - return (signed char)*parsenextc++; + if (--parsefile->nleft >= 0) + return (signed char)*parsefile->nextc++; else return preadbuffer(); } @@ -158,7 +129,7 @@ preadfd(void) { int nr; char *buf = parsefile->buf; - parsenextc = buf; + pa...
2020 Mar 28
0
[klibc:update-dash] dash: input: Move all input state into parsefile
...83,12 @@ INCLUDE "error.h" INIT { basepf.nextc = basepf.buf = basebuf; + basepf.linno = 1; } RESET { - parselleft = parsenleft = 0; /* clear input buffer */ + /* clear input buffer */ + basepf.lleft = basepf.nleft = 0; popallfiles(); } #endif @@ -131,8 +102,8 @@ RESET { int pgetc(void) { - if (--parsenleft >= 0) - return (signed char)*parsenextc++; + if (--parsefile->nleft >= 0) + return (signed char)*parsefile->nextc++; else return preadbuffer(); } @@ -158,7 +129,7 @@ preadfd(void) { int nr; char *buf = parsefile->buf; - parsenextc = buf; + pa...
2019 Jan 25
0
[klibc:update-dash] input: Make preadbuffer static
...*/ -int -preadbuffer(void) +static int preadbuffer(void) { char *q; int more; diff --git a/usr/dash/input.h b/usr/dash/input.h index 775291b8..90ff6c33 100644 --- a/usr/dash/input.h +++ b/usr/dash/input.h @@ -52,7 +52,6 @@ extern char *parsenextc; /* next character in input buffer */ int pgetc(void); int pgetc2(void); -int preadbuffer(void); void pungetc(void); void pushstring(char *, void *); void popstring(void);
2020 Mar 28
0
[klibc:update-dash] dash: input: Make preadbuffer static
...*/ -int -preadbuffer(void) +static int preadbuffer(void) { char *q; int more; diff --git a/usr/dash/input.h b/usr/dash/input.h index 775291b8..90ff6c33 100644 --- a/usr/dash/input.h +++ b/usr/dash/input.h @@ -52,7 +52,6 @@ extern char *parsenextc; /* next character in input buffer */ int pgetc(void); int pgetc2(void); -int preadbuffer(void); void pungetc(void); void pushstring(char *, void *); void popstring(void);
2019 Jan 25
0
[klibc:update-dash] parser: Add syntax stack for recursive parsing
...lquote; + int varnest; /* levels of variables expansion */ + int parenlevel; /* levels of parens in arithmetic */ + int dqvarnest; /* levels of variables expansion within double quotes */ +}; + struct heredoc *heredoclist; /* list of here documents to read */ @@ -841,6 +853,21 @@ static int pgetc_eatbnl(void) return c; } +static void synstack_push(struct synstack **stack, struct synstack *next, + const char *syntax) +{ + memset(next, 0, sizeof(*next)); + next->syntax = syntax; + next->next = *stack; + (*stack)->prev = next; + *stack = next; +} + +static void synstack_pop(s...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Add syntax stack for recursive parsing
...lquote; + int varnest; /* levels of variables expansion */ + int parenlevel; /* levels of parens in arithmetic */ + int dqvarnest; /* levels of variables expansion within double quotes */ +}; + struct heredoc *heredoclist; /* list of here documents to read */ @@ -841,6 +853,21 @@ static int pgetc_eatbnl(void) return c; } +static void synstack_push(struct synstack **stack, struct synstack *next, + const char *syntax) +{ + memset(next, 0, sizeof(*next)); + next->syntax = syntax; + next->next = *stack; + (*stack)->prev = next; + *stack = next; +} + +static void synstack_pop(s...