[tracker/rss-enclosures] libtracker-common: Bugfix usage of timegm on *BSD. Also use it for glibc, it's faster



commit 76cdfcc2a909d457feb70be54cef7fb0d3d033a6
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Apr 14 18:12:14 2010 +0200

    libtracker-common: Bugfix usage of timegm on *BSD. Also use it for glibc, it's faster

 src/libtracker-common/tracker-date-time.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-common/tracker-date-time.c b/src/libtracker-common/tracker-date-time.c
index cb16e4b..63d666a 100644
--- a/src/libtracker-common/tracker-date-time.c
+++ b/src/libtracker-common/tracker-date-time.c
@@ -20,9 +20,16 @@
 
 #include "config.h"
 
+/* For timegm usage on __GLIBC__ */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <strings.h>
 #include <string.h>
 #include <stdlib.h>
+#include <time.h>
+#include <stdlib.h>
 
 #include <glib.h>
 
@@ -111,11 +118,11 @@ tracker_string_to_date (const gchar *date_string,
 		/* mktime() always assumes that "tm" is in locale time but we
 		 * want to keep control on time, so we go to UTC
 		 */
-#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
-                t  = mktime (&tm);
-                t -= timezone;
+#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__GLIBC__))
+		t  = mktime (&tm);
+		t -= timezone;
 #else
-                t = timegm (&tm);
+		t = timegm (&tm);
 #endif
 
 		offset = 0;
@@ -154,11 +161,7 @@ tracker_string_to_date (const gchar *date_string,
 		/* local time */
 		tm.tm_isdst = -1;
 
-#if !(defined(__FreeBSD__) || defined(__OpenBSD__))
-                t = mktime (&tm);
-#else
-                t = timegm (&tm);
-#endif
+		t = mktime (&tm);
 
 		offset = -timezone + (tm.tm_isdst > 0 ? 3600 : 0);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]