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
eda33f22
Commit
eda33f22
authored
Aug 25, 2011
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Aug 25, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Fix if/else tab handling.
parent
6d3fd3ab
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
15 deletions
+29
-15
builtins.c
programs/cmd/builtins.c
+6
-5
test_builtins.cmd
programs/cmd/tests/test_builtins.cmd
+7
-0
test_builtins.cmd.exp
programs/cmd/tests/test_builtins.cmd.exp
+7
-0
wcmdmain.c
programs/cmd/wcmdmain.c
+9
-10
No files found.
programs/cmd/builtins.c
View file @
eda33f22
...
...
@@ -1250,7 +1250,7 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
if
(
isIF
)
processThese
=
conditionTRUE
;
while
(
*
cmdList
)
{
const
WCHAR
ifElse
[]
=
{
'e'
,
'l'
,
's'
,
'e'
,
' '
,
'\0'
};
const
WCHAR
ifElse
[]
=
{
'e'
,
'l'
,
's'
,
'e'
};
/* execute all appropriate commands */
curPosition
=
*
cmdList
;
...
...
@@ -1280,16 +1280,17 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
/* End of the command - does 'ELSE ' follow as the next command? */
}
else
{
if
(
isIF
&&
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
(
*
cmdList
)
->
command
,
5
,
ifElse
,
-
1
)
==
CSTR_EQUAL
)
{
if
(
isIF
&&
WCMD_keyword_ws_found
(
ifElse
,
sizeof
(
ifElse
)
/
sizeof
(
ifElse
[
0
])
,
(
*
cmdList
)
->
command
)
)
{
/* Swap between if and else processing */
processThese
=
!
processThese
;
/* Process the ELSE part */
if
(
processThese
)
{
WCHAR
*
cmd
=
((
*
cmdList
)
->
command
)
+
strlenW
(
ifElse
);
const
int
keyw_len
=
sizeof
(
ifElse
)
/
sizeof
(
ifElse
[
0
])
+
1
;
WCHAR
*
cmd
=
((
*
cmdList
)
->
command
)
+
keyw_len
;
/* Skip leading whitespace between condition and the command */
while
(
*
cmd
&&
(
*
cmd
==
' '
||
*
cmd
==
'\t'
))
cmd
++
;
...
...
programs/cmd/tests/test_builtins.cmd
View file @
eda33f22
...
...
@@ -391,6 +391,13 @@ if /i foo==FOO echo if /i seems to work
if /i not foo==FOO echo if /i seems to be broken
if /I foo==FOO echo if /I seems to work
if /I not foo==FOO echo if /I seems to be broken
if@tab@1==1 echo doom
if @tab@1==1 echo doom
if 1==1 (echo doom) else@tab@echo quake
if@tab@not @tab@1==@tab@0 @tab@echo lol
if 1==0@tab@(echo doom) else echo quake
if 1==0 (echo doom)@tab@else echo quake
if 1==0 (echo doom) else@tab@echo quake
echo -----------Testing for -----------
echo ...plain FOR
...
...
programs/cmd/tests/test_builtins.cmd.exp
View file @
eda33f22
...
...
@@ -271,6 +271,13 @@ Testing case sensitivity with and without /i option
if seems to default to case sensitivity
if /i seems to work
if /I seems to work
doom
doom
doom
lol
quake
quake
quake
-----------Testing for -----------
...plain FOR
A
...
...
programs/cmd/wcmdmain.c
View file @
eda33f22
...
...
@@ -1755,8 +1755,8 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
static
WCHAR
*
extraSpace
=
NULL
;
/* Deliberately never freed */
const
WCHAR
remCmd
[]
=
{
'r'
,
'e'
,
'm'
};
const
WCHAR
forCmd
[]
=
{
'f'
,
'o'
,
'r'
};
const
WCHAR
ifCmd
[]
=
{
'i'
,
'f'
,
' '
,
'\0'
};
const
WCHAR
ifElse
[]
=
{
'e'
,
'l'
,
's'
,
'e'
,
' '
,
'\0'
};
const
WCHAR
ifCmd
[]
=
{
'i'
,
'f'
};
const
WCHAR
ifElse
[]
=
{
'e'
,
'l'
,
's'
,
'e'
};
BOOL
inRem
=
FALSE
;
BOOL
inFor
=
FALSE
;
BOOL
inIn
=
FALSE
;
...
...
@@ -1847,24 +1847,23 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
}
else
if
(
WCMD_keyword_ws_found
(
forCmd
,
sizeof
(
forCmd
)
/
sizeof
(
forCmd
[
0
]),
curPos
))
{
inFor
=
TRUE
;
/* If command starts with 'if
' or 'else
', handle ('s mid line. We should ensure this
/* If command starts with 'if
' or 'else
', handle ('s mid line. We should ensure this
is only true in the command portion of the IF statement, but this
should suffice for now
FIXME: Silly syntax like "if 1(==1( (
echo they equal
)" will be parsed wrong */
}
else
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
curPos
,
3
,
ifCmd
,
-
1
)
==
CSTR_EQUAL
)
{
}
else
if
(
WCMD_keyword_ws_found
(
ifCmd
,
sizeof
(
ifCmd
)
/
sizeof
(
ifCmd
[
0
]),
curPos
))
{
inIf
=
TRUE
;
}
else
if
(
CompareStringW
(
LOCALE_USER_DEFAULT
,
NORM_IGNORECASE
|
SORT_STRINGSORT
,
c
urPos
,
5
,
ifElse
,
-
1
)
==
CSTR_EQUAL
)
{
}
else
if
(
WCMD_keyword_ws_found
(
ifElse
,
sizeof
(
ifElse
)
/
sizeof
(
ifElse
[
0
]),
curPos
))
{
c
onst
int
keyw_len
=
sizeof
(
ifElse
)
/
sizeof
(
ifElse
[
0
])
+
1
;
inElse
=
TRUE
;
lastWasElse
=
TRUE
;
onlyWhiteSpace
=
TRUE
;
memcpy
(
&
curCopyTo
[
*
curLen
],
curPos
,
5
*
sizeof
(
WCHAR
));
(
*
curLen
)
+=
5
;
curPos
+=
5
;
memcpy
(
&
curCopyTo
[
*
curLen
],
curPos
,
keyw_len
*
sizeof
(
WCHAR
));
(
*
curLen
)
+=
keyw_len
;
curPos
+=
keyw_len
;
continue
;
/* In a for loop, the DO command will follow a close bracket followed by
...
...
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