Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
e3a54234
Commit
e3a54234
authored
13 years ago
by
Frédéric Delanoy
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
cmd: Move WCMD_part_execute function to avoid forward declaration.
parent
52000a77
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
programs/cmd/builtins.c
+99
-104
99 additions, 104 deletions
programs/cmd/builtins.c
with
99 additions
and
104 deletions
programs/cmd/builtins.c
+
99
−
104
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
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment