fix use of environ in shared library on OS X

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@8571 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-01-25 18:28:34 +00:00
parent 065f841eab
commit 25024467b9

View file

@ -23,7 +23,12 @@
#include "pbd/epa.h"
#include "pbd/strsplit.h"
#ifdef __APPLE__
#include <crt_externs.h>
#define environ (*_NSGetEnviron())
#else
extern char** environ;
#endif
using namespace PBD;
using namespace std;
@ -55,14 +60,26 @@ EnvironmentalProtectionAgency::arm ()
void
EnvironmentalProtectionAgency::save ()
{
/* do this to avoid lots of calls to _NSGetEnviron() on OS X */
char** the_environ = environ;
e.clear ();
<<<<<<< .mine
for (size_t i = 0; the_environ[i]; ++i) {
=======
if (!_envname.empty()) {
/* fetch environment from named environment variable, rather than "environ"
*/
>>>>>>> .r8570
<<<<<<< .mine
string estring = the_environ[i];
string::size_type equal = estring.find_first_of ('=');
=======
const char* estr = getenv (_envname.c_str());
>>>>>>> .r8570
if (!estr) {
return;