You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-12-15 08:03:15 -08:00
Rebase against ea9253d6d3c9bb60d98b0d917292fc0b4babb3dd.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
From 29f88a1e1278d0ffec52d4463b3d743765fc1ad2 Mon Sep 17 00:00:00 2001
|
||||
From d728af2b7217357b79716b0f25d457071c7e52ae Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Wed, 16 Aug 2017 02:45:23 +0200
|
||||
Subject: [PATCH 1/2] kernelbase: Add semi-stub for PathCchCombineEx.
|
||||
Subject: [PATCH] kernelbase: Add semi-stub for PathCchCombineEx.
|
||||
|
||||
---
|
||||
.../api-ms-win-core-path-l1-1-0.spec | 2 +-
|
||||
@@ -11,20 +11,20 @@ Subject: [PATCH 1/2] kernelbase: Add semi-stub for PathCchCombineEx.
|
||||
4 files changed, 32 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
|
||||
index 61eb220..8c720ee 100644
|
||||
index 6896e4a8d4..5299b42c91 100644
|
||||
--- a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
|
||||
+++ b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
|
||||
@@ -8,7 +8,7 @@
|
||||
@ stub PathCchCanonicalize
|
||||
@ stub PathCchCanonicalizeEx
|
||||
@ stdcall PathCchCanonicalize(ptr long wstr) kernelbase.PathCchCanonicalize
|
||||
@ stdcall PathCchCanonicalizeEx(ptr long wstr long) kernelbase.PathCchCanonicalizeEx
|
||||
@ stub PathCchCombine
|
||||
-@ stub PathCchCombineEx
|
||||
+@ stdcall PathCchCombineEx(ptr long ptr ptr long) kernelbase.PathCchCombineEx
|
||||
@ stdcall PathCchFindExtension(wstr long ptr) kernelbase.PathCchFindExtension
|
||||
@ stdcall PathCchIsRoot(wstr) kernelbase.PathCchIsRoot
|
||||
@ stub PathCchRemoveBackslash
|
||||
@ stdcall PathCchRemoveBackslash(wstr long) kernelbase.PathCchRemoveBackslash
|
||||
diff --git a/dlls/kernelbase/Makefile.in b/dlls/kernelbase/Makefile.in
|
||||
index a7db45e..78c19bd 100644
|
||||
index a7db45e4c1..78c19bd2a1 100644
|
||||
--- a/dlls/kernelbase/Makefile.in
|
||||
+++ b/dlls/kernelbase/Makefile.in
|
||||
@@ -1,4 +1,6 @@
|
||||
@@ -36,20 +36,20 @@ index a7db45e..78c19bd 100644
|
||||
C_SRCS = \
|
||||
main.c \
|
||||
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
|
||||
index ffb5a95..53d45c4 100644
|
||||
index 752d489fba..0f6637cdf2 100644
|
||||
--- a/dlls/kernelbase/kernelbase.spec
|
||||
+++ b/dlls/kernelbase/kernelbase.spec
|
||||
@@ -1037,7 +1037,7 @@
|
||||
# @ stub PathCchCanonicalize
|
||||
# @ stub PathCchCanonicalizeEx
|
||||
@ stdcall PathCchCanonicalize(ptr long wstr)
|
||||
@ stdcall PathCchCanonicalizeEx(ptr long wstr long)
|
||||
# @ stub PathCchCombine
|
||||
-# @ stub PathCchCombineEx
|
||||
+@ stdcall PathCchCombineEx(ptr long ptr ptr long)
|
||||
@ stdcall PathCchFindExtension(wstr long ptr)
|
||||
@ stdcall PathCchIsRoot(wstr)
|
||||
# @ stub PathCchRemoveBackslash
|
||||
@ stdcall PathCchRemoveBackslash(wstr long)
|
||||
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
|
||||
index 75faf0b..047149e 100644
|
||||
index cc15d1c097..ed1ca37280 100644
|
||||
--- a/dlls/kernelbase/path.c
|
||||
+++ b/dlls/kernelbase/path.c
|
||||
@@ -22,6 +22,7 @@
|
||||
@@ -60,7 +60,7 @@ index 75faf0b..047149e 100644
|
||||
#include "strsafe.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
@@ -419,3 +420,29 @@ BOOL WINAPI PathIsUNCEx(const WCHAR *path, const WCHAR **server)
|
||||
@@ -737,3 +738,29 @@ BOOL WINAPI PathIsUNCEx(const WCHAR *path, const WCHAR **server)
|
||||
if (server) *server = result;
|
||||
return result ? TRUE : FALSE;
|
||||
}
|
||||
@@ -91,5 +91,5 @@ index 75faf0b..047149e 100644
|
||||
+}
|
||||
+
|
||||
--
|
||||
1.9.1
|
||||
2.14.1
|
||||
|
||||
|
||||
@@ -1,258 +0,0 @@
|
||||
From 1971ae905df4731f0f3f8b3e27329fff1a0c7b92 Mon Sep 17 00:00:00 2001
|
||||
From: Julien Schueller <schueller@phimeca.com>
|
||||
Date: Wed, 4 Jul 2018 22:35:16 +0200
|
||||
Subject: [PATCH 2/2] kernelbase: Implement
|
||||
PathCchRemoveBackslash()/PathCchRemoveBackslashEx().
|
||||
|
||||
---
|
||||
.../api-ms-win-core-path-l1-1-0.spec | 4 +-
|
||||
dlls/kernelbase/kernelbase.spec | 4 +-
|
||||
dlls/kernelbase/path.c | 31 +++++
|
||||
dlls/kernelbase/tests/path.c | 129 +++++++++++++++++++++
|
||||
include/pathcch.h | 2 +
|
||||
5 files changed, 166 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
|
||||
index 8c720ee..418ed61 100644
|
||||
--- a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
|
||||
+++ b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec
|
||||
@@ -11,8 +11,8 @@
|
||||
@ stdcall PathCchCombineEx(ptr long ptr ptr long) kernelbase.PathCchCombineEx
|
||||
@ stdcall PathCchFindExtension(wstr long ptr) kernelbase.PathCchFindExtension
|
||||
@ stdcall PathCchIsRoot(wstr) kernelbase.PathCchIsRoot
|
||||
-@ stub PathCchRemoveBackslash
|
||||
-@ stub PathCchRemoveBackslashEx
|
||||
+@ stdcall PathCchRemoveBackslash(wstr long) kernelbase.PathCchRemoveBackslash
|
||||
+@ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr) kernelbase.PathCchRemoveBackslashEx
|
||||
@ stdcall PathCchRemoveExtension(wstr long) kernelbase.PathCchRemoveExtension
|
||||
@ stub PathCchRemoveFileSpec
|
||||
@ stdcall PathCchRenameExtension(wstr long wstr) kernelbase.PathCchRenameExtension
|
||||
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
|
||||
index 53d45c4..a568627 100644
|
||||
--- a/dlls/kernelbase/kernelbase.spec
|
||||
+++ b/dlls/kernelbase/kernelbase.spec
|
||||
@@ -1040,8 +1040,8 @@
|
||||
@ stdcall PathCchCombineEx(ptr long ptr ptr long)
|
||||
@ stdcall PathCchFindExtension(wstr long ptr)
|
||||
@ stdcall PathCchIsRoot(wstr)
|
||||
-# @ stub PathCchRemoveBackslash
|
||||
-# @ stub PathCchRemoveBackslashEx
|
||||
+@ stdcall PathCchRemoveBackslash(wstr long)
|
||||
+@ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr)
|
||||
@ stdcall PathCchRemoveExtension(wstr long)
|
||||
# @ stub PathCchRemoveFileSpec
|
||||
@ stdcall PathCchRenameExtension(wstr long wstr)
|
||||
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
|
||||
index 047149e..a413e94 100644
|
||||
--- a/dlls/kernelbase/path.c
|
||||
+++ b/dlls/kernelbase/path.c
|
||||
@@ -446,3 +446,34 @@ HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, con
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
+HRESULT WINAPI PathCchRemoveBackslash(WCHAR *path, SIZE_T size)
|
||||
+{
|
||||
+ return PathCchRemoveBackslashEx(path, size, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T size, WCHAR **endptr, SIZE_T *remaining)
|
||||
+{
|
||||
+ BOOL needs_trim;
|
||||
+ SIZE_T length;
|
||||
+
|
||||
+ TRACE("%s, %lu, %p, %p\n", debugstr_w(path), size, endptr, remaining);
|
||||
+
|
||||
+ if (!path) return E_INVALIDARG;
|
||||
+ length = strlenW(path);
|
||||
+ needs_trim = size && length && path[length - 1] == '\\';
|
||||
+
|
||||
+ if (needs_trim && (length > 1) && path[length - 2] == ':')
|
||||
+ needs_trim = 0;
|
||||
+
|
||||
+ if (needs_trim)
|
||||
+ {
|
||||
+ path[length - 1] = 0;
|
||||
+ --length;
|
||||
+ }
|
||||
+
|
||||
+ if (endptr) *endptr = path + length;
|
||||
+ if (remaining) *remaining = size - length;
|
||||
+
|
||||
+ return needs_trim ? S_OK : S_FALSE;
|
||||
+}
|
||||
+
|
||||
diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c
|
||||
index 2edd49b..97bf7dd 100644
|
||||
--- a/dlls/kernelbase/tests/path.c
|
||||
+++ b/dlls/kernelbase/tests/path.c
|
||||
@@ -33,6 +33,8 @@
|
||||
HRESULT (WINAPI *pPathCchAddBackslash)(WCHAR *out, SIZE_T size);
|
||||
HRESULT (WINAPI *pPathCchAddBackslashEx)(WCHAR *out, SIZE_T size, WCHAR **endptr, SIZE_T *remaining);
|
||||
HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *extension);
|
||||
+HRESULT (WINAPI *pPathCchRemoveBackslash)(WCHAR *out, SIZE_T size);
|
||||
+HRESULT (WINAPI *pPathCchRemoveBackslashEx)(WCHAR *out, SIZE_T size, WCHAR **endptr, SIZE_T *remaining);
|
||||
HRESULT (WINAPI *pPathCchCombineEx)(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags);
|
||||
HRESULT (WINAPI *pPathCchFindExtension)(const WCHAR *path, SIZE_T size, const WCHAR **extension);
|
||||
BOOL (WINAPI *pPathCchIsRoot)(const WCHAR *path);
|
||||
@@ -1097,6 +1099,127 @@ static void test_PathIsUNCEx(void)
|
||||
}
|
||||
}
|
||||
|
||||
+struct removebackslash_test
|
||||
+{
|
||||
+ const char *path;
|
||||
+ const char *result;
|
||||
+ HRESULT hr;
|
||||
+ SIZE_T size;
|
||||
+ SIZE_T remaining;
|
||||
+};
|
||||
+
|
||||
+static const struct removebackslash_test removebackslash_tests[] =
|
||||
+{
|
||||
+ { "C:\\", "C:\\", S_FALSE, MAX_PATH, MAX_PATH - 3 },
|
||||
+ { "a.txt\\", "a.txt", S_OK, MAX_PATH, MAX_PATH - 5 },
|
||||
+ { "a/b\\", "a/b", S_OK, MAX_PATH, MAX_PATH - 3 },
|
||||
+ { "C:\\temp\\wine.txt", "C:\\temp\\wine.txt", S_FALSE, MAX_PATH, MAX_PATH - 16 },
|
||||
+};
|
||||
+
|
||||
+static void test_PathCchRemoveBackslash(void)
|
||||
+{
|
||||
+ WCHAR pathW[MAX_PATH];
|
||||
+ unsigned int i;
|
||||
+ HRESULT hr;
|
||||
+
|
||||
+ if (!pPathCchRemoveBackslash)
|
||||
+ {
|
||||
+ win_skip("PathCchRemoveBackslash() is not available.\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ pathW[0] = 0;
|
||||
+ hr = pPathCchRemoveBackslash(0, 0);
|
||||
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
||||
+ ok(pathW[0] == 0, "Unexpected path.\n");
|
||||
+
|
||||
+ pathW[0] = 0;
|
||||
+ hr = pPathCchRemoveBackslash(pathW, 1);
|
||||
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
|
||||
+ ok(pathW[0] == 0, "Unexpected path.\n");
|
||||
+
|
||||
+ pathW[0] = 0;
|
||||
+ hr = pPathCchRemoveBackslash(pathW, 2);
|
||||
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
|
||||
+ ok(pathW[0] == 0, "Unexpected path.\n");
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(removebackslash_tests); i++)
|
||||
+ {
|
||||
+ const struct removebackslash_test *test = &removebackslash_tests[i];
|
||||
+ char path[MAX_PATH];
|
||||
+
|
||||
+ MultiByteToWideChar(CP_ACP, 0, test->path, -1, pathW, ARRAY_SIZE(pathW));
|
||||
+ hr = pPathCchRemoveBackslash(pathW, test->size);
|
||||
+ ok(hr == test->hr, "%u: unexpected return value %#x.\n", i, hr);
|
||||
+
|
||||
+ WideCharToMultiByte(CP_ACP, 0, pathW, -1, path, ARRAY_SIZE(path), NULL, NULL);
|
||||
+ ok(!strcmp(path, test->result), "%u: unexpected resulting path %s.\n", i, path);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void test_PathCchRemoveBackslashEx(void)
|
||||
+{
|
||||
+ WCHAR pathW[MAX_PATH];
|
||||
+ SIZE_T remaining;
|
||||
+ unsigned int i;
|
||||
+ HRESULT hr;
|
||||
+ WCHAR *ptrW;
|
||||
+
|
||||
+ if (!pPathCchRemoveBackslashEx)
|
||||
+ {
|
||||
+ win_skip("PathCchRemoveBackslashEx() is not available.\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ pathW[0] = 0;
|
||||
+ hr = pPathCchRemoveBackslashEx(0, 0, NULL, NULL);
|
||||
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
||||
+ ok(pathW[0] == 0, "Unexpected path.\n");
|
||||
+
|
||||
+ pathW[0] = 0;
|
||||
+ ptrW = (void *)0xdeadbeef;
|
||||
+ remaining = 123;
|
||||
+ hr = pPathCchRemoveBackslashEx(pathW, 1, &ptrW, &remaining);
|
||||
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
|
||||
+ ok(pathW[0] == 0, "Unexpected path.\n");
|
||||
+ ok(ptrW == pathW, "Unexpected endptr %p.\n", ptrW);
|
||||
+ ok(remaining == 1, "Unexpected remaining size.\n");
|
||||
+
|
||||
+ pathW[0] = 0;
|
||||
+ hr = pPathCchRemoveBackslashEx(pathW, 2, NULL, NULL);
|
||||
+ ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
|
||||
+ ok(pathW[0] == 0, "Unexpected path.\n");
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(removebackslash_tests); i++)
|
||||
+ {
|
||||
+ const struct removebackslash_test *test = &removebackslash_tests[i];
|
||||
+ char path[MAX_PATH];
|
||||
+
|
||||
+ MultiByteToWideChar(CP_ACP, 0, test->path, -1, pathW, ARRAY_SIZE(pathW));
|
||||
+ hr = pPathCchRemoveBackslashEx(pathW, test->size, NULL, NULL);
|
||||
+ ok(hr == test->hr, "%u: unexpected return value %#x.\n", i, hr);
|
||||
+
|
||||
+ WideCharToMultiByte(CP_ACP, 0, pathW, -1, path, ARRAY_SIZE(path), NULL, NULL);
|
||||
+ ok(!strcmp(path, test->result), "%u: unexpected resulting path %s.\n", i, path);
|
||||
+
|
||||
+ ptrW = (void *)0xdeadbeef;
|
||||
+ remaining = 123;
|
||||
+ MultiByteToWideChar(CP_ACP, 0, test->path, -1, pathW, ARRAY_SIZE(pathW));
|
||||
+ hr = pPathCchRemoveBackslashEx(pathW, test->size, &ptrW, &remaining);
|
||||
+ ok(hr == test->hr, "%u: unexpected return value %#x.\n", i, hr);
|
||||
+ if (SUCCEEDED(hr))
|
||||
+ {
|
||||
+ ok(ptrW == (pathW + lstrlenW(pathW)), "%u: unexpected end pointer.\n", i);
|
||||
+ ok(remaining == test->remaining, "%u: unexpected remaining buffer length.\n", i);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ ok(ptrW == NULL, "%u: unexpecred end pointer.\n", i);
|
||||
+ ok(remaining == 0, "%u: unexpected remaining buffer length.\n", i);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
START_TEST(path)
|
||||
{
|
||||
HMODULE hmod = LoadLibraryA("kernelbase.dll");
|
||||
@@ -1114,6 +1237,9 @@ START_TEST(path)
|
||||
pPathCchStripToRoot = (void *)GetProcAddress(hmod, "PathCchStripToRoot");
|
||||
pPathIsUNCEx = (void *)GetProcAddress(hmod, "PathIsUNCEx");
|
||||
|
||||
+ pPathCchRemoveBackslash = (void *)GetProcAddress(hmod, "PathCchRemoveBackslash");
|
||||
+ pPathCchRemoveBackslashEx = (void *)GetProcAddress(hmod, "PathCchRemoveBackslashEx");
|
||||
+
|
||||
test_PathCchCombineEx();
|
||||
test_PathCchAddBackslash();
|
||||
test_PathCchAddBackslashEx();
|
||||
@@ -1126,4 +1252,7 @@ START_TEST(path)
|
||||
test_PathCchStripPrefix();
|
||||
test_PathCchStripToRoot();
|
||||
test_PathIsUNCEx();
|
||||
+
|
||||
+ test_PathCchRemoveBackslash();
|
||||
+ test_PathCchRemoveBackslashEx();
|
||||
}
|
||||
diff --git a/include/pathcch.h b/include/pathcch.h
|
||||
index 443ccd3..fec4567 100644
|
||||
--- a/include/pathcch.h
|
||||
+++ b/include/pathcch.h
|
||||
@@ -28,6 +28,8 @@
|
||||
HRESULT WINAPI PathCchAddBackslash(WCHAR *path, SIZE_T size);
|
||||
HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE_T *remaining);
|
||||
HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extension);
|
||||
+HRESULT WINAPI PathCchRemoveBackslash(WCHAR *path, SIZE_T size);
|
||||
+HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE_T *remaining);
|
||||
HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags);
|
||||
HRESULT WINAPI PathCchFindExtension(const WCHAR *path, SIZE_T size, const WCHAR **extension);
|
||||
BOOL WINAPI PathCchIsRoot(const WCHAR *path);
|
||||
--
|
||||
1.9.1
|
||||
|
||||
Reference in New Issue
Block a user