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
e8314684
Commit
e8314684
authored
Dec 29, 2011
by
Daniel Lehman
Committed by
Alexandre Julliard
Jul 17, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcp90: Handle npos as a len in basic_string<>::replace.
parent
5feea8ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
4 deletions
+58
-4
string.c
dlls/msvcp90/string.c
+4
-4
string.c
dlls/msvcp90/tests/string.c
+54
-0
No files found.
dlls/msvcp90/string.c
View file @
e8314684
...
@@ -1949,7 +1949,7 @@ basic_string_char* __thiscall basic_string_char_replace_cstr_len(basic_string_ch
...
@@ -1949,7 +1949,7 @@ basic_string_char* __thiscall basic_string_char_replace_cstr_len(basic_string_ch
if
(
this
->
size
<
off
)
if
(
this
->
size
<
off
)
MSVCP__String_base_Xran
();
MSVCP__String_base_Xran
();
if
(
off
+
len
>
this
->
size
)
if
(
len
>
this
->
size
-
off
)
len
=
this
->
size
-
off
;
len
=
this
->
size
-
off
;
if
(
MSVCP_basic_string_char_npos
-
str_len
<=
this
->
size
-
len
)
if
(
MSVCP_basic_string_char_npos
-
str_len
<=
this
->
size
-
len
)
...
@@ -2040,7 +2040,7 @@ basic_string_char* __thiscall basic_string_char_replace_ch(basic_string_char *th
...
@@ -2040,7 +2040,7 @@ basic_string_char* __thiscall basic_string_char_replace_ch(basic_string_char *th
if
(
this
->
size
<
off
)
if
(
this
->
size
<
off
)
MSVCP__String_base_Xran
();
MSVCP__String_base_Xran
();
if
(
off
+
len
>
this
->
size
)
if
(
len
>
this
->
size
-
off
)
len
=
this
->
size
-
off
;
len
=
this
->
size
-
off
;
if
(
MSVCP_basic_string_char_npos
-
count
<=
this
->
size
-
len
)
if
(
MSVCP_basic_string_char_npos
-
count
<=
this
->
size
-
len
)
...
@@ -3901,7 +3901,7 @@ basic_string_wchar* __thiscall basic_string_wchar_replace_cstr_len(basic_string_
...
@@ -3901,7 +3901,7 @@ basic_string_wchar* __thiscall basic_string_wchar_replace_cstr_len(basic_string_
if
(
this
->
size
<
off
)
if
(
this
->
size
<
off
)
MSVCP__String_base_Xran
();
MSVCP__String_base_Xran
();
if
(
off
+
len
>
this
->
size
)
if
(
len
>
this
->
size
-
off
)
len
=
this
->
size
-
off
;
len
=
this
->
size
-
off
;
if
(
MSVCP_basic_string_wchar_npos
-
str_len
<=
this
->
size
-
len
)
if
(
MSVCP_basic_string_wchar_npos
-
str_len
<=
this
->
size
-
len
)
...
@@ -4000,7 +4000,7 @@ basic_string_wchar* __thiscall basic_string_wchar_replace_ch(basic_string_wchar
...
@@ -4000,7 +4000,7 @@ basic_string_wchar* __thiscall basic_string_wchar_replace_ch(basic_string_wchar
if
(
this
->
size
<
off
)
if
(
this
->
size
<
off
)
MSVCP__String_base_Xran
();
MSVCP__String_base_Xran
();
if
(
off
+
len
>
this
->
size
)
if
(
len
>
this
->
size
-
off
)
len
=
this
->
size
-
off
;
len
=
this
->
size
-
off
;
if
(
MSVCP_basic_string_wchar_npos
-
count
<=
this
->
size
-
len
)
if
(
MSVCP_basic_string_wchar_npos
-
count
<=
this
->
size
-
len
)
...
...
dlls/msvcp90/tests/string.c
View file @
e8314684
...
@@ -76,6 +76,7 @@ static int (__thiscall *p_basic_string_char_compare_substr_substr)(basic_string_
...
@@ -76,6 +76,7 @@ static int (__thiscall *p_basic_string_char_compare_substr_substr)(basic_string_
static
int
(
__thiscall
*
p_basic_string_char_compare_substr_cstr_len
)(
basic_string_char
*
,
size_t
,
size_t
,
const
char
*
,
size_t
);
static
int
(
__thiscall
*
p_basic_string_char_compare_substr_cstr_len
)(
basic_string_char
*
,
size_t
,
size_t
,
const
char
*
,
size_t
);
static
size_t
(
__thiscall
*
p_basic_string_char_find_cstr_substr
)(
basic_string_char
*
,
const
char
*
,
size_t
,
size_t
);
static
size_t
(
__thiscall
*
p_basic_string_char_find_cstr_substr
)(
basic_string_char
*
,
const
char
*
,
size_t
,
size_t
);
static
size_t
(
__thiscall
*
p_basic_string_char_rfind_cstr_substr
)(
basic_string_char
*
,
const
char
*
,
size_t
,
size_t
);
static
size_t
(
__thiscall
*
p_basic_string_char_rfind_cstr_substr
)(
basic_string_char
*
,
const
char
*
,
size_t
,
size_t
);
static
basic_string_char
*
(
__thiscall
*
p_basic_string_char_replace_cstr
)(
basic_string_char
*
,
size_t
,
size_t
,
const
char
*
);
static
size_t
*
p_basic_string_char_npos
;
static
size_t
*
p_basic_string_char_npos
;
...
@@ -225,6 +226,8 @@ static BOOL init(void)
...
@@ -225,6 +226,8 @@ static BOOL init(void)
"?find@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA_KPEBD_K1@Z"
);
"?find@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA_KPEBD_K1@Z"
);
SET
(
p_basic_string_char_rfind_cstr_substr
,
SET
(
p_basic_string_char_rfind_cstr_substr
,
"?rfind@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA_KPEBD_K1@Z"
);
"?rfind@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA_KPEBD_K1@Z"
);
SET
(
p_basic_string_char_replace_cstr
,
"?replace@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEAV12@_K0PEBD@Z"
);
SET
(
p_basic_string_char_npos
,
SET
(
p_basic_string_char_npos
,
"?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2_KB"
);
"?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2_KB"
);
...
@@ -289,6 +292,8 @@ static BOOL init(void)
...
@@ -289,6 +292,8 @@ static BOOL init(void)
"?find@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z"
);
"?find@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z"
);
SET
(
p_basic_string_char_rfind_cstr_substr
,
SET
(
p_basic_string_char_rfind_cstr_substr
,
"?rfind@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z"
);
"?rfind@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIPBDII@Z"
);
SET
(
p_basic_string_char_replace_cstr
,
"?replace@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@IIPBD@Z"
);
SET
(
p_basic_string_char_npos
,
SET
(
p_basic_string_char_npos
,
"?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2IB"
);
"?npos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@2IB"
);
...
@@ -549,6 +554,54 @@ static void test_basic_string_char_rfind(void) {
...
@@ -549,6 +554,54 @@ static void test_basic_string_char_rfind(void) {
}
}
}
}
static
void
test_basic_string_char_replace
(
void
)
{
struct
replace_char_test
{
const
char
*
str
;
size_t
off
;
size_t
len
;
const
char
*
replace
;
const
char
*
ret
;
};
int
i
;
basic_string_char
str
;
basic_string_char
*
ret
;
struct
replace_char_test
tests
[]
=
{
{
""
,
0
,
0
,
""
,
""
},
/* empty string */
{
""
,
0
,
10
,
""
,
""
},
/* empty string with invalid len */
{
"ABCDEF"
,
0
,
0
,
""
,
"ABCDEF"
},
/* replace with empty string */
{
"ABCDEF"
,
0
,
0
,
"-"
,
"-ABCDEF"
},
/* replace with 0 len */
{
"ABCDEF"
,
0
,
1
,
"-"
,
"-BCDEF"
},
/* replace 1 at beginning */
{
"ABCDEF"
,
0
,
3
,
"-"
,
"-DEF"
},
/* replace 3 at beginning */
{
"ABCDEF"
,
0
,
42
,
"-"
,
"-"
},
/* replace whole string with invalid long len */
{
"ABCDEF"
,
0
,
*
p_basic_string_char_npos
,
"-"
,
"-"
},
/* replace whole string with npos */
{
"ABCDEF"
,
5
,
0
,
""
,
"ABCDEF"
},
/* replace at end with empty string */
{
"ABCDEF"
,
5
,
0
,
"-"
,
"ABCDE-F"
},
/* replace at end with 0 len */
{
"ABCDEF"
,
5
,
1
,
"-"
,
"ABCDE-"
},
/* replace 1 at end */
{
"ABCDEF"
,
5
,
42
,
"-"
,
"ABCDE-"
},
/* replace end with invalid long len */
{
"ABCDEF"
,
5
,
*
p_basic_string_char_npos
,
"-"
,
"ABCDE-"
},
/* replace end with npos */
{
"ABCDEF"
,
6
,
0
,
""
,
"ABCDEF"
},
/* replace after end with empty string */
{
"ABCDEF"
,
6
,
0
,
"-"
,
"ABCDEF-"
},
/* replace after end with 0 len */
{
"ABCDEF"
,
6
,
1
,
"-"
,
"ABCDEF-"
},
/* replace 1 after end */
{
"ABCDEF"
,
6
,
42
,
"-"
,
"ABCDEF-"
},
/* replace after end with invalid long len */
{
"ABCDEF"
,
6
,
*
p_basic_string_char_npos
,
"-"
,
"ABCDEF-"
},
/* replace after end with npos */
};
for
(
i
=
0
;
i
<
sizeof
(
tests
)
/
sizeof
(
tests
[
0
]);
i
++
)
{
call_func2
(
p_basic_string_char_ctor_cstr
,
&
str
,
tests
[
i
].
str
);
ret
=
call_func4
(
p_basic_string_char_replace_cstr
,
&
str
,
tests
[
i
].
off
,
tests
[
i
].
len
,
tests
[
i
].
replace
);
ok
(
ret
==
&
str
,
"str = %p ret = %p
\n
"
,
ret
,
&
str
);
ok
(
strcmp
(
tests
[
i
].
ret
,
(
const
char
*
)
call_func1
(
p_basic_string_char_cstr
,
ret
))
==
0
,
"str = %s ret = %s
\n
"
,
tests
[
i
].
ret
,
(
const
char
*
)
call_func1
(
p_basic_string_char_cstr
,
ret
));
call_func1
(
p_basic_string_char_dtor
,
&
str
);
}
}
static
void
test_basic_string_wchar
(
void
)
{
static
void
test_basic_string_wchar
(
void
)
{
static
const
wchar_t
test
[]
=
{
't'
,
'e'
,
's'
,
't'
,
0
};
static
const
wchar_t
test
[]
=
{
't'
,
'e'
,
's'
,
't'
,
0
};
...
@@ -661,6 +714,7 @@ START_TEST(string)
...
@@ -661,6 +714,7 @@ START_TEST(string)
test_basic_string_char_concatenate
();
test_basic_string_char_concatenate
();
test_basic_string_char_find
();
test_basic_string_char_find
();
test_basic_string_char_rfind
();
test_basic_string_char_rfind
();
test_basic_string_char_replace
();
test_basic_string_wchar
();
test_basic_string_wchar
();
test_basic_string_wchar_swap
();
test_basic_string_wchar_swap
();
...
...
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