mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
[CMD] Syntax errors during parsing of batch parameters expansion, or FOR and IF commands, are fatal, and batch execution should stop.
- To this purpose use the ParseErrorEx() that correctly sets the bParseError flag, and return the partially-parsed command so that it gets echoed as well for diagnostics purposes (Windows-compatible). - Any other parameters specified after (or before) the '/?' switch for the FOR and IF commands, are considered fatal syntax errors as well, thus we employ the ParseErrorEx() as well.
This commit is contained in:
parent
6eb1cae348
commit
495c82ccde
|
@ -1208,7 +1208,7 @@ GetBatchVar(TCHAR *varName, UINT *varNameLen)
|
||||||
ret = GetEnhancedVar(&varNameEnd, FindArg);
|
ret = GetEnhancedVar(&varNameEnd, FindArg);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
error_syntax(varName);
|
ParseErrorEx(varName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*varNameLen = varNameEnd - varName;
|
*varNameLen = varNameEnd - varName;
|
||||||
|
@ -1267,6 +1267,14 @@ SubstituteVars(TCHAR *Src, TCHAR *Dest, TCHAR Delim)
|
||||||
{
|
{
|
||||||
UINT NameLen;
|
UINT NameLen;
|
||||||
Var = GetBatchVar(Src, &NameLen);
|
Var = GetBatchVar(Src, &NameLen);
|
||||||
|
if (!Var && bParseError)
|
||||||
|
{
|
||||||
|
/* Return the partially-parsed command to be
|
||||||
|
* echoed for error diagnostics purposes. */
|
||||||
|
APPEND1(Delim);
|
||||||
|
APPEND(Src, DestEnd-Dest);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (Var != NULL)
|
if (Var != NULL)
|
||||||
{
|
{
|
||||||
VarLength = _tcslen(Var);
|
VarLength = _tcslen(Var);
|
||||||
|
|
|
@ -44,7 +44,7 @@ INT cmd_for(LPTSTR param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_syntax(param);
|
ParseErrorEx(param);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ INT cmd_if(LPTSTR param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_syntax(param);
|
ParseErrorEx(param);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue