Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
d958ecbc
Commit
d958ecbc
authored
Dec 12, 2012
by
Piotr Caban
Committed by
Alexandre Julliard
Dec 12, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Fixed floating point numbers printing when flags.Sign=' '.
parent
101abcd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
17 deletions
+43
-17
printf.h
dlls/msvcrt/printf.h
+23
-17
printf.c
dlls/msvcrt/tests/printf.c
+20
-0
No files found.
dlls/msvcrt/printf.h
View file @
d958ecbc
...
...
@@ -78,7 +78,7 @@ static inline int FUNC_NAME(pf_fill)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ct
{
int
i
,
r
=
0
,
written
;
if
(
flags
->
Sign
&&
!
(
flags
->
Format
==
'd'
||
flags
->
Format
==
'i'
))
if
(
flags
->
Sign
&&
!
strchr
(
"diaeEfgG"
,
flags
->
Format
))
flags
->
Sign
=
0
;
if
(
left
&&
flags
->
Sign
)
{
...
...
@@ -228,18 +228,8 @@ static inline int FUNC_NAME(pf_handle_string)(FUNC_NAME(puts_clbk) pf_puts, void
static
inline
void
FUNC_NAME
(
pf_rebuild_format_string
)(
char
*
p
,
FUNC_NAME
(
pf_flags
)
*
flags
)
{
*
p
++
=
'%'
;
if
(
flags
->
Sign
)
*
p
++
=
flags
->
Sign
;
if
(
flags
->
LeftAlign
)
*
p
++
=
flags
->
LeftAlign
;
if
(
flags
->
Alternate
)
*
p
++
=
flags
->
Alternate
;
if
(
flags
->
PadZero
)
*
p
++
=
flags
->
PadZero
;
if
(
flags
->
FieldLength
)
{
sprintf
(
p
,
"%d"
,
flags
->
FieldLength
);
p
+=
strlen
(
p
);
}
if
(
flags
->
Precision
>=
0
)
{
sprintf
(
p
,
".%d"
,
flags
->
Precision
);
p
+=
strlen
(
p
);
...
...
@@ -541,8 +531,9 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
HeapFree
(
GetProcessHeap
(),
0
,
tmp
);
}
else
if
(
flags
.
Format
&&
strchr
(
"aeEfgG"
,
flags
.
Format
))
{
char
float_fmt
[
20
],
buf_a
[
32
],
*
tmp
=
buf_a
,
*
decimal_point
;
int
max_len
=
(
flags
.
FieldLength
>
flags
.
Precision
?
flags
.
FieldLength
:
flags
.
Precision
)
+
10
;
int
len
=
flags
.
Precision
+
10
;
double
val
=
pf_args
(
args_ctx
,
pos
,
VT_R8
,
valist
).
get_double
;
int
r
;
if
(
flags
.
Format
==
'f'
)
{
if
(
val
>-
10
.
0
&&
val
<
10
.
0
)
...
...
@@ -552,16 +543,20 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
/* Default precision is 6, additional space for sign, separator and nullbyte is required */
i
+=
(
flags
.
Precision
==-
1
?
6
:
flags
.
Precision
)
+
3
;
if
(
i
>
max_
len
)
max_
len
=
i
;
if
(
i
>
len
)
len
=
i
;
}
if
(
max_
len
>
sizeof
(
buf_a
))
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
max_
len
);
if
(
len
>
sizeof
(
buf_a
))
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
if
(
!
tmp
)
return
-
1
;
FUNC_NAME
(
pf_rebuild_format_string
)(
float_fmt
,
&
flags
);
if
(
val
<
0
)
{
flags
.
Sign
=
'-'
;
val
=
-
val
;
}
sprintf
(
tmp
,
float_fmt
,
val
);
if
(
toupper
(
flags
.
Format
)
==
'E'
||
toupper
(
flags
.
Format
)
==
'G'
)
...
...
@@ -571,9 +566,20 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
if
(
decimal_point
)
*
decimal_point
=
*
locinfo
->
lconv
->
decimal_point
;
i
=
FUNC_NAME
(
pf_output_str
)(
pf_puts
,
puts_ctx
,
tmp
,
strlen
(
tmp
),
locinfo
);
len
=
strlen
(
tmp
);
i
=
FUNC_NAME
(
pf_fill
)(
pf_puts
,
puts_ctx
,
len
,
&
flags
,
TRUE
);
if
(
i
<
0
)
return
i
;
r
=
FUNC_NAME
(
pf_output_str
)(
pf_puts
,
puts_ctx
,
tmp
,
len
,
locinfo
);
if
(
r
<
0
)
return
r
;
i
+=
r
;
if
(
tmp
!=
buf_a
)
HeapFree
(
GetProcessHeap
(),
0
,
tmp
);
r
=
FUNC_NAME
(
pf_fill
)(
pf_puts
,
puts_ctx
,
len
,
&
flags
,
FALSE
);
if
(
r
<
0
)
return
r
;
i
+=
r
;
}
else
{
if
(
invoke_invalid_param_handler
)
{
MSVCRT__invalid_parameter
(
NULL
,
NULL
,
NULL
,
0
,
0
);
...
...
dlls/msvcrt/tests/printf.c
View file @
d958ecbc
...
...
@@ -515,6 +515,26 @@ static void test_sprintf( void )
ok
(
!
strcmp
(
buffer
,
"8.6000e+000"
),
"failed
\n
"
);
ok
(
r
==
11
,
"return count wrong
\n
"
);
format
=
"% 2.4e"
;
r
=
sprintf
(
buffer
,
format
,
8
.
6
);
ok
(
!
strcmp
(
buffer
,
" 8.6000e+000"
),
"failed: %s
\n
"
,
buffer
);
ok
(
r
==
12
,
"return count wrong
\n
"
);
format
=
"% 014.4e"
;
r
=
sprintf
(
buffer
,
format
,
8
.
6
);
ok
(
!
strcmp
(
buffer
,
" 008.6000e+000"
),
"failed: %s
\n
"
,
buffer
);
ok
(
r
==
14
,
"return count wrong
\n
"
);
format
=
"% 2.4e"
;
r
=
sprintf
(
buffer
,
format
,
-
8
.
6
);
ok
(
!
strcmp
(
buffer
,
"-8.6000e+000"
),
"failed: %s
\n
"
,
buffer
);
ok
(
r
==
12
,
"return count wrong
\n
"
);
format
=
"%+2.4e"
;
r
=
sprintf
(
buffer
,
format
,
8
.
6
);
ok
(
!
strcmp
(
buffer
,
"+8.6000e+000"
),
"failed: %s
\n
"
,
buffer
);
ok
(
r
==
12
,
"return count wrong
\n
"
);
format
=
"%2.4g"
;
r
=
sprintf
(
buffer
,
format
,
8
.
6
);
ok
(
!
strcmp
(
buffer
,
"8.6"
),
"failed
\n
"
);
...
...
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