From 618170baf3dc7295d157ab0ae891488744868719 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Mon, 29 Sep 2008 21:16:41 +0200 Subject: [PATCH] HP-UX port: unsetenv() might not exist --- config.h.in | 5 ++++- configure.in | 3 +++ sycls.c | 2 ++ sysutils.c | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config.h.in b/config.h.in index 259a942..46d12c6 100644 --- a/config.h.in +++ b/config.h.in @@ -331,7 +331,7 @@ /* Define if you have struct ifreq.ifr_index */ #undef HAVE_STRUCT_IFREQ_IFR_INDEX -/* Define if you have struct ifreq.ifr_ifindex */ +/* Define if you have struct ifreq.ifr_ifindex; not on HPUX */ #undef HAVE_STRUCT_IFREQ_IFR_IFINDEX /* Define if your struct sockaddr has sa_len */ @@ -364,6 +364,9 @@ /* Define if you have the setenv function */ #undef HAVE_SETENV +/* Define if you have the unsetenv function. not on HP-UX */ +#undef HAVE_UNSETENV + /* Define if you have the flock function */ #undef HAVE_FLOCK diff --git a/configure.in b/configure.in index b84d510..61dd284 100644 --- a/configure.in +++ b/configure.in @@ -1198,6 +1198,9 @@ dnl Search for setenv() AC_CHECK_FUNC(setenv, AC_DEFINE(HAVE_SETENV), AC_CHECK_LIB(isode, setenv, [LIBS="-lisode $LIBS"])) +dnl Search for unsetenv() +AC_CHECK_FUNC(unsetenv, AC_DEFINE(HAVE_UNSETENV)) + dnl Run time checks diff --git a/sycls.c b/sycls.c index e9b004f..fa9f1f9 100644 --- a/sycls.c +++ b/sycls.c @@ -1459,6 +1459,7 @@ int Setenv(const char *name, const char *value, int overwrite) { return result; } +#if HAVE_UNSETENV /* on Linux it returns int but on FreeBSD void. we do not expect many errors, so we take void which works on all systems. */ void Unsetenv(const char *name) { @@ -1470,6 +1471,7 @@ void Unsetenv(const char *name) { errno = _errno; return; } +#endif #if WITH_READLINE diff --git a/sysutils.c b/sysutils.c index ed1a1fa..f9512e7 100644 --- a/sysutils.c +++ b/sysutils.c @@ -550,7 +550,9 @@ int xiosetenv(const char *varname, const char *value, int overwrite) { if (Setenv(envname, value, overwrite) < 0) { Warn3("setenv(\"%s\", \"%s\", 1): %s", envname, value, strerror(errno)); +#if HAVE_UNSETENV Unsetenv(envname); /* dont want to have a wrong value */ +#endif return -1; } return 0; @@ -579,7 +581,9 @@ int xiosetenv2(const char *varname, const char *varname2, const char *value, if (Setenv(envname, value, overwrite) < 0) { Warn3("setenv(\"%s\", \"%s\", 1): %s", envname, value, strerror(errno)); +#if HAVE_UNSETENV Unsetenv(envname); /* dont want to have a wrong value */ +#endif return -1; } return 0;