Jason Edmeades : cmd: Correct for /f string and command set handling.
Alexandre Julliard
julliard at winehq.org
Wed Oct 24 13:39:41 CDT 2012
Module: wine
Branch: master
Commit: 182c5459b02f1154712afb219a8384e661effc65
URL: http://source.winehq.org/git/wine.git/?a=commit;h=182c5459b02f1154712afb219a8384e661effc65
Author: Jason Edmeades <jason at edmeades.me.uk>
Date: Tue Oct 23 00:28:18 2012 +0100
cmd: Correct for /f string and command set handling.
---
programs/cmd/builtins.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 6e252fe..721a1b7 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2039,6 +2039,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
(forf_usebackq && *itemStart != '\''))) {
HANDLE input;
+ WCHAR *itemparm;
WINE_TRACE("Processing for filespec from item %d '%s'\n", itemNum,
wine_dbgstr_w(item));
@@ -2049,12 +2050,13 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
(!forf_usebackq && *itemStart == '\'')) {
/* Use itemstart because the command is the whole set, not just the first token */
- input = WCMD_forf_getinputhandle(forf_usebackq, itemStart, TRUE);
+ itemparm = itemStart;
} else {
/* Use item because the file to process is just the first item in the set */
- input = WCMD_forf_getinputhandle(forf_usebackq, item, FALSE);
+ itemparm = item;
}
+ input = WCMD_forf_getinputhandle(forf_usebackq, itemparm, (itemparm==itemStart));
/* Process the input file */
if (input == INVALID_HANDLE_VALUE) {
@@ -2074,6 +2076,12 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
CloseHandle (input);
}
+ /* When we have processed the item as a whole command, abort future set processing */
+ if (itemparm==itemStart) {
+ thisSet = NULL;
+ break;
+ }
+
/* Filesets - A string literal */
} else if (doFileset && ((!forf_usebackq && *itemStart == '"') ||
(forf_usebackq && *itemStart == '\''))) {
@@ -2082,6 +2090,10 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
strcpyW(buffer, item);
WCMD_parse_line(cmdStart, firstCmd, &cmdEnd, variable, buffer, &doExecuted,
&forf_skip, forf_eol);
+
+ /* Only one string can be supplied in the whole set, abort future set processing */
+ thisSet = NULL;
+ break;
}
WINE_TRACE("Post-command, cmdEnd = %p\n", cmdEnd);
@@ -2089,7 +2101,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
}
/* Move onto the next set line */
- thisSet = thisSet->nextcommand;
+ if (thisSet) thisSet = thisSet->nextcommand;
}
/* If /L is provided, now run the for loop */
More information about the wine-cvs
mailing list