From 4db7d1d863cd41d200b8943980302f43967d25bf Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 20 Nov 2022 17:45:38 +0100 Subject: fixed teco_qreg_table_set_environ() on Win32: sometimes keys unexpectedly begin with an equals character * Has been observed on Windows Server 2008 with Glib 2.74.1-1, but not on the Github CI runner. --- src/qreg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qreg.c b/src/qreg.c index 6f3fdd9..e07bf9e 100644 --- a/src/qreg.c +++ b/src/qreg.c @@ -909,7 +909,19 @@ teco_qreg_table_set_environ(teco_qreg_table_t *table, GError **error) g_auto(GStrv) env = g_get_environ(); for (gchar **key = env; *key; key++) { - gchar *value = strchr(*key, '='); + const gchar *p = *key; + + /* + * FIXME: On Win32, the key sometimes starts with `=` + * which shouldn't be possible and in reality it is a `!`. + * For instance `=C:=C:\msys64`. + */ +#ifdef G_OS_WIN32 + if (G_UNLIKELY(*p == '=')) + p++; +#endif + + gchar *value = strchr(p, '='); assert(value != NULL); *value++ = '\0'; -- cgit v1.2.3