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
884d718c
Commit
884d718c
authored
Aug 23, 2007
by
Mikolaj Zalewski
Committed by
Alexandre Julliard
Aug 24, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Test and fix _ismbslead and _ismbstrail.
parent
b068ce5c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
12 deletions
+53
-12
mbcs.c
dlls/msvcrt/mbcs.c
+18
-11
string.c
dlls/msvcrt/tests/string.c
+35
-1
No files found.
dlls/msvcrt/mbcs.c
View file @
884d718c
...
...
@@ -1058,18 +1058,22 @@ int CDECL _ismbbtrail(unsigned int c)
*/
int
CDECL
_ismbslead
(
const
unsigned
char
*
start
,
const
unsigned
char
*
str
)
{
/* Lead bytes can also be trail bytes if caller messed up
* iterating through the string...
int
lead
=
0
;
if
(
!
g_mbcp_is_multibyte
)
return
0
;
/* Lead bytes can also be trail bytes so we need to analise the string
*/
if
(
MSVCRT___mb_cur_max
>
1
)
while
(
start
<=
str
)
{
while
(
start
<
str
)
start
+=
MSVCRT_isleadbyte
(
*
str
)
?
2
:
1
;
if
(
start
==
str
)
return
MSVCRT_isleadbyte
(
*
str
);
if
(
!*
start
)
return
0
;
lead
=
!
lead
&&
_ismbblead
(
*
start
);
start
++
;
}
return
0
;
/* Must have been a trail, we skipped it */
return
lead
?
-
1
:
0
;
}
/*********************************************************************
...
...
@@ -1077,8 +1081,11 @@ int CDECL _ismbslead(const unsigned char* start, const unsigned char* str)
*/
int
CDECL
_ismbstrail
(
const
unsigned
char
*
start
,
const
unsigned
char
*
str
)
{
/* Must not be a lead, and must be preceded by one */
return
!
_ismbslead
(
start
,
str
)
&&
MSVCRT_isleadbyte
(
str
[
-
1
]);
/* Note: this function doesn't check _ismbbtrail */
if
((
str
>
start
)
&&
_ismbslead
(
start
,
str
-
1
))
return
-
1
;
else
return
0
;
}
/*********************************************************************
...
...
dlls/msvcrt/tests/string.c
View file @
884d718c
...
...
@@ -183,7 +183,7 @@ static void test_mbcp(void)
int
curr_mbcp
=
_getmbcp
();
unsigned
char
*
mbstring
=
(
unsigned
char
*
)
"
\xb0\xb1\xb2
\xb3\xb4
\xb5
"
;
/* incorrect string */
unsigned
char
*
mbstring2
=
(
unsigned
char
*
)
"
\xb0\xb1\xb2\xb3
Q
\xb4\xb5
"
;
/* correct string */
unsigned
char
*
mbsonlylead
=
(
unsigned
char
*
)
"
\xb0\0\xb1\xb2
"
;
unsigned
char
*
mbsonlylead
=
(
unsigned
char
*
)
"
\xb0\0\xb1\xb2
\xb3
"
;
unsigned
char
buf
[
16
];
int
step
;
...
...
@@ -205,6 +205,40 @@ static void test_mbcp(void)
ok
(
_ismbbtrail
(
'\xb0'
),
"
\xa0
should be a trail byte
\n
"
);
ok
(
_ismbbtrail
(
' '
)
==
FALSE
,
"' ' should not be a trail byte
\n
"
);
/* _ismbslead */
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
0
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
1
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
2
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
3
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
4
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
5
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
6
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
7
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbstring
,
&
mbstring
[
8
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbsonlylead
,
&
mbsonlylead
[
0
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbsonlylead
,
&
mbsonlylead
[
1
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbsonlylead
,
&
mbsonlylead
[
2
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbslead
(
mbsonlylead
,
&
mbsonlylead
[
5
]),
FALSE
,
int
,
"%d"
);
/* _ismbstrail */
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
0
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
1
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
2
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
3
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
4
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
5
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
6
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
7
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbstring
,
&
mbstring
[
8
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbsonlylead
,
&
mbsonlylead
[
0
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbsonlylead
,
&
mbsonlylead
[
1
]),
-
1
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbsonlylead
,
&
mbsonlylead
[
2
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbsonlylead
,
&
mbsonlylead
[
3
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbsonlylead
,
&
mbsonlylead
[
4
]),
FALSE
,
int
,
"%d"
);
expect_eq
(
_ismbstrail
(
mbsonlylead
,
&
mbsonlylead
[
5
]),
FALSE
,
int
,
"%d"
);
/* _mbsnextc */
expect_eq
(
_mbsnextc
(
mbstring
),
0xb0b1
,
int
,
"%x"
);
expect_eq
(
_mbsnextc
(
&
mbstring
[
2
]),
0xb220
,
int
,
"%x"
);
/* lead + invalid tail */
...
...
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