check for setenv/getenv and only use if present (fixes mingw32)

This commit is contained in:
Marcus Meissner
2015-12-21 09:07:19 +01:00
parent 17b803a14c
commit 431a93becb
2 changed files with 7 additions and 1 deletions

View File

@@ -4923,24 +4923,30 @@ static int
_put_UINT32_as_localtime(CONFIG_PUT_ARGS) {
time_t camtime,newcamtime;
struct tm *ptm;
#if HAVE_SETENV
char *tz;
#endif
camtime = 0;
CR (gp_widget_get_value (widget, &camtime));
ptm = localtime(&camtime);
#if HAVE_SETENV
tz = getenv("TZ");
if (tz)
C_MEM (tz = strdup(tz));
setenv("TZ", "", 1);
tzset();
#endif
newcamtime = mktime(ptm);
#if HAVE_SETENV
if (tz) {
setenv("TZ", tz, 1);
free(tz);
} else
unsetenv("TZ");
tzset();
#endif
propval->u32 = newcamtime;
return (GP_OK);

View File

@@ -314,7 +314,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
dnl Checks for library functions.
AC_CHECK_FUNCS([getopt getopt_long mkdir strdup strncpy strcpy snprintf sprintf vsnprintf gmtime_r statfs localtime_r lstat inet_aton rand_r])
AC_CHECK_FUNCS([getenv getopt getopt_long mkdir setenv strdup strncpy strcpy snprintf sprintf vsnprintf gmtime_r statfs localtime_r lstat inet_aton rand_r])
dnl Find out how to get struct tm
AC_STRUCT_TM