[PATCH 03/12] CMD.exe: Pass command structure into WCMD_pipe,
not command line itself
Jason Edmeades
jason.edmeades at googlemail.com
Fri Jun 15 14:59:32 CDT 2007
Note I pass the address of the command structure as future commands
may modify it (simplifies next patch)
---
programs/cmd/wcmd.h | 20 ++++++++++----------
programs/cmd/wcmdmain.c | 5 +++--
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 4ab365c..fa8d785 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -28,6 +28,15 @@
#include <ctype.h>
#include <wine/unicode.h>
+/* Data structure to hold commands to be processed */
+
+typedef struct _CMD_LIST {
+ WCHAR *command; /* Command string to execute */
+ struct _CMD_LIST *nextcommand; /* Next command string to execute */
+ BOOL isAmphersand;/* Whether follows && */
+ int bracketDepth;/* How deep bracketing have we got to */
+} CMD_LIST;
+
void WCMD_assoc (WCHAR *, BOOL);
void WCMD_batch (WCHAR *, WCHAR *, int, WCHAR *, HANDLE);
void WCMD_call (WCHAR *command);
@@ -53,7 +62,7 @@ void WCMD_output (const WCHAR *format, ...);
void WCMD_output_asis (const WCHAR *message);
void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2);
void WCMD_pause (void);
-void WCMD_pipe (WCHAR *command);
+void WCMD_pipe (CMD_LIST **command);
void WCMD_popd (void);
void WCMD_print_error (void);
void WCMD_process_command (WCHAR *command);
@@ -92,15 +101,6 @@ WCHAR *WCMD_strdupW(WCHAR *input);
BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars,
LPDWORD charsRead, const LPOVERLAPPED unused);
-/* Data structure to hold commands to be processed */
-
-typedef struct _CMD_LIST {
- WCHAR *command; /* Command string to execute */
- struct _CMD_LIST *nextcommand; /* Next command string to execute */
- BOOL isAmphersand;/* Whether follows && */
- int bracketDepth;/* How deep bracketing have we got to */
-} CMD_LIST;
-
WCHAR *WCMD_ReadAndParseLine(WCHAR *initialcmd, CMD_LIST **output, HANDLE readFrom);
void WCMD_process_commands(CMD_LIST *thisCmd);
void WCMD_free_commands(CMD_LIST *cmds);
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 245556e..ba5f7df 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1487,9 +1487,10 @@ void WCMD_opt_s_strip_quotes(WCHAR *cmd) {
* Handle pipes within a command - the DOS way using temporary files.
*/
-void WCMD_pipe (WCHAR *command) {
+void WCMD_pipe (CMD_LIST **cmdEntry) {
WCHAR *p;
+ WCHAR *command = (*cmdEntry)->command;
WCHAR temp_path[MAX_PATH], temp_file[MAX_PATH], temp_file2[MAX_PATH], temp_cmd[1024];
static const WCHAR redirOut[] = {'%','s',' ','>',' ','%','s','\0'};
static const WCHAR redirIn[] = {'%','s',' ','<',' ','%','s','\0'};
@@ -2077,7 +2078,7 @@ void WCMD_process_commands(CMD_LIST *thisCmd) {
if (thisCmd->command && thisCmd->command[0] != ':') {
WINE_TRACE("Executing command: '%s'\n", wine_dbgstr_w(thisCmd->command));
if (strchrW(thisCmd->command,'|') != NULL) {
- WCMD_pipe (thisCmd->command);
+ WCMD_pipe (&thisCmd);
} else {
WCMD_process_command (thisCmd->command);
}
--
1.5.0
More information about the wine-patches
mailing list