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

oldstable
Alexandre Julliard 2010-06-16 12:02:34 +02:00
parent 02674b2b95
commit cdf6947080
2 changed files with 13 additions and 6 deletions

View File

@ -397,9 +397,12 @@ static unsigned long xstrtoul(const char *nptr, char **endptr, int base)
\{ return tBEGIN;
\} return tEND;
[0-9]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 16); return toupper(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-9]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 10);
return (yytext[yyleng-1] == 'L' || 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.

View File

@ -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((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");
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
}
else if(key->str.cstr[0] == '^')
{
keycode = toupper(key->str.cstr[1]) - '@';
keycode = toupper((unsigned char)key->str.cstr[1]) - '@';
if(keycode >= ' ')
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
}
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");
if(key->str.wstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)