gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/ClockTime.cpp


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog libbase/ClockTime.cpp
Date: Mon, 07 Apr 2008 11:35:03 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/04/07 11:35:02

Modified files:
        .              : ChangeLog 
        libbase        : ClockTime.cpp 

Log message:
                * libbase/ClockTime.{cpp,h}: fix build for systems with no
                  localtime_r; add safety checks.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6198&r2=1.6199
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/ClockTime.cpp?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6198
retrieving revision 1.6199
diff -u -b -r1.6198 -r1.6199
--- ChangeLog   7 Apr 2008 10:59:25 -0000       1.6198
+++ ChangeLog   7 Apr 2008 11:35:01 -0000       1.6199
@@ -1,5 +1,10 @@
 2008-04-07 Benjamin Wolsey <address@hidden>
 
+       * libbase/ClockTime.{cpp,h}: fix build for systems with no
+         localtime_r; add safety checks.
+
+2008-04-07 Benjamin Wolsey <address@hidden>
+
        * libbase/Time.{cpp,h}: renamed.
        * libbase/ClockTime.{cpp,h}: renamed from Time.{cpp,h}.
        * libbase/Makefile.am: reflect name change.

Index: libbase/ClockTime.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/ClockTime.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libbase/ClockTime.cpp       7 Apr 2008 10:59:26 -0000       1.1
+++ libbase/ClockTime.cpp       7 Apr 2008 11:35:02 -0000       1.2
@@ -31,6 +31,7 @@
 /// disadvantage is that date_time requires not only header files, but also
 /// a run-time library, and thus increases the requirements.
 
+#include <boost/cstdint.hpp>
 #include "ClockTime.h"
 #include "log.h"
 
@@ -161,9 +162,10 @@
 #ifdef HAVE_LOCALTIME_R
     localtime_r(&tt, &tm);
 #else
-    struct tm *tmp;
-    tmp = localtime(t);
-    memcpy(tm, tmp, sizeof(struct tm));
+    struct tm *tmp = NULL;
+    tmp = localtime(&tt);
+    if (!tmp) return 0; // We failed.
+    memcpy(&tm, tmp, sizeof(struct tm));
 #endif
 
     struct tm tm2 = tm;
@@ -173,7 +175,14 @@
     
     ttmp = mktime(&tm2);
 
+#ifdef HAVE_LOCALTIME_R
     localtime_r(&ttmp, &tm2);  // find out whether DST is in force
+#else
+    struct tm *tmp2 = NULL;
+    tmp2 = localtime(&ttmp);
+    if (!tmp2) return 0; // We failed.
+    memcpy(&tm2, tmp2, sizeof(struct tm));
+#endif
 
     // If mktime or localtime fail, tm2.tm_isdst should be unchanged,
     // so 0. That's why we don't make any checks on their success.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]