diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-05 21:15:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-05 21:15:29 -0700 |
commit | c5de7d4df4ccd7d70a511ee45e1aa901d51efb6f (patch) | |
tree | efb8985dcd1b40866f9f67ce945898015ae08029 /lib.c | |
parent | a5f2b7e6641a5f7ebaf01dd0e9fa10200ceb4606 (diff) | |
download | txr-c5de7d4df4ccd7d70a511ee45e1aa901d51efb6f.tar.gz txr-c5de7d4df4ccd7d70a511ee45e1aa901d51efb6f.tar.bz2 txr-c5de7d4df4ccd7d70a511ee45e1aa901d51efb6f.zip |
Task #11442. Make work on MingW.
* configure: Test for environ and GetEnvironmentStrings.
* lib.c: Conditionally include <windows.h>.
(env): Implemented for POSIX and Windows with #ifdefs.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -35,6 +35,9 @@ #include <setjmp.h> #include <wchar.h> #include "config.h" +#ifdef HAVE_GETENVIRONMENTSTRINGS +#include <windows.h> +#endif #include "lib.h" #include "gc.h" #include "hash.h" @@ -2301,18 +2304,28 @@ val set_diff(val list1, val list2, val testfun, val keyfun) val env(void) { - extern char **environ; - char **iter; - if (env_list) { return env_list; } else { list_collect_decl (out, ptail); +#if HAVE_ENVIRON + extern char **environ; + char **iter = environ; - for (iter = environ; *iter != 0; iter++) + for (; *iter != 0; iter++) list_collect (ptail, string_utf8(*iter)); return env_list = out; +#elif HAVE_GETENVIRONMENTSTRINGS + wchar_t *env = GetEnvironmentStringsW(); + + for (; *env; env += wcslen(env) + 1) + list_collect (ptail, string(env)); + + return env_list = out; +#else + uw_throwf(error_s, lit("string_extend: overflow"), nao); +#endif } } |