https://git.reactos.org/?p=reactos.git;a=commitdiff;h=324cda08358d2e2493f7e8f097346e88b3ccd86a

commit 324cda08358d2e2493f7e8f097346e88b3ccd86a
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Tue Feb 14 20:53:48 2023 +0900
Commit:     GitHub <[email protected]>
CommitDate: Tue Feb 14 20:53:48 2023 +0900

    [SHELL32][SHELL32_APITEST] Improve CommandLineToArgvW (#5055)
    
    This PR will reduce the failures of CommandLineToArgvW testcase of 
shell32_apitest.
    - Use isspace and isblank in shell32!CommandLineToArgvW.
    - Strengthen shell32_apitest:CommandLineToArgvW testcase.
    CORE-17787
---
 dll/win32/shell32/wine/shell32_main.c              | 17 ++++++-----
 .../apitests/shell32/CommandLineToArgvW.cpp        | 35 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/dll/win32/shell32/wine/shell32_main.c 
b/dll/win32/shell32/wine/shell32_main.c
index 58e114e09e1..3ab985c0740 100644
--- a/dll/win32/shell32/wine/shell32_main.c
+++ b/dll/win32/shell32/wine/shell32_main.c
@@ -134,11 +134,11 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* 
numargs)
     else
     {
         /* The executable path ends at the next space, no matter what */
-        while (*s && *s!=' ' && *s!='\t')
+        while (*s && !isspace(*s))
             s++;
     }
     /* skip to the first argument, if any */
-    while (*s==' ' || *s=='\t')
+    while (isblank(*s))
         s++;
     if (*s)
         argc++;
@@ -147,10 +147,10 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* 
numargs)
     qcount=bcount=0;
     while (*s)
     {
-        if ((*s==' ' || *s=='\t') && qcount==0)
+        if (isblank(*s) && qcount==0)
         {
             /* skip to the next argument and count it if any */
-            while (*s==' ' || *s=='\t')
+            while (isblank(*s))
                 s++;
             if (*s)
                 argc++;
@@ -218,7 +218,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* 
numargs)
     else
     {
         /* The executable path ends at the next space, no matter what */
-        while (*d && *d!=' ' && *d!='\t')
+        while (*d && !isspace(*d))
             d++;
         s=d;
         if (*s)
@@ -227,8 +227,9 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* 
numargs)
     /* close the executable path */
     *d++=0;
     /* skip to the first argument and initialize it if any */
-    while (*s==' ' || *s=='\t')
+    while (isblank(*s))
         s++;
+
     if (!*s)
     {
         /* There are no parameters so we are all done */
@@ -242,7 +243,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* 
numargs)
     qcount=bcount=0;
     while (*s)
     {
-        if ((*s==' ' || *s=='\t') && qcount==0)
+        if (isblank(*s) && qcount==0)
         {
             /* close the argument */
             *d++=0;
@@ -251,7 +252,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* 
numargs)
             /* skip to the next one and initialize it if any */
             do {
                 s++;
-            } while (*s==' ' || *s=='\t');
+            } while (isblank(*s));
             if (*s)
                 argv[argc++]=d;
         }
diff --git a/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp 
b/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp
index 03495b602e9..72d91caae59 100644
--- a/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp
+++ b/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp
@@ -45,15 +45,50 @@ START_TEST(CommandLineToArgvW)
     DoEntry(__LINE__, L"test.exe\t", 1);
     DoEntry(__LINE__, L"test.exe\r", 1);
     DoEntry(__LINE__, L"test.exe\n", 1);
+    DoEntry(__LINE__, L"test.exe\v", 1);
+    DoEntry(__LINE__, L"test.exe\f", 1);
+    DoEntry(__LINE__, L"test.exe\u3000", 1);
     DoEntry(__LINE__, L"\"This is a test.exe\"", 1);
     DoEntry(__LINE__, L"\"This is a test.exe\" ", 1);
     DoEntry(__LINE__, L"\"This is a test.exe\"\t", 1);
     DoEntry(__LINE__, L"\"This is a test.exe\"\r", 2, L"\r");
     DoEntry(__LINE__, L"\"This is a test.exe\"\n", 2, L"\n");
