wrc: Avoid locale- or Unicode-dependent case conversions.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e8076eeced
commit
865f23b503
|
@ -263,11 +263,13 @@ static void string_to_upper(string_t *str)
|
|||
|
||||
if(str->type == str_char)
|
||||
{
|
||||
for (i = 0; i < str->size; i++) str->str.cstr[i] = toupper((unsigned char)str->str.cstr[i]);
|
||||
for (i = 0; i < str->size; i++)
|
||||
if (str->str.cstr[i] >= 'a' && str->str.cstr[i] <= 'z') str->str.cstr[i] -= 32;
|
||||
}
|
||||
else if(str->type == str_unicode)
|
||||
{
|
||||
for (i = 0; i < str->size; i++) str->str.wstr[i] = toupperW(str->str.wstr[i]);
|
||||
for (i = 0; i < str->size; i++)
|
||||
if (str->str.wstr[i] >= 'a' && str->str.wstr[i] <= 'z') str->str.wstr[i] -= 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -250,7 +250,7 @@ static struct keyword keywords[] = {
|
|||
static int kw_cmp_func(const void *s1, const void *s2)
|
||||
{
|
||||
int ret;
|
||||
ret = strcasecmp(KWP(s1)->keyword, KWP(s2)->keyword);
|
||||
ret = compare_striA(KWP(s1)->keyword, KWP(s2)->keyword);
|
||||
if(!ret && (KWP(s1)->needcase || KWP(s2)->needcase))
|
||||
return strcmp(KWP(s1)->keyword, KWP(s2)->keyword);
|
||||
else
|
||||
|
|
|
@ -2072,37 +2072,23 @@ static int get_class_idW(const WCHAR *cc)
|
|||
static const WCHAR szSTATIC[] = {'S','T','A','T','I','C',0};
|
||||
static const WCHAR szSCROLLBAR[] = {'S','C','R','O','L','L','B','A','R',0};
|
||||
|
||||
if(!strcmpiW(szBUTTON, cc))
|
||||
return CT_BUTTON;
|
||||
if(!strcmpiW(szCOMBOBOX, cc))
|
||||
return CT_COMBOBOX;
|
||||
if(!strcmpiW(szLISTBOX, cc))
|
||||
return CT_LISTBOX;
|
||||
if(!strcmpiW(szEDIT, cc))
|
||||
return CT_EDIT;
|
||||
if(!strcmpiW(szSTATIC, cc))
|
||||
return CT_STATIC;
|
||||
if(!strcmpiW(szSCROLLBAR, cc))
|
||||
return CT_SCROLLBAR;
|
||||
|
||||
if(!compare_striW(szBUTTON, cc)) return CT_BUTTON;
|
||||
if(!compare_striW(szCOMBOBOX, cc)) return CT_COMBOBOX;
|
||||
if(!compare_striW(szLISTBOX, cc)) return CT_LISTBOX;
|
||||
if(!compare_striW(szEDIT, cc)) return CT_EDIT;
|
||||
if(!compare_striW(szSTATIC, cc)) return CT_STATIC;
|
||||
if(!compare_striW(szSCROLLBAR, cc)) return CT_SCROLLBAR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int get_class_idA(const char *cc)
|
||||
{
|
||||
if(!strcasecmp("BUTTON", cc))
|
||||
return CT_BUTTON;
|
||||
if(!strcasecmp("COMBOBOX", cc))
|
||||
return CT_COMBOBOX;
|
||||
if(!strcasecmp("LISTBOX", cc))
|
||||
return CT_LISTBOX;
|
||||
if(!strcasecmp("EDIT", cc))
|
||||
return CT_EDIT;
|
||||
if(!strcasecmp("STATIC", cc))
|
||||
return CT_STATIC;
|
||||
if(!strcasecmp("SCROLLBAR", cc))
|
||||
return CT_SCROLLBAR;
|
||||
|
||||
if(!compare_striA("BUTTON", cc)) return CT_BUTTON;
|
||||
if(!compare_striA("COMBOBOX", cc)) return CT_COMBOBOX;
|
||||
if(!compare_striA("LISTBOX", cc)) return CT_LISTBOX;
|
||||
if(!compare_striA("EDIT", cc)) return CT_EDIT;
|
||||
if(!compare_striA("STATIC", cc)) return CT_STATIC;
|
||||
if(!compare_striA("SCROLLBAR", cc)) return CT_SCROLLBAR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,6 +219,31 @@ char *xstrdup(const char *str)
|
|||
return strcpy(s, str);
|
||||
}
|
||||
|
||||
int compare_striA( const char *str1, const char *str2 )
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
/* only the A-Z range is case-insensitive */
|
||||
char ch1 = (*str1 >= 'a' && *str1 <= 'z') ? *str1 + 'A' - 'a' : *str1;
|
||||
char ch2 = (*str2 >= 'a' && *str2 <= 'z') ? *str2 + 'A' - 'a' : *str2;
|
||||
if (!ch1 || ch1 != ch2) return ch1 - ch2;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
}
|
||||
|
||||
int compare_striW( const WCHAR *str1, const WCHAR *str2 )
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
/* only the A-Z range is case-insensitive */
|
||||
WCHAR ch1 = (*str1 >= 'a' && *str1 <= 'z') ? *str1 + 'A' - 'a' : *str1;
|
||||
WCHAR ch2 = (*str2 >= 'a' && *str2 <= 'z') ? *str2 + 'A' - 'a' : *str2;
|
||||
if (!ch1 || ch1 != ch2) return ch1 - ch2;
|
||||
str1++;
|
||||
str2++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
|
@ -241,12 +266,12 @@ int compare_name_id(const name_id_t *n1, const name_id_t *n2)
|
|||
if(n1->name.s_name->type == str_char
|
||||
&& n2->name.s_name->type == str_char)
|
||||
{
|
||||
return strcasecmp(n1->name.s_name->str.cstr, n2->name.s_name->str.cstr);
|
||||
return compare_striA(n1->name.s_name->str.cstr, n2->name.s_name->str.cstr);
|
||||
}
|
||||
else if(n1->name.s_name->type == str_unicode
|
||||
&& n2->name.s_name->type == str_unicode)
|
||||
{
|
||||
return strcmpiW(n1->name.s_name->str.wstr, n2->name.s_name->str.wstr);
|
||||
return compare_striW(n1->name.s_name->str.wstr, n2->name.s_name->str.wstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -33,6 +33,8 @@ char *xstrdup(const char *str);
|
|||
#define __attribute__(X)
|
||||
#endif
|
||||
|
||||
int compare_striA( const char *str1, const char *str2 );
|
||||
int compare_striW( const WCHAR *str1, const WCHAR *str2 );
|
||||
char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 )));
|
||||
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
|
|
Loading…
Reference in New Issue