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=12173194711abe6205339f350cd9aa2a75acc467;p=rrdtool.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/program@2127 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_create.c b/src/rrd_create.c index 99b8475..4a5e67f 100644 --- a/src/rrd_create.c +++ b/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/src/rrd_dump.c b/src/rrd_dump.c index f175310..48e339b 100644 --- a/src/rrd_dump.c +++ b/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/src/rrd_graph.c b/src/rrd_graph.c index 66db171..f43e9ad 100644 --- a/src/rrd_graph.c +++ b/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/src/rrd_rpncalc.c b/src/rrd_rpncalc.c index f27fcb7..472184c 100644 --- a/src/rrd_rpncalc.c +++ b/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/src/rrd_tool.c b/src/rrd_tool.c index 2c32a35..b1a9b04 100644 --- a/src/rrd_tool.c +++ b/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/src/rrd_tune.c b/src/rrd_tune.c index f14ebc5..d42a0c0 100644 --- a/src/rrd_tune.c +++ b/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/src/rrd_update.c b/src/rrd_update.c index 64ddaee..150b8d0 100644 --- a/src/rrd_update.c +++ b/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;