diff options
author | Michael Lutz <michi@icosahedron.de> | 2018-04-29 00:34:01 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2018-06-06 21:37:09 +0200 |
commit | f4394debdc092487d603f95716a026a5c8834f8c (patch) | |
tree | db4865150cfd88422f279d6fa5213ab11e27beab /src/string.cpp | |
parent | 2b662b448cd020886c00ff7ec800d7bd7cb008fa (diff) | |
download | openttd-f4394debdc092487d603f95716a026a5c8834f8c.tar.xz |
Add: [Win32] Native natural sort implementation.
Diffstat (limited to 'src/string.cpp')
-rw-r--r-- | src/string.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/string.cpp b/src/string.cpp index 6306e6f75..170334792 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -25,6 +25,10 @@ #include <errno.h> // required by vsnprintf implementation for MSVC #endif +#ifdef WIN32 +#include "os/windows/win32.h" +#endif + #ifdef WITH_ICU_SORT /* Required by strnatcmp. */ #include <unicode/ustring.h> @@ -572,15 +576,20 @@ int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front) s1 = SkipGarbage(s1); s2 = SkipGarbage(s2); } + #ifdef WITH_ICU_SORT if (_current_collator != NULL) { UErrorCode status = U_ZERO_ERROR; int result = _current_collator->compareUTF8(s1, s2, status); if (U_SUCCESS(status)) return result; } - #endif /* WITH_ICU_SORT */ +#if defined(WIN32) && !defined(STRGEN) && !defined(SETTINGSGEN) + int res = OTTDStringCompare(s1, s2); + if (res != 0) return res - 2; // Convert to normal C return values. +#endif + /* Do a normal comparison if ICU is missing or if we cannot create a collator. */ return strcasecmp(s1, s2); } |