2 * CALL.C - call internal batch command.
7 * 16 Jul 1998 (Hans B Pufal)
10 * 16 Jul 1998 (John P Price)
11 * Separated commands into individual files.
13 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
14 * added config.h include
16 * 04-Aug-1998 (Hans B Pufal)
17 * added lines to initialize for pointers (HBP004) This fixed the
18 * lock-up that happened sometimes when calling a batch file from
21 * 07-Jan-1999 (Eric Kohl)
22 * Added help text ("call /?") and cleaned up.
24 * 20-Jan-1999 (Eric Kohl)
25 * Unicode and redirection safe!
27 * 02-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
28 * Remove all hardcoded strings in En.rc
34 * Perform CALL command.
37 INT
cmd_call(LPTSTR param
)
39 TCHAR line
[CMDLINE_LENGTH
+ 1];
41 BOOL bInQuote
= FALSE
;
43 TRACE ("cmd_call: (\'%s\')\n", debugstr_aw(param
));
44 if (!_tcsncmp (param
, _T("/?"), 2))
46 ConOutResPaging(TRUE
,STRING_CALL_HELP
);
50 /* Do a second round of %-variable substitutions */
51 if (!SubstituteVars(param
, line
, _T('%')))
52 return (nErrorLevel
= 1);
54 /* Find start and end of first word */
56 while (_istspace(*first
))
59 for (param
= first
; *param
; param
++)
61 if (!bInQuote
&& (_istspace(*param
) || _tcschr(_T(",;="), *param
)))
63 bInQuote
^= (*param
== _T('"'));
66 /* Separate first word from rest of line */
67 memmove(param
+ 1, param
, (_tcslen(param
) + 1) * sizeof(TCHAR
));
70 if (*first
== _T(':') && bc
)
72 /* CALL :label - call a subroutine of the current batch file */
73 while (*param
== _T(' '))
75 nErrorLevel
= Batch(bc
->BatchFilePath
, first
, param
, NULL
);
79 nErrorLevel
= DoCommand(first
, param
, NULL
);