Revision: 2281
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=2281&view=rev
Author: teuf
Date: 2009-03-21 13:21:51 +0000 (Sat, 21 Mar 2009)
Log Message:
-----------
Patch from: Andrew W. Nosenko <[email protected]>
Avoid using of the global variable 'timezone' in favor of struct
tm.tm_gmtoff (if available).
* src/itdb_device.c (get_local_timezone): Use struct tm.tm_gmtoff
if available (through localtime_r() or localtime(), depending on
the localtime_r() existence) if available and fallback to the
'timezone' or _timezone global variables if struct tm.tm_gmtoff
field is not available.
* configure.ac: Check for existence of localtime_r() function and
struct tm.tm_gmtoff field.
Avoid using of the global variable 'timezone' in favor of struct
tm.tm_gmtoff (if available).
* src/itdb_device.c (get_local_timezone): Use struct tm.tm_gmtoff
if available (through localtime_r() or localtime(), depending on
the localtime_r() existence) if available and fallback to the
'timezone' or _timezone global variables if struct tm.tm_gmtoff
field is not available.
* configure.ac: Check for existence of localtime_r() function and
struct tm.tm_gmtoff field.
Modified Paths:
--------------
libgpod/trunk/ChangeLog
libgpod/trunk/configure.ac
libgpod/trunk/src/itdb_device.c
Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog 2009-03-21 13:21:35 UTC (rev 2280)
+++ libgpod/trunk/ChangeLog 2009-03-21 13:21:51 UTC (rev 2281)
@@ -1,5 +1,33 @@
2009-03-21 Christophe Fergeau <[email protected]>
+ Patch from: Andrew W. Nosenko <[email protected]>
+
+ Avoid using of the global variable 'timezone' in favor of struct
+ tm.tm_gmtoff (if available).
+
+ * src/itdb_device.c (get_local_timezone): Use struct tm.tm_gmtoff
+ if available (through localtime_r() or localtime(), depending on
+ the localtime_r() existence) if available and fallback to the
+ 'timezone' or _timezone global variables if struct tm.tm_gmtoff
+ field is not available.
+
+ * configure.ac: Check for existence of localtime_r() function and
+ struct tm.tm_gmtoff field.
+
+ Avoid using of the global variable 'timezone' in favor of struct
+ tm.tm_gmtoff (if available).
+
+ * src/itdb_device.c (get_local_timezone): Use struct tm.tm_gmtoff
+ if available (through localtime_r() or localtime(), depending on
+ the localtime_r() existence) if available and fallback to the
+ 'timezone' or _timezone global variables if struct tm.tm_gmtoff
+ field is not available.
+
+ * configure.ac: Check for existence of localtime_r() function and
+ struct tm.tm_gmtoff field.
+
+2009-03-21 Christophe Fergeau <[email protected]>
+
Patch from: Jorg Schuller
* src/itdb_itunesdb.c: simplify pos_comp, make get_playlist more
Modified: libgpod/trunk/configure.ac
===================================================================
--- libgpod/trunk/configure.ac 2009-03-21 13:21:35 UTC (rev 2280)
+++ libgpod/trunk/configure.ac 2009-03-21 13:21:51 UTC (rev 2281)
@@ -40,6 +40,7 @@
AM_MAINTAINER_MODE
AC_GNU_SOURCE
+AC_DEFINE([_BSD_SOURCE], 1, [BSD Functions])
AC_PROG_CC
AM_PROG_CC_C_O
@@ -56,6 +57,8 @@
AC_PROG_MAKE_SET
AC_PROG_INTLTOOL([0.21])
+AC_CHECK_FUNCS([localtime_r])
+AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[#include <time.h>])
PKG_CHECK_MODULES(LIBGPOD, glib-2.0 >= 2.8.0 gobject-2.0)
dnl **************************************************
Modified: libgpod/trunk/src/itdb_device.c
===================================================================
--- libgpod/trunk/src/itdb_device.c 2009-03-21 13:21:35 UTC (rev 2280)
+++ libgpod/trunk/src/itdb_device.c 2009-03-21 13:21:51 UTC (rev 2281)
@@ -1620,9 +1620,40 @@
static gint get_local_timezone (void)
{
-#ifdef __CYGWIN__
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+ /*
+ *
http://www.gnu.org/software/libc/manual/html_node/Time-Zone-Functions.html
+ *
+ * Variable: long int timezone
+ *
+ * This contains the difference between UTC and the latest local
+ * standard time, in seconds west of UTC. For example, in the
+ * U.S. Eastern time zone, the value is 5*60*60. Unlike the
+ * tm_gmtoff member of the broken-down time structure, this value is
+ * not adjusted for daylight saving, and its sign is reversed. In
+ * GNU programs it is better to use tm_gmtoff, since it contains the
+ * correct offset even when it is not the latest one.
+ */
+ time_t t = time(NULL);
+ glong seconds_east_utc;
+# ifdef HAVE_LOCALTIME_R
+ {
+ struct tm tmb;
+ tzset ();
+ localtime_r(&t, &tmb);
+ seconds_east_utc = tmb.tm_gmtoff;
+ }
+# else /* !HAVE_LOCALTIME_R */
+ {
+ struct tm* tp;
+ tp = localtime(&t);
+ seconds_east_utc = tp->tm_gmtoff;
+ }
+# endif /* !HAVE_LOCALTIME_R */
+ return seconds_east_utc * -1; /* mimic the old behaviour when global
variable 'timezone' from the 'time.h' header was returned */
+#elif __CYGWIN__ /* !HAVE_STRUCT_TM_TM_GMTOFF */
return (gint) _timezone; /* global variable defined by time.h, see man
tzset */
-#else
+#else /* !HAVE_STRUCT_TM_TM_GMTOFF && !__CYGWIN__ */
return timezone; /* global variable defined by time.h, see man tzset */
#endif
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2