- Implement call :label by creating a new batch context; this way calls can be nested and have their own %0-%9 parameters.

- GetBatchVar: Implement %~n. Remove %? (an old FreeDOS-ism; the Windows equivalent is %ERRORLEVEL%)

svn path=/trunk/; revision=35681
This commit is contained in:
Jeffrey Morlan 2008-08-26 20:36:38 +00:00
parent 317fe611cb
commit 6c2116d0cf
5 changed files with 50 additions and 38 deletions

View file

@ -216,10 +216,9 @@ VOID ExitBatch (LPTSTR msg)
*
*/
BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, BOOL forcenew)
{
HANDLE hFile;
LPTSTR tmp;
SetLastError(0);
hFile = CreateFile (fullname, GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL |
@ -238,7 +237,7 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
while (bc && bc->forvar)
ExitBatch (NULL);
if (bc == NULL)
if (bc == NULL || forcenew)
{
/* No curent batch file, create a new context */
LPBATCH_CONTEXT n = (LPBATCH_CONTEXT)cmd_alloc (sizeof(BATCH_CONTEXT));
@ -264,16 +263,13 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
cmd_free (bc->raw_params);
}
GetFullPathName(fullname, sizeof(bc->BatchFilePath) / sizeof(TCHAR), bc->BatchFilePath, &tmp);
*tmp = '\0';
GetFullPathName(fullname, sizeof(bc->BatchFilePath) / sizeof(TCHAR), bc->BatchFilePath, NULL);
bc->hBatchFile = hFile;
SetFilePointer (bc->hBatchFile, 0, NULL, FILE_BEGIN);
bc->bEcho = bEcho; /* Preserve echo across batch calls */
bc->shiftlevel = 0;
bc->bCmdBlock = -1;
bc->lCallPosition = 0;
bc->lCallPositionHigh = 0;
bc->ffind = NULL;
bc->forvar = _T('\0');