aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/error.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-09-18 12:32:16 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-09-18 12:32:16 +0200
commitb7b98405089e69dfae0fc11e2a423860f50756e9 (patch)
treeb789182370dc4493d040dafb0bc932f69fbbd3c4 /src/error.h
parentdc417a890ad48e28e573770f2ae980af002e93cb (diff)
downloadsciteco-b7b98405089e69dfae0fc11e2a423860f50756e9.tar.gz
check that local register is not edited at the end of macro calls
* This was unsafe and could easily result in crashes, since teco_qreg_current would afterwards point to an already freed Q-Register. * Since automatically editing another register or buffer is not easy to do right, we throw an error instead.
Diffstat (limited to 'src/error.h')
-rw-r--r--src/error.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/error.h b/src/error.h
index b12ec80..03af66c 100644
--- a/src/error.h
+++ b/src/error.h
@@ -47,6 +47,7 @@ typedef enum {
TECO_ERROR_INVALIDQREG,
TECO_ERROR_QREGOPUNSUPPORTED,
TECO_ERROR_QREGCONTAINSNULL,
+ TECO_ERROR_EDITINGLOCALQREG,
TECO_ERROR_MEMLIMIT,
/** Interrupt current operation */
@@ -127,6 +128,14 @@ teco_error_qregcontainsnull_set(GError **error, const gchar *name, gsize len, gb
}
static inline void
+teco_error_editinglocalqreg_set(GError **error, const gchar *name, gsize len)
+{
+ g_autofree gchar *name_printable = teco_string_echo(name, len);
+ g_set_error(error, TECO_ERROR, TECO_ERROR_EDITINGLOCALQREG,
+ "Editing local Q-Register \"%s\" at end of macro call", name_printable);
+}
+
+static inline void
teco_error_interrupted_set(GError **error)
{
g_set_error_literal(error, TECO_ERROR, TECO_ERROR_INTERRUPTED, "Interrupted");