diff --git a/src/cmake.cc b/src/cmake.cc index 014964e..48e47d1 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -8,7 +8,7 @@ CMake::CMake(const boost::filesystem::path &path) { const auto find_cmake_project=[this](const boost::filesystem::path &cmake_path) { for(auto &line: filesystem::read_lines(cmake_path)) { - const boost::regex project_regex("^ *project *\\(.*$", boost::regex::icase); + const static boost::regex project_regex("^ *project *\\(.*$", boost::regex::icase); boost::smatch sm; if(boost::regex_match(line, sm, project_regex)) return true; @@ -207,7 +207,7 @@ void CMake::find_variables() { if(end_line>start_line) { auto line=file.substr(start_line, end_line-start_line); boost::smatch sm; - const boost::regex set_regex("^ *set *\\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\\) *$", boost::regex::icase); + const static boost::regex set_regex("^ *set *\\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\\) *$", boost::regex::icase); if(boost::regex_match(line, sm, set_regex)) { auto data=sm[2].str(); while(data.size()>0 && data.back()==' ') @@ -216,7 +216,7 @@ void CMake::find_variables() { variables[sm[1].str()]=data; } else { - const boost::regex project_regex("^ *project *\\( *([^ ]+).*\\) *$", boost::regex::icase); + const static boost::regex project_regex("^ *project *\\( *([^ ]+).*\\) *$", boost::regex::icase); if(boost::regex_match(line, sm, project_regex)) { auto data=sm[1].str(); parse_variable_parameters(data); diff --git a/src/source.cc b/src/source.cc index 63ad7c3..ee24f4b 100644 --- a/src/source.cc +++ b/src/source.cc @@ -79,6 +79,10 @@ std::string Source::FixIt::string(Glib::RefPtr buffer) { ////////////// //// View //// ////////////// +const boost::regex Source::View::bracket_regex("^([ \\t]*).*\\{ *$"); +const boost::regex Source::View::no_bracket_statement_regex("^([ \\t]*)(if|for|else if|while) *\\(.*[^;}] *$"); +const boost::regex Source::View::no_bracket_no_para_statement_regex("^([ \\t]*)(else) *$"); + AspellConfig* Source::View::spellcheck_config=NULL; Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr language): file_path(file_path), language(language) { @@ -271,10 +275,6 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtrget_id()=="chdr" || language->get_id()=="cpphdr" || language->get_id()=="c" || language->get_id()=="cpp" || language->get_id()=="objc" || language->get_id()=="java" || language->get_id()=="js" || language->get_id()=="ts" || language->get_id()=="proto" || diff --git a/src/source.h b/src/source.h index 33a3c2d..cdad7a1 100644 --- a/src/source.h +++ b/src/source.h @@ -138,9 +138,9 @@ namespace Source { bool find_right_bracket_forward(Gtk::TextIter iter, Gtk::TextIter &found_iter); bool find_left_bracket_backward(Gtk::TextIter iter, Gtk::TextIter &found_iter); - boost::regex bracket_regex; - boost::regex no_bracket_statement_regex; - boost::regex no_bracket_no_para_statement_regex; + const static boost::regex bracket_regex; + const static boost::regex no_bracket_statement_regex; + const static boost::regex no_bracket_no_para_statement_regex; bool on_key_press_event(GdkEventKey* key) override; bool on_key_press_event_basic(GdkEventKey* key); diff --git a/src/source_clang.cc b/src/source_clang.cc index 849a2f1..fde75d7 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -187,7 +187,7 @@ std::vector Source::ClangViewParse::get_compilation_commands() { } } auto clang_version_string=clang::to_string(clang_getClangVersion()); - const boost::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$"); + const static boost::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$"); boost::smatch sm; if(boost::regex_match(clang_version_string, sm, clang_version_regex)) { auto clang_version=sm[1].str(); @@ -634,8 +634,8 @@ void Source::ClangViewAutocomplete::autocomplete_check() { get_source_buffer()->iter_has_context_class(iter, "comment"))) return; std::string line=" "+get_line_before(); - const boost::regex in_specified_namespace("^(.*[a-zA-Z0-9_\\)\\]\\>])(->|\\.|::)([a-zA-Z0-9_]*)$"); - const boost::regex within_namespace("^(.*)([^a-zA-Z0-9_]+)([a-zA-Z0-9_]{3,})$"); + const static boost::regex in_specified_namespace("^(.*[a-zA-Z0-9_\\)\\]\\>])(->|\\.|::)([a-zA-Z0-9_]*)$"); + const static boost::regex within_namespace("^(.*)([^a-zA-Z0-9_]+)([a-zA-Z0-9_]{3,})$"); boost::smatch sm; if(boost::regex_match(line, sm, in_specified_namespace)) { {