[Aptitude-svn-commit] r3681 - in branches/aptitude-0.3/aptitude: . doc/en src/generic

Daniel Burrows dburrows at costa.debian.org
Tue Jul 26 00:42:18 UTC 2005


Author: dburrows
Date: Tue Jul 26 00:42:15 2005
New Revision: 3681

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/doc/en/aptitude.xml
   branches/aptitude-0.3/aptitude/src/generic/matchers.cc
Log:
Add a broken tag matcher (~G)

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Jul 26 00:42:15 2005
@@ -1,5 +1,10 @@
 2005-07-25  Daniel Burrows  <dburrows at debian.org>
 
+	* doc/en/aptitude.xml, src/generic/matchers.cc:
+
+	  Add a tag matcher, to match against the new Tags field.
+	  Currently it's broken, but it's a start.
+
 	* src/generic/tags.h:
 
 	  Add a routine to retrieve the plain text of a single tag.

Modified: branches/aptitude-0.3/aptitude/doc/en/aptitude.xml
==============================================================================
--- branches/aptitude-0.3/aptitude/doc/en/aptitude.xml	(original)
+++ branches/aptitude-0.3/aptitude/doc/en/aptitude.xml	Tue Jul 26 00:42:15 2005
@@ -3521,6 +3521,25 @@
 	</varlistentry>
 
 	<varlistentry>
+	  <term><literal>~G<replaceable>tag</replaceable></literal></term>
+
+	  <listitem>
+	    <para>
+	      Matches packages whose Tag field matches the regular
+	      expression <replaceable>tag</replaceable>.  For
+	      instance, the pattern
+	      <literal>~Ggame::strategy</literal> would match strategy
+	      games.
+	    </para>
+
+	    <para>
+	      For more information on tags and debtags, see <ulink
+	      url='http://debtags.alioth.debian.org'/>.
+	    </para>
+	  </listitem>
+	</varlistentry>
+
+	<varlistentry>
 	  <term><literal>~i</literal></term>
 
 	  <listitem>

Modified: branches/aptitude-0.3/aptitude/src/generic/matchers.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/matchers.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/matchers.cc	Tue Jul 26 00:42:15 2005
@@ -32,10 +32,13 @@
 
 #include "matchers.h"
 #include "apt.h"
+#include "tags.h"
 #include "tasks.h"
 
 #include "../aptitude.h"
 
+#include <set>
+
 #include <stdarg.h>
 
 #include <apt-pkg/error.h>
@@ -428,6 +431,48 @@
   }
 };
 
+class pkg_tag_matcher : public pkg_string_matcher
+{
+public:
+  pkg_tag_matcher(const string &s)
+    : pkg_string_matcher(s)
+  {
+  }
+
+  bool matches(const pkgCache::PkgIterator &pkg,
+	       const pkgCache::VerIterator &ver)
+  {
+    const std::set<tag> *tags = get_tags(pkg);
+
+    if(tags == NULL)
+      return false;
+
+    for(std::set<tag>::const_iterator i=tags->begin(); i!=tags->end(); ++i)
+      if(string_matches(i->str().c_str()))
+	return true;
+
+    return false;
+  }
+
+  pkg_match_result *get_match(const pkgCache::PkgIterator &pkg,
+			      const pkgCache::VerIterator &ver)
+  {
+    const set<tag> *tags = get_tags(pkg);
+
+    if(tags == NULL)
+      return NULL;
+
+    for(set<tag>::const_iterator i=tags->begin(); i!=tags->end(); ++i)
+      {
+	pkg_match_result *res = get_string_match(i->str().c_str());
+	if(res != NULL)
+	  return res;
+      }
+
+    return NULL;
+  }
+};
+
 //  Package-file info matchers.  Match a package if any of its
 // available files (for all versions) match the given criteria.
 //
@@ -1696,6 +1741,8 @@
 		      }
 		    case 'd':
 		      return new pkg_description_matcher(substr);
+		    case 'G':
+		      return new pkg_tag_matcher(substr);
 		    case 'F':
 		      return new pkg_false_matcher;
 		    case 'm':



More information about the Aptitude-svn-commit mailing list