From: Jerome Guitton <guitton@adacore.com>
To: gdb-patches@sourceware.org
Cc: Jerome Guitton <guitton@adacore.com>
Subject: [mingw32] environment variables are case-insensitive on win32
Date: Thu, 24 May 2012 16:49:00 -0000 [thread overview]
Message-ID: <1337878161-20057-1-git-send-email-guitton@adacore.com> (raw)
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;
}
\f
+
+#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
next reply other threads:[~2012-05-24 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-24 16:49 Jerome Guitton [this message]
2012-05-24 17:20 ` Pedro Alves
2012-05-24 17:27 ` Jerome Guitton
2012-05-24 17:38 ` Pedro Alves
2012-05-24 17:43 ` Jerome Guitton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337878161-20057-1-git-send-email-guitton@adacore.com \
--to=guitton@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox