1 |
commit: ee31ca7a1155fa1c9ffd605929985e77b66f5cb8 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Sep 20 17:10:52 2019 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 20 17:10:52 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ee31ca7a |
7 |
|
8 |
libq/atom: return compare results as enum proper |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
libq/atom.c | 8 ++++---- |
13 |
libq/atom.h | 12 +++++++++--- |
14 |
2 files changed, 13 insertions(+), 7 deletions(-) |
15 |
|
16 |
diff --git a/libq/atom.c b/libq/atom.c |
17 |
index 4c21a40..8f564eb 100644 |
18 |
--- a/libq/atom.c |
19 |
+++ b/libq/atom.c |
20 |
@@ -339,7 +339,7 @@ atom_implode(depend_atom *atom) |
21 |
free(atom); |
22 |
} |
23 |
|
24 |
-static int |
25 |
+static atom_equality |
26 |
_atom_compare_match(int ret, atom_operator op) |
27 |
{ |
28 |
if (op == ATOM_OP_NONE) |
29 |
@@ -370,7 +370,7 @@ _atom_compare_match(int ret, atom_operator op) |
30 |
* foo-1 <OLDER> foo-2 |
31 |
* foo-1 <NOT_EQUAL> bar-1 |
32 |
*/ |
33 |
-int |
34 |
+atom_equality |
35 |
atom_compare(const depend_atom *data, const depend_atom *query) |
36 |
{ |
37 |
atom_operator pfx_op; |
38 |
@@ -620,11 +620,11 @@ atom_compare(const depend_atom *data, const depend_atom *query) |
39 |
return _atom_compare_match(NEWER, pfx_op); |
40 |
} |
41 |
|
42 |
-int |
43 |
+atom_equality |
44 |
atom_compare_str(const char * const s1, const char * const s2) |
45 |
{ |
46 |
depend_atom *a1, *a2; |
47 |
- int ret = ERROR; |
48 |
+ atom_equality ret = ERROR; |
49 |
|
50 |
a1 = atom_explode(s1); |
51 |
if (!a1) |
52 |
|
53 |
diff --git a/libq/atom.h b/libq/atom.h |
54 |
index 72266d5..43397ad 100644 |
55 |
--- a/libq/atom.h |
56 |
+++ b/libq/atom.h |
57 |
@@ -87,12 +87,18 @@ typedef struct { |
58 |
} depend_atom; |
59 |
|
60 |
extern const char * const booga[]; |
61 |
-enum { ERROR=0, NOT_EQUAL, EQUAL, NEWER, OLDER }; |
62 |
+typedef enum { |
63 |
+ ERROR = 0, |
64 |
+ NOT_EQUAL, |
65 |
+ EQUAL, |
66 |
+ NEWER, |
67 |
+ OLDER |
68 |
+} atom_equality; |
69 |
|
70 |
depend_atom *atom_explode(const char *atom); |
71 |
void atom_implode(depend_atom *atom); |
72 |
-int atom_compare(const depend_atom *a1, const depend_atom *a2); |
73 |
-int atom_compare_str(const char * const s1, const char * const s2); |
74 |
+atom_equality atom_compare(const depend_atom *a1, const depend_atom *a2); |
75 |
+atom_equality atom_compare_str(const char * const s1, const char * const s2); |
76 |
char *atom_to_string_r(char *buf, size_t buflen, depend_atom *a); |
77 |
char *atom_format_r(char *buf, size_t buflen, |
78 |
const char *format, const depend_atom *atom); |