Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e3a54234
Commit
e3a54234
authored
Nov 18, 2011
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Nov 18, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Move WCMD_part_execute function to avoid forward declaration.
parent
52000a77
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
104 deletions
+99
-104
builtins.c
programs/cmd/builtins.c
+99
-104
No files found.
programs/cmd/builtins.c
View file @
e3a54234
...
...
@@ -41,10 +41,6 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
cmd
);
static
void
WCMD_part_execute
(
CMD_LIST
**
commands
,
const
WCHAR
*
firstcmd
,
const
WCHAR
*
variable
,
const
WCHAR
*
value
,
BOOL
isIF
,
BOOL
conditionTRUE
);
static
struct
env_stack
*
saved_environment
;
struct
env_stack
*
pushd_directories
;
...
...
@@ -922,6 +918,105 @@ void WCMD_echo (const WCHAR *command)
HeapFree
(
GetProcessHeap
(),
0
,
trimmed
);
}
/*****************************************************************************
* WCMD_part_execute
*
* Execute a command, and any && or bracketed follow on to the command. The
* first command to be executed may not be at the front of the
* commands->thiscommand string (eg. it may point after a DO or ELSE)
*/
static
void
WCMD_part_execute
(
CMD_LIST
**
cmdList
,
const
WCHAR
*
firstcmd
,
const
WCHAR
*
variable
,
const
WCHAR
*
value
,
BOOL
isIF
,
BOOL
conditionTRUE
)
{
CMD_LIST
*
curPosition
=
*
cmdList
;
int
myDepth
=
(
*
cmdList
)
->
bracketDepth
;
WINE_TRACE
(
"cmdList(%p), firstCmd(%p), with variable '%s'='%s', doIt(%d)
\n
"
,
cmdList
,
wine_dbgstr_w
(
firstcmd
),
wine_dbgstr_w
(
variable
),
wine_dbgstr_w
(
value
),
conditionTRUE
);
/* Skip leading whitespace between condition and the command */
while
(
firstcmd
&&
*
firstcmd
&&
(
*
firstcmd
==
' '
||
*
firstcmd
==
'\t'
))
firstcmd
++
;
/* Process the first command, if there is one */
if
(
conditionTRUE
&&
firstcmd
&&
*
firstcmd
)
{
WCHAR
*
command
=
WCMD_strdupW
(
firstcmd
);
WCMD_execute
(
firstcmd
,
(
*
cmdList
)
->
redirects
,
variable
,
value
,
cmdList
);
HeapFree
(
GetProcessHeap
(),
0
,
command
);
}
/* If it didn't move the position, step to next command */
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
/* Process any other parts of the command */
if
(
*
cmdList
)
{
BOOL
processThese
=
TRUE
;
if
(
isIF
)
processThese
=
conditionTRUE
;
while
(
*
cmdList
)
{
static
const
WCHAR
ifElse
[]
=
{
'e'
,
'l'
,
's'
,
'e'
};
/* execute all appropriate commands */
curPosition
=
*
cmdList
;
WINE_TRACE
(
"Processing cmdList(%p) - delim(%d) bd(%d / %d)
\n
"
,
*
cmdList
,
(
*
cmdList
)
->
prevDelim
,
(
*
cmdList
)
->
bracketDepth
,
myDepth
);
/* Execute any statements appended to the line */
/* FIXME: Only if previous call worked for && or failed for || */
if
((
*
cmdList
)
->
prevDelim
==
CMD_ONFAILURE
||
(
*
cmdList
)
->
prevDelim
==
CMD_ONSUCCESS
)
{
if
(
processThese
&&
(
*
cmdList
)
->
command
)
{
WCMD_execute
((
*
cmdList
)
->
command
,
(
*
cmdList
)
->
redirects
,
variable
,
value
,
cmdList
);
}
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
/* Execute any appended to the statement with (...) */
}
else
if
((
*
cmdList
)
->
bracketDepth
>
myDepth
)
{
if
(
processThese
)
{
*
cmdList
=
WCMD_process_commands
(
*
cmdList
,
TRUE
,
variable
,
value
);
WINE_TRACE
(
"Back from processing commands, (next = %p)
\n
"
,
*
cmdList
);
}
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
/* End of the command - does 'ELSE ' follow as the next command? */
}
else
{
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
)
{
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
++
;
if
(
*
cmd
)
{
WCMD_execute
(
cmd
,
(
*
cmdList
)
->
redirects
,
variable
,
value
,
cmdList
);
}
}
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
}
else
{
WINE_TRACE
(
"Found end of this IF statement (next = %p)
\n
"
,
*
cmdList
);
break
;
}
}
}
}
return
;
}
/**************************************************************************
* WCMD_for
*
...
...
@@ -1249,106 +1344,6 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
if
(
cmdEnd
&&
cmdEnd
->
command
==
NULL
)
*
cmdList
=
cmdEnd
->
nextcommand
;
}
/*****************************************************************************
* WCMD_part_execute
*
* Execute a command, and any && or bracketed follow on to the command. The
* first command to be executed may not be at the front of the
* commands->thiscommand string (eg. it may point after a DO or ELSE)
*/
static
void
WCMD_part_execute
(
CMD_LIST
**
cmdList
,
const
WCHAR
*
firstcmd
,
const
WCHAR
*
variable
,
const
WCHAR
*
value
,
BOOL
isIF
,
BOOL
conditionTRUE
)
{
CMD_LIST
*
curPosition
=
*
cmdList
;
int
myDepth
=
(
*
cmdList
)
->
bracketDepth
;
WINE_TRACE
(
"cmdList(%p), firstCmd(%p), with variable '%s'='%s', doIt(%d)
\n
"
,
cmdList
,
wine_dbgstr_w
(
firstcmd
),
wine_dbgstr_w
(
variable
),
wine_dbgstr_w
(
value
),
conditionTRUE
);
/* Skip leading whitespace between condition and the command */
while
(
firstcmd
&&
*
firstcmd
&&
(
*
firstcmd
==
' '
||
*
firstcmd
==
'\t'
))
firstcmd
++
;
/* Process the first command, if there is one */
if
(
conditionTRUE
&&
firstcmd
&&
*
firstcmd
)
{
WCHAR
*
command
=
WCMD_strdupW
(
firstcmd
);
WCMD_execute
(
firstcmd
,
(
*
cmdList
)
->
redirects
,
variable
,
value
,
cmdList
);
HeapFree
(
GetProcessHeap
(),
0
,
command
);
}
/* If it didn't move the position, step to next command */
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
/* Process any other parts of the command */
if
(
*
cmdList
)
{
BOOL
processThese
=
TRUE
;
if
(
isIF
)
processThese
=
conditionTRUE
;
while
(
*
cmdList
)
{
static
const
WCHAR
ifElse
[]
=
{
'e'
,
'l'
,
's'
,
'e'
};
/* execute all appropriate commands */
curPosition
=
*
cmdList
;
WINE_TRACE
(
"Processing cmdList(%p) - delim(%d) bd(%d / %d)
\n
"
,
*
cmdList
,
(
*
cmdList
)
->
prevDelim
,
(
*
cmdList
)
->
bracketDepth
,
myDepth
);
/* Execute any statements appended to the line */
/* FIXME: Only if previous call worked for && or failed for || */
if
((
*
cmdList
)
->
prevDelim
==
CMD_ONFAILURE
||
(
*
cmdList
)
->
prevDelim
==
CMD_ONSUCCESS
)
{
if
(
processThese
&&
(
*
cmdList
)
->
command
)
{
WCMD_execute
((
*
cmdList
)
->
command
,
(
*
cmdList
)
->
redirects
,
variable
,
value
,
cmdList
);
}
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
/* Execute any appended to the statement with (...) */
}
else
if
((
*
cmdList
)
->
bracketDepth
>
myDepth
)
{
if
(
processThese
)
{
*
cmdList
=
WCMD_process_commands
(
*
cmdList
,
TRUE
,
variable
,
value
);
WINE_TRACE
(
"Back from processing commands, (next = %p)
\n
"
,
*
cmdList
);
}
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
/* End of the command - does 'ELSE ' follow as the next command? */
}
else
{
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
)
{
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
++
;
if
(
*
cmd
)
{
WCMD_execute
(
cmd
,
(
*
cmdList
)
->
redirects
,
variable
,
value
,
cmdList
);
}
}
if
(
curPosition
==
*
cmdList
)
*
cmdList
=
(
*
cmdList
)
->
nextcommand
;
}
else
{
WINE_TRACE
(
"Found end of this IF statement (next = %p)
\n
"
,
*
cmdList
);
break
;
}
}
}
}
return
;
}
/**************************************************************************
* WCMD_give_help
*
...
...
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