/* String that is to be examined */
TCHAR str[MAX_PATH];
/* temp pointers to used to find needed parts */
- TCHAR * szSearch;
+ TCHAR * szSearch;
TCHAR * szSearch1;
TCHAR * szSearch2;
TCHAR * szSearch3;
/* when phrasing a string, this tells weather
you are inside quotes ot not. */
BOOL bInside = FALSE;
-
+
szPrefix[0] = _T('\0');
szSuffix[0] = _T('\0');
else
szSearch = szSearch1;
/* Move one char past */
- szSearch++;
+ szSearch++;
szSearch[0] = _T('\0');
_tcscpy(szPrefix,str);
return;
-
+
}
if(!_tcschr(str, _T(' ')))
/* No spaces, everything goes to Suffix */
_tcscpy(szSuffix,str);
/* look for a slash just in case */
- szSearch = _tcsrchr(str, _T('\\'));
+ szSearch = _tcsrchr(str, _T('\\'));
if(szSearch)
{
- szSearch++;
+ szSearch++;
szSearch[0] = _T('\0');
_tcscpy(szPrefix,str);
}
szSearch = szSearch3;
else
szSearch = szSearch1;
- szSearch++;
+ szSearch++;
szSearch[0] = _T('\0');
- _tcscpy(szPrefix,str);
+ _tcscpy(szPrefix,str);
return;
}
-
- /* All else fails and there is a lot of quotes, spaces and |
+
+ /* All else fails and there is a lot of quotes, spaces and |
Then we search through and find the last space or \ that is
not inside a quotes */
for(i = 0; i < _tcslen(str); i++)
}
SBreak++;
PBreak++;
- _tcscpy(szSuffix,&strIN[SBreak]);
+ _tcscpy(szSuffix,&strIN[SBreak]);
strIN[PBreak] = _T('\0');
_tcscpy(szPrefix,strIN);
if (szPrefix[_tcslen(szPrefix) - 2] == _T('\"') &&
}
}
- int __cdecl compare(const void *arg1,const void *arg2)
- {
+
+int __cdecl compare(const void *arg1,const void *arg2)
+{
FileName * File1;
FileName * File2;
INT ret;
cmd_free(File1);
cmd_free(File2);
return ret;
- }
+}
VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
{
static INT Sel;
BOOL NeededQuote = FALSE;
BOOL ShowAll = TRUE;
- TCHAR * line = strIN;
+ TCHAR * line = strIN;
strOut[0] = _T('\0');
while (_istspace (*line))
- line++;
+ line++;
if(!_tcsnicmp (line, _T("rd "), 3) || !_tcsnicmp (line, _T("cd "), 3))
ShowAll = FALSE;
if(!_tcscmp (file.cFileName, _T(".")) ||
!_tcscmp (file.cFileName, _T("..")))
continue;
-
+
/* Don't show files when they are doing 'cd' or 'rd' */
if(!ShowAll &&
file.dwFileAttributes != 0xFFFFFFFF &&
/* Add the file to the list of files */
FileList = cmd_realloc(FileList, ++FileListSize * sizeof(FileName));
-
- if(FileList == NULL)
+
+ if(FileList == NULL)
{
/* Assemble the orginal string and return */
_tcscpy(strOut,szOrginal);
}
/* Copies the file name into the struct */
_tcscpy(FileList[FileListSize-1].Name,file.cFileName);
-
+
} while(FindNextFile(hFile,&file));
FindClose(hFile);
if(FileListSize == 0)
{
_tcscpy(strOut,szOrginal);
- if(FileList != NULL)
+ if(FileList != NULL)
cmd_free(FileList);
return;
Sel = 0;
}
- /* nothing found that matched last time
+ /* nothing found that matched last time
so return the first thing in the list */
strOut[0] = _T('\0');
-
+
/* space in the name */
if(_tcschr(FileList[Sel].Name, _T(' ')))
{
LastSpace = i;
}
- /* insert the quoation and move things around */
+ /* insert the quotation and move things around */
if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
{
memmove ( &szPrefix[LastSpace+1], &szPrefix[LastSpace], (_tcslen(szPrefix)-LastSpace+1) * sizeof(TCHAR) );
-
+
if((UINT)(LastSpace + 1) == _tcslen(szPrefix))
{
_tcscat(szPrefix,_T("\""));
}
- szPrefix[LastSpace + 1] = _T('\"');
+ szPrefix[LastSpace + 1] = _T('\"');
}
else if(LastSpace == -1)
{
- _tcscpy(szBaseWord,_T("\""));
- _tcscat(szBaseWord,szPrefix);
- _tcscpy(szPrefix,szBaseWord);
-
+ /* Add quotation only if none exists already */
+ if (szPrefix[0] != _T('\"'))
+ {
+ _tcscpy(szBaseWord,_T("\""));
+ _tcscat(szBaseWord,szPrefix);
+ _tcscpy(szPrefix,szBaseWord);
+ }
}
}
_tcscpy(LastReturned,strOut);
EndLength = _tcslen(strOut);
DiffLength = EndLength - StartLength;
- if(FileList != NULL)
+ if(FileList != NULL)
cmd_free(FileList);
-
+
}
#endif