Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix build breakage on MinGW due to missing setenv
@ 2017-07-03 10:04 Anton Kolesov
  2017-07-03 11:21 ` Yao Qi
  0 siblings, 1 reply; 13+ messages in thread
From: Anton Kolesov @ 2017-07-03 10:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Anton Kolesov, Francois Bedard, Sergio Durigan Junior

Patch [1] broke a build on MinGW hosts, because MinGW doesn't provide POSIX
functions setenv () and unsetenv (), instead there is a putenv () wrapper
around WinAPI function, although with a different signature.

[1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9a6c7d9c0

gdb/ChangeLog
yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>

	* unittests/environ-selftests.c (run_tests): Use putenv on MinGW.
---
 gdb/unittests/environ-selftests.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gdb/unittests/environ-selftests.c b/gdb/unittests/environ-selftests.c
index 28b16f8..8872bfa 100644
--- a/gdb/unittests/environ-selftests.c
+++ b/gdb/unittests/environ-selftests.c
@@ -30,7 +30,11 @@ run_tests ()
 {
   /* Set a test environment variable.  This will be unset at the end
      of this function.  */
+#ifndef USE_WIN32API
   if (setenv ("GDB_SELFTEST_ENVIRON", "1", 1) != 0)
+#else
+  if (putenv ("GDB_SELFTEST_ENVIRON=1") != 0)
+#endif
     error (_("Could not set environment variable for testing."));
 
   gdb_environ env;
@@ -90,7 +94,13 @@ run_tests ()
   SELF_CHECK (num_found == 1);
 
   /* Get rid of our test variable.  */
+#ifndef USE_WIN32API
   unsetenv ("GDB_SELFTEST_ENVIRON");
+#else
+  /* putenv ("var=") has the same meaning as unsetenv ("var"), unlike the
+     setenv ("var="), which would assign an empty value.  */
+  putenv ("GDB_SELFTEST_ENVIRON=");
+#endif
 
   /* Test the case when we set a variable A, then set a variable B,
      then unset A, and make sure that we cannot find A in the environ
-- 
2.8.3


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

end of thread, other threads:[~2017-07-07  9:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-03 10:04 [PATCH] Fix build breakage on MinGW due to missing setenv Anton Kolesov
2017-07-03 11:21 ` Yao Qi
2017-07-03 15:26   ` Sergio Durigan Junior
2017-07-03 16:27     ` [PATCH] Import setenv and unsetenv from gnulib Anton Kolesov
2017-07-03 19:35       ` Sergio Durigan Junior
2017-07-04 10:20       ` Yao Qi
2017-07-04 18:06         ` Anton Kolesov
     [not found]           ` <8737ac6j91.fsf@redhat.com>
2017-07-05  9:50             ` Anton Kolesov
2017-07-06 15:34               ` Sergio Durigan Junior
2017-07-05  9:56           ` Pedro Alves
2017-07-05 10:32             ` Anton Kolesov
2017-07-07  8:24           ` Yao Qi
2017-07-07  9:35             ` Anton Kolesov

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