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
17607b80
Commit
17607b80
authored
Oct 25, 2012
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Oct 26, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Avoid using strstr to match == operator in WCMD_if.
parent
dd139544
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
builtins.c
programs/cmd/builtins.c
+30
-18
No files found.
programs/cmd/builtins.c
View file @
17607b80
...
...
@@ -2350,7 +2350,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList)
{
int
negate
;
/* Negate condition */
int
test
;
/* Condition evaluation result */
WCHAR
condition
[
MAX_PATH
],
*
command
,
*
s
;
WCHAR
condition
[
MAX_PATH
],
*
command
;
static
const
WCHAR
notW
[]
=
{
'n'
,
'o'
,
't'
,
'\0'
};
static
const
WCHAR
errlvlW
[]
=
{
'e'
,
'r'
,
'r'
,
'o'
,
'r'
,
'l'
,
'e'
,
'v'
,
'e'
,
'l'
,
'\0'
};
static
const
WCHAR
existW
[]
=
{
'e'
,
'x'
,
'i'
,
's'
,
't'
,
'\0'
};
...
...
@@ -2381,23 +2381,35 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList)
NULL
,
0
)
>
0
);
WCMD_parameter
(
p
,
2
+
negate
,
&
command
,
FALSE
,
FALSE
);
}
else
if
((
s
=
strstrW
(
p
,
eqeqW
)))
{
/* We need to get potential surrounding double quotes, so param1/2 can't be used */
WCHAR
*
leftPart
,
*
rightPart
;
unsigned
int
leftPartLen
,
rightPartLen
;
s
+=
2
;
leftPartLen
=
strlenW
(
WCMD_parameter
(
p
,
0
+
negate
+
caseInsensitive
,
&
leftPart
,
TRUE
,
FALSE
));
rightPartLen
=
strlenW
(
WCMD_parameter
(
p
,
1
+
negate
+
caseInsensitive
,
&
rightPart
,
TRUE
,
FALSE
));
test
=
caseInsensitive
?
(
CompareStringW
(
LOCALE_SYSTEM_DEFAULT
,
NORM_IGNORECASE
,
leftPart
,
leftPartLen
,
rightPart
,
rightPartLen
)
==
CSTR_EQUAL
)
:
(
CompareStringW
(
LOCALE_SYSTEM_DEFAULT
,
0
,
leftPart
,
leftPartLen
,
rightPart
,
rightPartLen
)
==
CSTR_EQUAL
);
WCMD_parameter
(
s
,
1
,
&
command
,
FALSE
,
FALSE
);
}
else
goto
syntax_err
;
else
{
/* comparison operation */
WCHAR
leftOperand
[
MAXSTRING
],
rightOperand
[
MAXSTRING
],
operator
[
MAXSTRING
];
WCHAR
*
paramStart
;
strcpyW
(
leftOperand
,
WCMD_parameter
(
p
,
negate
+
caseInsensitive
,
&
paramStart
,
TRUE
,
FALSE
));
if
(
!*
leftOperand
)
goto
syntax_err
;
/* Note: '==' can't be returned by WCMD_parameter since '=' is a separator */
p
=
paramStart
+
strlenW
(
leftOperand
);
while
(
*
p
==
' '
||
*
p
==
'\t'
)
p
++
;
if
(
strncmpW
(
p
,
eqeqW
,
strlenW
(
eqeqW
)))
goto
syntax_err
;
strcpyW
(
operator
,
eqeqW
);
p
+=
strlenW
(
operator
);
strcpyW
(
rightOperand
,
WCMD_parameter
(
p
,
0
,
&
paramStart
,
TRUE
,
FALSE
));
if
(
!*
rightOperand
)
goto
syntax_err
;
test
=
caseInsensitive
?
lstrcmpiW
(
leftOperand
,
rightOperand
)
==
0
:
lstrcmpW
(
leftOperand
,
rightOperand
)
==
0
;
p
=
paramStart
+
strlenW
(
rightOperand
);
WCMD_parameter
(
p
,
0
,
&
command
,
FALSE
,
FALSE
);
}
/* Process rest of IF statement which is on the same line
Note: This may process all or some of the cmdList (eg a GOTO) */
...
...
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