mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmcmdline: enhance locales check
Make check for 'radixchar' more readable and logical. Also avoid reread of number of locale is already using '.' as radixchar.
This commit is contained in:
parent
864017710c
commit
4fa739faf2
@ -544,7 +544,7 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
|
||||
char *val;
|
||||
double v;
|
||||
uint64_t v_tmp, adjustment;
|
||||
char *radixchar = nl_langinfo(RADIXCHAR);
|
||||
const char *radixchar = nl_langinfo(RADIXCHAR) ? : ".";
|
||||
|
||||
av->percent = PERCENT_NONE;
|
||||
|
||||
@ -567,10 +567,7 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (!isdigit(*val) &&
|
||||
(*val != '.') &&
|
||||
(radixchar && (*val != radixchar[0]))) {
|
||||
if (!isdigit(*val) && (*val != '.') && (*val != radixchar[0])) {
|
||||
log_error("Size requires number argument.");
|
||||
return 0;
|
||||
}
|
||||
@ -578,10 +575,10 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)),
|
||||
errno = 0;
|
||||
v = strtod(val, &ptr);
|
||||
|
||||
if (*ptr == '.') {
|
||||
if (*ptr == '.' && radixchar[0] != '.') {
|
||||
/*
|
||||
* Maybe user has non-C locale with different decimal point ?
|
||||
* Lets be toleran and retry with standard C locales
|
||||
* Lets be tolerant and retry with standard C locales
|
||||
*/
|
||||
if (setlocale(LC_ALL, "C")) {
|
||||
errno = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user