mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:33:10 +00:00
[CMD] Some fixes for getting the enhanced '%~XXX' batch/FOR variables.
CORE-11857 CORE-13736 It will be followed with a separate fix for the FOR-loop code. Fixes some cmd_winetests. A NULL pointer can be returned for a valid existing batch/FOR variable, in which case the enhanced-variable getter should return an empty string. This situation can happen e.g. when forcing a FOR-loop to tokenize a text line with not enough tokens in it.
This commit is contained in:
parent
014efdf7e8
commit
cb2a9c31a6
4 changed files with 146 additions and 58 deletions
|
@ -74,29 +74,35 @@ TCHAR textline[BATCH_BUFFSIZE];
|
|||
/*
|
||||
* Returns a pointer to the n'th parameter of the current batch file.
|
||||
* If no such parameter exists returns pointer to empty string.
|
||||
* If no batch file is current, returns NULL
|
||||
*
|
||||
* If no batch file is current, returns NULL.
|
||||
*/
|
||||
LPTSTR FindArg(TCHAR Char, BOOL *IsParam0)
|
||||
BOOL
|
||||
FindArg(
|
||||
IN TCHAR Char,
|
||||
OUT PCTSTR* ArgPtr,
|
||||
OUT BOOL* IsParam0)
|
||||
{
|
||||
LPTSTR pp;
|
||||
PCTSTR pp;
|
||||
INT n = Char - _T('0');
|
||||
|
||||
TRACE ("FindArg: (%d)\n", n);
|
||||
TRACE("FindArg: (%d)\n", n);
|
||||
|
||||
*ArgPtr = NULL;
|
||||
|
||||
if (n < 0 || n > 9)
|
||||
return NULL;
|
||||
return FALSE;
|
||||
|
||||
n = bc->shiftlevel[n];
|
||||
*IsParam0 = (n == 0);
|
||||
pp = bc->params;
|
||||
|
||||
/* Step up the strings till we reach the end */
|
||||
/* or the one we want */
|
||||
/* Step up the strings till we reach
|
||||
* the end or the one we want. */
|
||||
while (*pp && n--)
|
||||
pp += _tcslen (pp) + 1;
|
||||
pp += _tcslen(pp) + 1;
|
||||
|
||||
return pp;
|
||||
*ArgPtr = pp;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue