aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-12-27 21:45:36 +0200
committerArnold D. Robbins <arnold@skeeve.com>2015-12-27 21:45:36 +0200
commit0bf047964956e90481de3941768937c4318db948 (patch)
tree50707f64a8a02087c8445781a6320023df980507 /awkgram.c
parent33c4c9e344ae2d82b3ec5bc35c48236be26724b1 (diff)
downloadegawk-0bf047964956e90481de3941768937c4318db948.tar.gz
egawk-0bf047964956e90481de3941768937c4318db948.tar.bz2
egawk-0bf047964956e90481de3941768937c4318db948.zip
Bug fix for pretty printing empty else part.
Diffstat (limited to 'awkgram.c')
-rw-r--r--awkgram.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/awkgram.c b/awkgram.c
index 8e408cac..bc91d406 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -7223,14 +7223,12 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch,
*/
INSTRUCTION *ip;
+ bool setup_else_part = true;
if (false_branch == NULL) {
false_branch = list_create(instruction(Op_no_op));
- if (elsep != NULL) { /* else { } */
- if (do_pretty_print)
- (void) list_prepend(false_branch, elsep);
- else
- bcfree(elsep);
+ if (elsep == NULL) { /* else { } */
+ setup_else_part = false;
}
} else {
/* assert(elsep != NULL); */
@@ -7238,6 +7236,9 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch,
/* avoid a series of no_op's: if .. else if .. else if .. */
if (false_branch->lasti->opcode != Op_no_op)
(void) list_append(false_branch, instruction(Op_no_op));
+ }
+
+ if (setup_else_part) {
if (do_pretty_print) {
(void) list_prepend(false_branch, elsep);
false_branch->nexti->branch_end = false_branch->lasti;