CONFIG: use C++11 regex instead of POSIX for newer compilers

BUG: The ok_ flag was not being updated in the regExpCxx::set() method
This commit is contained in:
Mark Olesen
2019-05-21 12:29:52 +01:00
committed by Andrew Heather
parent 515027b7ab
commit 3a00dd9b9a
8 changed files with 60 additions and 12 deletions

View File

@ -27,12 +27,16 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOobject.H"
#include "IOstreams.H"
#include "IFstream.H"
#include "Switch.H"
#include "SubStrings.H"
#include "regExpCxx.H"
#ifndef _WIN32
#include "regExpPosix.H"
#endif
using namespace Foam;
@ -83,6 +87,7 @@ static Ostream& operator<<(Ostream& os, const regExpCxx::results_type& sm)
// Simple output of match groups
#ifndef _WIN32
static Ostream& operator<<(Ostream& os, const regExpPosix::results_type& sm)
{
for (std::smatch::size_type i = 1; i < sm.size(); ++i)
@ -92,6 +97,7 @@ static Ostream& operator<<(Ostream& os, const regExpPosix::results_type& sm)
return os;
}
#endif
template<class RegexType>
@ -209,7 +215,6 @@ void generalTests()
}
template<class RegexType>
void testExpressions(const UList<regexTest>& tests)
{
@ -293,11 +298,13 @@ int main(int argc, char *argv[])
"Test C++11 regular expressions"
);
#ifndef _WIN32
argList::addBoolOption
(
"posix",
"Test POSIX regular expressions"
);
#endif
argList::addArgument("file");
argList::addArgument("...");
@ -306,6 +313,17 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
if (std::is_same<regExp, regExpCxx>::value)
{
Info<<"Foam::regExp uses C++11 regex" << nl << nl;
}
#ifndef _WIN32
if (std::is_same<regExp, regExpPosix>::value)
{
Info<<"Foam::regExp uses POSIX regex" << nl << nl;
}
#endif
if (!args.count({"cxx", "posix"}))
{
Info<< "Specified one or more of -cxx, -posix" << nl;
@ -321,10 +339,12 @@ int main(int argc, char *argv[])
generalTests<regExpCxx>();
}
#ifndef _WIN32
if (args.found("posix"))
{
generalTests<regExpPosix>();
}
#endif
}
for (label argi = 1; argi < args.size(); ++argi)
@ -339,10 +359,12 @@ int main(int argc, char *argv[])
testExpressions<regExpCxx>(tests);
}
#ifndef _WIN32
if (args.found("posix"))
{
testExpressions<regExpPosix>(tests);
}
#endif
}
Info<< "\nDone" << nl << endl;

View File

@ -0,0 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Pattern, String
(
( true "(U|k|epsilon)" "U" )
( false "(U|k|epsilon)" "alpha" )
( true "ab.*" "abc" )
( true ".*" "abc" )
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //