From: Jerome Guitton <guitton@adacore.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/mingw32] environment variables are case-insensitive on win32
Date: Mon, 10 Dec 2012 15:35:00 -0000 [thread overview]
Message-ID: <20121210153510.GB17188@adacore.com> (raw)
In-Reply-To: <20121210134935.GL31477@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]
Joel Brobecker (brobecker@adacore.com):
> 1. Decide whether we want GDB to match environment variable names
> using case-sensitive or case-insensentive functions on cygwin.
> Right now, it's case-sensitive. FWIW, we are offering to change
> that behavior, and it seems more user-friencly at the moment,
> but either choice is fine with me. If no concensus can be reached
> on this, then we'll revert to the original behavior.
>
> 2. Commit Jerome's patch which implements the decision from (1),
> letting a more elaborate handling of environment variables
> as a followup patch for someone more involved in cygwin than
> we are.
At this point my feeling is that there is something to clarify for
Cygwin; the symptom being that the new test I submitted for
testenv.exp fails on this platform. But for the moment I'd be inclined
to let Cygwin's situation unchanged and let an expert handle it. The patch
that I would submit would fix mingw32 only. So I guess that would be (2).
The corresponding patch is in attachment.
[-- Attachment #2: environ.c.diff --]
[-- Type: text/x-diff, Size: 2483 bytes --]
commit 65a7d48d6ae3835fb63d2a7c6a40feee16572d95
Author: Jerome Guitton <guitton@adacore.com>
Date: Thu May 24 18:19:23 2012 +0200
environment variables are case-insensitive on mingw
gdb/ChangeLog:
* environ.c (host_has_case_sensitive_env_vars)
(env_var_name_ncmp): New functions.
(get_in_environ, set_in_environ, unset_in_environ): Use
env_var_name_ncmp instead of strncmp.
diff --git a/gdb/environ.c b/gdb/environ.c
index 33426eb..98d8ca6 100644
--- a/gdb/environ.c
+++ b/gdb/environ.c
@@ -96,6 +96,48 @@ environ_vector (struct gdb_environ *e)
return e->vector;
}
\f
+
+/* Return 1 if the names of environ variables are case sensitive
+ on host. */
+
+static int
+host_has_case_sensitive_env_vars()
+{
+ static int result = -1;
+ char *value;
+
+ if (result != -1)
+ return result;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ putenv ("__GDB_TEST_CASE_SENSITIVITY=set");
+
+#else
+ setenv ("__GDB_TEST_CASE_SENSITIVITY", "set", 1);
+#endif
+
+ value = getenv ("__GDB_test_CASE_Sensitivity");
+
+ if (value && (strcmp (value, "set") == 0))
+ result = 0;
+ else
+ result = 1;
+
+ return result;
+}
+
+/* Compare the first LENGTH characters of the names of two
+ environment variable A and B. */
+
+static int
+env_var_name_ncmp(const char *a, const char *b, int length)
+{
+ if (host_has_case_sensitive_env_vars())
+ return strncmp(a, b, length);
+ else
+ return strncasecmp (a, b, length);
+}
+
/* Return the value in environment E of variable VAR. */
char *
@@ -106,7 +148,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 +165,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 +212,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
next prev parent reply other threads:[~2012-12-10 15:35 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-30 13:37 Jerome Guitton
2012-11-30 13:47 ` Eli Zaretskii
2012-11-30 14:08 ` Jerome Guitton
2012-11-30 15:27 ` Eli Zaretskii
2012-11-30 15:34 ` Jerome Guitton
2012-11-30 16:07 ` Eli Zaretskii
2012-11-30 16:29 ` Jerome Guitton
2012-11-30 18:55 ` Eli Zaretskii
2012-12-07 9:22 ` Jerome Guitton
2012-12-07 9:30 ` Eli Zaretskii
2012-12-07 10:06 ` Jerome Guitton
2012-12-07 10:06 ` Joel Brobecker
2012-12-07 10:11 ` Jerome Guitton
2012-12-07 10:18 ` Joel Brobecker
2012-11-30 19:02 ` Pedro Alves
2012-12-03 11:31 ` Jerome Guitton
2012-12-09 23:53 ` Christopher Faylor
2012-12-10 10:51 ` Jerome Guitton
2012-12-10 11:01 ` Corinna Vinschen
2012-12-10 13:50 ` Joel Brobecker
2012-12-10 15:24 ` Corinna Vinschen
2012-12-10 15:42 ` Jerome Guitton
2012-12-10 15:58 ` Corinna Vinschen
2012-12-10 16:08 ` Jerome Guitton
2012-12-10 16:09 ` Eli Zaretskii
2012-12-10 16:17 ` Corinna Vinschen
2012-12-10 16:24 ` Eli Zaretskii
2012-12-10 16:57 ` Corinna Vinschen
2012-12-10 20:11 ` Eli Zaretskii
2012-12-11 10:20 ` Corinna Vinschen
2012-12-10 16:24 ` Jerome Guitton
2012-12-11 14:25 ` Pedro Alves
2012-12-11 14:41 ` Corinna Vinschen
2012-12-11 15:07 ` Pedro Alves
2012-12-11 15:21 ` Corinna Vinschen
2012-12-11 15:23 ` Pierre Muller
2012-12-14 10:55 ` Jerome Guitton
2012-12-14 10:35 ` Jerome Guitton
2012-12-10 15:35 ` Jerome Guitton [this message]
2012-12-10 16:09 ` Pierre Muller
2012-12-10 16:18 ` 'Jerome Guitton'
2012-12-10 16:27 ` Pierre Muller
2012-12-10 16:54 ` Corinna Vinschen
2012-12-10 18:22 ` Jerome Guitton
2012-12-10 18:35 ` Pierre Muller
2012-12-10 18:36 ` 'Jerome Guitton'
2012-12-11 9:50 ` 'Jerome Guitton'
2012-12-11 16:27 ` Christopher Faylor
[not found] ` <002401cdd6f0$c0b317b0$42194710$%muller@ics-cnrs.unistra.fr>
2012-12-10 16:26 ` Eli Zaretskii
2012-12-10 16:40 ` Pierre Muller
2012-12-10 16:51 ` Jerome Guitton
2012-12-10 17:16 ` Jerome Guitton
2012-11-30 14:43 ` Pedro Alves
2012-11-30 15:03 ` Jerome Guitton
2012-11-30 15:38 ` Jerome Guitton
2012-11-30 15:41 ` Pedro Alves
2012-11-30 15:46 ` Tom Tromey
2012-11-30 15:49 ` Pedro Alves
2012-11-30 16:02 ` 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=20121210153510.GB17188@adacore.com \
--to=guitton@adacore.com \
--cc=brobecker@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