From 67099d5d06014a3a2d520b2ce2a333edf6101ed1 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Sat, 12 May 2012 20:30:34 +0000 Subject: [PATCH] changed: misc::OnlyDigit() a comma is changed to a dot git-svn-id: svn://ttmath.org/publicrep/winix/trunk@835 e52654a7-88a9-db11-a3e9-0013d4bc506e --- core/misc.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/misc.h b/core/misc.h index 21c771d..99d2d5f 100755 --- a/core/misc.h +++ b/core/misc.h @@ -262,9 +262,11 @@ void MaxSize(StringType & str, size_t max_size) this method removing all characters from given string only digits are allowed and if allow_comma then one comma (or dot) character is allowed + + if change_to_dot is true then if a comma exists then it is changed to a dot */ template -void OnlyDigit(StringType & s, bool allow_comma = true) +void OnlyDigit(StringType & s, bool allow_comma = true, bool change_to_dot = true) { typename StringType::size_type i; bool was_comma = false; @@ -280,6 +282,9 @@ bool was_comma = false; if( (s[i]>='0' && s[i]<='9') || (allow_comma && !was_comma && (s[i]=='.' || s[i]==',')) ) { + if( change_to_dot && s[i] == ',' ) + s[i] = '.'; + if( s[i]=='.' || s[i]==',' ) was_comma = true;