diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-11-13 08:32:19 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-11-13 08:32:19 +0000 |
commit | 462ad8f0bf87c53383ddeffa08e1aa8146b388da (patch) | |
tree | d33cfc49b781aad50ab1b32b95318d94b4e95636 /win32 | |
parent | e4d7dbf5a35c8e4ea0de3d50c331c0753a421b32 (diff) |
* hash.c (envix): merge from 1.7: use GET_ENVIRON and FREE_ENVIRON to
get environment variables list.
* hash.c (env_keys): ditto.
* hash.c (env_each_key): ditto.
* hash.c (env_values): ditto.
* hash.c (env_keys): ditto.
* hash.c (env_each_value): ditto.
* hash.c (env_each): ditto.
* hash.c (env_inspect): ditto.
* hash.c (env_to_a): ditto.
* hash.c (env_size): ditto.
* hash.c (env_empty_p): ditto.
* hash.c (env_has_value): ditto.
* hash.c (env_index): ditto.
* hash.c (env_to_hash): ditto.
* win32/win32.c (win32_getenv): merge from 1.7: use static buffer.
* win32/win32.c, win32/win32.h (win32_get_environ): merge from 1.7:
get environment variables list.
* win32/win32.c, win32/win32.h (win32_free_environ): merge from 1.7:
free environment variables list.
* win32/Makefile.sub: merge from 1.7: add -DLIBRUBY_SO to CPPFLAGS.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile.sub | 2 | ||||
-rw-r--r-- | win32/win32.c | 44 | ||||
-rw-r--r-- | win32/win32.h | 2 |
3 files changed, 42 insertions, 6 deletions
diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 5164bc312a..65838f3160 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -38,7 +38,7 @@ AUTOCONF = autoconf prefix = /usr CFLAGS = -nologo -DNT=1 -Zi -MD -O2b2xg- -G5 -CPPFLAGS = -I$(srcdir) -I$(srcdir)/missing +CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)/missing -DLIBRUBY_SO=\"$(LIBRUBY_SO)\" LDFLAGS = $(CFLAGS) -Fm XLDFLAGS = #EXTLIBS = diff --git a/win32/win32.c b/win32/win32.c index 6d7b917aea..0309ea111e 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2524,14 +2524,16 @@ wait() char * win32_getenv(const char *name) { - char *curitem = NULL; /* XXX threadead */ - DWORD curlen = 0; /* XXX threadead */ + static char *curitem = NULL; + static DWORD curlen = 0; DWORD needlen; - curlen = 512; - curitem = ALLOC_N(char, curlen); + if (curitem == NULL || curlen == 0) { + curlen = 512; + curitem = ALLOC_N(char, curlen); + } - needlen = GetEnvironmentVariable(name,curitem,curlen); + needlen = GetEnvironmentVariable(name, curitem, curlen); if (needlen != 0) { while (needlen > curlen) { REALLOC_N(curitem, char, needlen); @@ -2961,3 +2963,35 @@ VALUE win32_asynchronize(asynchronous_func_t func, return val; } + +char **win32_get_environ(void) +{ + char *envtop, *env; + char **myenvtop, **myenv; + int num; + + envtop = GetEnvironmentStrings(); + for (env = envtop, num = 0; *env; env += strlen(env) + 1) + if (*env != '=') num++; + + myenvtop = ALLOC_N(char*, num + 1); + for (env = envtop, myenv = myenvtop; *env; env += strlen(env) + 1) { + if (*env != '=') { + *myenv = ALLOC_N(char, strlen(env) + 1); + strcpy(*myenv, env); + myenv++; + } + } + *myenv = NULL; + FreeEnvironmentStrings(envtop); + + return myenvtop; +} + +void win32_free_environ(char **env) +{ + char **t = env; + + while (*t) free(*t++); + free(env); +} diff --git a/win32/win32.h b/win32/win32.h index 4b31e94a95..f3eac8f41a 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -214,6 +214,8 @@ extern struct servent * mygetservbyname(char *, char *); extern struct servent * mygetservbyport(int, char *); extern char *win32_getenv(const char *); extern int myrename(const char *, const char *); +extern char **win32_get_environ(void); +extern void win32_free_environ(char **); extern int chown(const char *, int, int); extern int link(char *, char *); |