aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-23 00:28:23 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-23 00:28:23 +0200
commit32122651bdb51006edce2be3586dd09179bed52f (patch)
tree6fa0bb17ec74693e25eebe8e05a9e04828c3c446 /src/spawn.c
parent2e097cec409182c3cb39b74489387480bf8a278f (diff)
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.
Diffstat (limited to 'src/spawn.c')
-rw-r--r--src/spawn.c10
1 files changed, 4 insertions, 6 deletions
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);