aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-16 11:40:52 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-10-16 11:40:52 +0300
commitd714bb48a4b8629f6345a28bc21a24537207176b (patch)
treed605b57c182741590377edae8ced7e693000523d /src/parser.h
parentd556aee67e615b48c25861741d28d103109235e3 (diff)
downloadsciteco-d714bb48a4b8629f6345a28bc21a24537207176b.tar.gz
fixup: use teco_machine_t::must_undo instead of trying to identify the current state machine
* The previous solution was not wrong, but unnecessarily complex. We already have a flag for exactly this purpose. * Avoid redundancies by introducing teco_machine_stringbuilding_set_codepage().
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/parser.h b/src/parser.h
index 29b96b6..88de830 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -23,6 +23,7 @@
#include "sciteco.h"
#include "string-utils.h"
#include "goto.h"
+#include "undo.h"
#include "qreg.h"
/*
@@ -282,6 +283,8 @@ struct teco_machine_t {
* Whether side effects must be reverted on rubout.
* State machines created within macro calls don't have to
* even in interactive mode.
+ * In fact you MUST not revert side effects if this is FALSE
+ * as the data no longer exists on the call stack at undo-time.
*/
gboolean must_undo;
};
@@ -361,6 +364,16 @@ typedef struct teco_machine_stringbuilding_t {
void teco_machine_stringbuilding_init(teco_machine_stringbuilding_t *ctx, gunichar escape_char,
teco_qreg_table_t *locals, gboolean must_undo);
+static inline void
+teco_machine_stringbuilding_set_codepage(teco_machine_stringbuilding_t *ctx,
+ guint codepage)
+{
+ /* NOTE: This is not safe to undo in macro calls. */
+ if (ctx->parent.must_undo)
+ teco_undo_guint(ctx->codepage);
+ ctx->codepage = codepage;
+}
+
void teco_machine_stringbuilding_reset(teco_machine_stringbuilding_t *ctx);
/**