summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2428111)
raw | patch | inline | side by side (parent: 2428111)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 18 Jul 2007 21:47:26 +0000 (21:47 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 18 Jul 2007 21:47:26 +0000 (21:47 +0000) |
index a3b73ca5f734782e62fa061fcebafa0f618a76ac..0e2f82c14150e8d39ef28cd0f42dbed1192cdaf2 100644 (file)
--- a/program/src/rrd_create.c
+++ b/program/src/rrd_create.c
* rrd_create.c creates new rrds
*****************************************************************************/
+#include <locale.h>
+
#include "rrd_tool.h"
#include "rrd_rpncalc.h"
#include "rrd_hw.h"
int ds_idx)
{
char minstr[DS_NAM_SIZE], maxstr[DS_NAM_SIZE];
-
+ char *old_locale;
/*
int temp;
&(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) {
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
index f7ea57286a4112250d9cf0e92f471e2cbd73614d..6b8a46dbf1f8753edbfd234337c23e9919ebae01 100644 (file)
--- a/program/src/rrd_graph.c
+++ b/program/src/rrd_graph.c
long long_tmp;
struct rrd_time_value start_tv, end_tv;
long unsigned int color;
+ char *old_locale = "";
/* defines for long options without a short equivalent. should be bytes,
and may not collide with (the ASCII value of) short options */
int option_index = 0;
int opt;
int col_start, col_end;
-
opt = getopt_long(argc, argv,
"s:e:x:y:v:w:h:D:iu:l:rb:oc:n:m:t:f:a:I:zgjFYAMEX:L:S:T:NR:B:W:",
long_options, &option_index);
case LONGOPT_UNITS_SI:
if (im->extra_flags & FORCE_UNITS) {
rrd_set_error("--units can only be used once!");
+ setlocale(LC_NUMERIC,old_locale);
return;
}
if (strcmp(optarg, "si") == 0)
im->forceleftspace = 1;
break;
case 'T':
+ old_locale = setlocale(LC_NUMERIC,"C");
im->tabwidth = atof(optarg);
+ setlocale(LC_NUMERIC,old_locale);
break;
case 'S':
+ old_locale = setlocale(LC_NUMERIC,"C");
im->step = atoi(optarg);
+ setlocale(LC_NUMERIC,old_locale);
break;
case 'N':
im->gridfit = 0;
im->draw_y_grid = 0;
break;
};
-
+ old_locale=setlocale(LC_NUMERIC,"C");
if (sscanf(optarg, "%lf:%d", &im->ygridstep, &im->ylabfact) == 2) {
+ setlocale(LC_NUMERIC,old_locale);
if (im->ygridstep <= 0) {
rrd_set_error("grid step must be > 0");
return;
return;
}
} else {
+ setlocale(LC_NUMERIC,old_locale);
rrd_set_error("invalid y-grid format");
return;
}
im->ylegend[150] = '\0';
break;
case 'u':
+ old_locale=setlocale(LC_NUMERIC,"C");
im->maxval = atof(optarg);
+ setlocale(LC_NUMERIC,old_locale);
break;
case 'l':
+ old_locale=setlocale(LC_NUMERIC,"C");
im->minval = atof(optarg);
+ setlocale(LC_NUMERIC,old_locale);
break;
case 'b':
im->base = atol(optarg);
char prop[15];
double size = 1;
char font[1024] = "";
-
+ old_locale = setlocale(LC_NUMERIC,"C");
if (sscanf(optarg, "%10[A-Z]:%lf:%1000s", prop, &size, font) >= 2) {
int sindex, propidx;
-
+
+ setlocale(LC_NUMERIC,old_locale);
if ((sindex = text_prop_conv(prop)) != -1) {
for (propidx = sindex; propidx < TEXT_PROP_LAST;
propidx++) {
rrd_set_error("invalid fonttag '%s'", prop);
return;
}
- } else {
+ } else {
+ setlocale(LC_NUMERIC,old_locale);
rrd_set_error("invalid text property format");
return;
}
break;
}
case 'm':
+ old_locale=setlocale(LC_NUMERIC,"C");
im->zoom = atof(optarg);
+ setlocale(LC_NUMERIC,old_locale);
if (im->zoom <= 0.0) {
rrd_set_error("zoom factor must be > 0");
return;
double param;
char func[30];
int n;
+ char *old_locale;
n = 0;
+ old_locale = setlocale(LC_NUMERIC,"C");
sscanf(str, "%le,%29[A-Z]%n", ¶m, func, &n);
+ setlocale(LC_NUMERIC,old_locale);
if (n == (int) strlen(str)) { /* matched */
;
} else {
index 7953320f084820349345a38e55b0fba2d8cfdb8d..2fc6ca77ee2cdd6598a914f888e34a1849ab48f3 100644 (file)
#include "rrd_rpncalc.h"
#include "rrd_graph.h"
#include <limits.h>
+#include <locale.h>
short addop2str(
enum op_en op,
long steps = -1;
rpnp_t *rpnp;
char vname[MAX_VNAME_LEN + 10];
+ char *old_locale;
+ old_locale = setlocale(LC_NUMERIC,"C");
rpnp = NULL;
expr = (char *) expr_const;
while (*expr) {
if ((rpnp = (rpnp_t *) rrd_realloc(rpnp, (++steps + 2) *
sizeof(rpnp_t))) == NULL) {
+ setlocale(LC_NUMERIC,old_locale);
return NULL;
}
-
+
else if ((sscanf(expr, "%lf%n", &rpnp[steps].val, &pos) == 1)
&& (expr[pos] == ',')) {
rpnp[steps].op = OP_NUMBER;
else if (strncmp(expr, #VVV, strlen(#VVV))==0 && ( expr[strlen(#VVV)] == ',' || expr[strlen(#VVV)] == '\0' )){ \
rpnp[steps].op = VV; \
expr+=strlen(#VVV); \
- }
-
+ }
#define match_op_param(VV,VVV) \
else if (sscanf(expr, #VVV "(" DEF_NAM_FMT ")",vname) == 1) { \
}
else {
+ setlocale(LC_NUMERIC,old_locale);
free(rpnp);
return NULL;
}
+
if (*expr == 0)
break;
if (*expr == ',')
expr++;
else {
+ setlocale(LC_NUMERIC,old_locale);
free(rpnp);
return NULL;
}
}
rpnp[steps + 1].op = OP_END;
+ setlocale(LC_NUMERIC,old_locale);
return rpnp;
}
diff --git a/program/src/rrd_tune.c b/program/src/rrd_tune.c
index f675c8b24d92ec9f5524a696b67f543ca629d2dd..f5bea46a6daf8b16e89706f3726d6268686ad581 100644 (file)
--- a/program/src/rrd_tune.c
+++ b/program/src/rrd_tune.c
#include "rrd_tool.h"
#include "rrd_rpncalc.h"
#include "rrd_hw.h"
+#include <locale.h>
int set_hwarg(
rrd_t *rrd,
while (1) {
int option_index = 0;
int opt;
-
+ char *old_locale = "";
opt = getopt_long(argc, argv, "h:i:a:d:r:p:n:w:f:x:y:z:v:b:",
long_options, &option_index);
if (opt == EOF)
optcnt++;
switch (opt) {
case 'h':
+ old_locale = setlocale(LC_NUMERIC,"C");
if ((matches =
sscanf(optarg, DS_NAM_FMT ":%ld", ds_nam,
&heartbeat)) != 2) {
rrd_set_error("invalid arguments for heartbeat");
rrd_free(&rrd);
rrd_close(rrd_file);
+ setlocale(LC_NUMERIC,old_locale);
return -1;
}
+ setlocale(LC_NUMERIC,old_locale);
if ((ds = ds_match(&rrd, ds_nam)) == -1) {
rrd_free(&rrd);
rrd_close(rrd_file);
break;
case 'i':
+ old_locale = setlocale(LC_NUMERIC,"C");
if ((matches =
sscanf(optarg, DS_NAM_FMT ":%lf", ds_nam, &min)) < 1) {
rrd_set_error("invalid arguments for minimum ds value");
rrd_free(&rrd);
rrd_close(rrd_file);
+ setlocale(LC_NUMERIC,old_locale);
return -1;
}
+ setlocale(LC_NUMERIC,old_locale);
if ((ds = ds_match(&rrd, ds_nam)) == -1) {
rrd_free(&rrd);
rrd_close(rrd_file);
break;
case 'a':
+ old_locale = setlocale(LC_NUMERIC,"C");
if ((matches =
sscanf(optarg, DS_NAM_FMT ":%lf", ds_nam, &max)) < 1) {
rrd_set_error("invalid arguments for maximum ds value");
rrd_free(&rrd);
rrd_close(rrd_file);
+ setlocale(LC_NUMERIC,old_locale);
return -1;
}
+ setlocale(LC_NUMERIC,old_locale);
if ((ds = ds_match(&rrd, ds_nam)) == -1) {
rrd_free(&rrd);
rrd_close(rrd_file);
index 9a1f32dafc90e1e1dec629da0c1d132eb4f92801..45971a4b5898a3a9a5007c5c304458eda0985c11 100644 (file)
--- a/program/src/rrd_update.c
+++ b/program/src/rrd_update.c
#include <io.h>
#endif
+#include <locale.h>
+
#include "rrd_hw.h"
#include "rrd_rpncalc.h"
current_time_usec = tmp_time.tv_usec;
} else {
double tmp;
-
+ char *old_locale;
+ old_locale = setlocale(LC_NUMERIC,"C");
tmp = strtod(updvals[0], 0);
+ setlocale(LC_NUMERIC,old_locale);
current_time = floor(tmp);
current_time_usec =
(long) ((tmp - (double) current_time) * 1000000.0);
(dst_idx != DST_CDEF) &&
rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt >= interval) {
double rate = DNAN;
+ char *old_locale;
/* the data source type defines how to process the data */
/* pdp_new contains rate * time ... eg the bytes
}
break;
case DST_ABSOLUTE:
+ old_locale = setlocale(LC_NUMERIC,"C");
errno = 0;
pdp_new[i] = strtod(updvals[i + 1], &endptr);
+ setlocale(LC_NUMERIC,old_locale);
if (errno > 0) {
rrd_set_error("converting '%s' to float: %s",
updvals[i + 1], rrd_strerror(errno));
break;
case DST_GAUGE:
errno = 0;
+ old_locale = setlocale(LC_NUMERIC,"C");
pdp_new[i] = strtod(updvals[i + 1], &endptr) * interval;
+ setlocale(LC_NUMERIC,old_locale);
if (errno > 0) {
rrd_set_error("converting '%s' to float: %s",
updvals[i + 1], rrd_strerror(errno));