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
b6924112
Commit
b6924112
authored
Sep 11, 2007
by
Jason Edmeades
Committed by
Alexandre Julliard
Sep 12, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd.exe: Expand for variables at last with tilda modifications.
parent
dc372175
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
161 additions
and
132 deletions
+161
-132
batch.c
programs/cmd/batch.c
+20
-14
builtins.c
programs/cmd/builtins.c
+1
-35
wcmd.h
programs/cmd/wcmd.h
+1
-2
wcmdmain.c
programs/cmd/wcmdmain.c
+139
-81
No files found.
programs/cmd/batch.c
View file @
b6924112
...
...
@@ -19,6 +19,9 @@
*/
#include "wcmd.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
cmd
);
extern
int
echo_mode
;
extern
WCHAR
quals
[
MAX_PATH
],
param1
[
MAX_PATH
],
param2
[
MAX_PATH
];
...
...
@@ -301,7 +304,7 @@ void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHA
* Hence search forwards until find an invalid modifier, and then
* backwards until find for variable or 0-9
*/
void
WCMD_HandleTildaModifiers
(
WCHAR
**
start
,
WCHAR
*
forVariable
)
{
void
WCMD_HandleTildaModifiers
(
WCHAR
**
start
,
WCHAR
*
forVariable
,
WCHAR
*
forValue
,
BOOL
justFors
)
{
#define NUMMODIFIERS 11
static
const
WCHAR
validmodifiers
[
NUMMODIFIERS
]
=
{
...
...
@@ -324,10 +327,10 @@ void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable) {
BOOL
skipFileParsing
=
FALSE
;
BOOL
doneModifier
=
FALSE
;
/* Search forwards until find invalid
WCHAR
acter modifier */
/* Search forwards until find invalid
char
acter modifier */
while
(
!
finished
)
{
/* Work on the previous
WCHAR
acter */
/* Work on the previous
char
acter */
if
(
lastModifier
!=
NULL
)
{
for
(
i
=
0
;
i
<
NUMMODIFIERS
;
i
++
)
{
...
...
@@ -355,27 +358,30 @@ void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable) {
}
}
/* Now make sure the position we stopped at is a valid parameter */
if
(
!
(
*
lastModifier
>=
'0'
||
*
lastModifier
<=
'9'
)
&&
(
forVariable
!=
NULL
)
&&
(
toupperW
(
*
lastModifier
)
!=
toupperW
(
*
forVariable
)))
{
while
(
lastModifier
>
firstModifier
)
{
WINE_TRACE
(
"Looking backwards for parameter id: %s / %s
\n
"
,
wine_dbgstr_w
(
lastModifier
),
wine_dbgstr_w
(
forVariable
));
if
(
!
justFors
&&
context
&&
(
*
lastModifier
>=
'0'
||
*
lastModifier
<=
'9'
))
{
/* Its a valid parameter identifier - OK */
break
;
/* Its not... Step backwards until it matches or we get to the start */
while
(
toupperW
(
*
lastModifier
)
!=
toupperW
(
*
forVariable
)
&&
lastModifier
>
firstModifier
)
{
}
else
if
(
forVariable
&&
*
lastModifier
==
*
(
forVariable
+
1
))
{
/* Its a valid parameter identifier - OK */
break
;
}
else
{
lastModifier
--
;
}
if
(
lastModifier
==
firstModifier
)
return
;
/* Invalid syntax */
}
if
(
lastModifier
==
firstModifier
)
return
;
/* Invalid syntax */
/* Extract the parameter to play with */
if
((
*
lastModifier
>=
'0'
&&
*
lastModifier
<=
'9'
))
{
strcpyW
(
outputparam
,
WCMD_parameter
(
context
->
command
,
*
lastModifier
-
'0'
+
context
->
shift_count
[
*
lastModifier
-
'0'
],
NULL
));
}
else
{
/* FIXME: Retrieve 'for' variable %c\n", *lastModifier); */
/* Need to get 'for' loop variable into outputparam */
return
;
strcpyW
(
outputparam
,
forValue
);
}
/* So now, firstModifier points to beginning of modifiers, lastModifier
...
...
programs/cmd/builtins.c
View file @
b6924112
...
...
@@ -992,40 +992,6 @@ void WCMD_part_execute(CMD_LIST **cmdList, WCHAR *firstcmd, WCHAR *variable,
return
;
}
/*****************************************************************************
* WCMD_Execute
*
* Execute a command after substituting variable text for the supplied parameter
*/
void
WCMD_execute
(
WCHAR
*
orig_cmd
,
WCHAR
*
param
,
WCHAR
*
subst
,
CMD_LIST
**
cmdList
)
{
WCHAR
*
new_cmd
,
*
p
,
*
s
,
*
dup
;
int
size
;
if
(
param
)
{
size
=
(
strlenW
(
orig_cmd
)
+
1
)
*
sizeof
(
WCHAR
);
new_cmd
=
(
WCHAR
*
)
LocalAlloc
(
LMEM_FIXED
|
LMEM_ZEROINIT
,
size
);
dup
=
s
=
WCMD_strdupW
(
orig_cmd
);
while
((
p
=
strstrW
(
s
,
param
)))
{
*
p
=
'\0'
;
size
+=
strlenW
(
subst
)
*
sizeof
(
WCHAR
);
new_cmd
=
(
WCHAR
*
)
LocalReAlloc
((
HANDLE
)
new_cmd
,
size
,
0
);
strcatW
(
new_cmd
,
s
);
strcatW
(
new_cmd
,
subst
);
s
=
p
+
strlenW
(
param
);
}
strcatW
(
new_cmd
,
s
);
WCMD_process_command
(
new_cmd
,
cmdList
);
free
(
dup
);
LocalFree
((
HANDLE
)
new_cmd
);
}
else
{
WCMD_process_command
(
orig_cmd
,
cmdList
);
}
}
/**************************************************************************
* WCMD_give_help
*
...
...
@@ -1067,7 +1033,7 @@ void WCMD_goto (CMD_LIST **cmdList) {
WCHAR
string
[
MAX_PATH
];
/* Do not process any more parts of a processed multipart or multilines command */
*
cmdList
=
NULL
;
if
(
cmdList
)
*
cmdList
=
NULL
;
if
(
param1
[
0
]
==
0x00
)
{
WCMD_output
(
WCMD_LoadMessage
(
WCMD_NOARG
));
...
...
programs/cmd/wcmd.h
View file @
b6924112
...
...
@@ -65,7 +65,6 @@ void WCMD_pause (void);
void
WCMD_pipe
(
CMD_LIST
**
command
,
WCHAR
*
var
,
WCHAR
*
val
);
void
WCMD_popd
(
void
);
void
WCMD_print_error
(
void
);
void
WCMD_process_command
(
WCHAR
*
command
,
CMD_LIST
**
cmdList
);
void
WCMD_pushd
(
WCHAR
*
);
int
WCMD_read_console
(
WCHAR
*
string
,
int
str_len
);
void
WCMD_remove_dir
(
WCHAR
*
command
);
...
...
@@ -92,7 +91,7 @@ WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where);
WCHAR
*
WCMD_strtrim_leading_spaces
(
WCHAR
*
string
);
void
WCMD_strtrim_trailing_spaces
(
WCHAR
*
string
);
void
WCMD_opt_s_strip_quotes
(
WCHAR
*
cmd
);
void
WCMD_HandleTildaModifiers
(
WCHAR
**
start
,
WCHAR
*
forVariable
);
void
WCMD_HandleTildaModifiers
(
WCHAR
**
start
,
WCHAR
*
forVariable
,
WCHAR
*
forValue
,
BOOL
justFors
);
BOOL
WCMD_ask_confirm
(
WCHAR
*
message
,
BOOL
showSureText
,
BOOL
*
optionAll
);
void
WCMD_splitpath
(
const
WCHAR
*
path
,
WCHAR
*
drv
,
WCHAR
*
dir
,
WCHAR
*
name
,
WCHAR
*
ext
);
...
...
programs/cmd/wcmdmain.c
View file @
b6924112
This diff is collapsed.
Click to expand it.
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