don't force data out ... let cache management do this
[rrdtool.git] / src / rrd_create.c
index a3b73ca..4e442d2 100644 (file)
@@ -4,6 +4,8 @@
  * rrd_create.c  creates new rrds
  *****************************************************************************/
 
+#include <locale.h>
+
 #include "rrd_tool.h"
 #include "rrd_rpncalc.h"
 #include "rrd_hw.h"
@@ -131,8 +133,8 @@ int rrd_create_r(
     }
 
     /* set some defaults */
-    strcpy(rrd.stat_head->cookie, RRD_COOKIE);
-    strcpy(rrd.stat_head->version, RRD_VERSION);
+    strcpy(rrd.stat_head->cookie, RRD_COOKIE);    
+    strcpy(rrd.stat_head->version, RRD_VERSION3); /* by default we are still version 3 */
     rrd.stat_head->float_cookie = FLOAT_COOKIE;
     rrd.stat_head->ds_cnt = 0;  /* this will be adjusted later */
     rrd.stat_head->rra_cnt = 0; /* ditto */
@@ -245,8 +247,9 @@ int rrd_create_r(
                         rrd_set_error("Failed to parse CF name");
                     switch (cf_conv
                             (rrd.rra_def[rrd.stat_head->rra_cnt].cf_nam)) {
-                    case CF_HWPREDICT:
                     case CF_MHWPREDICT:
+                        strcpy(rrd.stat_head->version, RRD_VERSION); /* MHWPREDICT causes Version 4 */
+                    case CF_HWPREDICT:
                         /* initialize some parameters */
                         rrd.rra_def[rrd.stat_head->rra_cnt].par[RRA_hw_alpha].
                             u_val = 0.1;
@@ -512,7 +515,7 @@ void parseGENERIC_DS(
     int ds_idx)
 {
     char      minstr[DS_NAM_SIZE], maxstr[DS_NAM_SIZE];
-
+    char *old_locale;
     /*
        int temp;
 
@@ -520,6 +523,7 @@ void parseGENERIC_DS(
        &(rrd -> ds_def[ds_idx].par[DS_mrhb_cnt].u_cnt),
        minstr,maxstr);
      */
+    old_locale = setlocale(LC_NUMERIC,"C");
     if (sscanf(def, "%lu:%18[^:]:%18[^:]",
                &(rrd->ds_def[ds_idx].par[DS_mrhb_cnt].u_cnt),
                minstr, maxstr) == 3) {
@@ -538,11 +542,13 @@ void parseGENERIC_DS(
             rrd->ds_def[ds_idx].par[DS_min_val].u_val
             >= rrd->ds_def[ds_idx].par[DS_max_val].u_val) {
             rrd_set_error("min must be less than max in DS definition");
+            setlocale(LC_NUMERIC,old_locale);
             return;
         }
     } else {
         rrd_set_error("failed to parse data source %s", def);
     }
+    setlocale(LC_NUMERIC,old_locale);
 }
 
 /* Create the CF_DEVPREDICT, CF_DEVSEASONAL, CF_SEASONAL, and CF_FAILURES RRAs