mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
[GUI] Avoid overflow in alphanum sorting
This commit is contained in:
parent
c52940abc4
commit
fb574064c9
@ -67,11 +67,17 @@ namespace AssetStudioGUI
|
||||
|
||||
if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
|
||||
{
|
||||
int thisNumericChunk = int.Parse(new string(space1));
|
||||
int thatNumericChunk = int.Parse(new string(space2));
|
||||
if (long.TryParse(new string(space1), out long thisNumericChunk) &&
|
||||
long.TryParse(new string(space2), out long thatNumericChunk))
|
||||
{
|
||||
result = thisNumericChunk.CompareTo(thatNumericChunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = MemoryExtensions.CompareTo(space1, space2, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = MemoryExtensions.CompareTo(space1, space2, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
@ -72,11 +72,17 @@ namespace AssetStudioGUI
|
||||
|
||||
if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
|
||||
{
|
||||
int thisNumericChunk = int.Parse(space1);
|
||||
int thatNumericChunk = int.Parse(space2);
|
||||
if (long.TryParse(space1, out long thisNumericChunk) &&
|
||||
long.TryParse(space2, out long thatNumericChunk))
|
||||
{
|
||||
result = thisNumericChunk.CompareTo(thatNumericChunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = MemoryExtensions.CompareTo(space1, space2, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = MemoryExtensions.CompareTo(space1, space2, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user