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/file-utils.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/file-utils.c') diff --git a/src/file-utils.c b/src/file-utils.c index 8555271..4bf5e6a 100644 --- a/src/file-utils.c +++ b/src/file-utils.c @@ -348,18 +348,13 @@ teco_file_expand_path(const gchar *path) * but this ensures that a proper path is constructed even if * it does (e.g. $HOME is changed later on). * - * FIXME: In the future, it might be possible to remove the entire register. - */ - teco_qreg_t *qreg = teco_qreg_table_find(&teco_qreg_table_globals, "$HOME", 5); - g_assert(qreg != NULL); - - /* * Getting the string should not possible to fail. * The $HOME register should not contain any null-bytes on startup, * but it may have been changed later on. */ g_auto(teco_string_t) home = {NULL, 0}; - if (!qreg->vtable->get_string(qreg, &home.data, &home.len, NULL, NULL) || + if (!teco_qreg_table_get_string(&teco_qreg_table_globals, "$HOME", + &home.data, &home.len, NULL) || teco_string_contains(home, '\0')) return g_strdup(path); g_assert(home.data != NULL); -- cgit v1.2.3