https://git.reactos.org/?p=reactos.git;a=commitdiff;h=358e45d33a80a8db868324cf1f477c9e24408e53

commit 358e45d33a80a8db868324cf1f477c9e24408e53
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sat Aug 5 19:44:13 2023 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sat Aug 5 19:44:13 2023 +0900

    [SHELL32][SHELL32_APITEST][SDK] Implement SheRemoveQuotesA/W (#5517)
    
    - Implement SheRemoveQuotesA and SheRemoveQuotesW functions.
    - Add She testcase into shell32_apitest.
    - Add SheRemoveQuotesA/W into <undocshell.h>.
    CORE-9277
---
 dll/win32/shell32/stubs.cpp                      | 42 ++++++++----
 modules/rostests/apitests/shell32/CMakeLists.txt |  1 +
 modules/rostests/apitests/shell32/She.cpp        | 87 ++++++++++++++++++++++++
 modules/rostests/apitests/shell32/testlist.c     |  2 +
 sdk/include/reactos/undocshell.h                 |  3 +
 5 files changed, 123 insertions(+), 12 deletions(-)

diff --git a/dll/win32/shell32/stubs.cpp b/dll/win32/shell32/stubs.cpp
index 460a423206c..ec1da6daf41 100644
--- a/dll/win32/shell32/stubs.cpp
+++ b/dll/win32/shell32/stubs.cpp
@@ -440,26 +440,44 @@ SheSetCurDrive(INT iIndex)
     return 1;
 }
 
-/*
- * Unimplemented
- */
 EXTERN_C LPWSTR
 WINAPI
-SheRemoveQuotesW(LPWSTR lpInput)
+SheRemoveQuotesW(LPWSTR psz)
 {
-    FIXME("SheRemoveQuotesW() stub\n");
-    return NULL;
+    PWCHAR pch;
+
+    if (*psz == L'"')
+    {
+        for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
+        {
+            *(pch - 1) = *pch;
+        }
+
+        if (*pch == L'"')
+            *(pch - 1) = UNICODE_NULL;
+    }
+
+    return psz;
 }
 
-/*
- * Unimplemented
- */
 EXTERN_C LPSTR
 WINAPI
