summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/RegularExpression.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-05-16 15:06:18 (GMT)
committerBrad King <brad.king@kitware.com>2008-05-16 15:06:18 (GMT)
commitf43748e1dd656a4b9c5f2d59ece64618a51efba5 (patch)
treeada810555a08b905bac22d546f07ade1ed944369 /Source/kwsys/RegularExpression.cxx
parentb18b370aab5cfc51d5aaac5aa90f14b86642da78 (diff)
downloadCMake-f43748e1dd656a4b9c5f2d59ece64618a51efba5.zip
CMake-f43748e1dd656a4b9c5f2d59ece64618a51efba5.tar.gz
CMake-f43748e1dd656a4b9c5f2d59ece64618a51efba5.tar.bz2
ENH: Add assignment operator to KWSys RegularExpression.
Diffstat (limited to 'Source/kwsys/RegularExpression.cxx')
-rw-r--r--Source/kwsys/RegularExpression.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index 6d31e39..ac2c9b0 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -74,6 +74,38 @@ RegularExpression::RegularExpression (const RegularExpression& rxp) {
this->regmlen = rxp.regmlen; // Copy remaining private data
}
+// operator= -- Copies the given regular expression.
+RegularExpression& RegularExpression::operator= (const RegularExpression& rxp)
+{
+ if ( !rxp.program )
+ {
+ this->program = 0;
+ return *this;
+ }
+ int ind;
+ this->progsize = rxp.progsize; // Copy regular expression size
+ 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
+ if (rxp.regmust != 0) {
+ char* dum = rxp.program;
+ ind = 0;
+ while (dum != rxp.regmust) {
+ ++dum;
+ ++ind;
+ }
+ this->regmust = this->program + ind;
+ }
+ this->regstart = rxp.regstart; // Copy starting index
+ this->reganch = rxp.reganch; // Copy remaining private data
+ this->regmlen = rxp.regmlen; // Copy remaining private data
+
+ return *this;
+}
+
// operator== -- Returns true if two regular expressions have the same
// compiled program for pattern matching.
bool RegularExpression::operator== (const RegularExpression& rxp) const {