From b986b3880187a70756103edb1494f2ce56a84030 Mon Sep 17 00:00:00 2001 From: Ole Christian Eidheim Date: Tue, 10 May 2016 14:59:28 +0200 Subject: [PATCH] Fix for current Arch Linux boost link issue --- src/cmake.cc | 33 ++++++++++++++++++++++----------- src/source.cc | 30 +++++++++++++++--------------- src/source.h | 17 ++++++++++++++--- src/source_clang.cc | 16 ++++++++-------- 4 files changed, 59 insertions(+), 37 deletions(-) diff --git a/src/cmake.cc b/src/cmake.cc index 76c1c4b..65f74ba 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -3,14 +3,25 @@ #include "dialogs.h" #include "config.h" #include "terminal.h" + +//Temporary fix for current Arch Linux boost linking problem +#ifdef __GNUC_PREREQ +#if __GNUC_PREREQ(5,1) +#include +#define REGEX_NS std +#endif +#endif +#ifndef REGEX_NS #include +#define REGEX_NS boost +#endif 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 static boost::regex project_regex("^ *project *\\(.*$", boost::regex::icase); - boost::smatch sm; - if(boost::regex_match(line, sm, project_regex)) + const static REGEX_NS::regex project_regex("^ *project *\\(.*$", REGEX_NS::regex::icase); + REGEX_NS::smatch sm; + if(REGEX_NS::regex_match(line, sm, project_regex)) return true; } return false; @@ -206,9 +217,9 @@ void CMake::find_variables() { end_line=file.size(); if(end_line>start_line) { auto line=file.substr(start_line, end_line-start_line); - boost::smatch sm; - 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)) { + REGEX_NS::smatch sm; + const static REGEX_NS::regex set_regex("^ *set *\\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\\) *$", REGEX_NS::regex::icase); + if(REGEX_NS::regex_match(line, sm, set_regex)) { auto data=sm[2].str(); while(data.size()>0 && data.back()==' ') data.pop_back(); @@ -216,8 +227,8 @@ void CMake::find_variables() { variables[sm[1].str()]=data; } else { - const static boost::regex project_regex("^ *project *\\( *([^ ]+).*\\) *$", boost::regex::icase); - if(boost::regex_match(line, sm, project_regex)) { + const static REGEX_NS::regex project_regex("^ *project *\\( *([^ ]+).*\\) *$", REGEX_NS::regex::icase); + if(REGEX_NS::regex_match(line, sm, project_regex)) { auto data=sm[1].str(); parse_variable_parameters(data); variables["CMAKE_PROJECT_NAME"]=data; //TODO: is this variable deprecated/non-standard? @@ -324,7 +335,7 @@ std::vector CMake::get_function_parameters(std::string &data) { } std::vector > > CMake::get_functions_parameters(const std::string &name) { - const boost::regex function_regex("^ *"+name+" *\\( *(.*)\\) *$", boost::regex::icase); + const REGEX_NS::regex function_regex("^ *"+name+" *\\( *(.*)\\) *$", REGEX_NS::regex::icase); if(!parsed) parse(); std::vector > > functions; @@ -338,8 +349,8 @@ std::vector > > CMak end_line=file.size(); if(end_line>start_line) { auto line=file.substr(start_line, end_line-start_line); - boost::smatch sm; - if(boost::regex_match(line, sm, function_regex)) { + REGEX_NS::smatch sm; + if(REGEX_NS::regex_match(line, sm, function_regex)) { auto data=sm[1].str(); while(data.size()>0 && data.back()==' ') data.pop_back(); diff --git a/src/source.cc b/src/source.cc index ee24f4b..97ba40b 100644 --- a/src/source.cc +++ b/src/source.cc @@ -79,9 +79,9 @@ 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) *$"); +const REGEX_NS::regex Source::View::bracket_regex("^([ \\t]*).*\\{ *$"); +const REGEX_NS::regex Source::View::no_bracket_statement_regex("^([ \\t]*)(if|for|else if|while) *\\(.*[^;}] *$"); +const REGEX_NS::regex Source::View::no_bracket_no_para_statement_regex("^([ \\t]*)(else) *$"); AspellConfig* Source::View::spellcheck_config=NULL; @@ -1337,7 +1337,7 @@ bool Source::View::on_key_press_event_bracket_language(GdkEventKey* key) { auto start_sentence_tabs_end_iter=get_tabs_end_iter(start_of_sentence_iter); auto tabs=get_line_before(start_sentence_tabs_end_iter); - boost::smatch sm; + REGEX_NS::smatch sm; if(iter.backward_char() && *iter=='{') { auto found_iter=iter; bool found_right_bracket=find_right_bracket_forward(iter, found_iter); @@ -1389,13 +1389,13 @@ bool Source::View::on_key_press_event_bracket_language(GdkEventKey* key) { iter.forward_char(); } } - else if(boost::regex_match(line, sm, no_bracket_statement_regex)) { + else if(REGEX_NS::regex_match(line, sm, no_bracket_statement_regex)) { get_source_buffer()->insert_at_cursor("\n"+tabs+tab); scroll_to(get_source_buffer()->get_insert()); get_source_buffer()->end_user_action(); return true; } - else if(boost::regex_match(line, sm, no_bracket_no_para_statement_regex)) { + else if(REGEX_NS::regex_match(line, sm, no_bracket_no_para_statement_regex)) { get_source_buffer()->insert_at_cursor("\n"+tabs+tab); scroll_to(get_source_buffer()->get_insert()); get_source_buffer()->end_user_action(); @@ -1403,18 +1403,18 @@ bool Source::View::on_key_press_event_bracket_language(GdkEventKey* key) { } //Indenting after for instance if(...)\n...;\n else if(iter.backward_char() && *iter==';') { - boost::smatch sm2; + REGEX_NS::smatch sm2; size_t line_nr=get_source_buffer()->get_insert()->get_iter().get_line(); if(line_nr>0 && tabs.size()>=tab_size) { std::string previous_line=get_line(line_nr-1); - if(!boost::regex_match(previous_line, sm2, bracket_regex)) { - if(boost::regex_match(previous_line, sm2, no_bracket_statement_regex)) { + if(!REGEX_NS::regex_match(previous_line, sm2, bracket_regex)) { + if(REGEX_NS::regex_match(previous_line, sm2, no_bracket_statement_regex)) { get_source_buffer()->insert_at_cursor("\n"+sm2[1].str()); scroll_to(get_source_buffer()->get_insert()); get_source_buffer()->end_user_action(); return true; } - else if(boost::regex_match(previous_line, sm2, no_bracket_no_para_statement_regex)) { + else if(REGEX_NS::regex_match(previous_line, sm2, no_bracket_no_para_statement_regex)) { get_source_buffer()->insert_at_cursor("\n"+sm2[1].str()); scroll_to(get_source_buffer()->get_insert()); get_source_buffer()->end_user_action(); @@ -1431,7 +1431,7 @@ bool Source::View::on_key_press_event_bracket_language(GdkEventKey* key) { left_bracket_iter.forward_char(); Gtk::TextIter start_of_left_bracket_sentence_iter; if(find_start_of_closed_expression(left_bracket_iter, start_of_left_bracket_sentence_iter)) { - boost::smatch sm; + REGEX_NS::smatch sm; auto tabs_end_iter=get_tabs_end_iter(start_of_left_bracket_sentence_iter); auto tabs_start_of_sentence=get_line_before(tabs_end_iter); if(tabs.size()==(tabs_start_of_sentence.size()+tab_size)) { @@ -1485,12 +1485,12 @@ bool Source::View::on_key_press_event_bracket_language(GdkEventKey* key) { size_t line_nr=iter.get_line(); if(line_nr>0 && tabs.size()>=tab_size && iter==tabs_end_iter) { std::string previous_line=get_line(line_nr-1); - boost::smatch sm; - if(!boost::regex_match(previous_line, sm, bracket_regex)) { + REGEX_NS::smatch sm; + if(!REGEX_NS::regex_match(previous_line, sm, bracket_regex)) { auto start_iter=iter; start_iter.backward_chars(tab_size); - if(boost::regex_match(previous_line, sm, no_bracket_statement_regex) || - boost::regex_match(previous_line, sm, no_bracket_no_para_statement_regex)) { + if(REGEX_NS::regex_match(previous_line, sm, no_bracket_statement_regex) || + REGEX_NS::regex_match(previous_line, sm, no_bracket_no_para_statement_regex)) { if((tabs.size()-tab_size)==sm[1].str().size()) { get_buffer()->erase(start_iter, iter); get_buffer()->insert_at_cursor("{"); diff --git a/src/source.h b/src/source.h index cdad7a1..9aa3b8f 100644 --- a/src/source.h +++ b/src/source.h @@ -7,7 +7,18 @@ #include #include #include + +//Temporary fix for current Arch Linux boost linking problem +#ifdef __GNUC_PREREQ +#if __GNUC_PREREQ(5,1) +#include +#define REGEX_NS std +#endif +#endif +#ifndef REGEX_NS #include +#define REGEX_NS boost +#endif #include "selectiondialog.h" #include "tooltips.h" @@ -138,9 +149,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); - const static boost::regex bracket_regex; - const static boost::regex no_bracket_statement_regex; - const static boost::regex no_bracket_no_para_statement_regex; + const static REGEX_NS::regex bracket_regex; + const static REGEX_NS::regex no_bracket_statement_regex; + const static REGEX_NS::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 fde75d7..cff5551 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -187,9 +187,9 @@ std::vector Source::ClangViewParse::get_compilation_commands() { } } auto clang_version_string=clang::to_string(clang_getClangVersion()); - 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)) { + const static REGEX_NS::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$"); + REGEX_NS::smatch sm; + if(REGEX_NS::regex_match(clang_version_string, sm, clang_version_regex)) { auto clang_version=sm[1].str(); arguments.emplace_back("-I/usr/lib/clang/"+clang_version+"/include"); #ifdef __APPLE__ @@ -634,10 +634,10 @@ void Source::ClangViewAutocomplete::autocomplete_check() { get_source_buffer()->iter_has_context_class(iter, "comment"))) return; std::string line=" "+get_line_before(); - 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)) { + const static REGEX_NS::regex in_specified_namespace("^(.*[a-zA-Z0-9_\\)\\]\\>])(->|\\.|::)([a-zA-Z0-9_]*)$"); + const static REGEX_NS::regex within_namespace("^(.*)([^a-zA-Z0-9_]+)([a-zA-Z0-9_]{3,})$"); + REGEX_NS::smatch sm; + if(REGEX_NS::regex_match(line, sm, in_specified_namespace)) { { std::unique_lock lock(prefix_mutex); prefix=sm[3].str(); @@ -645,7 +645,7 @@ void Source::ClangViewAutocomplete::autocomplete_check() { if(prefix.size()==0 || prefix[0]<'0' || prefix[0]>'9') autocomplete(); } - else if(boost::regex_match(line, sm, within_namespace)) { + else if(REGEX_NS::regex_match(line, sm, within_namespace)) { { std::unique_lock lock(prefix_mutex); prefix=sm[3].str();