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
bcfaf467
Commit
bcfaf467
authored
Oct 11, 2010
by
Andrew Nguyen
Committed by
Alexandre Julliard
Oct 11, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Implement _itoa_s.
parent
60866103
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
175 additions
and
4 deletions
+175
-4
msvcr100.spec
dlls/msvcr100/msvcr100.spec
+1
-1
msvcr80.spec
dlls/msvcr80/msvcr80.spec
+1
-1
msvcr90.spec
dlls/msvcr90/msvcr90.spec
+1
-1
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+1
-1
string.c
dlls/msvcrt/string.c
+75
-0
string.c
dlls/msvcrt/tests/string.c
+95
-0
stdlib.h
include/msvcrt/stdlib.h
+1
-0
No files found.
dlls/msvcr100/msvcr100.spec
View file @
bcfaf467
...
...
@@ -834,7 +834,7 @@
@ stub _iswxdigit_l
@ stub _isxdigit_l
@ cdecl _itoa(long ptr long) msvcrt._itoa
@
stub
_itoa_s
@
cdecl _itoa_s(long ptr long long) msvcrt.
_itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
@ stub _itow_s
@ cdecl _j0(double) msvcrt._j0
...
...
dlls/msvcr80/msvcr80.spec
View file @
bcfaf467
...
...
@@ -680,7 +680,7 @@
@ stub _iswxdigit_l
@ stub _isxdigit_l
@ cdecl _itoa(long ptr long) msvcrt._itoa
@
stub
_itoa_s
@
cdecl _itoa_s(long ptr long long) msvcrt.
_itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
@ stub _itow_s
@ cdecl _j0(double) msvcrt._j0
...
...
dlls/msvcr90/msvcr90.spec
View file @
bcfaf467
...
...
@@ -668,7 +668,7 @@
@ stub _iswxdigit_l
@ stub _isxdigit_l
@ cdecl _itoa(long ptr long) msvcrt._itoa
@
stub
_itoa_s
@
cdecl _itoa_s(long ptr long long) msvcrt.
_itoa_s
@ cdecl _itow(long ptr long) msvcrt._itow
@ stub _itow_s
@ cdecl _j0(double) msvcrt._j0
...
...
dlls/msvcrt/msvcrt.spec
View file @
bcfaf467
...
...
@@ -607,7 +607,7 @@
# stub _iswxdigit_l
# stub _isxdigit_l
@ cdecl _itoa(long ptr long) ntdll._itoa
# stub _itoa_s
@ cdecl _itoa_s(long ptr long long)
@ cdecl _itow(long ptr long) ntdll._itow
# stub _itow_s
@ cdecl _j0(double)
...
...
dlls/msvcrt/string.c
View file @
bcfaf467
...
...
@@ -637,6 +637,81 @@ unsigned __int64 CDECL MSVCRT_strtoui64(const char *nptr, char **endptr, int bas
}
/*********************************************************************
* _itoa_s (MSVCRT.@)
*/
int
CDECL
_itoa_s
(
int
value
,
char
*
str
,
MSVCRT_size_t
size
,
int
radix
)
{
unsigned
int
val
,
digit
;
int
is_negative
;
char
buffer
[
33
],
*
pos
;
size_t
len
;
if
(
!
str
||
!
size
||
radix
<
2
||
radix
>
36
)
{
if
(
str
&&
size
)
str
[
0
]
=
'\0'
;
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
}
if
(
value
<
0
&&
radix
==
10
)
{
is_negative
=
1
;
val
=
-
value
;
}
else
{
is_negative
=
0
;
val
=
value
;
}
pos
=
buffer
+
32
;
*
pos
=
'\0'
;
do
{
digit
=
val
%
radix
;
val
/=
radix
;
if
(
digit
<
10
)
*--
pos
=
'0'
+
digit
;
else
*--
pos
=
'a'
+
digit
-
10
;
}
while
(
val
!=
0
);
if
(
is_negative
)
*--
pos
=
'-'
;
len
=
buffer
+
33
-
pos
;
if
(
len
>
size
)
{
size_t
i
;
char
*
p
=
str
;
/* Copy the temporary buffer backwards up to the available number of
* characters. Don't copy the negative sign if present. */
if
(
is_negative
)
{
p
++
;
size
--
;
}
for
(
pos
=
buffer
+
31
,
i
=
0
;
i
<
size
;
i
++
)
*
p
++
=
*
pos
--
;
str
[
0
]
=
'\0'
;
*
MSVCRT__errno
()
=
MSVCRT_ERANGE
;
return
MSVCRT_ERANGE
;
}
memcpy
(
str
,
pos
,
len
);
return
0
;
}
/*********************************************************************
* _ui64toa_s (MSVCRT.@)
*/
int
CDECL
MSVCRT__ui64toa_s
(
unsigned
__int64
value
,
char
*
str
,
...
...
dlls/msvcrt/tests/string.c
View file @
bcfaf467
...
...
@@ -59,6 +59,7 @@ static unsigned __int64 (__cdecl *p_strtoui64)(const char *, char **, int);
static
int
(
__cdecl
*
pwcstombs_s
)(
size_t
*
,
char
*
,
size_t
,
const
wchar_t
*
,
size_t
);
static
int
(
__cdecl
*
pmbstowcs_s
)(
size_t
*
,
wchar_t
*
,
size_t
,
const
char
*
,
size_t
);
static
errno_t
(
__cdecl
*
p_gcvt_s
)(
char
*
,
size_t
,
double
,
int
);
static
errno_t
(
__cdecl
*
p_itoa_s
)(
int
,
char
*
,
size_t
,
int
);
static
int
*
p__mb_cur_max
;
static
unsigned
char
*
p_mbctype
;
...
...
@@ -1277,6 +1278,98 @@ static void test_gcvt(void)
ok
(
buf
[
0
]
==
'\0'
,
"buf[0] = %c
\n
"
,
buf
[
0
]);
}
static
void
test__itoa_s
(
void
)
{
errno_t
ret
;
char
buffer
[
33
];
if
(
!
p_itoa_s
)
{
win_skip
(
"Skipping _itoa_s tests
\n
"
);
return
;
}
errno
=
EBADF
;
ret
=
p_itoa_s
(
0
,
NULL
,
0
,
0
);
ok
(
ret
==
EINVAL
,
"Expected _itoa_s to return EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
memset
(
buffer
,
'X'
,
sizeof
(
buffer
));
errno
=
EBADF
;
ret
=
p_itoa_s
(
0
,
buffer
,
0
,
0
);
ok
(
ret
==
EINVAL
,
"Expected _itoa_s to return EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
buffer
[
0
]
==
'X'
,
"Expected the output buffer to be untouched
\n
"
);
memset
(
buffer
,
'X'
,
sizeof
(
buffer
));
errno
=
EBADF
;
ret
=
p_itoa_s
(
0
,
buffer
,
sizeof
(
buffer
),
0
);
ok
(
ret
==
EINVAL
,
"Expected _itoa_s to return EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
buffer
[
0
]
==
'\0'
,
"Expected the output buffer to be null terminated
\n
"
);
memset
(
buffer
,
'X'
,
sizeof
(
buffer
));
errno
=
EBADF
;
ret
=
p_itoa_s
(
0
,
buffer
,
sizeof
(
buffer
),
64
);
ok
(
ret
==
EINVAL
,
"Expected _itoa_s to return EINVAL, got %d
\n
"
,
ret
);
ok
(
errno
==
EINVAL
,
"Expected errno to be EINVAL, got %d
\n
"
,
errno
);
ok
(
buffer
[
0
]
==
'\0'
,
"Expected the output buffer to be null terminated
\n
"
);
memset
(
buffer
,
'X'
,
sizeof
(
buffer
));
errno
=
EBADF
;
ret
=
p_itoa_s
(
12345678
,
buffer
,
4
,
10
);
ok
(
ret
==
ERANGE
,
"Expected _itoa_s to return ERANGE, got %d
\n
"
,
ret
);
ok
(
errno
==
ERANGE
,
"Expected errno to be ERANGE, got %d
\n
"
,
errno
);
ok
(
!
memcmp
(
buffer
,
"
\000
765"
,
4
),
"Expected the output buffer to be null terminated with truncated output
\n
"
);
memset
(
buffer
,
'X'
,
sizeof
(
buffer
));
errno
=
EBADF
;
ret
=
p_itoa_s
(
12345678
,
buffer
,
8
,
10
);
ok
(
ret
==
ERANGE
,
"Expected _itoa_s to return ERANGE, got %d
\n
"
,
ret
);
ok
(
errno
==
ERANGE
,
"Expected errno to be ERANGE, got %d
\n
"
,
errno
);
ok
(
!
memcmp
(
buffer
,
"
\000
7654321"
,
8
),
"Expected the output buffer to be null terminated with truncated output
\n
"
);
memset
(
buffer
,
'X'
,
sizeof
(
buffer
));
errno
=
EBADF
;
ret
=
p_itoa_s
(
-
12345678
,
buffer
,
9
,
10
);
ok
(
ret
==
ERANGE
,
"Expected _itoa_s to return ERANGE, got %d
\n
"
,
ret
);
ok
(
errno
==
ERANGE
,
"Expected errno to be ERANGE, got %d
\n
"
,
errno
);
ok
(
!
memcmp
(
buffer
,
"
\000
87654321"
,
9
),
"Expected the output buffer to be null terminated with truncated output
\n
"
);
ret
=
p_itoa_s
(
12345678
,
buffer
,
9
,
10
);
ok
(
ret
==
0
,
"Expected _itoa_s to return 0, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
buffer
,
"12345678"
),
"Expected output buffer string to be
\"
12345678
\"
, got
\"
%s
\"\n
"
,
buffer
);
ret
=
p_itoa_s
(
43690
,
buffer
,
sizeof
(
buffer
),
2
);
ok
(
ret
==
0
,
"Expected _itoa_s to return 0, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
buffer
,
"1010101010101010"
),
"Expected output buffer string to be
\"
1010101010101010
\"
, got
\"
%s
\"\n
"
,
buffer
);
ret
=
p_itoa_s
(
1092009
,
buffer
,
sizeof
(
buffer
),
36
);
ok
(
ret
==
0
,
"Expected _itoa_s to return 0, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
buffer
,
"nell"
),
"Expected output buffer string to be
\"
nell
\"
, got
\"
%s
\"\n
"
,
buffer
);
ret
=
p_itoa_s
(
5704
,
buffer
,
sizeof
(
buffer
),
18
);
ok
(
ret
==
0
,
"Expected _itoa_s to return 0, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
buffer
,
"hag"
),
"Expected output buffer string to be
\"
hag
\"
, got
\"
%s
\"\n
"
,
buffer
);
ret
=
p_itoa_s
(
-
12345678
,
buffer
,
sizeof
(
buffer
),
10
);
ok
(
ret
==
0
,
"Expected _itoa_s to return 0, got %d
\n
"
,
ret
);
ok
(
!
strcmp
(
buffer
,
"-12345678"
),
"Expected output buffer string to be
\"
-12345678
\"
, got
\"
%s
\"\n
"
,
buffer
);
}
START_TEST
(
string
)
{
char
mem
[
100
];
...
...
@@ -1302,6 +1395,7 @@ START_TEST(string)
pmbstowcs_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"mbstowcs_s"
);
pwcstombs_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"wcstombs_s"
);
p_gcvt_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_gcvt_s"
);
p_itoa_s
=
(
void
*
)
GetProcAddress
(
hMsvcrt
,
"_itoa_s"
);
/* MSVCRT memcpy behaves like memmove for overlapping moves,
MFC42 CString::Insert seems to rely on that behaviour */
...
...
@@ -1336,4 +1430,5 @@ START_TEST(string)
test__strtod
();
test_mbstowcs
();
test_gcvt
();
test__itoa_s
();
}
include/msvcrt/stdlib.h
View file @
bcfaf467
...
...
@@ -148,6 +148,7 @@ char* __cdecl _fullpath(char*,const char*,size_t);
char
*
__cdecl
_gcvt
(
double
,
int
,
char
*
);
char
*
__cdecl
_i64toa
(
__int64
,
char
*
,
int
);
char
*
__cdecl
_itoa
(
int
,
char
*
,
int
);
errno_t
__cdecl
_itoa_s
(
int
,
char
*
,
size_t
,
int
);
char
*
__cdecl
_ltoa
(
__msvcrt_long
,
char
*
,
int
);
__msvcrt_ulong
__cdecl
_lrotl
(
__msvcrt_ulong
,
int
);
__msvcrt_ulong
__cdecl
_lrotr
(
__msvcrt_ulong
,
int
);
...
...
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