aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-11-07 22:13:50 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-11-07 22:13:50 +0300
commitb016f781647ce0aec03f98cb67d743983b5d6038 (patch)
tree283b9da2359d48f83d8a51d754cea77e35089b31 /src/parser.c
parentd3a91fcd0e2326c290570463f47aca461092cab9 (diff)
downloadsciteco-b016f781647ce0aec03f98cb67d743983b5d6038.tar.gz
if a macro ends without finding a goto label, always throw a 'Label "..." not found' error
* This is important with gotos in loops as in <@O/x/> where, we would otherwise get a confusing "Unterminated loop" error. * This in particular fixes the error thrown in grosciteco.tes when encountering a new unknown command.
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/parser.c b/src/parser.c
index d08b8aa..4ee6a90 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -216,6 +216,13 @@ teco_execute_macro(const gchar *macro, gsize macro_len,
teco_loop_stack->len - macro_machine.loop_stack_fp);
}
+ if (G_UNLIKELY(teco_goto_skip_label.len > 0)) {
+ g_autofree gchar *label_printable = teco_string_echo(teco_goto_skip_label.data, teco_goto_skip_label.len);
+ g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Label \"%s\" not found", label_printable);
+ goto error_attach;
+ }
+
if (G_UNLIKELY(teco_loop_stack->len > macro_machine.loop_stack_fp)) {
const teco_loop_context_t *ctx = &g_array_index(teco_loop_stack, teco_loop_context_t, teco_loop_stack->len-1);
/* ctx->pc points to the character after the loop start command */
@@ -226,13 +233,6 @@ teco_execute_macro(const gchar *macro, gsize macro_len,
goto error_cleanup;
}
- if (G_UNLIKELY(teco_goto_skip_label.len > 0)) {
- g_autofree gchar *label_printable = teco_string_echo(teco_goto_skip_label.data, teco_goto_skip_label.len);
- g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Label \"%s\" not found", label_printable);
- goto error_attach;
- }
-
/*
* Some states (esp. commands involving a
* "lookahead") are valid at the end of a macro.