From c30ffeea721480bdf3dd6126bc32dd07f5317803 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 25 Aug 2013 20:05:57 +0300 Subject: [PATCH] * small cleanups (macos) --- lib/mu-date.c | 18 +++++++++++------- lib/mu-util.c | 10 +++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/mu-date.c b/lib/mu-date.c index 357ef06d..13ff9b26 100644 --- a/lib/mu-date.c +++ b/lib/mu-date.c @@ -222,10 +222,10 @@ mu_date_interpret (const char *datespec, gboolean is_begin) time_t mu_date_str_to_time_t (const char* date, gboolean local) { - struct tm tm; - char mydate[14 + 1]; /* YYYYMMDDHHMMSS */ - time_t t; - const char *tz; + struct tm tm; + char mydate[14 + 1]; /* YYYYMMDDHHMMSS */ + time_t t; + char *tz; memset (&tm, 0, sizeof(struct tm)); strncpy (mydate, date, 15); @@ -239,13 +239,15 @@ mu_date_str_to_time_t (const char* date, gboolean local) tm.tm_mday = atoi (mydate + 6); mydate[6] = '\0'; tm.tm_mon = atoi (mydate + 4) - 1; mydate[4] = '\0'; tm.tm_year = atoi (mydate) - 1900; - tm.tm_isdst = -1; /* figure out the dst */ + tm.tm_isdst = -1; /* let mktime figure out the dst */ if (!local) { /* temporarily switch to UTC */ tz = getenv ("TZ"); + tz = tz ? g_strdup (tz) : NULL; setenv ("TZ", "", 1); tzset (); - } + } else + tz = NULL; t = mktime (&tm); @@ -254,9 +256,11 @@ mu_date_str_to_time_t (const char* date, gboolean local) setenv("TZ", tz, 1); else unsetenv("TZ"); - tzset(); + tzset (); } + g_free (tz); + return t; } diff --git a/lib/mu-util.c b/lib/mu-util.c index 101dea43..295593b2 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -70,10 +70,14 @@ do_wordexp (const char *path) /* strangely, below seems to lead to a crash on MacOS (BSD); so we have to allow for a tiny leak here on that platform... maybe instead of __APPLE__ it should be - __BSD__?*/ -#ifndef __APPLE__ + __BSD__? + + Hmmm., cannot reproduce that crash anymore, so commenting + it out for now... + */ +/* #ifndef __APPLE__ */ wordfree (&wexp); -#endif /*__APPLE__*/ +/* #endif /\*__APPLE__*\/ */ return dir; # else /*!HAVE_WORDEXP_H*/