From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 14:07:17 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6D5836FE for ; Sun, 15 Sep 2013 14:07:17 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 40BD72365 for ; Sun, 15 Sep 2013 14:07:17 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FE7HbP019714 for ; Sun, 15 Sep 2013 14:07:17 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FE7HIK019709 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 14:07:17 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 15 Sep 2013 14:07:17 GMT Message-Id: <201309151407.r8FE7HIK019709@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257375 - soc2013/mattbw/backend/query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Sep 2013 14:07:17 -0000 Author: mattbw Date: Sun Sep 15 14:07:16 2013 New Revision: 257375 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257375 Log: Split query check into two functions. Modified: soc2013/mattbw/backend/query/check.c Modified: soc2013/mattbw/backend/query/check.c ============================================================================== --- soc2013/mattbw/backend/query/check.c Sun Sep 15 13:50:56 2013 (r257374) +++ soc2013/mattbw/backend/query/check.c Sun Sep 15 14:07:16 2013 (r257375) @@ -35,6 +35,7 @@ /* Attempts to match a set of QueryIDs into packages. */ static bool string_match(const char *left, const char *right); +static bool check_metadata(const char *name, const char *namever, const char *repo, const char *arch, struct query_id *query_id); /* Returns true if the given package matches the given query ID. */ bool @@ -58,33 +59,42 @@ if (namever == NULL || arch == NULL || repo == NULL) { matches = false; } else { - bool namever_matches; - bool namever_matches_name; - bool namever_matches_namever; - bool arch_matches; - bool repo_matches; - - /* - * Allow raw names to match the Query ID namever, as well as - * the full package namevers. This allows Resolve to work - * properly. - */ - namever_matches_name = string_match(query_id->namever, name); - namever_matches_namever = string_match(query_id->namever, - namever); - namever_matches = (namever_matches_name || - namever_matches_namever); + matches = check_metadata(name, namever, repo, arch, query_id); + } - arch_matches = string_match(query_id->arch, arch); - repo_matches = string_match(query_id->repo, repo); + free(namever); + return matches; +} +static bool +check_metadata(const char *name, const char *namever, const char *repo, + const char *arch, struct query_id *query_id) +{ + bool namever_matches; + bool namever_matches_name; + bool namever_matches_namever; + bool arch_matches; + bool repo_matches; + + assert(name != NULL); + assert(namever != NULL); + assert(arch != NULL); + assert(repo != NULL); + assert(query_id != NULL); + assert(query_id->namever != NULL); - matches = (namever_matches && arch_matches && repo_matches); - } + /* + * Allow raw names to match the Query ID namever, as well as the full + * package namevers. This allows Resolve to work properly. + */ + namever_matches_name = string_match(query_id->namever, name); + namever_matches_namever = string_match(query_id->namever, namever); + namever_matches = (namever_matches_name || namever_matches_namever); - free(namever); + arch_matches = string_match(query_id->arch, arch); + repo_matches = string_match(query_id->repo, repo); - return matches; + return (namever_matches && arch_matches && repo_matches); } /*