This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[mingw32] environment variables are case-insensitive on win32
- From: Jerome Guitton <guitton at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Jerome Guitton <guitton at adacore dot com>
- Date: Thu, 24 May 2012 18:49:21 +0200
- Subject: [mingw32] environment variables are case-insensitive on win32
Yet another idiosyncrasy of this platform. It would have been nice to
have a configure test for that, using setenv/getenv to detect the fact
that env variables are case-insensitive. Unfortunately we don't have
setenv on win32. So I ended up using _WIN32 just like we do to handle
the .exe extension. Any other idea?
gdb/ChangeLog:
* environ.c (env_var_name_ncmp): New macro.
(get_in_environ, set_in_environ, unset_in_environ): Use
env_var_name_ncmp instead of strncmp.
---
gdb/environ.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/gdb/environ.c b/gdb/environ.c
index 33426eb..9992782 100644
--- a/gdb/environ.c
+++ b/gdb/environ.c
@@ -96,6 +96,13 @@ environ_vector (struct gdb_environ *e)
return e->vector;
}
+
+#if defined(_WIN32) || !defined(__CYGWIN__)
+#define env_var_name_ncmp(a, b, length) strnicmp (a, b, length)
+#else
+#define env_var_name_ncmp(a, b, length) strncmp(a, b, length)
+#endif
+
/* Return the value in environment E of variable VAR. */
char *
@@ -106,7 +113,7 @@ get_in_environ (const struct gdb_environ *e, const char *var)
char *s;
for (; (s = *vector) != NULL; vector++)
- if (strncmp (s, var, len) == 0 && s[len] == '=')
+ if (env_var_name_ncmp (s, var, len) == 0 && s[len] == '=')
return &s[len + 1];
return 0;
@@ -123,7 +130,7 @@ set_in_environ (struct gdb_environ *e, const char *var, const char *value)
char *s;
for (i = 0; (s = vector[i]) != NULL; i++)
- if (strncmp (s, var, len) == 0 && s[len] == '=')
+ if (env_var_name_ncmp (s, var, len) == 0 && s[len] == '=')
break;
if (s == 0)
@@ -170,7 +177,7 @@ unset_in_environ (struct gdb_environ *e, char *var)
for (; (s = *vector) != NULL; vector++)
{
- if (strncmp (s, var, len) == 0 && s[len] == '=')
+ if (env_var_name_ncmp (s, var, len) == 0 && s[len] == '=')
{
xfree (s);
/* Walk through the vector, shuffling args down by one, including
--
1.7.0.2