mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
Fix comparison of empty properties to numbers and add test cases.
This commit is contained in:
parent
0940654da7
commit
fc0cc66b54
@ -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 );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user