Skip to content

Commit

Permalink
Adjust formatting of compile-time error messages to suit gcc <= 9
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaskosunen committed Jan 15, 2024
1 parent 43d3be8 commit 5f20acc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
6 changes: 2 additions & 4 deletions include/scn/detail/format_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ constexpr typename ParseCtx::iterator parse_format_specs(ParseCtx& parse_ctx)
specs.type == presentation_type::regex_escaped) &&
!(ranges::range<Source> && ranges::contiguous_range<Source>)) {
// clang-format off
parse_ctx.on_error("Cannot read a regex from a non-contiguous "
"source");
parse_ctx.on_error("Cannot read a regex from a non-contiguous source");
// clang-format on
}
}
Expand Down Expand Up @@ -502,8 +501,7 @@ class format_string_checker {
if (m_types[id] == arg_type::narrow_regex_matches_type ||
m_types[id] == arg_type::wide_regex_matches_type) {
// clang-format off
return on_error("Regular expression needs to be specified "
"when reading regex_matches");
return on_error("Regular expression needs to be specified when reading regex_matches");
// clang-format on
}
}
Expand Down
30 changes: 10 additions & 20 deletions include/scn/detail/format_string_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,7 @@ constexpr void parse_presentation_set_literal(const CharT*& begin,

if (SCN_UNLIKELY(cp_second < cp_first)) {
// clang-format off
handler.on_error("Invalid range in [character set] format string "
"argument: Range end before the beginning");
handler.on_error("Invalid range in [character set] format string argument: Range end before the beginning");
// clang-format on
return;
}
Expand All @@ -564,8 +563,7 @@ constexpr std::basic_string_view<CharT> parse_presentation_set(

if (SCN_UNLIKELY(begin == end)) {
// clang-format off
handler.on_error("Unexpected end of [character set] specifier "
"in format string");
handler.on_error("Unexpected end of [character set] specifier in format string");
// clang-format on
return {};
}
Expand Down Expand Up @@ -674,15 +672,13 @@ constexpr const CharT* parse_presentation_regex(const CharT*& begin,
#if SCN_REGEX_BACKEND == SCN_REGEX_BACKEND_STD
if (*begin == CharT{'s'}) {
// clang-format off
handler.on_error("/s flag for regex isn't supported "
"by regex backend");
handler.on_error("/s flag for regex isn't supported by regex backend");
// clang-format on
}
#if !SCN_HAS_STD_REGEX_MULTILINE
if (*begin == CharT{'m'}) {
// clang-format off
handler.on_error("/m flag for regex isn't supported "
"by regex backend");
handler.on_error("/m flag for regex isn't supported by regex backend");
// clang-format on
}
#endif
Expand Down Expand Up @@ -720,8 +716,7 @@ constexpr const CharT* parse_format_specs(const CharT* begin,
auto set = parse_presentation_set(begin, end, handler);
if (SCN_UNLIKELY(set.size() <= 2)) {
// clang-format off
handler.on_error("Invalid (empty) [character set] specifier "
"in format string");
handler.on_error("Invalid (empty) [character set] specifier in format string");
// clang-format on
return begin;
}
Expand Down Expand Up @@ -979,8 +974,7 @@ class specs_checker : public Handler {
cat != arg_type_category::boolean) {
SCN_UNLIKELY_ATTR
// clang-format off
return this->on_error("'L' specifier can only be used "
"with arguments of integer, floating-point, or boolean types");
return this->on_error("'L' specifier can only be used with arguments of integer, floating-point, or boolean types");
// clang-format on
}

Expand All @@ -1001,15 +995,13 @@ constexpr void check_int_type_specs(const basic_format_specs<CharT>& specs,
if (specs.localized) {
if (SCN_UNLIKELY(specs.type == presentation_type::int_binary)) {
// clang-format off
handler.on_error("'b'/'B' specifier not supported for localized "
"integers");
handler.on_error("'b'/'B' specifier not supported for localized integers");
// clang-format on
return;
}
if (SCN_UNLIKELY(specs.type == presentation_type::int_arbitrary_base)) {
// clang-format off
return handler.on_error("Arbitrary bases not supported "
"for localized integers");
return handler.on_error("Arbitrary bases not supported for localized integers");
// clang-format on
}
}
Expand Down Expand Up @@ -1064,8 +1056,7 @@ constexpr void check_string_type_specs(const basic_format_specs<CharT>& specs,
if (specs.type == presentation_type::character) {
if (SCN_UNLIKELY(specs.width == 0)) {
// clang-format off
return handler.on_error("'c' type specifier for strings requires "
"the field width to be specified");
return handler.on_error("'c' type specifier for strings requires the field width to be specified");
// clang-format on
}
return;
Expand Down Expand Up @@ -1109,8 +1100,7 @@ constexpr void check_regex_type_specs(const basic_format_specs<CharT>& specs,
if (SCN_UNLIKELY(specs.type == presentation_type::none ||
specs.charset_string.empty())) {
// clang-format off
return handler.on_error("Regular expression needs to specified "
"when reading regex_matches");
return handler.on_error("Regular expression needs to specified when reading regex_matches");
// clang-format on
}
if (specs.type == presentation_type::regex ||
Expand Down
9 changes: 3 additions & 6 deletions include/scn/detail/parse_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,15 @@ class compile_parse_context : public basic_scan_parse_context<CharT> {
type == arg_type::wide_string_view_type) &&
!m_is_contiguous) {
// clang-format off
this->
on_error("Cannot read a string_view from a non-contiguous source");
this->on_error("Cannot read a string_view from a non-contiguous source");
// clang-format on
return;
}
if ((type == arg_type::narrow_string_view_type ||
type == arg_type::wide_string_view_type) &&
!m_is_borrowed) {
// clang-format off
this->
on_error("Cannot read a string_view from a non-borrowed source");
this->on_error("Cannot read a string_view from a non-borrowed source");
// clang-format on
return;
}
Expand All @@ -180,8 +178,7 @@ class compile_parse_context : public basic_scan_parse_context<CharT> {
type == arg_type::wide_regex_matches_type) &&
!m_is_contiguous) {
// clang-format off
this->
on_error("Cannot read a regex_matches from a non-contiguous source");
this->on_error("Cannot read a regex_matches from a non-contiguous source");
// clang-format on
return;
}
Expand Down

0 comments on commit 5f20acc

Please sign in to comment.