From 4f36fcd2c105008014364131c48f7001597bdcf7 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Wed, 19 Jun 2013 18:51:16 +0200 Subject: [PATCH] avoid duplicate conflict branches --- src/backends/lr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backends/lr.c b/src/backends/lr.c index 392d3f64..4ab53bce 100644 --- a/src/backends/lr.c +++ b/src/backends/lr.c @@ -170,11 +170,19 @@ HLRAction *h_lr_conflict(HArena *arena, HLRAction *action, HLRAction *new) action->type = HLR_CONFLICT; action->branches = h_slist_new(arena); h_slist_push(action->branches, old); + h_slist_push(action->branches, new); + } else { + // check if 'new' is already among branches + HSlistNode *x; + for(x=action->branches->head; x; x=x->next) { + if(x->elem == new) + break; + } + // add 'new' if it is not already in list + if(x == NULL) + h_slist_push(action->branches, new); } - assert(action->type == HLR_CONFLICT); - h_slist_push(action->branches, new); - return action; } -- GitLab