msvc6 compatibility and small performance improvement in filename completion

svn path=/trunk/; revision=17819
This commit is contained in:
Royce Mitchell III 2005-09-12 16:06:53 +00:00
parent 811a8addb8
commit 5fbac4d9e6
11 changed files with 52 additions and 53 deletions

View file

@ -148,9 +148,9 @@
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
#endif
typedef NTSTATUS (STDCALL *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
typedef NTSTATUS (WINAPI *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
PVOID, ULONG, PULONG);
typedef NTSTATUS (STDCALL *NtReadVirtualMemoryProc)(HANDLE, PVOID, PVOID, ULONG, PULONG);
typedef NTSTATUS (WINAPI *NtReadVirtualMemoryProc)(HANDLE, PVOID, PVOID, ULONG, PULONG);
BOOL bExit = FALSE; /* indicates EXIT was typed */
BOOL bCanExit = TRUE; /* indicates if this shell is exitable */
@ -356,7 +356,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest)
}
else
{
INT i = 0;
UINT i = 0;
BOOL bInside = FALSE;
rest[0] = _T('\0');
full[0] = _T('\0');
@ -1392,12 +1392,10 @@ Initialize (int argc, TCHAR* argv[])
#ifdef _DEBUG
INT x;
DebugPrintf (_T("[command args:\n"));
for (x = 0; x < argc; x++)
for (i = 0; i < argc; i++)
{
DebugPrintf (_T("%d. %s\n"), x, argv[x]);
DebugPrintf (_T("%d. %s\n"), i, argv[i]);
}
DebugPrintf (_T("]\n"));
#endif

View file

@ -224,11 +224,11 @@ VOID msg_pause (VOID);
/* Prototypes for FILECOMP.C */
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
VOID CompleteFilename (LPTSTR, INT);
VOID CompleteFilename (LPTSTR, UINT);
INT ShowCompletionMatches (LPTSTR, INT);
#endif
#ifdef FEATURE_4NT_FILENAME_COMPLETION
VOID CompleteFilename (LPTSTR, BOOL, LPTSTR, INT);
VOID CompleteFilename (LPTSTR, BOOL, LPTSTR, UINT);
#endif

View file

@ -138,6 +138,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
WORD wLastKey = 0;
TCHAR ch;
BOOL bContinue=FALSE;/*is TRUE the second case will not be executed*/
TCHAR szPath[MAX_PATH];
/* get screen size */
GetScreenSize (&maxx, &maxy);
@ -366,8 +367,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
/* used to later see if we went down to the next line */
tempscreen = charcount;
TCHAR szPath[MAX_PATH];
szPath[0]=_T('\0');
szPath[0]=_T('\0');
/* str is the whole things that is on the current line
that is and and out. arg 2 is weather it goes back
@ -404,7 +404,7 @@ VOID ReadCommand (LPTSTR str, INT maxlen)
if(((charcount + orgx) / maxx) + orgy > maxy - 1)
orgy += maxy - ((charcount + orgx) / maxx + orgy + 1);
}
SetCursorXY((orgx + current) % maxx, orgy + (orgx + current) / maxx);
SetCursorXY((short)(((int)orgx + current) % maxx), (short)((int)orgy + ((int)orgx + current) / maxx));
GetCursorXY(&curx, &cury);
#endif

View file

@ -94,12 +94,12 @@ INT CommandColor (LPTSTR first, LPTSTR rest)
}
else if ( (_tcscmp(&rest[0], _T("a")) >=0 ) && (_tcscmp(&rest[0], _T("f")) <=0 ) )
{
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10) - _T('a') );
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10 - _T('a')) );
return 0;
}
else if ( (_tcscmp(&rest[0], _T("A")) >=0 ) && (_tcscmp(&rest[0], _T("F")) <=0 ) )
{
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10) - _T('A') );
SetConsoleTextAttribute (hConsole, (WORD) (rest[0] + 10 - _T('A')) );
return 0;
}
ConErrResPuts(STRING_COLOR_ERROR2);

View file

@ -130,7 +130,7 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA* f)
HANDLE file;
DWORD temp;
LONG BufferSize = 65536;
#define BufferSize 65536
BYTE buffer[BufferSize];
LONGLONG i;
LARGE_INTEGER FileSize;
@ -150,7 +150,7 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA* f)
WriteFile (file, buffer, BufferSize, &temp, NULL);
ConOutPrintf (_T("%I64d%% %s\r"),(i * (LONGLONG)100)/FileSize.QuadPart,szDeleteWipe);
}
WriteFile (file, buffer, FileSize.QuadPart - i, &temp, NULL);
WriteFile (file, buffer, (DWORD)(FileSize.QuadPart - i), &temp, NULL);
ConOutPrintf (_T("100%% %s\n"),szDeleteWipe);
CloseHandle (file);
}

View file

@ -199,8 +199,8 @@ typedef struct _DIRFINDLISTNODE
} DIRFINDLISTNODE, *PDIRFINDLISTNODE;
typedef BOOL STDCALL
(*PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
typedef BOOL
(WINAPI *PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
/* Globally save the # of dirs, files and bytes,
@ -1294,7 +1294,7 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
{
/* Calculate the lines that will be printed */
// iLines = ceil((float)dwCount/(float)iColumns);
iLines = dwCount / iColumns;
iLines = (USHORT)(dwCount / iColumns);
for (i = 0;i < iLines;i++)
{
@ -1982,22 +1982,25 @@ INT CommandDir(LPTSTR first, LPTSTR rest)
/* <Debug :>
Uncomment this to show the final state of switch flags*/
#ifdef _DEBUG
ConOutPrintf("Attributes mask/value %x/%x\n",stFlags.stAttribs.dwAttribMask,stFlags.stAttribs.dwAttribVal );
ConOutPrintf("(B) Bare format : %i\n", stFlags.bBareFormat );
ConOutPrintf("(C) Thousand : %i\n", stFlags.bTSeperator );
ConOutPrintf("(W) Wide list : %i\n", stFlags.bWideList );
ConOutPrintf("(D) Wide list sort by column : %i\n", stFlags.bWideListColSort );
ConOutPrintf("(L) Lowercase : %i\n", stFlags.bLowerCase );
ConOutPrintf("(N) New : %i\n", stFlags.bNewLongList );
ConOutPrintf("(O) Order : %i\n", stFlags.stOrderBy.sCriteriaCount );
for (i =0;i<stFlags.stOrderBy.sCriteriaCount;i++)
ConOutPrintf(" Order Criteria [%i]: %i (Reversed: %i)\n",i, stFlags.stOrderBy.eCriteria[i], stFlags.stOrderBy.bCriteriaRev[i] );
ConOutPrintf("(P) Pause : %i\n", stFlags.bPause );
ConOutPrintf("(Q) Owner : %i\n", stFlags.bUser );
ConOutPrintf("(S) Recursive : %i\n", stFlags.bRecursive );
ConOutPrintf("(T) Time field : %i\n", stFlags.stTimeField.eTimeField );
ConOutPrintf("(X) Short names : %i\n", stFlags.bShortName );
ConOutPrintf("Parameter : %s\n", param );
{
int i;
ConOutPrintf(_T("Attributes mask/value %x/%x\n"),stFlags.stAttribs.dwAttribMask,stFlags.stAttribs.dwAttribVal );
ConOutPrintf(_T("(B) Bare format : %i\n"), stFlags.bBareFormat );
ConOutPrintf(_T("(C) Thousand : %i\n"), stFlags.bTSeperator );
ConOutPrintf(_T("(W) Wide list : %i\n"), stFlags.bWideList );
ConOutPrintf(_T("(D) Wide list sort by column : %i\n"), stFlags.bWideListColSort );
ConOutPrintf(_T("(L) Lowercase : %i\n"), stFlags.bLowerCase );
ConOutPrintf(_T("(N) New : %i\n"), stFlags.bNewLongList );
ConOutPrintf(_T("(O) Order : %i\n"), stFlags.stOrderBy.sCriteriaCount );
for (i =0;i<stFlags.stOrderBy.sCriteriaCount;i++)
ConOutPrintf(_T(" Order Criteria [%i]: %i (Reversed: %i)\n"),i, stFlags.stOrderBy.eCriteria[i], stFlags.stOrderBy.bCriteriaRev[i] );
ConOutPrintf(_T("(P) Pause : %i\n"), stFlags.bPause );
ConOutPrintf(_T("(Q) Owner : %i\n"), stFlags.bUser );
ConOutPrintf(_T("(S) Recursive : %i\n"), stFlags.bRecursive );
ConOutPrintf(_T("(T) Time field : %i\n"), stFlags.stTimeField.eTimeField );
ConOutPrintf(_T("(X) Short names : %i\n"), stFlags.bShortName );
ConOutPrintf(_T("Parameter : %s\n"), param );
}
#endif
/* print the header */

View file

@ -33,7 +33,7 @@
INT CommandEcho (LPTSTR cmd, LPTSTR param)
{
TCHAR szMsg[RC_STRING_MAX_SIZE];
INT i = 0;
UINT i = 0;
#ifdef _DEBUG
DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param);

View file

@ -25,7 +25,7 @@
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
VOID CompleteFilename (LPTSTR str, INT charcount)
VOID CompleteFilename (LPTSTR str, UINT charcount)
{
WIN32_FIND_DATA file;
HANDLE hFile;
@ -376,7 +376,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
/* number of quotes in the string */
INT nQuotes = 0;
/* used in for loops */
INT i;
UINT i;
/* Char number to break the string at */
INT PBreak = 0;
INT SBreak = 0;
@ -509,7 +509,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
return ret;
}
VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
{
/* Length of string before we complete it */
INT StartLength;
@ -534,16 +534,17 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
/* Number of files */
INT FileListSize = 0;
/* Used for loops */
INT i;
UINT i;
/* Editable string of what was passed in */
TCHAR str[MAX_PATH];
/* Keeps track of what element was last selected */
static INT Sel;
BOOL NeededQuote = FALSE;
strOut[0] = _T('\0');
BOOL ShowAll = TRUE;
TCHAR * line = strIN;
strOut[0] = _T('\0');
while (_istspace (*line))
line++;
if(!_tcsncmp (line, _T("rd "), 3) || !_tcsncmp (line, _T("cd "), 3))
@ -708,14 +709,9 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
/* insert the quoation and move things around */
if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
{
/* add another char or you will lose a null char ending */
_tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1);
for(i = _tcslen(szPrefix) - 1; i > LastSpace; i--)
{
szPrefix[i] = szPrefix[i - 1];
}
memmove ( &szPrefix[LastSpace+1], &szPrefix[LastSpace], (_tcslen(szPrefix)-LastSpace+1) * sizeof(TCHAR) );
if(LastSpace + 1 == _tcslen(szPrefix))
if((UINT)(LastSpace + 1) == _tcslen(szPrefix))
{
_tcscat(szPrefix,_T("\""));
}

View file

@ -193,8 +193,8 @@ VOID del(LPHIST_ENTRY item)
if (item==NULL || item==Top || item==Bottom)
{
#ifdef _DEBUG
DebugPrintf(_T("del in " __FILE__ ": retrning\n"
"item is 0x%08x (Bottom is0x%08x)\n"),
DebugPrintf(_T("del in ") _T(__FILE__) _T(": retrning\n")
_T("item is 0x%08x (Bottom is0x%08x)\n"),
item, Bottom);
#endif
return;

View file

@ -276,7 +276,7 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
TCHAR * tmpPath;
TCHAR szCurrent[MAX_PATH];
TCHAR szMsg[RC_STRING_MAX_SIZE];
INT i;
UINT i;
/* Filter out special cases first */

View file

@ -1,6 +1,5 @@
#include <windows.h>
#include <winnt.h>
#include <winternl.h>
#include <shellapi.h>
#include <tchar.h>
@ -14,6 +13,9 @@
#include <math.h>
#include <time.h>
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
#include "cmd.h"
#include "config.h"
#include "batch.h"