From 7c9f49b98f4610998930ca1939acf64cc9a35185 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs@hunt.opencfd.co.uk>
Date: Mon, 24 Nov 2008 16:35:18 +0000
Subject: [PATCH] full match

---
 src/OSspecific/Unix/regularExpression.H   | 12 ++++++++----
 src/OpenFOAM/db/dictionary/dictionary.C   |  1 +
 src/OpenFOAM/db/dictionary/dictionary.H   |  3 +--
 src/OpenFOAM/db/dictionary/dictionaryIO.C |  1 +
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/OSspecific/Unix/regularExpression.H b/src/OSspecific/Unix/regularExpression.H
index 9924caef28f..fed14379ad9 100644
--- a/src/OSspecific/Unix/regularExpression.H
+++ b/src/OSspecific/Unix/regularExpression.H
@@ -37,6 +37,8 @@ SourceFiles
 
 #include <sys/types.h>
 #include <regex.h>
+#include "string.H"
+#include "IOstreams.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -73,7 +75,7 @@ public:
         {
             preg_ = new regex_t;
 
-            if (regcomp(preg_, s.c_str(), REG_EXTENDED|REG_NOSUB) != 0)
+            if (regcomp(preg_, s.c_str(), REG_EXTENDED) != 0)
             {
                 FatalErrorIn
                 (
@@ -102,10 +104,12 @@ public:
         //- Matches?
         inline bool matches(const string& s) const
         {
-            size_t nmatch = 0;
-            regmatch_t *pmatch = NULL;
+            size_t nmatch = 1;
+            regmatch_t pmatch[1];
 
-            return regexec(preg_, s.c_str(), nmatch, pmatch, 0) == 0;
+            int errVal = regexec(preg_, s.c_str(), nmatch, pmatch, 0);
+
+            return (errVal == 0 && pmatch[0].rm_eo == label(s.size()));
         }
 };
 
diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C
index ad960e74057..265a2944cb0 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.C
+++ b/src/OpenFOAM/db/dictionary/dictionary.C
@@ -27,6 +27,7 @@ License
 #include "dictionary.H"
 #include "primitiveEntry.H"
 #include "dictionaryEntry.H"
+#include "regularExpression.H"
 
 /* * * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * */
 
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index ac6ca653896..b1d0d186f65 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -60,7 +60,6 @@ SourceFiles
 #include "HashTable.H"
 #include "wordList.H"
 #include "className.H"
-#include "regularExpression.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -68,7 +67,7 @@ namespace Foam
 {
 
 // Forward declaration of friend functions and operators
-
+class regularExpression;
 class dictionary;
 Istream& operator>>(Istream&, dictionary&);
 Ostream& operator<<(Ostream&, const dictionary&);
diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C
index b1d5fbcbc45..cb04194915c 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C
@@ -27,6 +27,7 @@ License
 #include "dictionary.H"
 #include "IFstream.H"
 #include "inputModeEntry.H"
+#include "regularExpression.H"
 
 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
 
-- 
GitLab