From: oetiker Date: Wed, 8 Sep 2010 12:15:13 +0000 (+0000) Subject: fix use of setlocale all over the place ... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=68583e5c68ae17ec1a074f83f68701b110a04f36;p=rrdtool-all.git fix use of setlocale all over the place ... - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); the original version never restored the locale since it held a copy of the new locale and not the old one despite the name. bug found by Pawe? 'Reef' Polewicz git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2127 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_create.c b/program/src/rrd_create.c index 99b84750..4a5e67f0 100644 --- a/program/src/rrd_create.c +++ b/program/src/rrd_create.c @@ -571,7 +571,8 @@ void parseGENERIC_DS( &(rrd -> ds_def[ds_idx].par[DS_mrhb_cnt].u_cnt), minstr,maxstr); */ - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); if (sscanf(def, "%lu:%18[^:]:%18[^:]", &(rrd->ds_def[ds_idx].par[DS_mrhb_cnt].u_cnt), minstr, maxstr) == 3) { diff --git a/program/src/rrd_dump.c b/program/src/rrd_dump.c index f175310d..48e339ba 100644 --- a/program/src/rrd_dump.c +++ b/program/src/rrd_dump.c @@ -103,7 +103,8 @@ int rrd_dump_cb_r( return (-1); } - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); if (opt_header == 1) { diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 66db1713..f43e9ada 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -3926,7 +3926,8 @@ rrd_info_t *rrd_graph_v( char *old_locale; rrd_graph_init(&im); /* a dummy surface so that we can measure text sizes for placements */ - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); rrd_graph_options(argc, argv, &im); if (rrd_test_error()) { rrd_info_free(im.grinfo); diff --git a/program/src/rrd_rpncalc.c b/program/src/rrd_rpncalc.c index f27fcb7c..472184c2 100644 --- a/program/src/rrd_rpncalc.c +++ b/program/src/rrd_rpncalc.c @@ -297,7 +297,8 @@ rpnp_t *rpn_parse( char vname[MAX_VNAME_LEN + 10]; char *old_locale; - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); rpnp = NULL; expr = (char *) expr_const; diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c index 2c32a352..b1a9b046 100644 --- a/program/src/rrd_tool.c +++ b/program/src/rrd_tool.c @@ -714,7 +714,8 @@ int HandleInputLine( if (rrd_xport (argc - 1, &argv[1], &xxsize, &start, &end, &step, &col_cnt, &legend_v, &data) != -1) { - char *old_locale = setlocale(LC_NUMERIC, "C"); + char *old_locale = setlocale(LC_NUMERIC,NULL); + setlocale(LC_NUMERIC, "C"); row_cnt = (end - start) / step; ptr = data; printf("\n\n", diff --git a/program/src/rrd_tune.c b/program/src/rrd_tune.c index f14ebc56..d42a0c06 100644 --- a/program/src/rrd_tune.c +++ b/program/src/rrd_tune.c @@ -126,7 +126,8 @@ int rrd_tune( optcnt++; switch (opt) { case 'h': - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); if ((matches = sscanf(optarg, DS_NAM_FMT ":%ld", ds_nam, &heartbeat)) != 2) { @@ -146,7 +147,8 @@ int rrd_tune( break; case 'i': - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + 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"); @@ -168,7 +170,8 @@ int rrd_tune( break; case 'a': - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + 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"); diff --git a/program/src/rrd_update.c b/program/src/rrd_update.c index 64ddaee4..150b8d0b 100644 --- a/program/src/rrd_update.c +++ b/program/src/rrd_update.c @@ -967,7 +967,8 @@ static int get_time_from_reading( *current_time = tmp_time.tv_sec; *current_time_usec = tmp_time.tv_usec; } else { - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); errno = 0; tmp = strtod(updvals[0], 0); if (errno > 0) { @@ -1079,7 +1080,8 @@ static int update_pdp_prep( } break; case DST_ABSOLUTE: - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); errno = 0; pdp_new[ds_idx] = strtod(updvals[ds_idx + 1], &endptr); if (errno > 0) { @@ -1097,7 +1099,8 @@ static int update_pdp_prep( rate = pdp_new[ds_idx] / interval; break; case DST_GAUGE: - old_locale = setlocale(LC_NUMERIC, "C"); + old_locale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); errno = 0; pdp_new[ds_idx] = strtod(updvals[ds_idx + 1], &endptr) * interval;