Hi,

At Wed, 2 Nov 2005 14:40:45 +0900,
Blair Zajac wrote in [ruby-core:06546]:
> > I'm not sure if it's OK to replace environ by _NSGetEnviron() since
> > this code assumes UNIX style environment variable memory map.  Could
> > anyone confirm this is OK or not for Mac OS X?
> > 
> > 							matz.
> Regarding _NSGetEnviron and the memory map, I don't know, but you're already
> using this in several places in ruby:

"UNIX style environment variable memory map" means that elements of
environ point the continuous area followes just after the area pointed
by elements of argv, and it must be visible from other processes.  If
not, using _NSGetEnviron() here has no sense completely.

BTW:

> eval.c:
> 
> #if defined(__APPLE__)
> #define environ (*_NSGetEnviron())
> #elif !defined(_WIN32) && !defined(__MACOS__) || defined(_WIN32_WCE)
> extern char **environ;
> #endif
> char **rb_origenviron;
> 
> 
> hash.c:

I guess hash.c also should use rb_origenviron.


Index: hash.c =================================================================== RCS file: /cvs/ruby/src/ruby/hash.c,v retrieving revision 1.128.2.14 diff -U2 -p -r1.128.2.14 hash.c --- hash.c 19 Jul 2005 08:25:37 -0000 1.128.2.14 +++ hash.c 2 Nov 2005 06:15:05 -0000 @@ -1608,5 +1608,5 @@ rb_hash_merge(hash1, hash2) static int path_tainted = -1; -static char **origenviron; +extern char **rb_origenviron; #ifdef _WIN32 #define GET_ENVIRON(e) (e = rb_w32_get_environ()) @@ -2476,5 +2476,4 @@ Init_Hash() #ifndef __MACOS__ /* environment variables nothing on MacOS. */ - origenviron = environ; envtbl = rb_obj_alloc(rb_cObject); rb_extend_object(envtbl, rb_mEnumerable); Index: ruby.c =================================================================== RCS file: /cvs/ruby/src/ruby/ruby.c,v retrieving revision 1.83.2.11 diff -U2 -p -r1.83.2.11 ruby.c --- ruby.c 28 Jun 2005 13:09:58 -0000 1.83.2.11 +++ ruby.c 2 Nov 2005 05:59:51 -0000 @@ -972,5 +972,5 @@ VALUE rb_argv; VALUE rb_argv0; -#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE) && !defined(DOSISH) +#if !defined(PSTAT_SETCMD) && !defined(HAVE_SETPROCTITLE) && !defined(DOSISH) && !defined(__APPLE__) static struct { char *begin, *end;
-- Nobu Nakada