diff options
-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() + |