+    DoEntry(__LINE__, L"\"This is a test.exe\"\v", 2, L"\v");
+    DoEntry(__LINE__, L"\"This is a test.exe\"\f", 2, L"\f");
+    DoEntry(__LINE__, L"\"This is a test.exe\"\u3000", 2, L"\u3000");
     DoEntry(__LINE__, L"test.exe a", 2, L"a");
     DoEntry(__LINE__, L"test.exe\ta", 2, L"a");
     DoEntry(__LINE__, L"test.exe\ra", 2, L"a");
     DoEntry(__LINE__, L"test.exe\na", 2, L"a");
+    DoEntry(__LINE__, L"test.exe\va", 2, L"a");
+    DoEntry(__LINE__, L"test.exe\fa", 2, L"a");
+    DoEntry(__LINE__, L"test.exe\u3000" L"a", 1);
+    DoEntry(__LINE__, L"test.exe  a", 2, L"a");
+    DoEntry(__LINE__, L"test.exe \ta", 2, L"a");
+    DoEntry(__LINE__, L"test.exe \ra", 2, L"\ra");
+    DoEntry(__LINE__, L"test.exe \na", 2, L"\na");
+    DoEntry(__LINE__, L"test.exe \va", 2, L"\va");
+    DoEntry(__LINE__, L"test.exe \fa", 2, L"\fa");
+    DoEntry(__LINE__, L"test.exe a ", 2, L"a");
+    DoEntry(__LINE__, L"test.exe a\t", 2, L"a");
+    DoEntry(__LINE__, L"test.exe a\r", 2, L"a\r");
+    DoEntry(__LINE__, L"test.exe a\n", 2, L"a\n");
+    DoEntry(__LINE__, L"test.exe a\v", 2, L"a\v");
+    DoEntry(__LINE__, L"test.exe a\f", 2, L"a\f");
+    DoEntry(__LINE__, L"test.exe \"a\" ", 2, L"a");
+    DoEntry(__LINE__, L"test.exe \"a\"\t", 2, L"a");
+    DoEntry(__LINE__, L"test.exe \"a\"\r", 2, L"a\r");
+    DoEntry(__LINE__, L"test.exe \"a\"\n", 2, L"a\n");
+    DoEntry(__LINE__, L"test.exe \"a\"\v", 2, L"a\v");
+    DoEntry(__LINE__, L"test.exe \"a\"\f", 2, L"a\f");
+    DoEntry(__LINE__, L"test.exe \u3000" L"a", 2, L"\u3000" L"a");
+    DoEntry(__LINE__, L"test.exe \"a b\"", 2, L"a b");
+    DoEntry(__LINE__, L"test.exe \"a\tb\"", 2, L"a\tb");
+    DoEntry(__LINE__, L"test.exe \"a\rb\"", 2, L"a\rb");
+    DoEntry(__LINE__, L"test.exe \"a\nb\"", 2, L"a\nb");
+    DoEntry(__LINE__, L"test.exe \"a\vb\"", 2, L"a\vb");
+    DoEntry(__LINE__, L"test.exe \"a\fb\"", 2, L"a\fb");
+    DoEntry(__LINE__, L"test.exe \"a\u3000" L"b\"", 2, L"a\u3000" L"b");
     DoEntry(__LINE__, L"test.exe a b c", 4, L"a", L"b", L"c");
     DoEntry(__LINE__, L"test.exe a b \"c", 4, L"a", L"b", L"c");
     DoEntry(__LINE__, L"test.exe \"a b\" \"c d\"", 3, L"a b", L"c d");

Reply via email to