From 612e8238c9ae3eaa6b47d0354b0f4cd2949a7625 Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Mon, 1 Nov 2004 12:03:45 +0000 Subject: [PATCH] * utilunix.c (mc_tmpdir): Use putenv(3) instead of setenv(3) if the latter is not available. Needed for Solaris. --- src/ChangeLog | 5 +++++ src/utilunix.c | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6e8e68977..2794b7abd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-11-01 Roland Illig + + * utilunix.c (mc_tmpdir): Use putenv(3) instead of setenv(3) if + the latter is not available. Needed for Solaris. + 2004-10-29 Pavel Tsekov * complete.c (completion_matches): Fix duplicate completion matches diff --git a/src/utilunix.c b/src/utilunix.c index 3d8a2134b..0c196161d 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -292,6 +292,16 @@ tilde_expand (const char *directory) return g_strconcat (passwd->pw_dir, PATH_SEP_STR, q, (char *) NULL); } +static void +mc_setenv (const char *name, const char *value, int overwrite_flag) +{ +#if defined(HAVE_SETENV) + setenv (name, value, overwrite_flag); +#else + if (overwrite_flag || getenv (name) == NULL) + putenv (g_strconcat (name, "=", value, (char *) NULL)); +#endif +} /* * Return the directory where mc should keep its temporary files. @@ -386,7 +396,7 @@ mc_tmpdir (void) } if (!error) - setenv ("MC_TMPDIR", tmpdir, 1); + mc_setenv ("MC_TMPDIR", tmpdir, 1); return tmpdir; }