From 574b9c446da11baaf89551f09f951d6523eff731 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 7 Sep 2021 21:44:44 +0200 Subject: [PATCH] hush: fix var_LINENO3.tests failure function old new delta parse_and_run_string 40 62 +22 i_getch 105 102 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-3) Total: 19 bytes Signed-off-by: Denys Vlasenko --- shell/hush.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 5fafa322c..6d472337f 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -2753,6 +2753,12 @@ static int i_getch(struct in_str *i) if (ch != '\0') { i->p++; i->last_char = ch; +#if ENABLE_HUSH_LINENO_VAR + if (ch == '\n') { + G.parse_lineno++; + debug_printf_parse("G.parse_lineno++ = %u\n", G.parse_lineno); + } +#endif return ch; } return EOF; @@ -7540,11 +7546,11 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) static void parse_and_run_string(const char *s) { struct in_str input; - //IF_HUSH_LINENO_VAR(unsigned sv = G.parse_lineno;) + IF_HUSH_LINENO_VAR(unsigned sv = G.parse_lineno;) setup_string_in_str(&input, s); parse_and_run_stream(&input, '\0'); - //IF_HUSH_LINENO_VAR(G.parse_lineno = sv;) + IF_HUSH_LINENO_VAR(G.parse_lineno = sv;) } static void parse_and_run_file(HFILE *fp)