diff options
Diffstat (limited to 'Utilities/cmjsoncpp/src/lib_json/json_tool.h')
-rw-r--r-- | Utilities/cmjsoncpp/src/lib_json/json_tool.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_tool.h b/Utilities/cmjsoncpp/src/lib_json/json_tool.h index 2d7b7d9a00..b952c19167 100644 --- a/Utilities/cmjsoncpp/src/lib_json/json_tool.h +++ b/Utilities/cmjsoncpp/src/lib_json/json_tool.h @@ -116,14 +116,18 @@ template <typename Iter> void fixNumericLocaleInput(Iter begin, Iter end) { * Return iterator that would be the new end of the range [begin,end), if we * were to delete zeros in the end of string, but not the last zero before '.'. */ -template <typename Iter> Iter fixZerosInTheEnd(Iter begin, Iter end) { +template <typename Iter> +Iter fixZerosInTheEnd(Iter begin, Iter end, unsigned int precision) { for (; begin != end; --end) { if (*(end - 1) != '0') { return end; } // Don't delete the last zero before the decimal point. - if (begin != (end - 1) && *(end - 2) == '.') { - return end; + if (begin != (end - 1) && begin != (end - 2) && *(end - 2) == '.') { + if (precision) { + return end; + } + return end - 2; } } return end; |