aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/goto-commands.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-08-31 02:24:11 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-08-31 02:24:11 +0300
commit9425ad37ec95a40dc039169031259161c92cc217 (patch)
tree11525a5d372eba9feac20b6ff47ef91e5cbc3b47 /src/goto-commands.h
parente82dc6639e829490cb11267fa4a49ef97c6459ae (diff)
downloadsciteco-9425ad37ec95a40dc039169031259161c92cc217.tar.gz
support <:O>: if a label is not found, continue execution after the go-to statement
* this is a SciTECO extension - it's not in TECO-11 * Allows for select-case-like constructs with default-clauses as in :Os.^EQa$ !* default *! !s.foo! !* ... *! !s.bar! !* ... *! * Consistent with nOlabel0,label1,...$ if <n> is out of range. Unfortunately this form of computed goto is not applicable when "selecting" by strings or non-consecutive integers. * In order to continue after the <:O> statement, we must keep the program counter along with the label we were looking for. At the end of the macro, the PC is restored instead of throwing an error. * Since that would be very inefficient in loops - where potentially all iterations would result in rescanning till the end of the macro - we now store a completed-flag in the goto table. If it is set while trying to :O to an unknown label, we can just continue execution.
Diffstat (limited to 'src/goto-commands.h')
-rw-r--r--src/goto-commands.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/goto-commands.h b/src/goto-commands.h
index f4f52d5..45c68e9 100644
--- a/src/goto-commands.h
+++ b/src/goto-commands.h
@@ -16,10 +16,13 @@
*/
#pragma once
+#include <glib.h>
+
#include "parser.h"
#include "string-utils.h"
extern teco_string_t teco_goto_skip_label;
+extern gssize teco_goto_backup_pc;
TECO_DECLARE_STATE(teco_state_label);
TECO_DECLARE_STATE(teco_state_goto);