aboutsummaryrefslogtreecommitdiff
path: root/scripts/parse_kconfig/symlist.c
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-04-30 16:22:01 +0200
committerKarel Kočí <cynerd@email.cz>2015-04-30 16:22:01 +0200
commitcd1b4f5e954f925bb7689189a5c2fd5fef52d745 (patch)
treed73567badc8e09787a69b4033291c37c8f0eb880 /scripts/parse_kconfig/symlist.c
parent94a0f92e1a36d68c95781e916a94a377b7081d2f (diff)
downloadlinux-conf-perf-cd1b4f5e954f925bb7689189a5c2fd5fef52d745.tar.gz
linux-conf-perf-cd1b4f5e954f925bb7689189a5c2fd5fef52d745.tar.bz2
linux-conf-perf-cd1b4f5e954f925bb7689189a5c2fd5fef52d745.zip
parse_kconfig changes before more changes come
This is commit that breaks parse_kconfig program...
Diffstat (limited to 'scripts/parse_kconfig/symlist.c')
-rw-r--r--scripts/parse_kconfig/symlist.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/scripts/parse_kconfig/symlist.c b/scripts/parse_kconfig/symlist.c
index b0b90ea..f5f42ab 100644
--- a/scripts/parse_kconfig/symlist.c
+++ b/scripts/parse_kconfig/symlist.c
@@ -5,6 +5,7 @@ struct symlist *symlist_create() {
ret = malloc(sizeof(struct symlist));
ret->size = 1;
ret->pos = 0;
+ ret->lastsym = 0;
ret->array = malloc(ret->size * sizeof(struct symlist_el));
return ret;
}
@@ -15,39 +16,57 @@ void symlist_add(struct symlist *sl, char *name) {
sl->array =
realloc(sl->array, sl->size * sizeof(struct symlist_el));
}
- sl->array[sl->pos].id = (unsigned) sl->pos + 1;
sl->array[sl->pos].name = name;
- sl->array[sl->pos].be = NULL;
sl->array[sl->pos].prompt = false;
- sl->array[sl->pos].def = true;
+ sl->array[sl->pos].def = NULL;
+ sl->array[sl->pos].def_size = 0;
+ sl->array[sl->pos].dep = NULL;
+ sl->array[sl->pos].rev_dep = NULL;
sl->pos++;
}
-void symlist_set_prompt(struct symlist *sl, char *name, bool prompt) {
- symlist_find(sl, name)->prompt = prompt;
+void symlist_closesym(struct symlist *sl) {
+ sl->lastsym = (unsigned) sl->pos;
+}
+
+unsigned symlist_adddummy(struct symlist *sl) {
+ if (sl->lastsym == 0)
+ fprintf(stderr,
+ "W: symlist adddummy, but lastsym is zero. This shouldn't happen.");
+ return sl->lastsym++;
}
-// TODO faster implementation? Maybe binary search tree?
struct symlist_el *symlist_find(struct symlist *sl, char *name) {
+ size_t i = symlist_id(sl, name);
+ if (i == 0)
+ return NULL;
+ else
+ return &(sl->array[i - 1]);
+}
+
+// TODO faster implementation? Maybe binary search tree?
+size_t symlist_id(struct symlist * sl, char *name) {
size_t i = 0;
while (i < sl->pos) {
if (!strcmp(name, sl->array[i].name))
- return &sl->array[i];
+ return i + 1;
i++;
}
- return NULL;
+ return 0;
}
void symlist_print(struct symlist *sl) {
- size_t i;
- for (i = 0; i < sl->pos; i++) {
- printf("%d:%s\n", sl->array[i].id, sl->array[i].name);
- if (sl->array[i].be != NULL) {
- printf(" ");
- cnf_printf(sl->array[i].be);
- printf("\n");
- }
- }
+ /*
+ size_t i;
+ for (i = 0; i < sl->pos; i++) {
+ printf("%d:%s\n", sl->array[i].id, sl->array[i].name);
+ if (sl->array[i].be != NULL) {
+ printf(" ");
+ cnf_printf(sl->array[i].be);
+ printf("\n");
+ }
+ }
+ */
}
void symlist_free(struct symlist *sl) {