diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2022-11-20 18:48:01 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2022-11-20 18:48:01 +0300 |
commit | b92d663430198b5a3a3696b684f93e39be237f78 (patch) | |
tree | d1b1dba38f0d57678f016a40aaec008208dee7ec | |
parent | 80969817fa948bfff4cdfa53acc96e7ac390af69 (diff) | |
download | sciteco-b92d663430198b5a3a3696b684f93e39be237f78.tar.gz |
teco_qreg_table_set_environ() will now use g_get_environ() instead of g_listenv()
* This is assumed to fix current Windows CI build problems caused by g_getenv() returning NULL
for keys contained in g_listenv(), which is probably a new Glib bug.
* Using g_get_environ() is more efficient since we do not have to repeatedly search
through the environment array with g_getenv().
* Windows 2000 - which supposedly relied on the old code because of its own bugs - is
no longer supported by our minimum Glib version anyway.
-rw-r--r-- | src/qreg.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -897,8 +897,6 @@ teco_qreg_table_edit_name(teco_qreg_table_t *table, const gchar *name, gsize len * Import process environment into table * by setting environment registers for every * environment variable. - * It is assumed that the table does not yet - * contain any environment register. * * In general this method is only safe to call * at startup. @@ -908,13 +906,13 @@ teco_qreg_table_edit_name(teco_qreg_table_t *table, const gchar *name, gsize len gboolean teco_qreg_table_set_environ(teco_qreg_table_t *table, GError **error) { - /* - * NOTE: Using g_get_environ() would be more efficient, - * but it appears to be broken, at least on Windows 2000. - */ - g_auto(GStrv) env = g_listenv(); + g_auto(GStrv) env = g_get_environ(); for (gchar **key = env; *key; key++) { + gchar *value = strchr(*key, '='); + assert(value != NULL); + *value++ = '\0'; + g_autofree gchar *name = g_strconcat("$", *key, NULL); /* @@ -928,8 +926,6 @@ teco_qreg_table_set_environ(teco_qreg_table_t *table, GError **error) qreg = found; } - const gchar *value = g_getenv(*key); - g_assert(value != NULL); if (!qreg->vtable->set_string(qreg, value, strlen(value), error)) return FALSE; } |