aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-06 01:48:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-06 01:48:44 +0000
commit3150f0b24ee988fb93e70096d39724ef28a5902c (patch)
tree7b0175d4667b7296a393bdb4f28a108bae8cce75
parentde54f744804bc9ba9ba73bf1cabfcdfdd3a9e6c3 (diff)
downloadpaludis-3150f0b24ee988fb93e70096d39724ef28a5902c.tar.gz
paludis-3150f0b24ee988fb93e70096d39724ef28a5902c.tar.xz
Kill match_sequence. It's only used for one QA check, which is probably better done using something more powerful anyway.
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/match_sequence.cc181
-rw-r--r--paludis/util/match_sequence.hh98
-rw-r--r--paludis/util/match_sequence_TEST.cc71
4 files changed, 0 insertions, 351 deletions
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index e362d37..98186f7 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -25,7 +25,6 @@ add(`instantiation_policy', `hh', `test')
add(`is_file_with_extension', `hh', `cc', `test', `testscript')
add(`join', `hh', `test')
add(`log', `hh', `cc', `test')
-add(`match_sequence', `hh', `cc', `test')
add(`private_implementation_pattern', `hh')
add(`pstream', `hh', `cc', `test')
add(`random', `hh', `cc', `test')
diff --git a/paludis/util/match_sequence.cc b/paludis/util/match_sequence.cc
deleted file mode 100644
index cc29797..0000000
--- a/paludis/util/match_sequence.cc
+++ /dev/null
@@ -1,181 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/match_sequence.hh>
-
-/** \file
- * Implementation for MatchRule.
- *
- * \ingroup grpmatch
- */
-
-using namespace paludis;
-
-struct MatchRule::Rule :
- InternalCounted<MatchRule::Rule>
-{
- virtual std::string::size_type local_match(const std::string &,
- std::string::size_type) const = 0;
-
- virtual ~Rule()
- {
- }
-};
-
-struct MatchRule::StringRule :
- MatchRule::Rule
-{
- const std::string s;
-
- StringRule(const std::string & ss) :
- s(ss)
- {
- }
-
- std::string::size_type
- local_match(const std::string & t, std::string::size_type p) const
- {
- return (0 == t.compare(p, s.length(), s)) ? s.length() : std::string::npos;
- }
-};
-
-struct MatchRule::SequenceRule :
- MatchRule::Rule
-{
- const MatchRule r1, r2;
-
- SequenceRule(const MatchRule & rr1, const MatchRule & rr2) :
- r1(rr1),
- r2(rr2)
- {
- }
-
- std::string::size_type
- local_match(const std::string & t, std::string::size_type p) const
- {
- std::string::size_type l1(r1._rule->local_match(t, p)), l2(0);
- if (std::string::npos == l1)
- return l1;
-
- l2 = r2._rule->local_match(t, p + l1);
- return (std::string::npos == l2) ? l2 : l1 + l2;
- }
-};
-
-struct MatchRule::EitherRule :
- MatchRule::Rule
-{
- const MatchRule r1, r2;
-
- EitherRule(const MatchRule & rr1, const MatchRule & rr2) :
- r1(rr1),
- r2(rr2)
- {
- }
-
- std::string::size_type
- local_match(const std::string & t, std::string::size_type p) const
- {
- std::string::size_type l1(r1._rule->local_match(t, p));
- if (std::string::npos != l1)
- return l1;
- return r2._rule->local_match(t, p);
- }
-};
-
-struct MatchRule::ZeroOrMoreRule :
- MatchRule::Rule
-{
- const MatchRule r1;
-
- ZeroOrMoreRule(const MatchRule & rr1) :
- r1(rr1)
- {
- }
-
- std::string::size_type
- local_match(const std::string & t, std::string::size_type p) const
- {
- std::string::size_type result(p), q;
- while (std::string::npos != ((q = r1._rule->local_match(t, result))))
- result += q;
-
- return result - p;
- }
-};
-
-struct MatchRule::EolRule :
- MatchRule::Rule
-{
- std::string::size_type
- local_match(const std::string & t, std::string::size_type p) const
- {
- return p >= t.length() ? 0 : std::string::npos;
- }
-};
-
-MatchRule::MatchRule(const std::string & s) :
- _rule(CountedPtr<Rule>(new StringRule(s)))
-{
-}
-
-MatchRule::MatchRule(const MatchRule & other) :
- _rule(other._rule)
-{
-}
-
-MatchRule::MatchRule(CountedPtr<Rule> r) :
- _rule(r)
-{
-}
-
-const MatchRule
-MatchRule::eol()
-{
- return MatchRule(CountedPtr<Rule>(new EolRule));
-}
-
-MatchRule::~MatchRule()
-{
-}
-
-const MatchRule
-MatchRule::operator>> (const MatchRule & other) const
-{
- return MatchRule(CountedPtr<Rule>(new SequenceRule(*this, other)));
-}
-
-const MatchRule
-MatchRule::operator|| (const MatchRule & other) const
-{
- return MatchRule(CountedPtr<Rule>(new EitherRule(*this, other)));
-}
-
-const MatchRule
-MatchRule::operator* () const
-{
- return MatchRule(CountedPtr<Rule>(new ZeroOrMoreRule(*this)));
-}
-
-bool
-MatchRule::match(const std::string & s) const
-{
- return (std::string::npos != _rule->local_match(s, 0));
-}
-
diff --git a/paludis/util/match_sequence.hh b/paludis/util/match_sequence.hh
deleted file mode 100644
index 4ebbbd3..0000000
--- a/paludis/util/match_sequence.hh
+++ /dev/null
@@ -1,98 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_MATCH_SEQUENCE_HH
-#define PALUDIS_GUARD_PALUDIS_MATCH_SEQUENCE_HH 1
-
-#include <paludis/util/counted_ptr.hh>
-#include <string>
-
-/** \file
- * Declarations for the MatchRule classes.
- *
- * \ingroup grpmatch
- */
-
-namespace paludis
-{
- /**
- * MatchRule is used to match text.
- *
- * \ingroup grpmatch
- */
- class MatchRule
- {
- private:
- struct Rule;
- struct StringRule;
- struct SequenceRule;
- struct ZeroOrMoreRule;
- struct EitherRule;
- struct EolRule;
-
- CountedPtr<Rule> _rule;
-
- void operator= (const MatchRule &);
-
- MatchRule(CountedPtr<Rule>);
-
- public:
- /**
- * Constructor.
- */
- MatchRule(const std::string &);
-
- /**
- * Copy constructor.
- */
- MatchRule(const MatchRule &);
-
- /**
- * A rule matching end of line.
- */
- static const MatchRule eol();
-
- /**
- * Destructor.
- */
- ~MatchRule();
-
- /**
- * Followed by rule.
- */
- const MatchRule operator>> (const MatchRule &) const;
-
- /**
- * Alternation rule.
- */
- const MatchRule operator|| (const MatchRule &) const;
-
- /**
- * Repetition rule.
- */
- const MatchRule operator* () const;
-
- /**
- * Match against a string.
- */
- bool match(const std::string &) const;
- };
-}
-
-#endif
diff --git a/paludis/util/match_sequence_TEST.cc b/paludis/util/match_sequence_TEST.cc
deleted file mode 100644
index a81cf16..0000000
--- a/paludis/util/match_sequence_TEST.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/match_sequence.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for MatchRule.
- *
- * \ingroup grptestcases
- */
-
-namespace test_case
-{
- /**
- * \test Test MatchRule
- *
- * \ingroup grptestcases
- */
- struct MatchRuleTest : TestCase
- {
- MatchRuleTest() : TestCase("match rule") { }
-
- void run()
- {
- typedef MatchRule X;
-
- TEST_CHECK(X::eol().match(""));
- TEST_CHECK(! X::eol().match("a"));
-
- X r1(*X("\t") >> X("econf") >> *X(" ") >> (X::eol() || (X("||") >> *X(" ") >> X("die"))));
-
- TEST_CHECK(r1.match("econf"));
- TEST_CHECK(r1.match("\teconf"));
- TEST_CHECK(r1.match("\t\teconf"));
- TEST_CHECK(r1.match("\t\teconf "));
- TEST_CHECK(! r1.match(" econf"));
- TEST_CHECK(! r1.match("\tecong"));
- TEST_CHECK(! r1.match("\t"));
- TEST_CHECK(! r1.match("econfmoo"));
- TEST_CHECK(! r1.match("econf moo"));
-
- TEST_CHECK(r1.match("\teconf || die"));
- TEST_CHECK(r1.match("\teconf || die \"moo\""));
- TEST_CHECK(! r1.match("\teconf ||"));
- TEST_CHECK(r1.match("\teconf || die"));
- TEST_CHECK(! r1.match("\texonf || die"));
- }
- } test_match_rule;
-}
-