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
7a57f02b
Commit
7a57f02b
authored
Jan 29, 2011
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 31, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Implement _fcvt_s().
parent
9d432ff7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
123 additions
and
9 deletions
+123
-9
msvcr100.spec
dlls/msvcr100/msvcr100.spec
+1
-1
msvcr80.spec
dlls/msvcr80/msvcr80.spec
+1
-1
msvcr90.spec
dlls/msvcr90/msvcr90.spec
+1
-1
math.c
dlls/msvcrt/math.c
+89
-0
msvcrt.spec
dlls/msvcrt/msvcrt.spec
+1
-1
printf.c
dlls/msvcrt/tests/printf.c
+30
-5
No files found.
dlls/msvcr100/msvcr100.spec
View file @
7a57f02b
...
@@ -606,7 +606,7 @@
...
@@ -606,7 +606,7 @@
@ stub _fclose_nolock
@ stub _fclose_nolock
@ cdecl _fcloseall() msvcrt._fcloseall
@ cdecl _fcloseall() msvcrt._fcloseall
@ cdecl _fcvt(double long ptr ptr) msvcrt._fcvt
@ cdecl _fcvt(double long ptr ptr) msvcrt._fcvt
@
stub
_fcvt_s
@
cdecl _fcvt_s(ptr long double long ptr ptr) msvcrt.
_fcvt_s
@ cdecl _fdopen(long str) msvcrt._fdopen
@ cdecl _fdopen(long str) msvcrt._fdopen
@ stub _fflush_nolock
@ stub _fflush_nolock
@ cdecl _fgetchar() msvcrt._fgetchar
@ cdecl _fgetchar() msvcrt._fgetchar
...
...
dlls/msvcr80/msvcr80.spec
View file @
7a57f02b
...
@@ -447,7 +447,7 @@
...
@@ -447,7 +447,7 @@
@ stub _fclose_nolock
@ stub _fclose_nolock
@ cdecl _fcloseall() msvcrt._fcloseall
@ cdecl _fcloseall() msvcrt._fcloseall
@ cdecl _fcvt(double long ptr ptr) msvcrt._fcvt
@ cdecl _fcvt(double long ptr ptr) msvcrt._fcvt
@
stub
_fcvt_s
@
cdecl _fcvt_s(ptr long double long ptr ptr) msvcrt.
_fcvt_s
@ cdecl _fdopen(long str) msvcrt._fdopen
@ cdecl _fdopen(long str) msvcrt._fdopen
@ stub _fflush_nolock
@ stub _fflush_nolock
@ cdecl _fgetchar() msvcrt._fgetchar
@ cdecl _fgetchar() msvcrt._fgetchar
...
...
dlls/msvcr90/msvcr90.spec
View file @
7a57f02b
...
@@ -439,7 +439,7 @@
...
@@ -439,7 +439,7 @@
@ stub _fclose_nolock
@ stub _fclose_nolock
@ cdecl _fcloseall() msvcrt._fcloseall
@ cdecl _fcloseall() msvcrt._fcloseall
@ cdecl _fcvt(double long ptr ptr) msvcrt._fcvt
@ cdecl _fcvt(double long ptr ptr) msvcrt._fcvt
@
stub
_fcvt_s
@
cdecl _fcvt_s(ptr long double long ptr ptr) msvcrt.
_fcvt_s
@ cdecl _fdopen(long str) msvcrt._fdopen
@ cdecl _fdopen(long str) msvcrt._fdopen
@ stub _fflush_nolock
@ stub _fflush_nolock
@ cdecl _fgetchar() msvcrt._fgetchar
@ cdecl _fgetchar() msvcrt._fgetchar
...
...
dlls/msvcrt/math.c
View file @
7a57f02b
...
@@ -1423,6 +1423,95 @@ char * CDECL _fcvt( double number, int ndigits, int *decpt, int *sign )
...
@@ -1423,6 +1423,95 @@ char * CDECL _fcvt( double number, int ndigits, int *decpt, int *sign )
}
}
/***********************************************************************
/***********************************************************************
* _fcvt_s (MSVCRT.@)
*/
int
CDECL
_fcvt_s
(
char
*
outbuffer
,
MSVCRT_size_t
size
,
double
number
,
int
ndigits
,
int
*
decpt
,
int
*
sign
)
{
int
stop
,
dec1
,
dec2
;
char
*
ptr1
,
*
ptr2
,
*
first
;
char
buf
[
80
];
/* ought to be enough */
if
(
!
outbuffer
||
!
decpt
||
!
sign
||
size
==
0
)
{
*
MSVCRT__errno
()
=
MSVCRT_EINVAL
;
return
MSVCRT_EINVAL
;
}
if
(
number
<
0
)
{
*
sign
=
1
;
number
=
-
number
;
}
else
*
sign
=
0
;
snprintf
(
buf
,
80
,
"%.*f"
,
ndigits
<
0
?
0
:
ndigits
,
number
);
ptr1
=
buf
;
ptr2
=
outbuffer
;
first
=
NULL
;
dec1
=
0
;
dec2
=
0
;
/* For numbers below the requested resolution, work out where
the decimal point will be rather than finding it in the string */
if
(
number
<
1
.
0
&&
number
>
0
.
0
)
{
dec2
=
log10
(
number
+
1e-10
);
if
(
-
dec2
<=
ndigits
)
dec2
=
0
;
}
/* If requested digits is zero or less, we will need to truncate
* the returned string */
if
(
ndigits
<
1
)
{
stop
=
strlen
(
buf
)
+
ndigits
;
}
else
{
stop
=
strlen
(
buf
);
}
while
(
*
ptr1
==
'0'
)
ptr1
++
;
/* Skip leading zeroes */
while
(
*
ptr1
!=
'\0'
&&
*
ptr1
!=
'.'
)
{
if
(
!
first
)
first
=
ptr2
;
if
((
ptr1
-
buf
)
<
stop
)
{
if
(
size
>
1
)
{
*
ptr2
++
=
*
ptr1
++
;
size
--
;
}
}
else
{
ptr1
++
;
}
dec1
++
;
}
if
(
ndigits
>
0
)
{
ptr1
++
;
if
(
!
first
)
{
while
(
*
ptr1
==
'0'
)
{
/* Process leading zeroes */
if
(
number
==
0
.
0
&&
size
>
1
)
{
*
ptr2
++
=
'0'
;
size
--
;
}
ptr1
++
;
dec1
--
;
}
}
while
(
*
ptr1
!=
'\0'
)
{
if
(
!
first
)
first
=
ptr2
;
if
(
size
>
1
)
{
*
ptr2
++
=
*
ptr1
++
;
size
--
;
}
}
}
*
ptr2
=
'\0'
;
/* We never found a non-zero digit, then our number is either
* smaller than the requested precision, or 0.0 */
if
(
!
first
&&
(
number
<=
0
.
0
))
dec1
=
0
;
*
decpt
=
dec2
?
dec2
:
dec1
;
return
0
;
}
/***********************************************************************
* _gcvt (MSVCRT.@)
* _gcvt (MSVCRT.@)
*/
*/
char
*
CDECL
_gcvt
(
double
number
,
int
ndigit
,
char
*
buff
)
char
*
CDECL
_gcvt
(
double
number
,
int
ndigit
,
char
*
buff
)
...
...
dlls/msvcrt/msvcrt.spec
View file @
7a57f02b
...
@@ -400,7 +400,7 @@
...
@@ -400,7 +400,7 @@
# stub _expand_dbg
# stub _expand_dbg
@ cdecl _fcloseall() MSVCRT__fcloseall
@ cdecl _fcloseall() MSVCRT__fcloseall
@ cdecl _fcvt(double long ptr ptr)
@ cdecl _fcvt(double long ptr ptr)
# stub _fcvt_s
@ cdecl _fcvt_s(ptr long double long ptr ptr)
@ cdecl _fdopen(long str) MSVCRT__fdopen
@ cdecl _fdopen(long str) MSVCRT__fdopen
@ cdecl _fgetchar()
@ cdecl _fgetchar()
@ cdecl _fgetwchar()
@ cdecl _fgetwchar()
...
...
dlls/msvcrt/tests/printf.c
View file @
7a57f02b
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#define _CRT_NON_CONFORMING_SWPRINTFS
#define _CRT_NON_CONFORMING_SWPRINTFS
#include <stdio.h>
#include <stdio.h>
#include <errno.h>
#include "windef.h"
#include "windef.h"
#include "winbase.h"
#include "winbase.h"
...
@@ -760,7 +761,7 @@ static struct {
...
@@ -760,7 +761,7 @@ static struct {
{
0
.
4
,
0
,
""
,
""
,
0
,
0
,
0
},
{
0
.
4
,
0
,
""
,
""
,
0
,
0
,
0
},
{
0
.
49
,
0
,
""
,
""
,
0
,
0
,
0
},
{
0
.
49
,
0
,
""
,
""
,
0
,
0
,
0
},
{
0
.
51
,
0
,
""
,
"1"
,
1
,
1
,
0
},
{
0
.
51
,
0
,
""
,
"1"
,
1
,
1
,
0
},
/* ask
ridiculous amunt of
precision, ruin formatting this table */
/* ask
for ridiculous
precision, ruin formatting this table */
{
1
.
0
,
30
,
"100000000000000000000000000000"
,
{
1
.
0
,
30
,
"100000000000000000000000000000"
,
"1000000000000000000000000000000"
,
1
,
1
,
0
},
"1000000000000000000000000000000"
,
1
,
1
,
0
},
{
123456789012345678901
.
0
,
30
,
"123456789012345680000000000000"
,
{
123456789012345678901
.
0
,
30
,
"123456789012345680000000000000"
,
...
@@ -773,6 +774,7 @@ static void test_xcvt(void)
...
@@ -773,6 +774,7 @@ static void test_xcvt(void)
{
{
char
*
str
;
char
*
str
;
int
i
,
decpt
,
sign
,
err
;
int
i
,
decpt
,
sign
,
err
;
for
(
i
=
0
;
strcmp
(
test_cvt_testcases
[
i
].
expstr_e
,
"END"
);
i
++
){
for
(
i
=
0
;
strcmp
(
test_cvt_testcases
[
i
].
expstr_e
,
"END"
);
i
++
){
decpt
=
sign
=
100
;
decpt
=
sign
=
100
;
str
=
_ecvt
(
test_cvt_testcases
[
i
].
value
,
str
=
_ecvt
(
test_cvt_testcases
[
i
].
value
,
...
@@ -830,17 +832,40 @@ static void test_xcvt(void)
...
@@ -830,17 +832,40 @@ static void test_xcvt(void)
if
(
p__fcvt_s
)
if
(
p__fcvt_s
)
{
{
int
i
;
str
=
malloc
(
1024
);
str
=
malloc
(
1024
);
/* invalid arguments */
err
=
p__fcvt_s
(
NULL
,
0
,
0
.
0
,
0
,
&
i
,
&
i
);
ok
(
err
==
EINVAL
,
"got %d, expected EINVAL
\n
"
,
err
);
err
=
p__fcvt_s
(
str
,
0
,
0
.
0
,
0
,
&
i
,
&
i
);
ok
(
err
==
EINVAL
,
"got %d, expected EINVAL
\n
"
,
err
);
str
[
0
]
=
' '
;
str
[
1
]
=
0
;
err
=
p__fcvt_s
(
str
,
-
1
,
0
.
0
,
0
,
&
i
,
&
i
);
ok
(
err
==
0
,
"got %d, expected 0
\n
"
,
err
);
ok
(
str
[
0
]
==
0
,
"got %c, expected 0
\n
"
,
str
[
0
]);
ok
(
str
[
1
]
==
0
,
"got %c, expected 0
\n
"
,
str
[
1
]);
err
=
p__fcvt_s
(
str
,
1
,
0
.
0
,
0
,
NULL
,
&
i
);
ok
(
err
==
EINVAL
,
"got %d, expected EINVAL
\n
"
,
err
);
err
=
p__fcvt_s
(
str
,
1
,
0
.
0
,
0
,
&
i
,
NULL
);
ok
(
err
==
EINVAL
,
"got %d, expected EINVAL
\n
"
,
err
);
for
(
i
=
0
;
strcmp
(
test_cvt_testcases
[
i
].
expstr_e
,
"END"
);
i
++
){
for
(
i
=
0
;
strcmp
(
test_cvt_testcases
[
i
].
expstr_e
,
"END"
);
i
++
){
decpt
=
sign
=
100
;
decpt
=
sign
=
100
;
err
=
p__fcvt_s
(
str
,
1024
,
test_cvt_testcases
[
i
].
value
,
test_cvt_testcases
[
i
].
nrdigits
,
&
decpt
,
&
sign
);
err
=
p__fcvt_s
(
str
,
1024
,
test_cvt_testcases
[
i
].
value
,
test_cvt_testcases
[
i
].
nrdigits
,
&
decpt
,
&
sign
);
ok
(
err
==
0
,
"_fcvt_s() failed with error code %d"
,
err
);
ok
(
err
==
0
,
"_fcvt_s() failed with error code %d"
,
err
);
ok
(
0
==
strncmp
(
str
,
test_cvt_testcases
[
i
].
expstr_f
,
15
),
ok
(
0
==
strncmp
(
str
,
test_cvt_testcases
[
i
].
expstr_f
,
15
),
"_fcvt_s() bad return, got
\n
'%s' expected
\n
'%s'
\n
"
,
str
,
"_fcvt_s() bad return, got
'%s' expected '%s'. test %d
\n
"
,
str
,
test_cvt_testcases
[
i
].
expstr_
e
);
test_cvt_testcases
[
i
].
expstr_
f
,
i
);
ok
(
decpt
==
test_cvt_testcases
[
i
].
expdecpt_f
,
ok
(
decpt
==
test_cvt_testcases
[
i
].
expdecpt_f
,
"_fcvt_s() decimal point wrong, got %d expected %d
\n
"
,
decpt
,
"_fcvt_s() decimal point wrong, got %d expected %d
\n
"
,
decpt
,
test_cvt_testcases
[
i
].
expdecpt_
e
);
test_cvt_testcases
[
i
].
expdecpt_
f
);
ok
(
sign
==
test_cvt_testcases
[
i
].
expsign
,
ok
(
sign
==
test_cvt_testcases
[
i
].
expsign
,
"_fcvt_s() sign wrong, got %d expected %d
\n
"
,
sign
,
"_fcvt_s() sign wrong, got %d expected %d
\n
"
,
sign
,
test_cvt_testcases
[
i
].
expsign
);
test_cvt_testcases
[
i
].
expsign
);
...
@@ -848,7 +873,7 @@ static void test_xcvt(void)
...
@@ -848,7 +873,7 @@ static void test_xcvt(void)
free
(
str
);
free
(
str
);
}
}
else
else
todo_wine
win_skip
(
"_fcvt_s not available
\n
"
);
win_skip
(
"_fcvt_s not available
\n
"
);
}
}
static
int
__cdecl
_vsnwprintf_wrapper
(
wchar_t
*
str
,
size_t
len
,
const
wchar_t
*
format
,
...)
static
int
__cdecl
_vsnwprintf_wrapper
(
wchar_t
*
str
,
size_t
len
,
const
wchar_t
*
format
,
...)
...
...
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