From c251da29ddd3d22b1b5f17c60010ed198118b57b Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 4 May 2017 08:21:29 +0000 Subject: [PATCH] remove duplicate entries from the lookup index --- src/runtime/c/pgf/lookup.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/runtime/c/pgf/lookup.c b/src/runtime/c/pgf/lookup.c index ac1e14a0d..5f2b3aff3 100644 --- a/src/runtime/c/pgf/lookup.c +++ b/src/runtime/c/pgf/lookup.c @@ -76,7 +76,17 @@ pgf_lookup_index_syms(GuMap* lexicon_idx, PgfSymbols* syms, PgfProductionIdx* id for (size_t k = 0; k < n_idx; k++) { PgfProductionIdxEntry* entry = gu_buf_index(idx, PgfProductionIdxEntry, k); - gu_buf_push(funs, PgfAbsFun*, entry->papp->fun->absfun); + bool found = false; + size_t n_funs = gu_buf_length(funs); + for (size_t l = 0; l < n_funs; l++) { + PgfAbsFun* fun = gu_buf_get(funs, PgfAbsFun*, l); + if (fun == entry->papp->fun->absfun) { + found = true; + break; + } + } + if (!found) + gu_buf_push(funs, PgfAbsFun*, entry->papp->fun->absfun); } break; }