Mercurial > hg > octave-nkf
changeset 17788:415583856971
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 29 Oct 2013 01:28:06 -0400 |
parents | 175b392e91fe |
children | f2b047f9b605 |
files | bootstrap.conf liboctave/util/lo-utils.cc |
diffstat | 2 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/bootstrap.conf +++ b/bootstrap.conf @@ -70,7 +70,6 @@ round roundf select - setenv sigaction signal sigprocmask
--- a/liboctave/util/lo-utils.cc +++ b/liboctave/util/lo-utils.cc @@ -26,7 +26,6 @@ #endif #include <cctype> -#include <cerrno> #include <cstdlib> #include <cstdio> #include <cstring> @@ -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<char*> (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