mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
RX: Inherited RX fixes from clog
This commit is contained in:
parent
df7a7e6dd2
commit
1590ab6564
2 changed files with 36 additions and 4 deletions
37
src/RX.cpp
37
src/RX.cpp
|
@ -29,6 +29,14 @@
|
|||
#include <string.h>
|
||||
#include <RX.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
RX::RX ()
|
||||
: _compiled (false)
|
||||
, _pattern ("")
|
||||
, _case_sensitive (false)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
RX::RX (
|
||||
const std::string& pattern,
|
||||
|
@ -40,6 +48,14 @@ RX::RX (
|
|||
compile ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
RX::RX (const RX& other)
|
||||
{
|
||||
_compiled = false;
|
||||
_pattern = other._pattern;
|
||||
_case_sensitive = other._case_sensitive;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
RX::~RX ()
|
||||
{
|
||||
|
@ -47,10 +63,23 @@ RX::~RX ()
|
|||
regfree (&_regex);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
RX& RX::operator= (const RX& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
_compiled = false;
|
||||
_pattern = other._pattern;
|
||||
_case_sensitive = other._case_sensitive;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void RX::compile ()
|
||||
{
|
||||
if (!_compiled)
|
||||
if (! _compiled)
|
||||
{
|
||||
memset (&_regex, 0, sizeof (regex_t));
|
||||
|
||||
|
@ -75,7 +104,7 @@ void RX::compile ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool RX::match (const std::string& in)
|
||||
{
|
||||
if (!_compiled)
|
||||
if (! _compiled)
|
||||
compile ();
|
||||
|
||||
return regexec (&_regex, in.c_str (), 0, NULL, 0) == 0 ? true : false;
|
||||
|
@ -86,7 +115,7 @@ bool RX::match (
|
|||
std::vector<std::string>& matches,
|
||||
const std::string& in)
|
||||
{
|
||||
if (!_compiled)
|
||||
if (! _compiled)
|
||||
compile ();
|
||||
|
||||
regmatch_t rm[2];
|
||||
|
@ -112,7 +141,7 @@ bool RX::match (
|
|||
std::vector <int>& end,
|
||||
const std::string& in)
|
||||
{
|
||||
if (!_compiled)
|
||||
if (! _compiled)
|
||||
compile ();
|
||||
|
||||
regmatch_t rm[2];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue