File 0009-zypp-adjust-PK_FILTER_ENUM_NOT_DEVELOPMENT-bnc-77002.patch of Package PackageKit

From fb6dfc56c3608b931dda9723b6bd49d024d0e04a Mon Sep 17 00:00:00 2001
From: Michael Andres <ma@suse.de>
Date: Fri, 6 Jul 2012 12:12:49 +0200
Subject: [PATCH 9/9] zypp: adjust PK_FILTER_ENUM_NOT_DEVELOPMENT (bnc#770028)

---
 backends/zypp/zypp-utils.cpp |   49 +++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 55e13a3..c8b69c2 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -146,33 +146,34 @@ zypp_is_changeable_media (PkBackend *backend, const Url &url)
 	return is_cd;
 }
 
+namespace {
+	/// Helper finding pattern at end or embedded in name.
+	/// E.g '-debug' in 'repo-debug' or 'repo-debug-update'
+	inline bool
+	name_ends_or_contains( const std::string & name_r, const std::string & pattern_r, const char sepchar_r = '-' )
+	{
+		if ( ! pattern_r.empty() )
+		{
+			for ( std::string::size_type pos = name_r.find( pattern_r );
+			      pos != std::string::npos;
+			      pos = name_r.find( pattern_r, pos + pattern_r.size() ) )
+			{
+				if ( pos + pattern_r.size() == name_r.size()		// at end
+				  || name_r[pos + pattern_r.size()] == sepchar_r )	// embedded
+					return true;
+			}
+		}
+		return false;
+	}
+}
+
 gboolean
 zypp_is_development_repo (PkBackend *backend, RepoInfo repo)
 {
-	string repo_debuginfo("-debuginfo");
-	string repo_debug("-debug");
-	string repo_development("-development");
-	string repo_source ("-source");
-
-	string repo_name(repo.name());
-
-	if (repo_name.length() > repo_debuginfo.length() &&
-	    repo_name.compare(repo_name.length() - repo_debuginfo.length(), repo_debuginfo.length(), repo_debuginfo) == 0)
-		return TRUE;
-
-	if (repo_name.length() > repo_debug.length() &&
-	    repo_name.compare(repo_name.length() - repo_debug.length(), repo_debug.length(), repo_debug) == 0)
-		return TRUE;
-
-	if (repo_name.length() > repo_development.length() &&
-	    repo_name.compare(repo_name.length() - repo_development.length(), repo_development.length(), repo_development) == 0)
-		return TRUE;
-
-	if (repo_name.length() > repo_source.length() &&
-	   repo_name.compare(repo_name.length() - repo_source.length(), repo_source.length(), repo_source) == 0)
-		return TRUE;
-
-	return FALSE;
+	return ( name_ends_or_contains( repo.alias(), "-debuginfo" )
+	      || name_ends_or_contains( repo.alias(), "-debug" )
+	      || name_ends_or_contains( repo.alias(), "-source" )
+	      || name_ends_or_contains( repo.alias(), "-development" ) );
 }
 
 gboolean
-- 
1.7.10.4