aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-30 14:27:39 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-30 14:27:39 +0300
commitbe230b5ebccde8605557eb6f8233867cc0bb2e06 (patch)
tree1b6e3cf9038061c88de4c95f5dcc0e319203206e /src
parentff2d1376a1456d5c06e208eedd9dbc65e71e81b4 (diff)
downloadsciteco-be230b5ebccde8605557eb6f8233867cc0bb2e06.tar.gz
fixup: make sure the correct PCs, pointing directly at the command that failed, get assigned to error frames
Diffstat (limited to 'src')
-rw-r--r--src/parser.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index 5d97e9d..d08b8aa 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -101,7 +101,11 @@ teco_state_end_of_macro(teco_machine_t *ctx, GError **error)
gboolean
teco_machine_main_step(teco_machine_main_t *ctx, const gchar *macro, gsize stop_pos, GError **error)
{
+ gsize last_pc = 0;
+
while (ctx->macro_pc < stop_pos) {
+ last_pc = ctx->macro_pc;
+
if (G_UNLIKELY(teco_interface_is_interrupted())) {
teco_error_interrupted_set(error);
goto error_attach;
@@ -149,7 +153,7 @@ error_attach:
* FIXME: Maybe this can be avoided altogether by passing in ctx->macro_pc
* from the callees?
*/
- teco_error_set_coord(macro, ctx->macro_pc-1);
+ teco_error_set_coord(macro, last_pc);
return FALSE;
}
@@ -214,7 +218,8 @@ teco_execute_macro(const gchar *macro, gsize macro_len,
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);
- teco_error_set_coord(macro, ctx->pc);
+ /* ctx->pc points to the character after the loop start command */
+ teco_error_set_coord(macro, ctx->pc-1);
g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
"Unterminated loop");