-SheRemoveQuotesA(LPSTR lpInput)
+SheRemoveQuotesA(LPSTR psz)
 {
-    FIXME("SheRemoveQuotesA() stub\n");
-    return NULL;
+    PCHAR pch;
+
+    if (*psz == '"')
+    {
+        for (pch = psz + 1; *pch && *pch != '"'; ++pch)
+        {
+            *(pch - 1) = *pch;
+        }
+
+        if (*pch == '"')
+            *(pch - 1) = ANSI_NULL;
+    }
+
+    return psz;
 }
 
 /*
diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt 
b/modules/rostests/apitests/shell32/CMakeLists.txt
index 797e6e5ed1c..602e25ad199 100644
--- a/modules/rostests/apitests/shell32/CMakeLists.txt
+++ b/modules/rostests/apitests/shell32/CMakeLists.txt
@@ -25,6 +25,7 @@ list(APPEND SOURCE
     SHCreateFileDataObject.cpp
     SHCreateFileExtractIconW.cpp
     SHParseDisplayName.cpp
+    She.cpp
     ShellExecCmdLine.cpp
     ShellExecuteEx.cpp
     ShellExecuteW.cpp
diff --git a/modules/rostests/apitests/shell32/She.cpp 
b/modules/rostests/apitests/shell32/She.cpp
new file mode 100644
index 00000000000..4c2c9f4e494
--- /dev/null
+++ b/modules/rostests/apitests/shell32/She.cpp
@@ -0,0 +1,87 @@
+/*
+ * PROJECT:     ReactOS api tests
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Test for She* functions
+ * COPYRIGHT:   Copyright 2023 Katayama Hirofumi MZ 
<[email protected]>
+ */
+
+#include "shelltest.h"
+#include <undocshell.h>
+
+typedef LPSTR (WINAPI *FN_SheRemoveQuotesA)(LPSTR psz);
+typedef LPWSTR (WINAPI *FN_SheRemoveQuotesW)(LPWSTR psz);
+
+static FN_SheRemoveQuotesA pSheRemoveQuotesA = NULL;
+static FN_SheRemoveQuotesW pSheRemoveQuotesW = NULL;
+
+static void test_SheRemoveQuotesA(void)
+{
+    CHAR sz0[] = "A\"Test\"";
+    CHAR sz1[] = "\"Test\"";
+    CHAR sz2[] = "\"Test\"123";
+
+    BOOL bGotException = FALSE;
+    _SEH2_TRY
+    {
+        pSheRemoveQuotesA(NULL);
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        bGotException = TRUE;
+    }
+    _SEH2_END;
+    ok_int(bGotException, TRUE);
+
+    ok_ptr(pSheRemoveQuotesA(sz0), sz0);
+    ok_str(sz0, "A\"Test\"");
+
+    ok_ptr(pSheRemoveQuotesA(sz1), sz1);
+    ok_str(sz1, "Test");
+
+    ok_ptr(pSheRemoveQuotesA(sz2), sz2);
+    ok_str(sz2, "Test");
+}
+
+static void test_SheRemoveQuotesW(void)
+{
+    WCHAR sz0[] = L"A\"Test\"";
+    WCHAR sz1[] = L"\"Test\"";
+    WCHAR sz2[] = L"\"Test\"123";
+
+    BOOL bGotException = FALSE;
+    _SEH2_TRY
+    {
+        pSheRemoveQuotesW(NULL);
+    }
+    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+    {
+        bGotException = TRUE;
+    }
+    _SEH2_END;
+    ok_int(bGotException, TRUE);
+
+    ok_ptr(pSheRemoveQuotesW(sz0), sz0);
+    ok_wstr(sz0, L"A\"Test\"");
+
+    ok_ptr(pSheRemoveQuotesW(sz1), sz1);
+    ok_wstr(sz1, L"Test");
+
+    ok_ptr(pSheRemoveQuotesW(sz2), sz2);
+    ok_wstr(sz2, L"Test");
+}
+
+START_TEST(She)
+{
+    HINSTANCE hShell32 = GetModuleHandleW(L"shell32");
+    pSheRemoveQuotesA = (FN_SheRemoveQuotesA)GetProcAddress(hShell32, 
"SheRemoveQuotesA");
+    pSheRemoveQuotesW = (FN_SheRemoveQuotesW)GetProcAddress(hShell32, 
"SheRemoveQuotesW");
+
+    if (!pSheRemoveQuotesA || !pSheRemoveQuotesW)
+    {
+        skip("SheRemoveQuotes not found");
+        return;
+    }
+
+    test_SheRemoveQuotesA();
+    test_SheRemoveQuotesW();
+}
diff --git a/modules/rostests/apitests/shell32/testlist.c 
b/modules/rostests/apitests/shell32/testlist.c
index 5522cb0b659..2d364f19770 100644
--- a/modules/rostests/apitests/shell32/testlist.c
+++ b/modules/rostests/apitests/shell32/testlist.c
@@ -26,6 +26,7 @@ extern void func_SHChangeNotify(void);
 extern void func_SHCreateDataObject(void);
 extern void func_SHCreateFileDataObject(void);
 extern void func_SHCreateFileExtractIconW(void);
+extern void func_She(void);
 extern void func_ShellExecCmdLine(void);
 extern void func_ShellExecuteEx(void);
 extern void func_ShellExecuteW(void);
@@ -60,6 +61,7 @@ const struct test winetest_testlist[] =
     { "SHCreateDataObject", func_SHCreateDataObject },
     { "SHCreateFileDataObject", func_SHCreateFileDataObject },
     { "SHCreateFileExtractIconW", func_SHCreateFileExtractIconW },
+    { "She", func_She },
     { "ShellExecCmdLine", func_ShellExecCmdLine },
     { "ShellExecuteEx", func_ShellExecuteEx },
     { "ShellExecuteW", func_ShellExecuteW },
diff --git a/sdk/include/reactos/undocshell.h b/sdk/include/reactos/undocshell.h
index 9196713ef6d..1d87844e1a9 100644
--- a/sdk/include/reactos/undocshell.h
+++ b/sdk/include/reactos/undocshell.h
@@ -653,6 +653,9 @@ BOOL WINAPI GUIDFromStringW(
     _Out_  LPGUID pguid
     );
 
+LPSTR WINAPI SheRemoveQuotesA(LPSTR psz);
+LPWSTR WINAPI SheRemoveQuotesW(LPWSTR psz);
+
 /*****************************************************************************
  * Shell32 resources
  */

Reply via email to