Browse Source

Now using boost::regex instead of std::regex so that juci can compile with g++-4.8. Many systems use this old compiler and this makes juci compile on more platforms. Also, installation on Ubuntu 14 is simpler and do not require to tap the test repository.

merge-requests/365/head
Ole 10 years ago
parent
commit
807606696e
  1. 8
      docs/install.md
  2. 2
      src/CMakeLists.txt
  3. 20
      src/cmake.cc
  4. 38
      src/source_clang.cc
  5. 8
      src/source_clang.h

8
docs/install.md

@ -3,7 +3,7 @@
## Debian/Ubuntu 15
Install dependencies:
```sh
sudo apt-get install git cmake make g++ libclang-dev pkg-config libboost-system-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev
sudo apt-get install git cmake make g++ libclang-dev pkg-config libboost-system-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libboost-regex-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev
sudo apt-get install clang-format-3.6 || sudo apt-get install clang-format-3.5
```
@ -19,11 +19,7 @@ sudo make install
## Ubuntu 14/Linux Mint 17
Install dependencies:
```sh
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
sudo apt-get remove g++-4.8
sudo apt-get install git cmake make g++ libclang-3.6-dev clang-format-3.6 pkg-config libboost-system1.55-dev libboost-thread1.55-dev libboost-filesystem1.55-dev libboost-log1.55-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev
sudo apt-get install git cmake make g++ libclang-3.6-dev clang-format-3.6 pkg-config libboost-system-dev libboost-thread-dev libboost-filesystem-dev libboost-log-dev libboost-regex-dev libgtkmm-3.0-dev libgtksourceviewmm-3.0-dev aspell-en libaspell-dev
```
Get juCi++ source, compile and install:

2
src/CMakeLists.txt

@ -32,7 +32,7 @@ find_package(LibClang REQUIRED)
#find_package(PythonLibs 2.7)
#find_package(Boost 1.55 COMPONENTS python thread log system filesystem REQUIRED)
find_package(Boost 1.55 COMPONENTS thread log system filesystem REQUIRED)
find_package(Boost 1.54 COMPONENTS thread log system filesystem regex REQUIRED)
pkg_check_modules(GTKMM gtkmm-3.0 REQUIRED) # The name GTKMM is set here for the variables abouve

20
src/cmake.cc

