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
c1e97392
Commit
c1e97392
authored
Aug 11, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings
parent
4e99e09b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
17 deletions
+20
-17
include/fmt/chrono.h
include/fmt/chrono.h
+1
-1
include/fmt/compile.h
include/fmt/compile.h
+1
-1
include/fmt/format.h
include/fmt/format.h
+15
-12
include/fmt/safe-duration-cast.h
include/fmt/safe-duration-cast.h
+2
-2
test/format-test.cc
test/format-test.cc
+1
-1
No files found.
include/fmt/chrono.h
View file @
c1e97392
...
...
@@ -520,7 +520,7 @@ struct chrono_formatter {
std
::
chrono
::
duration
<
Rep
,
Period
>
d
)
:
context
(
ctx
),
out
(
o
),
val
(
d
.
count
()),
negative
(
false
)
{
if
(
d
.
count
()
<
0
)
{
val
=
-
val
;
val
=
0
-
val
;
negative
=
true
;
}
...
...
include/fmt/compile.h
View file @
c1e97392
...
...
@@ -358,7 +358,7 @@ template <typename Format> class compiletime_prepared_parts_type_provider {
using
value_type
=
format_part
<
char_type
>
;
};
using
type
=
conditional_t
<
static_cast
<
bool
>
(
number_of_format_parts
)
,
using
type
=
conditional_t
<
number_of_format_parts
!=
0
,
format_parts_array
<
number_of_format_parts
>
,
empty
>
;
};
...
...
include/fmt/format.h
View file @
c1e97392
...
...
@@ -1741,11 +1741,14 @@ class arg_formatter_base {
}
void
write
(
const
char_type
*
value
)
{
if
(
!
value
)
FMT_THROW
(
format_error
(
"string pointer is null"
));
if
(
!
value
)
{
FMT_THROW
(
format_error
(
"string pointer is null"
));
}
else
{
auto
length
=
std
::
char_traits
<
char_type
>::
length
(
value
);
basic_string_view
<
char_type
>
sv
(
value
,
length
);
specs_
?
writer_
.
write
(
sv
,
*
specs_
)
:
writer_
.
write
(
sv
);
}
}
public:
arg_formatter_base
(
Range
r
,
format_specs
*
s
,
locale_ref
loc
)
...
...
@@ -1851,7 +1854,7 @@ FMT_CONSTEXPR int parse_nonnegative_int(const Char*& begin, const Char* end,
}
unsigned
value
=
0
;
// Convert to unsigned to prevent a warning.
unsigned
max_int
=
(
std
::
numeric_limits
<
int
>::
max
)();
constexpr
unsigned
max_int
=
(
std
::
numeric_limits
<
int
>::
max
)();
unsigned
big
=
max_int
/
10
;
do
{
// Check for overflow.
...
...
@@ -2054,7 +2057,7 @@ FMT_CONSTEXPR void set_dynamic_spec(T& value, FormatArg arg, ErrorHandler eh) {
struct
auto_id
{};
template
<
typename
Context
>
FMT_CONSTEXPR
typename
Context
::
format_arg
get_arg
(
Context
&
ctx
,
unsigned
id
)
{
FMT_CONSTEXPR
typename
Context
::
format_arg
get_arg
(
Context
&
ctx
,
int
id
)
{
auto
arg
=
ctx
.
arg
(
id
);
if
(
!
arg
)
ctx
.
on_error
(
"argument index out of range"
);
return
arg
;
...
...
@@ -2092,7 +2095,7 @@ class specs_handler : public specs_setter<typename Context::char_type> {
return
internal
::
get_arg
(
context_
,
parse_context_
.
next_arg_id
());
}
FMT_CONSTEXPR
format_arg
get_arg
(
unsigned
arg_id
)
{
FMT_CONSTEXPR
format_arg
get_arg
(
int
arg_id
)
{
parse_context_
.
check_arg_id
(
arg_id
);
return
internal
::
get_arg
(
context_
,
arg_id
);
}
...
...
@@ -2418,7 +2421,7 @@ inline bool find<false, char>(const char* first, const char* last, char value,
template
<
typename
Handler
,
typename
Char
>
struct
id_adapter
{
FMT_CONSTEXPR
void
operator
()()
{
handler
.
on_arg_id
();
}
FMT_CONSTEXPR
void
operator
()(
unsigned
id
)
{
handler
.
on_arg_id
(
id
);
}
FMT_CONSTEXPR
void
operator
()(
int
id
)
{
handler
.
on_arg_id
(
id
);
}
FMT_CONSTEXPR
void
operator
()(
basic_string_view
<
Char
>
id
)
{
handler
.
on_arg_id
(
id
);
}
...
...
@@ -2511,7 +2514,7 @@ class format_string_checker {
arg_id_
=
context_
.
next_arg_id
();
check_arg_id
();
}
FMT_CONSTEXPR
void
on_arg_id
(
unsigned
id
)
{
FMT_CONSTEXPR
void
on_arg_id
(
int
id
)
{
arg_id_
=
id
;
context_
.
check_arg_id
(
id
);
check_arg_id
();
...
...
@@ -2642,7 +2645,7 @@ class FMT_API system_error : public std::runtime_error {
protected:
int
error_code_
;
system_error
()
:
std
::
runtime_error
(
""
)
{}
system_error
()
:
std
::
runtime_error
(
""
)
,
error_code_
(
0
)
{}
public:
/**
...
...
@@ -3156,10 +3159,10 @@ struct format_handler : internal::error_handler {
context
.
advance_to
(
out
);
}
void
get_arg
(
unsigned
id
)
{
arg
=
internal
::
get_arg
(
context
,
id
);
}
void
get_arg
(
int
id
)
{
arg
=
internal
::
get_arg
(
context
,
id
);
}
void
on_arg_id
()
{
get_arg
(
parse_context
.
next_arg_id
());
}
void
on_arg_id
(
unsigned
id
)
{
void
on_arg_id
(
int
id
)
{
parse_context
.
check_arg_id
(
id
);
get_arg
(
id
);
}
...
...
include/fmt/safe-duration-cast.h
View file @
c1e97392
...
...
@@ -72,7 +72,7 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
// yes, From always fits in To.
}
else
{
// from may not fit in To, we have to do a dynamic check
if
(
from
>
T
::
max
(
))
{
if
(
from
>
static_cast
<
From
>
(
T
::
max
()
))
{
ec
=
1
;
return
{};
}
...
...
@@ -85,7 +85,7 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
// yes, From always fits in To.
}
else
{
// from may not fit in To, we have to do a dynamic check
if
(
from
>
T
::
max
(
))
{
if
(
from
>
static_cast
<
From
>
(
T
::
max
()
))
{
// outside range.
ec
=
1
;
return
{};
...
...
test/format-test.cc
View file @
c1e97392
...
...
@@ -1461,7 +1461,7 @@ TEST(FormatterTest, PrecisionRounding) {
// Trigger rounding error in Grisu by a carefully chosen number.
auto
n
=
3788512123356.985352
;
char
buffer
[
64
];
sprintf
(
buffer
,
"%f"
,
n
);
s
afe_s
printf
(
buffer
,
"%f"
,
n
);
EXPECT_EQ
(
buffer
,
format
(
"{:f}"
,
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