# HG changeset patch # User John W. Eaton # Date 1383024486 14400 # Node ID 4155838569715b2bfd242246c8ddf797d68e8a41 # Parent 175b392e91fe2a2b6f90a9b6c30cf1755f3c120f undo 7b305b36b87e to avoid Windows putenv/setenv failure (bug #40381) This change may reintroduce a memory leak issue, but at least it works. * bootstrap.conf (gnulib_modules): Remove setenv from the list. * lo-utils.cc (octave_putenv): Use gnulib::putenv instead of gnulib::setenv. diff -r 175b392e91fe -r 415583856971 bootstrap.conf --- a/bootstrap.conf Mon Oct 28 19:51:46 2013 -0700 +++ b/bootstrap.conf Tue Oct 29 01:28:06 2013 -0400 @@ -70,7 +70,6 @@ round roundf select - setenv sigaction signal sigprocmask diff -r 175b392e91fe -r 415583856971 liboctave/util/lo-utils.cc --- a/liboctave/util/lo-utils.cc Mon Oct 28 19:51:46 2013 -0700 +++ b/liboctave/util/lo-utils.cc Tue Oct 29 01:28:06 2013 -0400 @@ -26,7 +26,6 @@ #endif #include -#include #include #include #include @@ -88,12 +87,26 @@ return tmp; } +// This function was adapted from xputenv from Karl Berry's kpathsearch +// library. + +// FIXME -- make this do the right thing if we don't have a +// SMART_PUTENV. + void octave_putenv (const std::string& name, const std::string& value) { - if (gnulib::setenv (name.c_str (), value.c_str (), true) < 0) - (*current_liboctave_error_handler) ("putenv: %s", - gnulib::strerror (errno)); + int new_len = name.length () + value.length () + 2; + + char *new_item = static_cast (gnulib::malloc (new_len)); + + sprintf (new_item, "%s=%s", name.c_str (), value.c_str ()); + + // As far as I can see there's no way to distinguish between the + // various errors; putenv doesn't have errno values. + + if (gnulib::putenv (new_item) < 0) + (*current_liboctave_error_handler) ("putenv (%s) failed", new_item); } std::string