#ifdef FEATURE_UNIX_FILENAME_COMPLETION
-VOID CompleteFilename (LPTSTR str, INT charcount)
+VOID CompleteFilename (LPTSTR str, UINT charcount)
{
WIN32_FIND_DATA file;
HANDLE hFile;
if(!perfectmatch)
{
-#ifdef __REACTOS__
- Beep (440, 50);
-#else
MessageBeep (-1);
-#endif
}
}
else
}
}
-#ifdef __REACTOS__
- Beep (440, 50);
-#else
MessageBeep (-1);
-#endif
}
}
else
{
/* no match found */
-#ifdef __REACTOS__
- Beep (440, 50);
-#else
MessageBeep (-1);
-#endif
return FALSE;
}
/* 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;
nQuotes++;
/* Find the prefix and suffix */
- if(nQuotes % 2 && nQuotes)
+ if(nQuotes % 2 && nQuotes > 1)
{
/* Odd number of quotes. Just start from the last " */
/* THis is the way MS does it, and is an easy way out */
bInside = !bInside;
if(str[i] == _T(' ') && !bInside)
SBreak = i;
- if((!_tcsncmp(&str[i], _T(" "),1) || !_tcsncmp(&str[i], _T("\\"),1)) && !bInside)
+ if((str[i] == _T(' ') || str[i] == _T('\\')) && !bInside)
PBreak = i;
}
_tcscpy(szSuffix,&strIN[SBreak]);
strIN[PBreak] = _T('\0');
_tcscpy(szPrefix,strIN);
- if(!_tcsncmp(&szPrefix[_tcslen(szPrefix) - 2],_T("\""),1))
+ if(szPrefix[_tcslen(szPrefix) - 2] == _T('\"'))
{
/* need to remove the " right before a \ at the end to
allow the next stuff to stay inside one set of quotes
}
}
- int compare(const void *arg1,const void *arg2)
+ int __cdecl compare(const void *arg1,const void *arg2)
{
FileName * File1;
FileName * File2;
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;
/* Number of files */
INT FileListSize = 0;
/* Used for loops */
- INT i;
- INT ii;
+ 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;
+ BOOL ShowAll = TRUE;
+ TCHAR * line = strIN;
+
strOut[0] = _T('\0');
+ while (_istspace (*line))
+ line++;
+ if(!_tcsnicmp (line, _T("rd "), 3) || !_tcsnicmp (line, _T("cd "), 3))
+ ShowAll = FALSE;
+
/* Copy the string, str can be edited and orginal should not be */
_tcscpy(str,strIN);
_tcscpy(szOrginal,strIN);
no quote at the END of the full name */
FindPrefixAndSuffix(str,szPrefix,szBaseWord);
/* Strip quotes */
- for(i = 0; i < _tcslen(szBaseWord); i++)
+ for(i = 0; i < _tcslen(szBaseWord); )
{
- if(!_tcsncmp(&szBaseWord[i], _T("\""),1))
- {
- for(ii = i; ii < (_tcslen(szBaseWord)); ii++)
- szBaseWord[ii] = szBaseWord[ii + 1];
- }
+ if(szBaseWord[i] == _T('\"'))
+ memmove(&szBaseWord[i],&szBaseWord[i + 1], _tcslen(&szBaseWord[i]) * sizeof(TCHAR));
+ else
+ i++;
}
/* clear it out */
if(!_tcscmp (file.cFileName, _T(".")) ||
!_tcscmp (file.cFileName, _T("..")))
continue;
+
+ /* Don't show files when they are doing 'cd' or 'rd' */
+ if(!ShowAll)
+ {
+ DWORD attr = GetFileAttributes (file.cFileName);
+ if(attr != 0xFFFFFFFF && (!(attr & FILE_ATTRIBUTE_DIRECTORY)))
+ continue;
+ }
+
/* Add the file to the list of files */
if(FileList == NULL)
{
}while(FindNextFile(hFile,&file));
-
+ /* Check the size of the list to see if we
+ found any matches */
+ if(FileListSize == 0)
+ {
+ _tcscpy(strOut,szOrginal);
+ CloseHandle(hFile);
+ if(FileList != NULL)
+ free(FileList);
+ return;
+
+ }
/* Sort the files */
qsort(FileList,FileListSize,sizeof(FileName), compare);
LastSpace = i;
}
- /* insert the space and move things around */
- if(_tcsncmp(&szPrefix[LastSpace + 1],_T("\""),1) && LastSpace != -1)
+ /* 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("\""));
}