1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed an edge-case in String::compareNatural

This commit is contained in:
jules 2018-02-05 11:12:15 +00:00
parent 56a6bf06cd
commit 6ee9030e37

View file

@ -681,7 +681,12 @@ static int naturalStringCompare (String::CharPointerType s1, String::CharPointer
const bool hasSpace2 = s2.isWhitespace();
if ((! firstLoop) && (hasSpace1 ^ hasSpace2))
{
if (s1.isEmpty()) return -1;
if (s2.isEmpty()) return 1;
return hasSpace2 ? 1 : -1;
}
firstLoop = false;
@ -690,8 +695,8 @@ static int naturalStringCompare (String::CharPointerType s1, String::CharPointer
if (s1.isDigit() && s2.isDigit())
{
const int result = (*s1 == '0' || *s2 == '0') ? stringCompareLeft (s1, s2)
: stringCompareRight (s1, s2);
auto result = (*s1 == '0' || *s2 == '0') ? stringCompareLeft (s1, s2)
: stringCompareRight (s1, s2);
if (result != 0)
return result;
@ -748,8 +753,8 @@ void String::appendCharPointer (const CharPointerType startOfTextToAppend,
{
jassert (startOfTextToAppend.getAddress() != nullptr && endOfTextToAppend.getAddress() != nullptr);
const int extraBytesNeeded = getAddressDifference (endOfTextToAppend.getAddress(),
startOfTextToAppend.getAddress());
auto extraBytesNeeded = getAddressDifference (endOfTextToAppend.getAddress(),
startOfTextToAppend.getAddress());
jassert (extraBytesNeeded >= 0);
if (extraBytesNeeded > 0)