aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-09 17:02:21 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-09 17:02:21 +0100
commit437ee31fac70799f9fafc7864655283270d4fed8 (patch)
tree042a88cfe91b4c492aaedaf76945485acd434515 /src/mds-kbdc
parentm (diff)
downloadmds-437ee31fac70799f9fafc7864655283270d4fed8.tar.gz
mds-437ee31fac70799f9fafc7864655283270d4fed8.tar.bz2
mds-437ee31fac70799f9fafc7864655283270d4fed8.tar.xz
mds-kbdc: m bug fixes + more test cases
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-kbdc')
-rw-r--r--src/mds-kbdc/compile-layout.c12
-rw-r--r--src/mds-kbdc/make-tree.c1
-rw-r--r--src/mds-kbdc/variables.c3
3 files changed, 8 insertions, 8 deletions
diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c
index bd906d5..ae29046 100644
--- a/src/mds-kbdc/compile-layout.c
+++ b/src/mds-kbdc/compile-layout.c
@@ -174,7 +174,7 @@ static int let(size_t variable, const char32_t* restrict string, const mds_kbdc_
statement && (statement->processed != PROCESS_LEVEL))
{
statement->processed = PROCESS_LEVEL;
- NEW_ERROR(statement, WARNING, "does not shadow existing definition");/* TODO test */
+ NEW_ERROR(statement, WARNING, "does not shadow existing definition");
error->start = lineoff;
error->end = lineoff + (size_t)snprintf(NULL, 0, "\\%zu", variable);
}
@@ -315,7 +315,7 @@ static int call_function(mds_kbdc_tree_t* restrict tree, const char* restrict na
/* Push call stack and set parameters. */
variables_stack_push();
for (i = 0; i < arg_count; i++)
- fail_if (let(i, arguments[i], NULL, NULL, 0, 0));
+ fail_if (let(i + 1, arguments[i], NULL, NULL, 0, 0));
/* Switch include-stack to the function's. */
fail_if (our_include_stack = mds_kbdc_include_stack_save(), our_include_stack == NULL);
@@ -333,7 +333,7 @@ static int call_function(mds_kbdc_tree_t* restrict tree, const char* restrict na
/* Check that the function returned a value. */
if (*return_value == NULL)
- FUN_ERROR(tree, ERROR, "function ‘%s/%zu’ did not return a value", name, arg_count);/* TODO test */
+ FUN_ERROR(tree, ERROR, "function ‘%s/%zu’ did not return a value", name, arg_count);
goto done;
}
@@ -2410,7 +2410,7 @@ static int compile_map(mds_kbdc_tree_map_t* restrict tree)
array that is not shadowed by an inner function- or macro-call. */
if (r && !have_side_effect)
{
- NEW_ERROR(tree, ERROR, "value-statement outside function without side-effects");/* TODO test */
+ NEW_ERROR(tree, ERROR, "value-statement outside function without side-effects");
tree->processed = PROCESS_LEVEL;
}
if (have_side_effect)
@@ -2422,7 +2422,7 @@ static int compile_map(mds_kbdc_tree_map_t* restrict tree)
/* For simplicity we set `last_value_statement` on includes,
* so we are sure `last_value_statement` has the same include-stack. */
- NEW_ERROR(previous_last_value_statement, WARNING, "value-statement has no effects");/* TODO test */
+ NEW_ERROR(previous_last_value_statement, WARNING, "value-statement has no effects");
NEW_ERROR(tree, NOTE, "overridden here");
}
@@ -2469,7 +2469,7 @@ static int compile_macro_call(mds_kbdc_tree_macro_call_t* restrict tree)
fail_if (arg = mds_kbdc_tree_dup(tree->arguments), arg == NULL);
fail_if (bad = evaluate_element(arg), bad < 0);
if (bad)
- return 0;
+ return mds_kbdc_tree_free(arg), 0;
/* Get the macro's subtree and include-stack, if it has
not been defined `get_macro` will add an error message
diff --git a/src/mds-kbdc/make-tree.c b/src/mds-kbdc/make-tree.c
index 7534a40..960fe22 100644
--- a/src/mds-kbdc/make-tree.c
+++ b/src/mds-kbdc/make-tree.c
@@ -788,6 +788,7 @@ static int test_for_keyword(const char* restrict keyword)
SKIP_SPACES(end);
prev_end_char = *end, *end = '\0';
NEW_ERROR(1, ERROR, "expecting keyword ‘%s’", keyword);
+ error->end = error->start + 1;
return 0;
fail:
diff --git a/src/mds-kbdc/variables.c b/src/mds-kbdc/variables.c
index 7431767..155edd7 100644
--- a/src/mds-kbdc/variables.c
+++ b/src/mds-kbdc/variables.c
@@ -168,8 +168,7 @@ int variables_let(size_t variable, mds_kbdc_tree_t* restrict value)
{
/* Shadow or define. */
previous = variables[variable];
- variables[variable] = malloc(sizeof(variable_t));
- if (variables[variable] == NULL)
+ if (xmalloc(variables[variable], 1, variable_t))
fail_if (variables[variable] = previous, 1);
variables[variable]->value = value;
variables[variable]->previous = previous;