From 215349aa69a1358050f5fba5645b5ffb8c064925 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Fri, 10 Mar 2017 13:05:35 +0100 Subject: [PATCH] BUG: in wordRe::operator=(const keyType&) - the regex was not being unset on assignment. - drop unused recompile() method as being dubious --- applications/test/wordRe/Test-wordRe.C | 4 ++-- src/OpenFOAM/primitives/strings/wordRe/wordRe.H | 7 ++----- src/OpenFOAM/primitives/strings/wordRe/wordReI.H | 15 ++++----------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C index e3fae58cc57..f5dfcda831f 100644 --- a/applications/test/wordRe/Test-wordRe.C +++ b/applications/test/wordRe/Test-wordRe.C @@ -75,8 +75,8 @@ int main(int argc, char *argv[]) wre.info(Info) << " after DETECT" << endl; wre.uncompile(); wre.info(Info) << " uncompiled" << endl; - wre.recompile(); - wre.info(Info) << " recompiled" << endl; + wre.compile(); + wre.info(Info) << " re-compiled" << endl; wre.set("something .* value", wordRe::LITERAL); wre.info(Info) << " set as LITERAL" << endl; diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index c5a0a3b95ed..612b2c96ab5 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H @@ -39,8 +39,8 @@ Description Note If the string contents are changed - eg, by the operator+=() or by - string::replace(), etc - it will be necessary to use compile() or - recompile() to synchronize the regular expression. + string::replace(), etc - it will be necessary to use compile() to + synchronize the regular expression. SourceFiles wordRe.C @@ -161,9 +161,6 @@ public: //- Possibly compile the regular expression, with greater control inline bool compile(const compOption) const; - //- Recompile an existing regular expression - inline bool recompile() const; - //- Frees precompiled regular expression, making wordRe a literal. // Optionally strips invalid word characters inline void uncompile(const bool doStripInvalid = false) const; diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H index d35a8134b7c..093093e0551 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H @@ -165,17 +165,6 @@ inline bool Foam::wordRe::compile() const } -inline bool Foam::wordRe::recompile() const -{ - if (re_.exists()) - { - re_ = *this; - } - - return re_.exists(); -} - - inline void Foam::wordRe::uncompile(const bool doStripInvalid) const { if (re_.clear()) @@ -265,6 +254,10 @@ inline void Foam::wordRe::operator=(const keyType& str) { compile(); } + else + { + re_.clear(); + } } -- GitLab