Add a bunch of tests for MsiEvaluateCondition and make them pass.
This commit is contained in:
parent
4007d748dc
commit
9d43994ec2
669
dlls/msi/cond.y
669
dlls/msi/cond.y
|
@ -28,12 +28,14 @@
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
|
#include "winuser.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
|
|
||||||
#include "msi.h"
|
#include "msi.h"
|
||||||
#include "msiquery.h"
|
#include "msiquery.h"
|
||||||
#include "msipriv.h"
|
#include "msipriv.h"
|
||||||
|
#include "action.h"
|
||||||
|
|
||||||
#define YYLEX_PARAM info
|
#define YYLEX_PARAM info
|
||||||
#define YYPARSE_PARAM info
|
#define YYPARSE_PARAM info
|
||||||
|
@ -58,45 +60,20 @@ struct cond_str {
|
||||||
static LPWSTR COND_GetString( struct cond_str *str );
|
static LPWSTR COND_GetString( struct cond_str *str );
|
||||||
static LPWSTR COND_GetLiteral( struct cond_str *str );
|
static LPWSTR COND_GetLiteral( struct cond_str *str );
|
||||||
static int COND_lex( void *COND_lval, COND_input *info);
|
static int COND_lex( void *COND_lval, COND_input *info);
|
||||||
|
static const WCHAR szEmpty[] = { 0 };
|
||||||
|
|
||||||
typedef INT (*comp_int)(INT a, INT b);
|
static INT compare_int( INT a, INT operator, INT b );
|
||||||
typedef INT (*comp_str)(LPWSTR a, LPWSTR b, BOOL caseless);
|
static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b );
|
||||||
typedef INT (*comp_m1)(LPWSTR a,int b);
|
|
||||||
typedef INT (*comp_m2)(int a,LPWSTR b);
|
|
||||||
|
|
||||||
static INT comp_lt_i(INT a, INT b);
|
static INT compare_and_free_strings( LPWSTR a, INT op, LPWSTR b )
|
||||||
static INT comp_gt_i(INT a, INT b);
|
{
|
||||||
static INT comp_le_i(INT a, INT b);
|
INT r;
|
||||||
static INT comp_ge_i(INT a, INT b);
|
|
||||||
static INT comp_eq_i(INT a, INT b);
|
|
||||||
static INT comp_ne_i(INT a, INT b);
|
|
||||||
static INT comp_bitand(INT a, INT b);
|
|
||||||
static INT comp_highcomp(INT a, INT b);
|
|
||||||
static INT comp_lowcomp(INT a, INT b);
|
|
||||||
|
|
||||||
static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless);
|
r = compare_string( a, op, b );
|
||||||
static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless);
|
msi_free( a );
|
||||||
static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless);
|
msi_free( b );
|
||||||
static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless);
|
return r;
|
||||||
static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless);
|
}
|
||||||
static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless);
|
|
||||||
static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless);
|
|
||||||
static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless);
|
|
||||||
static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless);
|
|
||||||
|
|
||||||
static INT comp_eq_m1(LPWSTR a, INT b);
|
|
||||||
static INT comp_ne_m1(LPWSTR a, INT b);
|
|
||||||
static INT comp_lt_m1(LPWSTR a, INT b);
|
|
||||||
static INT comp_gt_m1(LPWSTR a, INT b);
|
|
||||||
static INT comp_le_m1(LPWSTR a, INT b);
|
|
||||||
static INT comp_ge_m1(LPWSTR a, INT b);
|
|
||||||
|
|
||||||
static INT comp_eq_m2(INT a, LPWSTR b);
|
|
||||||
static INT comp_ne_m2(INT a, LPWSTR b);
|
|
||||||
static INT comp_lt_m2(INT a, LPWSTR b);
|
|
||||||
static INT comp_gt_m2(INT a, LPWSTR b);
|
|
||||||
static INT comp_le_m2(INT a, LPWSTR b);
|
|
||||||
static INT comp_ge_m2(INT a, LPWSTR b);
|
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -107,28 +84,22 @@ static INT comp_ge_m2(INT a, LPWSTR b);
|
||||||
struct cond_str str;
|
struct cond_str str;
|
||||||
LPWSTR string;
|
LPWSTR string;
|
||||||
INT value;
|
INT value;
|
||||||
comp_int fn_comp_int;
|
|
||||||
comp_str fn_comp_str;
|
|
||||||
comp_m1 fn_comp_m1;
|
|
||||||
comp_m2 fn_comp_m2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%token COND_SPACE COND_EOF COND_SPACE
|
%token COND_SPACE COND_EOF COND_SPACE
|
||||||
%token COND_OR COND_AND COND_NOT
|
%token COND_OR COND_AND COND_NOT COND_XOR COND_IMP COND_EQV
|
||||||
%token COND_LT COND_GT COND_EQ
|
%token COND_LT COND_GT COND_EQ COND_NE COND_GE COND_LE
|
||||||
%token COND_LPAR COND_RPAR COND_TILDA
|
%token COND_ILT COND_IGT COND_IEQ COND_INE COND_IGE COND_ILE
|
||||||
|
%token COND_LPAR COND_RPAR COND_TILDA COND_SS COND_ISS
|
||||||
|
%token COND_ILHS COND_IRHS COND_LHS COND_RHS
|
||||||
%token COND_PERCENT COND_DOLLARS COND_QUESTION COND_AMPER COND_EXCLAM
|
%token COND_PERCENT COND_DOLLARS COND_QUESTION COND_AMPER COND_EXCLAM
|
||||||
%token <str> COND_IDENT <str> COND_NUMBER <str> COND_LITER
|
%token <str> COND_IDENT <str> COND_NUMBER <str> COND_LITER
|
||||||
|
|
||||||
%nonassoc COND_EOF COND_ERROR
|
%nonassoc COND_ERROR COND_EOF
|
||||||
|
|
||||||
%type <value> expression boolean_term boolean_factor
|
%type <value> expression boolean_term boolean_factor
|
||||||
%type <value> term value_i symbol_i integer
|
%type <value> value_i integer operator
|
||||||
%type <string> identifier value_s symbol_s literal
|
%type <string> identifier symbol_s value_s literal
|
||||||
%type <fn_comp_int> comp_op_i
|
|
||||||
%type <fn_comp_str> comp_op_s
|
|
||||||
%type <fn_comp_m1> comp_op_m1
|
|
||||||
%type <fn_comp_m2> comp_op_m2
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
@ -150,10 +121,22 @@ expression:
|
||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| boolean_term COND_OR expression
|
| expression COND_OR boolean_term
|
||||||
{
|
{
|
||||||
$$ = $1 || $3;
|
$$ = $1 || $3;
|
||||||
}
|
}
|
||||||
|
| expression COND_IMP boolean_term
|
||||||
|
{
|
||||||
|
$$ = !$1 || $3;
|
||||||
|
}
|
||||||
|
| expression COND_XOR boolean_term
|
||||||
|
{
|
||||||
|
$$ = ( $1 || $3 ) && !( $1 && $3 );
|
||||||
|
}
|
||||||
|
| expression COND_EQV boolean_term
|
||||||
|
{
|
||||||
|
$$ = ( $1 && $3 ) || ( !$1 && !$3 );
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
boolean_term:
|
boolean_term:
|
||||||
|
@ -168,52 +151,53 @@ boolean_term:
|
||||||
;
|
;
|
||||||
|
|
||||||
boolean_factor:
|
boolean_factor:
|
||||||
term
|
COND_NOT boolean_factor
|
||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $2 ? 0 : 1;
|
||||||
}
|
}
|
||||||
| COND_NOT term
|
| value_i
|
||||||
{
|
{
|
||||||
$$ = ! $2;
|
$$ = $1 ? 1 : 0;
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
term:
|
|
||||||
value_i
|
|
||||||
{
|
|
||||||
$$ = $1;
|
|
||||||
}
|
}
|
||||||
| value_s
|
| value_s
|
||||||
{
|
{
|
||||||
$$ = ($1 && $1[0]) ? MSICONDITION_TRUE : MSICONDITION_FALSE;
|
$$ = ($1 && $1[0]) ? 1 : 0;
|
||||||
msi_free( $1 );
|
|
||||||
}
|
}
|
||||||
| value_i comp_op_i value_i
|
| value_i operator value_i
|
||||||
{
|
{
|
||||||
$$ = $2( $1, $3 );
|
$$ = compare_int( $1, $2, $3 );
|
||||||
}
|
}
|
||||||
| value_s comp_op_s value_s
|
| symbol_s operator value_i
|
||||||
{
|
{
|
||||||
$$ = $2( $1, $3, FALSE );
|
$$ = compare_int( $1 ? atoiW($1) : 0, $2, $3 );
|
||||||
msi_free( $1 );
|
|
||||||
msi_free( $3 );
|
|
||||||
}
|
}
|
||||||
| value_s COND_TILDA comp_op_s value_s
|
| value_i operator symbol_s
|
||||||
{
|
{
|
||||||
$$ = $3( $1, $4, TRUE );
|
$$ = compare_int( $1, $2, $3 ? atoiW($3) : 0 );
|
||||||
msi_free( $1 );
|
|
||||||
msi_free( $4 );
|
|
||||||
}
|
}
|
||||||
| value_s comp_op_m1 value_i
|
| symbol_s operator symbol_s
|
||||||
{
|
{
|
||||||
$$ = $2( $1, $3 );
|
$$ = compare_and_free_strings( $1, $2, $3 );
|
||||||
msi_free( $1 );
|
|
||||||
}
|
}
|
||||||
| value_i comp_op_m2 value_s
|
| symbol_s operator literal
|
||||||
{
|
{
|
||||||
$$ = $2( $1, $3 );
|
$$ = compare_and_free_strings( $1, $2, $3 );
|
||||||
msi_free( $3 );
|
}
|
||||||
|
| literal operator symbol_s
|
||||||
|
{
|
||||||
|
$$ = compare_and_free_strings( $1, $2, $3 );
|
||||||
|
}
|
||||||
|
| literal operator literal
|
||||||
|
{
|
||||||
|
$$ = compare_and_free_strings( $1, $2, $3 );
|
||||||
|
}
|
||||||
|
| literal operator value_i
|
||||||
|
{
|
||||||
|
$$ = 0;
|
||||||
|
}
|
||||||
|
| value_i operator literal
|
||||||
|
{
|
||||||
|
$$ = 0;
|
||||||
}
|
}
|
||||||
| COND_LPAR expression COND_RPAR
|
| COND_LPAR expression COND_RPAR
|
||||||
{
|
{
|
||||||
|
@ -221,179 +205,26 @@ term:
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
comp_op_i:
|
operator:
|
||||||
/* common functions */
|
/* common functions */
|
||||||
COND_EQ
|
COND_EQ { $$ = COND_EQ }
|
||||||
{
|
| COND_NE { $$ = COND_NE }
|
||||||
$$ = comp_eq_i;
|
| COND_LT { $$ = COND_LT }
|
||||||
}
|
| COND_GT { $$ = COND_GT }
|
||||||
| COND_LT COND_GT
|
| COND_LE { $$ = COND_LE }
|
||||||
{
|
| COND_GE { $$ = COND_GE }
|
||||||
$$ = comp_ne_i;
|
| COND_SS { $$ = COND_SS }
|
||||||
}
|
| COND_IEQ { $$ = COND_IEQ }
|
||||||
| COND_LT
|
| COND_INE { $$ = COND_INE }
|
||||||
{
|
| COND_ILT { $$ = COND_ILT }
|
||||||
$$ = comp_lt_i;
|
| COND_IGT { $$ = COND_IGT }
|
||||||
}
|
| COND_ILE { $$ = COND_ILE }
|
||||||
| COND_GT
|
| COND_IGE { $$ = COND_IGE }
|
||||||
{
|
| COND_ISS { $$ = COND_ISS }
|
||||||
$$ = comp_gt_i;
|
| COND_LHS { $$ = COND_LHS }
|
||||||
}
|
| COND_RHS { $$ = COND_RHS }
|
||||||
| COND_LT COND_EQ
|
| COND_ILHS { $$ = COND_ILHS }
|
||||||
{
|
| COND_IRHS { $$ = COND_IRHS }
|
||||||
$$ = comp_le_i;
|
|
||||||
}
|
|
||||||
| COND_GT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_ge_i;
|
|
||||||
}
|
|
||||||
/*Int only*/
|
|
||||||
| COND_GT COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_bitand;
|
|
||||||
}
|
|
||||||
| COND_LT COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_highcomp;
|
|
||||||
}
|
|
||||||
| COND_GT COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_lowcomp;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
comp_op_s:
|
|
||||||
/* common functions */
|
|
||||||
COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_eq_s;
|
|
||||||
}
|
|
||||||
| COND_LT COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_ne_s;
|
|
||||||
}
|
|
||||||
| COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_lt_s;
|
|
||||||
}
|
|
||||||
| COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_gt_s;
|
|
||||||
}
|
|
||||||
| COND_LT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_le_s;
|
|
||||||
}
|
|
||||||
| COND_GT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_ge_s;
|
|
||||||
}
|
|
||||||
/*string only*/
|
|
||||||
| COND_GT COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_substring;
|
|
||||||
}
|
|
||||||
| COND_LT COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_start;
|
|
||||||
}
|
|
||||||
| COND_GT COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_end;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
comp_op_m1:
|
|
||||||
/* common functions */
|
|
||||||
COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_eq_m1;
|
|
||||||
}
|
|
||||||
| COND_LT COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_ne_m1;
|
|
||||||
}
|
|
||||||
| COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_lt_m1;
|
|
||||||
}
|
|
||||||
| COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_gt_m1;
|
|
||||||
}
|
|
||||||
| COND_LT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_le_m1;
|
|
||||||
}
|
|
||||||
| COND_GT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_ge_m1;
|
|
||||||
}
|
|
||||||
/*Not valid for mixed compares*/
|
|
||||||
| COND_GT COND_LT
|
|
||||||
{
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
| COND_LT COND_LT
|
|
||||||
{
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
| COND_GT COND_GT
|
|
||||||
{
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
comp_op_m2:
|
|
||||||
/* common functions */
|
|
||||||
COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_eq_m2;
|
|
||||||
}
|
|
||||||
| COND_LT COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_ne_m2;
|
|
||||||
}
|
|
||||||
| COND_LT
|
|
||||||
{
|
|
||||||
$$ = comp_lt_m2;
|
|
||||||
}
|
|
||||||
| COND_GT
|
|
||||||
{
|
|
||||||
$$ = comp_gt_m2;
|
|
||||||
}
|
|
||||||
| COND_LT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_le_m2;
|
|
||||||
}
|
|
||||||
| COND_GT COND_EQ
|
|
||||||
{
|
|
||||||
$$ = comp_ge_m2;
|
|
||||||
}
|
|
||||||
/*Not valid for mixed compares*/
|
|
||||||
| COND_GT COND_LT
|
|
||||||
{
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
| COND_LT COND_LT
|
|
||||||
{
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
| COND_GT COND_GT
|
|
||||||
{
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
value_i:
|
|
||||||
symbol_i
|
|
||||||
{
|
|
||||||
$$ = $1;
|
|
||||||
}
|
|
||||||
| integer
|
|
||||||
{
|
|
||||||
$$ = $1;
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
value_s:
|
value_s:
|
||||||
|
@ -416,8 +247,12 @@ literal:
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
symbol_i:
|
value_i:
|
||||||
COND_DOLLARS identifier
|
integer
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
| COND_DOLLARS identifier
|
||||||
{
|
{
|
||||||
COND_input* cond = (COND_input*) info;
|
COND_input* cond = (COND_input*) info;
|
||||||
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
|
INSTALLSTATE install = INSTALLSTATE_UNKNOWN, action = INSTALLSTATE_UNKNOWN;
|
||||||
|
@ -458,34 +293,18 @@ symbol_i:
|
||||||
symbol_s:
|
symbol_s:
|
||||||
identifier
|
identifier
|
||||||
{
|
{
|
||||||
DWORD sz;
|
|
||||||
COND_input* cond = (COND_input*) info;
|
COND_input* cond = (COND_input*) info;
|
||||||
|
|
||||||
sz = 0;
|
$$ = msi_dup_property( cond->package, $1 );
|
||||||
MSI_GetPropertyW(cond->package, $1, NULL, &sz);
|
|
||||||
if (sz == 0)
|
|
||||||
{
|
|
||||||
$$ = msi_alloc( sizeof(WCHAR));
|
|
||||||
$$[0] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sz ++;
|
|
||||||
$$ = msi_alloc( sz*sizeof (WCHAR) );
|
|
||||||
|
|
||||||
/* Lookup the identifier */
|
|
||||||
|
|
||||||
MSI_GetPropertyW(cond->package,$1,$$,&sz);
|
|
||||||
}
|
|
||||||
msi_free( $1 );
|
msi_free( $1 );
|
||||||
}
|
}
|
||||||
| COND_PERCENT identifier
|
| COND_PERCENT identifier
|
||||||
{
|
{
|
||||||
UINT len = GetEnvironmentVariableW( $2, NULL, 0 );
|
UINT len = GetEnvironmentVariableW( $2, NULL, 0 );
|
||||||
if( len++ )
|
$$ = NULL;
|
||||||
|
if (len++)
|
||||||
{
|
{
|
||||||
$$ = msi_alloc( len*sizeof (WCHAR) );
|
$$ = msi_alloc( len*sizeof (WCHAR) );
|
||||||
if( $$ )
|
|
||||||
GetEnvironmentVariableW( $2, $$, len );
|
GetEnvironmentVariableW( $2, $$, len );
|
||||||
}
|
}
|
||||||
msi_free( $2 );
|
msi_free( $2 );
|
||||||
|
@ -527,83 +346,101 @@ static int COND_IsNumber( WCHAR x )
|
||||||
return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') );
|
return( (( x >= '0' ) && ( x <= '9' )) || (x =='-') || (x =='.') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static WCHAR *strstriW( const WCHAR *str, const WCHAR *sub )
|
||||||
/* the mess of comparison functions */
|
|
||||||
|
|
||||||
static INT comp_lt_i(INT a, INT b)
|
|
||||||
{ return (a < b); }
|
|
||||||
static INT comp_gt_i(INT a, INT b)
|
|
||||||
{ return (a > b); }
|
|
||||||
static INT comp_le_i(INT a, INT b)
|
|
||||||
{ return (a <= b); }
|
|
||||||
static INT comp_ge_i(INT a, INT b)
|
|
||||||
{ return (a >= b); }
|
|
||||||
static INT comp_eq_i(INT a, INT b)
|
|
||||||
{ return (a == b); }
|
|
||||||
static INT comp_ne_i(INT a, INT b)
|
|
||||||
{ return (a != b); }
|
|
||||||
static INT comp_bitand(INT a, INT b)
|
|
||||||
{ return a & b;}
|
|
||||||
static INT comp_highcomp(INT a, INT b)
|
|
||||||
{ return HIWORD(a)==b; }
|
|
||||||
static INT comp_lowcomp(INT a, INT b)
|
|
||||||
{ return LOWORD(a)==b; }
|
|
||||||
|
|
||||||
static INT comp_eq_s(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return !strcmpiW(a,b); else return !strcmpW(a,b);}
|
|
||||||
static INT comp_ne_s(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return strcmpiW(a,b); else return strcmpW(a,b);}
|
|
||||||
static INT comp_lt_s(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return strcmpiW(a,b)<0; else return strcmpW(a,b)<0;}
|
|
||||||
static INT comp_gt_s(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return strcmpiW(a,b)>0; else return strcmpW(a,b)>0;}
|
|
||||||
static INT comp_le_s(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return strcmpiW(a,b)<=0; else return strcmpW(a,b)<=0;}
|
|
||||||
static INT comp_ge_s(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return strcmpiW(a,b)>=0; else return strcmpW(a,b)>=0;}
|
|
||||||
static INT comp_substring(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
/* ERROR NOT WORKING REWRITE */
|
|
||||||
{ if (casless) return strstrW(a,b)!=NULL; else return strstrW(a,b)!=NULL;}
|
|
||||||
static INT comp_start(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{ if (casless) return strncmpiW(a,b,strlenW(b))==0;
|
|
||||||
else return strncmpW(a,b,strlenW(b))==0;}
|
|
||||||
static INT comp_end(LPWSTR a, LPWSTR b, BOOL casless)
|
|
||||||
{
|
{
|
||||||
int i = strlenW(a);
|
LPWSTR strlower, sublower, r;
|
||||||
int j = strlenW(b);
|
strlower = CharLowerW( strdupW( str ) );
|
||||||
if (j>i)
|
sublower = CharLowerW( strdupW( sub ) );
|
||||||
|
r = strstrW( strlower, sublower );
|
||||||
|
if (r)
|
||||||
|
r = (LPWSTR)str + (r - strlower);
|
||||||
|
msi_free( strlower );
|
||||||
|
msi_free( sublower );
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static INT compare_string( LPCWSTR a, INT operator, LPCWSTR b )
|
||||||
|
{
|
||||||
|
/* a or b may be NULL */
|
||||||
|
switch (operator)
|
||||||
|
{
|
||||||
|
case COND_LT:
|
||||||
|
return -1 == lstrcmpW( a, b );
|
||||||
|
case COND_GT:
|
||||||
|
return 1 == lstrcmpW( a, b );
|
||||||
|
case COND_EQ:
|
||||||
|
return 0 == lstrcmpW( a, b );
|
||||||
|
case COND_NE:
|
||||||
|
return 0 != lstrcmpW( a, b );
|
||||||
|
case COND_GE:
|
||||||
|
return -1 != lstrcmpW( a, b );
|
||||||
|
case COND_LE:
|
||||||
|
return 1 != lstrcmpW( a, b );
|
||||||
|
case COND_SS: /* substring */
|
||||||
|
return ( a && b && strstrW( a, b ) ) ? 1 : 0;
|
||||||
|
case COND_ILT:
|
||||||
|
return -1 == lstrcmpiW( a, b );
|
||||||
|
case COND_IGT:
|
||||||
|
return 1 == lstrcmpiW( a, b );
|
||||||
|
case COND_IEQ:
|
||||||
|
return 0 == lstrcmpiW( a, b );
|
||||||
|
case COND_INE:
|
||||||
|
return 0 != lstrcmpiW( a, b );
|
||||||
|
case COND_IGE:
|
||||||
|
return -1 != lstrcmpiW( a, b );
|
||||||
|
case COND_ILE:
|
||||||
|
return 1 != lstrcmpiW( a, b );
|
||||||
|
case COND_ISS:
|
||||||
|
return ( a && b && strstriW( a, b ) ) ? 1 : 0;
|
||||||
|
case COND_LHS:
|
||||||
|
case COND_RHS:
|
||||||
|
case COND_ILHS:
|
||||||
|
case COND_IRHS:
|
||||||
|
ERR("unimplemented string comparison\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERR("invalid integer operator\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
if (casless) return (!strcmpiW(&a[i-j-1],b));
|
|
||||||
else return (!strcmpW(&a[i-j-1],b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static INT comp_eq_m1(LPWSTR a, INT b)
|
static INT compare_int( INT a, INT operator, INT b )
|
||||||
{ if (COND_IsNumber(a[0])) return atoiW(a)==b; else return 0;}
|
{
|
||||||
static INT comp_ne_m1(LPWSTR a, INT b)
|
switch (operator)
|
||||||
{ if (COND_IsNumber(a[0])) return atoiW(a)!=b; else return 1;}
|
{
|
||||||
static INT comp_lt_m1(LPWSTR a, INT b)
|
case COND_LT:
|
||||||
{ if (COND_IsNumber(a[0])) return atoiW(a)<b; else return 0;}
|
case COND_ILT:
|
||||||
static INT comp_gt_m1(LPWSTR a, INT b)
|
return a < b;
|
||||||
{ if (COND_IsNumber(a[0])) return atoiW(a)>b; else return 0;}
|
case COND_GT:
|
||||||
static INT comp_le_m1(LPWSTR a, INT b)
|
case COND_IGT:
|
||||||
{ if (COND_IsNumber(a[0])) return atoiW(a)<=b; else return 0;}
|
return a > b;
|
||||||
static INT comp_ge_m1(LPWSTR a, INT b)
|
case COND_EQ:
|
||||||
{ if (COND_IsNumber(a[0])) return atoiW(a)>=b; else return 0;}
|
case COND_IEQ:
|
||||||
|
return a == b;
|
||||||
static INT comp_eq_m2(INT a, LPWSTR b)
|
case COND_NE:
|
||||||
{ if (COND_IsNumber(b[0])) return a == atoiW(b); else return 0;}
|
case COND_INE:
|
||||||
static INT comp_ne_m2(INT a, LPWSTR b)
|
return a != b;
|
||||||
{ if (COND_IsNumber(b[0])) return a != atoiW(b); else return 1;}
|
case COND_GE:
|
||||||
static INT comp_lt_m2(INT a, LPWSTR b)
|
case COND_IGE:
|
||||||
{ if (COND_IsNumber(b[0])) return a < atoiW(b); else return 0;}
|
return a >= b;
|
||||||
static INT comp_gt_m2(INT a, LPWSTR b)
|
case COND_LE:
|
||||||
{ if (COND_IsNumber(b[0])) return a > atoiW(b); else return 0;}
|
case COND_ILE:
|
||||||
static INT comp_le_m2(INT a, LPWSTR b)
|
return a >= b;
|
||||||
{ if (COND_IsNumber(b[0])) return a <= atoiW(b); else return 0;}
|
case COND_SS:
|
||||||
static INT comp_ge_m2(INT a, LPWSTR b)
|
case COND_ISS:
|
||||||
{ if (COND_IsNumber(b[0])) return a >= atoiW(b); else return 0;}
|
return ( a & b ) ? 1 : 0;
|
||||||
|
case COND_RHS:
|
||||||
|
return ( ( a & 0xffff ) == b ) ? 1 : 0;
|
||||||
|
case COND_LHS:
|
||||||
|
return ( ( (a>>16) & 0xffff ) == b ) ? 1 : 0;
|
||||||
|
default:
|
||||||
|
ERR("invalid integer operator\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int COND_IsIdent( WCHAR x )
|
static int COND_IsIdent( WCHAR x )
|
||||||
|
@ -612,17 +449,54 @@ static int COND_IsIdent( WCHAR x )
|
||||||
|| ( x == '#' ) || (x == '.') );
|
|| ( x == '#' ) || (x == '.') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int COND_GetOperator( COND_input *cond )
|
||||||
|
{
|
||||||
|
static const struct {
|
||||||
|
const WCHAR str[4];
|
||||||
|
int id;
|
||||||
|
} table[] = {
|
||||||
|
{ {'~','=',0}, COND_IEQ },
|
||||||
|
{ {'~','>','=',0}, COND_ILE },
|
||||||
|
{ {'~','>','<',0}, COND_ISS },
|
||||||
|
{ {'~','>','>',0}, COND_IRHS },
|
||||||
|
{ {'~','>',0}, COND_ILT },
|
||||||
|
{ {'~','<','>',0}, COND_INE },
|
||||||
|
{ {'~','<','=',0}, COND_IGE },
|
||||||
|
{ {'~','<','<',0}, COND_ILHS },
|
||||||
|
{ {'~','<',0}, COND_IGT },
|
||||||
|
{ {'>','=',0}, COND_GE },
|
||||||
|
{ {'>','<',0}, COND_SS },
|
||||||
|
{ {'>','>',0}, COND_LHS },
|
||||||
|
{ {'>',0}, COND_GT },
|
||||||
|
{ {'<','>',0}, COND_NE },
|
||||||
|
{ {'<','=',0}, COND_LE },
|
||||||
|
{ {'<','<',0}, COND_RHS },
|
||||||
|
{ {'<',0}, COND_LT },
|
||||||
|
{ {0}, 0 }
|
||||||
|
};
|
||||||
|
LPCWSTR p = &cond->str[cond->n];
|
||||||
|
int i = 0, len;
|
||||||
|
|
||||||
|
while ( 1 )
|
||||||
|
{
|
||||||
|
len = lstrlenW( table[i].str );
|
||||||
|
if ( !len || 0 == strncmpW( table[i].str, p, len ) )
|
||||||
|
break;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
cond->n += len;
|
||||||
|
return table[i].id;
|
||||||
|
}
|
||||||
|
|
||||||
static int COND_GetOne( struct cond_str *str, COND_input *cond )
|
static int COND_GetOne( struct cond_str *str, COND_input *cond )
|
||||||
{
|
{
|
||||||
static const WCHAR szNot[] = {'N','O','T',0};
|
|
||||||
static const WCHAR szAnd[] = {'A','N','D',0};
|
|
||||||
static const WCHAR szOr[] = {'O','R',0};
|
|
||||||
WCHAR ch;
|
|
||||||
int rc, len = 1;
|
int rc, len = 1;
|
||||||
|
WCHAR ch;
|
||||||
|
|
||||||
str->data = &cond->str[cond->n];
|
str->data = &cond->str[cond->n];
|
||||||
|
|
||||||
ch = str->data[0];
|
ch = str->data[0];
|
||||||
|
|
||||||
switch( ch )
|
switch( ch )
|
||||||
{
|
{
|
||||||
case 0: return 0;
|
case 0: return 0;
|
||||||
|
@ -635,57 +509,72 @@ static int COND_GetOne( struct cond_str *str, COND_input *cond )
|
||||||
case '%': rc = COND_PERCENT; break;
|
case '%': rc = COND_PERCENT; break;
|
||||||
case ' ': rc = COND_SPACE; break;
|
case ' ': rc = COND_SPACE; break;
|
||||||
case '=': rc = COND_EQ; break;
|
case '=': rc = COND_EQ; break;
|
||||||
case '~': rc = COND_TILDA; break;
|
|
||||||
case '<': rc = COND_LT; break;
|
|
||||||
case '>': rc = COND_GT; break;
|
|
||||||
case '"':
|
|
||||||
{
|
|
||||||
const WCHAR *ch2 = str->data + 1;
|
|
||||||
|
|
||||||
|
|
||||||
while ( *ch2 && *ch2 != '"' )
|
|
||||||
++ch2;
|
|
||||||
if (*ch2 == '"')
|
|
||||||
{
|
|
||||||
len = ch2 - str->data + 1;
|
|
||||||
rc = COND_LITER;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
case '~':
|
||||||
ERR("Unterminated string\n");
|
case '<':
|
||||||
|
case '>':
|
||||||
|
rc = COND_GetOperator( cond );
|
||||||
|
if (!rc)
|
||||||
rc = COND_ERROR;
|
rc = COND_ERROR;
|
||||||
break;
|
return rc;
|
||||||
default:
|
default:
|
||||||
if( COND_IsAlpha( ch ) )
|
rc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( rc )
|
||||||
{
|
{
|
||||||
|
cond->n += len;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch == '"' )
|
||||||
|
{
|
||||||
|
LPCWSTR p = strchrW( str->data + 1, '"' );
|
||||||
|
if (!p)
|
||||||
|
return COND_ERROR;
|
||||||
|
len = p - str->data + 1;
|
||||||
|
rc = COND_LITER;
|
||||||
|
}
|
||||||
|
else if( COND_IsAlpha( ch ) )
|
||||||
|
{
|
||||||
|
static const WCHAR szNot[] = {'N','O','T',0};
|
||||||
|
static const WCHAR szAnd[] = {'A','N','D',0};
|
||||||
|
static const WCHAR szXor[] = {'X','O','R',0};
|
||||||
|
static const WCHAR szEqv[] = {'E','Q','V',0};
|
||||||
|
static const WCHAR szImp[] = {'I','M','P',0};
|
||||||
|
static const WCHAR szOr[] = {'O','R',0};
|
||||||
|
|
||||||
while( COND_IsIdent( str->data[len] ) )
|
while( COND_IsIdent( str->data[len] ) )
|
||||||
len++;
|
len++;
|
||||||
rc = COND_IDENT;
|
rc = COND_IDENT;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( COND_IsNumber( ch ) )
|
if ( len == 3 )
|
||||||
|
{
|
||||||
|
if ( !strncmpiW( str->data, szNot, len ) )
|
||||||
|
rc = COND_NOT;
|
||||||
|
else if( !strncmpiW( str->data, szAnd, len ) )
|
||||||
|
rc = COND_AND;
|
||||||
|
else if( !strncmpiW( str->data, szXor, len ) )
|
||||||
|
rc = COND_XOR;
|
||||||
|
else if( !strncmpiW( str->data, szEqv, len ) )
|
||||||
|
rc = COND_EQV;
|
||||||
|
else if( !strncmpiW( str->data, szImp, len ) )
|
||||||
|
rc = COND_IMP;
|
||||||
|
}
|
||||||
|
else if( (len == 2) && !strncmpiW( str->data, szOr, len ) )
|
||||||
|
rc = COND_OR;
|
||||||
|
}
|
||||||
|
else if( COND_IsNumber( ch ) )
|
||||||
{
|
{
|
||||||
while( COND_IsNumber( str->data[len] ) )
|
while( COND_IsNumber( str->data[len] ) )
|
||||||
len++;
|
len++;
|
||||||
rc = COND_NUMBER;
|
rc = COND_NUMBER;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
ERR("Got unknown character %c(%x)\n",ch,ch);
|
|
||||||
rc = COND_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* keyword identifiers */
|
|
||||||
if( rc == COND_IDENT )
|
|
||||||
{
|
{
|
||||||
if( (len==3) && (strncmpiW(str->data,szNot,len)==0) )
|
ERR("Got unknown character %c(%x)\n",ch,ch);
|
||||||
rc = COND_NOT;
|
return COND_ERROR;
|
||||||
else if( (len==3) && (strncmpiW(str->data,szAnd,len)==0) )
|
|
||||||
rc = COND_AND;
|
|
||||||
else if( (len==2) && (strncmpiW(str->data,szOr,len)==0) )
|
|
||||||
rc = COND_OR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cond->n += len;
|
cond->n += len;
|
||||||
|
@ -745,6 +634,8 @@ MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
|
||||||
COND_input cond;
|
COND_input cond;
|
||||||
MSICONDITION r;
|
MSICONDITION r;
|
||||||
|
|
||||||
|
TRACE("%s\n", debugstr_w( szCondition ) );
|
||||||
|
|
||||||
if ( szCondition == NULL )
|
if ( szCondition == NULL )
|
||||||
return MSICONDITION_NONE;
|
return MSICONDITION_NONE;
|
||||||
|
|
||||||
|
@ -753,14 +644,12 @@ MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *package, LPCWSTR szCondition )
|
||||||
cond.n = 0;
|
cond.n = 0;
|
||||||
cond.result = MSICONDITION_ERROR;
|
cond.result = MSICONDITION_ERROR;
|
||||||
|
|
||||||
TRACE("Evaluating %s\n",debugstr_w(szCondition));
|
|
||||||
|
|
||||||
if ( !COND_parse( &cond ) )
|
if ( !COND_parse( &cond ) )
|
||||||
r = cond.result;
|
r = cond.result;
|
||||||
else
|
else
|
||||||
r = MSICONDITION_ERROR;
|
r = MSICONDITION_ERROR;
|
||||||
|
|
||||||
TRACE("Evaluates to %i\n",r);
|
TRACE("%i <- %s\n", r, debugstr_w(szCondition));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,247 @@ static void test_gettargetpath_bad(void)
|
||||||
MsiCloseHandle( hpkg );
|
MsiCloseHandle( hpkg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_condition(void)
|
||||||
|
{
|
||||||
|
MSICONDITION r;
|
||||||
|
MSIHANDLE hpkg;
|
||||||
|
|
||||||
|
hpkg = package_from_db(create_package_db());
|
||||||
|
ok( hpkg, "failed to create package\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(0, NULL);
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, NULL);
|
||||||
|
ok( r == MSICONDITION_NONE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "");
|
||||||
|
ok( r == MSICONDITION_NONE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 = 0");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 <> 0");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 = 1");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 >= 1");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 >=");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " ");
|
||||||
|
ok( r == MSICONDITION_NONE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "LicView <> \"1\"");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "LicView <> \"0\"");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "LicView <> LicView");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "not 0");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "not LicView");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "not \"A\"");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "~not \"A\"");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "\"0\"");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 and 2");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "not 0 and 3");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "not 0 and 0");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "not 0 or 1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "(0)");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "(((((1))))))");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "(((((1)))))");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" < \"B\" ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" > \"B\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"1\" > \"12\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"100\" < \"21\" ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 < > 0");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "(1<<1) == 2");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" = \"a\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" ~ = \"a\" ");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" ~= \"a\" ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" ~= 1 ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " \"A\" = 1 ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " 1 ~= 1 ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " 1 ~= \"1\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " 1 = \"1\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " 0 = \"1\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " 0 < \"100\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, " 100 > \"0\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 XOR 1");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 IMP 1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 IMP 0");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 IMP 0");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 EQV 0");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 EQV 1");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 IMP 1 OR 0");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 IMPL 1");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "\"ASFD\" >< \"S\" ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"s\" ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"\" ");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "\"ASFD\" ~>< \"sss\" ");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
MsiSetProperty(hpkg, "mm", "5" );
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "mm = 5");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "mm < 6");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "mm <= 5");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "mm > 4");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "mm < 12");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "mm = \"5\"");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 = \"\"");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 AND \"\"");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 AND \"\"");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "1 AND \"1\"");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "3 >< 1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "3 >< 4");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "NOT 0 AND 0");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "NOT 1 OR 0");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 AND 1 OR 1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "0 AND 0 OR 1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "NOT 0 AND 1 OR 0");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "_1 = _1");
|
||||||
|
ok( r == MSICONDITION_TRUE, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "( 1 AND 1 ) = 2");
|
||||||
|
ok( r == MSICONDITION_ERROR, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiEvaluateCondition(hpkg, "NOT ( 1 AND 1 )");
|
||||||
|
ok( r == MSICONDITION_FALSE, "wrong return val\n");
|
||||||
|
|
||||||
|
MsiCloseHandle( hpkg );
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(package)
|
START_TEST(package)
|
||||||
{
|
{
|
||||||
test_createpackage();
|
test_createpackage();
|
||||||
|
|
Loading…
Reference in New Issue