* small cleanups (macos)

This commit is contained in:
djcb 2013-08-25 20:05:57 +03:00
parent 8da4ff383a
commit c30ffeea72
2 changed files with 18 additions and 10 deletions

View File

@ -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;
}

View File

@ -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*/