[CMD]
[reactos.git] / reactos / base / shell / cmd / filecomp.c
index 5e64e14..7cb99a7 100644 (file)
@@ -483,8 +483,9 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
        }
 
 }
- int __cdecl compare(const void *arg1,const void *arg2)
- {
+
+int __cdecl compare(const void *arg1,const void *arg2)
+{
        FileName * File1;
        FileName * File2;
        INT ret;
@@ -503,7 +504,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
        cmd_free(File1);
        cmd_free(File2);
        return ret;
- }
+}
 
 VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
 {
@@ -702,7 +703,7 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
                                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) );
@@ -711,14 +712,17 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
                        {
                                _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);
+                       }
                }
        }