Commit cdf69470 authored by Alexandre Julliard's avatar Alexandre Julliard

wrc: Avoid use of toupper/isupper on signed chars.

parent 02674b2b
...@@ -397,9 +397,12 @@ static unsigned long xstrtoul(const char *nptr, char **endptr, int base) ...@@ -397,9 +397,12 @@ static unsigned long xstrtoul(const char *nptr, char **endptr, int base)
\{ return tBEGIN; \{ return tBEGIN;
\} return tEND; \} return tEND;
[0-9]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } [0-9]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 10);
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } return (yytext[yyleng-1] == 'L' || yytext[yyleng-1] == 'l') ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { parser_lval.num = xstrtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; } 0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 16);
return (yytext[yyleng-1] == 'L' || yytext[yyleng-1] == 'l') ? tLNUMBER : tNUMBER; }
0[oO][0-7]+[lL]? { parser_lval.num = xstrtoul(yytext+2, 0, 8);
return (yytext[yyleng-1] == 'L' || yytext[yyleng-1] == 'l') ? tLNUMBER : tNUMBER; }
/* /*
* The next two rules scan identifiers and filenames. * The next two rules scan identifiers and filenames.
......
...@@ -2172,7 +2172,9 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev ...@@ -2172,7 +2172,9 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
if(key->type == str_char) if(key->type == str_char)
{ {
if((flags & WRC_AF_VIRTKEY) && (!isupper(key->str.cstr[0] & 0xff) && !isdigit(key->str.cstr[0] & 0xff))) if((flags & WRC_AF_VIRTKEY) &&
!((key->str.cstr[0] >= 'A' && key->str.cstr[0] <= 'Z') ||
(key->str.cstr[0] >= '0' && key->str.cstr[0] <= '9')))
yyerror("VIRTKEY code is not equal to ascii value"); yyerror("VIRTKEY code is not equal to ascii value");
if(key->str.cstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0) if(key->str.cstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)
...@@ -2181,7 +2183,7 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev ...@@ -2181,7 +2183,7 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
} }
else if(key->str.cstr[0] == '^') else if(key->str.cstr[0] == '^')
{ {
keycode = toupper(key->str.cstr[1]) - '@'; keycode = toupper((unsigned char)key->str.cstr[1]) - '@';
if(keycode >= ' ') if(keycode >= ' ')
yyerror("Control-code out of range"); yyerror("Control-code out of range");
} }
...@@ -2190,7 +2192,9 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev ...@@ -2190,7 +2192,9 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
} }
else else
{ {
if((flags & WRC_AF_VIRTKEY) && !isupperW(key->str.wstr[0]) && !isdigitW(key->str.wstr[0])) if((flags & WRC_AF_VIRTKEY) &&
!((key->str.wstr[0] >= 'A' && key->str.wstr[0] <= 'Z') ||
(key->str.wstr[0] >= '0' && key->str.wstr[0] <= '9')))
yyerror("VIRTKEY code is not equal to ascii value"); yyerror("VIRTKEY code is not equal to ascii value");
if(key->str.wstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0) if(key->str.wstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment