mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 11:48:54 +02:00
ircd::spirit: Increase expectation rule buffer size.
ircd::spirit: Simplify expectation failure wrapper.
This commit is contained in:
parent
cd2a71d3c2
commit
231bcf3f95
2 changed files with 7 additions and 27 deletions
|
@ -15,10 +15,11 @@ namespace ircd {
|
||||||
namespace spirit
|
namespace spirit
|
||||||
__attribute__((visibility("default")))
|
__attribute__((visibility("default")))
|
||||||
{
|
{
|
||||||
template<class parent_error> struct expectation_failure;
|
template<class parent_error>
|
||||||
|
struct expectation_failure;
|
||||||
|
|
||||||
// parse.cc
|
// parse.cc
|
||||||
extern thread_local char rule_buffer[64];
|
extern thread_local char rule_buffer[128];
|
||||||
}}
|
}}
|
||||||
|
|
||||||
template<class parent_error>
|
template<class parent_error>
|
||||||
|
@ -28,12 +29,7 @@ ircd::spirit::expectation_failure
|
||||||
{
|
{
|
||||||
template<class it = const char *>
|
template<class it = const char *>
|
||||||
expectation_failure(const qi::expectation_failure<it> &e,
|
expectation_failure(const qi::expectation_failure<it> &e,
|
||||||
const ssize_t &show_max = 64);
|
const ssize_t &show_max = 128);
|
||||||
|
|
||||||
template<class it = const char *>
|
|
||||||
expectation_failure(const qi::expectation_failure<it> &e,
|
|
||||||
const it &start,
|
|
||||||
const ssize_t &show_max = 64);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class parent>
|
template<class parent>
|
||||||
|
@ -42,25 +38,9 @@ ircd::spirit::expectation_failure<parent>::expectation_failure(const qi::expecta
|
||||||
const ssize_t &show_max)
|
const ssize_t &show_max)
|
||||||
:parent
|
:parent
|
||||||
{
|
{
|
||||||
"Expected %s. You input %zd invalid characters :%s",
|
"expected %s with %zu characters remaining '%s'...",
|
||||||
ircd::string(rule_buffer, e.what_),
|
ircd::string(rule_buffer, e.what_),
|
||||||
std::distance(e.first, e.last),
|
std::distance(e.first, e.last),
|
||||||
string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)}
|
string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)}
|
||||||
}
|
}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<class parent>
|
|
||||||
template<class it>
|
|
||||||
ircd::spirit::expectation_failure<parent>::expectation_failure(const qi::expectation_failure<it> &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)}
|
|
||||||
}
|
|
||||||
{}
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ __attribute__((visibility("internal")))
|
||||||
bool parse(const char *&start, const char *const &stop, gen&&, attr&&...);
|
bool parse(const char *&start, const char *const &stop, gen&&, attr&&...);
|
||||||
|
|
||||||
template<class parent_error,
|
template<class parent_error,
|
||||||
size_t error_show_max = 48,
|
size_t error_show_max = 128,
|
||||||
class gen,
|
class gen,
|
||||||
class... attr>
|
class... attr>
|
||||||
bool parse(const char *&start, const char *const &stop, gen&&, attr&&...);
|
bool parse(const char *&start, const char *const &stop, gen&&, attr&&...);
|
||||||
|
@ -159,7 +159,7 @@ catch(const qi::expectation_failure<const char *> &e)
|
||||||
{
|
{
|
||||||
throw expectation_failure<parent_error>
|
throw expectation_failure<parent_error>
|
||||||
{
|
{
|
||||||
e, start, error_show_max
|
e, error_show_max
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue