Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
df42519c
Commit
df42519c
authored
Dec 23, 2015
by
Hans Leidekker
Committed by
Alexandre Julliard
Dec 23, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wbemprox: Support string literals in comparisons with integer properties.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4cce8cbd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
14 deletions
+79
-14
query.c
dlls/wbemprox/query.c
+68
-6
query.c
dlls/wbemprox/tests/query.c
+6
-1
wql.y
dlls/wbemprox/wql.y
+5
-7
No files found.
dlls/wbemprox/query.c
View file @
df42519c
...
...
@@ -108,10 +108,31 @@ static HRESULT eval_strcmp( UINT op, const WCHAR *lstr, const WCHAR *rstr, LONGL
return
S_OK
;
}
static
inline
BOOL
is_strcmp
(
const
struct
complex_expr
*
expr
)
static
BOOL
is_int
(
CIMTYPE
type
)
{
return
((
expr
->
left
->
type
==
EXPR_PROPVAL
&&
expr
->
right
->
type
==
EXPR_SVAL
)
||
(
expr
->
left
->
type
==
EXPR_SVAL
&&
expr
->
right
->
type
==
EXPR_PROPVAL
));
switch
(
type
)
{
case
CIM_SINT8
:
case
CIM_SINT16
:
case
CIM_SINT32
:
case
CIM_SINT64
:
case
CIM_UINT8
:
case
CIM_UINT16
:
case
CIM_UINT32
:
case
CIM_UINT64
:
return
TRUE
;
default:
return
FALSE
;
}
}
static
inline
BOOL
is_strcmp
(
const
struct
complex_expr
*
expr
,
UINT
ltype
,
UINT
rtype
)
{
if
((
ltype
==
CIM_STRING
||
is_int
(
ltype
))
&&
expr
->
left
->
type
==
EXPR_PROPVAL
&&
expr
->
right
->
type
==
EXPR_SVAL
)
return
TRUE
;
else
if
((
rtype
==
CIM_STRING
||
is_int
(
rtype
))
&&
expr
->
right
->
type
==
EXPR_PROPVAL
&&
expr
->
left
->
type
==
EXPR_SVAL
)
return
TRUE
;
return
FALSE
;
}
static
inline
BOOL
is_boolcmp
(
const
struct
complex_expr
*
expr
,
UINT
ltype
,
UINT
rtype
)
...
...
@@ -186,6 +207,41 @@ static UINT resolve_type( UINT left, UINT right )
return
CIM_ILLEGAL
;
}
static
const
WCHAR
*
format_int
(
WCHAR
*
buf
,
CIMTYPE
type
,
LONGLONG
val
)
{
static
const
WCHAR
fmt_signedW
[]
=
{
'%'
,
'd'
,
0
};
static
const
WCHAR
fmt_unsignedW
[]
=
{
'%'
,
'u'
,
0
};
static
const
WCHAR
fmt_signed64W
[]
=
{
'%'
,
'I'
,
'6'
,
'4'
,
'd'
,
0
};
static
const
WCHAR
fmt_unsigned64W
[]
=
{
'%'
,
'I'
,
'6'
,
'4'
,
'u'
,
0
};
switch
(
type
)
{
case
CIM_SINT8
:
case
CIM_SINT16
:
case
CIM_SINT32
:
sprintfW
(
buf
,
fmt_signedW
,
val
);
return
buf
;
case
CIM_UINT8
:
case
CIM_UINT16
:
case
CIM_UINT32
:
sprintfW
(
buf
,
fmt_unsignedW
,
val
);
return
buf
;
case
CIM_SINT64
:
wsprintfW
(
buf
,
fmt_signed64W
,
val
);
return
buf
;
case
CIM_UINT64
:
wsprintfW
(
buf
,
fmt_unsigned64W
,
val
);
return
buf
;
default:
ERR
(
"unhandled type %u
\n
"
,
type
);
return
NULL
;
}
}
static
HRESULT
eval_binary
(
const
struct
table
*
table
,
UINT
row
,
const
struct
complex_expr
*
expr
,
LONGLONG
*
val
,
UINT
*
type
)
{
...
...
@@ -202,10 +258,16 @@ static HRESULT eval_binary( const struct table *table, UINT row, const struct co
if
(
is_boolcmp
(
expr
,
ltype
,
rtype
))
return
eval_boolcmp
(
expr
->
op
,
lval
,
rval
,
ltype
,
rtype
,
val
);
if
(
is_strcmp
(
expr
))
if
(
is_strcmp
(
expr
,
ltype
,
rtype
))
{
const
WCHAR
*
lstr
=
(
const
WCHAR
*
)(
INT_PTR
)
lval
;
const
WCHAR
*
rstr
=
(
const
WCHAR
*
)(
INT_PTR
)
rval
;
const
WCHAR
*
lstr
,
*
rstr
;
WCHAR
lbuf
[
21
],
rbuf
[
21
];
if
(
is_int
(
ltype
))
lstr
=
format_int
(
lbuf
,
ltype
,
lval
);
else
lstr
=
(
const
WCHAR
*
)(
INT_PTR
)
lval
;
if
(
is_int
(
rtype
))
rstr
=
format_int
(
rbuf
,
ltype
,
rval
);
else
rstr
=
(
const
WCHAR
*
)(
INT_PTR
)
rval
;
return
eval_strcmp
(
expr
->
op
,
lstr
,
rstr
,
val
);
}
...
...
dlls/wbemprox/tests/query.c
View file @
df42519c
...
...
@@ -102,7 +102,12 @@ static void test_select( IWbemServices *services )
{
'S'
,
'E'
,
'L'
,
'E'
,
'C'
,
'T'
,
' '
,
'*'
,
' '
,
'F'
,
'R'
,
'O'
,
'M'
,
' '
,
'W'
,
'i'
,
'n'
,
'3'
,
'2'
,
'_'
,
'P'
,
'r'
,
'o'
,
'c'
,
'e'
,
's'
,
's'
,
' '
,
'W'
,
'H'
,
'E'
,
'R'
,
'E'
,
' '
,
'C'
,
'a'
,
'p'
,
't'
,
'i'
,
'o'
,
'n'
,
' '
,
'L'
,
'I'
,
'K'
,
'E'
,
' '
,
'"'
,
'%'
,
'f'
,
'i'
,
'r'
,
'e'
,
'f'
,
'o'
,
'x'
,
'.'
,
'e'
,
'x'
,
'e'
,
'"'
,
0
};
static
const
WCHAR
*
test
[]
=
{
query1
,
query2
,
query3
,
query4
,
query5
,
query6
,
query7
,
query8
,
query9
,
query10
};
static
const
WCHAR
query11
[]
=
{
'S'
,
'E'
,
'L'
,
'E'
,
'C'
,
'T'
,
' '
,
'*'
,
' '
,
'F'
,
'R'
,
'O'
,
'M'
,
' '
,
'W'
,
'i'
,
'n'
,
'3'
,
'2'
,
'_'
,
'V'
,
'i'
,
'd'
,
'e'
,
'o'
,
'C'
,
'o'
,
'n'
,
't'
,
'r'
,
'o'
,
'l'
,
'l'
,
'e'
,
'r'
,
' '
,
'w'
,
'h'
,
'e'
,
'r'
,
'e'
,
' '
,
'a'
,
'v'
,
'a'
,
'i'
,
'l'
,
'a'
,
'b'
,
'i'
,
'l'
,
'i'
,
't'
,
'y'
,
' '
,
'='
,
' '
,
'\''
,
'3'
,
'\''
,
0
};
static
const
WCHAR
*
test
[]
=
{
query1
,
query2
,
query3
,
query4
,
query5
,
query6
,
query7
,
query8
,
query9
,
query10
,
query11
};
HRESULT
hr
;
IEnumWbemClassObject
*
result
;
BSTR
wql
=
SysAllocString
(
wqlW
);
...
...
dlls/wbemprox/wql.y
View file @
df42519c
...
...
@@ -647,15 +647,13 @@ static int get_token( const WCHAR *s, int *token )
return 1;
case '\"':
case '\'':
for (i = 1; s[i]; i++)
{
for (i = 1; s[i]; i++)
{
if (s[i] == s[0]) break;
}
if (s[i]) i++;
*token = TK_STRING;
return i;
if (s[i] == s[0]) break;
}
if (s[i]) i++;
*token = TK_STRING;
return i;
case '.':
if (!isdigitW( s[1] ))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment