mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
- Implement SHIFT /n.
- Make prompt code $T and %TIME% have the hours space-padded, not zero-padded. - Allow delayed expansion in the parameter of IF ERRORLEVEL. svn path=/trunk/; revision=40084
This commit is contained in:
parent
466a9064a2
commit
3a52766a90
5 changed files with 26 additions and 9 deletions
|
@ -91,7 +91,7 @@ LPTSTR FindArg(TCHAR Char, BOOL *IsParam0)
|
|||
if (n < 0 || n > 9)
|
||||
return NULL;
|
||||
|
||||
n += bc->shiftlevel;
|
||||
n = bc->shiftlevel[n];
|
||||
*IsParam0 = (n == 0);
|
||||
pp = bc->params;
|
||||
|
||||
|
@ -207,6 +207,7 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd
|
|||
{
|
||||
BATCH_CONTEXT new;
|
||||
LPFOR_CONTEXT saved_fc;
|
||||
INT i;
|
||||
|
||||
HANDLE hFile;
|
||||
SetLastError(0);
|
||||
|
@ -260,7 +261,8 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd
|
|||
bc->hBatchFile = hFile;
|
||||
SetFilePointer (bc->hBatchFile, 0, NULL, FILE_BEGIN);
|
||||
bc->bEcho = bEcho; /* Preserve echo across batch calls */
|
||||
bc->shiftlevel = 0;
|
||||
for (i = 0; i < 10; i++)
|
||||
bc->shiftlevel[i] = i;
|
||||
|
||||
bc->params = BatchParams (firstword, param);
|
||||
//
|
||||
|
|
|
@ -14,7 +14,7 @@ typedef struct tagBATCHCONTEXT
|
|||
TCHAR BatchFilePath[MAX_PATH];
|
||||
LPTSTR params;
|
||||
LPTSTR raw_params; /* Holds the raw params given by the input */
|
||||
INT shiftlevel;
|
||||
INT shiftlevel[10];
|
||||
BOOL bEcho; /* Preserve echo flag across batch calls */
|
||||
REDIRECTION *RedirList;
|
||||
PARSED_COMMAND *current;
|
||||
|
|
|
@ -103,7 +103,7 @@ BOOL ExecuteIf(PARSED_COMMAND *Cmd)
|
|||
else if (Cmd->If.Operator == IF_ERRORLEVEL)
|
||||
{
|
||||
/* IF ERRORLEVEL n: check if last exit code is greater or equal to n */
|
||||
INT n = _tcstol(Cmd->If.RightArg, ¶m, 10);
|
||||
INT n = _tcstol(Right, ¶m, 10);
|
||||
if (*param != _T('\0'))
|
||||
{
|
||||
error_syntax(Right);
|
||||
|
|
|
@ -76,7 +76,7 @@ GetTimeString(VOID)
|
|||
static TCHAR szTime[12];
|
||||
SYSTEMTIME t;
|
||||
GetLocalTime(&t);
|
||||
_stprintf(szTime, _T("%02d%c%02d%c%02d%c%02d"),
|
||||
_stprintf(szTime, _T("%2d%c%02d%c%02d%c%02d"),
|
||||
t.wHour, cTimeSeparator, t.wMinute, cTimeSeparator,
|
||||
t.wSecond, cDecimalSeparator, t.wMilliseconds / 10);
|
||||
return szTime;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
INT cmd_shift (LPTSTR param)
|
||||
{
|
||||
|
||||
INT i = 0;
|
||||
TRACE ("cmd_shift: (\'%s\')\n", debugstr_aw(param));
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
|
@ -58,11 +58,26 @@ INT cmd_shift (LPTSTR param)
|
|||
|
||||
if (!_tcsicmp (param, _T("down")))
|
||||
{
|
||||
if (bc->shiftlevel)
|
||||
bc->shiftlevel--;
|
||||
if (bc->shiftlevel[0])
|
||||
for (; i <= 9; i++)
|
||||
bc->shiftlevel[i]--;
|
||||
}
|
||||
else /* shift up */
|
||||
bc->shiftlevel++;
|
||||
{
|
||||
if (*param == _T('/'))
|
||||
{
|
||||
if (param[1] < '0' || param[1] > '9')
|
||||
{
|
||||
error_invalid_switch(param[1]);
|
||||
return 1;
|
||||
}
|
||||
i = param[1] - '0';
|
||||
}
|
||||
|
||||
for (; i < 9; i++)
|
||||
bc->shiftlevel[i] = bc->shiftlevel[i + 1];
|
||||
bc->shiftlevel[i]++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue