From 2443c7f6d3022b0120e405588db3a65e91e45f2f Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Mon, 22 Nov 2004 18:15:42 +0000 Subject: [PATCH] Allow negative numbers in RCDATA resources like RC.EXE does. Fix false out of 16 bits range warning. --- tools/wrc/parser.y | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index 59f3f65aa20..fd63561df98 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -1788,11 +1788,15 @@ raw_data: opt_lvc tBEGIN raw_elements tEND { raw_elements : tRAWDATA { $$ = $1; } | tNUMBER { $$ = int2raw_data($1); } + | '-' tNUMBER { $$ = int2raw_data(-($2)); } | tLNUMBER { $$ = long2raw_data($1); } + | '-' tLNUMBER { $$ = long2raw_data(-($2)); } | tSTRING { $$ = str2raw_data($1); } | raw_elements opt_comma tRAWDATA { $$ = merge_raw_data($1, $3); free($3->data); free($3); } | raw_elements opt_comma tNUMBER { $$ = merge_raw_data_int($1, $3); } + | raw_elements opt_comma '-' tNUMBER { $$ = merge_raw_data_int($1, -($4)); } | raw_elements opt_comma tLNUMBER { $$ = merge_raw_data_long($1, $3); } + | raw_elements opt_comma '-' tLNUMBER { $$ = merge_raw_data_long($1, -($4)); } | raw_elements opt_comma tSTRING { $$ = merge_raw_data_str($1, $3); } ; @@ -2314,7 +2318,8 @@ static raw_data_t *int2raw_data(int i) { raw_data_t *rd; - if((int)((short)i) != i) + if( ( i >= 0 && (int)((unsigned short)i) != i) || + ( i < 0 && (int)((short)i) != i) ) yywarning("Integer constant out of 16bit range (%d), truncated to %d\n", i, (short)i); rd = new_raw_data();