cmd: Get rid of longer needed 'end' parameter in WCMD_parameter.
This commit is contained in:
parent
517ed44396
commit
cee1652e61
|
@ -130,29 +130,26 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
|
||||||
* s [I] input string, non NULL
|
* s [I] input string, non NULL
|
||||||
* n [I] # of the parameter to return, counted from 0
|
* n [I] # of the parameter to return, counted from 0
|
||||||
* start [O] Optional. Pointer to the first char of param n in s
|
* start [O] Optional. Pointer to the first char of param n in s
|
||||||
* end [O] Optional. Pointer to the last char of param n in s
|
* raw [I] TRUE to return the parameter in raw format (quotes maintained)
|
||||||
* raw [I] True to return the parameter in raw format (quotes maintained)
|
* FALSE to return the parameter with quotes stripped (including internal ones)
|
||||||
* False returns the parameter with quotes stripped
|
* wholecmdline [I] TRUE to indicate this routine is being used to parse the
|
||||||
* wholecmdline [I] True to indicate this routine is being used to parse the
|
|
||||||
* command line, and special logic for arg0->1 transition
|
* command line, and special logic for arg0->1 transition
|
||||||
* needs to be applied.
|
* needs to be applied.
|
||||||
* delims[I] The delimiter characters to use
|
* delims[I] The delimiter characters to use
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: The nth delimited parameter found in s
|
* Success: The nth delimited parameter found in s
|
||||||
* if start != NULL, *start points to the start of the param
|
* if start != NULL, *start points to the start of the param (quotes maintained)
|
||||||
* if end != NULL, *end points to the end of the param
|
|
||||||
* Failure: An empty string if the param is not found.
|
* Failure: An empty string if the param is not found.
|
||||||
* *start == *end == NULL
|
* *start == NULL
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Return value is stored in static storage (i.e. overwritten after each call).
|
* Return value is stored in static storage (i.e. overwritten after each call).
|
||||||
* Specify 'start' and/or 'end' to include delimiting double quotes as well, if any.
|
|
||||||
* By default, the parameter is returned with quotes removed, ready for use with
|
* By default, the parameter is returned with quotes removed, ready for use with
|
||||||
* other API calls, e.g. c:\"a b"\c is returned as c:\a b\c. However, some commands
|
* other API calls, e.g. c:\"a b"\c is returned as c:\a b\c. However, some commands
|
||||||
* need to preserve the exact syntax (echo, for, etc) hence the raw option.
|
* need to preserve the exact syntax (echo, for, etc) hence the raw option.
|
||||||
*/
|
*/
|
||||||
WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, WCHAR **end,
|
WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start,
|
||||||
BOOL raw, BOOL wholecmdline, const WCHAR *delims)
|
BOOL raw, BOOL wholecmdline, const WCHAR *delims)
|
||||||
{
|
{
|
||||||
int curParamNb = 0;
|
int curParamNb = 0;
|
||||||
|
@ -160,7 +157,6 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, WCHAR **end,
|
||||||
WCHAR *p = s, *begin;
|
WCHAR *p = s, *begin;
|
||||||
|
|
||||||
if (start != NULL) *start = NULL;
|
if (start != NULL) *start = NULL;
|
||||||
if (end != NULL) *end = NULL;
|
|
||||||
param[0] = '\0';
|
param[0] = '\0';
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
|
@ -212,7 +208,6 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, WCHAR **end,
|
||||||
}
|
}
|
||||||
param[i] = '\0';
|
param[i] = '\0';
|
||||||
}
|
}
|
||||||
if (end) *end = p - 1;
|
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
curParamNb++;
|
curParamNb++;
|
||||||
|
@ -226,11 +221,11 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, WCHAR **end,
|
||||||
* default set of delimiter characters. For parameters, see the main
|
* default set of delimiter characters. For parameters, see the main
|
||||||
* function above.
|
* function above.
|
||||||
*/
|
*/
|
||||||
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **start, WCHAR **end, BOOL raw,
|
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **start, BOOL raw,
|
||||||
BOOL wholecmdline)
|
BOOL wholecmdline)
|
||||||
{
|
{
|
||||||
static const WCHAR defaultDelims[] = { ' ', '\t', ',', '=', ';', '\0' };
|
static const WCHAR defaultDelims[] = { ' ', '\t', ',', '=', ';', '\0' };
|
||||||
return WCMD_parameter_with_delims (s, n, start, end, raw, wholecmdline, defaultDelims);
|
return WCMD_parameter_with_delims (s, n, start, raw, wholecmdline, defaultDelims);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -471,7 +466,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, const WCHAR *forVariable,
|
||||||
strcpyW(outputparam,
|
strcpyW(outputparam,
|
||||||
WCMD_parameter (context -> command,
|
WCMD_parameter (context -> command,
|
||||||
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'],
|
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'],
|
||||||
NULL, NULL, FALSE, TRUE));
|
NULL, FALSE, TRUE));
|
||||||
} else {
|
} else {
|
||||||
strcpyW(outputparam, forValue);
|
strcpyW(outputparam, forValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
opt_d = opt_v = opt_n = opt_z = opt_y = opt_noty = FALSE;
|
opt_d = opt_v = opt_n = opt_z = opt_y = opt_noty = FALSE;
|
||||||
|
|
||||||
/* Walk through all args, building up a list of files to process */
|
/* Walk through all args, building up a list of files to process */
|
||||||
thisparam = WCMD_parameter(args, argno++, &rawarg, NULL, TRUE, FALSE);
|
thisparam = WCMD_parameter(args, argno++, &rawarg, TRUE, FALSE);
|
||||||
while (*(thisparam)) {
|
while (*(thisparam)) {
|
||||||
WCHAR *pos1, *pos2;
|
WCHAR *pos1, *pos2;
|
||||||
BOOL inquotes;
|
BOOL inquotes;
|
||||||
|
@ -599,7 +599,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This parameter was purely switches, get the next one */
|
/* This parameter was purely switches, get the next one */
|
||||||
thisparam = WCMD_parameter(args, argno++, &rawarg, NULL, TRUE, FALSE);
|
thisparam = WCMD_parameter(args, argno++, &rawarg, TRUE, FALSE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
/* Move to next thing to process */
|
/* Move to next thing to process */
|
||||||
thisparam++;
|
thisparam++;
|
||||||
if (*thisparam == 0x00)
|
if (*thisparam == 0x00)
|
||||||
thisparam = WCMD_parameter(args, argno++, &rawarg, NULL, TRUE, FALSE);
|
thisparam = WCMD_parameter(args, argno++, &rawarg, TRUE, FALSE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,7 +681,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
thisparam = pos1;
|
thisparam = pos1;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
thisparam = WCMD_parameter(args, argno++, &rawarg, NULL, TRUE, FALSE);
|
thisparam = WCMD_parameter(args, argno++, &rawarg, TRUE, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ void WCMD_create_dir (WCHAR *args) {
|
||||||
}
|
}
|
||||||
/* Loop through all args */
|
/* Loop through all args */
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
WCHAR *thisArg = WCMD_parameter(args, argno++, &argN, NULL, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter(args, argno++, &argN, FALSE, FALSE);
|
||||||
if (!argN) break;
|
if (!argN) break;
|
||||||
if (!create_full_path(thisArg)) {
|
if (!create_full_path(thisArg)) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
|
@ -1324,7 +1324,7 @@ BOOL WCMD_delete (WCHAR *args) {
|
||||||
WCHAR *thisArg;
|
WCHAR *thisArg;
|
||||||
|
|
||||||
argN = NULL;
|
argN = NULL;
|
||||||
thisArg = WCMD_parameter (args, argno, &argN, NULL, FALSE, FALSE);
|
thisArg = WCMD_parameter (args, argno, &argN, FALSE, FALSE);
|
||||||
if (!argN)
|
if (!argN)
|
||||||
break; /* no more parameters */
|
break; /* no more parameters */
|
||||||
if (argN[0] == '/')
|
if (argN[0] == '/')
|
||||||
|
@ -1715,7 +1715,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract the parameter */
|
/* Extract the parameter */
|
||||||
parm = WCMD_parameter_with_delims(buffer, 0, &where, NULL, FALSE, FALSE, forf_delims);
|
parm = WCMD_parameter_with_delims(buffer, 0, &where, FALSE, FALSE, forf_delims);
|
||||||
WINE_TRACE("Parsed parameter: %s from %s\n", wine_dbgstr_w(parm),
|
WINE_TRACE("Parsed parameter: %s from %s\n", wine_dbgstr_w(parm),
|
||||||
wine_dbgstr_w(buffer));
|
wine_dbgstr_w(buffer));
|
||||||
|
|
||||||
|
@ -1830,7 +1830,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
BOOL forf_usebackq = FALSE;
|
BOOL forf_usebackq = FALSE;
|
||||||
|
|
||||||
/* Handle optional qualifiers (multiple are allowed) */
|
/* Handle optional qualifiers (multiple are allowed) */
|
||||||
WCHAR *thisArg = WCMD_parameter(p, parameterNo++, NULL, NULL, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter(p, parameterNo++, NULL, FALSE, FALSE);
|
||||||
|
|
||||||
optionsRoot[0] = 0;
|
optionsRoot[0] = 0;
|
||||||
while (thisArg && *thisArg == '/') {
|
while (thisArg && *thisArg == '/') {
|
||||||
|
@ -1854,7 +1854,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
|
|
||||||
/* Retrieve next parameter to see if is root/options (raw form required
|
/* Retrieve next parameter to see if is root/options (raw form required
|
||||||
with for /f, or unquoted in for /r) */
|
with for /f, or unquoted in for /r) */
|
||||||
thisArg = WCMD_parameter(p, parameterNo, NULL, NULL, doFileset, FALSE);
|
thisArg = WCMD_parameter(p, parameterNo, NULL, doFileset, FALSE);
|
||||||
|
|
||||||
/* Next parm is either qualifier, path/options or variable -
|
/* Next parm is either qualifier, path/options or variable -
|
||||||
only care about it if it is the path/options */
|
only care about it if it is the path/options */
|
||||||
|
@ -1869,7 +1869,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Step to next token */
|
/* Step to next token */
|
||||||
thisArg = WCMD_parameter(p, parameterNo++, NULL, NULL, FALSE, FALSE);
|
thisArg = WCMD_parameter(p, parameterNo++, NULL, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure line continues with variable */
|
/* Ensure line continues with variable */
|
||||||
|
@ -1903,7 +1903,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
WINE_TRACE("Variable identified as %s\n", wine_dbgstr_w(variable));
|
WINE_TRACE("Variable identified as %s\n", wine_dbgstr_w(variable));
|
||||||
|
|
||||||
/* Ensure line continues with IN */
|
/* Ensure line continues with IN */
|
||||||
thisArg = WCMD_parameter(p, parameterNo++, NULL, NULL, FALSE, FALSE);
|
thisArg = WCMD_parameter(p, parameterNo++, NULL, FALSE, FALSE);
|
||||||
if (!thisArg
|
if (!thisArg
|
||||||
|| !(CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
|
|| !(CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
|
||||||
thisArg, sizeof(inW)/sizeof(inW[0]), inW,
|
thisArg, sizeof(inW)/sizeof(inW[0]), inW,
|
||||||
|
@ -1968,7 +1968,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
|
|
||||||
WINE_TRACE("Processing for set %p\n", thisSet);
|
WINE_TRACE("Processing for set %p\n", thisSet);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (*(item = WCMD_parameter (thisSet->command, i, &itemStart, NULL, TRUE, FALSE))) {
|
while (*(item = WCMD_parameter (thisSet->command, i, &itemStart, TRUE, FALSE))) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the parameter within the set has a wildcard then search for matching files
|
* If the parameter within the set has a wildcard then search for matching files
|
||||||
|
@ -2365,7 +2365,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
WINE_TRACE("Condition: %s\n", wine_dbgstr_w(condition));
|
WINE_TRACE("Condition: %s\n", wine_dbgstr_w(condition));
|
||||||
|
|
||||||
if (!lstrcmpiW (condition, errlvlW)) {
|
if (!lstrcmpiW (condition, errlvlW)) {
|
||||||
WCHAR *param = WCMD_parameter(p, 1+negate, NULL, NULL, FALSE, FALSE);
|
WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE);
|
||||||
WCHAR *endptr;
|
WCHAR *endptr;
|
||||||
long int param_int = strtolW(param, &endptr, 10);
|
long int param_int = strtolW(param, &endptr, 10);
|
||||||
if (*endptr) {
|
if (*endptr) {
|
||||||
|
@ -2373,32 +2373,33 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
test = ((long int)errorlevel >= param_int);
|
test = ((long int)errorlevel >= param_int);
|
||||||
WCMD_parameter(p, 2+negate, &command, NULL, FALSE, FALSE);
|
WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
else if (!lstrcmpiW (condition, existW)) {
|
else if (!lstrcmpiW (condition, existW)) {
|
||||||
test = (GetFileAttributesW(WCMD_parameter(p, 1+negate, NULL, NULL, FALSE, FALSE))
|
test = (GetFileAttributesW(WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE))
|
||||||
!= INVALID_FILE_ATTRIBUTES);
|
!= INVALID_FILE_ATTRIBUTES);
|
||||||
WCMD_parameter(p, 2+negate, &command, NULL, FALSE, FALSE);
|
WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
else if (!lstrcmpiW (condition, defdW)) {
|
else if (!lstrcmpiW (condition, defdW)) {
|
||||||
test = (GetEnvironmentVariableW(WCMD_parameter(p, 1+negate, NULL, NULL, FALSE, FALSE),
|
test = (GetEnvironmentVariableW(WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE),
|
||||||
NULL, 0) > 0);
|
NULL, 0) > 0);
|
||||||
WCMD_parameter(p, 2+negate, &command, NULL, FALSE, FALSE);
|
WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
else if ((s = strstrW (p, eqeqW))) {
|
else if ((s = strstrW (p, eqeqW))) {
|
||||||
/* We need to get potential surrounding double quotes, so param1/2 can't be used */
|
/* We need to get potential surrounding double quotes, so param1/2 can't be used */
|
||||||
WCHAR *leftPart, *leftPartEnd, *rightPart, *rightPartEnd;
|
WCHAR *leftPart, *rightPart;
|
||||||
|
unsigned int leftPartLen, rightPartLen;
|
||||||
s += 2;
|
s += 2;
|
||||||
WCMD_parameter(p, 0+negate+caseInsensitive, &leftPart, &leftPartEnd, TRUE, FALSE);
|
leftPartLen = strlenW(WCMD_parameter(p, 0+negate+caseInsensitive, &leftPart, TRUE, FALSE));
|
||||||
WCMD_parameter(p, 1+negate+caseInsensitive, &rightPart, &rightPartEnd, TRUE, FALSE);
|
rightPartLen = strlenW(WCMD_parameter(p, 1+negate+caseInsensitive, &rightPart, TRUE, FALSE));
|
||||||
test = caseInsensitive
|
test = caseInsensitive
|
||||||
? (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
|
? (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
|
||||||
leftPart, leftPartEnd-leftPart+1,
|
leftPart, leftPartLen,
|
||||||
rightPart, rightPartEnd-rightPart+1) == CSTR_EQUAL)
|
rightPart, rightPartLen) == CSTR_EQUAL)
|
||||||
: (CompareStringW(LOCALE_SYSTEM_DEFAULT, 0,
|
: (CompareStringW(LOCALE_SYSTEM_DEFAULT, 0,
|
||||||
leftPart, leftPartEnd-leftPart+1,
|
leftPart, leftPartLen,
|
||||||
rightPart, rightPartEnd-rightPart+1) == CSTR_EQUAL);
|
rightPart, rightPartLen) == CSTR_EQUAL);
|
||||||
WCMD_parameter(s, 1, &command, NULL, FALSE, FALSE);
|
WCMD_parameter(s, 1, &command, FALSE, FALSE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
|
||||||
|
@ -2573,7 +2574,7 @@ void WCMD_remove_dir (WCHAR *args) {
|
||||||
|
|
||||||
/* Loop through all args */
|
/* Loop through all args */
|
||||||
while (argN) {
|
while (argN) {
|
||||||
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, NULL, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
|
||||||
if (argN && argN[0] != '/') {
|
if (argN && argN[0] != '/') {
|
||||||
WINE_TRACE("rd: Processing arg %s (quals:%s)\n", wine_dbgstr_w(thisArg),
|
WINE_TRACE("rd: Processing arg %s (quals:%s)\n", wine_dbgstr_w(thisArg),
|
||||||
wine_dbgstr_w(quals));
|
wine_dbgstr_w(quals));
|
||||||
|
@ -3345,7 +3346,7 @@ void WCMD_type (WCHAR *args) {
|
||||||
/* Loop through all args */
|
/* Loop through all args */
|
||||||
errorlevel = 0;
|
errorlevel = 0;
|
||||||
while (argN) {
|
while (argN) {
|
||||||
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, NULL, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
|
||||||
|
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
WCHAR buffer[512];
|
WCHAR buffer[512];
|
||||||
|
@ -3439,7 +3440,7 @@ void WCMD_more (WCHAR *args) {
|
||||||
WCMD_enter_paged_mode(moreStrPage);
|
WCMD_enter_paged_mode(moreStrPage);
|
||||||
|
|
||||||
while (argN) {
|
while (argN) {
|
||||||
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, NULL, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter (args, argno++, &argN, FALSE, FALSE);
|
||||||
HANDLE h;
|
HANDLE h;
|
||||||
|
|
||||||
if (!argN) break;
|
if (!argN) break;
|
||||||
|
|
|
@ -803,7 +803,7 @@ void WCMD_directory (WCHAR *args)
|
||||||
prevEntry = NULL;
|
prevEntry = NULL;
|
||||||
while (argN) {
|
while (argN) {
|
||||||
WCHAR fullname[MAXSTRING];
|
WCHAR fullname[MAXSTRING];
|
||||||
WCHAR *thisArg = WCMD_parameter(args, argno++, &argN, NULL, FALSE, FALSE);
|
WCHAR *thisArg = WCMD_parameter(args, argno++, &argN, FALSE, FALSE);
|
||||||
if (argN && argN[0] != '/') {
|
if (argN && argN[0] != '/') {
|
||||||
|
|
||||||
WINE_TRACE("Found parm '%s'\n", wine_dbgstr_w(thisArg));
|
WINE_TRACE("Found parm '%s'\n", wine_dbgstr_w(thisArg));
|
||||||
|
|
|
@ -107,8 +107,8 @@ static inline BOOL WCMD_is_console_handle(HANDLE h)
|
||||||
return (((DWORD_PTR)h) & 3) == 3;
|
return (((DWORD_PTR)h) & 3) == 3;
|
||||||
}
|
}
|
||||||
WCHAR *WCMD_fgets (WCHAR *buf, DWORD n, HANDLE stream);
|
WCHAR *WCMD_fgets (WCHAR *buf, DWORD n, HANDLE stream);
|
||||||
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **start, WCHAR **end, BOOL raw, BOOL wholecmdline);
|
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **start, BOOL raw, BOOL wholecmdline);
|
||||||
WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, WCHAR **end, BOOL raw,
|
WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, BOOL raw,
|
||||||
BOOL wholecmdline, const WCHAR *delims);
|
BOOL wholecmdline, const WCHAR *delims);
|
||||||
WCHAR *WCMD_skip_leading_spaces (WCHAR *string);
|
WCHAR *WCMD_skip_leading_spaces (WCHAR *string);
|
||||||
BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
|
BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
|
||||||
|
|
|
@ -838,15 +838,15 @@ static void handleExpansion(WCHAR *cmd, BOOL justFors,
|
||||||
/* Replace use of %0...%9 if in batch program*/
|
/* Replace use of %0...%9 if in batch program*/
|
||||||
} else if (!justFors && context && (i >= 0) && (i <= 9)) {
|
} else if (!justFors && context && (i >= 0) && (i <= 9)) {
|
||||||
t = WCMD_parameter(context -> command, i + context -> shift_count[i],
|
t = WCMD_parameter(context -> command, i + context -> shift_count[i],
|
||||||
NULL, NULL, TRUE, TRUE);
|
NULL, TRUE, TRUE);
|
||||||
WCMD_strsubstW(p, p+2, t, -1);
|
WCMD_strsubstW(p, p+2, t, -1);
|
||||||
|
|
||||||
/* Replace use of %* if in batch program*/
|
/* Replace use of %* if in batch program*/
|
||||||
} else if (!justFors && context && *(p+1)=='*') {
|
} else if (!justFors && context && *(p+1)=='*') {
|
||||||
WCHAR *startOfParms = NULL;
|
WCHAR *startOfParms = NULL;
|
||||||
WCMD_parameter(context -> command, 0, NULL, &startOfParms, TRUE, TRUE);
|
WCHAR *thisParm = WCMD_parameter(context -> command, 0, &startOfParms, TRUE, TRUE);
|
||||||
if (startOfParms != NULL) {
|
if (startOfParms != NULL) {
|
||||||
startOfParms++; /* Skip to first delimiter then skip whitespace */
|
startOfParms += strlenW(thisParm);
|
||||||
while (*startOfParms==' ' || *startOfParms == '\t') startOfParms++;
|
while (*startOfParms==' ' || *startOfParms == '\t') startOfParms++;
|
||||||
WCMD_strsubstW(p, p+2, startOfParms, -1);
|
WCMD_strsubstW(p, p+2, startOfParms, -1);
|
||||||
} else
|
} else
|
||||||
|
@ -1025,7 +1025,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
|
||||||
|
|
||||||
/* Quick way to get the filename is to extract the first argument. */
|
/* Quick way to get the filename is to extract the first argument. */
|
||||||
WINE_TRACE("Running '%s' (%d)\n", wine_dbgstr_w(command), called);
|
WINE_TRACE("Running '%s' (%d)\n", wine_dbgstr_w(command), called);
|
||||||
firstParam = WCMD_parameter(command, 0, NULL, NULL, FALSE, TRUE);
|
firstParam = WCMD_parameter(command, 0, NULL, FALSE, TRUE);
|
||||||
if (!firstParam) return;
|
if (!firstParam) return;
|
||||||
|
|
||||||
/* Calculate the search path and stem to search for */
|
/* Calculate the search path and stem to search for */
|
||||||
|
@ -1380,7 +1380,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
|
|
||||||
/* Otherwise STDIN could come from a '<' redirect */
|
/* Otherwise STDIN could come from a '<' redirect */
|
||||||
} else if ((p = strchrW(new_redir,'<')) != NULL) {
|
} else if ((p = strchrW(new_redir,'<')) != NULL) {
|
||||||
h = CreateFileW(WCMD_parameter(++p, 0, NULL, NULL, FALSE, FALSE), GENERIC_READ, FILE_SHARE_READ,
|
h = CreateFileW(WCMD_parameter(++p, 0, NULL, FALSE, FALSE), GENERIC_READ, FILE_SHARE_READ,
|
||||||
&sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
&sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
|
@ -1425,7 +1425,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
||||||
WINE_TRACE("Redirect %d (%p) to %d (%p)\n", handle, GetStdHandle(idx_stdhandles[idx]), idx, h);
|
WINE_TRACE("Redirect %d (%p) to %d (%p)\n", handle, GetStdHandle(idx_stdhandles[idx]), idx, h);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
WCHAR *param = WCMD_parameter(p, 0, NULL, NULL, FALSE, FALSE);
|
WCHAR *param = WCMD_parameter(p, 0, NULL, FALSE, FALSE);
|
||||||
h = CreateFileW(param, GENERIC_WRITE, 0, &sa, creationDisposition,
|
h = CreateFileW(param, GENERIC_WRITE, 0, &sa, creationDisposition,
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if (h == INVALID_HANDLE_VALUE) {
|
if (h == INVALID_HANDLE_VALUE) {
|
||||||
|
@ -2357,14 +2357,14 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
args = 1; /* start at first arg, skipping cmd.exe itself */
|
args = 1; /* start at first arg, skipping cmd.exe itself */
|
||||||
|
|
||||||
opt_c = opt_k = opt_q = opt_s = FALSE;
|
opt_c = opt_k = opt_q = opt_s = FALSE;
|
||||||
WCMD_parameter(cmdLine, args, &argPos, NULL, TRUE, TRUE);
|
WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
|
||||||
while (argPos && argPos[0] != 0x00)
|
while (argPos && argPos[0] != 0x00)
|
||||||
{
|
{
|
||||||
WCHAR c;
|
WCHAR c;
|
||||||
WINE_TRACE("Command line parm: '%s'\n", wine_dbgstr_w(argPos));
|
WINE_TRACE("Command line parm: '%s'\n", wine_dbgstr_w(argPos));
|
||||||
if (argPos[0]!='/' || argPos[1]=='\0') {
|
if (argPos[0]!='/' || argPos[1]=='\0') {
|
||||||
args++;
|
args++;
|
||||||
WCMD_parameter(cmdLine, args, &argPos, NULL, TRUE, TRUE);
|
WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2389,7 +2389,7 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
|
|
||||||
if (argPos[2]==0 || argPos[2]==' ' || argPos[2]=='\t') {
|
if (argPos[2]==0 || argPos[2]==' ' || argPos[2]=='\t') {
|
||||||
args++;
|
args++;
|
||||||
WCMD_parameter(cmdLine, args, &argPos, NULL, TRUE, TRUE);
|
WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
else /* handle `cmd /cnotepad.exe` and `cmd /x/c ...` */
|
else /* handle `cmd /cnotepad.exe` and `cmd /x/c ...` */
|
||||||
{
|
{
|
||||||
|
@ -2470,7 +2470,7 @@ int wmain (int argc, WCHAR *argvW[])
|
||||||
/* Finally, we only stay in new mode IF the first parameter is quoted and
|
/* Finally, we only stay in new mode IF the first parameter is quoted and
|
||||||
is a valid executable, i.e. must exist, otherwise drop back to old mode */
|
is a valid executable, i.e. must exist, otherwise drop back to old mode */
|
||||||
if (!opt_s) {
|
if (!opt_s) {
|
||||||
WCHAR *thisArg = WCMD_parameter(cmd, 0, NULL, NULL, FALSE, TRUE);
|
WCHAR *thisArg = WCMD_parameter(cmd, 0, NULL, FALSE, TRUE);
|
||||||
WCHAR pathext[MAXSTRING];
|
WCHAR pathext[MAXSTRING];
|
||||||
BOOL found = FALSE;
|
BOOL found = FALSE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue