From d96c3419c6245bac4825ea017bc603d47eb7912c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 7 Dec 2014 00:44:58 +0100 Subject: mds-kbdc: typo + generate error if a function is used within a function before it has been defined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/compile-layout.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/mds-kbdc/compile-layout.c') diff --git a/src/mds-kbdc/compile-layout.c b/src/mds-kbdc/compile-layout.c index a2cb2a0..1a31b00 100644 --- a/src/mds-kbdc/compile-layout.c +++ b/src/mds-kbdc/compile-layout.c @@ -272,7 +272,7 @@ static int call_function(mds_kbdc_tree_t* restrict tree, const char* restrict na if (builtin == 0) callables_get(name, arg_count, (mds_kbdc_tree_t**)&function, &function_include_stack); if ((builtin == 0) && (function == NULL)) - FUN_ERROR(tree, ERROR, "function ‘%s/%zu’ as not been defined yet", name, arg_count); + FUN_ERROR(tree, ERROR, "function ‘%s/%zu’ has not been defined yet", name, arg_count); /* Call non-builtin function. */ @@ -473,11 +473,19 @@ static void check_function_call(const mds_kbdc_tree_t* restrict tree, const char if (*rc < 0) return; /* Check that the function is defined. */ - if (builtin_function_defined(name, arg_count) == 0) - { - callables_get(name, arg_count, &function, &_function_include_stack); - *rc |= function != NULL; - } + if (builtin_function_defined(name, arg_count)) + return; + callables_get(name, arg_count, &function, &_function_include_stack); + if (function != NULL) + return; + *rc |= 1; + NEW_ERROR(tree, ERROR, "function ‘%s/%zu’ has not been defined yet", name, arg_count); + error->start = lineoff; + error->end = lineoff + (size_t)(bracket - raw); + return; + + pfail: + *rc |= -1; } @@ -1011,7 +1019,7 @@ static int get_macro(mds_kbdc_tree_macro_call_t* restrict macro_call, get_macro_lax(macro_call->name, macro, macro_include_stack); if (*macro == NULL) { - NEW_ERROR(macro_call, ERROR, "macro ‘%s’ as not been defined yet", macro_call->name); + NEW_ERROR(macro_call, ERROR, "macro ‘%s’ has not been defined yet", macro_call->name); macro_call->processed = PROCESS_LEVEL; return 0; } -- cgit v1.2.3-70-g09d2