[CMD]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 14 Apr 2012 22:22:20 +0000 (22:22 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 14 Apr 2012 22:22:20 +0000 (22:22 +0000)
Add quotes to autocompleted names, when certain characters are present, not only spaces. Not sure if that's really all, but should be the most common.

svn path=/trunk/; revision=56350

reactos/base/shell/cmd/filecomp.c

index bb480a6..c4c2e04 100644 (file)
@@ -506,6 +506,41 @@ int __cdecl compare(const void *arg1,const void *arg2)
        return ret;
 }
 
+BOOL
+FileNameContainsSpecialCharacters(LPTSTR pszFileName)
+{
+    TCHAR chr;
+
+    while ((chr = *pszFileName++) != _T('\0'))
+    {
+        if ((chr == _T(' ')) ||
+            (chr == _T('!')) ||
+            (chr == _T('%')) ||
+            (chr == _T('&')) ||
+            (chr == _T('(')) ||
+            (chr == _T(')')) ||
+            (chr == _T('{')) ||
+            (chr == _T('}')) ||
+            (chr == _T('[')) ||
+            (chr == _T(']')) ||
+            (chr == _T('=')) ||
+            (chr == _T('\'')) ||
+            (chr == _T('`')) ||
+            (chr == _T(',')) ||
+            (chr == _T(';')) ||
+            (chr == _T('^')) ||
+            (chr == _T('~')) ||
+            (chr == _T('+')) ||
+            (chr == 0xB4)) // 'ยด'
+        {
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+
 VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
 {
        /* Length of string before we complete it */
@@ -695,8 +730,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
           so return the first thing in the list */
        strOut[0] = _T('\0');
 
-       /* space in the name */
-       if(_tcschr(FileList[Sel].Name, _T(' ')))
+       /* Special character in the name */
+       if (FileNameContainsSpecialCharacters(FileList[Sel].Name))
        {
                INT LastSpace;
                BOOL bInside;