@ -1,7 +1,7 @@
#include "cmake.h"
#include "singletons.h"
#include "filesystem.h"
#include <regex>
#include <boost/regex.hpp>
#include "dialogs.h"
#include <iostream> //TODO: remove
@ -10,9 +10,9 @@ using namespace std; //TODO: remove
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 std::regex project_regex("^ *project *\\(.*$");
std::smatch sm;
if(std::regex_match(line, sm, project_regex)) {
const boost::regex project_regex("^ *project *\\(.*$");
boost::smatch sm;
if(boost::regex_match(line, sm, project_regex)) {
return true;
}
}
@ -142,9 +142,9 @@ void CMake::find_variables() {
end_line=file.size();
if(end_line>start_line) {
auto line=file.substr(start_line, end_line-start_line);
const std::regex set_regex("^ *set *\\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\\) *$");
std::smatch sm;
if(std::regex_match(line, sm, set_regex)) {
const boost::regex set_regex("^ *set *\\( *([A-Za-z_][A-Za-z_0-9]*) +(.*)\\) *$");
boost::smatch sm;
if(boost::regex_match(line, sm, set_regex)) {
auto data=sm[2].str();
while(data.size()>0 && data.back()==' ')
data.pop_back();
@ -264,9 +264,9 @@ std::vector<std::pair<boost::filesystem::path, std::vector<std::string> > > CMak
end_line=file.size();
if(end_line>start_line) {
auto line=file.substr(start_line, end_line-start_line);
const std::regex function_regex("^ *"+name+" *\\( *(.*)\\) *$");
std::smatch sm;
if(std::regex_match(line, sm, function_regex)) {
const boost::regex function_regex("^ *"+name+" *\\( *(.*)\\) *$");
boost::smatch sm;
if(boost::regex_match(line, sm, function_regex)) {
auto data=sm[1].str();
while(data.size()>0 && data.back()==' ')
data.pop_back();

38
src/source_clang.cc

@ -100,9 +100,9 @@ void Source::ClangViewParse::configure() {
}
}
bracket_regex=std::regex("^([ \\t]*).*\\{ *$");
no_bracket_statement_regex=std::regex("^([ \\t]*)(if|for|else if|catch|while) *\\(.*[^;}] *$");
no_bracket_no_para_statement_regex=std::regex("^([ \\t]*)(else|try|do) *$");
bracket_regex=boost::regex("^([ \\t]*).*\\{ *$");
no_bracket_statement_regex=boost::regex("^([ \\t]*)(if|for|else if|catch|while) *\\(.*[^;}] *$");
no_bracket_no_para_statement_regex=boost::regex("^([ \\t]*)(else|try|do) *$");
}
void Source::ClangViewParse::init_parse() {
@ -194,9 +194,9 @@ std::vector<std::string> Source::ClangViewParse::get_compilation_commands() {
}
}
auto clang_version_string=clang::to_string(clang_getClangVersion());
const std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$");
std::smatch sm;
if(std::regex_match(clang_version_string, sm, clang_version_regex)) {
const 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();
arguments.emplace_back("-I/usr/lib/clang/"+clang_version+"/include");
arguments.emplace_back("-I/usr/local/Cellar/llvm/"+clang_version+"/lib/clang/"+clang_version+"/include");
@ -464,7 +464,7 @@ bool Source::ClangViewParse::on_key_press_event(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);
std::smatch sm;
boost::smatch sm;
if(iter.backward_char() && *iter=='{') {
auto found_iter=iter;
bool found_right_bracket=find_right_bracket_forward(iter, found_iter);
@ -516,13 +516,13 @@ bool Source::ClangViewParse::on_key_press_event(GdkEventKey* key) {
iter.forward_char();
}
}
else if(std::regex_match(line, sm, no_bracket_statement_regex)) {
else if(boost::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(std::regex_match(line, sm, no_bracket_no_para_statement_regex)) {
else if(boost::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();
@ -530,18 +530,18 @@ bool Source::ClangViewParse::on_key_press_event(GdkEventKey* key) {
}
//Indenting after for instance if(...)\n...;\n
else if(iter.backward_char() && *iter==';') {
std::smatch sm2;
boost::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(!std::regex_match(previous_line, sm2, bracket_regex)) {
if(std::regex_match(previous_line, sm2, no_bracket_statement_regex)) {
if(!boost::regex_match(previous_line, sm2, bracket_regex)) {
if(boost::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(std::regex_match(previous_line, sm2, no_bracket_no_para_statement_regex)) {
else if(boost::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();
@ -558,7 +558,7 @@ bool Source::ClangViewParse::on_key_press_event(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)) {
std::smatch sm;
boost::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)) {
@ -689,10 +689,10 @@ void Source::ClangViewAutocomplete::start_autocomplete() {
}
std::string line=" "+get_line_before();
if((std::count(line.begin(), line.end(), '\"')%2)!=1 && line.find("//")==std::string::npos) {
const std::regex in_specified_namespace("^(.*[a-zA-Z0-9_\\)\\]\\>])(->|\\.|::)([a-zA-Z0-9_]*)$");
const std::regex within_namespace("^(.*)([^a-zA-Z0-9_]+)([a-zA-Z0-9_]{3,})$");
std::smatch sm;
if(std::regex_match(line, sm, in_specified_namespace)) {
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,})$");
boost::smatch sm;
if(boost::regex_match(line, sm, in_specified_namespace)) {
prefix_mutex.lock();
prefix=sm[3].str();
prefix_mutex.unlock();
@ -702,7 +702,7 @@ void Source::ClangViewAutocomplete::start_autocomplete() {
else if(last_keyval=='.' && autocomplete_starting)
autocomplete_cancel_starting=true;
}
else if(std::regex_match(line, sm, within_namespace)) {
else if(boost::regex_match(line, sm, within_namespace)) {
prefix_mutex.lock();
prefix=sm[3].str();
prefix_mutex.unlock();

8
src/source_clang.h

@ -5,7 +5,7 @@
#include <atomic>
#include <mutex>
#include <set>
#include <regex>
#include <boost/regex.hpp>
#include "clangmm.h"
#include "source.h"
#include "terminal.h"
@ -42,9 +42,9 @@ namespace Source {
virtual void show_diagnostic_tooltips(const Gdk::Rectangle &rectangle);
virtual void show_type_tooltips(const Gdk::Rectangle &rectangle);
std::regex bracket_regex;
std::regex no_bracket_statement_regex;
std::regex no_bracket_no_para_statement_regex;
boost::regex bracket_regex;
boost::regex no_bracket_statement_regex;
boost::regex no_bracket_no_para_statement_regex;
std::set<int> diagnostic_offsets;
std::vector<FixIt> fix_its;

Loading…
Cancel
Save