Fix unicode filename compare when wchar_t is not 16bit

Do not use wcscmp() which takes wchar_t arguments.
wchar_t bit width is system dependent. It is often 32bits.
Grafx2 supports 16bits wide characters

fixes b49fa1dfcc6209065c79f112b364a75f0d30e2b2
This commit is contained in:
Thomas Bernard 2019-04-26 23:56:47 +02:00
parent e76adfe9d9
commit 653593ba66
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
3 changed files with 16 additions and 1 deletions

View File

@ -827,7 +827,7 @@ void Read_list_of_drives(T_Fileselector *list, byte name_length)
#else #else
// case-sensitive // case-sensitive
#define FILENAME_COMPARE strcmp #define FILENAME_COMPARE strcmp
#define FILENAME_COMPARE_UNICODE wcscmp #define FILENAME_COMPARE_UNICODE Unicode_strcmp
#endif #endif

View File

@ -73,6 +73,18 @@ void Unicode_strlcat(word * dst, const word * src, size_t len)
Unicode_strlcpy(dst + dst_len, src, len - dst_len); Unicode_strlcpy(dst + dst_len, src, len - dst_len);
} }
/// Compare two unicode strings
int Unicode_strcmp(const word * s1, const word * s2)
{
while (*s1 == *s2)
{
if (*s1 == 0) return 0;
s1++;
s2++;
}
return (*s1 > *s2) ? 1 : -1;
}
/// Compare an unicode string with a regular Latin1 string /// Compare an unicode string with a regular Latin1 string
int Unicode_char_strcmp(const word * s1, const char * s2) int Unicode_char_strcmp(const word * s1, const char * s2)
{ {

View File

@ -46,6 +46,9 @@ void Unicode_strlcpy(word * dst, const word * src, size_t len);
/// Append unicode string to another /// Append unicode string to another
void Unicode_strlcat(word * dst, const word * src, size_t len); void Unicode_strlcat(word * dst, const word * src, size_t len);
/// Compare two unicode strings
int Unicode_strcmp(const word * s1, const word * s2);
/// Compare an unicode string with a regular Latin1 string /// Compare an unicode string with a regular Latin1 string
int Unicode_char_strcmp(const word * s1, const char * s2); int Unicode_char_strcmp(const word * s1, const char * s2);