[Cmake-commits] CMake branch, master, updated. v3.10.0-540-g9820657

Kitware Robot kwrobot at kitware.com
Wed Dec 6 08:05:11 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  98206571fb68881fe373c040ae703aac318fe6d7 (commit)
       via  22f440ae6930c8ef9eccfa65530c6b59949657ef (commit)
       via  b6dd3969e819a7a2508c8f705ef7e13fb7e11dff (commit)
       via  79b241dee076d594f5527a148142c0c15a5909dc (commit)
       via  4a8bbc520aa62187fb70aaf0c28daa67e275c26e (commit)
       via  52a5c4a877d066a283e76bd5b6e63a9f3eec31ea (commit)
       via  2047eb360de5a9d2a8cac6a689bd7846c5a0128f (commit)
       via  bde7513d2fcd7a366eb4dd93fc1f061334743bb7 (commit)
      from  a442624def318c950936c8d49964c4b3bfb0487d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=98206571fb68881fe373c040ae703aac318fe6d7
commit 98206571fb68881fe373c040ae703aac318fe6d7
Merge: 22f440a 79b241d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Dec 6 13:00:48 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Dec 6 08:01:20 2017 -0500

    Merge topic 'update-kwsys'
    
    79b241de cmake-gui: Update RegexExplorer for changes to KWSys
    4a8bbc52 Merge branch 'upstream-KWSys' into update-kwsys
    52a5c4a8 KWSys 2017-12-05 (9376537e)
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1558


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=22f440ae6930c8ef9eccfa65530c6b59949657ef
commit 22f440ae6930c8ef9eccfa65530c6b59949657ef
Merge: b6dd396 bde7513
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Dec 6 13:00:12 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Dec 6 08:00:46 2017 -0500

    Merge topic 'findmpi-notfound-spam'
    
    bde7513d FindMPI: Correct legacy variable handling
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1557


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b6dd3969e819a7a2508c8f705ef7e13fb7e11dff
commit b6dd3969e819a7a2508c8f705ef7e13fb7e11dff
Merge: a442624 2047eb3
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Dec 6 13:00:01 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Dec 6 08:00:07 2017 -0500

    Merge topic 'findmpi-found-cond'
    
    2047eb36 FindMPI: Fix multiple configure runs
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1556


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=79b241dee076d594f5527a148142c0c15a5909dc
commit 79b241dee076d594f5527a148142c0c15a5909dc
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Dec 5 11:32:08 2017 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Dec 5 11:32:08 2017 -0500

    cmake-gui: Update RegexExplorer for changes to KWSys

diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx
index abed70e..cb67f85 100644
--- a/Source/QtDialog/RegexExplorer.cxx
+++ b/Source/QtDialog/RegexExplorer.cxx
@@ -8,7 +8,7 @@ RegexExplorer::RegexExplorer(QWidget* p)
 {
   this->setupUi(this);
 
-  for (int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i) {
+  for (int i = 1; i < cmsys::RegularExpressionMatch::NSUBEXP; ++i) {
     matchNumber->addItem(QString("Match %1").arg(QString::number(i)),
                          QVariant(i));
   }
@@ -105,7 +105,7 @@ void RegexExplorer::on_matchNumber_currentIndexChanged(int index)
   QVariant itemData = matchNumber->itemData(index);
   int idx = itemData.toInt();
 
-  if (idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP) {
+  if (idx < 1 || idx >= cmsys::RegularExpressionMatch::NSUBEXP) {
     return;
   }
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4a8bbc520aa62187fb70aaf0c28daa67e275c26e
commit 4a8bbc520aa62187fb70aaf0c28daa67e275c26e
Merge: d06b826 52a5c4a
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Dec 5 11:31:27 2017 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Dec 5 11:31:27 2017 -0500

    Merge branch 'upstream-KWSys' into update-kwsys
    
    * upstream-KWSys:
      KWSys 2017-12-05 (9376537e)


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52a5c4a877d066a283e76bd5b6e63a9f3eec31ea
commit 52a5c4a877d066a283e76bd5b6e63a9f3eec31ea
Author:     KWSys Upstream <kwrobot at kitware.com>
AuthorDate: Tue Dec 5 11:30:36 2017 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Dec 5 11:31:27 2017 -0500

    KWSys 2017-12-05 (9376537e)
    
    Code extracted from:
    
        https://gitlab.kitware.com/utils/kwsys.git
    
    at commit 9376537ec0e4770a28f4b1705cfacf79650f71b6 (master).
    
    Upstream Shortlog
    -----------------
    
    Brad King (1):
          e9557f37 RegularExpression: Fix regression in 'find' method
    
    Sebastian Holtermann (4):
          4d1e8738 RegularExpression: Make compile() reentrant (thread safe)
          64f80068 RegularExpression: Make find() reentrant (thread safe)
          bbc94ba8 RegularExpression: Remove unused code
          cff58f07 RegularExpression: New RegularExpressionMatch class

diff --git a/RegularExpression.cxx b/RegularExpression.cxx
index 26e84e0..fa3551c 100644
--- a/RegularExpression.cxx
+++ b/RegularExpression.cxx
@@ -45,9 +45,9 @@ RegularExpression::RegularExpression(const RegularExpression& rxp)
   this->program = new char[this->progsize]; // Allocate storage
   for (ind = this->progsize; ind-- != 0;)   // Copy regular expresion
     this->program[ind] = rxp.program[ind];
-  this->startp[0] = rxp.startp[0]; // Copy pointers into last
-  this->endp[0] = rxp.endp[0];     // Successful "find" operation
-  this->regmust = rxp.regmust;     // Copy field
+  // Copy pointers into last successful "find" operation
+  this->regmatch = rxp.regmatch;
+  this->regmust = rxp.regmust; // Copy field
   if (rxp.regmust != 0) {
     char* dum = rxp.program;
     ind = 0;
@@ -78,9 +78,9 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
   this->program = new char[this->progsize]; // Allocate storage
   for (ind = this->progsize; ind-- != 0;)   // Copy regular expresion
     this->program[ind] = rxp.program[ind];
-  this->startp[0] = rxp.startp[0]; // Copy pointers into last
-  this->endp[0] = rxp.endp[0];     // Successful "find" operation
-  this->regmust = rxp.regmust;     // Copy field
+  // Copy pointers into last successful "find" operation
+  this->regmatch = rxp.regmatch;
+  this->regmust = rxp.regmust; // Copy field
   if (rxp.regmust != 0) {
     char* dum = rxp.program;
     ind = 0;
@@ -123,8 +123,9 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
   while (ind-- != 0)                            // Else while still characters
     if (this->program[ind] != rxp.program[ind]) // If regexp are different
       return false;                             // Return failure
-  return (this->startp[0] == rxp.startp[0] &&   // Else if same start/end ptrs,
-          this->endp[0] == rxp.endp[0]);        // Return true
+  // Else if same start/end ptrs, return true
+  return (this->regmatch.start() == rxp.regmatch.start() &&
+          this->regmatch.end() == rxp.regmatch.end());
 }
 
 // The remaining code in this file is derived from the  regular expression code
@@ -276,31 +277,35 @@ const unsigned char MAGIC = 0234;
 /////////////////////////////////////////////////////////////////////////
 
 /*
- * Global work variables for compile().
+ * Read only utility variables.
  */
-static const char* regparse; // Input-scan pointer.
-static int regnpar;          // () count.
 static char regdummy;
-static char* regcode; // Code-emit pointer; &regdummy = don't.
-static long regsize;  // Code size.
+static char* const regdummyptr = ®dummy;
 
 /*
- * Forward declarations for compile()'s friends.
+ * Utility class for RegularExpression::compile().
  */
-// #ifndef static
-// #define      static  static
-// #endif
-static char* reg(int, int*);
-static char* regbranch(int*);
-static char* regpiece(int*);
-static char* regatom(int*);
-static char* regnode(char);
+class RegExpCompile
+{
+public:
+  const char* regparse; // Input-scan pointer.
+  int regnpar;          // () count.
+  char* regcode;        // Code-emit pointer; regdummyptr = don't.
+  long regsize;         // Code size.
+
+  char* reg(int, int*);
+  char* regbranch(int*);
+  char* regpiece(int*);
+  char* regatom(int*);
+  char* regnode(char);
+  void regc(char);
+  void reginsert(char, char*);
+  static void regtail(char*, const char*);
+  static void regoptail(char*, const char*);
+};
+
 static const char* regnext(const char*);
 static char* regnext(char*);
-static void regc(char);
-static void reginsert(char, char*);
-static void regtail(char*, const char*);
-static void regoptail(char*, const char*);
 
 #ifdef STRCSPN
 static int strcspn();
@@ -337,19 +342,20 @@ bool RegularExpression::compile(const char* exp)
   }
 
   // First pass: determine size, legality.
-  regparse = exp;
-  regnpar = 1;
-  regsize = 0L;
-  regcode = ®dummy;
-  regc(static_cast<char>(MAGIC));
-  if (!reg(0, &flags)) {
+  RegExpCompile comp;
+  comp.regparse = exp;
+  comp.regnpar = 1;
+  comp.regsize = 0L;
+  comp.regcode = regdummyptr;
+  comp.regc(static_cast<char>(MAGIC));
+  if (!comp.reg(0, &flags)) {
     printf("RegularExpression::compile(): Error in compile.\n");
     return false;
   }
-  this->startp[0] = this->endp[0] = this->searchstring = 0;
+  this->regmatch.clear();
 
   // Small enough for pointer-storage convention?
-  if (regsize >= 32767L) { // Probably could be 65535L.
+  if (comp.regsize >= 32767L) { // Probably could be 65535L.
     // RAISE Error, SYM(RegularExpression), SYM(Expr_Too_Big),
     printf("RegularExpression::compile(): Expression too big.\n");
     return false;
@@ -360,8 +366,8 @@ bool RegularExpression::compile(const char* exp)
   if (this->program != 0)
     delete[] this->program;
   //#endif
-  this->program = new char[regsize];
-  this->progsize = static_cast<int>(regsize);
+  this->program = new char[comp.regsize];
+  this->progsize = static_cast<int>(comp.regsize);
 
   if (this->program == 0) {
     // RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
@@ -370,11 +376,11 @@ bool RegularExpression::compile(const char* exp)
   }
 
   // Second pass: emit code.
-  regparse = exp;
-  regnpar = 1;
-  regcode = this->program;
-  regc(static_cast<char>(MAGIC));
-  reg(0, &flags);
+  comp.regparse = exp;
+  comp.regnpar = 1;
+  comp.regcode = this->program;
+  comp.regc(static_cast<char>(MAGIC));
+  comp.reg(0, &flags);
 
   // Dig out information for optimizations.
   this->regstart = '\0'; // Worst-case defaults.
@@ -423,7 +429,7 @@ bool RegularExpression::compile(const char* exp)
  * is a trifle forced, but the need to tie the tails of the branches to what
  * follows makes it hard to avoid.
  */
-static char* reg(int paren, int* flagp)
+char* RegExpCompile::reg(int paren, int* flagp)
 {
   char* ret;
   char* br;
@@ -435,7 +441,7 @@ static char* reg(int paren, int* flagp)
 
   // Make an OPEN node, if parenthesized.
   if (paren) {
-    if (regnpar >= RegularExpression::NSUBEXP) {
+    if (regnpar >= RegularExpressionMatch::NSUBEXP) {
       // RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens),
       printf("RegularExpression::compile(): Too many parentheses.\n");
       return 0;
@@ -501,7 +507,7 @@ static char* reg(int paren, int* flagp)
  *
  * Implements the concatenation operator.
  */
-static char* regbranch(int* flagp)
+char* RegExpCompile::regbranch(int* flagp)
 {
   char* ret;
   char* chain;
@@ -538,7 +544,7 @@ static char* regbranch(int* flagp)
  * It might seem that this node could be dispensed with entirely, but the
  * endmarker role is not redundant.
  */
-static char* regpiece(int* flagp)
+char* RegExpCompile::regpiece(int* flagp)
 {
   char* ret;
   char op;
@@ -605,7 +611,7 @@ static char* regpiece(int* flagp)
  * faster to run.  Backslashed characters are exceptions, each becoming a
  * separate node; the code is simpler that way and it's not worth fixing.
  */
-static char* regatom(int* flagp)
+char* RegExpCompile::regatom(int* flagp)
 {
   char* ret;
   int flags;
@@ -724,13 +730,13 @@ static char* regatom(int* flagp)
  - regnode - emit a node
    Location.
  */
-static char* regnode(char op)
+char* RegExpCompile::regnode(char op)
 {
   char* ret;
   char* ptr;
 
   ret = regcode;
-  if (ret == &regdummy) {
+  if (ret == regdummyptr) {
     regsize += 3;
     return (ret);
   }
@@ -747,9 +753,9 @@ static char* regnode(char op)
 /*
  - regc - emit (if appropriate) a byte of code
  */
-static void regc(char b)
+void RegExpCompile::regc(char b)
 {
-  if (regcode != &regdummy)
+  if (regcode != regdummyptr)
     *regcode++ = b;
   else
     regsize++;
@@ -760,13 +766,13 @@ static void regc(char b)
  *
  * Means relocating the operand.
  */
-static void reginsert(char op, char* opnd)
+void RegExpCompile::reginsert(char op, char* opnd)
 {
   char* src;
   char* dst;
   char* place;
 
-  if (regcode == &regdummy) {
+  if (regcode == regdummyptr) {
     regsize += 3;
     return;
   }
@@ -786,13 +792,13 @@ static void reginsert(char op, char* opnd)
 /*
  - regtail - set the next-pointer at the end of a node chain
  */
-static void regtail(char* p, const char* val)
+void RegExpCompile::regtail(char* p, const char* val)
 {
   char* scan;
   char* temp;
   int offset;
 
-  if (p == &regdummy)
+  if (p == regdummyptr)
     return;
 
   // Find last node.
@@ -815,10 +821,10 @@ static void regtail(char* p, const char* val)
 /*
  - regoptail - regtail on operand of first argument; nop if operandless
  */
-static void regoptail(char* p, const char* val)
+void RegExpCompile::regoptail(char* p, const char* val)
 {
   // "Operandless" and "op != BRANCH" are synonymous in practice.
-  if (p == 0 || p == &regdummy || OP(p) != BRANCH)
+  if (p == 0 || p == regdummyptr || OP(p) != BRANCH)
     return;
   regtail(OPERAND(p), val);
 }
@@ -830,34 +836,30 @@ static void regoptail(char* p, const char* val)
 ////////////////////////////////////////////////////////////////////////
 
 /*
- * Global work variables for find().
+ * Utility class for RegularExpression::find().
  */
-static const char* reginput;   // String-input pointer.
-static const char* regbol;     // Beginning of input, for ^ check.
-static const char** regstartp; // Pointer to startp array.
-static const char** regendp;   // Ditto for endp.
+class RegExpFind
+{
+public:
+  const char* reginput;   // String-input pointer.
+  const char* regbol;     // Beginning of input, for ^ check.
+  const char** regstartp; // Pointer to startp array.
+  const char** regendp;   // Ditto for endp.
 
-/*
- * Forwards.
- */
-static int regtry(const char*, const char**, const char**, const char*);
-static int regmatch(const char*);
-static int regrepeat(const char*);
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump();
-static char* regprop();
-#endif
+  int regtry(const char*, const char**, const char**, const char*);
+  int regmatch(const char*);
+  int regrepeat(const char*);
+};
 
 // find -- Matches the regular expression to the given string.
 // Returns true if found, and sets start and end indexes accordingly.
-
-bool RegularExpression::find(const char* string)
+bool RegularExpression::find(char const* string,
+                             RegularExpressionMatch& rmatch) const
 {
   const char* s;
 
-  this->searchstring = string;
+  rmatch.clear();
+  rmatch.searchstring = string;
 
   if (!this->program) {
     return false;
@@ -868,7 +870,7 @@ bool RegularExpression::find(const char* string)
     // RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
     printf(
       "RegularExpression::find(): Compiled regular expression corrupted.\n");
-    return 0;
+    return false;
   }
 
   // If there is a "must appear" string, look for it.
@@ -880,42 +882,45 @@ bool RegularExpression::find(const char* string)
       s++;
     }
     if (s == 0) // Not present.
-      return (0);
+      return false;
   }
 
+  RegExpFind regFind;
+
   // Mark beginning of line for ^ .
-  regbol = string;
+  regFind.regbol = string;
 
   // Simplest case:  anchored match need be tried only once.
   if (this->reganch)
-    return (regtry(string, this->startp, this->endp, this->program) != 0);
+    return (
+      regFind.regtry(string, rmatch.startp, rmatch.endp, this->program) != 0);
 
   // Messy cases:  unanchored match.
   s = string;
   if (this->regstart != '\0')
     // We know what char it must start with.
     while ((s = strchr(s, this->regstart)) != 0) {
-      if (regtry(s, this->startp, this->endp, this->program))
-        return (1);
+      if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
+        return true;
       s++;
     }
   else
     // We don't -- general case.
     do {
-      if (regtry(s, this->startp, this->endp, this->program))
-        return (1);
+      if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
+        return true;
     } while (*s++ != '\0');
 
   // Failure.
-  return (0);
+  return false;
 }
 
 /*
  - regtry - try match at specific point
    0 failure, 1 success
  */
-static int regtry(const char* string, const char** start, const char** end,
-                  const char* prog)
+int RegExpFind::regtry(const char* string, const char** start,
+                       const char** end, const char* prog)
 {
   int i;
   const char** sp1;
@@ -927,7 +932,7 @@ static int regtry(const char* string, const char** start, const char** end,
 
   sp1 = start;
   ep = end;
-  for (i = RegularExpression::NSUBEXP; i > 0; i--) {
+  for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) {
     *sp1++ = 0;
     *ep++ = 0;
   }
@@ -950,7 +955,7 @@ static int regtry(const char* string, const char** start, const char** end,
  * by recursion.
  * 0 failure, 1 success
  */
-static int regmatch(const char* prog)
+int RegExpFind::regmatch(const char* prog)
 {
   const char* scan; // Current node.
   const char* next; // Next node.
@@ -1129,7 +1134,7 @@ static int regmatch(const char* prog)
 /*
  - regrepeat - repeatedly match something simple, report how many
  */
-static int regrepeat(const char* p)
+int RegExpFind::regrepeat(const char* p)
 {
   int count = 0;
   const char* scan;
@@ -1176,7 +1181,7 @@ static const char* regnext(const char* p)
 {
   int offset;
 
-  if (p == &regdummy)
+  if (p == regdummyptr)
     return (0);
 
   offset = NEXT(p);
@@ -1193,7 +1198,7 @@ static char* regnext(char* p)
 {
   int offset;
 
-  if (p == &regdummy)
+  if (p == regdummyptr)
     return (0);
 
   offset = NEXT(p);
diff --git a/RegularExpression.hxx.in b/RegularExpression.hxx.in
index 763fdab..a3fe72d 100644
--- a/RegularExpression.hxx.in
+++ b/RegularExpression.hxx.in
@@ -34,6 +34,115 @@
 
 namespace @KWSYS_NAMESPACE@ {
 
+// Forward declaration
+class RegularExpression;
+
+/** \class RegularExpressionMatch
+ * \brief Stores the pattern matches of a RegularExpression
+ */
+class @KWSYS_NAMESPACE at _EXPORT RegularExpressionMatch
+{
+public:
+  RegularExpressionMatch();
+
+  bool isValid() const;
+  void clear();
+
+  std::string::size_type start() const;
+  std::string::size_type end() const;
+  std::string::size_type start(int n) const;
+  std::string::size_type end(int n) const;
+  std::string match(int n) const;
+
+  enum
+  {
+    NSUBEXP = 10
+  };
+
+private:
+  friend class RegularExpression;
+  const char* startp[NSUBEXP];
+  const char* endp[NSUBEXP];
+  const char* searchstring;
+};
+
+/**
+ * \brief Creates an invalid match object
+ */
+inline RegularExpressionMatch::RegularExpressionMatch()
+{
+  startp[0] = 0;
+  endp[0] = 0;
+  searchstring = 0;
+}
+
+/**
+ * \brief Returns true if the match pointers are valid
+ */
+inline bool RegularExpressionMatch::isValid() const
+{
+  return (this->startp[0] != 0);
+}
+
+/**
+ * \brief Resets to the (invalid) construction state.
+ */
+inline void RegularExpressionMatch::clear()
+{
+  startp[0] = 0;
+  endp[0] = 0;
+  searchstring = 0;
+}
+
+/**
+ * \brief Returns the start index of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::start() const
+{
+  return static_cast<std::string::size_type>(this->startp[0] - searchstring);
+}
+
+/**
+ * \brief Returns the end index of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::end() const
+{
+  return static_cast<std::string::size_type>(this->endp[0] - searchstring);
+}
+
+/**
+ * \brief Returns the start index of nth submatch.
+ *        start(0) is the start of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::start(int n) const
+{
+  return static_cast<std::string::size_type>(this->startp[n] -
+                                             this->searchstring);
+}
+
+/**
+ * \brief Returns the end index of nth submatch.
+ *        end(0) is the end of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::end(int n) const
+{
+  return static_cast<std::string::size_type>(this->endp[n] -
+                                             this->searchstring);
+}
+
+/**
+ * \brief Returns the nth submatch as a string.
+ */
+inline std::string RegularExpressionMatch::match(int n) const
+{
+  if (this->startp[n] == 0) {
+    return std::string();
+  } else {
+    return std::string(this->startp[n], static_cast<std::string::size_type>(
+                                          this->endp[n] - this->startp[n]));
+  }
+}
+
 /** \class RegularExpression
  * \brief Implements pattern matching with regular expressions.
  *
@@ -170,6 +279,9 @@ namespace @KWSYS_NAMESPACE@ {
  *      the same as the two characters before  the first p  encounterd in
  *      the line.  It would match "drepa qrepb" in "rep drepa qrepb".
  *
+ * All methods of RegularExpression can be called simultaneously from
+ * different threads but only if each invocation uses an own instance of
+ * RegularExpression.
  */
 class @KWSYS_NAMESPACE at _EXPORT RegularExpression
 {
@@ -213,9 +325,19 @@ public:
 
   /**
    * Matches the regular expression to the given string.
+   * Returns true if found, and sets start and end indexes
+   * in the RegularExpressionMatch instance accordingly.
+   *
+   * This method is thread safe when called with different
+   * RegularExpressionMatch instances.
+   */
+  bool find(char const*, RegularExpressionMatch&) const;
+
+  /**
+   * Matches the regular expression to the given string.
    * Returns true if found, and sets start and end indexes accordingly.
    */
-  bool find(char const*);
+  inline bool find(char const*);
 
   /**
    * Matches the regular expression to the given std string.
@@ -224,14 +346,18 @@ public:
   inline bool find(std::string const&);
 
   /**
-   * Index to start of first find.
+   * Match indices
    */
+  inline RegularExpressionMatch const& regMatch() const;
   inline std::string::size_type start() const;
+  inline std::string::size_type end() const;
+  inline std::string::size_type start(int n) const;
+  inline std::string::size_type end(int n) const;
 
   /**
-   * Index to end of first find.
+   * Match strings
    */
-  inline std::string::size_type end() const;
+  inline std::string match(int n) const;
 
   /**
    * Copy the given regular expression.
@@ -266,29 +392,14 @@ public:
    */
   inline void set_invalid();
 
-  /**
-   * Destructor.
-   */
-  // awf added
-  std::string::size_type start(int n) const;
-  std::string::size_type end(int n) const;
-  std::string match(int n) const;
-
-  enum
-  {
-    NSUBEXP = 10
-  };
-
 private:
-  const char* startp[NSUBEXP];
-  const char* endp[NSUBEXP];
+  RegularExpressionMatch regmatch;
   char regstart;                  // Internal use only
   char reganch;                   // Internal use only
   const char* regmust;            // Internal use only
   std::string::size_type regmlen; // Internal use only
   char* program;
   int progsize;
-  const char* searchstring;
 };
 
 /**
@@ -344,51 +455,42 @@ inline bool RegularExpression::compile(std::string const& s)
  * Matches the regular expression to the given std string.
  * Returns true if found, and sets start and end indexes accordingly.
  */
-inline bool RegularExpression::find(std::string const& s)
+inline bool RegularExpression::find(const char* s)
 {
-  return this->find(s.c_str());
+  return this->find(s, this->regmatch);
 }
 
 /**
- * Set the start position for the regular expression.
+ * Matches the regular expression to the given std string.
+ * Returns true if found, and sets start and end indexes accordingly.
  */
-inline std::string::size_type RegularExpression::start() const
+inline bool RegularExpression::find(std::string const& s)
 {
-  return static_cast<std::string::size_type>(this->startp[0] - searchstring);
+  return this->find(s.c_str());
 }
 
 /**
- * Returns the start/end index of the last item found.
+ * Returns the internal match object
  */
-inline std::string::size_type RegularExpression::end() const
+inline RegularExpressionMatch const& RegularExpression::regMatch() const
 {
-  return static_cast<std::string::size_type>(this->endp[0] - searchstring);
+  return this->regmatch;
 }
 
 /**
- * Returns true if two regular expressions have different
- * compiled program for pattern matching.
+ * Returns the start index of the full match.
  */
-inline bool RegularExpression::operator!=(const RegularExpression& r) const
+inline std::string::size_type RegularExpression::start() const
 {
-  return (!(*this == r));
+  return regmatch.start();
 }
 
 /**
- * Returns true if a valid regular expression is compiled
- * and ready for pattern matching.
+ * Returns the end index of the full match.
  */
-inline bool RegularExpression::is_valid() const
-{
-  return (this->program != 0);
-}
-
-inline void RegularExpression::set_invalid()
+inline std::string::size_type RegularExpression::end() const
 {
-  //#ifndef _WIN32
-  delete[] this->program;
-  //#endif
-  this->program = 0;
+  return regmatch.end();
 }
 
 /**
@@ -396,7 +498,7 @@ inline void RegularExpression::set_invalid()
  */
 inline std::string::size_type RegularExpression::start(int n) const
 {
-  return static_cast<std::string::size_type>(this->startp[n] - searchstring);
+  return regmatch.start(n);
 }
 
 /**
@@ -404,7 +506,7 @@ inline std::string::size_type RegularExpression::start(int n) const
  */
 inline std::string::size_type RegularExpression::end(int n) const
 {
-  return static_cast<std::string::size_type>(this->endp[n] - searchstring);
+  return regmatch.end(n);
 }
 
 /**
@@ -412,12 +514,33 @@ inline std::string::size_type RegularExpression::end(int n) const
  */
 inline std::string RegularExpression::match(int n) const
 {
-  if (this->startp[n] == 0) {
-    return std::string("");
-  } else {
-    return std::string(this->startp[n], static_cast<std::string::size_type>(
-                                          this->endp[n] - this->startp[n]));
-  }
+  return regmatch.match(n);
+}
+
+/**
+ * Returns true if two regular expressions have different
+ * compiled program for pattern matching.
+ */
+inline bool RegularExpression::operator!=(const RegularExpression& r) const
+{
+  return (!(*this == r));
+}
+
+/**
+ * Returns true if a valid regular expression is compiled
+ * and ready for pattern matching.
+ */
+inline bool RegularExpression::is_valid() const
+{
+  return (this->program != 0);
+}
+
+inline void RegularExpression::set_invalid()
+{
+  //#ifndef _WIN32
+  delete[] this->program;
+  //#endif
+  this->program = 0;
 }
 
 } // namespace @KWSYS_NAMESPACE@

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2047eb360de5a9d2a8cac6a689bd7846c5a0128f
commit 2047eb360de5a9d2a8cac6a689bd7846c5a0128f
Author:     Christian Pfeiffer <cpfeiffer at live.de>
AuthorDate: Tue Dec 5 12:31:56 2017 +0100
Commit:     Christian Pfeiffer <cpfeiffer at live.de>
CommitDate: Tue Dec 5 14:17:27 2017 +0100

    FindMPI: Fix multiple configure runs
    
    Due to a erroneous logical dependency on a temporary variable, FindMPI
    would depend its FOUND status on the set of flags needed to support
    compiler-implicit MPI support after the first configure run.
    
    This behavior is especially causing a misreported NOT FOUND status after
    the first run on MPI implementations without MPI compiler like MS-MPI or
    MPICH2 on Windows.

diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 7f4c44c..2af0329 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -1336,7 +1336,7 @@ foreach(LANG IN ITEMS C CXX Fortran)
     set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT})
 
     unset(MPI_${LANG}_REQUIRED_VARS)
-    if (MPI_${LANG}_WRAPPER_FOUND OR MPI_${LANG}_GUESS_FOUND)
+    if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
       foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES)
         list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY")
       endforeach()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bde7513d2fcd7a366eb4dd93fc1f061334743bb7
commit bde7513d2fcd7a366eb4dd93fc1f061334743bb7
Author:     Christian Pfeiffer <cpfeiffer at live.de>
AuthorDate: Tue Dec 5 14:03:37 2017 +0100
Commit:     Christian Pfeiffer <cpfeiffer at live.de>
CommitDate: Tue Dec 5 14:14:40 2017 +0100

    FindMPI: Correct legacy variable handling
    
    Due to a minor logic error, MPI_LIBRARY, MPI_EXTRA_LIBRARY and
    MPI_<LANG>_LIBRARIES hints are currently not correctly handled and
    discarded.
    
    Additionally, if either C or CXX aren't enabled, there subsequent calls
    to FindMPI will cause cache variables of the sort "MPI_MPI_EXTRA_LIBRARY-NOTFOUND"
    to appear due to an error in the compatibility handling. (Doesn't affect
    functionality)

diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 7f4c44c..21ac0bc 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -602,6 +602,9 @@ function (_MPI_interrogate_compiler lang)
   if(MPI_DIRECT_LIB_NAMES_WORK)
     set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}")
   endif()
+  if(MPI_${LANG}_EXTRA_LIB_NAMES)
+    list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}")
+  endif()
 
   # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to
   # link it in that case. -lpthread is covered by the normal library treatment on the other hand.
@@ -1076,18 +1079,21 @@ foreach (LANG IN ITEMS C CXX)
   endif()
 
   # If a list of libraries was given, we'll split it into new-style cache variables
+  unset(MPI_${LANG}_EXTRA_LIB_NAMES)
   if(NOT MPI_${LANG}_LIB_NAMES)
     foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY)
-      get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE)
-      get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME)
-      get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY)
-      list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}")
-      find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
-        NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
-        HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB}
-        DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
-      )
-      mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+      if(_MPI_LIB)
+        get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE)
+        get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME)
+        get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY)
+        list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}")
+        find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
+          NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
+          HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB}
+          DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
+        )
+        mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+      endif()
     endforeach()
   endif()
 endforeach()

-----------------------------------------------------------------------

Summary of changes:
 Modules/FindMPI.cmake                 |   28 ++--
 Source/QtDialog/RegexExplorer.cxx     |    4 +-
 Source/kwsys/RegularExpression.cxx    |  189 ++++++++++++++-------------
 Source/kwsys/RegularExpression.hxx.in |  227 +++++++++++++++++++++++++--------
 4 files changed, 291 insertions(+), 157 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list