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
12ff6788
Commit
12ff6788
authored
Aug 19, 2007
by
Mikolaj Zalewski
Committed by
Alexandre Julliard
Aug 21, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Test that some functions depends on locale codepage, not the one set by _setmbcp.
parent
cea1052f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
36 deletions
+60
-36
mbcs.c
dlls/msvcrt/mbcs.c
+47
-36
string.c
dlls/msvcrt/tests/string.c
+13
-0
No files found.
dlls/msvcrt/mbcs.c
View file @
12ff6788
...
...
@@ -360,21 +360,6 @@ unsigned int CDECL _mbclen(const unsigned char* str)
}
/*********************************************************************
* mblen(MSVCRT.@)
*/
int
CDECL
MSVCRT_mblen
(
const
char
*
str
,
MSVCRT_size_t
size
)
{
if
(
str
&&
*
str
&&
size
)
{
if
(
MSVCRT___mb_cur_max
==
1
)
return
1
;
/* ASCII CP */
return
!
MSVCRT_isleadbyte
(
*
str
)
?
1
:
(
size
>
1
?
2
:
-
1
);
}
return
0
;
}
/*********************************************************************
* _mbslen(MSVCRT.@)
*/
MSVCRT_size_t
CDECL
_mbslen
(
const
unsigned
char
*
str
)
...
...
@@ -395,27 +380,6 @@ MSVCRT_size_t CDECL _mbslen(const unsigned char* str)
}
/*********************************************************************
* _mbstrlen(MSVCRT.@)
*/
MSVCRT_size_t
CDECL
_mbstrlen
(
const
char
*
str
)
{
if
(
MSVCRT___mb_cur_max
>
1
)
{
MSVCRT_size_t
len
=
0
;
while
(
*
str
)
{
/* FIXME: According to the documentation we are supposed to test for
* multi-byte character validity. Whatever that means
*/
str
+=
MSVCRT_isleadbyte
(
*
str
)
?
2
:
1
;
len
++
;
}
return
len
;
}
return
strlen
(
str
);
/* ASCII CP */
}
/*********************************************************************
* _mbccpy(MSVCRT.@)
*/
void
CDECL
_mbccpy
(
unsigned
char
*
dest
,
const
unsigned
char
*
src
)
...
...
@@ -1477,3 +1441,50 @@ unsigned char* CDECL _mbspbrk(const unsigned char* str, const unsigned char* acc
}
return
NULL
;
}
/*
* Functions depending on locale codepage
*/
/*********************************************************************
* mblen(MSVCRT.@)
* REMARKS
* Unlike most of the multibyte string functions this function uses
* the locale codepage, not the codepage set by _setmbcp
*/
int
CDECL
MSVCRT_mblen
(
const
char
*
str
,
MSVCRT_size_t
size
)
{
if
(
str
&&
*
str
&&
size
)
{
if
(
MSVCRT___mb_cur_max
==
1
)
return
1
;
/* ASCII CP */
return
!
MSVCRT_isleadbyte
(
*
str
)
?
1
:
(
size
>
1
?
2
:
-
1
);
}
return
0
;
}
/*********************************************************************
* _mbstrlen(MSVCRT.@)
* REMARKS
* Unlike most of the multibyte string functions this function uses
* the locale codepage, not the codepage set by _setmbcp
*/
MSVCRT_size_t
CDECL
_mbstrlen
(
const
char
*
str
)
{
if
(
MSVCRT___mb_cur_max
>
1
)
{
MSVCRT_size_t
len
=
0
;
while
(
*
str
)
{
/* FIXME: According to the documentation we are supposed to test for
* multi-byte character validity. Whatever that means
*/
str
+=
MSVCRT_isleadbyte
(
*
str
)
?
2
:
1
;
len
++
;
}
return
len
;
}
return
strlen
(
str
);
/* ASCII CP */
}
dlls/msvcrt/tests/string.c
View file @
12ff6788
...
...
@@ -201,6 +201,19 @@ static void test_mbcp(void)
expect_eq
(
_mbslen
(
mbsonlylead
),
0
,
int
,
"%d"
);
/* lead + NUL not counted as character */
expect_eq
(
_mbslen
(
mbstring
),
4
,
int
,
"%d"
);
/* lead + invalid trail counted */
/* functions that depend on locale codepage, not mbcp.
* we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet
* (as of Wine 0.9.43)
*/
if
(
__mb_cur_max
==
1
)
{
expect_eq
(
mblen
((
char
*
)
mbstring
,
3
),
1
,
int
,
"%x"
);
expect_eq
(
_mbstrlen
((
char
*
)
mbstring2
),
7
,
int
,
"%d"
);
}
else
skip
(
"Current locale has double-byte charset - could leave to false positives
\n
"
);
_setmbcp
(
curr_mbcp
);
}
...
...
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