From 519fbe71e46c747a254bc200ea93396591e1a1a3 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 28 Oct 2014 11:20:33 +0100 Subject: [PATCH] lvmcmdline: extra support for decimal point If root has locales with different decimal point then '.' (i.e. Czech with ',') lets be tolerant and retry with "C" locales in the case '.' is found during parse of number. Locales are then restored back. --- WHATS_NEW | 1 + tools/lvmcmdline.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index e59e0f4bd..a8ea15fcb 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.112 - ===================================== + Add extra support for '.' as decimal point in size args. Configurable support for creation of sparse volumes with thin-pools. Update and correct lvcreate and lvcovert man pages. Mark pools and snapshots as unzeroable volumes. diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index c426873ca..33c0045b0 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef HAVE_GETOPTLONG # include @@ -414,6 +415,17 @@ static int _size_arg(struct cmd_context *cmd __attribute__((unused)), struct arg v = strtod(val, &ptr); + if (*ptr == '.') { + /* + * Maybe user has non-C locale with different decimal point ? + * Lets be toleran and retry with standard C locales + */ + if (setlocale(LC_ALL, "C")) { + v = strtod(val, &ptr); + setlocale(LC_ALL, ""); + } + } + if (ptr == val) return 0;