![](https://seccdn.libravatar.org/avatar/ba30a531854d27405c5e37aae6d3aaad.jpg?s=120&d=mm&r=g)
Author: jkupec
Date: Thu Apr 10 15:29:08 2008
New Revision: 9511
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9511&view=rev
Log:
- enable regex matching for different per-attribute values
Modified:
trunk/libzypp/tests/zypp/PoolQuery_test.cc
trunk/libzypp/zypp/PoolQuery.cc
Modified: trunk/libzypp/tests/zypp/PoolQuery_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/PoolQuery_test.cc?rev=9511&r1=9510&r2=9511&view=diff
==============================================================================
--- trunk/libzypp/tests/zypp/PoolQuery_test.cc (original)
+++ trunk/libzypp/tests/zypp/PoolQuery_test.cc Thu Apr 10 15:29:08 2008
@@ -348,7 +348,6 @@
cout << endl;
}
-
// multiple attributes, different search strings (one string per attrbute)
BOOST_AUTO_TEST_CASE(pool_query_104)
{
@@ -361,6 +360,18 @@
BOOST_CHECK(q.size() == 22);
}
+// multiple attributes, different search strings (one string per attrbute), regex matching
+BOOST_AUTO_TEST_CASE(pool_query_105)
+{
+ cout << "****105****" << endl;
+ PoolQuery q;
+ q.addAttribute(sat::SolvAttr::name, "no.ell");
+ q.addAttribute(sat::SolvAttr::summary, "package management");
+ q.setMatchRegex();
+
+ std::for_each(q.begin(), q.end(), &result_cb);
+ BOOST_CHECK(q.size() == 22);
+}
/////////////////////////////////////////////////////////////////////////////
// 3xx repo filter queries (addRepo(alias_str))
Modified: trunk/libzypp/zypp/PoolQuery.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9511&r1=9510&r2=9511&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolQuery.cc (original)
+++ trunk/libzypp/zypp/PoolQuery.cc Thu Apr 10 15:29:08 2008
@@ -100,6 +100,7 @@
/** Function for processing found solvables. Used in execute(). */
mutable PoolQuery::ProcessResolvable _fnc;
+
private:
friend Impl * rwcowClone<Impl>( const Impl * rhs );
/** clone for RWCOW_pointer */
@@ -107,7 +108,17 @@
{ return new Impl( *this ); }
};
-
+ static void
+ compileRegex(regex_t * regex, const string & str, bool nocase)
+ {
+ /* We feed multiple lines eventually (e.g. authors or descriptions),
+ so set REG_NEWLINE. */
+ if (regcomp(regex, str.c_str(),
+ REG_EXTENDED | REG_NOSUB | REG_NEWLINE | (nocase ? REG_ICASE : 0)) != 0)
+ ZYPP_THROW(Exception(
+ str::form(_("Invalid regular expression '%s'"), str.c_str())));
+ }
+
struct MyInserter
{
MyInserter(PoolQuery::StrContainer & cont) : _cont(cont) {}
@@ -220,6 +231,9 @@
// copy the _attrs keys to _rcattrs
for_(ai, _attrs.begin(), _attrs.end())
_rcattrs.insert(pair