Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9872 - in /trunk/libzypp/zypp: PoolQuery.cc Repository.h
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Mon, 28 Apr 2008 16:27:29 -0000
  • Message-id: <20080428162729.B40E3253A7@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Mon Apr 28 18:27:29 2008
New Revision: 9872

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9872&view=rev
Log:
- check for valid pool in begin(), improve the code (bnc #384337)

Modified:
trunk/libzypp/zypp/PoolQuery.cc
trunk/libzypp/zypp/Repository.h

Modified: trunk/libzypp/zypp/PoolQuery.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9872&r1=9871&r2=9872&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolQuery.cc (original)
+++ trunk/libzypp/zypp/PoolQuery.cc Mon Apr 28 18:27:29 2008
@@ -364,40 +364,48 @@
{
compile();

- // if only one repository has been specified, find it in the pool
sat::Pool pool(sat::Pool::instance());
- sat::Pool::RepositoryIterator itr = pool.reposBegin();
+ // no pool or no repos
+ if (!pool.get() || pool.reposEmpty())
+ return end();
+
+ // if only one repository has been specified, find it in the pool
+ Repository repo;
if (!(_cflags & SEARCH_ALL_REPOS) && _repos.size() == 1)
{
string theone = *_repos.begin();
- for (; itr->info().alias() != theone && itr != pool.reposEnd(); ++itr);
- if (itr == pool.reposEnd())
+ repo = pool.reposFind(theone);
+ if (repo == Repository::noRepository)
{
RepoInfo info; info.setAlias(theone);
- ERR << "Repository not found in sat pool." << endl;
+ ERR << "Repository not found in sat pool." << endl;
ZYPP_THROW(repo::RepoNotFoundException(info));
}
}

+ if ((_cflags & SEARCH_ALL_REPOS) || repo == Repository::noRepository)
+ repo = *pool.reposBegin();
+
DBG << "_cflags:" << _cflags << endl;

scoped_ptr< ::_Dataiterator> _rdit( new ::Dataiterator );
// needed while LookupAttr::iterator::dip_equal does ::memcmp:
::memset( _rdit.get(), 0, sizeof(::_Dataiterator) );

+ // initialize the Dataiterator for different cases
if (_rcattrs.empty())
{
- ::dataiterator_init(_rdit.get(),
- _cflags & SEARCH_ALL_REPOS ? pool.get()->repos[0] : itr->get(), //
repository \todo fix this
- 0, // search all solvables
- 0, // attribute id - only if 1
attr key specified
- _rcstrings.empty() ? 0 : _rcstrings.c_str(), // compiled search string
- _cflags);
+ ::dataiterator_init(_rdit.get(),
+ repo.get(), // either the first repo
or the repo to search
+ 0, // search all solvables
+ 0, // attribute id - only if
1 attr key specified
+ _rcstrings.empty() ? 0 : _rcstrings.c_str(), // compiled search string
+ _cflags);
}
else if (_rcattrs.size() == 1)
{
::dataiterator_init(_rdit.get(),
- _cflags & SEARCH_ALL_REPOS ? pool.get()->repos[0] : itr->get(), //
repository \todo fix this
+ repo.get(), // either the first repo
or the repo to search
0, // search all solvables
_rcattrs.begin()->first.id(), // keyname - attribute id
- only if 1 attr key specified
_rcstrings.empty() ? 0 : _rcstrings.c_str(), // compiled search string
@@ -406,7 +414,7 @@
else
{
::dataiterator_init(_rdit.get(),
- _cflags & SEARCH_ALL_REPOS ? pool.get()->repos[0] : itr->get(), /*
repository - switch to next at the end of current one in increment() */
+ repo.get(), // either the first repo
or the repo to search
0, /*search all resolvables */
0, /*keyname - if only 1 attr key specified, pass it here, otherwise
do more magic */
0, //qs.empty() ? 0 : qs.c_str(), /* create regex, pass it here */
@@ -423,9 +431,9 @@
return it;
}

+
PoolQuery::const_iterator PoolQuery::Impl::end() const
{
- //INT << "end" << endl;
return PoolQuery::const_iterator();
}

@@ -569,10 +577,7 @@

bool got_match = false;
if (_has_next)
- {
- XXX << "last: " << _sid << endl;
while (_has_next && !(got_match = matchSolvable()));
- }

// no more solvables and the last did not match
if (!got_match && !_has_next)
@@ -580,8 +585,6 @@
base_reference() = LookupAttr::iterator();
_sid = 0;
}
-
- XXX << "next: " << _sid << endl;
}

bool PoolQueryIterator::matchSolvable()

Modified: trunk/libzypp/zypp/Repository.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=9872&r1=9871&r2=9872&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.h (original)
+++ trunk/libzypp/zypp/Repository.h Mon Apr 28 18:27:29 2008
@@ -56,7 +56,9 @@
bool isSystemRepo() const;

public:
- /** The repos name (alias). */
+ /** The repos name (alias).
+ * \todo FIXME why is this not called alias if it <b>is</b> alias?
+ */
std::string name() const;

/** Whether \ref Repository contains solvables. */

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages