From 2734f4a788dad6faf960d53de00da74ebff69bd5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Nov 2018 21:12:28 +0300 Subject: Fix dispaly '+' on stats with negative values. --- src/utils/itemxmlutils.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/utils/itemxmlutils.cpp b/src/utils/itemxmlutils.cpp index ac8e48e2b..7362441b9 100644 --- a/src/utils/itemxmlutils.cpp +++ b/src/utils/itemxmlutils.cpp @@ -29,6 +29,15 @@ #include "debug.h" +static void convertSignedValue(std::string &outStr, + const std::string &srcStr) +{ + if (!srcStr.empty() && srcStr[0] != '-') + outStr = std::string("+").append(srcStr); + else + outStr = srcStr; +} + static bool readField(ItemFieldInfos::const_iterator it, XmlNodeConstPtr node, std::string &combined) @@ -52,8 +61,8 @@ static bool readField(ItemFieldInfos::const_iterator it, std::string value2; if (field->sign) { - value1 = std::string("+").append(tokens[0]); - value2 = std::string("+").append(tokens[1]); + convertSignedValue(value1, tokens[0]); + convertSignedValue(value2, tokens[1]); } else { @@ -67,7 +76,7 @@ static bool readField(ItemFieldInfos::const_iterator it, else { if (field->sign) - value = std::string("+").append(value); + convertSignedValue(value, value); } const std::string format = translator->getStr(field->description); combined = strprintf(format.c_str(), -- cgit v1.2.3-60-g2f50