From a7d6b91ad32d9ae0216821e2c5a1a39238974f79 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 21 Jun 2011 18:15:58 -0400 Subject: [PATCH] Cleanup - Renamed RegX to RX. Got sick of the RegX name - looked too much like GenX. --- src/Att.cpp | 20 ++++++++++---------- src/CMakeLists.txt | 2 +- src/Expression.cpp | 4 ++-- src/Expression.h | 4 ++-- src/Nibbler.cpp | 8 ++++---- src/{RegX.cpp => RX.cpp} | 22 +++++++++++----------- src/{RegX.h => RX.h} | 18 +++++++++--------- src/commands/CmdDiagnostics.cpp | 8 ++++---- test/rx.t.cpp | 18 +++++++++--------- 9 files changed, 52 insertions(+), 52 deletions(-) rename src/{RegX.cpp => RX.cpp} (93%) rename src/{RegX.h => RX.h} (86%) diff --git a/src/Att.cpp b/src/Att.cpp index 1c19ec52b..ca6606a9f 100644 --- a/src/Att.cpp +++ b/src/Att.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -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 start; std::vector 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 start; std::vector 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])) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81a53146c..2a9705473 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/Expression.cpp b/src/Expression.cpp index eb03ab371..363b03b5e 100644 --- a/src/Expression.cpp +++ b/src/Expression.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -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; diff --git a/src/Expression.h b/src/Expression.h index b7d0a13f3..56ebd075f 100644 --- a/src/Expression.h +++ b/src/Expression.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include class Expression @@ -61,7 +61,7 @@ private: private: Arguments _args; - std::map _regexes; + std::map _regexes; }; #endif diff --git a/src/Nibbler.cpp b/src/Nibbler.cpp index 44768f378..8378378fd 100644 --- a/src/Nibbler.cpp +++ b/src/Nibbler.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include 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 start; std::vector 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 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 results; if (r.match (results, mInput.substr (mCursor))) { diff --git a/src/RegX.cpp b/src/RX.cpp similarity index 93% rename from src/RegX.cpp rename to src/RX.cpp index 0b2653cca..cae119177 100644 --- a/src/RegX.cpp +++ b/src/RX.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #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& matches, const std::string& in) { @@ -139,7 +139,7 @@ bool RegX::match ( } //////////////////////////////////////////////////////////////////////////////// -bool RegX::match ( +bool RX::match ( std::vector & start, std::vector & end, const std::string& in) diff --git a/src/RegX.h b/src/RX.h similarity index 86% rename from src/RegX.h rename to src/RX.h index d93a0883c..651029823 100644 --- a/src/RegX.h +++ b/src/RX.h @@ -25,23 +25,23 @@ // //////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_REGX -#define INCLUDED_REGX +#ifndef INCLUDED_RX +#define INCLUDED_RX #define L10N // Localization complete. #include #include #include -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&, const std::string&); diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 01bb6f74f..bbf47316b 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -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: " diff --git a/test/rx.t.cpp b/test/rx.t.cpp index a5c871030..703ee0fb5 100644 --- a/test/rx.t.cpp +++ b/test/rx.t.cpp @@ -25,7 +25,7 @@ // //////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include 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 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 results; std::vector start; std::vector 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");