diff --git a/reactos/apps/utils/cmd/attrib.c b/reactos/apps/utils/cmd/attrib.c index 8316e63ef05..ebdda49b471 100644 --- a/reactos/apps/utils/cmd/attrib.c +++ b/reactos/apps/utils/cmd/attrib.c @@ -316,8 +316,14 @@ INT cmd_attrib (LPTSTR cmd, LPTSTR param) if (argc == 0) { - GetCurrentDirectory (MAX_PATH, szPath); - _tcscat (szPath, _T("\\")); + DWORD len; + + len = GetCurrentDirectory (MAX_PATH, szPath); + if (szPath[len-1] != _T('\\')) + { + szPath[len] = _T('\\'); + szPath[len + 1] = 0; + } _tcscpy (szFileName, _T("*.*")); PrintAttribute (szPath, szFileName, bRecurse); } diff --git a/reactos/apps/utils/cmd/cmdinput.c b/reactos/apps/utils/cmd/cmdinput.c index e2021bbf455..9f087ef0378 100644 --- a/reactos/apps/utils/cmd/cmdinput.c +++ b/reactos/apps/utils/cmd/cmdinput.c @@ -125,7 +125,7 @@ ClearCommandLine (LPTSTR str, INT maxlen, SHORT orgx, SHORT orgy) #ifndef __REACTOS__ _tcsnset (str, _T('\0'), maxlen); #else - memset (str, 0, maxlen * sizeof(TCHAR)); + memset (str, 0, maxlen * sizeof(TCHAR)); #endif SetCursorXY (orgx, orgy); } diff --git a/reactos/apps/utils/cmd/console.c b/reactos/apps/utils/cmd/console.c index 03d0dfb8a8a..a4881d63442 100644 --- a/reactos/apps/utils/cmd/console.c +++ b/reactos/apps/utils/cmd/console.c @@ -20,13 +20,6 @@ -/* internal variables for paged output */ -SHORT sLineCount; -SHORT sMaxLines; -BOOL bPageable; - - - #ifdef _DEBUG VOID DebugPrintf (LPTSTR szFormat, ...) { @@ -38,7 +31,9 @@ VOID DebugPrintf (LPTSTR szFormat, ...) va_end (arg_ptr); WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL); -// OutputDebugString (szOut); +#if 0 + OutputDebugString (szOut); +#endif } #endif /* _DEBUG */ @@ -70,9 +65,6 @@ VOID ConInKey (PINPUT_RECORD lpBuffer) do { -#ifndef __REACTOS__ - WaitForSingleObject (hInput, INFINITE); -#endif ReadConsoleInput (hInput, lpBuffer, 1, &dwRead); if ((lpBuffer->EventType == KEY_EVENT) && (lpBuffer->Event.KeyEvent.bKeyDown == TRUE)) @@ -127,8 +119,10 @@ VOID ConOutPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); -// WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); - WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); +#if 0 + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +#endif + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -159,8 +153,10 @@ VOID ConErrPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_ERROR_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); -// WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); - WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); +#if 0 + WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +#endif + WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -178,8 +174,6 @@ VOID ConErrPrintf (LPTSTR szFormat, ...) } - - VOID SetCursorXY (SHORT x, SHORT y) { COORD coPos; @@ -241,5 +235,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible) cci.dwSize = bInsert ? 10 : 100; cci.bVisible = bVisible; - SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); } diff --git a/reactos/apps/utils/cmd/misc.c b/reactos/apps/utils/cmd/misc.c index b010cd9e4e2..d863ac762e4 100644 --- a/reactos/apps/utils/cmd/misc.c +++ b/reactos/apps/utils/cmd/misc.c @@ -48,7 +48,6 @@ TCHAR cgetchar (VOID) do { - WaitForSingleObject (hInput, INFINITE); ReadConsoleInput (hInput, &irBuffer, 1, &dwRead); if ((irBuffer.EventType == KEY_EVENT) && (irBuffer.Event.KeyEvent.bKeyDown == TRUE)) diff --git a/reactos/apps/utils/cmd/where.c b/reactos/apps/utils/cmd/where.c index fab018d0d0e..78ed109642a 100644 --- a/reactos/apps/utils/cmd/where.c +++ b/reactos/apps/utils/cmd/where.c @@ -63,7 +63,10 @@ * * 26-Feb-1999 (Eric Kohl ) * Replaced find_which() by SearchForExecutable(). - * Now files are serched with the right order of extensions. + * Now files are searched using the right extension order. + * + * 20-Apr-1999 (Eric Kohl ) + * Some minor changes and improvements. */ #include "config.h" @@ -89,25 +92,20 @@ BOOL SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) { TCHAR szPathBuffer[MAX_PATH]; - LPTSTR pszBuffer = NULL; - DWORD dwBuffer; + LPTSTR pszBuffer = NULL; + DWORD dwBuffer, len; INT n; LPTSTR p,s,f; /* load environment varable PATH into buffer */ pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE); - if (dwBuffer == 0) - { - ConErrPrintf (_T("No PATH environment variable found!\n")); - } - else if (dwBuffer > ENV_BUFFER_SIZE) + if (dwBuffer > ENV_BUFFER_SIZE) { pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR)); GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer * sizeof (TCHAR)); } - /* initialize full name buffer */ *pFullName = _T('\0'); @@ -120,9 +118,12 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) #endif /* search in current directory */ - GetCurrentDirectory (MAX_PATH, szPathBuffer); - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = GetCurrentDirectory (MAX_PATH, szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); p = szPathBuffer + _tcslen (szPathBuffer); @@ -134,7 +135,6 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) #ifdef _DEBUG DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer); #endif -ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); if (IsValidFileName (szPathBuffer)) { @@ -165,8 +165,12 @@ ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); s = NULL; } - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = _tcslen(szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); p = szPathBuffer + _tcslen (szPathBuffer); @@ -200,9 +204,12 @@ ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); #endif /* search in current directory */ - GetCurrentDirectory (MAX_PATH, szPathBuffer); - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = GetCurrentDirectory (MAX_PATH, szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); #ifdef _DEBUG @@ -237,8 +244,12 @@ ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); s = NULL; } - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = _tcslen(szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); #ifdef _DEBUG diff --git a/reactos/lib/crtdll/io/find.c b/reactos/lib/crtdll/io/find.c index 9d4e2b4491d..a18b90513d7 100644 --- a/reactos/lib/crtdll/io/find.c +++ b/reactos/lib/crtdll/io/find.c @@ -9,13 +9,16 @@ int _findfirst(const char *_name, struct _finddata_t *result) { WIN32_FIND_DATA FindFileData; char dir[MAX_PATH]; - - long hFindFile; + int len = 0; if ( _name == NULL || _name[0] == 0 ) { - GetCurrentDirectory(MAX_PATH,dir); - strcat(dir,"\\*.*"); + len = GetCurrentDirectory(MAX_PATH,dir); + if (dir[len-1] != '\\') { + dir[len] = '\\'; + dir[len+1] = 0; + } + strcat(dir,"*.*"); } else strcpy(dir,_name); @@ -48,9 +51,8 @@ int _findnext(int handle, struct _finddata_t *result) strncpy(result->name,FindFileData.cFileName,260); return 0; } + int _findclose(int handle) { return FindClose((void *)handle); } - - diff --git a/reactos/lib/kernel32/file/curdir.c b/reactos/lib/kernel32/file/curdir.c index ac5aa34eec4..13997680959 100644 --- a/reactos/lib/kernel32/file/curdir.c +++ b/reactos/lib/kernel32/file/curdir.c @@ -11,6 +11,8 @@ /* INCLUDES ******************************************************************/ #include +#include +#include #define NDEBUG #include @@ -79,6 +81,11 @@ DWORD STDCALL GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) lpBuffer[2] = 0; lstrcpyW(&lpBuffer[2], DriveDirectoryW[CurrentDrive]); } + if (uSize > 3 && lpBuffer[uSize - 1] == L'\\') + { + lpBuffer[uSize - 1] = 0; + uSize--; + } DPRINT("GetCurrentDirectoryW() = '%w'\n",lpBuffer); return uSize; } @@ -164,7 +171,12 @@ WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName) return(TRUE); } - GetCurrentDirectoryW(MAX_PATH, PathName); + len = GetCurrentDirectoryW(MAX_PATH, PathName); + if (PathName[len-1] != '\\') + { + PathName[len] = '\\'; + PathName[len+1] = 0; + } lstrcatW(PathName, lpPathName); len = lstrlenW(PathName); if (PathName[len-1] != '\\') diff --git a/reactos/lib/kernel32/file/dir.c b/reactos/lib/kernel32/file/dir.c index 5cce4f78286..66c5900bc2e 100644 --- a/reactos/lib/kernel32/file/dir.c +++ b/reactos/lib/kernel32/file/dir.c @@ -19,7 +19,7 @@ #include #include -#define NDEBUG +//#define NDEBUG #include /* FUNCTIONS *****************************************************************/ @@ -168,7 +168,84 @@ DWORD STDCALL GetFullPathNameA(LPCSTR lpFileName, LPSTR lpBuffer, LPSTR *lpFilePart) { - + PSTR p; + PSTR prev = NULL; + + DPRINT("GetFullPathNameA(lpFileName %s, nBufferLength %d, lpBuffer %s, " + "lpFilePart %x)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart); + + if (!lpFileName || !lpBuffer) + return 0; + + if (isalpha(lpFileName[0]) && lpFileName[1] == ':') + { + lstrcpyA(lpBuffer, lpFileName); + } + else if (lpFileName[0] == '\\') + { + GetCurrentDirectoryA(nBufferLength, lpBuffer); + lstrcpyA(&lpBuffer[2], lpFileName); + } + else + { + DWORD len; + len = GetCurrentDirectoryA(nBufferLength, lpBuffer); + if (lpBuffer[len - 1] != '\\') + { + lpBuffer[len] = '\\'; + lpBuffer[len + 1] = 0; + } + lstrcatA(lpBuffer, lpFileName); + } + + DPRINT("lpBuffer %s\n",lpBuffer); + + p = lpBuffer + 2; + + while ((*p) != 0) + { + DPRINT("prev %s p %s\n",prev,p); + if (p[1] == '.' && (p[2] == '\\' || p[2] == 0)) + { + lstrcpyA(p, p+2); + } + else if (p[1] == '.' && p[2] == '.' && (p[3] == '\\' || p[3] == 0) && + prev != NULL) + { + lstrcpyA(prev, p+3); + p = prev; + if (prev == (lpBuffer+2)) + { + prev = NULL; + } + else + { + prev--; + while ((*prev) != '\\') + { + prev--; + } + } + } + else + { + prev = p; + do + { + p++; + } + while ((*p) != 0 && (*p) != '\\'); + } + } + + if (lpFilePart != NULL) + { + (*lpFilePart) = prev; + } + + DPRINT("lpBuffer %s\n",lpBuffer); + + return strlen(lpBuffer); } DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName, @@ -182,7 +259,8 @@ DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName, DPRINT("GetFullPathNameW(lpFileName %w, nBufferLength %d, lpBuffer %w, " "lpFilePart %x)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart); - if (!lpFileName || !lpBuffer) return 0; + if (!lpFileName || !lpBuffer) + return 0; if (isalpha(lpFileName[0]) && lpFileName[1] == ':') { @@ -190,10 +268,18 @@ DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName, } else if (lpFileName[0] == '\\') { + GetCurrentDirectoryW(nBufferLength, lpBuffer); lstrcpyW(&lpBuffer[2], lpFileName); } else { + DWORD len; + len = GetCurrentDirectoryW(nBufferLength, lpBuffer); + if (lpBuffer[len - 1] != L'\\') + { + lpBuffer[len] = L'\\'; + lpBuffer[len + 1] = 0; + } lstrcatW(lpBuffer, lpFileName); } @@ -247,13 +333,6 @@ DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName, return wcslen(lpBuffer); } - - - - - - - DWORD STDCALL GetShortPathNameA( diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index f2f88e667e6..bf9e63f7877 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -419,7 +419,7 @@ DWORD STDCALL GetFileAttributesW(LPCWSTR lpFileName) { CloseHandle(hFile); SetLastError(RtlNtStatusToDosError(errCode)); - return 0; + return 0; } CloseHandle(hFile); return (DWORD)FileBasic.FileAttributes; diff --git a/reactos/lib/kernel32/file/find.c b/reactos/lib/kernel32/file/find.c index bb6b1f51be2..06b88953774 100644 --- a/reactos/lib/kernel32/file/find.c +++ b/reactos/lib/kernel32/file/find.c @@ -112,11 +112,20 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName, OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING DirectoryNameStr; IO_STATUS_BLOCK IoStatusBlock; + DWORD Len = 0; DPRINT("FindFirstFileW(lpFileName %w, lpFindFileData %x)\n", lpFileName, lpFindFileData); - - GetCurrentDirectoryW(MAX_PATH, CurrentDirectory); + +/* + Len = GetCurrentDirectoryW(MAX_PATH, CurrentDirectory); + if (CurrentDirectory[Len - 1] != L'\\') + { + CurrentDirectory[Len] = L'\\'; + CurrentDirectory[Len + 1] = 0; + } +*/ + GetFullPathNameW(lpFileName, MAX_PATH, CurrentDirectory, NULL); Directory[0] = '\\'; Directory[1] = '?'; Directory[2] = '?'; @@ -125,8 +134,8 @@ HANDLE STDCALL InternalFindFirstFile(LPCWSTR lpFileName, DPRINT("Directory %w\n",Directory); wcscat(Directory, CurrentDirectory); DPRINT("Directory %w\n",Directory); - wcscat(Directory, lpFileName); - DPRINT("Directory %w\n",Directory); +// wcscat(Directory, lpFileName); +// DPRINT("Directory %w\n",Directory); End = wcsrchr(Directory, '\\'); *End = 0; @@ -270,7 +279,12 @@ BOOL FindClose(HANDLE hFindFile) PKERNEL32_FIND_FILE_DATA IData; DPRINT("FindClose(hFindFile %x)\n",hFindFile); - + + if (hFindFile || hFindFile == INVALID_HANDLE_VALUE) + { + SetLastError (ERROR_INVALID_HANDLE); + return(FALSE); + } IData = (PKERNEL32_FIND_FILE_DATA)hFindFile; CloseHandle(IData->DirectoryHandle); HeapFree(GetProcessHeap(), 0, IData); diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index a281e9bab91..4805625ff16 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -21,7 +21,7 @@ #include #include -#define NDEBUG +//#define NDEBUG #include /* FUNCTIONS ****************************************************************/ @@ -218,7 +218,8 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName, PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; NTSTATUS Status; HANDLE hSection; - + DWORD len = 0; + hFile = NULL; /* @@ -250,7 +251,12 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName, } if (TempFileName[1] != ':') { - GetCurrentDirectoryW(MAX_PATH,TempDirectoryName); + len = GetCurrentDirectoryW(MAX_PATH,TempDirectoryName); + if (TempDirectoryName[len - 1] != L'\\') + { + TempDirectoryName[len] = L'\\'; + TempDirectoryName[len + 1] = 0; + } wcscat(TempApplicationName,TempDirectoryName); } wcscat(TempApplicationName,TempFileName); diff --git a/rosapps/cmd/attrib.c b/rosapps/cmd/attrib.c index 8316e63ef05..ebdda49b471 100644 --- a/rosapps/cmd/attrib.c +++ b/rosapps/cmd/attrib.c @@ -316,8 +316,14 @@ INT cmd_attrib (LPTSTR cmd, LPTSTR param) if (argc == 0) { - GetCurrentDirectory (MAX_PATH, szPath); - _tcscat (szPath, _T("\\")); + DWORD len; + + len = GetCurrentDirectory (MAX_PATH, szPath); + if (szPath[len-1] != _T('\\')) + { + szPath[len] = _T('\\'); + szPath[len + 1] = 0; + } _tcscpy (szFileName, _T("*.*")); PrintAttribute (szPath, szFileName, bRecurse); } diff --git a/rosapps/cmd/cmdinput.c b/rosapps/cmd/cmdinput.c index e2021bbf455..9f087ef0378 100644 --- a/rosapps/cmd/cmdinput.c +++ b/rosapps/cmd/cmdinput.c @@ -125,7 +125,7 @@ ClearCommandLine (LPTSTR str, INT maxlen, SHORT orgx, SHORT orgy) #ifndef __REACTOS__ _tcsnset (str, _T('\0'), maxlen); #else - memset (str, 0, maxlen * sizeof(TCHAR)); + memset (str, 0, maxlen * sizeof(TCHAR)); #endif SetCursorXY (orgx, orgy); } diff --git a/rosapps/cmd/console.c b/rosapps/cmd/console.c index 03d0dfb8a8a..a4881d63442 100644 --- a/rosapps/cmd/console.c +++ b/rosapps/cmd/console.c @@ -20,13 +20,6 @@ -/* internal variables for paged output */ -SHORT sLineCount; -SHORT sMaxLines; -BOOL bPageable; - - - #ifdef _DEBUG VOID DebugPrintf (LPTSTR szFormat, ...) { @@ -38,7 +31,9 @@ VOID DebugPrintf (LPTSTR szFormat, ...) va_end (arg_ptr); WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szOut, _tcslen(szOut), &dwWritten, NULL); -// OutputDebugString (szOut); +#if 0 + OutputDebugString (szOut); +#endif } #endif /* _DEBUG */ @@ -70,9 +65,6 @@ VOID ConInKey (PINPUT_RECORD lpBuffer) do { -#ifndef __REACTOS__ - WaitForSingleObject (hInput, INFINITE); -#endif ReadConsoleInput (hInput, lpBuffer, 1, &dwRead); if ((lpBuffer->EventType == KEY_EVENT) && (lpBuffer->Event.KeyEvent.bKeyDown == TRUE)) @@ -127,8 +119,10 @@ VOID ConOutPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); -// WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); - WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); +#if 0 + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +#endif + WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -159,8 +153,10 @@ VOID ConErrPuts (LPTSTR szText) DWORD dwWritten; WriteFile (GetStdHandle (STD_ERROR_HANDLE), szText, _tcslen(szText), &dwWritten, NULL); -// WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); - WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); +#if 0 + WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\x0a\x0d", 2, &dwWritten, NULL); +#endif + WriteFile (GetStdHandle (STD_ERROR_HANDLE), "\n", 1, &dwWritten, NULL); } @@ -178,8 +174,6 @@ VOID ConErrPrintf (LPTSTR szFormat, ...) } - - VOID SetCursorXY (SHORT x, SHORT y) { COORD coPos; @@ -241,5 +235,5 @@ VOID SetCursorType (BOOL bInsert, BOOL bVisible) cci.dwSize = bInsert ? 10 : 100; cci.bVisible = bVisible; - SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cci); } diff --git a/rosapps/cmd/misc.c b/rosapps/cmd/misc.c index b010cd9e4e2..d863ac762e4 100644 --- a/rosapps/cmd/misc.c +++ b/rosapps/cmd/misc.c @@ -48,7 +48,6 @@ TCHAR cgetchar (VOID) do { - WaitForSingleObject (hInput, INFINITE); ReadConsoleInput (hInput, &irBuffer, 1, &dwRead); if ((irBuffer.EventType == KEY_EVENT) && (irBuffer.Event.KeyEvent.bKeyDown == TRUE)) diff --git a/rosapps/cmd/where.c b/rosapps/cmd/where.c index fab018d0d0e..78ed109642a 100644 --- a/rosapps/cmd/where.c +++ b/rosapps/cmd/where.c @@ -63,7 +63,10 @@ * * 26-Feb-1999 (Eric Kohl ) * Replaced find_which() by SearchForExecutable(). - * Now files are serched with the right order of extensions. + * Now files are searched using the right extension order. + * + * 20-Apr-1999 (Eric Kohl ) + * Some minor changes and improvements. */ #include "config.h" @@ -89,25 +92,20 @@ BOOL SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) { TCHAR szPathBuffer[MAX_PATH]; - LPTSTR pszBuffer = NULL; - DWORD dwBuffer; + LPTSTR pszBuffer = NULL; + DWORD dwBuffer, len; INT n; LPTSTR p,s,f; /* load environment varable PATH into buffer */ pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE); - if (dwBuffer == 0) - { - ConErrPrintf (_T("No PATH environment variable found!\n")); - } - else if (dwBuffer > ENV_BUFFER_SIZE) + if (dwBuffer > ENV_BUFFER_SIZE) { pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR)); GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer * sizeof (TCHAR)); } - /* initialize full name buffer */ *pFullName = _T('\0'); @@ -120,9 +118,12 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) #endif /* search in current directory */ - GetCurrentDirectory (MAX_PATH, szPathBuffer); - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = GetCurrentDirectory (MAX_PATH, szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); p = szPathBuffer + _tcslen (szPathBuffer); @@ -134,7 +135,6 @@ SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) #ifdef _DEBUG DebugPrintf (_T("Testing: \'%s\'\n"), szPathBuffer); #endif -ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); if (IsValidFileName (szPathBuffer)) { @@ -165,8 +165,12 @@ ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); s = NULL; } - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = _tcslen(szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); p = szPathBuffer + _tcslen (szPathBuffer); @@ -200,9 +204,12 @@ ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); #endif /* search in current directory */ - GetCurrentDirectory (MAX_PATH, szPathBuffer); - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = GetCurrentDirectory (MAX_PATH, szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); #ifdef _DEBUG @@ -237,8 +244,12 @@ ConOutPrintf(_T("Testing: \'%s\'\n"), szPathBuffer); s = NULL; } - if (szPathBuffer[_tcslen(szPathBuffer)-1] != _T('\\')) - _tcscat (szPathBuffer, _T("\\")); + len = _tcslen(szPathBuffer); + if (szPathBuffer[len - 1] != _T('\\')) + { + szPathBuffer[len] = _T('\\'); + szPathBuffer[len + 1] = _T('\0'); + } _tcscat (szPathBuffer, pFileName); #ifdef _DEBUG