From abfd215f498bfa69d6c1a743a1c07c2320e401e5 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 26 Mar 2010 14:12:19 +0100 Subject: [PATCH] Add Capability::guessPackageSpec allowing to detect whether the argument was rewritten. --- zypp/Capability.cc | 16 +++++++++++++++- zypp/Capability.h | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/zypp/Capability.cc b/zypp/Capability.cc index dd4c3c6..96230be 100644 --- a/zypp/Capability.cc +++ b/zypp/Capability.cc @@ -365,7 +365,7 @@ namespace zypp return str::regex_match( name_r, what, filenameRegex ); } - Capability Capability::guessPackageSpec( const std::string & str_r ) + Capability Capability::guessPackageSpec( const std::string & str_r, bool & rewrote_r ) { Capability cap( str_r ); CapDetail detail( cap.detail() ); @@ -386,7 +386,10 @@ namespace zypp ResPool pool( ResPool::instance() ); // require name part matching a pool items name (not just provides!) if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) ) + { + rewrote_r = true; return guesscap; + } // try the one but last '-' if ( pos ) @@ -401,13 +404,24 @@ namespace zypp // require name part matching a pool items name (not just provides!) if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) ) + { + rewrote_r = true; return guesscap; + } } } } + + rewrote_r = false; return cap; } + Capability guessPackageSpec( const std::string & str_r ) + { + bool dummy; + return guessPackageSpec( str_r, dummy ); + } + /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp/Capability.h b/zypp/Capability.h index 06758d2..8f76c2c 100644 --- a/zypp/Capability.h +++ b/zypp/Capability.h @@ -236,6 +236,11 @@ namespace zypp * result depends on the pools content. */ static Capability guessPackageSpec( const std::string & str_r ); + /** \overload Taking an additional bool indicating whether \c str_r made + * a valid \ref Capability (\c true) or the result was was guessed by + * rewiting a \c '-' to \c '='. (\c false). + */ + static Capability guessPackageSpec( const std::string & str_r, bool & rewrote_r ); public: /** Expert backdoor. */ -- 2.7.4