mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 11:31:40 +00:00
support else
handle negative values in special envvars stdin,out,err can't be redirected for windows gui apps svn path=/trunk/; revision=32068
This commit is contained in:
parent
00e33fbce3
commit
11ca34b0e3
2 changed files with 42 additions and 14 deletions
|
@ -458,10 +458,21 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
|||
{
|
||||
if (*first == _T(')'))
|
||||
{
|
||||
bc->bCmdBlock--;
|
||||
first++;
|
||||
/* Strip leading spaces and trailing space/control chars */
|
||||
while(_istspace (*first))
|
||||
first++;
|
||||
if ((_tcsncicmp (first, _T("else"), 4) == 0) && (_tcschr(first, _T('('))))
|
||||
{
|
||||
bc->bExecuteBlock[bc->bCmdBlock] = !bc->bExecuteBlock[bc->bCmdBlock];
|
||||
}
|
||||
else
|
||||
{
|
||||
bc->bCmdBlock--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ((bc->bCmdBlock >= 0) && (bc->bCmdBlock < MAX_PATH))
|
||||
if (bc->bCmdBlock < MAX_PATH)
|
||||
if (!bc->bExecuteBlock[bc->bCmdBlock])
|
||||
{
|
||||
/* increase the bCmdBlock count when there is another conditon which opens a new bracket */
|
||||
|
|
|
@ -811,9 +811,18 @@ VOID ParseCommandLine (LPTSTR cmd)
|
|||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LoadString(CMD_ModuleHandle, STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf(szMsg, in);
|
||||
return;
|
||||
if (bc)
|
||||
{
|
||||
/* will fail for windows gui apps */
|
||||
num = 0;
|
||||
bc->hBatchFile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadString(CMD_ModuleHandle, STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE);
|
||||
ConErrPrintf(szMsg, in);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!SetStdHandle (STD_INPUT_HANDLE, hFile))
|
||||
|
@ -892,7 +901,7 @@ VOID ParseCommandLine (LPTSTR cmd)
|
|||
|
||||
/* Now set up the end conditions... */
|
||||
/* redirect STDOUT */
|
||||
if (out[0])
|
||||
if ((bc) && (bc->hBatchFile != INVALID_HANDLE_VALUE) && (out[0]))
|
||||
{
|
||||
/* Final output to here */
|
||||
HANDLE hFile;
|
||||
|
@ -959,7 +968,7 @@ VOID ParseCommandLine (LPTSTR cmd)
|
|||
}
|
||||
|
||||
/* redirect STDERR */
|
||||
if (err[0])
|
||||
if ((bc) && (bc->hBatchFile != INVALID_HANDLE_VALUE) && (err[0]))
|
||||
{
|
||||
/* Final output to here */
|
||||
HANDLE hFile;
|
||||
|
@ -1165,15 +1174,23 @@ GetEnvVarOrSpecial ( LPCTSTR varName )
|
|||
if (position)
|
||||
{
|
||||
position += 2;
|
||||
Token = _tcstok(position, _T(","));
|
||||
while ((Token != NULL) && (i < 2))
|
||||
if (_tcschr(position, _T(',')) != NULL)
|
||||
{
|
||||
StringPart[i] = _ttoi(Token);
|
||||
i++;
|
||||
Token = _tcstok (NULL, _T(","));
|
||||
Token = _tcstok(position, _T(","));
|
||||
while ((Token != NULL) && (i < 2))
|
||||
{
|
||||
StringPart[i] = _ttoi(Token);
|
||||
i++;
|
||||
Token = _tcstok (NULL, _T(","));
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (StringPart[1] < 0)
|
||||
StringPart[1] = _tcslen(ret + StringPart[0]) + StringPart[1];
|
||||
_tcsncpy(ReturnValue, ret + StringPart[0], StringPart[1]);
|
||||
_tcscpy(ret, ReturnValue);
|
||||
}
|
||||
}
|
||||
_tcsncpy(ReturnValue, ret + StringPart[0], StringPart[1]);
|
||||
_tcscpy(ret, ReturnValue);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue