Regex: remove use of buffer_utils.hh from regex_impl.cc

This commit is contained in:
Maxime Coste 2017-10-07 10:43:21 +08:00
parent c375268c2d
commit 52ee62172a
3 changed files with 15 additions and 20 deletions

View File

@ -11,8 +11,14 @@ using Utf8It = RegexUtf8It<const char*>;
Regex::Regex(StringView re, flag_type flags) try Regex::Regex(StringView re, flag_type flags) try
: RegexBase{Utf8It{re.begin(), re}, Utf8It{re.end(), re}, flags}, m_str{re.str()} : RegexBase{Utf8It{re.begin(), re}, Utf8It{re.end(), re}, flags}, m_str{re.str()}
{ {
if (auto compiled_regex = compile_regex(re)) try
m_impl = new CompiledRegex{std::move(compiled_regex)}; {
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()); } } catch (std::runtime_error& err) { throw regex_error(err.what()); }
String option_to_string(const Regex& re) String option_to_string(const Regex& re)

View File

@ -1,14 +1,12 @@
#include "regex_impl.hh" #include "regex_impl.hh"
#include "vector.hh"
#include "unit_tests.hh" #include "exception.hh"
#include "string.hh" #include "string.hh"
#include "unicode.hh" #include "unicode.hh"
#include "unit_tests.hh"
#include "utf8.hh" #include "utf8.hh"
#include "utf8_iterator.hh" #include "utf8_iterator.hh"
#include "exception.hh" #include "vector.hh"
#include "array_view.hh"
#include "buffer_utils.hh"
namespace Kakoune namespace Kakoune
{ {
@ -873,16 +871,7 @@ void dump_regex(const CompiledRegex& program)
CompiledRegex compile_regex(StringView re) CompiledRegex compile_regex(StringView re)
{ {
CompiledRegex res; return RegexCompiler::compile(re);
try
{
res = RegexCompiler::compile(re);
}
catch (runtime_error& err)
{
write_to_debug_buffer(err.what());
}
return std::move(res);
} }
auto test_regex = UnitTest{[]{ auto test_regex = UnitTest{[]{

View File

@ -1,12 +1,12 @@
#ifndef regex_impl_hh_INCLUDED #ifndef regex_impl_hh_INCLUDED
#define regex_impl_hh_INCLUDED #define regex_impl_hh_INCLUDED
#include "flags.hh"
#include "ref_ptr.hh"
#include "unicode.hh" #include "unicode.hh"
#include "utf8.hh" #include "utf8.hh"
#include "utf8_iterator.hh" #include "utf8_iterator.hh"
#include "vector.hh" #include "vector.hh"
#include "flags.hh"
#include "ref_ptr.hh"
#include <string.h> #include <string.h>