From 52ee62172a8573352dd62121c70de81117db782a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 7 Oct 2017 10:43:21 +0800 Subject: [PATCH] Regex: remove use of buffer_utils.hh from regex_impl.cc --- src/regex.cc | 10 ++++++++-- src/regex_impl.cc | 21 +++++---------------- src/regex_impl.hh | 4 ++-- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/regex.cc b/src/regex.cc index a622269b..25ace466 100644 --- a/src/regex.cc +++ b/src/regex.cc @@ -11,8 +11,14 @@ using Utf8It = RegexUtf8It; Regex::Regex(StringView re, flag_type flags) try : RegexBase{Utf8It{re.begin(), re}, Utf8It{re.end(), re}, flags}, m_str{re.str()} { - if (auto compiled_regex = compile_regex(re)) - m_impl = new CompiledRegex{std::move(compiled_regex)}; + try + { + m_impl = new CompiledRegex{compile_regex(re)}; + } + catch (runtime_error& err) + { + write_to_debug_buffer(err.what()); + } } catch (std::runtime_error& err) { throw regex_error(err.what()); } String option_to_string(const Regex& re) diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 66426aae..0c40b21e 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -1,14 +1,12 @@ #include "regex_impl.hh" -#include "vector.hh" -#include "unit_tests.hh" + +#include "exception.hh" #include "string.hh" #include "unicode.hh" +#include "unit_tests.hh" #include "utf8.hh" #include "utf8_iterator.hh" -#include "exception.hh" -#include "array_view.hh" - -#include "buffer_utils.hh" +#include "vector.hh" namespace Kakoune { @@ -873,16 +871,7 @@ void dump_regex(const CompiledRegex& program) CompiledRegex compile_regex(StringView re) { - CompiledRegex res; - try - { - res = RegexCompiler::compile(re); - } - catch (runtime_error& err) - { - write_to_debug_buffer(err.what()); - } - return std::move(res); + return RegexCompiler::compile(re); } auto test_regex = UnitTest{[]{ diff --git a/src/regex_impl.hh b/src/regex_impl.hh index 0cc1d23f..16daba22 100644 --- a/src/regex_impl.hh +++ b/src/regex_impl.hh @@ -1,12 +1,12 @@ #ifndef regex_impl_hh_INCLUDED #define regex_impl_hh_INCLUDED +#include "flags.hh" +#include "ref_ptr.hh" #include "unicode.hh" #include "utf8.hh" #include "utf8_iterator.hh" #include "vector.hh" -#include "flags.hh" -#include "ref_ptr.hh" #include