Dependencies: get rid of boost-regexp (see #995)

Mostly, std::regexp can be used as a drop-in replacement.

Note: unfortunately ECMA regexps do not support lookbehind assertions.
This lookbehind is necesary here because we want to allow parsing values
from strings with additional content, which means we need explicitly to
exclude mismatches due to invalid syntax.

We can work around that issue like "either line start, or *not* one of these characters.


Alternatively we could consider to make the match more rigid,
i.e we would require the string to conain *only* the timecode spec to be parsed.
This commit is contained in:
Fischlurch 2019-06-24 02:41:02 +02:00
parent ab90d9c71d
commit 8ffab2f002
12 changed files with 53 additions and 56 deletions

View file

@ -92,8 +92,6 @@ def configure(env):
problems.append('We need the boost::system support library (including binary lib).')
if not conf.CheckLibWithHeader('boost_filesystem','boost/filesystem.hpp','C++'):
problems.append('We need the boost::filesystem lib (including binary lib for linking).')
if not conf.CheckLibWithHeader('boost_regex','boost/regex.hpp','C++'):
problems.append('We need the boost regular expression lib (incl. binary lib for linking).')
if not conf.CheckPkgConfig('gavl', '1.4'):

View file

@ -1,5 +1,5 @@
Dependencies
============
Build Dependencies
==================
:Author: core-devs
:Date: 11/2015
:toc:
@ -66,7 +66,6 @@ Languages and Tools
- libboost-program-options-dev
- libboost-program-options-dev
- libboost-filesystem-dev
- libboost-regex-dev
* Script languages
- Python (*2.7*) for build scripts

View file

@ -4,14 +4,14 @@ Lumiera build system
As work progresses, we will add more information on the Lumiera build system.
//Menu: label Build System
//Menu: prepend child 'Dependencies'
//Menu: prepend child 'BuildDependencies'
//Menu: prepend child 'SCons'
build -- continuous integration -- packaging
* link:SCons.html[Buildsystem]
* link:Dependencies.html[Dependencies]
* link:BuildDependencies.html[Lumiera Build Dependencies]
* link:BuildDroneDraft.html[»Builddrone« concept from 2008]
* Packaging: link:LumieraDebianPackage.html[Debian] RPM
* Lumiera link:../infra/debianDepot.html/[debian depot]

View file

@ -36,16 +36,16 @@
#include <boost/functional/hash.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <regex>
using lib::Literal;
using util::isnil;
using boost::regex;
using boost::smatch;
using boost::sregex_iterator;
using boost::match_continuous;
using std::regex;
using std::smatch;
using std::sregex_iterator;
using std::regex_constants::match_continuous;
using boost::hash_combine;
using boost::lexical_cast;

View file

@ -30,15 +30,14 @@
#include "lib/util.hpp"
#include "include/logging.h"
#include "lib/cmdline.hpp"
#include "lib/format-util.hpp"
#include <boost/regex.hpp>
#include <boost/algorithm/string/join.hpp>
using boost::regex;
using boost::smatch;
using boost::regex_search;
using boost::algorithm::join;
#include <regex>
using std::regex;
using std::smatch;
using std::regex_search;
using util::join;
using util::noneg;
@ -64,12 +63,12 @@ namespace lib {
*/
Cmdline::Cmdline (const string cmdline)
{
regex tokendef("[^ \r\n\t]+");
static regex TOKENDEF{"\\S+"};
smatch match;
string::const_iterator it = cmdline.begin();
string::const_iterator end = cmdline.end();
while (regex_search(it, end, match, tokendef))
while (regex_search(it, end, match, TOKENDEF))
{
string ss(match[0]);
this->push_back(ss);

View file

@ -27,6 +27,7 @@
** the referred data into a vector of strings. Thus `Cmdline` is a way to
** express explicitly on APIs that we are consuming commandline contents,
** and, moreover, it offers a way more sane interface to deal with those.
** @see CmdlineWrapper_test
*/

View file

@ -31,14 +31,15 @@
#include "lib/util.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <functional>
#include <regex>
#include <map>
using std::map;
using boost::regex;
using boost::smatch;
using boost::regex_search;
using boost::sregex_iterator;
using std::regex;
using std::smatch;
using std::regex_search;
using std::sregex_iterator;
using util::contains;
using util::isnil;
@ -49,7 +50,7 @@ namespace lib {
namespace { // local definitions
typedef boost::function<bool(string::value_type)> ChPredicate;
using ChPredicate = std::function<bool(string::value_type)> ;
ChPredicate is_alpha = boost::algorithm::is_alpha();
ChPredicate is_upper = boost::algorithm::is_upper();
@ -79,14 +80,14 @@ namespace lib {
map<Symbol, regex> regexTable;
Literal matchArgument = "\\(\\s*([\\w_\\.\\-]+)\\s*\\),?\\s*";
regex findPredicate (string("(\\w+)")+matchArgument);
Literal MATCH_ARGUMENT = R"~(\(\s*([\w_\.\-]+)\s*\),?\s*)~";
const regex FIND_PREDICATE{string{"(\\w+)"} + MATCH_ARGUMENT};
inline regex&
getTermRegex (Symbol sym)
{
if (!contains (regexTable, sym))
regexTable[sym] = regex (string(sym)+matchArgument);
regexTable[sym] = regex (string(sym)+MATCH_ARGUMENT);
return regexTable[sym];
}
}
@ -146,7 +147,7 @@ namespace lib {
{
uint cnt (0);
sregex_iterator end;
for (sregex_iterator i (q.begin(),q.end(), findPredicate);
for (sregex_iterator i (q.begin(),q.end(), FIND_PREDICATE);
i != end; ++i)
++cnt;
return cnt;

View file

@ -43,6 +43,8 @@ namespace lib {
LUMIERA_ERROR_DEFINE (FILE_NOT_DIRECTORY, "path element points at a file instead of a directory");
using std::regex;
using std::regex_replace;
const regex SearchPathSplitter::EXTRACT_PATHSPEC ("[^:]+");
@ -78,7 +80,7 @@ namespace lib {
static const string expandedOriginDir
= fsys::path (findExePath()).parent_path().string() + "/"; ///////////TICKET #896
return boost::regex_replace(src, PICK_ORIGIN_TOKEN, expandedOriginDir);
return regex_replace(src, PICK_ORIGIN_TOKEN, expandedOriginDir);
}

View file

@ -37,19 +37,15 @@
#include "lib/nocopy.hpp"
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>
#include <string>
#include <regex>
namespace lib {
using std::string;
using boost::regex;
using boost::smatch;
using boost::regex_search;
using boost::sregex_iterator;
typedef smatch::value_type const& SubMatch;
using SubMatch = std::smatch::value_type const&;
namespace error = lumiera::error;
namespace fsys = boost::filesystem;
@ -77,10 +73,10 @@ namespace lib {
: util::NonCopyable
{
string pathSpec_;
sregex_iterator pos_,
end_;
std::sregex_iterator pos_,
end_;
static const regex EXTRACT_PATHSPEC;
static const std::regex EXTRACT_PATHSPEC;
public:
SearchPathSplitter (string const& searchPath)

View file

@ -36,17 +36,17 @@
#include "lib/util.hpp"
#include "lib/util-quant.hpp"
#include <regex>
#include <functional>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
using std::string;
using util::unConst;
using util::isSameObject;
using util::floorwrap;
using boost::regex;
using boost::smatch;
using boost::regex_search;
using std::string;
using std::regex;
using std::smatch;
using std::regex_search;
using boost::lexical_cast;
namespace error = lumiera::error;
@ -71,8 +71,8 @@ namespace time {
TimeValue
Frames::parse (string const& frameNumber, QuantR frameGrid)
{
static regex frameNr_parser ("(?<![\\.\\-\\d])(-?\\d+)#"); // no leading [.-\d], number+'#'
smatch match;
static regex frameNr_parser{"(?:^|[^\\d\\.\\-])(\\-?\\d+)#"}; // no leading [.-\d], digit+'#'
smatch match; // note: ECMA regexp does not support lookbehind
if (regex_search (frameNumber, match, frameNr_parser))
return frameGrid.timeOf (lexical_cast<FrameCnt> (match[1]));
else
@ -119,8 +119,8 @@ namespace time {
TimeValue
Seconds::parse (string const& seconds, QuantR grid)
{
static regex fracSecs_parser ("(?<![\\./\\-\\d])(-?\\d+)(?:([\\-\\+]\\d+)?/(\\d+))?sec");
//__no leading[./-\d] number [+-] number '/' number 'sec'
static regex fracSecs_parser ("(?:^|[^\\./\\d\\-])(\\-?\\d+)(?:([\\-\\+]\\d+)?/(\\d+))?sec");
//__no leading[./-\d] number [+-] number '/' number 'sec'
#define SUB_EXPR(N) lexical_cast<long> (match[N])
smatch match;

View file

@ -38,7 +38,7 @@
#include "lib/util.hpp"
#include "include/logging.h"
#include <boost/regex.hpp>
#include <regex>
using util::_Fmt;
@ -48,9 +48,9 @@ using lib::time::Duration;
using backend_interface::MediaDesc;
using backend_interface::MediaAccessFacade;
using boost::regex;
using boost::smatch;
using boost::regex_search;
using std::regex;
using std::smatch;
using std::regex_search;
using std::dynamic_pointer_cast;
namespace error = lumiera::error;
@ -66,10 +66,10 @@ namespace asset {
*/
string extractName (const string& path)
{
regex pathname_pattern("([^/\\.]+)(\\.\\w+)?$");
static regex PATHNAME_PATTERN("([^/\\.]+)(\\.\\w+)?$");
smatch match;
if (regex_search (path, match, pathname_pattern))
if (regex_search (path, match, PATHNAME_PATTERN))
return util::sanitise (string (match[1]));
else
return "";

View file

@ -144,6 +144,7 @@ namespace test{
Parsing<format::Frames> ("xxx25#xxx") .should_yield (1);
Parsing<format::Frames> ("12 25#") .should_yield (1);
Parsing<format::Frames> ("12 25# 33#") .should_yield (1); // note pitfall: the first valid number is used
Parsing<format::Frames> ("12 25# \n 33#") .should_yield (1);
Parsing<format::Frames> ("12\n 25# \n 33#") .should_yield (1);
Parsing<format::Frames> ("12.25#") .should_fail(); // rejected because of leading dot (ambiguity)
}