From 1e8eac0e3ddac941239e8d4d9ec3de6f745c714c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 29 Oct 2015 23:23:41 -0400 Subject: [PATCH] Nibbler: Removed unused ::getRx method --- src/Nibbler.cpp | 31 ------------------------------- src/Nibbler.h | 6 ------ test/nibbler.t.cpp | 20 -------------------- 3 files changed, 57 deletions(-) diff --git a/src/Nibbler.cpp b/src/Nibbler.cpp index 237910f39..f869be080 100644 --- a/src/Nibbler.cpp +++ b/src/Nibbler.cpp @@ -32,9 +32,6 @@ #include #include #include -#ifdef NIBBLER_FEATURE_REGEX -#include -#endif #include #include #include @@ -492,34 +489,6 @@ bool Nibbler::getLiteral (const std::string& literal) return false; } -//////////////////////////////////////////////////////////////////////////////// -#ifdef NIBBLER_FEATURE_REGEX -bool Nibbler::getRx (const std::string& regex, std::string& result) -{ - if (_cursor < _length) - { - // Regex may be anchored to the beginning and include capturing parentheses, - // otherwise they are added. - std::string modified_regex; - if (regex.substr (0, 2) != "^(") - modified_regex = "^(" + regex + ")"; - else - modified_regex = regex; - - RX r (modified_regex, true); - std::vector results; - if (r.match (results, _input->substr (_cursor))) - { - result = results[0]; - _cursor += result.length (); - return true; - } - } - - return false; -} -#endif - //////////////////////////////////////////////////////////////////////////////// bool Nibbler::getUUID (std::string& result) { diff --git a/src/Nibbler.h b/src/Nibbler.h index 2c1eb1f1b..a0c5855a1 100644 --- a/src/Nibbler.h +++ b/src/Nibbler.h @@ -27,9 +27,6 @@ #ifndef INCLUDED_NIBBLER #define INCLUDED_NIBBLER -#define NIBBLER_FEATURE_REGEX -//#undef NIBBLER_FEATURE_REGEX - #include #include #include @@ -63,9 +60,6 @@ public: bool getNumber (std::string&); bool getNumber (double&); bool getLiteral (const std::string&); -#ifdef NIBBLER_FEATURE_REGEX - bool getRx (const std::string&, std::string&); -#endif bool getUUID (std::string&); bool getPartialUUID (std::string&); bool getOneOf (const std::vector &, std::string&); diff --git a/test/nibbler.t.cpp b/test/nibbler.t.cpp index daead254d..47be01fcd 100644 --- a/test/nibbler.t.cpp +++ b/test/nibbler.t.cpp @@ -35,11 +35,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int, char**) { -#ifdef NIBBLER_FEATURE_REGEX - UnitTest t (325); -#else UnitTest t (315); -#endif // Ensure environment has no influence. unsetenv ("TASKDATA"); @@ -290,22 +286,6 @@ int main (int, char**) t.ok (n.getLiteral ("bar"), " 'bar' : getLiteral ('bar') -> true"); t.ok (n.depleted (), " '' : depleted () -> true"); -#ifdef NIBBLER_FEATURE_REGEX - // bool getRx (const std::string&, std::string&); - t.diag ("Nibbler::getRx"); - n = Nibbler ("one two three"); - t.ok (n.getRx ("^(o..)", s), "'one two three' : getRx ('^(o..)') -> true"); - t.is (s, "one", "'one two three' : getRx ('^(o..)') -> 'one'"); - t.ok (n.skip (' '), " ' two three' : skip (' ') -> true"); - t.ok (n.getRx ("t..", s), " 'two three' : getRx ('t..') -> true"); - t.is (s, "two", " 'two three' : getRx ('t..') -> 'two'"); - t.notok (n.getRx ("th...", s), " ' three' : getRx ('th...') -> false"); - t.ok (n.skip (' '), " ' three' : skip (' ') -> true"); - t.ok (n.getRx ("th...", s), " 'three' : getRx ('th...') -> true"); - t.is (s, "three", " 'three' : getRx ('th...') -> 'three'"); - t.ok (n.depleted (), " '' : depleted () -> true"); -#endif - // bool getUUID (std::string&); t.diag ("Nibbler::getUUID"); n = Nibbler ("a0b1c2d3-e4f5-A6B7-C8D9-E0F1a2b3c4d5");