mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
TR1: use std::tr1 regex with msvc10
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34725 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
86172fbebe
commit
615d42d357
@ -479,7 +479,7 @@ if(UseExternalBoost)
|
|||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message(STATUS "----- Using internal boost. To build with installed version use -DUseExternalBoost:BOOL=ON")
|
message(STATUS "----- Using internal boost. To build with installed version use -DUseExternalBoost:BOOL=ON")
|
||||||
set(Lyx_Boost_Libraries boost_signals boost_regex)
|
set(Lyx_Boost_Libraries boost_signals ${BOOST_REGEX_LIB})
|
||||||
add_definitions(-DBOOST_USER_CONFIG="<config.h>")
|
add_definitions(-DBOOST_USER_CONFIG="<config.h>")
|
||||||
include_directories(${TOP_SRC_DIR}/boost)
|
include_directories(${TOP_SRC_DIR}/boost)
|
||||||
add_subdirectory(boost)
|
add_subdirectory(boost)
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
project(boost)
|
project(boost)
|
||||||
|
|
||||||
add_subdirectory(regex)
|
if(MSVC10)
|
||||||
|
message(STATUS "Using TR1 regex")
|
||||||
|
else()
|
||||||
|
add_subdirectory(regex)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(signals)
|
add_subdirectory(signals)
|
||||||
|
|
||||||
|
@ -21,3 +21,5 @@ lyx_add_path(boost_regex_sources ${TOP_SRC_DIR}/boost/libs/regex/src)
|
|||||||
|
|
||||||
add_library(boost_regex STATIC ${boost_regex_sources})
|
add_library(boost_regex STATIC ${boost_regex_sources})
|
||||||
|
|
||||||
|
set(BOOST_REGEX_LIB boost_regex CACHE STRING "Boost regex lib" FORCE)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/textutils.h"
|
#include "support/textutils.h"
|
||||||
|
|
||||||
#include "boost/regex.hpp"
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@ -175,8 +175,8 @@ docstring convertLaTeXCommands(docstring const & str)
|
|||||||
// unicodesymbols has things in the form: \"{u},
|
// unicodesymbols has things in the form: \"{u},
|
||||||
// whereas we may see things like: \"u. So we'll
|
// whereas we may see things like: \"u. So we'll
|
||||||
// look for that and change it, if necessary.
|
// look for that and change it, if necessary.
|
||||||
static boost::regex const reg("^\\\\\\W\\w");
|
static lyx::regex const reg("^\\\\\\W\\w");
|
||||||
if (boost::regex_search(to_utf8(val), reg)) {
|
if (lyx::regex_search(to_utf8(val), reg)) {
|
||||||
val.insert(3, from_ascii("}"));
|
val.insert(3, from_ascii("}"));
|
||||||
val.insert(2, from_ascii("{"));
|
val.insert(2, from_ascii("{"));
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,10 @@
|
|||||||
#include "support/Systemcall.h"
|
#include "support/Systemcall.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using boost::regex;
|
|
||||||
using boost::smatch;
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
@ -952,7 +950,7 @@ void LaTeX::deplog(DepTable & head)
|
|||||||
string lastline;
|
string lastline;
|
||||||
while (ifs) {
|
while (ifs) {
|
||||||
// Ok, the scanning of files here is not sufficient.
|
// Ok, the scanning of files here is not sufficient.
|
||||||
// Sometimes files are named by "File: xxx" only
|
// Sometimes files are named by "File:Â xxx" only
|
||||||
// So I think we should use some regexps to find files instead.
|
// So I think we should use some regexps to find files instead.
|
||||||
// Note: all file names and paths might contains spaces.
|
// Note: all file names and paths might contains spaces.
|
||||||
bool found_file = false;
|
bool found_file = false;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
@ -873,11 +873,11 @@ docstring const i18npreamble(Language const * lang, docstring const & templ)
|
|||||||
LASSERT(false, /**/);
|
LASSERT(false, /**/);
|
||||||
#else
|
#else
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
// boost::regex is not unicode-safe.
|
// lyx::regex is not unicode-safe.
|
||||||
// Should use QRegExp or (boost::u32regex, but that requires ICU)
|
// Should use QRegExp or (boost::u32regex, but that requires ICU)
|
||||||
static boost::regex const reg("_\\(([^\\)]+)\\)");
|
static regex const reg("_\\(([^\\)]+)\\)");
|
||||||
boost::smatch sub;
|
smatch sub;
|
||||||
while (boost::regex_search(preamble, sub, reg)) {
|
while (regex_search(preamble, sub, reg)) {
|
||||||
string const key = sub.str(1);
|
string const key = sub.str(1);
|
||||||
string translated;
|
string translated;
|
||||||
if (isAscii(key))
|
if (isAscii(key))
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include "support/bind.h"
|
#include "support/bind.h"
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -38,8 +38,6 @@ using namespace lyx::support;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
using boost::regex;
|
|
||||||
using boost::smatch;
|
|
||||||
|
|
||||||
LayoutFile::LayoutFile(string const & fn, string const & cln,
|
LayoutFile::LayoutFile(string const & fn, string const & cln,
|
||||||
string const & desc, string const & prereq,
|
string const & desc, string const & prereq,
|
||||||
|
@ -26,17 +26,14 @@
|
|||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/Path.h"
|
#include "support/Path.h"
|
||||||
#include "support/Systemcall.h"
|
#include "support/Systemcall.h"
|
||||||
|
#include "support/regex.h"
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
using boost::regex;
|
|
||||||
using boost::regex_match;
|
|
||||||
using boost::smatch;
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#undef KeyPress
|
#undef KeyPress
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -673,9 +673,9 @@ static docstring escape_special_chars(docstring const & expr)
|
|||||||
{
|
{
|
||||||
// Search for all chars '.|*?+(){}[^$]\'
|
// Search for all chars '.|*?+(){}[^$]\'
|
||||||
// Note that '[' and '\' must be escaped.
|
// Note that '[' and '\' must be escaped.
|
||||||
// This is a limitation of boost::regex, but all other chars in BREs
|
// This is a limitation of lyx::regex, but all other chars in BREs
|
||||||
// are assumed literal.
|
// are assumed literal.
|
||||||
static const boost::regex reg("[].|*?+(){}^$\\[\\\\]");
|
static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]");
|
||||||
|
|
||||||
// $& is a perl-like expression that expands to all
|
// $& is a perl-like expression that expands to all
|
||||||
// of the current match
|
// of the current match
|
||||||
@ -683,7 +683,7 @@ static docstring escape_special_chars(docstring const & expr)
|
|||||||
// boost to treat it as a literal.
|
// boost to treat it as a literal.
|
||||||
// Thus, to prefix a matched expression with '\', we use:
|
// Thus, to prefix a matched expression with '\', we use:
|
||||||
// FIXME: UNICODE
|
// FIXME: UNICODE
|
||||||
return from_utf8(boost::regex_replace(to_utf8(expr), reg, "\\\\$&"));
|
return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\\\$&")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -700,15 +700,15 @@ vector<docstring> GuiCitation::searchKeys(BiblioInfo const & bi,
|
|||||||
|
|
||||||
if (!regex)
|
if (!regex)
|
||||||
// We must escape special chars in the search_expr so that
|
// We must escape special chars in the search_expr so that
|
||||||
// it is treated as a simple string by boost::regex.
|
// it is treated as a simple string by lyx::regex.
|
||||||
expr = escape_special_chars(expr);
|
expr = escape_special_chars(expr);
|
||||||
|
|
||||||
boost::regex reg_exp;
|
lyx::regex reg_exp;
|
||||||
try {
|
try {
|
||||||
reg_exp.assign(to_utf8(expr), case_sensitive ?
|
reg_exp.assign(to_utf8(expr), case_sensitive ?
|
||||||
boost::regex_constants::normal : boost::regex_constants::icase);
|
lyx::regex_constants::ECMAScript : lyx::regex_constants::icase);
|
||||||
} catch (boost::regex_error & e) {
|
} catch (lyx::regex_error & e) {
|
||||||
// boost::regex throws an exception if the regular expression is not
|
// lyx::regex throws an exception if the regular expression is not
|
||||||
// valid.
|
// valid.
|
||||||
LYXERR(Debug::GUI, e.what());
|
LYXERR(Debug::GUI, e.what());
|
||||||
return vector<docstring>();
|
return vector<docstring>();
|
||||||
@ -734,10 +734,10 @@ vector<docstring> GuiCitation::searchKeys(BiblioInfo const & bi,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (boost::regex_search(data, reg_exp))
|
if (lyx::regex_search(data, reg_exp))
|
||||||
foundKeys.push_back(*it);
|
foundKeys.push_back(*it);
|
||||||
}
|
}
|
||||||
catch (boost::regex_error & e) {
|
catch (lyx::regex_error & e) {
|
||||||
LYXERR(Debug::GUI, e.what());
|
LYXERR(Debug::GUI, e.what());
|
||||||
return vector<docstring>();
|
return vector<docstring>();
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
// for FileFilter.
|
// for FileFilter.
|
||||||
// FIXME: Remove
|
// FIXME: Remove
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -338,17 +338,17 @@ static string const convert_brace_glob(string const & glob)
|
|||||||
{
|
{
|
||||||
// Matches " *.{abc,def,ghi}", storing "*." as group 1 and
|
// Matches " *.{abc,def,ghi}", storing "*." as group 1 and
|
||||||
// "abc,def,ghi" as group 2.
|
// "abc,def,ghi" as group 2.
|
||||||
static boost::regex const glob_re(" *([^ {]*)\\{([^ }]+)\\}");
|
static lyx::regex const glob_re(" *([^ {]*)\\{([^ }]+)\\}");
|
||||||
// Matches "abc" and "abc,", storing "abc" as group 1.
|
// Matches "abc" and "abc,", storing "abc" as group 1.
|
||||||
static boost::regex const block_re("([^,}]+),?");
|
static lyx::regex const block_re("([^,}]+),?");
|
||||||
|
|
||||||
string pattern;
|
string pattern;
|
||||||
|
|
||||||
string::const_iterator it = glob.begin();
|
string::const_iterator it = glob.begin();
|
||||||
string::const_iterator const end = glob.end();
|
string::const_iterator const end = glob.end();
|
||||||
while (true) {
|
while (true) {
|
||||||
boost::match_results<string::const_iterator> what;
|
match_results<string::const_iterator> what;
|
||||||
if (!boost::regex_search(it, end, what, glob_re)) {
|
if (!regex_search(it, end, what, glob_re)) {
|
||||||
// Ensure that no information is lost.
|
// Ensure that no information is lost.
|
||||||
pattern += string(it, end);
|
pattern += string(it, end);
|
||||||
break;
|
break;
|
||||||
@ -365,7 +365,7 @@ static string const convert_brace_glob(string const & glob)
|
|||||||
// Split the ','-separated chunks of tail so that
|
// Split the ','-separated chunks of tail so that
|
||||||
// $head{$chunk1,$chunk2} becomes "$head$chunk1 $head$chunk2".
|
// $head{$chunk1,$chunk2} becomes "$head$chunk1 $head$chunk2".
|
||||||
string const fmt = " " + head + "$1";
|
string const fmt = " " + head + "$1";
|
||||||
pattern += boost::regex_merge(tail, block_re, fmt);
|
pattern += regex_replace(tail, block_re, fmt);
|
||||||
|
|
||||||
// Increment the iterator to the end of the match.
|
// Increment the iterator to the end of the match.
|
||||||
it += distance(it, what[0].second);
|
it += distance(it, what[0].second);
|
||||||
@ -474,14 +474,14 @@ FileFilterList::FileFilterList(docstring const & qt_style_filter)
|
|||||||
|
|
||||||
// Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
|
// Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
|
||||||
// into individual filters.
|
// into individual filters.
|
||||||
static boost::regex const separator_re(";;");
|
static lyx::regex const separator_re(";;");
|
||||||
|
|
||||||
string::const_iterator it = filter.begin();
|
string::const_iterator it = filter.begin();
|
||||||
string::const_iterator const end = filter.end();
|
string::const_iterator const end = filter.end();
|
||||||
while (true) {
|
while (true) {
|
||||||
boost::match_results<string::const_iterator> what;
|
match_results<string::const_iterator> what;
|
||||||
|
|
||||||
if (!boost::regex_search(it, end, what, separator_re)) {
|
if (!lyx::regex_search(it, end, what, separator_re)) {
|
||||||
parse_filter(string(it, end));
|
parse_filter(string(it, end));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -500,10 +500,10 @@ void FileFilterList::parse_filter(string const & filter)
|
|||||||
{
|
{
|
||||||
// Matches "TeX documents (*.tex)",
|
// Matches "TeX documents (*.tex)",
|
||||||
// storing "TeX documents " as group 1 and "*.tex" as group 2.
|
// storing "TeX documents " as group 1 and "*.tex" as group 2.
|
||||||
static boost::regex const filter_re("([^(]*)\\(([^)]+)\\) *$");
|
static lyx::regex const filter_re("([^(]*)\\(([^)]+)\\) *$");
|
||||||
|
|
||||||
boost::match_results<string::const_iterator> what;
|
match_results<string::const_iterator> what;
|
||||||
if (!boost::regex_search(filter, what, filter_re)) {
|
if (!lyx::regex_search(filter, what, filter_re)) {
|
||||||
// Just a glob, no description.
|
// Just a glob, no description.
|
||||||
filters_.push_back(Filter(docstring(), trim(filter)));
|
filters_.push_back(Filter(docstring(), trim(filter)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "support/lyxlib.h" // float_equal
|
#include "support/lyxlib.h" // float_equal
|
||||||
#include "support/Translator.h"
|
#include "support/Translator.h"
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <cmath> // abs
|
#include <cmath> // abs
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -279,10 +279,10 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
// Strip any leading commas
|
// Strip any leading commas
|
||||||
// "[,,,,foo..." -> "foo..." ("foo..." may be empty)
|
// "[,,,,foo..." -> "foo..." ("foo..." may be empty)
|
||||||
string output;
|
string output;
|
||||||
boost::smatch what;
|
lyx::smatch what;
|
||||||
static boost::regex const front("^( *[[],*)(.*)$");
|
static lyx::regex const front("^( *[[],*)(.*)$");
|
||||||
|
|
||||||
regex_match(it, end, what, front, boost::match_partial);
|
regex_match(it, end, what, front, regex_constants::match_partial);
|
||||||
if (!what[0].matched) {
|
if (!what[0].matched) {
|
||||||
lyxerr << "Unable to sanitize LaTeX \"Option\": "
|
lyxerr << "Unable to sanitize LaTeX \"Option\": "
|
||||||
<< input << '\n';
|
<< input << '\n';
|
||||||
@ -293,9 +293,9 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
// Replace any consecutive commas with a single one
|
// Replace any consecutive commas with a single one
|
||||||
// "foo,,,,bar" -> "foo,bar"
|
// "foo,,,,bar" -> "foo,bar"
|
||||||
// with iterator now pointing to 'b'
|
// with iterator now pointing to 'b'
|
||||||
static boost::regex const commas("([^,]*)(,,*)(.*)$");
|
static lyx::regex const commas("([^,]*)(,,*)(.*)$");
|
||||||
for (; it != end;) {
|
for (; it != end;) {
|
||||||
regex_match(it, end, what, commas, boost::match_partial);
|
regex_match(it, end, what, commas, regex_constants::match_partial);
|
||||||
if (!what[0].matched) {
|
if (!what[0].matched) {
|
||||||
output += string(it, end);
|
output += string(it, end);
|
||||||
break;
|
break;
|
||||||
@ -306,7 +306,7 @@ string const sanitizeLatexOption(string const & input)
|
|||||||
|
|
||||||
// Strip any trailing commas
|
// Strip any trailing commas
|
||||||
// "...foo,,,]" -> "...foo" ("...foo,,," may be empty)
|
// "...foo,,,]" -> "...foo" ("...foo,,," may be empty)
|
||||||
static boost::regex const back("^(.*[^,])?,*[]] *$");
|
static lyx::regex const back("^(.*[^,])?,*[]] *$");
|
||||||
regex_match(output, what, back);
|
regex_match(output, what, back);
|
||||||
if (!what[0].matched) {
|
if (!what[0].matched) {
|
||||||
lyxerr << "Unable to sanitize LaTeX \"Option\": "
|
lyxerr << "Unable to sanitize LaTeX \"Option\": "
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include "frontends/alert.h"
|
#include "frontends/alert.h"
|
||||||
#include "frontends/Application.h"
|
#include "frontends/Application.h"
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -47,7 +47,6 @@ using namespace lyx::support;
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
using boost::regex;
|
|
||||||
|
|
||||||
char const lstinline_delimiters[] =
|
char const lstinline_delimiters[] =
|
||||||
"!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
|
"!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -559,14 +559,14 @@ string escape_for_regex(string s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper for boost::regex_replace with simpler interface
|
/// Wrapper for lyx::regex_replace with simpler interface
|
||||||
bool regex_replace(string const & s, string & t, string const & searchstr,
|
bool regex_replace(string const & s, string & t, string const & searchstr,
|
||||||
string const & replacestr)
|
string const & replacestr)
|
||||||
{
|
{
|
||||||
boost::regex e(searchstr);
|
lyx::regex e(searchstr);
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
ostream_iterator<char, char> it(oss);
|
ostream_iterator<char, char> it(oss);
|
||||||
boost::regex_replace(it, s.begin(), s.end(), e, replacestr);
|
lyx::regex_replace(it, s.begin(), s.end(), e, replacestr);
|
||||||
// tolerate t and s be references to the same variable
|
// tolerate t and s be references to the same variable
|
||||||
bool rv = (s != oss.str());
|
bool rv = (s != oss.str());
|
||||||
t = oss.str();
|
t = oss.str();
|
||||||
@ -661,9 +661,9 @@ private:
|
|||||||
// normalized string to search
|
// normalized string to search
|
||||||
string par_as_string;
|
string par_as_string;
|
||||||
// regular expression to use for searching
|
// regular expression to use for searching
|
||||||
boost::regex regexp;
|
lyx::regex regexp;
|
||||||
// same as regexp, but prefixed with a ".*"
|
// same as regexp, but prefixed with a ".*"
|
||||||
boost::regex regexp2;
|
lyx::regex regexp2;
|
||||||
// unmatched open braces in the search string/regexp
|
// unmatched open braces in the search string/regexp
|
||||||
int open_braces;
|
int open_braces;
|
||||||
// number of (.*?) subexpressions added at end of search regexp for closing
|
// number of (.*?) subexpressions added at end of search regexp for closing
|
||||||
@ -722,9 +722,9 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions const &
|
|||||||
LYXERR(Debug::FIND, "Close .*? : " << close_wildcards);
|
LYXERR(Debug::FIND, "Close .*? : " << close_wildcards);
|
||||||
LYXERR(Debug::FIND, "Replaced text (to be used as regex): " << par_as_string);
|
LYXERR(Debug::FIND, "Replaced text (to be used as regex): " << par_as_string);
|
||||||
// If entered regexp must match at begin of searched string buffer
|
// If entered regexp must match at begin of searched string buffer
|
||||||
regexp = boost::regex(string("\\`") + par_as_string);
|
regexp = lyx::regex(string("\\`") + par_as_string);
|
||||||
// If entered regexp may match wherever in searched string buffer
|
// If entered regexp may match wherever in searched string buffer
|
||||||
regexp2 = boost::regex(string("\\`.*") + par_as_string);
|
regexp2 = lyx::regex(string("\\`.*") + par_as_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,11 +747,11 @@ int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) con
|
|||||||
} else {
|
} else {
|
||||||
// Try all possible regexp matches,
|
// Try all possible regexp matches,
|
||||||
//until one that verifies the braces match test is found
|
//until one that verifies the braces match test is found
|
||||||
boost::regex const *p_regexp = at_begin ? ®exp : ®exp2;
|
regex const *p_regexp = at_begin ? ®exp : ®exp2;
|
||||||
boost::sregex_iterator re_it(str.begin(), str.end(), *p_regexp);
|
sregex_iterator re_it(str.begin(), str.end(), *p_regexp);
|
||||||
boost::sregex_iterator re_it_end;
|
sregex_iterator re_it_end;
|
||||||
for (; re_it != re_it_end; ++re_it) {
|
for (; re_it != re_it_end; ++re_it) {
|
||||||
boost::match_results<string::const_iterator> const & m = *re_it;
|
match_results<string::const_iterator> const & m = *re_it;
|
||||||
// Check braces on the segment that matched the entire regexp expression,
|
// Check braces on the segment that matched the entire regexp expression,
|
||||||
// plus the last subexpression, if a (.*?) was inserted in the constructor.
|
// plus the last subexpression, if a (.*?) was inserted in the constructor.
|
||||||
if (! braces_match(m[0].first, m[0].second, open_braces))
|
if (! braces_match(m[0].first, m[0].second, open_braces))
|
||||||
@ -1222,7 +1222,7 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt)
|
|||||||
else
|
else
|
||||||
match_len = findBackwardsAdv(cur, matchAdv);
|
match_len = findBackwardsAdv(cur, matchAdv);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// This may only be raised by boost::regex()
|
// This may only be raised by lyx::regex()
|
||||||
bv->message(_("Invalid regular expression!"));
|
bv->message(_("Invalid regular expression!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
@ -537,9 +537,9 @@ string const replaceEnvironmentPath(string const & path)
|
|||||||
// $\{[A-Za-z_][A-Za-z_0-9]*\}
|
// $\{[A-Za-z_][A-Za-z_0-9]*\}
|
||||||
static string const envvar = "[$]([A-Za-z_][A-Za-z_0-9]*)";
|
static string const envvar = "[$]([A-Za-z_][A-Za-z_0-9]*)";
|
||||||
|
|
||||||
static boost::regex envvar_br_re("(.*)" + envvar_br + "(.*)");
|
static regex envvar_br_re("(.*)" + envvar_br + "(.*)");
|
||||||
static boost::regex envvar_re("(.*)" + envvar + "(.*)");
|
static regex envvar_re("(.*)" + envvar + "(.*)");
|
||||||
boost::smatch what;
|
smatch what;
|
||||||
string result;
|
string result;
|
||||||
string remaining = path;
|
string remaining = path;
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -921,13 +921,13 @@ string const readBB_from_PSFile(FileName const & file)
|
|||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boost::regex bbox_re(
|
static lyx::regex bbox_re(
|
||||||
"^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
|
"^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
|
||||||
ifstream is(file_.toFilesystemEncoding().c_str());
|
ifstream is(file_.toFilesystemEncoding().c_str());
|
||||||
while (is) {
|
while (is) {
|
||||||
string s;
|
string s;
|
||||||
getline(is,s);
|
getline(is,s);
|
||||||
boost::smatch what;
|
lyx::smatch what;
|
||||||
if (regex_match(s, what, bbox_re)) {
|
if (regex_match(s, what, bbox_re)) {
|
||||||
// Our callers expect the tokens in the string
|
// Our callers expect the tokens in the string
|
||||||
// separated by single spaces.
|
// separated by single spaces.
|
||||||
|
63
src/support/regex.h
Normal file
63
src/support/regex.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file regexp.h
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Peter Kümmel
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LYX_REGEXP_H
|
||||||
|
#define LYX_REGEXP_H
|
||||||
|
|
||||||
|
#include "checktr1.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define LYX_REGEX_TO_LYX(X) \
|
||||||
|
using X::regex; \
|
||||||
|
using X::smatch; \
|
||||||
|
using X::regex_replace; \
|
||||||
|
using X::basic_regex; \
|
||||||
|
using X::regex_error; \
|
||||||
|
using X::regex_search; \
|
||||||
|
using X::sregex_iterator; \
|
||||||
|
using X::match_results; \
|
||||||
|
\
|
||||||
|
namespace regex_constants \
|
||||||
|
{ \
|
||||||
|
using namespace X::regex_constants; \
|
||||||
|
using X::regex_constants::match_flag_type; \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: only tested with msvc10
|
||||||
|
#if defined(LYX_USE_TR1) && defined(_MSC_VER)
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <regex>
|
||||||
|
#define match_partial _Match_partial // why is match_partial not public?
|
||||||
|
#else
|
||||||
|
#include <tr1/regexp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace lyx
|
||||||
|
{
|
||||||
|
LYX_REGEX_TO_LYX(std::tr1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include "boost/regex.hpp"
|
||||||
|
|
||||||
|
namespace lyx
|
||||||
|
{
|
||||||
|
LYX_REGEX_TO_LYX(boost);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -25,7 +25,7 @@
|
|||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include "support/regex.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -36,8 +36,7 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
using boost::regex;
|
|
||||||
using boost::smatch;
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user