simplify C-sytle code

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21935 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2007-12-03 06:40:51 +00:00
parent be0895b664
commit dbda8edf6d

View File

@ -18,7 +18,6 @@
#include "support/os.h"
#include <boost/tokenizer.hpp>
#include <boost/shared_array.hpp>
#include <cstdlib>
#include <map>
@ -67,16 +66,9 @@ bool setEnv(string const & name, string const & value)
#if defined (HAVE_SETENV)
return ::setenv(name.c_str(), encoded.c_str(), true);
#elif defined (HAVE_PUTENV)
static std::map<string, boost::shared_array<char> > varmap;
string envstr = name + '=' + encoded;
boost::shared_array<char> newptr(new char[envstr.size() + 1]);
envstr.copy(newptr.get(), envstr.length());
newptr.get()[envstr.length()] = '\0';
bool const retval = ::putenv(newptr.get()) == 0;
varmap[name] = newptr;
return retval;
static std::map<string, string> varmap;
varmap[name] = name + '=' + encoded;
return ::putenv(varmap[name].c_str()) == 0;
#else
#error No environment-setting function has been defined.
#endif