Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [mingw32] environment variables are case-insensitive on win32
@ 2012-05-24 16:49 Jerome Guitton
  2012-05-24 17:20 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Jerome Guitton @ 2012-05-24 16:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jerome Guitton

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mingw32] environment variables are case-insensitive on win32
  2012-05-24 16:49 [mingw32] environment variables are case-insensitive on win32 Jerome Guitton
@ 2012-05-24 17:20 ` Pedro Alves
  2012-05-24 17:27   ` Jerome Guitton
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2012-05-24 17:20 UTC (permalink / raw)
  To: Jerome Guitton; +Cc: gdb-patches

On 05/24/2012 05:49 PM, Jerome Guitton wrote:

> +
> +#if defined(_WIN32) || !defined(__CYGWIN__)


I think you meant:

#if defined(_WIN32) && !defined(__CYGWIN__)

?

> +#define env_var_name_ncmp(a, b, length) strnicmp (a, b, length)


We use strncasecmp everywhere else.

> +#else
> +#define env_var_name_ncmp(a, b, length) strncmp(a, b, length)
> +#endif
> +


-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mingw32] environment variables are case-insensitive on win32
  2012-05-24 17:20 ` Pedro Alves
@ 2012-05-24 17:27   ` Jerome Guitton
  2012-05-24 17:38     ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Jerome Guitton @ 2012-05-24 17:27 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves (palves@redhat.com):

> I think you meant:
> 
> #if defined(_WIN32) && !defined(__CYGWIN__)

Definitely :) Thanks for catching that.


> > +#define env_var_name_ncmp(a, b, length) strnicmp (a, b, length)
> 
> 
> We use strncasecmp everywhere else.

OK.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mingw32] environment variables are case-insensitive on win32
  2012-05-24 17:27   ` Jerome Guitton
@ 2012-05-24 17:38     ` Pedro Alves
  2012-05-24 17:43       ` Jerome Guitton
  0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2012-05-24 17:38 UTC (permalink / raw)
  To: Jerome Guitton; +Cc: gdb-patches

On 05/24/2012 06:27 PM, Jerome Guitton wrote:

> Pedro Alves (palves@redhat.com):
> 
>> > I think you meant:
>> > 
>> > #if defined(_WIN32) && !defined(__CYGWIN__)
> Definitely :) Thanks for catching that.


Maybe we need a new test.  ;-)

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [mingw32] environment variables are case-insensitive on win32
  2012-05-24 17:38     ` Pedro Alves
@ 2012-05-24 17:43       ` Jerome Guitton
  0 siblings, 0 replies; 5+ messages in thread
From: Jerome Guitton @ 2012-05-24 17:43 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves (palves@redhat.com):

> Maybe we need a new test.  ;-)

Of course :)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-24 17:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-24 16:49 [mingw32] environment variables are case-insensitive on win32 Jerome Guitton
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox