From 25024467b97d2bf3f7a06358bde107ada4d4db41 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 25 Jan 2011 18:28:34 +0000 Subject: 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 --- libs/pbd/epa.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libs') diff --git a/libs/pbd/epa.cc b/libs/pbd/epa.cc index 3d3f7477d7..a12dc961a9 100644 --- a/libs/pbd/epa.cc +++ b/libs/pbd/epa.cc @@ -23,7 +23,12 @@ #include "pbd/epa.h" #include "pbd/strsplit.h" +#ifdef __APPLE__ +#include +#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; -- cgit v1.2.3