[Xfce4-commits] <xfce4-weather-plugin:master> Really get the plugin working on OpenBSD (bug #9152).

Harald Judt noreply at xfce.org
Wed Jul 25 10:28:01 CEST 2012


Updating branch refs/heads/master
         to 654ce328524c1f9c7e812c1c999e8b51a2c4721c (commit)
       from 77546c193fb1307c76981e8f41687687344b24f2 (commit)

commit 654ce328524c1f9c7e812c1c999e8b51a2c4721c
Author: Landry Breuil <landry at xfce.org>
Date:   Wed Jul 25 10:23:04 2012 +0200

    Really get the plugin working on OpenBSD (bug #9152).
    
    The #define added in 94c7c6e88ed7caf1ed8fec608558050274064a84
    is only part of the solution. One also has to initialize the
    tm structs before using strptime, otherwise the behaviour is
    not defined.
    
    Some references:
    http://linux.die.net/man/3/strptime
    "In principle, this function does not initialize tm but only stores the values
    specified. This means that tm should be initialized before the call. Details
    differ a bit between different UNIX systems. The glibc implementation does not
    touch those fields which are not explicitly specified, except that it
    recomputes the tm_wday and tm_yday field if any of the year, month, or day
    elements changed."
    
    http://www.openbsd.org/cgi-bin/man.cgi?query=strptime
    "There is no way to specify whether Daylight Saving Time is in effect when
    calling strptime.  To use the resulting tm structure with functions that
    check the tm_isdst field, either set it to a negative value, which will
    cause mktime(3) to attempt to divine whether Daylight Saving Time would
    be in effect for the given time, or compute the value manually."

 panel-plugin/weather-parsers.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index d574df2..dc47805 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -28,6 +28,7 @@
 #include <libxfce4panel/libxfce4panel.h>
 #include <time.h>
 #include <stdlib.h>
+#include <string.h>
 
 static time_t my_timegm(struct tm *tm)
 {
@@ -98,6 +99,11 @@ void parse_time (xmlNode * cur_node, xml_weather * data) {
 	xml_time *timeslice;
 	xmlNode *child_node;
 
+    memset(&start_tm, 0, sizeof(struct tm));
+    memset(&end_tm, 0, sizeof(struct tm));
+    start_tm.tm_isdst = -1;
+    end_tm.tm_isdst = -1;
+
 	if (xmlStrcasecmp(datatype, "forecast")) {
 		xmlFree(datatype);
 		xmlFree(start);


More information about the Xfce4-commits mailing list