Browse Source

Changed some regex strings to string literals

merge-requests/382/head
eidheim 8 years ago
parent
commit
e68a697765
  1. 2
      src/cmake.cc
  2. 2
      src/compile_commands.cc
  3. 2
      src/ctags.cc
  4. 2
      src/meson.cc
  5. 6
      src/source_clang.cc
  6. 4
      src/source_language_protocol.cc
  7. 2
      src/usages_clang.cc

2
src/cmake.cc

@ -9,7 +9,7 @@
CMake::CMake(const boost::filesystem::path &path) { CMake::CMake(const boost::filesystem::path &path) {
const auto find_cmake_project=[](const boost::filesystem::path &cmake_path) { const auto find_cmake_project=[](const boost::filesystem::path &cmake_path) {
for(auto &line: filesystem::read_lines(cmake_path)) { for(auto &line: filesystem::read_lines(cmake_path)) {
const static std::regex project_regex("^ *project *\\(.*\\r?$", std::regex::icase); const static std::regex project_regex(R"(^ *project *\(.*\r?$)", std::regex::icase);
std::smatch sm; std::smatch sm;
if(std::regex_match(line, sm, project_regex)) if(std::regex_match(line, sm, project_regex))
return true; return true;

2
src/compile_commands.cc

@ -112,7 +112,7 @@ std::vector<std::string> CompileCommands::get_arguments(const boost::filesystem:
arguments.emplace_back(default_std_argument); arguments.emplace_back(default_std_argument);
auto clang_version_string=clangmm::to_string(clang_getClangVersion()); auto clang_version_string=clangmm::to_string(clang_getClangVersion());
const static std::regex clang_version_regex("^[A-Za-z ]+([0-9.]+).*$"); const static std::regex clang_version_regex(R"(^[A-Za-z ]+([0-9.]+).*$)");
std::smatch sm; std::smatch sm;
if(std::regex_match(clang_version_string, sm, clang_version_regex)) { if(std::regex_match(clang_version_string, sm, clang_version_regex)) {
auto clang_version=sm[1].str(); auto clang_version=sm[1].str();

2
src/ctags.cc

@ -48,7 +48,7 @@ Ctags::Location Ctags::get_location(const std::string &line, bool markup) {
auto &line_fixed=line; auto &line_fixed=line;
#endif #endif
const static std::regex regex("^([^\t]+)\t([^\t]+)\t(?:/\\^)?([ \t]*)(.+?)(\\$/)?;\"\tline:([0-9]+)\t?[a-zA-Z]*:?(.*)$"); const static std::regex regex(R"(^([^\t]+)\t([^\t]+)\t(?:/\^)?([ \t]*)(.+?)(\$/)?;"\tline:([0-9]+)\t?[a-zA-Z]*:?(.*)$)");
std::smatch sm; std::smatch sm;
if(std::regex_match(line_fixed, sm, regex)) { if(std::regex_match(line_fixed, sm, regex)) {
location.symbol=sm[1].str(); location.symbol=sm[1].str();

2
src/meson.cc

@ -9,7 +9,7 @@
Meson::Meson(const boost::filesystem::path &path) { Meson::Meson(const boost::filesystem::path &path) {
const auto find_project=[](const boost::filesystem::path &file_path) { const auto find_project=[](const boost::filesystem::path &file_path) {
for(auto &line: filesystem::read_lines(file_path)) { for(auto &line: filesystem::read_lines(file_path)) {
const static std::regex project_regex("^ *project *\\(.*\\r?$", std::regex::icase); const static std::regex project_regex(R"(^ *project *\(.*\r?$)", std::regex::icase);
std::smatch sm; std::smatch sm;
if(std::regex_match(line, sm, project_regex)) if(std::regex_match(line, sm, project_regex))
return true; return true;

6
src/source_clang.cc

@ -536,8 +536,8 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa
std::string line=" "+get_line_before(); std::string line=" "+get_line_before();
const static std::regex dot_or_arrow(R"(^.*[a-zA-Z0-9_\)\]\>](\.|->)([a-zA-Z0-9_]*)$)"); const static std::regex dot_or_arrow(R"(^.*[a-zA-Z0-9_\)\]\>](\.|->)([a-zA-Z0-9_]*)$)");
const static std::regex colon_colon("^.*::([a-zA-Z0-9_]*)$"); const static std::regex colon_colon(R"(^.*::([a-zA-Z0-9_]*)$)");
const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$"); const static std::regex part_of_symbol(R"(^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$)");
std::smatch sm; std::smatch sm;
if(std::regex_match(line, sm, dot_or_arrow)) { if(std::regex_match(line, sm, dot_or_arrow)) {
{ {
@ -987,7 +987,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
} }
else { else {
// If cursor is at an include line, return offset to included file // If cursor is at an include line, return offset to included file
const static std::regex include_regex("^[ \t]*#[ \t]*include[ \t]*[<\"]([^<>\"]+)[>\"].*$"); const static std::regex include_regex(R"(^[ \t]*#[ \t]*include[ \t]*[<"]([^<>"]+)[>"].*$)");
std::smatch sm; std::smatch sm;
auto line=get_line(); auto line=get_line();
if(std::regex_match(line, sm, include_regex)) { if(std::regex_match(line, sm, include_regex)) {

4
src/source_language_protocol.cc

@ -1148,8 +1148,8 @@ void Source::LanguageProtocolView::setup_autocomplete() {
std::string line=" "+get_line_before(); std::string line=" "+get_line_before();
const static std::regex dot_or_arrow(R"(^.*[a-zA-Z0-9_\)\]\>"'](\.)([a-zA-Z0-9_]*)$)"); const static std::regex dot_or_arrow(R"(^.*[a-zA-Z0-9_\)\]\>"'](\.)([a-zA-Z0-9_]*)$)");
const static std::regex colon_colon("^.*::([a-zA-Z0-9_]*)$"); const static std::regex colon_colon(R"(^.*::([a-zA-Z0-9_]*)$)");
const static std::regex part_of_symbol("^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$"); const static std::regex part_of_symbol(R"(^.*[^a-zA-Z0-9_]+([a-zA-Z0-9_]{3,})$)");
std::smatch sm; std::smatch sm;
if(std::regex_match(line, sm, dot_or_arrow)) { if(std::regex_match(line, sm, dot_or_arrow)) {
{ {

2
src/usages_clang.cc

@ -572,7 +572,7 @@ std::pair<std::map<boost::filesystem::path, Usages::Clang::PathSet>, Usages::Cla
std::map<boost::filesystem::path, PathSet> paths_includes; std::map<boost::filesystem::path, PathSet> paths_includes;
PathSet paths_with_spelling; PathSet paths_with_spelling;
const static std::regex include_regex("^[ \t]*#[ \t]*include[ \t]*[\"]([^\"]+)[\"].*$"); const static std::regex include_regex(R"R(^[ \t]*#[ \t]*include[ \t]*"([^"]+)".*$)R");
auto is_spelling_char = [](char chr) { auto is_spelling_char = [](char chr) {
return (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') || chr == '_'; return (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') || chr == '_';

Loading…
Cancel
Save