wdvi

network DVI viewer
Log | Files | Refs

commit c6b47409852504a95862b744d28f4b0f5af4d40f
parent 58600d720afbae4b7998113d996e5ee834eeef95
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Thu, 19 Aug 2021 18:22:53 +0000

assume we have setenv and use it

Use setenv() instead of putenv() by default as it looks like the saner
interface of the two.

Diffstat:
Mutil.c | 56--------------------------------------------------------
1 file changed, 0 insertions(+), 56 deletions(-)

diff --git a/util.c b/util.c @@ -277,70 +277,14 @@ alloc_bitmap(bitmap) /* * Put a variable in the environment or abort on error. */ - -extern char **environ; - void xputenv(var, value) const char *var; const char *value; { - -#if HAVE_PUTENV - - char *buf; - int len1, len2; - - len1 = strlen(var); - len2 = strlen(value) + 1; - buf = xmalloc((unsigned int) len1 + len2 + 1); - bcopy(var, buf, len1); - buf[len1++] = '='; - bcopy(value, buf + len1, len2); - if (putenv(buf) != 0) - oops("! Failure in setting environment variable."); - return; - -#elif HAVE_SETENV - if (setenv(var, value, True) != 0) oops("! Failure in setting environment variable."); return; - -#else /* not HAVE_{PUTENV,SETENV} */ - - int len1; - int len2; - char *buf; - char **linep; - static Boolean did_malloc = False; - - len1 = strlen(var); - len2 = strlen(value) + 1; - buf = xmalloc((unsigned int) len1 + len2 + 1); - bcopy(var, buf, len1); - buf[len1++] = '='; - bcopy(value, buf + len1, len2); - for (linep = environ; *linep != NULL; ++linep) - if (memcmp(*linep, buf, len1) == 0) { - *linep = buf; - return; - } - len1 = linep - environ; - if (did_malloc) - environ = xrealloc(environ, - (unsigned int) (len1 + 2) * sizeof(char *)); - else { - linep = xmalloc((unsigned int)(len1 + 2) * sizeof(char *)); - bcopy((char *) environ, (char *) linep, len1 * sizeof(char *)); - environ = linep; - did_malloc = True; - } - environ[len1++] = buf; - environ[len1] = NULL; - -#endif /* not HAVE_{PUTENV,SETENV} */ - } #endif /* not KPATHSEA */