Author: jmorlan Date: Wed Mar 18 06:52:58 2009 New Revision: 40084
URL: http://svn.reactos.org/svn/reactos?rev=40084&view=rev Log: - 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.
Modified: trunk/reactos/base/shell/cmd/batch.c trunk/reactos/base/shell/cmd/batch.h trunk/reactos/base/shell/cmd/if.c trunk/reactos/base/shell/cmd/locale.c trunk/reactos/base/shell/cmd/shift.c
Modified: trunk/reactos/base/shell/cmd/batch.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.c?rev=... ============================================================================== --- trunk/reactos/base/shell/cmd/batch.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/batch.c [iso-8859-1] Wed Mar 18 06:52:58 2009 @@ -91,7 +91,7 @@ if (n < 0 || n > 9) return NULL;
- n += bc->shiftlevel; + n = bc->shiftlevel[n]; *IsParam0 = (n == 0); pp = bc->params;
@@ -207,6 +207,7 @@ { BATCH_CONTEXT new; LPFOR_CONTEXT saved_fc; + INT i;
HANDLE hFile; SetLastError(0); @@ -260,7 +261,8 @@ 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); //
Modified: trunk/reactos/base/shell/cmd/batch.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.h?rev=... ============================================================================== --- trunk/reactos/base/shell/cmd/batch.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/batch.h [iso-8859-1] Wed Mar 18 06:52:58 2009 @@ -14,7 +14,7 @@ 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;
Modified: trunk/reactos/base/shell/cmd/if.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/if.c?rev=400... ============================================================================== --- trunk/reactos/base/shell/cmd/if.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/if.c [iso-8859-1] Wed Mar 18 06:52:58 2009 @@ -103,7 +103,7 @@ 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);
Modified: trunk/reactos/base/shell/cmd/locale.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/locale.c?rev... ============================================================================== --- trunk/reactos/base/shell/cmd/locale.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/locale.c [iso-8859-1] Wed Mar 18 06:52:58 2009 @@ -76,7 +76,7 @@ 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;
Modified: trunk/reactos/base/shell/cmd/shift.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/shift.c?rev=... ============================================================================== --- trunk/reactos/base/shell/cmd/shift.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/shift.c [iso-8859-1] Wed Mar 18 06:52:58 2009 @@ -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 @@
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; }