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
b39c59e7
Commit
b39c59e7
authored
Oct 19, 2010
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Oct 19, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Improve wcsncat_s.
parent
c7536ef8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
string.c
dlls/msvcrt/tests/string.c
+6
-1
wcs.c
dlls/msvcrt/wcs.c
+12
-13
No files found.
dlls/msvcrt/tests/string.c
View file @
b39c59e7
...
@@ -1459,8 +1459,13 @@ static void test_wcsncat_s(void)
...
@@ -1459,8 +1459,13 @@ static void test_wcsncat_s(void)
dst
[
0
]
=
0
;
dst
[
0
]
=
0
;
ret
=
p_wcsncat_s
(
dst
,
2
,
src
,
_TRUNCATE
);
ret
=
p_wcsncat_s
(
dst
,
2
,
src
,
_TRUNCATE
);
todo_wine
ok
(
ret
==
80
,
"err = %d
\n
"
,
ret
);
ok
(
ret
==
STRUNCATE
,
"err = %d
\n
"
,
ret
);
ok
(
dst
[
0
]
==
'a'
&&
dst
[
1
]
==
0
,
"dst is %s
\n
"
,
wine_dbgstr_w
(
dst
));
ok
(
dst
[
0
]
==
'a'
&&
dst
[
1
]
==
0
,
"dst is %s
\n
"
,
wine_dbgstr_w
(
dst
));
memcpy
(
dst
,
abcW
,
sizeof
(
abcW
));
dst
[
3
]
=
'd'
;
ret
=
p_wcsncat_s
(
dst
,
4
,
src
,
4
);
ok
(
ret
==
EINVAL
,
"err = %d
\n
"
,
ret
);
}
}
START_TEST
(
string
)
START_TEST
(
string
)
...
...
dlls/msvcrt/wcs.c
View file @
b39c59e7
...
@@ -1588,8 +1588,8 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
...
@@ -1588,8 +1588,8 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
const
MSVCRT_wchar_t
*
src
,
MSVCRT_size_t
count
)
const
MSVCRT_wchar_t
*
src
,
MSVCRT_size_t
count
)
{
{
MSVCRT_size_t
srclen
;
MSVCRT_size_t
srclen
;
MSVCRT_size_t
i
;
MSVCRT_wchar_t
dststart
;
MSVCRT_wchar_t
dststart
;
INT
ret
=
0
;
if
(
src
==
NULL
&&
count
>
0
)
if
(
src
==
NULL
&&
count
>
0
)
return
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
...
@@ -1597,34 +1597,33 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
...
@@ -1597,34 +1597,33 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem,
return
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
if
(
elem
==
0
)
if
(
elem
==
0
)
return
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
if
(
count
==
0
)
return
0
;
for
(
i
=
0
;
i
<
elem
;
i
++
)
for
(
dststart
=
0
;
dststart
<
elem
;
dststart
++
)
{
{
dststart
=
i
;
if
(
dst
[
dststart
]
==
'\0'
)
if
(
dst
[
i
]
==
'\0'
)
break
;
break
;
}
}
if
(
dststart
==
elem
)
if
(
dststart
==
elem
)
return
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
if
(
count
==
MSVCRT__TRUNCATE
)
if
(
count
==
MSVCRT__TRUNCATE
)
srclen
=
elem
-
dststart
-
1
;
else
srclen
=
count
;
for
(
i
=
0
;
i
<
srclen
;
i
++
)
{
{
if
(
src
[
i
]
==
'\0'
)
srclen
=
strlenW
(
src
);
if
(
srclen
>=
(
elem
-
dststart
))
{
{
srclen
=
i
;
srclen
=
elem
-
dststart
-
1
;
break
;
ret
=
MSVCRT_STRUNCATE
;
}
}
}
}
else
srclen
=
min
(
strlenW
(
src
),
count
);
if
(
srclen
<
(
elem
-
dststart
))
if
(
srclen
<
(
elem
-
dststart
))
{
{
memcpy
(
&
dst
[
dststart
],
src
,
srclen
*
sizeof
(
MSVCRT_wchar_t
));
memcpy
(
&
dst
[
dststart
],
src
,
srclen
*
sizeof
(
MSVCRT_wchar_t
));
dst
[
srclen
]
=
'\0'
;
dst
[
srclen
]
=
'\0'
;
return
0
;
return
ret
;
}
}
dst
[
0
]
=
'\0'
;
dst
[
0
]
=
'\0'
;
return
MSVCRT_ERANGE
;
return
MSVCRT_ERANGE
;
...
...
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