From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7CF31138334 for ; Sat, 21 Sep 2019 19:53:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90C49E08F4; Sat, 21 Sep 2019 19:53:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6D6CFE08D0 for ; Sat, 21 Sep 2019 19:53:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4149C34B46E for ; Sat, 21 Sep 2019 19:53:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 84BC6615 for ; Sat, 21 Sep 2019 19:53:54 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1568999452.ee31ca7a1155fa1c9ffd605929985e77b66f5cb8.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/atom.c libq/atom.h X-VCS-Directories: libq/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: ee31ca7a1155fa1c9ffd605929985e77b66f5cb8 X-VCS-Branch: master Date: Sat, 21 Sep 2019 19:53:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0d1a60bb-ff9a-4ffc-b7e6-aeb2ffdb52b7 X-Archives-Hash: d0d1b2967f9e30d9fae93b469d721d5f commit: ee31ca7a1155fa1c9ffd605929985e77b66f5cb8 Author: Fabian Groffen gentoo org> AuthorDate: Fri Sep 20 17:10:52 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Sep 20 17:10:52 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ee31ca7a libq/atom: return compare results as enum proper Signed-off-by: Fabian Groffen gentoo.org> libq/atom.c | 8 ++++---- libq/atom.h | 12 +++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libq/atom.c b/libq/atom.c index 4c21a40..8f564eb 100644 --- a/libq/atom.c +++ b/libq/atom.c @@ -339,7 +339,7 @@ atom_implode(depend_atom *atom) free(atom); } -static int +static atom_equality _atom_compare_match(int ret, atom_operator op) { if (op == ATOM_OP_NONE) @@ -370,7 +370,7 @@ _atom_compare_match(int ret, atom_operator op) * foo-1 foo-2 * foo-1 bar-1 */ -int +atom_equality atom_compare(const depend_atom *data, const depend_atom *query) { atom_operator pfx_op; @@ -620,11 +620,11 @@ atom_compare(const depend_atom *data, const depend_atom *query) return _atom_compare_match(NEWER, pfx_op); } -int +atom_equality atom_compare_str(const char * const s1, const char * const s2) { depend_atom *a1, *a2; - int ret = ERROR; + atom_equality ret = ERROR; a1 = atom_explode(s1); if (!a1) diff --git a/libq/atom.h b/libq/atom.h index 72266d5..43397ad 100644 --- a/libq/atom.h +++ b/libq/atom.h @@ -87,12 +87,18 @@ typedef struct { } depend_atom; extern const char * const booga[]; -enum { ERROR=0, NOT_EQUAL, EQUAL, NEWER, OLDER }; +typedef enum { + ERROR = 0, + NOT_EQUAL, + EQUAL, + NEWER, + OLDER +} atom_equality; depend_atom *atom_explode(const char *atom); void atom_implode(depend_atom *atom); -int atom_compare(const depend_atom *a1, const depend_atom *a2); -int atom_compare_str(const char * const s1, const char * const s2); +atom_equality atom_compare(const depend_atom *a1, const depend_atom *a2); +atom_equality atom_compare_str(const char * const s1, const char * const s2); char *atom_to_string_r(char *buf, size_t buflen, depend_atom *a); char *atom_format_r(char *buf, size_t buflen, const char *format, const depend_atom *atom);