Use libc setenv when available.

SVN revision: 9406
This commit is contained in:
Kim Woelders 2004-03-20 15:28:04 +00:00
parent 1e9bac844d
commit f58796573c
7 changed files with 34 additions and 26 deletions

View File

@ -342,9 +342,6 @@ main(int argc, char **argv)
exit(1);
}
}
Esetenv("DISPLAY", DisplayString(disp), 1);
Esetenv("E_DATADIR", ENLIGHTENMENT_ROOT, 1);
Esetenv("E_BINDIR", ENLIGHTENMENT_BIN, 1);
t = 16;
GetObjects(f);

View File

@ -188,13 +188,6 @@ extern Drawable vIcDrw;
typedef struct _efont Efont;
#define Esetenv(var, val, overwrite) \
{ \
static char envvar[1024]; \
sprintf(envvar, "%500s=%500s", var, val);\
putenv(envvar);\
}
typedef struct _root
{
Window win;

View File

@ -48,7 +48,9 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#define USE_STRDUP 1
#if HAVE_STRDUP
#define USE_LIBC_STRDUP 1 /* Use libc strdup if present */
#endif
#define LIST_FINDBY_NAME 0
#define LIST_FINDBY_ID 1
@ -147,7 +149,7 @@ __Emalloc(x)
__Erealloc(x, y)
#endif
#if defined(USE_STRDUP) && defined(HAVE_STRDUP)
#if USE_LIBC_STRDUP
#define Estrdup(s) ((s) ? strdup(s) : NULL)
#else
char *Estrdup(const char *s);

View File

@ -152,7 +152,7 @@ __Efree(void *ptr)
EDBUG_RETURN_;
}
#if !(defined(USE_STRDUP) && defined(HAVE_STRDUP))
#if !USE_LIBC_STRDUP
char *
Estrdup(const char *s)
{

27
src/E.h
View File

@ -26,8 +26,15 @@
#define _GNU_SOURCE
#include "config.h"
#define USE_STRDUP 1 /* Use libc strdup if present */
#define USE_STRNDUP 1 /* Use libc strndup if present */
#if HAVE_STRDUP
#define USE_LIBC_STRDUP 1 /* Use libc strdup if present */
#endif
#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
#define DEBUG_EWMH 0
#include <X11/Xlib.h>
@ -274,13 +281,6 @@ int Esnprintf(va_alist);
#endif
#endif /* HAVE_SNPRINTF */
#define Esetenv(var, val, overwrite) \
{ \
static char envvar[FILEPATH_LEN_MAX]; \
Esnprintf(envvar, FILEPATH_LEN_MAX, "%s=%s", var, val);\
putenv(envvar);\
}
/* This is a start to providing internationalization by means */
/* of gettext */
@ -2348,6 +2348,11 @@ void EdgeHandleLeave(XEvent * ev);
void EdgeHandleMotion(XEvent * ev);
void Quicksort(void **a, int l, int r,
int (*CompareFunc) (void *d1, void *d2));
#if USE_LIBC_SETENV
#define Esetenv setenv
#else
int Esetenv(const char *name, const char *value, int overwrite);
#endif
/* moveresize.c */
int ActionMoveStart(EWin * ewin, void *params, char constrained,
@ -2711,12 +2716,12 @@ __Emalloc(x, "<unknown>", 0)
__Erealloc(x, y, "<unknown>", 0)
#endif
#if defined(USE_STRDUP) && defined(HAVE_STRDUP)
#if USE_LIBC_STRDUP
#define Estrdup(s) ((s) ? strdup(s) : NULL)
#else
char *Estrdup(const char *s);
#endif
#if defined(USE_STRNDUP) && defined(HAVE_STRNDUP)
#if USE_LIBC_STRNDUP
#define Estrndup(s,n) ((s) ? strndup(s,n) : NULL)
#else
char *Estrndup(const char *s, int n);

View File

@ -391,7 +391,7 @@ __Efree(void *ptr, const char *file, int line)
}
#endif
#if !(defined(USE_STRDUP) && defined(HAVE_STRDUP))
#if !USE_LIBC_STRDUP
char *
Estrdup(const char *s)
{
@ -408,7 +408,7 @@ Estrdup(const char *s)
}
#endif
#if !(defined(USE_STRDUP) && defined(HAVE_STRNDUP))
#if !USE_LIBC_STRNDUP
char *
Estrndup(const char *s, int n)
{

View File

@ -437,3 +437,14 @@ Quicksort(void **a, int l, int r, int (*CompareFunc) (void *d1, void *d2))
Quicksort(a, i + 1, r, CompareFunc);
}
}
#if !USE_LIBC_SETENV
int
Esetenv(const char *name, const char *value, int overwrite __UNUSED__)
{
char envvar[FILEPATH_LEN_MAX];
Esnprintf(envvar, FILEPATH_LEN_MAX, "%s=%s", name, value);
return putenv(Estrdup(envvar));
}
#endif