Fixed a bug in tab complete when there was only one " and it was in the middle or end of the string. Also changed used more optimized code removing " and removed all _tcsncmp(..,..,1).

svn path=/trunk/; revision=17591
This commit is contained in:
Brandon Turner 2005-08-29 18:25:54 +00:00
parent 13115c5ce3
commit d261fc0b2b

View file

@ -396,7 +396,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
nQuotes++; nQuotes++;
/* Find the prefix and suffix */ /* Find the prefix and suffix */
if(nQuotes % 2 && nQuotes) if(nQuotes % 2 && nQuotes > 1)
{ {
/* Odd number of quotes. Just start from the last " */ /* Odd number of quotes. Just start from the last " */
/* THis is the way MS does it, and is an easy way out */ /* THis is the way MS does it, and is an easy way out */
@ -468,7 +468,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
bInside = !bInside; bInside = !bInside;
if(str[i] == _T(' ') && !bInside) if(str[i] == _T(' ') && !bInside)
SBreak = i; SBreak = i;
if((!_tcsncmp(&str[i], _T(" "),1) || !_tcsncmp(&str[i], _T("\\"),1)) && !bInside) if((str[i] == _T(' ') || str[i] == _T('\\')) && !bInside)
PBreak = i; PBreak = i;
} }
@ -477,7 +477,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
_tcscpy(szSuffix,&strIN[SBreak]); _tcscpy(szSuffix,&strIN[SBreak]);
strIN[PBreak] = _T('\0'); strIN[PBreak] = _T('\0');
_tcscpy(szPrefix,strIN); _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 /* need to remove the " right before a \ at the end to
allow the next stuff to stay inside one set of quotes allow the next stuff to stay inside one set of quotes
@ -535,7 +535,6 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
INT FileListSize = 0; INT FileListSize = 0;
/* Used for loops */ /* Used for loops */
INT i; INT i;
INT ii;
/* Editable string of what was passed in */ /* Editable string of what was passed in */
TCHAR str[MAX_PATH]; TCHAR str[MAX_PATH];
/* Keeps track of what element was last selected */ /* Keeps track of what element was last selected */
@ -573,13 +572,12 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
no quote at the END of the full name */ no quote at the END of the full name */
FindPrefixAndSuffix(str,szPrefix,szBaseWord); FindPrefixAndSuffix(str,szPrefix,szBaseWord);
/* Strip quotes */ /* Strip quotes */
for(i = 0; i < _tcslen(szBaseWord); i++) while(i < _tcslen(szBaseWord)+1)
{ {
if(!_tcsncmp(&szBaseWord[i], _T("\""),1)) if(szBaseWord[i] == _T('\"'))
{ memmove(&szBaseWord[i],&szBaseWord[i + 1], _tcslen(&szBaseWord[i]) * sizeof(TCHAR));
for(ii = i; ii < (_tcslen(szBaseWord)); ii++) else
szBaseWord[ii] = szBaseWord[ii + 1]; i++;
}
} }
/* clear it out */ /* clear it out */
@ -691,8 +689,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
LastSpace = i; LastSpace = i;
} }
/* insert the space and move things around */ /* insert the quoation and move things around */
if(_tcsncmp(&szPrefix[LastSpace + 1],_T("\""),1) && LastSpace != -1) if(szPrefix[LastSpace + 1] == _T('\"') && LastSpace != -1)
{ {
/* add another char or you will lose a null char ending */ /* add another char or you will lose a null char ending */
_tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1); _tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1);