summaryrefslogtreecommitdiffstats
path: root/Utilities/cmjsoncpp/src/lib_json/json_tool.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-12 22:05:54 (GMT)
committerBrad King <brad.king@kitware.com>2022-01-12 22:05:54 (GMT)
commit33fae4cd7a344889404ce61fe1d40a443ad58def (patch)
tree0b35ff2e6a978007be841227a731f08fccfe2ad2 /Utilities/cmjsoncpp/src/lib_json/json_tool.h
parenteb031dfe9fdb498592d368e900ed3e1ee2181703 (diff)
parent7a72ab3388c5f439070167fbcefd1cbdd776be9f (diff)
downloadCMake-33fae4cd7a344889404ce61fe1d40a443ad58def.zip
CMake-33fae4cd7a344889404ce61fe1d40a443ad58def.tar.gz
CMake-33fae4cd7a344889404ce61fe1d40a443ad58def.tar.bz2
Merge branch 'upstream-jsoncpp' into update-jsoncpp
* upstream-jsoncpp: jsoncpp 2022-01-12 (42e892d9)
Diffstat (limited to 'Utilities/cmjsoncpp/src/lib_json/json_tool.h')
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_tool.h10
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 2d7b7d9..b952c19 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;