From 93e347c0fc607c7dc0c4272b948b578db253bc76 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT service" Date: Fri, 6 Feb 2009 14:57:39 +0100 Subject: [PATCH] Ticket #262: remove obsolete own putenv() implementation. Removed obsolete own putenv() implementation Signed-off-by: Slava Zanko --- configure.ac | 1 - lib/utilunix.c | 75 +--------------------------------------------------------- 2 files changed, 1 insertion(+), 75 deletions(-) diff --git a/configure.ac b/configure.ac index 082cecda4..4c7fb9cf9 100644 --- a/configure.ac +++ b/configure.ac @@ -164,7 +164,6 @@ AC_CHECK_FUNCS([\ cfgetospeed \ initgroups isascii \ memcpy memset \ - putenv \ setreuid statfs sysconf \ tcgetattr tcsetattr truncate \ ]) diff --git a/lib/utilunix.c b/lib/utilunix.c index a4a27b176..9b71718aa 100644 --- a/lib/utilunix.c +++ b/lib/utilunix.c @@ -239,17 +239,6 @@ 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. * This directory is (in Bourne shell terms) "${TMPDIR=/tmp}/mc-$USER" @@ -346,7 +335,7 @@ mc_tmpdir (void) tmpdir = buffer; if (!error) - mc_setenv ("MC_TMPDIR", tmpdir, 1); + g_setenv ("MC_TMPDIR", tmpdir, TRUE); return tmpdir; } @@ -604,68 +593,6 @@ int gettimeofday (struct timeval *tp, void *tzp) } #endif /* HAVE_GET_PROCESS_STATS */ -#ifndef HAVE_PUTENV - -/* The following piece of code was copied from the GNU C Library */ -/* And is provided here for nextstep who lacks putenv */ - -extern char **environ; - -#ifndef HAVE_GNU_LD -#define __environ environ -#endif - - -/* Put STRING, which is of the form "NAME=VALUE", in the environment. */ -int -putenv (char *string) -{ - const char *const name_end = strchr (string, '='); - register size_t size; - register char **ep; - - if (name_end == NULL){ - /* Remove the variable from the environment. */ - size = strlen (string); - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp (*ep, string, size) && (*ep)[size] == '='){ - while (ep[1] != NULL){ - ep[0] = ep[1]; - ++ep; - } - *ep = NULL; - return 0; - } - } - - size = 0; - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp (*ep, string, name_end - string) && - (*ep)[name_end - string] == '=') - break; - else - ++size; - - if (*ep == NULL){ - static char **last_environ = NULL; - char **new_environ = g_try_new (char *, size + 2); - if (new_environ == NULL) - return -1; - (void) memcpy ((void *) new_environ, (void *) __environ, - size * sizeof (char *)); - new_environ[size] = (char *) string; - new_environ[size + 1] = NULL; - g_free ((void *) last_environ); - last_environ = new_environ; - __environ = new_environ; - } - else - *ep = (char *) string; - - return 0; -} -#endif /* !HAVE_PUTENV */ - char * mc_realpath (const char *path, char resolved_path[]) { -- 2.11.4.GIT