Code

we are using a comparison with sizeof(long) to figure the size of time_t this is...
[rrdtool-all.git] / program / src / rrd_restore.c
index c5cbcd2dffae485242236e9bd7793dd45054a604..cefdfaea1da699431e1d234256468a9cea04df4b 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.3.8  Copyright by Tobi Oetiker, 1997-2009
+ * RRDtool 1.3.9  Copyright by Tobi Oetiker, 1997-2009
  * This file:     Copyright 2008 Florian octo Forster
  * Distributed under the GPL
  *****************************************************************************
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <fcntl.h>
+#include <locale.h>
 
 #if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
 #include <math.h>
@@ -959,7 +960,7 @@ static int parse_tag_rrd(
             status = get_ulong_from_node(doc, child,
                                         &rrd->stat_head->pdp_step);
         else if (xmlStrcmp(child->name, (const xmlChar *) "lastupdate") == 0) {
-            if (sizeof(time_t) == sizeof(long)) {
+            if (sizeof(time_t) == sizeof(int)) {
                status = get_long_from_node(doc, child, (long *)&rrd->live_head->last_up);
             }
             else { if (sizeof(time_t) == sizeof(long long)) {
@@ -1138,6 +1139,7 @@ int rrd_restore(
     char **argv)
 {
     rrd_t    *rrd;
+    char*    old_locale;
 
 #ifdef WIN32
     srand((unsigned int) time(NULL));
@@ -1185,7 +1187,16 @@ int rrd_restore(
         return (-1);
     }
 
+#ifdef HAVE_SETLOCALE
+    old_locale = setlocale(LC_NUMERIC, "C");
+#endif
+
     rrd = parse_file(argv[optind]);
+
+#ifdef HAVE_SETLOCALE
+    setlocale(LC_NUMERIC, old_locale);
+#endif
+
     if (rrd == NULL)
         return (-1);