[prev in list] [next in list] [prev in thread] [next in thread]
List: lyx-cvs
Subject: r34725 - in lyx-devel/trunk: development/cmake development/cmake/boost/libs development/cmake/boost/
From: kuemmel () lyx ! org
Date: 2010-06-29 17:09:42
Message-ID: 20100629170942.46FDA30AE2 () lyx ! lyx ! org
[Download RAW message or body]
Author: kuemmel
Date: Tue Jun 29 19:09:40 2010
New Revision: 34725
URL: http://www.lyx.org/trac/changeset/34725
Log:
TR1: use std::tr1 regex with msvc10
Added:
lyx-devel/trunk/src/support/regex.h (contents, props changed)
Modified:
lyx-devel/trunk/development/cmake/CMakeLists.txt
lyx-devel/trunk/development/cmake/boost/libs/CMakeLists.txt
lyx-devel/trunk/development/cmake/boost/libs/regex/CMakeLists.txt
lyx-devel/trunk/src/BiblioInfo.cpp
lyx-devel/trunk/src/LaTeX.cpp
lyx-devel/trunk/src/Layout.cpp
lyx-devel/trunk/src/LayoutFile.cpp
lyx-devel/trunk/src/VCBackend.cpp
lyx-devel/trunk/src/frontends/qt4/GuiCitation.cpp
lyx-devel/trunk/src/frontends/qt4/qt_helpers.cpp
lyx-devel/trunk/src/insets/ExternalTransforms.cpp
lyx-devel/trunk/src/insets/InsetListings.cpp
lyx-devel/trunk/src/lyxfind.cpp
lyx-devel/trunk/src/support/filetools.cpp
lyx-devel/trunk/src/tex2lyx/preamble.cpp
Modified: lyx-devel/trunk/development/cmake/CMakeLists.txt
==============================================================================
--- lyx-devel/trunk/development/cmake/CMakeLists.txt Tue Jun 29 19:08:17 \
2010 (r34724)
+++ lyx-devel/trunk/development/cmake/CMakeLists.txt Tue Jun 29 19:09:40 \
2010 (r34725) @@ -479,7 +479,7 @@
endif()
else()
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>")
include_directories(${TOP_SRC_DIR}/boost)
add_subdirectory(boost)
Modified: lyx-devel/trunk/development/cmake/boost/libs/CMakeLists.txt
==============================================================================
--- lyx-devel/trunk/development/cmake/boost/libs/CMakeLists.txt Tue Jun 29 19:08:17 \
2010 (r34724)
+++ lyx-devel/trunk/development/cmake/boost/libs/CMakeLists.txt Tue Jun 29 19:09:40 \
2010 (r34725) @@ -6,6 +6,11 @@
project(boost)
-add_subdirectory(regex)
+if(MSVC10)
+ message(STATUS "Using TR1 regex")
+else()
+ add_subdirectory(regex)
+endif()
+
add_subdirectory(signals)
Modified: lyx-devel/trunk/development/cmake/boost/libs/regex/CMakeLists.txt
==============================================================================
--- lyx-devel/trunk/development/cmake/boost/libs/regex/CMakeLists.txt Tue Jun 29 \
19:08:17 2010 (r34724)
+++ lyx-devel/trunk/development/cmake/boost/libs/regex/CMakeLists.txt Tue Jun 29 \
19:09:40 2010 (r34725) @@ -21,3 +21,5 @@
add_library(boost_regex STATIC ${boost_regex_sources})
+set(BOOST_REGEX_LIB boost_regex CACHE STRING "Boost regex lib" FORCE)
+
Modified: lyx-devel/trunk/src/BiblioInfo.cpp
==============================================================================
--- lyx-devel/trunk/src/BiblioInfo.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/BiblioInfo.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -36,7 +36,7 @@
#include "support/lstrings.h"
#include "support/textutils.h"
-#include "boost/regex.hpp"
+#include "support/regex.h"
#include <set>
@@ -175,8 +175,8 @@
// unicodesymbols has things in the form: \"{u},
// whereas we may see things like: \"u. So we'll
// look for that and change it, if necessary.
- static boost::regex const reg("^\\\\\\W\\w");
- if (boost::regex_search(to_utf8(val), reg)) {
+ static lyx::regex const reg("^\\\\\\W\\w");
+ if (lyx::regex_search(to_utf8(val), reg)) {
val.insert(3, from_ascii("}"));
val.insert(2, from_ascii("{"));
}
Modified: lyx-devel/trunk/src/LaTeX.cpp
==============================================================================
--- lyx-devel/trunk/src/LaTeX.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/LaTeX.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -29,12 +29,10 @@
#include "support/Systemcall.h"
#include "support/os.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <fstream>
-using boost::regex;
-using boost::smatch;
using namespace std;
using namespace lyx::support;
@@ -952,7 +950,7 @@
string lastline;
while (ifs) {
// 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.
// Note: all file names and paths might contains spaces.
bool found_file = false;
Modified: lyx-devel/trunk/src/Layout.cpp
==============================================================================
--- lyx-devel/trunk/src/Layout.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/Layout.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -23,7 +23,7 @@
#include "support/lassert.h"
#include "support/lstrings.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
using namespace std;
using namespace lyx::support;
@@ -873,11 +873,11 @@
LASSERT(false, /**/);
#else
// FIXME UNICODE
- // boost::regex is not unicode-safe.
+ // lyx::regex is not unicode-safe.
// Should use QRegExp or (boost::u32regex, but that requires ICU)
- static boost::regex const reg("_\\(([^\\)]+)\\)");
- boost::smatch sub;
- while (boost::regex_search(preamble, sub, reg)) {
+ static regex const reg("_\\(([^\\)]+)\\)");
+ smatch sub;
+ while (regex_search(preamble, sub, reg)) {
string const key = sub.str(1);
string translated;
if (isAscii(key))
Modified: lyx-devel/trunk/src/LayoutFile.cpp
==============================================================================
--- lyx-devel/trunk/src/LayoutFile.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/LayoutFile.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -28,7 +28,7 @@
#include "support/lstrings.h"
#include "support/bind.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <fstream>
@@ -38,8 +38,6 @@
namespace lyx {
-using boost::regex;
-using boost::smatch;
LayoutFile::LayoutFile(string const & fn, string const & cln,
string const & desc, string const & prereq,
Modified: lyx-devel/trunk/src/VCBackend.cpp
==============================================================================
--- lyx-devel/trunk/src/VCBackend.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/VCBackend.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -26,17 +26,14 @@
#include "support/lstrings.h"
#include "support/Path.h"
#include "support/Systemcall.h"
-
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <fstream>
using namespace std;
using namespace lyx::support;
-using boost::regex;
-using boost::regex_match;
-using boost::smatch;
+
namespace lyx {
Modified: lyx-devel/trunk/src/frontends/qt4/GuiCitation.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiCitation.cpp Tue Jun 29 19:08:17 \
2010 (r34724)
+++ lyx-devel/trunk/src/frontends/qt4/GuiCitation.cpp Tue Jun 29 19:09:40 \
2010 (r34725) @@ -41,7 +41,7 @@
#undef KeyPress
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <algorithm>
#include <string>
@@ -673,9 +673,9 @@
{
// Search for all chars '.|*?+(){}[^$]\'
// 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.
- static const boost::regex reg("[].|*?+(){}^$\\[\\\\]");
+ static const lyx::regex reg("[].|*?+(){}^$\\[\\\\]");
// $& is a perl-like expression that expands to all
// of the current match
@@ -683,7 +683,7 @@
// boost to treat it as a literal.
// Thus, to prefix a matched expression with '\', we use:
// 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 @@
if (!regex)
// 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);
- boost::regex reg_exp;
+ lyx::regex reg_exp;
try {
reg_exp.assign(to_utf8(expr), case_sensitive ?
- boost::regex_constants::normal : boost::regex_constants::icase);
- } catch (boost::regex_error & e) {
- // boost::regex throws an exception if the regular expression is not
+ lyx::regex_constants::ECMAScript : lyx::regex_constants::icase);
+ } catch (lyx::regex_error & e) {
+ // lyx::regex throws an exception if the regular expression is not
// valid.
LYXERR(Debug::GUI, e.what());
return vector<docstring>();
@@ -734,10 +734,10 @@
continue;
try {
- if (boost::regex_search(data, reg_exp))
+ if (lyx::regex_search(data, reg_exp))
foundKeys.push_back(*it);
}
- catch (boost::regex_error & e) {
+ catch (lyx::regex_error & e) {
LYXERR(Debug::GUI, e.what());
return vector<docstring>();
}
Modified: lyx-devel/trunk/src/frontends/qt4/qt_helpers.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/qt_helpers.cpp Tue Jun 29 19:08:17 \
2010 (r34724)
+++ lyx-devel/trunk/src/frontends/qt4/qt_helpers.cpp Tue Jun 29 19:09:40 \
2010 (r34725) @@ -50,7 +50,7 @@
// for FileFilter.
// FIXME: Remove
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <boost/tokenizer.hpp>
@@ -338,17 +338,17 @@
{
// Matches " *.{abc,def,ghi}", storing "*." as group 1 and
// "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.
- static boost::regex const block_re("([^,}]+),?");
+ static lyx::regex const block_re("([^,}]+),?");
string pattern;
string::const_iterator it = glob.begin();
string::const_iterator const end = glob.end();
while (true) {
- boost::match_results<string::const_iterator> what;
- if (!boost::regex_search(it, end, what, glob_re)) {
+ match_results<string::const_iterator> what;
+ if (!regex_search(it, end, what, glob_re)) {
// Ensure that no information is lost.
pattern += string(it, end);
break;
@@ -365,7 +365,7 @@
// Split the ','-separated chunks of tail so that
// $head{$chunk1,$chunk2} becomes "$head$chunk1 $head$chunk2".
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.
it += distance(it, what[0].second);
@@ -474,14 +474,14 @@
// Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
// into individual filters.
- static boost::regex const separator_re(";;");
+ static lyx::regex const separator_re(";;");
string::const_iterator it = filter.begin();
string::const_iterator const end = filter.end();
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));
break;
}
@@ -500,10 +500,10 @@
{
// Matches "TeX documents (*.tex)",
// 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;
- if (!boost::regex_search(filter, what, filter_re)) {
+ match_results<string::const_iterator> what;
+ if (!lyx::regex_search(filter, what, filter_re)) {
// Just a glob, no description.
filters_.push_back(Filter(docstring(), trim(filter)));
} else {
Modified: lyx-devel/trunk/src/insets/ExternalTransforms.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/ExternalTransforms.cpp Tue Jun 29 19:08:17 \
2010 (r34724)
+++ lyx-devel/trunk/src/insets/ExternalTransforms.cpp Tue Jun 29 19:09:40 \
2010 (r34725) @@ -18,7 +18,7 @@
#include "support/lyxlib.h" // float_equal
#include "support/Translator.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <cmath> // abs
#include <sstream>
@@ -279,10 +279,10 @@
// Strip any leading commas
// "[,,,,foo..." -> "foo..." ("foo..." may be empty)
string output;
- boost::smatch what;
- static boost::regex const front("^( *[[],*)(.*)$");
+ lyx::smatch what;
+ 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) {
lyxerr << "Unable to sanitize LaTeX \"Option\": "
<< input << '\n';
@@ -293,9 +293,9 @@
// Replace any consecutive commas with a single one
// "foo,,,,bar" -> "foo,bar"
// with iterator now pointing to 'b'
- static boost::regex const commas("([^,]*)(,,*)(.*)$");
+ static lyx::regex const commas("([^,]*)(,,*)(.*)$");
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) {
output += string(it, end);
break;
@@ -306,7 +306,7 @@
// Strip any trailing commas
// "...foo,,,]" -> "...foo" ("...foo,,," may be empty)
- static boost::regex const back("^(.*[^,])?,*[]] *$");
+ static lyx::regex const back("^(.*[^,])?,*[]] *$");
regex_match(output, what, back);
if (!what[0].matched) {
lyxerr << "Unable to sanitize LaTeX \"Option\": "
Modified: lyx-devel/trunk/src/insets/InsetListings.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetListings.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/insets/InsetListings.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -38,7 +38,7 @@
#include "frontends/alert.h"
#include "frontends/Application.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <sstream>
@@ -47,7 +47,6 @@
namespace lyx {
-using boost::regex;
char const lstinline_delimiters[] =
"!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
Modified: lyx-devel/trunk/src/lyxfind.cpp
==============================================================================
--- lyx-devel/trunk/src/lyxfind.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/lyxfind.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -47,7 +47,7 @@
#include "support/lassert.h"
#include "support/lstrings.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <boost/next_prior.hpp>
using namespace std;
@@ -559,14 +559,14 @@
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,
string const & replacestr)
{
- boost::regex e(searchstr);
+ lyx::regex e(searchstr);
ostringstream 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
bool rv = (s != oss.str());
t = oss.str();
@@ -661,9 +661,9 @@
// normalized string to search
string par_as_string;
// regular expression to use for searching
- boost::regex regexp;
+ lyx::regex regexp;
// same as regexp, but prefixed with a ".*"
- boost::regex regexp2;
+ lyx::regex regexp2;
// unmatched open braces in the search string/regexp
int open_braces;
// number of (.*?) subexpressions added at end of search regexp for closing
@@ -722,9 +722,9 @@
LYXERR(Debug::FIND, "Close .*? : " << close_wildcards);
LYXERR(Debug::FIND, "Replaced text (to be used as regex): " << par_as_string);
// 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
- regexp2 = boost::regex(string("\\`.*") + par_as_string);
+ regexp2 = lyx::regex(string("\\`.*") + par_as_string);
}
}
@@ -747,11 +747,11 @@
} else {
// Try all possible regexp matches,
//until one that verifies the braces match test is found
- boost::regex const *p_regexp = at_begin ? ®exp : ®exp2;
- boost::sregex_iterator re_it(str.begin(), str.end(), *p_regexp);
- boost::sregex_iterator re_it_end;
+ regex const *p_regexp = at_begin ? ®exp : ®exp2;
+ sregex_iterator re_it(str.begin(), str.end(), *p_regexp);
+ sregex_iterator re_it_end;
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,
// plus the last subexpression, if a (.*?) was inserted in the constructor.
if (! braces_match(m[0].first, m[0].second, open_braces))
@@ -1222,7 +1222,7 @@
else
match_len = findBackwardsAdv(cur, matchAdv);
} catch (...) {
- // This may only be raised by boost::regex()
+ // This may only be raised by lyx::regex()
bv->message(_("Invalid regular expression!"));
return false;
}
Modified: lyx-devel/trunk/src/support/filetools.cpp
==============================================================================
--- lyx-devel/trunk/src/support/filetools.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/support/filetools.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -36,7 +36,7 @@
#include <QDir>
#include "support/lassert.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <fcntl.h>
@@ -537,9 +537,9 @@
// $\{[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 boost::regex envvar_re("(.*)" + envvar + "(.*)");
- boost::smatch what;
+ static regex envvar_br_re("(.*)" + envvar_br + "(.*)");
+ static regex envvar_re("(.*)" + envvar + "(.*)");
+ smatch what;
string result;
string remaining = path;
while (1) {
@@ -921,13 +921,13 @@
return string();
}
- static boost::regex bbox_re(
+ static lyx::regex bbox_re(
"^%%BoundingBox:\\s*([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)\\s+([[:digit:]]+)");
ifstream is(file_.toFilesystemEncoding().c_str());
while (is) {
string s;
getline(is,s);
- boost::smatch what;
+ lyx::smatch what;
if (regex_match(s, what, bbox_re)) {
// Our callers expect the tokens in the string
// separated by single spaces.
Added: lyx-devel/trunk/src/support/regex.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ lyx-devel/trunk/src/support/regex.h Tue Jun 29 19:09:40 2010 (r34725)
@@ -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
Modified: lyx-devel/trunk/src/tex2lyx/preamble.cpp
==============================================================================
--- lyx-devel/trunk/src/tex2lyx/preamble.cpp Tue Jun 29 19:08:17 2010 (r34724)
+++ lyx-devel/trunk/src/tex2lyx/preamble.cpp Tue Jun 29 19:09:40 2010 (r34725)
@@ -25,7 +25,7 @@
#include "support/filetools.h"
#include "support/lstrings.h"
-#include <boost/regex.hpp>
+#include "support/regex.h"
#include <algorithm>
#include <iostream>
@@ -36,8 +36,7 @@
using namespace std;
using namespace lyx::support;
-using boost::regex;
-using boost::smatch;
+
namespace lyx {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic