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

Alexandre Julliard julliard at winehq.org
Wed Jun 16 13:23:21 CDT 2010


Module: wine
Branch: master
Commit: cdf6947080695a288fec566506cb3dac99e915fd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cdf6947080695a288fec566506cb3dac99e915fd

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun 16 12:02:34 2010 +0200

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

---

 tools/wrc/parser.l |    9 ++++++---
 tools/wrc/parser.y |   10 +++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l
index e048665..834c568 100644
--- a/tools/wrc/parser.l
+++ b/tools/wrc/parser.l
@@ -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.
diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y
index a62bccf..cfc02f9 100644
--- a/tools/wrc/parser.y
+++ b/tools/wrc/parser.y
@@ -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)




More information about the wine-cvs mailing list