From c3086c76f928785548579cf5548ba4e9bf05a1d2 Mon Sep 17 00:00:00 2001 From: Arjen Baart Date: Thu, 30 Dec 2010 13:13:10 +0100 Subject: [PATCH] Added regex assignment operator --- src/String.h | 13 ++++++------- src/regex.cpp | 24 ++++++++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/String.h b/src/String.h index 6182be5..6369fa8 100644 --- a/src/String.h +++ b/src/String.h @@ -5,7 +5,7 @@ *********************** ** FILE NAME : String.h ** SYSTEM NAME : Andromeda X-Windows Encapsulation -** VERSION NUMBER : $Revision: 1.6 $ +** VERSION NUMBER : $Revision: 1.4 $ ** ** DESCRIPTION : Character String class definition ** @@ -17,16 +17,13 @@ ******************************** ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl ** CREATION DATE : Nov 17, 1995 -** LAST UPDATE : Nov 02, 2002 +** LAST UPDATE : Mar 31, 2010 ** MODIFICATIONS : **************************************************************************/ /***************************** $Log: String.h,v $ - Revision 1.6 2010-12-30 12:04:02 arjen - Added regex assignment operator - - Revision 1.4 2007-05-04 13:56:05 arjen + Revision 1.4 2007/05/04 13:56:05 arjen Added a copy contructor to the regex class. This prevents multiple frees in the destructor. Revision 1.3 2002/11/03 13:18:57 arjen @@ -41,7 +38,7 @@ *****************************/ -// static const char RCSID[] = "$Id: String.h,v 1.6 2010-12-30 12:04:02 arjen Exp $"; +// static const char RCSID[] = "$Id: String.h,v 1.4 2007/05/04 13:56:05 arjen Exp $"; #ifndef STRING_H #define STRING_H @@ -377,6 +374,8 @@ public: regex(const regex & reg); ~regex(); + regex& operator=(const regex &); + friend bool operator == (const String &s, const regex &r); friend bool operator == (const regex &r, const String &s); }; diff --git a/src/regex.cpp b/src/regex.cpp index b065741..2ec3132 100644 --- a/src/regex.cpp +++ b/src/regex.cpp @@ -5,7 +5,7 @@ *********************** ** FILE NAME : regex.cpp ** SYSTEM NAME : Andromeda X-Windows Encapsulation -** VERSION NUMBER : $Revision: 1.5 $ +** VERSION NUMBER : $Revision: 1.3 $ ** ** DESCRIPTION : regex class implementation. ** @@ -17,16 +17,13 @@ ******************************** ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl ** CREATION DATE : Feb 23, 2001 -** LAST UPDATE : Feb 23, 2001 +** LAST UPDATE : Mar 31, 2010 ** MODIFICATIONS : **************************************************************************/ /***************************** $Log: regex.cpp,v $ - Revision 1.5 2010-12-30 12:04:02 arjen - Added regex assignment operator - - Revision 1.3 2007-05-04 13:56:05 arjen + Revision 1.3 2007/05/04 13:56:05 arjen Added a copy contructor to the regex class. This prevents multiple frees in the destructor. Revision 1.2 2002/09/28 06:45:51 arjen @@ -38,7 +35,7 @@ *****************************/ -static const char RCSID[] = "$Id: regex.cpp,v 1.5 2010-12-30 12:04:02 arjen Exp $"; +static const char RCSID[] = "$Id: regex.cpp,v 1.3 2007/05/04 13:56:05 arjen Exp $"; #include #include @@ -49,19 +46,19 @@ static const char RCSID[] = "$Id: regex.cpp,v 1.5 2010-12-30 12:04:02 arjen Exp regex::regex(const String ®) { original = reg; - regcomp (&expression, reg.p->s, REG_EXTENDED); + int error = regcomp (&expression, reg.p->s, REG_EXTENDED); } regex::regex(const char *reg) { original = reg; - regcomp (&expression, reg, REG_EXTENDED); + int error = regcomp (&expression, reg, REG_EXTENDED); } regex::regex(const regex & reg) { original = reg.original; - regcomp (&expression, reg.original, REG_EXTENDED); + int error = regcomp (&expression, reg.original, REG_EXTENDED); } regex::~regex() @@ -69,6 +66,13 @@ regex::~regex() regfree(&expression); } +regex& regex::operator=(const regex& x) +{ + original = x.original; + int error = regcomp (&expression, x.original, REG_EXTENDED); + + return *this; +} bool operator == (const String &s, const regex &r) { -- 2.11.0