aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-07 00:44:58 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-07 00:44:58 +0100
commitd96c3419c6245bac4825ea017bc603d47eb7912c (patch)
tree31446ea45ffb5115666a97f5be496c00adcacec2 /src
parentmds-kbdc: check_function_calls_in_literal (diff)
downloadmds-d96c3419c6245bac4825ea017bc603d47eb7912c.tar.gz
mds-d96c3419c6245bac4825ea017bc603d47eb7912c.tar.bz2
mds-d96c3419c6245bac4825ea017bc603d47eb7912c.tar.xz
mds-kbdc: typo + generate error if a function is used within a function before it has been defined
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/mds-kbdc/compile-layout.c22
1 files changed, 15 insertions, 7 deletions
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;
}