Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
404cd8a9
Commit
404cd8a9
authored
Apr 24, 2021
by
Esme Povirk
Committed by
Alexandre Julliard
Apr 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Always remove trailing spaces in PathRemoveBlanks.
Signed-off-by:
Esme Povirk
<
esme@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
53e7842e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
+52
-5
path.c
dlls/kernelbase/path.c
+7
-5
path.c
dlls/shlwapi/tests/path.c
+45
-0
No files found.
dlls/kernelbase/path.c
View file @
404cd8a9
...
@@ -1902,14 +1902,14 @@ BOOL WINAPI PathIsUNCServerW(const WCHAR *path)
...
@@ -1902,14 +1902,14 @@ BOOL WINAPI PathIsUNCServerW(const WCHAR *path)
void
WINAPI
PathRemoveBlanksA
(
char
*
path
)
void
WINAPI
PathRemoveBlanksA
(
char
*
path
)
{
{
char
*
start
;
char
*
start
,
*
first
;
TRACE
(
"%s
\n
"
,
wine_dbgstr_a
(
path
));
TRACE
(
"%s
\n
"
,
wine_dbgstr_a
(
path
));
if
(
!
path
||
!*
path
)
if
(
!
path
||
!*
path
)
return
;
return
;
start
=
path
;
start
=
first
=
path
;
while
(
*
path
==
' '
)
while
(
*
path
==
' '
)
path
=
CharNextA
(
path
);
path
=
CharNextA
(
path
);
...
@@ -1917,7 +1917,7 @@ void WINAPI PathRemoveBlanksA(char *path)
...
@@ -1917,7 +1917,7 @@ void WINAPI PathRemoveBlanksA(char *path)
while
(
*
path
)
while
(
*
path
)
*
start
++
=
*
path
++
;
*
start
++
=
*
path
++
;
if
(
start
!=
path
)
if
(
start
!=
first
)
while
(
start
[
-
1
]
==
' '
)
while
(
start
[
-
1
]
==
' '
)
start
--
;
start
--
;
...
@@ -1926,20 +1926,22 @@ void WINAPI PathRemoveBlanksA(char *path)
...
@@ -1926,20 +1926,22 @@ void WINAPI PathRemoveBlanksA(char *path)
void
WINAPI
PathRemoveBlanksW
(
WCHAR
*
path
)
void
WINAPI
PathRemoveBlanksW
(
WCHAR
*
path
)
{
{
WCHAR
*
start
=
path
;
WCHAR
*
start
,
*
first
;
TRACE
(
"%s
\n
"
,
wine_dbgstr_w
(
path
));
TRACE
(
"%s
\n
"
,
wine_dbgstr_w
(
path
));
if
(
!
path
||
!*
path
)
if
(
!
path
||
!*
path
)
return
;
return
;
start
=
first
=
path
;
while
(
*
path
==
' '
)
while
(
*
path
==
' '
)
path
++
;
path
++
;
while
(
*
path
)
while
(
*
path
)
*
start
++
=
*
path
++
;
*
start
++
=
*
path
++
;
if
(
start
!=
path
)
if
(
start
!=
first
)
while
(
start
[
-
1
]
==
' '
)
while
(
start
[
-
1
]
==
' '
)
start
--
;
start
--
;
...
...
dlls/shlwapi/tests/path.c
View file @
404cd8a9
...
@@ -1712,6 +1712,50 @@ static void test_PathUndecorate(void)
...
@@ -1712,6 +1712,50 @@ static void test_PathUndecorate(void)
PathUndecorateW
(
NULL
);
PathUndecorateW
(
NULL
);
}
}
static
void
test_PathRemoveBlanks
(
void
)
{
struct
remove_blanks_test
{
const
char
*
input
;
const
char
*
expected
;
};
struct
remove_blanks_test
tests
[]
=
{
{
""
,
""
},
{
" "
,
""
},
{
"test"
,
"test"
},
{
" test"
,
"test"
},
{
" test"
,
"test"
},
{
"test "
,
"test"
},
{
"test "
,
"test"
},
{
" test "
,
"test"
},
{
" test "
,
"test"
}};
char
pathA
[
MAX_PATH
];
WCHAR
pathW
[
MAX_PATH
];
int
i
,
ret
;
const
UINT
CP_ASCII
=
20127
;
PathRemoveBlanksW
(
NULL
);
PathRemoveBlanksA
(
NULL
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
i
++
)
{
strcpy
(
pathA
,
tests
[
i
].
input
);
PathRemoveBlanksA
(
pathA
);
ok
(
strcmp
(
pathA
,
tests
[
i
].
expected
)
==
0
,
"input string '%s', expected '%s', got '%s'
\n
"
,
tests
[
i
].
input
,
tests
[
i
].
expected
,
pathA
);
ret
=
MultiByteToWideChar
(
CP_ASCII
,
MB_ERR_INVALID_CHARS
,
tests
[
i
].
input
,
-
1
,
pathW
,
MAX_PATH
);
ok
(
ret
!=
0
,
"MultiByteToWideChar failed for '%s'
\n
"
,
tests
[
i
].
input
);
PathRemoveBlanksW
(
pathW
);
ret
=
WideCharToMultiByte
(
CP_ASCII
,
0
,
pathW
,
-
1
,
pathA
,
MAX_PATH
,
NULL
,
NULL
);
ok
(
ret
!=
0
,
"WideCharToMultiByte failed for %s from test string '%s'
\n
"
,
wine_dbgstr_w
(
pathW
),
tests
[
i
].
input
);
ok
(
strcmp
(
pathA
,
tests
[
i
].
expected
)
==
0
,
"input string '%s', expected '%s', got '%s'
\n
"
,
tests
[
i
].
input
,
tests
[
i
].
expected
,
pathA
);
}
}
START_TEST
(
path
)
START_TEST
(
path
)
{
{
HMODULE
hShlwapi
=
GetModuleHandleA
(
"shlwapi.dll"
);
HMODULE
hShlwapi
=
GetModuleHandleA
(
"shlwapi.dll"
);
...
@@ -1759,4 +1803,5 @@ START_TEST(path)
...
@@ -1759,4 +1803,5 @@ START_TEST(path)
test_PathIsRelativeW
();
test_PathIsRelativeW
();
test_PathStripPathA
();
test_PathStripPathA
();
test_PathUndecorate
();
test_PathUndecorate
();
test_PathRemoveBlanks
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment