Skip to content

Commit 6ea25c7

Browse files
author
Daniel Shelepanov
committed
[PBCKP-216] review fixes
1 parent 612205d commit 6ea25c7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/show.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <time.h>
1414
#include <dirent.h>
15+
#include <locale.h>
1516
#include <sys/stat.h>
1617

1718
#include "utils/json.h"
@@ -1045,15 +1046,16 @@ show_archive_json(const char *instance_name, uint32 xlog_seg_size,
10451046
appendPQExpBuffer(buf, "%lu", tlinfo->size);
10461047

10471048
json_add_key(buf, "zratio", json_level);
1048-
10491049
// forcing comma-based floating point representation
1050-
char *save_locale = setlocale(LC_NUMERIC, NULL);
1051-
setlocale(LC_NUMERIC, "POSIX");
1050+
locale_t newloc = newlocale(LC_NUMERIC_MASK, "POSIX", (locale_t)0);
1051+
locale_t saveloc = uselocale(newloc);
10521052
if (tlinfo->size != 0)
10531053
zratio = ((float)xlog_seg_size*tlinfo->n_xlog_files) / tlinfo->size;
10541054
appendPQExpBuffer(buf, "%.2f", zratio);
10551055
// restoring previous locale
1056-
setlocale(LC_NUMERIC, save_locale);
1056+
if(saveloc != (locale_t)0)
1057+
uselocale(saveloc);
1058+
freelocale(newloc);
10571059

10581060
if (tlinfo->closest_backup != NULL)
10591061
snprintf(tmp_buf, lengthof(tmp_buf), "%s",

0 commit comments

Comments
 (0)