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
c7b88e95
Commit
c7b88e95
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: Add basic support for FOR /F parsing launched programs output.
parent
f3ae48cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
builtins.c
programs/cmd/builtins.c
+35
-3
No files found.
programs/cmd/builtins.c
View file @
c7b88e95
...
...
@@ -822,14 +822,41 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
}
else
if
(
doFileset
&&
*
itemStart
!=
'"'
)
{
HANDLE
input
;
WCHAR
temp_file
[
MAX_PATH
];
WINE_TRACE
(
"Processing for filespec from item %d '%s'
\n
"
,
itemNum
,
wine_dbgstr_w
(
item
));
/*
Open the file, read line by line and process */
input
=
CreateFile
(
item
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
/*
If backquote or single quote, we need to launch that command
and parse the results - use a temporary file */
if
(
*
itemStart
==
'`'
||
*
itemStart
==
'\''
)
{
WCHAR
temp_path
[
MAX_PATH
],
temp_cmd
[
MAXSTRING
];
static
const
WCHAR
redirOut
[]
=
{
'%'
,
's'
,
' '
,
'>'
,
' '
,
'%'
,
's'
,
'\0'
};
static
const
WCHAR
cmdW
[]
=
{
'C'
,
'M'
,
'D'
,
'\0'
};
/* Remove trailing character */
itemStart
[
strlenW
(
itemStart
)
-
1
]
=
0x00
;
/* Get temp filename */
GetTempPath
(
sizeof
(
temp_path
)
/
sizeof
(
WCHAR
),
temp_path
);
GetTempFileName
(
temp_path
,
cmdW
,
0
,
temp_file
);
/* Execute program and redirect output */
wsprintf
(
temp_cmd
,
redirOut
,
(
itemStart
+
1
),
temp_file
);
WCMD_execute
(
temp_cmd
,
NULL
,
NULL
,
NULL
);
/* Open the file, read line by line and process */
input
=
CreateFile
(
temp_file
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
}
else
{
/* Open the file, read line by line and process */
input
=
CreateFile
(
item
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
}
/* Process the input file */
if
(
input
==
INVALID_HANDLE_VALUE
)
{
WCMD_print_error
();
WCMD_output
(
WCMD_LoadMessage
(
WCMD_READFAIL
),
item
);
...
...
@@ -862,6 +889,11 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
CloseHandle
(
input
);
}
/* Delete the temporary file */
if
(
*
itemStart
==
'`'
||
*
itemStart
==
'\''
)
{
DeleteFile
(
temp_file
);
}
/* Filesets - A string literal */
}
else
if
(
doFileset
&&
*
itemStart
==
'"'
)
{
WCHAR
buffer
[
MAXSTRING
]
=
{
'\0'
};
...
...
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