- Let the solver treat vendor suse and opensuse as equivalent.
authorMichael Andres <ma@suse.de>
Thu, 6 Sep 2007 12:20:35 +0000 (12:20 +0000)
committerMichael Andres <ma@suse.de>
Thu, 6 Sep 2007 12:20:35 +0000 (12:20 +0000)
zypp/VendorAttr.cc

index a12bfa9..852ac93 100644 (file)
@@ -147,18 +147,27 @@ namespace zypp
   bool VendorAttr::autoProtect( const Vendor & vendor_r ) const
   { return( ZConfig::instance().autolock_untrustedvendor() && ! trusted( vendor_r ) ); }
 
-  bool VendorAttr::equivalent( const Vendor & lhs, const Vendor & rhs ) const
+  /** Helper: Lowercase prefix */
+  inline bool hasLcPrefix( const std::string & str_r, const std::string & pref_r )
+  { return str::toLower( str_r.substr( 0, pref_r.size() ) ) == pref_r; }
+
+  /** Helper: SuSE and equivalent vendors */
+  inline bool isSUSE( const Vendor & vnd_r )
   {
-    static const std::string defSUSE( "suse" );
+    static const std::string defSUSE    ( "suse" );
+    static const std::string defopenSUSE( "opensuse" );
 
-    if ( lhs == rhs )
-      return true;
-    // By now handcrafted equivalence definition:
-    if (    str::toLower( lhs.substr( 0, 4 ) ) == defSUSE
-         && str::toLower( rhs.substr( 0, 4 ) ) == defSUSE )
+    return(    hasLcPrefix( vnd_r, defSUSE )
+            || hasLcPrefix( vnd_r, defopenSUSE ) );
+  }
+
+  bool VendorAttr::equivalent( const Vendor & lhs, const Vendor & rhs ) const
+  {
+   if ( lhs == rhs )
       return true;
 
-    return false;
+    // By now handcrafted equivalence definition:
+    return( isSUSE( lhs ) && isSUSE( rhs ) );
   }
 
   /////////////////////////////////////////////////////////////////