- Renamed RegX to RX.  Got sick of the RegX name - looked too much like GenX.
This commit is contained in:
Paul Beckingham 2011-06-21 18:15:58 -04:00
parent 03dbf7f468
commit a7d6b91ad3
9 changed files with 52 additions and 52 deletions

View file

@ -30,7 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <text.h>
#include <RegX.h>
#include <RX.h>
#include <Color.h>
#include <util.h>
#include <Date.h>
@ -634,7 +634,7 @@ bool Att::match (const Att& other) const
if (regex)
{
std::string pattern = "^" + mValue + "$";
RegX r (pattern, case_sensitive);
RX r (pattern, case_sensitive);
if (!r.match (other.mValue))
return false;
}
@ -653,7 +653,7 @@ bool Att::match (const Att& other) const
#ifdef FEATURE_REGEX
if (regex)
{
RegX r (mValue, case_sensitive);
RX r (mValue, case_sensitive);
if (!r.match (other.mValue))
return false;
}
@ -672,7 +672,7 @@ bool Att::match (const Att& other) const
if (regex)
{
std::string pattern = "^" + mValue + "$";
RegX r (pattern, case_sensitive);
RX r (pattern, case_sensitive);
if (!r.match (other.mValue))
return false;
}
@ -691,7 +691,7 @@ bool Att::match (const Att& other) const
if (regex)
{
std::string pattern = "^" + mValue + "$";
RegX r (pattern, case_sensitive);
RX r (pattern, case_sensitive);
if (r.match (other.mValue))
return false;
}
@ -724,7 +724,7 @@ bool Att::match (const Att& other) const
if (regex)
{
std::string pattern = "^" + mValue;
RegX r (pattern, case_sensitive);
RX r (pattern, case_sensitive);
if (!r.match (other.mValue))
return false;
}
@ -748,7 +748,7 @@ bool Att::match (const Att& other) const
if (regex)
{
std::string pattern = mValue + "$";
RegX r (pattern, case_sensitive);
RX r (pattern, case_sensitive);
if (!r.match (other.mValue))
return false;
}
@ -773,7 +773,7 @@ bool Att::match (const Att& other) const
#ifdef FEATURE_REGEX
if (regex)
{
RegX r (mValue, case_sensitive);
RX r (mValue, case_sensitive);
if (r.match (other.mValue))
return false;
}
@ -869,7 +869,7 @@ bool Att::match (const Att& other) const
{
std::vector <int> start;
std::vector <int> end;
RegX r (mValue, case_sensitive);
RX r (mValue, case_sensitive);
if (!r.match (start, end, other.mValue))
return false;
@ -906,7 +906,7 @@ bool Att::match (const Att& other) const
{
std::vector <int> start;
std::vector <int> end;
RegX r (mValue, case_sensitive);
RX r (mValue, case_sensitive);
if (r.match (start, end, other.mValue) &&
isWordStart (other.mValue, start[0]) &&
isWordEnd (other.mValue, end[0]))

View file

@ -25,7 +25,7 @@ set (task_SRCS API.cpp API.h
Path.cpp Path.h
Permission.cpp Permission.h
Record.cpp Record.h
RegX.cpp RegX.h
RX.cpp RX.h
TDB.cpp TDB.h
TDB2.cpp TDB2.h
Task.cpp Task.h

View file

@ -34,7 +34,7 @@
#include <Duration.h>
#include <Nibbler.h>
#include <Variant.h>
#include <RegX.h>
#include <RX.h>
#include <text.h>
#include <Expression.h>
@ -347,7 +347,7 @@ bool Expression::eval_match (Variant& left, Variant& right, bool case_sensitive)
// Create a cached entry, if it does not already exist.
if (_regexes.find (right._string) == _regexes.end ())
_regexes[right._string] = RegX (right._string, case_sensitive);
_regexes[right._string] = RX (right._string, case_sensitive);
if (_regexes[right._string].match (left._string))
return true;

View file

@ -32,7 +32,7 @@
#include <stack>
#include <Arguments.h>
#include <Task.h>
#include <RegX.h>
#include <RX.h>
#include <Variant.h>
class Expression
@ -61,7 +61,7 @@ private:
private:
Arguments _args;
std::map <std::string, RegX> _regexes;
std::map <std::string, RX> _regexes;
};
#endif

View file

@ -34,7 +34,7 @@
#include <inttypes.h>
#include <Nibbler.h>
#include <Date.h>
#include <RegX.h>
#include <RX.h>
const char* c_digits = "0123456789";
@ -147,7 +147,7 @@ bool Nibbler::getUntilRx (const std::string& regex, std::string& result)
else
modified_regex = regex;
RegX r (modified_regex, true);
RX r (modified_regex, true);
std::vector <int> start;
std::vector <int> end;
if (r.match (start, end, mInput.substr (mCursor)))
@ -452,7 +452,7 @@ bool Nibbler::getRx (const std::string& regex, std::string& result)
else
modified_regex = regex;
RegX r (modified_regex, true);
RX r (modified_regex, true);
std::vector <std::string> results;
if (r.match (results, mInput.substr (mCursor)))
{
@ -1012,7 +1012,7 @@ bool Nibbler::skipRx (const std::string& regex)
else
modified_regex = regex;
RegX r (modified_regex, true);
RX r (modified_regex, true);
std::vector <std::string> results;
if (r.match (results, mInput.substr (mCursor)))
{

View file

@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <RegX.h>
#include <RX.h>
#define L10N // Localization complete.
@ -35,7 +35,7 @@
#define MAX_MATCHES 64
////////////////////////////////////////////////////////////////////////////////
RegX::RegX ()
RX::RX ()
: _compiled (false)
, _pattern ("")
, _case_sensitive (true)
@ -43,7 +43,7 @@ RegX::RegX ()
}
////////////////////////////////////////////////////////////////////////////////
RegX::RegX (
RX::RX (
const std::string& pattern,
bool case_sensitive /* = true */)
: _compiled (false)
@ -54,7 +54,7 @@ RegX::RegX (
}
////////////////////////////////////////////////////////////////////////////////
RegX::RegX (const RegX& other)
RX::RX (const RX& other)
: _compiled (false)
, _pattern (other._pattern)
, _case_sensitive (other._case_sensitive)
@ -62,7 +62,7 @@ RegX::RegX (const RegX& other)
}
////////////////////////////////////////////////////////////////////////////////
RegX& RegX::operator= (const RegX& other)
RX& RX::operator= (const RX& other)
{
if (this != &other)
{
@ -75,21 +75,21 @@ RegX& RegX::operator= (const RegX& other)
}
////////////////////////////////////////////////////////////////////////////////
bool RegX::operator== (const RegX& other) const
bool RX::operator== (const RX& other) const
{
return _pattern == other._pattern &&
_case_sensitive == other._case_sensitive;
}
////////////////////////////////////////////////////////////////////////////////
RegX::~RegX ()
RX::~RX ()
{
if (_compiled)
regfree (&_regex);
}
////////////////////////////////////////////////////////////////////////////////
void RegX::compile ()
void RX::compile ()
{
if (!_compiled)
{
@ -110,7 +110,7 @@ void RegX::compile ()
}
////////////////////////////////////////////////////////////////////////////////
bool RegX::match (const std::string& in)
bool RX::match (const std::string& in)
{
if (!_compiled)
compile ();
@ -119,7 +119,7 @@ bool RegX::match (const std::string& in)
}
////////////////////////////////////////////////////////////////////////////////
bool RegX::match (
bool RX::match (
std::vector<std::string>& matches,
const std::string& in)
{
@ -139,7 +139,7 @@ bool RegX::match (
}
////////////////////////////////////////////////////////////////////////////////
bool RegX::match (
bool RX::match (
std::vector <int>& start,
std::vector <int>& end,
const std::string& in)

View file

@ -25,23 +25,23 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_REGX
#define INCLUDED_REGX
#ifndef INCLUDED_RX
#define INCLUDED_RX
#define L10N // Localization complete.
#include <string>
#include <vector>
#include <regex.h>
class RegX
class RX
{
public:
RegX ();
RegX (const std::string&, bool caseSensitive = true);
RegX (const RegX&);
RegX& operator= (const RegX&);
bool operator== (const RegX&) const;
~RegX ();
RX ();
RX (const std::string&, bool caseSensitive = true);
RX (const RX&);
RX& operator= (const RX&);
bool operator== (const RX&) const;
~RX ();
bool match (const std::string&);
bool match (std::vector<std::string>&, const std::string&);

View file

@ -29,7 +29,7 @@
#include <sstream>
#include <algorithm>
#include <stdlib.h>
#include <RegX.h>
#include <RX.h>
#include <Context.h>
#include <util.h>
#include <cmake.h>
@ -223,7 +223,7 @@ int CmdDiagnostics::execute (std::string& output)
char* p = fgets (buffer, 1023, fp);
pclose (fp);
RegX r ("usage", false);
RX r ("usage", false);
if (p)
out << " scp: "
<< (r.match (buffer) ? "found" : "n/a")
@ -238,7 +238,7 @@ int CmdDiagnostics::execute (std::string& output)
// rsync version 2.6.9 protocol version 29
if (p)
{
RegX r ("version ([0-9]+\\.[0-9]+\\.[0-9]+)", false);
RX r ("version ([0-9]+\\.[0-9]+\\.[0-9]+)", false);
matches.clear ();
r.match (matches, buffer);
out << " rsync: "
@ -255,7 +255,7 @@ int CmdDiagnostics::execute (std::string& output)
// curl 7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
if (p)
{
RegX r ("curl ([0-9]+\\.[0-9]+\\.[0-9]+)", false);
RX r ("curl ([0-9]+\\.[0-9]+\\.[0-9]+)", false);
matches.clear ();
r.match (matches, buffer);
out << " curl: "

View file

@ -25,7 +25,7 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <Context.h>
#include <RegX.h>
#include <RX.h>
#include <test.h>
Context context;
@ -36,39 +36,39 @@ int main (int argc, char** argv)
std::string text = "This is a test.";
RegX r1 ("i. ", true);
RX r1 ("i. ", true);
ut.ok (r1.match (text), text + " =~ /i. /");
std::vector <std::string> matches;
RegX r2 ("(i.) ", false);
RX r2 ("(i.) ", false);
ut.ok (r2.match (matches, text), text + " =~ /(i.) /");
ut.ok (matches.size () == 1, "1 match");
ut.is (matches[0], "is", "$1 == is");
text = "abcdefghijklmnopqrstuvwxyz";
RegX r3 ("t..", true);
RX r3 ("t..", true);
ut.ok (r3.match (text), "t..");
RegX r4 ("T..", false);
RX r4 ("T..", false);
ut.ok (r4.match (text), "T..");
RegX r5 ("T..", true);
RX r5 ("T..", true);
ut.ok (!r5.match (text), "! T..");
text = "this is a test of the regex engine.";
// |...:....|....:....|....:....|....:
RegX r6 ("^this");
RX r6 ("^this");
ut.ok (r6.match (text), "^this matches");
RegX r7 ("engine\\.$");
RX r7 ("engine\\.$");
ut.ok (r7.match (text), "engine\\.$ matches");
std::vector <std::string> results;
std::vector <int> start;
std::vector <int> end;
RegX r8 ("(e..)", true);
RX r8 ("(e..)", true);
ut.ok (r8.match (results, text), "(e..) there are matches");
ut.ok (r8.match (start, end, text), "(e..) there are matches");
ut.is (results.size (), (size_t) 1, "(e..) == 1 match");