diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-10-04 12:04:39 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-10-04 12:04:39 +0000 |
| commit | e8335806afc45e31157937b880ff39b75c14a2cd (patch) | |
| tree | 5e3233cfdf934ff350f66d755bde759512ef5f20 /src/runtime/c/pgf/literals.c | |
| parent | 27091048ce8276cc542e909588695d273e95b087 (diff) | |
GuString is now an ordinary C string - it makes live easier. In addition PgfSymbolKS, PgfExprFun and PgfLiteralStr now keep their strings as embedded flexible arrays. The latest change gives us the same compactness as the old representation but it is a lot easier to use.
Diffstat (limited to 'src/runtime/c/pgf/literals.c')
| -rw-r--r-- | src/runtime/c/pgf/literals.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/runtime/c/pgf/literals.c b/src/runtime/c/pgf/literals.c index 7e0c664c6..ad8d900cc 100644 --- a/src/runtime/c/pgf/literals.c +++ b/src/runtime/c/pgf/literals.c @@ -39,10 +39,11 @@ pgf_match_string_lit(PgfConcr* concr, PgfItem* item, PgfToken tok, PgfExprLit, &ep->expr, pool); PgfLiteralStr *lit_str = - gu_new_variant(PGF_LITERAL_STR, - PgfLiteralStr, - &expr_lit->lit, pool); - lit_str->val = sks->token; + gu_new_flex_variant(PGF_LITERAL_STR, + PgfLiteralStr, + val, strlen(sks->token)+1, + &expr_lit->lit, pool); + strcpy(lit_str->val, sks->token); *out_ep = ep; accepted = false; @@ -185,12 +186,10 @@ pgf_match_name_lit(PgfConcr* concr, PgfItem* item, PgfToken tok, GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool); - GuString hyp = gu_str_string("-", tmp_pool); - bool iscap = false; - if (gu_string_eq(tok, hyp)) { + if (strcmp(tok, "-") == 0) { iscap = true; - } else if (!gu_string_eq(tok, gu_empty_string)) { + } else if (*tok) { GuIn* in = gu_string_in(tok, tmp_pool); iscap = iswupper(gu_in_utf8(in, err)); } @@ -218,21 +217,24 @@ pgf_match_name_lit(PgfConcr* concr, PgfItem* item, PgfToken tok, gu_new_variant(PGF_EXPR_APP, PgfExprApp, &ep->expr, pool); + GuString con = "MkSymb"; PgfExprFun *expr_fun = - gu_new_variant(PGF_EXPR_FUN, - PgfExprFun, - &expr_app->fun, pool); - expr_fun->fun = gu_str_string("MkSymb", pool); + gu_new_flex_variant(PGF_EXPR_FUN, + PgfExprFun, + fun, strlen(con)+1, + &expr_app->fun, pool); + strcpy(expr_fun->fun, con); PgfExprLit *expr_lit = gu_new_variant(PGF_EXPR_LIT, PgfExprLit, &expr_app->arg, pool); + GuString val = gu_string_buf_freeze(sbuf, tmp_pool); PgfLiteralStr *lit_str = - gu_new_variant(PGF_LITERAL_STR, - PgfLiteralStr, - &expr_lit->lit, pool); - lit_str->val = gu_string_buf_freeze(sbuf, pool); - + gu_new_flex_variant(PGF_LITERAL_STR, + PgfLiteralStr, + val, strlen(val)+1, + &expr_lit->lit, pool); + strcpy(lit_str->val, val); *out_ep = ep; } else { *out_ep = NULL; |
