- 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:
Jeffrey Morlan 2009-03-18 03:52:58 +00:00
parent 466a9064a2
commit 3a52766a90
5 changed files with 26 additions and 9 deletions

View file

@ -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);
//

View file

@ -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;

View file

@ -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, &param, 10);
INT n = _tcstol(Right, &param, 10);
if (*param != _T('\0'))
{
error_syntax(Right);

View file

@ -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;

View file

@ -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;
}