From 32122651bdb51006edce2be3586dd09179bed52f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 23 Aug 2026 00:28:23 +0200 Subject: introduced helper functions teco_qreg_table_get_string() and teco_qreg_table_get_integer() * Simplifies the common task of querying an integer or string from a Q-Register table. * Undefined Q-Regs are reported as TECO_ERROR_QREGUNDEF, so you can theoretically handle this case. In practice however, it requires less boilerplating to just call teco_qreg_table_find() manually. * It also doesn't make sense to use these functions when getting and setting a register at the same time as you will want to avoid repeated lookups. --- src/spawn.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/spawn.c') diff --git a/src/spawn.c b/src/spawn.c index 6289830..644bf31 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -125,10 +125,9 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error) #ifdef G_OS_WIN32 if (!(teco_ed & TECO_ED_SHELLEMU)) { - teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, "$COMSPEC", 8); - g_assert(reg != NULL); teco_string_t comspec; - if (!reg->vtable->get_string(reg, &comspec.data, &comspec.len, NULL, error)) + if (!teco_qreg_table_get_string(&teco_qreg_table_globals, "$COMSPEC", + &comspec.data, &comspec.len, error)) return NULL; if (teco_string_contains(comspec, '\0')) { teco_string_clear(&comspec); @@ -145,10 +144,9 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error) } #elif defined(G_OS_UNIX) if (!(teco_ed & TECO_ED_SHELLEMU)) { - teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, "$SHELL", 6); - g_assert(reg != NULL); teco_string_t shell; - if (!reg->vtable->get_string(reg, &shell.data, &shell.len, NULL, error)) + if (!teco_qreg_table_get_string(&teco_qreg_table_globals, "$SHELL", + &shell.data, &shell.len, error)) return NULL; if (teco_string_contains(shell, '\0')) { teco_string_clear(&shell); -- cgit v1.2.3