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
9a2d605d
Commit
9a2d605d
authored
Aug 22, 2007
by
Mikolaj Zalewski
Committed by
Alexandre Julliard
Aug 23, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Test and fix _mbsinc/_mbsninc.
parent
cf8cf1d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
mbcs.c
dlls/msvcrt/mbcs.c
+17
-12
string.c
dlls/msvcrt/tests/string.c
+26
-0
No files found.
dlls/msvcrt/mbcs.c
View file @
9a2d605d
...
...
@@ -27,6 +27,7 @@
#include "wine/unicode.h"
#include "wine/debug.h"
#include "msvcrt/mbctype.h"
#include "msvcrt/mbstring.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
msvcrt
);
...
...
@@ -335,10 +336,7 @@ unsigned char* CDECL _mbsdec(const unsigned char* start, const unsigned char* cu
*/
unsigned
char
*
CDECL
_mbsinc
(
const
unsigned
char
*
str
)
{
if
(
MSVCRT___mb_cur_max
>
1
&&
MSVCRT_isleadbyte
(
*
str
))
return
(
unsigned
char
*
)
str
+
2
;
/* MB char */
return
(
unsigned
char
*
)
str
+
1
;
/* ASCII CP or SB char */
return
(
unsigned
char
*
)(
str
+
_mbclen
(
str
));
}
/*********************************************************************
...
...
@@ -346,15 +344,22 @@ unsigned char* CDECL _mbsinc(const unsigned char* str)
*/
unsigned
char
*
CDECL
_mbsninc
(
const
unsigned
char
*
str
,
MSVCRT_size_t
num
)
{
if
(
!
str
||
num
<
1
)
if
(
!
str
)
return
NULL
;
if
(
MSVCRT___mb_cur_max
>
1
)
while
(
num
>
0
&&
*
str
)
{
while
(
num
--
)
str
=
_mbsinc
(
str
);
return
(
unsigned
char
*
)
str
;
if
(
_ismbblead
(
*
str
))
{
if
(
!*
(
str
+
1
))
break
;
str
++
;
}
str
++
;
num
--
;
}
return
(
unsigned
char
*
)
str
+
num
;
/* ASCII CP */
return
(
unsigned
char
*
)
str
;
}
/*********************************************************************
...
...
@@ -1348,7 +1353,7 @@ MSVCRT_size_t CDECL _mbsspn(const unsigned char* string, const unsigned char* se
/*********************************************************************
* _mbsspnp (MSVCRT.@)
*/
const
unsigned
char
*
CDECL
_mbsspnp
(
const
unsigned
char
*
string
,
const
unsigned
char
*
set
)
unsigned
char
*
CDECL
_mbsspnp
(
const
unsigned
char
*
string
,
const
unsigned
char
*
set
)
{
const
unsigned
char
*
p
,
*
q
;
...
...
@@ -1376,7 +1381,7 @@ const unsigned char* CDECL _mbsspnp(const unsigned char* string, const unsigned
}
if
(
*
p
==
'\0'
)
return
NULL
;
return
p
;
return
(
unsigned
char
*
)
p
;
}
/*********************************************************************
...
...
dlls/msvcrt/tests/string.c
View file @
9a2d605d
...
...
@@ -185,6 +185,7 @@ static void test_mbcp(void)
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
buf
[
16
];
int
step
;
/* some two single-byte code pages*/
test_codepage
(
1252
);
...
...
@@ -252,6 +253,31 @@ static void test_mbcp(void)
_mbsnbcpy
(
buf
,
mbsonlylead
,
5
);
expect_bin
(
buf
,
"
\0\0\0\0\0\xff
"
,
6
);
/* _mbsinc/mbsdec */
step
=
_mbsinc
(
mbstring
)
-
mbstring
;
ok
(
step
==
2
,
"_mbsinc adds %d (exp. 2)
\n
"
,
step
);
step
=
_mbsinc
(
&
mbstring
[
2
])
-
&
mbstring
[
2
];
/* lead + invalid tail */
ok
(
step
==
2
,
"_mbsinc adds %d (exp. 2)
\n
"
,
step
);
step
=
_mbsninc
(
mbsonlylead
,
1
)
-
mbsonlylead
;
ok
(
step
==
0
,
"_mbsninc adds %d (exp. 0)
\n
"
,
step
);
step
=
_mbsninc
(
mbsonlylead
,
2
)
-
mbsonlylead
;
/* lead + NUL byte + lead + char */
ok
(
step
==
0
,
"_mbsninc adds %d (exp. 0)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
0
)
-
mbstring2
;
ok
(
step
==
0
,
"_mbsninc adds %d (exp. 2)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
1
)
-
mbstring2
;
ok
(
step
==
2
,
"_mbsninc adds %d (exp. 2)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
2
)
-
mbstring2
;
ok
(
step
==
4
,
"_mbsninc adds %d (exp. 4)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
3
)
-
mbstring2
;
ok
(
step
==
5
,
"_mbsninc adds %d (exp. 5)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
4
)
-
mbstring2
;
ok
(
step
==
7
,
"_mbsninc adds %d (exp. 7)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
5
)
-
mbstring2
;
ok
(
step
==
7
,
"_mbsninc adds %d (exp. 7)
\n
"
,
step
);
step
=
_mbsninc
(
mbstring2
,
17
)
-
mbstring2
;
ok
(
step
==
7
,
"_mbsninc adds %d (exp. 7)
\n
"
,
step
);
/* 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)
...
...
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