diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index e1e7c6638..96d97eb2b 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -749,7 +749,7 @@ generic_string stringJoin(const std::vector& strings, const gene return joined; } -int stoiStrict(const generic_string& input) +long long stollStrict(const generic_string& input) { if (input.empty()) { @@ -774,7 +774,7 @@ int stoiStrict(const generic_string& input) throw std::invalid_argument("Invalid character found."); } - return std::stoi(input); + return std::stoll(input); } } @@ -786,7 +786,7 @@ bool allLinesAreNumericOrEmpty(const std::vector& lines) { if (!line.empty()) { - stoiStrict(line); + stollStrict(line); } } catch (std::invalid_argument&) @@ -833,9 +833,9 @@ std::vector numericSort(std::vector input, bool { // Pre-condition: all strings in "input" are either empty or convertible to int with stoiStrict. // Note that empty lines are filtered out and added back manually to the output at the end. - std::vector nonEmptyinputAsInts; + std::vector nonEmptyInputAsNumbers; size_t nofEmptyLines = 0; - nonEmptyinputAsInts.reserve(input.size()); + nonEmptyInputAsNumbers.reserve(input.size()); for (const generic_string& line : input) { if (line.empty()) @@ -844,11 +844,11 @@ std::vector numericSort(std::vector input, bool } else { - nonEmptyinputAsInts.push_back(stoiStrict(line)); + nonEmptyInputAsNumbers.push_back(stollStrict(line)); } } assert(nonEmptyinputAsInts.size() + nofEmptyLines == input.size()); - std::sort(nonEmptyinputAsInts.begin(), nonEmptyinputAsInts.end(), [isDescending](int a, int b) + std::sort(nonEmptyInputAsNumbers.begin(), nonEmptyInputAsNumbers.end(), [isDescending](long long a, long long b) { if (isDescending) { @@ -866,9 +866,9 @@ std::vector numericSort(std::vector input, bool { output.insert(output.end(), empties.begin(), empties.end()); } - for (const int& sortedInt : nonEmptyinputAsInts) + for (const long long& sortedNumber : nonEmptyInputAsNumbers) { - output.push_back(std::to_wstring(sortedInt)); + output.push_back(std::to_wstring(sortedNumber)); } if (isDescending) { diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index a86e63298..2e90fea69 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -190,7 +190,7 @@ generic_string stringToUpper(generic_string strToConvert); generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace); std::vector stringSplit(const generic_string& input, const generic_string& delimiter); generic_string stringJoin(const std::vector& strings, const generic_string& separator); -int stoiStrict(const generic_string& input); +long long stollStrict(const generic_string& input); bool allLinesAreNumericOrEmpty(const std::vector& lines); std::vector repeatString(const generic_string& text, const size_t count);