From 231bcf3f95a01805e83f7168107c857d044370da Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 31 Oct 2020 01:15:57 -0700 Subject: [PATCH] ircd::spirit: Increase expectation rule buffer size. ircd::spirit: Simplify expectation failure wrapper. --- include/ircd/spirit/expectation_failure.h | 30 ++++------------------- include/ircd/spirit/parse.h | 4 +-- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/include/ircd/spirit/expectation_failure.h b/include/ircd/spirit/expectation_failure.h index 473776d63..256d3cd82 100644 --- a/include/ircd/spirit/expectation_failure.h +++ b/include/ircd/spirit/expectation_failure.h @@ -15,10 +15,11 @@ namespace ircd { namespace spirit __attribute__((visibility("default"))) { - template struct expectation_failure; + template + struct expectation_failure; // parse.cc - extern thread_local char rule_buffer[64]; + extern thread_local char rule_buffer[128]; }} template @@ -28,12 +29,7 @@ ircd::spirit::expectation_failure { template expectation_failure(const qi::expectation_failure &e, - const ssize_t &show_max = 64); - - template - expectation_failure(const qi::expectation_failure &e, - const it &start, - const ssize_t &show_max = 64); + const ssize_t &show_max = 128); }; template @@ -42,25 +38,9 @@ ircd::spirit::expectation_failure::expectation_failure(const qi::expecta const ssize_t &show_max) :parent { - "Expected %s. You input %zd invalid characters :%s", + "expected %s with %zu characters remaining '%s'...", ircd::string(rule_buffer, e.what_), std::distance(e.first, e.last), string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)} } {} - -template -template -ircd::spirit::expectation_failure::expectation_failure(const qi::expectation_failure &e, - const it &start, - const ssize_t &show_max) -:parent -{ - "Expected %s. You input %zd invalid characters somewhere between position %zd and %zd :%s", - ircd::string(rule_buffer, e.what_), - std::distance(e.first, e.last), - std::distance(start, e.first), - std::distance(start, e.last), - string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)} -} -{} diff --git a/include/ircd/spirit/parse.h b/include/ircd/spirit/parse.h index 67db6fdd2..3c4ba926a 100644 --- a/include/ircd/spirit/parse.h +++ b/include/ircd/spirit/parse.h @@ -27,7 +27,7 @@ __attribute__((visibility("internal"))) bool parse(const char *&start, const char *const &stop, gen&&, attr&&...); template bool parse(const char *&start, const char *const &stop, gen&&, attr&&...); @@ -159,7 +159,7 @@ catch(const qi::expectation_failure &e) { throw expectation_failure { - e, start, error_show_max + e, error_show_max }; }