diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-07 22:46:41 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-07 22:46:41 +0100 |
commit | 07acde13ba36189d9dfed7354d12459cb409f6b5 (patch) | |
tree | e05050912a210276e12306e41f71b7baf6286c1a | |
parent | mds-kbdc: compile-layout: bug fixes (diff) | |
download | mds-07acde13ba36189d9dfed7354d12459cb409f6b5.tar.gz mds-07acde13ba36189d9dfed7354d12459cb409f6b5.tar.bz2 mds-07acde13ba36189d9dfed7354d12459cb409f6b5.tar.xz |
mds-kbdc: test call to undefined callables and mark the entire macro call if the macro does not exist
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/mds-kbdc/compile-layout.c | 7 | ||||
-rw-r--r-- | test-files/mds-kbdc/compile-layout/invalid/call_to_undefined_macro | 2 | ||||
-rw-r--r-- | test-files/mds-kbdc/compile-layout/invalid/map-undefined_function | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c index 1eb1dfc..e9d16c5 100644 --- a/src/mds-kbdc/compile-layout.c +++ b/src/mds-kbdc/compile-layout.c @@ -1199,15 +1199,22 @@ static int get_macro(mds_kbdc_tree_macro_call_t* restrict macro_call, mds_kbdc_tree_macro_t** restrict macro, mds_kbdc_include_stack_t** restrict macro_include_stack) { + char* code = result->source_code->lines[macro_call->loc_line]; + char* end = code + strlen(code) - 1; + get_macro_lax(macro_call->name, macro, macro_include_stack); if (*macro == NULL) { NEW_ERROR(macro_call, ERROR, "macro ‘%s’ has not been defined yet", macro_call->name); + while (*end == ' ') + end--; + error->end = (size_t)(++end - code); macro_call->processed = PROCESS_LEVEL; return 0; } if ((*macro)->processed == PROCESS_LEVEL) *macro = NULL; + return 0; pfail: return -1; diff --git a/test-files/mds-kbdc/compile-layout/invalid/call_to_undefined_macro b/test-files/mds-kbdc/compile-layout/invalid/call_to_undefined_macro new file mode 100644 index 0000000..cc93330 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/call_to_undefined_macro @@ -0,0 +1,2 @@ +letter("a" "A") + diff --git a/test-files/mds-kbdc/compile-layout/invalid/map-undefined_function b/test-files/mds-kbdc/compile-layout/invalid/map-undefined_function new file mode 100644 index 0000000..8179208 --- /dev/null +++ b/test-files/mds-kbdc/compile-layout/invalid/map-undefined_function @@ -0,0 +1,2 @@ +<letter \f()> : \f() + |