Commit fc0cc66b authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Fix comparison of empty properties to numbers and add test cases.

parent 0940654d
......@@ -75,6 +75,30 @@ static INT compare_and_free_strings( LPWSTR a, INT op, LPWSTR b )
return r;
}
static BOOL num_from_prop( LPCWSTR p, INT *val )
{
INT ret = 0, sign = 1;
if (!p)
return FALSE;
if (*p == '-')
{
sign = -1;
p++;
}
if (!*p)
return FALSE;
while (*p)
{
if( *p < '0' || *p > '9' )
return FALSE;
ret = ret*10 + (*p - '0');
p++;
}
*val = ret*sign;
return TRUE;
}
%}
%pure-parser
......@@ -169,11 +193,13 @@ boolean_factor:
}
| symbol_s operator value_i
{
$$ = compare_int( $1 ? atoiW($1) : 0, $2, $3 );
int num;
$$ = num_from_prop( $1, &num ) && compare_int( num, $2, $3 );
}
| value_i operator symbol_s
{
$$ = compare_int( $1, $2, $3 ? atoiW($3) : 0 );
int num;
$$ = num_from_prop( $3, &num ) && compare_int( $1, $2, num );
}
| symbol_s operator symbol_s
{
......
......@@ -593,6 +593,60 @@ void test_condition(void)
r = MsiEvaluateCondition(hpkg, "Installed<>\"\"");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
r = MsiEvaluateCondition(hpkg, "NOT 1 AND 0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "0" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_TRUE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "asdf" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "0asdf" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "0 " );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "-0" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_TRUE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "0000000000000" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_TRUE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "--0" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "0x00" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "-" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "+0" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiSetProperty(hpkg, "bandalmael", "0.0" );
r = MsiEvaluateCondition(hpkg, "bandalmael=0");
ok( r == MSICONDITION_FALSE, "wrong return val\n");
MsiCloseHandle( hpkg );
}
......
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