From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20899 invoked by alias); 30 Nov 2012 13:37:02 -0000 Received: (qmail 20798 invoked by uid 22791); 30 Nov 2012 13:37:00 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Nov 2012 13:36:55 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 94916CB28EC; Fri, 30 Nov 2012 14:36:58 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id K1IXYBVBTYh4; Fri, 30 Nov 2012 14:36:58 +0100 (CET) Received: from chelles.act-europe.fr (chelles.act-europe.fr [10.10.0.160]) by mel.act-europe.fr (Postfix) with ESMTP id 8082FCB28E9; Fri, 30 Nov 2012 14:36:58 +0100 (CET) Received: by chelles.act-europe.fr (Postfix, from userid 560) id 7B5C81EA005A; Fri, 30 Nov 2012 14:36:58 +0100 (CET) From: Jerome Guitton To: gdb-patches@sourceware.org Cc: Jerome Guitton Subject: [RFA/mingw32] environment variables are case-insensitive on win32 Date: Fri, 30 Nov 2012 13:37:00 -0000 Message-Id: <1354282597-22691-1-git-send-email-guitton@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00919.txt.bz2 A patch that I sent a few months ago, I think, but never got in: environment variables are case-insensitive on windows, this patch would take that into account. It would have been nice to have a configure test for that, using setenv/getenv to detect the case insensitivity. 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? I could not run the testsuite on Windows though; so I run it on x86-linux just to make sure that it had no effect on it. Note that the problem does not reproduce when GDB is run from cygwin, which makes it even harder to test. So I ended up using AdaCore's internal testsuite to validate this. 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 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/environ.c b/gdb/environ.c index 33426eb..2201926 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) strncasecmp (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.10.4