Enable unsetting env vars with Esetenv().
SVN revision: 22282
This commit is contained in:
parent
980de43afc
commit
0a4c0153e0
|
@ -69,7 +69,7 @@ AC_CHECK_FUNCS(mkdir)
|
|||
AC_CHECK_FUNCS(snprintf)
|
||||
AM_CONDITIONAL(USE_ESNPRINTF, test "x$ac_cv_func_snprintf" != "xyes")
|
||||
AC_CHECK_FUNCS(strcasecmp)
|
||||
AC_CHECK_FUNCS(setenv)
|
||||
AC_CHECK_FUNCS(setenv unsetenv)
|
||||
AC_CHECK_FUNCS(strdup strndup)
|
||||
|
||||
AC_CHECK_FUNCS(blumfrub)
|
||||
|
|
14
src/main.c
14
src/main.c
|
@ -231,12 +231,12 @@ main(int argc, char **argv)
|
|||
ThemePathFind();
|
||||
|
||||
/* Set the Environment variables */
|
||||
Esetenv("EVERSION", e_wm_version, 1);
|
||||
Esetenv("EROOT", EDirRoot(), 1);
|
||||
Esetenv("EBIN", EDirBin(), 1);
|
||||
Esetenv("ECONFDIR", EDirUser(), 1);
|
||||
Esetenv("ECACHEDIR", EDirUserCache(), 1);
|
||||
Esetenv("ETHEME", Mode.theme.path, 1);
|
||||
Esetenv("EVERSION", e_wm_version);
|
||||
Esetenv("EROOT", EDirRoot());
|
||||
Esetenv("EBIN", EDirBin());
|
||||
Esetenv("ECONFDIR", EDirUser());
|
||||
Esetenv("ECACHEDIR", EDirUserCache());
|
||||
Esetenv("ETHEME", Mode.theme.path);
|
||||
|
||||
/* Unmap the clients */
|
||||
MapUnmap(0);
|
||||
|
@ -510,7 +510,7 @@ EConfNameSet(const char *name)
|
|||
if (Mode.conf.name)
|
||||
Efree(Mode.conf.name);
|
||||
Mode.conf.name = Estrdup(name);
|
||||
Esetenv("ECONFNAME", Mode.conf.name, 1);
|
||||
Esetenv("ECONFNAME", Mode.conf.name);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
28
src/memory.c
28
src/memory.c
|
@ -296,13 +296,27 @@ StrlistFromString(const char *str, int delim, int *num)
|
|||
return lst;
|
||||
}
|
||||
|
||||
#if !USE_LIBC_SETENV
|
||||
int
|
||||
Esetenv(const char *name, const char *value, int overwrite __UNUSED__)
|
||||
void
|
||||
Esetenv(const char *name, const char *value)
|
||||
{
|
||||
char envvar[FILEPATH_LEN_MAX];
|
||||
if (value)
|
||||
{
|
||||
#if HAVE_SETENV
|
||||
setenv(name, value, 1);
|
||||
#else
|
||||
char buf[FILEPATH_LEN_MAX];
|
||||
|
||||
Esnprintf(envvar, FILEPATH_LEN_MAX, "%s=%s", name, value);
|
||||
return putenv(Estrdup(envvar));
|
||||
}
|
||||
Esnprintf(buf, FILEPATH_LEN_MAX, "%s=%s", name, value);
|
||||
putenv(Estrdup(buf));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if HAVE_UNSETENV
|
||||
unsetenv(name);
|
||||
#else
|
||||
if (getenv(name))
|
||||
putenv((char *)name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ SetupX(const char *dstr)
|
|||
}
|
||||
|
||||
Mode.display.name = Estrdup(DisplayString(disp));
|
||||
Esetenv("DISPLAY", Mode.display.name, 1);
|
||||
Esetenv("DISPLAY", Mode.display.name);
|
||||
|
||||
/* set up an error handler for then E would normally have fatal X errors */
|
||||
XSetErrorHandler((XErrorHandler) HandleXError);
|
||||
|
@ -234,7 +234,7 @@ SetupX(const char *dstr)
|
|||
|
||||
/* Enable eesh and edox to pix up the virtual root */
|
||||
Esnprintf(buf, sizeof(buf), "%#lx", VRoot.win);
|
||||
Esetenv("ENL_WM_ROOT", buf, 1);
|
||||
Esetenv("ENL_WM_ROOT", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
11
src/util.h
11
src/util.h
|
@ -40,9 +40,6 @@
|
|||
#if HAVE_STRNDUP
|
||||
#define USE_LIBC_STRNDUP 1 /* Use libc strndup if present */
|
||||
#endif
|
||||
#if HAVE_SETENV
|
||||
#define USE_LIBC_SETENV 1 /* Use libc setenv if present */
|
||||
#endif
|
||||
|
||||
/* memory.c */
|
||||
#define Ecalloc calloc
|
||||
|
@ -69,12 +66,6 @@ char *Estrndup(const char *s, int n);
|
|||
|
||||
char *Estrdupcat2(char *ss, const char *s1, const char *s2);
|
||||
|
||||
#if USE_LIBC_SETENV
|
||||
#define Esetenv setenv
|
||||
#else
|
||||
int Esetenv(const char *name, const char *value, int overwrite);
|
||||
#endif
|
||||
|
||||
char **StrlistDup(char **lst, int num);
|
||||
void StrlistFree(char **lst, int num);
|
||||
char *StrlistJoin(char **lst, int num);
|
||||
|
@ -83,6 +74,8 @@ char *StrlistEncodeEscaped(char *buf, int len, char **lst,
|
|||
char **StrlistDecodeEscaped(const char *str, int *pnum);
|
||||
char **StrlistFromString(const char *str, int delim, int *num);
|
||||
|
||||
void Esetenv(const char *name, const char *value);
|
||||
|
||||
/* misc.c */
|
||||
void __PRINTF__ Eprintf(const char *fmt, ...);
|
||||
|
||||
|
|
Loading…
Reference in New Issue