fix one bug with cmd goto so WBAT will work bit more now. thx gasmann to report it.

svn path=/trunk/; revision=16668
This commit is contained in:
Magnus Olsen 2005-07-20 17:06:53 +00:00
parent 8e5b438930
commit 4365851492

View file

@ -72,14 +72,20 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
tmp++; tmp++;
*tmp = _T('\0'); *tmp = _T('\0');
/* set file pointer to the beginning of the batch file */ /* set file pointer to the beginning of the batch file */
lNewPosHigh = 0; lNewPosHigh = 0;
SetFilePointer (bc->hBatchFile, 0, &lNewPosHigh, FILE_BEGIN); SetFilePointer (bc->hBatchFile, 0, &lNewPosHigh, FILE_BEGIN);
while (FileGetString (bc->hBatchFile, textline, sizeof(textline))) while (FileGetString (bc->hBatchFile, textline, sizeof(textline)))
{ {
int pos;
int size;
/* Strip out any trailing spaces or control chars */ /* Strip out any trailing spaces or control chars */
tmp = textline + _tcslen (textline) - 1; tmp = textline + _tcslen (textline) - 1;
while (_istcntrl (*tmp) || _istspace (*tmp)) while (_istcntrl (*tmp) || _istspace (*tmp))
tmp--; tmp--;
*(tmp + 1) = _T('\0'); *(tmp + 1) = _T('\0');
@ -89,15 +95,24 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
while (_istspace (*tmp)) while (_istspace (*tmp))
tmp++; tmp++;
/* use only 1st 8 chars of label */ /* All space after leading space terminate the string */
if ((*tmp == _T(':')) && (_tcsncmp (++tmp, param, 8) == 0)) size = _tcslen(tmp) -1;
pos=0;
while (tmp+pos < tmp+size)
{
if (_istspace(tmp[pos]))
tmp[pos]=_T('\0');
pos++;
}
/* use whole label name */
if ((*tmp == _T(':')) && (_tcsicmp (++tmp, param) == 0))
return 0; return 0;
} }
LoadString(CMD_ModuleHandle, STRING_GOTO_ERROR2, szMsg, RC_STRING_MAX_SIZE); LoadString(CMD_ModuleHandle, STRING_GOTO_ERROR2, szMsg, RC_STRING_MAX_SIZE);
ConErrPrintf(szMsg, param); ConErrPrintf(szMsg, param);
ExitBatch(NULL); ExitBatch(NULL);
return 1; return 1;
} }