From cd1b4f5e954f925bb7689189a5c2fd5fef52d745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 30 Apr 2015 16:22:01 +0200 Subject: parse_kconfig changes before more changes come This is commit that breaks parse_kconfig program... --- scripts/parse_kconfig/symlist.c | 53 ++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 17 deletions(-) (limited to 'scripts/parse_kconfig/symlist.c') 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) { -- cgit v1.2.3