last bugfixes for cmd

svn path=/trunk/; revision=389
This commit is contained in:
Eric Kohl 1999-04-16 00:16:18 +00:00
parent 7e74c066a7
commit eda973b1cc
7 changed files with 44 additions and 23 deletions

View file

@ -197,18 +197,21 @@ Execute (LPTSTR first, LPTSTR rest)
else else
{ {
/* exec the program */ /* exec the program */
#ifndef __REACTOS__
TCHAR szFullCmdLine [1024]; TCHAR szFullCmdLine [1024];
#endif
PROCESS_INFORMATION prci; PROCESS_INFORMATION prci;
STARTUPINFO stui; STARTUPINFO stui;
// DWORD dwError = 0;
#ifdef _DEBUG #ifdef _DEBUG
DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest); DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest);
#endif #endif
#ifndef __REACTOS__
/* build command line for CreateProcess() */ /* build command line for CreateProcess() */
_tcscpy (szFullCmdLine, szFullName); _tcscpy (szFullCmdLine, szFullName);
_tcscat (szFullCmdLine, _T(" ")); _tcscat (szFullCmdLine, _T(" "));
_tcscat (szFullCmdLine, rest); _tcscat (szFullCmdLine, rest);
#endif
/* fill startup info */ /* fill startup info */
memset (&stui, 0, sizeof (STARTUPINFO)); memset (&stui, 0, sizeof (STARTUPINFO));
@ -216,8 +219,13 @@ Execute (LPTSTR first, LPTSTR rest)
stui.dwFlags = STARTF_USESHOWWINDOW; stui.dwFlags = STARTF_USESHOWWINDOW;
stui.wShowWindow = SW_SHOWDEFAULT; stui.wShowWindow = SW_SHOWDEFAULT;
#ifndef __REACTOS__
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE, if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &stui, &prci)) 0, NULL, NULL, &stui, &prci))
#else
if (CreateProcess (szFullName, rest, NULL, NULL, FALSE,
0, NULL, NULL, &stui, &prci))
#endif
{ {
DWORD dwExitCode; DWORD dwExitCode;
WaitForSingleObject (prci.hProcess, INFINITE); WaitForSingleObject (prci.hProcess, INFINITE);
@ -229,7 +237,7 @@ Execute (LPTSTR first, LPTSTR rest)
else else
{ {
ErrorMessage (GetLastError (), ErrorMessage (GetLastError (),
"Error executing CreateProcess()!!\n"); "Error executing CreateProcess()!!\n");
} }
} }
} }

View file

@ -70,7 +70,9 @@ VOID ConInKey (PINPUT_RECORD lpBuffer)
do do
{ {
WaitForSingleObject (hInput, INFINITE); #ifndef __REACTOS__
WaitForSingleObject (hInput, INFINITE);
#endif
ReadConsoleInput (hInput, lpBuffer, 1, &dwRead); ReadConsoleInput (hInput, lpBuffer, 1, &dwRead);
if ((lpBuffer->EventType == KEY_EVENT) && if ((lpBuffer->EventType == KEY_EVENT) &&
(lpBuffer->Event.KeyEvent.bKeyDown == TRUE)) (lpBuffer->Event.KeyEvent.bKeyDown == TRUE))
@ -239,5 +241,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible)
cci.dwSize = bInsert ? 10 : 100; cci.dwSize = bInsert ? 10 : 100;
cci.bVisible = bVisible; cci.bVisible = bVisible;
// SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
} }

View file

