diff --git a/src/runtime/c/pgf/linearizer.c b/src/runtime/c/pgf/linearizer.c index 93fecc03c..d71cb1110 100644 --- a/src/runtime/c/pgf/linearizer.c +++ b/src/runtime/c/pgf/linearizer.c @@ -210,8 +210,22 @@ redo:; static PgfCncTree pgf_lzn_resolve_def(PgfLzn* lzn, PgfFunIds* lindefs, GuString s, GuPool* pool) { + PgfCncTree lit = gu_null_variant; PgfCncTree ret = gu_null_variant; + PgfCncTreeLit* clit = + gu_new_variant(PGF_CNC_TREE_LIT, + PgfCncTreeLit, + &lit, pool); + clit->lit = + gu_new_variant_i(pool, + PGF_LITERAL_STR, + PgfLiteralStr, + s); + + if (lindefs == NULL) + return lit; + int index = gu_choice_next(lzn->ch, gu_list_length(lindefs)); if (index < 0) { @@ -223,16 +237,7 @@ pgf_lzn_resolve_def(PgfLzn* lzn, PgfFunIds* lindefs, GuString s, GuPool* pool) args, 1, &ret, pool); capp->fun = gu_list_index(lindefs, index); capp->n_args = 1; - - PgfCncTreeLit* clit = - gu_new_variant(PGF_CNC_TREE_LIT, - PgfCncTreeLit, - &capp->args[0], pool); - clit->lit = - gu_new_variant_i(pool, - PGF_LITERAL_STR, - PgfLiteralStr, - s); + capp->args[0] = lit; return ret; } @@ -281,12 +286,13 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool) goto done; } case PGF_EXPR_META: { - if (ccat->lindefs == NULL) + PgfFunIds* lindefs = NULL; + if (ccat != NULL && ccat->lindefs == NULL) { goto done; + } GuString s = gu_str_string("?", pool); - - ret = pgf_lzn_resolve_def(lzn, ccat->lindefs, s, pool); + ret = pgf_lzn_resolve_def(lzn, lindefs, s, pool); goto done; } case PGF_EXPR_FUN: { @@ -295,8 +301,10 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool) PgfCncOverloadMap* overl_table = gu_map_get(lzn->concr->fun_indices, &efun->fun, PgfCncOverloadMap*); if (overl_table == NULL) { - if (ccat->lindefs == NULL) + PgfFunIds* lindefs = NULL; + if (ccat != NULL && ccat->lindefs == NULL) { goto done; + } GuPool* tmp_pool = gu_local_pool(); GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool); @@ -308,8 +316,7 @@ pgf_lzn_resolve(PgfLzn* lzn, PgfExpr expr, PgfCCat* ccat, GuPool* pool) gu_putc(']', wtr, err); GuString s = gu_string_buf_freeze(sbuf, tmp_pool); - ret = pgf_lzn_resolve_def(lzn, ccat->lindefs, s, - pool); + ret = pgf_lzn_resolve_def(lzn, lindefs, s, pool); gu_pool_free(tmp_pool); goto done; diff --git a/src/runtime/c/pgf/parser.c b/src/runtime/c/pgf/parser.c index 93a2f78e9..808938d4c 100644 --- a/src/runtime/c/pgf/parser.c +++ b/src/runtime/c/pgf/parser.c @@ -1945,7 +1945,7 @@ pgf_parser_init_state(PgfConcr* concr, PgfCId cat, size_t lin_idx, GuPool* pool) conts->outside_prob = 0; conts->ref_count = 0; gu_buf_push(conts->items, PgfItem*, NULL); - + #ifdef PGF_COUNTS_DEBUG ps->cont_full_count++; #endif