aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2022-11-20 17:45:38 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2022-11-20 17:45:38 +0100
commit4db7d1d863cd41d200b8943980302f43967d25bf (patch)
tree92bb2e0b50eb390b3d03949ba081e5b9c13ff2af
parent915f3bcb59d12c0b61267c6899e186ee3096a5b1 (diff)
downloadsciteco-4db7d1d863cd41d200b8943980302f43967d25bf.tar.gz
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.
-rw-r--r--src/qreg.c14
1 files changed, 13 insertions, 1 deletions
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';