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
5098bab5
Commit
5098bab5
authored
Nov 02, 2023
by
Bartosz Kosiorek
Committed by
Alexandre Julliard
Nov 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Add _mbsncpy_l implementation.
parent
2a89257b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
38 deletions
+105
-38
msvcr100.spec
dlls/msvcr100/msvcr100.spec
+1
-1
msvcr110.spec
dlls/msvcr110/msvcr110.spec
+1
-1
msvcr120.spec
dlls/msvcr120/msvcr120.spec
+1
-1
msvcr80.spec
dlls/msvcr80/msvcr80.spec
+1
-1
msvcr90.spec
dlls/msvcr90/msvcr90.spec
+1
-1
mbcs.c
dlls/msvcrt/mbcs.c
+49
-30
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+1
-1
string.c
dlls/msvcrt/tests/string.c
+48
-0
ucrtbase.spec
dlls/ucrtbase/ucrtbase.spec
+2
-2
No files found.
dlls/msvcr100/msvcr100.spec
View file @
5098bab5
...
...
@@ -1156,7 +1156,7 @@
@ stub _mbsncoll(str str long)
@ stub _mbsncoll_l
@ cdecl _mbsncpy(ptr str long)
@
stub _mbsncpy_l
@
cdecl _mbsncpy_l(ptr str long ptr)
@ stub _mbsncpy_s
@ stub _mbsncpy_s_l
@ cdecl _mbsnextc(str)
...
...
dlls/msvcr110/msvcr110.spec
View file @
5098bab5
...
...
@@ -1513,7 +1513,7 @@
@ stub _mbsncoll(str str long)
@ stub _mbsncoll_l
@ cdecl _mbsncpy(ptr str long)
@
stub _mbsncpy_l
@
cdecl _mbsncpy_l(ptr str long ptr)
@ stub _mbsncpy_s
@ stub _mbsncpy_s_l
@ cdecl _mbsnextc(str)
...
...
dlls/msvcr120/msvcr120.spec
View file @
5098bab5
...
...
@@ -1524,7 +1524,7 @@
@ stub _mbsncoll(str str long)
@ stub _mbsncoll_l
@ cdecl _mbsncpy(ptr str long)
@
stub _mbsncpy_l
@
cdecl _mbsncpy_l(ptr str long ptr)
@ stub _mbsncpy_s
@ stub _mbsncpy_s_l
@ cdecl _mbsnextc(str)
...
...
dlls/msvcr80/msvcr80.spec
View file @
5098bab5
...
...
@@ -828,7 +828,7 @@
@ stub _mbsncoll(str str long)
@ stub _mbsncoll_l
@ cdecl _mbsncpy(ptr str long)
@
stub _mbsncpy_l
@
cdecl _mbsncpy_l(ptr str long ptr)
@ stub _mbsncpy_s
@ stub _mbsncpy_s_l
@ cdecl _mbsnextc(str)
...
...
dlls/msvcr90/msvcr90.spec
View file @
5098bab5
...
...
@@ -806,7 +806,7 @@
@ stub _mbsncoll(str str long)
@ stub _mbsncoll_l
@ cdecl _mbsncpy(ptr str long)
@
stub _mbsncpy_l
@
cdecl _mbsncpy_l(ptr str long ptr)
@ stub _mbsncpy_s
@ stub _mbsncpy_s_l
@ cdecl _mbsnextc(str)
...
...
dlls/msvcrt/mbcs.c
View file @
5098bab5
...
...
@@ -839,47 +839,66 @@ int CDECL _mbccpy_s(unsigned char* dest, size_t maxsize,
return
_mbccpy_s_l
(
dest
,
maxsize
,
copied
,
src
,
NULL
);
}
/*********************************************************************
* _mbsncpy(MSVCRT.@)
* _mbsncpy
_l
(MSVCRT.@)
* REMARKS
* The parameter n is the number or characters to copy, not the size of
* the buffer. Use _mbsnbcpy for a function analogical to strncpy
* the buffer. Use _mbsnbcpy
_l
for a function analogical to strncpy
*/
unsigned
char
*
CDECL
_mbsncpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
size_t
n
)
unsigned
char
*
CDECL
_mbsncpy
_l
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
size_t
n
,
_locale_t
locale
)
{
unsigned
char
*
ret
=
dst
;
if
(
!
n
)
return
dst
;
if
(
get_mbcinfo
()
->
ismbcodepage
)
{
while
(
*
src
&&
n
)
unsigned
char
*
ret
=
dst
;
pthreadmbcinfo
mbcinfo
;
if
(
!
n
)
return
dst
;
if
(
!
MSVCRT_CHECK_PMT
(
dst
&&
src
))
return
NULL
;
if
(
locale
)
mbcinfo
=
locale
->
mbcinfo
;
else
mbcinfo
=
get_mbcinfo
();
if
(
mbcinfo
->
ismbcodepage
)
{
n
--
;
if
(
_ismbblead
(
*
src
))
{
if
(
!*
(
src
+
1
))
while
(
*
src
&&
n
)
{
*
dst
++
=
0
;
*
dst
++
=
0
;
break
;
n
--
;
if
(
_ismbblead_l
(
*
src
,
locale
))
{
if
(
!*
(
src
+
1
))
{
*
dst
++
=
0
;
*
dst
++
=
0
;
break
;
}
*
dst
++
=
*
src
++
;
}
*
dst
++
=
*
src
++
;
}
*
dst
++
=
*
src
++
;
}
*
dst
++
=
*
src
++
;
}
}
else
{
while
(
n
)
else
{
n
--
;
if
(
!
(
*
dst
++
=
*
src
++
))
break
;
while
(
n
)
{
n
--
;
if
(
!
(
*
dst
++
=
*
src
++
))
break
;
}
}
}
while
(
n
--
)
*
dst
++
=
0
;
return
ret
;
while
(
n
--
)
*
dst
++
=
0
;
return
ret
;
}
/*********************************************************************
* _mbsncpy(MSVCRT.@)
* REMARKS
* The parameter n is the number or characters to copy, not the size of
* the buffer. Use _mbsnbcpy for a function analogical to strncpy
*/
unsigned
char
*
CDECL
_mbsncpy
(
unsigned
char
*
dst
,
const
unsigned
char
*
src
,
size_t
n
)
{
return
_mbsncpy_l
(
dst
,
src
,
n
,
NULL
);
}
/*********************************************************************
...
...
dlls/msvcrt/msvcrt.spec
View file @
5098bab5
...
...
@@ -777,7 +777,7 @@
@ stub _mbsncoll(str str long)
# stub _mbsncoll_l(str str long ptr)
@ cdecl _mbsncpy(ptr str long)
# stub
_mbsncpy_l(ptr str long ptr)
@ cdecl
_mbsncpy_l(ptr str long ptr)
# stub _mbsncpy_s(ptr long str long)
# stub _mbsncpy_s_l(ptr long str long ptr)
@ cdecl _mbsnextc(str)
...
...
dlls/msvcrt/tests/string.c
View file @
5098bab5
...
...
@@ -264,6 +264,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
\xb3
"
;
unsigned
char
buf
[
16
];
unsigned
char
*
ret
;
int
step
;
CPINFO
cp_info
;
...
...
@@ -462,6 +463,53 @@ static void test_mbcp(void)
expect_bin
(
buf
,
"
\x00\xff
"
,
2
);
}
errno
=
0xdeadbeef
;
ret
=
_mbsncpy
(
NULL
,
mbstring
,
1
);
ok
(
ret
==
NULL
,
"_mbsncpy returned %p, expected NULL
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"_mbsncpy returned %d
\n
"
,
errno
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
errno
=
0xdeadbeef
;
ret
=
_mbsncpy
(
buf
,
NULL
,
1
);
ok
(
ret
==
NULL
,
"_mbsncpy returned %p, expected NULL
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"_mbsncpy returned %d
\n
"
,
errno
);
expect_bin
(
buf
,
"
\xff\xff\xff
"
,
3
);
errno
=
0xdeadbeef
;
ret
=
_mbsncpy
(
NULL
,
mbstring
,
0
);
ok
(
ret
==
NULL
,
"_mbsncpy returned %p, expected NULL
\n
"
,
ret
);
ok
(
errno
==
0xdeadbeef
,
"_mbsncpy should not change errno
\n
"
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
errno
=
0xdeadbeef
;
ret
=
_mbsncpy
(
buf
,
NULL
,
0
);
ok
(
ret
==
buf
,
"_mbsncpy returned %p, expected %sp
\n
"
,
ret
,
buf
);
ok
(
errno
==
0xdeadbeef
,
"_mbsncpy should not change errno
\n
"
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
errno
=
0xdeadbeef
;
ret
=
_mbsncpy
(
NULL
,
mbstring
,
1
);
ok
(
ret
==
NULL
,
"_mbsncpy returned %p, expected NULL
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"_mbsncpy returned %d
\n
"
,
errno
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
errno
=
0xdeadbeef
;
ret
=
_mbsncpy
(
buf
,
NULL
,
1
);
ok
(
ret
==
NULL
,
"_mbsncpy returned %p, expected NULL
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"_mbsncpy returned %d
\n
"
,
errno
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
ret
=
_mbsncpy
(
NULL
,
mbstring
,
0
);
ok
(
ret
==
NULL
,
"_mbsncpy returned %p, expected %p
\n
"
,
ret
,
buf
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
ret
=
_mbsncpy
(
buf
,
NULL
,
0
);
ok
(
ret
==
buf
,
"_mbsncpy returned %p, expected %sp
\n
"
,
ret
,
buf
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
ret
=
_mbsncpy
(
buf
,
mbstring
,
0
);
ok
(
ret
==
buf
,
"_mbsncpy returned %p, expected %p
\n
"
,
ret
,
buf
);
memset
(
buf
,
0xff
,
sizeof
(
buf
));
_mbsncpy
(
buf
,
mbstring
,
1
);
expect_bin
(
buf
,
"
\xb0\xb1\xff
"
,
3
);
...
...
dlls/ucrtbase/ucrtbase.spec
View file @
5098bab5
...
...
@@ -672,7 +672,7 @@
@ stub _mbsncoll(str str long)
@ stub _mbsncoll_l
@ cdecl _mbsncpy(ptr str long)
@
stub _mbsncpy_l
@
cdecl _mbsncpy_l(ptr str long ptr)
@ stub _mbsncpy_s
@ stub _mbsncpy_s_l
@ cdecl _mbsnextc(str)
...
...
@@ -1241,7 +1241,7 @@
@ stub _o__mbsncoll
@ stub _o__mbsncoll_l
@ cdecl _o__mbsncpy(ptr str long) _mbsncpy
@
stub _o_
_mbsncpy_l
@
cdecl _o__mbsncpy_l(ptr str long ptr)
_mbsncpy_l
@ stub _o__mbsncpy_s
@ stub _o__mbsncpy_s_l
@ cdecl _o__mbsnextc(str) _mbsnextc
...
...
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