[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
This commit is contained in:
Katayama Hirofumi MZ 2023-08-05 19:44:13 +09:00 committed by GitHub
parent 1273bbe417
commit 358e45d33a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 123 additions and 12 deletions

View file

@ -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;
}
/*

View file

@ -25,6 +25,7 @@ list(APPEND SOURCE
SHCreateFileDataObject.cpp
SHCreateFileExtractIconW.cpp
SHParseDisplayName.cpp
She.cpp
ShellExecCmdLine.cpp
ShellExecuteEx.cpp
ShellExecuteW.cpp

View file

@ -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 <katayama.hirofumi.mz@gmail.com>
*/
#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();
}

View file

@ -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 },

View file

@ -653,6 +653,9 @@ BOOL WINAPI GUIDFromStringW(
_Out_ LPGUID pguid
);
LPSTR WINAPI SheRemoveQuotesA(LPSTR psz);
LPWSTR WINAPI SheRemoveQuotesW(LPWSTR psz);
/*****************************************************************************
* Shell32 resources
*/