Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
bc784d36
Commit
bc784d36
authored
Mar 17, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove isnan workaround
parent
53379dfd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
32 deletions
+14
-32
include/fmt/format.h
include/fmt/format.h
+14
-32
No files found.
include/fmt/format.h
View file @
bc784d36
...
@@ -296,8 +296,6 @@ typedef std::numeric_limits<internal::dummy_int> fputil;
...
@@ -296,8 +296,6 @@ typedef std::numeric_limits<internal::dummy_int> fputil;
// available.
// available.
inline
dummy_int
isinf
(...)
{
return
dummy_int
();
}
inline
dummy_int
isinf
(...)
{
return
dummy_int
();
}
inline
dummy_int
_finite
(...)
{
return
dummy_int
();
}
inline
dummy_int
_finite
(...)
{
return
dummy_int
();
}
inline
dummy_int
isnan
(...)
{
return
dummy_int
();
}
inline
dummy_int
_isnan
(...)
{
return
dummy_int
();
}
template
<
typename
Allocator
>
template
<
typename
Allocator
>
typename
Allocator
::
value_type
*
allocate
(
Allocator
&
alloc
,
std
::
size_t
n
)
{
typename
Allocator
::
value_type
*
allocate
(
Allocator
&
alloc
,
std
::
size_t
n
)
{
...
@@ -332,14 +330,6 @@ class numeric_limits<fmt::internal::dummy_int>
...
@@ -332,14 +330,6 @@ class numeric_limits<fmt::internal::dummy_int>
return
isinf
(
x
)
!=
0
;
return
isinf
(
x
)
!=
0
;
return
!
_finite
(
static_cast
<
double
>
(
x
));
return
!
_finite
(
static_cast
<
double
>
(
x
));
}
}
// Portable version of isnan.
template
<
typename
T
>
static
bool
isnotanumber
(
T
x
)
{
using
namespace
fmt
::
internal
;
if
(
const_check
(
sizeof
(
isnan
(
x
))
!=
sizeof
(
fmt
::
internal
::
dummy_int
)))
return
isnan
(
x
)
!=
0
;
return
_isnan
(
static_cast
<
double
>
(
x
))
!=
0
;
}
};
};
}
// namespace std
}
// namespace std
...
@@ -1200,8 +1190,7 @@ It grisu2_prettify(const char* digits, int size, int exp, It it,
...
@@ -1200,8 +1190,7 @@ It grisu2_prettify(const char* digits, int size, int exp, It it,
*
it
++
=
static_cast
<
Char
>
(
'.'
);
*
it
++
=
static_cast
<
Char
>
(
'.'
);
if
(
!
params
.
trailing_zeros
)
{
if
(
!
params
.
trailing_zeros
)
{
// Remove trailing zeros.
// Remove trailing zeros.
while
(
size
>
full_exp
&&
digits
[
size
-
1
]
==
'0'
)
while
(
size
>
full_exp
&&
digits
[
size
-
1
]
==
'0'
)
--
size
;
--
size
;
return
copy_str
<
Char
>
(
digits
+
full_exp
,
digits
+
size
,
it
);
return
copy_str
<
Char
>
(
digits
+
full_exp
,
digits
+
size
,
it
);
}
}
it
=
copy_str
<
Char
>
(
digits
+
full_exp
,
digits
+
size
,
it
);
it
=
copy_str
<
Char
>
(
digits
+
full_exp
,
digits
+
size
,
it
);
...
@@ -2849,22 +2838,15 @@ void basic_writer<Range>::write_double(T value, const format_specs& spec) {
...
@@ -2849,22 +2838,15 @@ void basic_writer<Range>::write_double(T value, const format_specs& spec) {
sign
=
spec
.
has
(
PLUS_FLAG
)
?
'+'
:
' '
;
sign
=
spec
.
has
(
PLUS_FLAG
)
?
'+'
:
' '
;
}
}
struct
write_inf_or_nan_t
{
if
(
!
std
::
isfinite
(
value
))
{
basic_writer
&
writer
;
format_specs
spec
;
char
sign
;
bool
as_percentage
;
void
operator
()(
const
char
*
str
)
const
{
writer
.
write_padded
(
spec
,
inf_or_nan_writer
{
sign
,
as_percentage
,
str
});
}
}
write_inf_or_nan
=
{
*
this
,
spec
,
sign
,
handler
.
as_percentage
};
// Format infinity and NaN ourselves because sprintf's output is not
// Format infinity and NaN ourselves because sprintf's output is not
// consistent across platforms.
// consistent across platforms.
if
(
internal
::
fputil
::
isinfinity
(
value
))
const
char
*
str
=
internal
::
fputil
::
isinfinity
(
value
)
return
write_inf_or_nan
(
handler
.
upper
?
"INF"
:
"inf"
);
?
(
handler
.
upper
?
"INF"
:
"inf"
)
if
(
internal
::
fputil
::
isnotanumber
(
value
))
:
(
handler
.
upper
?
"NAN"
:
"nan"
);
return
write_inf_or_nan
(
handler
.
upper
?
"NAN"
:
"nan"
);
return
write_padded
(
spec
,
inf_or_nan_writer
{
sign
,
handler
.
as_percentage
,
str
});
}
if
(
handler
.
as_percentage
)
value
*=
100
;
if
(
handler
.
as_percentage
)
value
*=
100
;
...
@@ -2872,8 +2854,8 @@ void basic_writer<Range>::write_double(T value, const format_specs& spec) {
...
@@ -2872,8 +2854,8 @@ void basic_writer<Range>::write_double(T value, const format_specs& spec) {
int
exp
=
0
;
int
exp
=
0
;
int
precision
=
spec
.
has_precision
()
||
!
spec
.
type
?
spec
.
precision
:
6
;
int
precision
=
spec
.
has_precision
()
||
!
spec
.
type
?
spec
.
precision
:
6
;
bool
use_grisu
=
fmt
::
internal
::
use_grisu
<
T
>
()
&&
bool
use_grisu
=
fmt
::
internal
::
use_grisu
<
T
>
()
&&
(
spec
.
type
!=
'a'
&&
spec
.
type
!=
'A'
&&
(
spec
.
type
!=
'a'
&&
spec
.
type
!=
'A'
&&
spec
.
type
!=
'e'
&&
spec
.
type
!=
'
e'
&&
spec
.
type
!=
'
E'
)
&&
spec
.
type
!=
'E'
)
&&
internal
::
grisu2_format
(
static_cast
<
double
>
(
value
),
buffer
,
internal
::
grisu2_format
(
static_cast
<
double
>
(
value
),
buffer
,
precision
,
handler
.
fixed
,
exp
);
precision
,
handler
.
fixed
,
exp
);
if
(
!
use_grisu
)
internal
::
sprintf_format
(
value
,
buffer
,
spec
);
if
(
!
use_grisu
)
internal
::
sprintf_format
(
value
,
buffer
,
spec
);
...
@@ -2898,8 +2880,8 @@ void basic_writer<Range>::write_double(T value, const format_specs& spec) {
...
@@ -2898,8 +2880,8 @@ void basic_writer<Range>::write_double(T value, const format_specs& spec) {
auto
params
=
internal
::
gen_digits_params
();
auto
params
=
internal
::
gen_digits_params
();
params
.
fixed
=
handler
.
fixed
;
params
.
fixed
=
handler
.
fixed
;
params
.
num_digits
=
precision
;
params
.
num_digits
=
precision
;
params
.
trailing_zeros
=
params
.
trailing_zeros
=
(
precision
!=
0
&&
(
handler
.
fixed
||
!
spec
.
type
))
||
(
precision
!=
0
&&
(
handler
.
fixed
||
!
spec
.
type
))
||
spec
.
has
(
HASH_FLAG
);
spec
.
has
(
HASH_FLAG
);
write_padded
(
as
,
grisu_writer
{
sign
,
buffer
,
exp
,
params
});
write_padded
(
as
,
grisu_writer
{
sign
,
buffer
,
exp
,
params
});
}
else
{
}
else
{
write_padded
(
as
,
double_writer
{
sign
,
buffer
});
write_padded
(
as
,
double_writer
{
sign
,
buffer
});
...
...
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