@ -79,7 +79,7 @@
#define ENV_BUFFER_SIZE 1024 #define ENV_BUFFER_SIZE 1024
static LPTSTR ext[] = {".BAT", ".CMD", ".COM", ".EXE"}; static LPTSTR ext[] = {".bat", ".cmd", ".com", ".exe"};
static INT nExtCount = sizeof(ext) / sizeof(LPTSTR); static INT nExtCount = sizeof(ext) / sizeof(LPTSTR);
@ -89,7 +89,7 @@ BOOL
SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
{ {
TCHAR szPathBuffer[MAX_PATH]; TCHAR szPathBuffer[MAX_PATH];
LPTSTR pszBuffer; LPTSTR pszBuffer = NULL;
DWORD dwBuffer; DWORD dwBuffer;
INT n; INT n;
LPTSTR p,s,f; LPTSTR p,s,f;
@ -99,8 +99,7 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0) if (dwBuffer == 0)
{ {
ConErrPrintf (_T("Not PATH environment variable found!\n")); ConErrPrintf (_T("No PATH environment variable found!\n"));
return 0;
} }
else if (dwBuffer > ENV_BUFFER_SIZE) else if (dwBuffer > ENV_BUFFER_SIZE)
{ {
@ -135,6 +134,7 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
#ifdef _DEBUG #ifdef _DEBUG
DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer); DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer);
#endif #endif
ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer);
if (IsValidFileName (szPathBuffer)) if (IsValidFileName (szPathBuffer))
{ {

View file

@ -608,7 +608,8 @@ SetConsoleCP = SetConsoleCP@4
;SetConsoleCommandHistoryMode@4 ;SetConsoleCommandHistoryMode@4
;SetConsoleCtrlHandler@8 ;SetConsoleCtrlHandler@8
;SetConsoleCursor@8 ;SetConsoleCursor@8
;SetConsoleCursorInfo@8 SetConsoleCursorInfo@8
SetConsoleCursorInfo = SetConsoleCursorInfo@8
SetConsoleCursorPosition@8 SetConsoleCursorPosition@8
SetConsoleCursorPosition = SetConsoleCursorPosition@8 SetConsoleCursorPosition = SetConsoleCursorPosition@8
;SetConsoleDisplayMode@12 ;SetConsoleDisplayMode@12

View file

@ -197,18 +197,21 @@ Execute (LPTSTR first, LPTSTR rest)
else else
{ {
/* exec the program */ /* exec the program */
#ifndef __REACTOS__
TCHAR szFullCmdLine [1024]; TCHAR szFullCmdLine [1024];
#endif
PROCESS_INFORMATION prci; PROCESS_INFORMATION prci;
STARTUPINFO stui; STARTUPINFO stui;
// DWORD dwError = 0;
#ifdef _DEBUG #ifdef _DEBUG
DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest); DebugPrintf ("[EXEC: %s %s]\n", szFullName, rest);
#endif #endif
#ifndef __REACTOS__
/* build command line for CreateProcess() */ /* build command line for CreateProcess() */
_tcscpy (szFullCmdLine, szFullName); _tcscpy (szFullCmdLine, szFullName);
_tcscat (szFullCmdLine, _T(" ")); _tcscat (szFullCmdLine, _T(" "));
_tcscat (szFullCmdLine, rest); _tcscat (szFullCmdLine, rest);
#endif
/* fill startup info */ /* fill startup info */
memset (&stui, 0, sizeof (STARTUPINFO)); memset (&stui, 0, sizeof (STARTUPINFO));
@ -216,8 +219,13 @@ Execute (LPTSTR first, LPTSTR rest)
stui.dwFlags = STARTF_USESHOWWINDOW; stui.dwFlags = STARTF_USESHOWWINDOW;
stui.wShowWindow = SW_SHOWDEFAULT; stui.wShowWindow = SW_SHOWDEFAULT;
#ifndef __REACTOS__
if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE, if (CreateProcess (NULL, szFullCmdLine, NULL, NULL, FALSE,
0, NULL, NULL, &stui, &prci)) 0, NULL, NULL, &stui, &prci))
#else
if (CreateProcess (szFullName, rest, NULL, NULL, FALSE,
0, NULL, NULL, &stui, &prci))
#endif
{ {
DWORD dwExitCode; DWORD dwExitCode;
WaitForSingleObject (prci.hProcess, INFINITE); WaitForSingleObject (prci.hProcess, INFINITE);
@ -229,7 +237,7 @@ Execute (LPTSTR first, LPTSTR rest)
else else
{ {
ErrorMessage (GetLastError (), ErrorMessage (GetLastError (),
"Error executing CreateProcess()!!\n"); "Error executing CreateProcess()!!\n");
} }
} }
} }

View file

@ -70,7 +70,9 @@ VOID ConInKey (PINPUT_RECORD lpBuffer)
do do
{ {
WaitForSingleObject (hInput, INFINITE); #ifndef __REACTOS__
WaitForSingleObject (hInput, INFINITE);
#endif
ReadConsoleInput (hInput, lpBuffer, 1, &dwRead); ReadConsoleInput (hInput, lpBuffer, 1, &dwRead);
if ((lpBuffer->EventType == KEY_EVENT) && if ((lpBuffer->EventType == KEY_EVENT) &&
(lpBuffer->Event.KeyEvent.bKeyDown == TRUE)) (lpBuffer->Event.KeyEvent.bKeyDown == TRUE))
@ -239,5 +241,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible)
cci.dwSize = bInsert ? 10 : 100; cci.dwSize = bInsert ? 10 : 100;
cci.bVisible = bVisible; cci.bVisible = bVisible;
// SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci);
} }

View file

@ -79,7 +79,7 @@
#define ENV_BUFFER_SIZE 1024 #define ENV_BUFFER_SIZE 1024
static LPTSTR ext[] = {".BAT", ".CMD", ".COM", ".EXE"}; static LPTSTR ext[] = {".bat", ".cmd", ".com", ".exe"};
static INT nExtCount = sizeof(ext) / sizeof(LPTSTR); static INT nExtCount = sizeof(ext) / sizeof(LPTSTR);
@ -89,7 +89,7 @@ BOOL
SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
{ {
TCHAR szPathBuffer[MAX_PATH]; TCHAR szPathBuffer[MAX_PATH];
LPTSTR pszBuffer; LPTSTR pszBuffer = NULL;
DWORD dwBuffer; DWORD dwBuffer;
INT n; INT n;
LPTSTR p,s,f; LPTSTR p,s,f;
@ -99,8 +99,7 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0) if (dwBuffer == 0)
{ {
ConErrPrintf (_T("Not PATH environment variable found!\n")); ConErrPrintf (_T("No PATH environment variable found!\n"));
return 0;
} }
else if (dwBuffer > ENV_BUFFER_SIZE) else if (dwBuffer > ENV_BUFFER_SIZE)
{ {
@ -135,6 +134,7 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName)
#ifdef _DEBUG #ifdef _DEBUG
DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer); DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer);
#endif #endif
ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer);
if (IsValidFileName (szPathBuffer)) if (IsValidFileName (szPathBuffer))
{ {