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
e4728409
Commit
e4728409
authored
Sep 06, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use throw_format_error in more places to reduce bloat
parent
e3ebf366
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
14 deletions
+10
-14
include/fmt/core.h
include/fmt/core.h
+3
-3
include/fmt/format-inl.h
include/fmt/format-inl.h
+4
-4
include/fmt/format.h
include/fmt/format.h
+3
-7
No files found.
include/fmt/core.h
View file @
e4728409
...
@@ -569,12 +569,14 @@ FMT_INLINE void check_format_string(const S&) {
...
@@ -569,12 +569,14 @@ FMT_INLINE void check_format_string(const S&) {
template
<
typename
...
,
typename
S
,
FMT_ENABLE_IF
(
is_compile_string
<
S
>
::
value
)
>
template
<
typename
...
,
typename
S
,
FMT_ENABLE_IF
(
is_compile_string
<
S
>
::
value
)
>
void
check_format_string
(
S
);
void
check_format_string
(
S
);
FMT_NORETURN
FMT_API
void
throw_format_error
(
const
char
*
message
);
struct
error_handler
{
struct
error_handler
{
constexpr
error_handler
()
=
default
;
constexpr
error_handler
()
=
default
;
constexpr
error_handler
(
const
error_handler
&
)
=
default
;
constexpr
error_handler
(
const
error_handler
&
)
=
default
;
// This function is intentionally not constexpr to give a compile-time error.
// This function is intentionally not constexpr to give a compile-time error.
FMT_NORETURN
FMT_API
void
on_error
(
const
char
*
message
);
void
on_error
(
const
char
*
message
)
{
throw_format_error
(
message
);
}
};
};
FMT_END_DETAIL_NAMESPACE
FMT_END_DETAIL_NAMESPACE
...
@@ -1922,8 +1924,6 @@ using sign_t = sign::type;
...
@@ -1922,8 +1924,6 @@ using sign_t = sign::type;
FMT_BEGIN_DETAIL_NAMESPACE
FMT_BEGIN_DETAIL_NAMESPACE
void
throw_format_error
(
const
char
*
message
);
// Workaround an array initialization issue in gcc 4.8.
// Workaround an array initialization issue in gcc 4.8.
template
<
typename
Char
>
struct
fill_t
{
template
<
typename
Char
>
struct
fill_t
{
private:
private:
...
...
include/fmt/format-inl.h
View file @
e4728409
...
@@ -40,6 +40,10 @@ FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
...
@@ -40,6 +40,10 @@ FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
std
::
terminate
();
std
::
terminate
();
}
}
FMT_FUNC
void
throw_format_error
(
const
char
*
message
)
{
FMT_THROW
(
format_error
(
message
));
}
#ifndef _MSC_VER
#ifndef _MSC_VER
# define FMT_SNPRINTF snprintf
# define FMT_SNPRINTF snprintf
#else // _MSC_VER
#else // _MSC_VER
...
@@ -2563,10 +2567,6 @@ FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
...
@@ -2563,10 +2567,6 @@ FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
format_error_code
(
out
,
error_code
,
message
);
format_error_code
(
out
,
error_code
,
message
);
}
}
FMT_FUNC
void
detail
::
error_handler
::
on_error
(
const
char
*
message
)
{
FMT_THROW
(
format_error
(
message
));
}
FMT_FUNC
void
report_system_error
(
int
error_code
,
FMT_FUNC
void
report_system_error
(
int
error_code
,
const
char
*
message
)
FMT_NOEXCEPT
{
const
char
*
message
)
FMT_NOEXCEPT
{
report_error
(
format_system_error
,
error_code
,
message
);
report_error
(
format_system_error
,
error_code
,
message
);
...
...
include/fmt/format.h
View file @
e4728409
...
@@ -841,10 +841,6 @@ constexpr auto compile_string_to_view(detail::std_string_view<Char> s)
...
@@ -841,10 +841,6 @@ constexpr auto compile_string_to_view(detail::std_string_view<Char> s)
FMT_BEGIN_DETAIL_NAMESPACE
FMT_BEGIN_DETAIL_NAMESPACE
inline
void
throw_format_error
(
const
char
*
message
)
{
FMT_THROW
(
format_error
(
message
));
}
template
<
typename
T
>
struct
is_integral
:
std
::
is_integral
<
T
>
{};
template
<
typename
T
>
struct
is_integral
:
std
::
is_integral
<
T
>
{};
template
<
>
struct
is_integral
<
int128_t
>
:
std
::
true_type
{};
template
<
>
struct
is_integral
<
int128_t
>
:
std
::
true_type
{};
template
<
>
struct
is_integral
<
uint128_t
>
:
std
::
true_type
{};
template
<
>
struct
is_integral
<
uint128_t
>
:
std
::
true_type
{};
...
@@ -1604,7 +1600,7 @@ FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg<T> arg,
...
@@ -1604,7 +1600,7 @@ FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg<T> arg,
case
presentation_type
:
:
chr
:
case
presentation_type
:
:
chr
:
return
write_char
(
out
,
static_cast
<
Char
>
(
abs_value
),
specs
);
return
write_char
(
out
,
static_cast
<
Char
>
(
abs_value
),
specs
);
default:
default:
FMT_THROW
(
format_error
(
"invalid type specifier"
)
);
throw_format_error
(
"invalid type specifier"
);
}
}
return
out
;
return
out
;
}
}
...
@@ -1926,7 +1922,7 @@ auto write(OutputIt out, T value, basic_format_specs<Char> specs,
...
@@ -1926,7 +1922,7 @@ auto write(OutputIt out, T value, basic_format_specs<Char> specs,
:
6
;
:
6
;
if
(
fspecs
.
format
==
float_format
::
exp
)
{
if
(
fspecs
.
format
==
float_format
::
exp
)
{
if
(
precision
==
max_value
<
int
>
())
if
(
precision
==
max_value
<
int
>
())
FMT_THROW
(
format_error
(
"number is too big"
)
);
throw_format_error
(
"number is too big"
);
else
else
++
precision
;
++
precision
;
}
}
...
@@ -2048,7 +2044,7 @@ template <typename Char, typename OutputIt>
...
@@ -2048,7 +2044,7 @@ template <typename Char, typename OutputIt>
FMT_CONSTEXPR_CHAR_TRAITS
auto
write
(
OutputIt
out
,
const
Char
*
value
)
FMT_CONSTEXPR_CHAR_TRAITS
auto
write
(
OutputIt
out
,
const
Char
*
value
)
->
OutputIt
{
->
OutputIt
{
if
(
!
value
)
{
if
(
!
value
)
{
FMT_THROW
(
format_error
(
"string pointer is null"
)
);
throw_format_error
(
"string pointer is null"
);
}
else
{
}
else
{
auto
length
=
std
::
char_traits
<
Char
>::
length
(
value
);
auto
length
=
std
::
char_traits
<
Char
>::
length
(
value
);
out
=
write
(
out
,
basic_string_view
<
Char
>
(
value
,
length
));
out
=
write
(
out
,
basic_string_view
<
Char
>
(
value
,
length
));
...
...
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