From: Wayne Davison Date: Tue, 11 Jun 2013 20:28:45 +0000 (-0700) Subject: Set number_separator the first time it gets used. X-Git-Tag: v3.1.0pre1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc2d6fabe7ef7543caa0cb36231c8234dd6b6eeb;p=thirdparty%2Frsync.git Set number_separator the first time it gets used. --- diff --git a/lib/compat.c b/lib/compat.c index f756f76d..b89ef02e 100644 --- a/lib/compat.c +++ b/lib/compat.c @@ -22,7 +22,7 @@ #include "rsync.h" #include "itypes.h" -extern char number_separator; +static char number_separator; #ifndef HAVE_STRDUP char *strdup(char *s) @@ -190,6 +190,15 @@ char *do_big_num(int64 num, int human_flag, const char *fract) char *s; int len, negated; + if (human_flag && !number_separator) { + char buf[32]; + snprintf(buf, sizeof buf, "%f", 3.14); + if (strchr(buf, '.') != NULL) + number_separator = ','; + else + number_separator = '.'; + } + n = (n + 1) % (sizeof bufs / sizeof bufs[0]); if (human_flag > 1) { diff --git a/options.c b/options.c index 91e3fdd5..cebf2569 100644 --- a/options.c +++ b/options.c @@ -123,7 +123,6 @@ int checksum_seed = 0; int inplace = 0; int delay_updates = 0; long block_size = 0; /* "long" because popt can't set an int32. */ -char number_separator; char *skip_compress = NULL; item_list dparam_list = EMPTY_ITEM_LIST; @@ -1870,15 +1869,6 @@ int parse_arguments(int *argc_p, const char ***argv_p) verbose > 1 ? "stats3" : "stats2", DEFAULT_PRIORITY); } - if (human_readable) { - char buf[32]; - snprintf(buf, sizeof buf, "%f", 3.14); - if (strchr(buf, '.') != NULL) - number_separator = ','; - else - number_separator = '.'; - } - #ifdef ICONV_OPTION if (iconv_opt && protect_args != 2) { if (!am_server && strcmp(iconv_opt, "-") == 0) diff --git a/t_stub.c b/t_stub.c index 013c09d1..0fca8659 100644 --- a/t_stub.c +++ b/t_stub.c @@ -30,7 +30,6 @@ int module_dirlen = 0; int preserve_acls = 0; int preserve_times = 0; int preserve_xattrs = 0; -char number_separator = ','; char *partial_dir; char *module_dir; filter_rule_list daemon_filter_list; diff --git a/tls.c b/tls.c index f111c02e..b84085d7 100644 --- a/tls.c +++ b/tls.c @@ -51,7 +51,6 @@ int link_owner = 0; int nsec_times = 0; int preserve_perms = 0; int preserve_executability = 0; -char number_separator; #ifdef SUPPORT_XATTRS @@ -255,12 +254,6 @@ main(int argc, char *argv[]) if (!extra_args || *extra_args == NULL) tls_usage(1); - snprintf(buf, sizeof buf, "%f", 3.14); - if (strchr(buf, '.') != NULL) - number_separator = ','; - else - number_separator = '.'; - for (; *extra_args; extra_args++) list_file(*extra_args); poptFreeContext(pc); diff --git a/trimslash.c b/trimslash.c index 448064ab..7694eb1e 100644 --- a/trimslash.c +++ b/trimslash.c @@ -28,7 +28,6 @@ int read_only = 1; int list_only = 0; int preserve_perms = 0; int preserve_executability = 0; -char number_separator = ','; int main(int argc, char **argv) diff --git a/wildtest.c b/wildtest.c index 10534e01..2621c15b 100644 --- a/wildtest.c +++ b/wildtest.c @@ -31,7 +31,6 @@ int fnmatch_errors = 0; #endif int wildmatch_errors = 0; -char number_separator = ','; typedef char bool;