From a2390d266f967d37ad24a7a3b4d7f3617b5e28e1 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 3 Oct 2014 14:30:36 +1000 Subject: [PATCH] parsergen: remove special casing for pop(0). If pop() is asked to remove nothing from the stack, it now does exactly the right thing and returns the value that we want. So some special-casing can be removed. Signed-off-by: NeilBrown --- csrc/parsergen.mdc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index cdcd942..7ac1e0b 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2561,8 +2561,6 @@ collects a summary of the indents in the symbols that are being removed. It is called _after_ we reduce a production, just before we `shift` the nonterminal in. -`pop` is only called if there are entries to remove, so `num` is never zero. - ###### parser functions static int pop(struct parser *p, int num, @@ -2745,13 +2743,8 @@ since the last state which could have been at the start of a line. bufsize = do_reduce(prod, body, config, buf); - if (size) - indents = pop(&p, size, &start_of_line, - do_free); - else { - indents = 0; - start_of_line = 0; - } + indents = pop(&p, size, &start_of_line, + do_free); res = memdup(buf, bufsize); memset(buf, 0, bufsize); if (!shift(&p, nextstate->reduce_sym, @@ -2815,8 +2808,7 @@ since the last state which could have been at the start of a line. tos->indents += indents; } free(tk); - if (p.tos) - pop(&p, p.tos, NULL, do_free); + pop(&p, p.tos, NULL, do_free); free(p.asn_stack); free(p.stack); return ret; -- 2.43.0