diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-04 14:30:46 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-04 14:30:46 +0100 |
commit | 0239a64c71af094908d3337042a7507e018d3eb3 (patch) | |
tree | 76e64cbe0b10a573e669dab0dd44465c198bd7e4 /src/mds-kbdc | |
parent | mds-kbdc: more compilation stuff (diff) | |
download | mds-0239a64c71af094908d3337042a7507e018d3eb3.tar.gz mds-0239a64c71af094908d3337042a7507e018d3eb3.tar.bz2 mds-0239a64c71af094908d3337042a7507e018d3eb3.tar.xz |
mds-kbdc: m + add argument count suffix to macro calls during simplification
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/mds-kbdc/compile-layout.c | 10 | ||||
-rw-r--r-- | src/mds-kbdc/simplify-tree.c | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c index 9ef5cf8..9242a76 100644 --- a/src/mds-kbdc/compile-layout.c +++ b/src/mds-kbdc/compile-layout.c @@ -644,10 +644,7 @@ static int compile_map(mds_kbdc_tree_map_t* restrict tree) static int compile_macro_call(mds_kbdc_tree_macro_call_t* restrict tree) { int bad; - size_t arg_count = 0; mds_kbdc_tree_t* arg = NULL; - mds_kbdc_tree_t* arg_; - char* full_macro_name = NULL; int saved_errno; fail_if ((arg = mds_kbdc_tree_dup(tree->arguments), arg = NULL)); @@ -655,19 +652,12 @@ static int compile_macro_call(mds_kbdc_tree_macro_call_t* restrict tree) if (bad) return 0; - for (arg_ = arg; arg_; arg_ = arg_->next) - arg_count++; - - fail_if (xasprintf(full_macro_name, "%s/%zu", tree->name, arg_count)); - /* TODO */ break_level = 0; - free(full_macro_name); mds_kbdc_tree_free(arg); return 0; FAIL_BEGIN; - free(full_macro_name); mds_kbdc_tree_free(arg); FAIL_END; } diff --git a/src/mds-kbdc/simplify-tree.c b/src/mds-kbdc/simplify-tree.c index 170c9ef..cc8ede7 100644 --- a/src/mds-kbdc/simplify-tree.c +++ b/src/mds-kbdc/simplify-tree.c @@ -218,6 +218,7 @@ static int simplify_macro_call(mds_kbdc_tree_macro_call_t* restrict tree) mds_kbdc_tree_t* argument; mds_kbdc_tree_t* dup_arguments = NULL; mds_kbdc_tree_t** here; + char* full_macro_name; size_t argument_index = 0; int saved_errno; @@ -230,16 +231,22 @@ static int simplify_macro_call(mds_kbdc_tree_macro_call_t* restrict tree) /* Copy arguments. */ if (tree->arguments == NULL) - return 0; + goto no_args; fail_if ((dup_arguments = mds_kbdc_tree_dup(tree->arguments), dup_arguments == NULL)); /* Eliminate alterations. */ for (argument = dup_arguments; argument; argument = argument->next, argument_index++) if (argument->type == C(ALTERNATION)) fail_if (eliminate_alternation((mds_kbdc_tree_t*)tree, argument, argument_index)); - mds_kbdc_tree_free(dup_arguments), dup_arguments = NULL; + /* Add argument count suffix. */ + no_args: + for (argument_index = 0, argument = tree->arguments; argument; argument = argument->next) + argument_index++; + fail_if (xasprintf(full_macro_name, "%s/%zu", tree->name, argument_index)); + free(tree->name), tree->name = full_macro_name; + /* Example of what will happend: * * my_macro([1 2] [1 2] [1 2]) ## call 1 @@ -308,6 +315,9 @@ static int simplify_macro_call(mds_kbdc_tree_macro_call_t* restrict tree) * no difference after simplify_macro_call on call 8 * * Nothings (‘.’) are removed before processing the alternations. + * + * It should also be noticed that all macro names are update to + * with the argument count suffix. */ return 0; |