[Xfce4-commits] <xfce4-weather-plugin:master> Add string-to-double helper function, using alternate value in case of error.
Harald Judt
noreply at xfce.org
Tue Nov 27 16:46:02 CET 2012
Updating branch refs/heads/master
to 37c1524bc4be019c695d92d98d43c85f320d1263 (commit)
from fd3dab2254e561db21a7c40045f5120481eb3642 (commit)
commit 37c1524bc4be019c695d92d98d43c85f320d1263
Author: Harald Judt <h.judt at gmx.at>
Date: Wed Nov 21 13:10:31 2012 +0100
Add string-to-double helper function, using alternate value in case of error.
panel-plugin/weather-data.c | 12 ++++++++++++
panel-plugin/weather-data.h | 3 +++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index ca3e804..ffc353e 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -53,6 +53,18 @@ has_timeslice(xml_weather *data,
}
+/* convert string to a double value, returning backup value on error */
+gdouble
+string_to_double(const gchar *str,
+ gdouble backup)
+{
+ gdouble d = backup;
+ if (str && strlen(str) > 0)
+ d = g_ascii_strtod(str, NULL);
+ return d;
+}
+
+
gchar *
get_data(const xml_time *timeslice,
const unit_systems unit_system,
diff --git a/panel-plugin/weather-data.h b/panel-plugin/weather-data.h
index 05d680c..288ceaf 100644
--- a/panel-plugin/weather-data.h
+++ b/panel-plugin/weather-data.h
@@ -55,6 +55,9 @@ typedef enum {
} daytime;
+gdouble string_to_double(const gchar *str,
+ gdouble backup);
+
gchar *get_data(const xml_time *timeslice,
unit_systems unit_system,
data_types type);
More information about the Xfce4-commits
mailing list