Skip to content

Commit 1f451b3

Browse files
committed
Tweak default/visible handling in comps parser
1 parent 6c7b940 commit 1f451b3

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

ext/repo_comps.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <stdlib.h>
1717
#include <string.h>
1818
#include <assert.h>
19-
#include <stdbool.h>
2019

2120
#include "pool.h"
2221
#include "repo.h"
@@ -97,22 +96,23 @@ struct parsedata {
9796

9897
Solvable *solvable;
9998
const char *kind;
99+
int isdefault;
100+
int isvisible;
100101
Id handle;
101102
};
102103

103104

104-
const bool COMPS_DEFAULT_USERVISIBLE = true;
105-
const bool COMPS_DEFAULT_DEFAULT = false;
106-
105+
#define COMPS_DEFAULT_ISVISIBLE 1
106+
#define COMPS_DEFAULT_ISDEFAULT 0
107107

108108
/* Return true if "true", false if "false", default_value otherwise */
109-
bool
110-
parse_boolean(char *content, bool default_value)
109+
static int
110+
parse_boolean(char *content, int default_value)
111111
{
112112
if (!strcmp(content, "true"))
113-
return true;
113+
return 1;
114114
if (!strcmp(content, "false"))
115-
return false;
115+
return 0;
116116
return default_value;
117117
}
118118

@@ -131,10 +131,8 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
131131
s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
132132
pd->handle = s - pool->solvables;
133133
pd->kind = state == STATE_GROUP ? "group" : "category";
134-
if (COMPS_DEFAULT_USERVISIBLE)
135-
repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
136-
if (COMPS_DEFAULT_DEFAULT)
137-
repodata_set_void(pd->data, pd->handle, SOLVABLE_ISDEFAULT);
134+
pd->isvisible = COMPS_DEFAULT_ISVISIBLE;
135+
pd->isdefault = COMPS_DEFAULT_ISDEFAULT;
138136
break;
139137

140138
case STATE_NAME:
@@ -185,6 +183,10 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
185183
s->evr = ID_EMPTY;
186184
if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
187185
s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
186+
if (pd->isvisible)
187+
repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
188+
if (pd->isdefault)
189+
repodata_set_void(pd->data, pd->handle, SOLVABLE_ISDEFAULT);
188190
pd->solvable = 0;
189191
break;
190192

@@ -213,17 +215,11 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
213215
break;
214216

215217
case STATE_USERVISIBLE:
216-
if (parse_boolean(content, COMPS_DEFAULT_USERVISIBLE))
217-
repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
218-
else
219-
repodata_unset(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
218+
pd->isvisible = parse_boolean(content, COMPS_DEFAULT_ISVISIBLE);
220219
break;
221220

222221
case STATE_DEFAULT:
223-
if (parse_boolean(content, COMPS_DEFAULT_DEFAULT))
224-
repodata_set_void(pd->data, pd->handle, SOLVABLE_ISDEFAULT);
225-
else
226-
repodata_unset(pd->data, pd->handle, SOLVABLE_ISDEFAULT);
222+
pd->isdefault = parse_boolean(content, COMPS_DEFAULT_ISDEFAULT);
227223
break;
228224

229225
case STATE_LANG_ONLY:

0 commit comments

Comments
 (0)