diff options
author | Karel Kočí <cynerd@email.cz> | 2015-04-17 09:54:55 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-04-17 09:54:55 +0200 |
commit | b81979aaea68da39fdf41bd82469f4d6b8201827 (patch) | |
tree | da9f21d865c31fc6a0139bf57bb63f6ec601296f /scripts/write_config/solution.c | |
parent | 1c910efc793d22a0aa269fa5314474d69a6212af (diff) | |
download | linux-conf-perf-b81979aaea68da39fdf41bd82469f4d6b8201827.tar.gz linux-conf-perf-b81979aaea68da39fdf41bd82469f4d6b8201827.tar.bz2 linux-conf-perf-b81979aaea68da39fdf41bd82469f4d6b8201827.zip |
write_config implemented solution reader, but most of code in write.c is now commented
Diffstat (limited to 'scripts/write_config/solution.c')
-rw-r--r-- | scripts/write_config/solution.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/write_config/solution.c b/scripts/write_config/solution.c new file mode 100644 index 0000000..fd3d2cf --- /dev/null +++ b/scripts/write_config/solution.c @@ -0,0 +1,48 @@ +#include "solution.h" + +void solution_set(struct symlist *sl, FILE * f) { + int c; + // skip first line + do + c = fgetc(f); + while (c != EOF && c != '\n'); + + char *w; + size_t w_size = 1, w_pos = 0; + w = malloc((w_size + 1) * sizeof(char)); + do { + c = fgetc(f); + if (c == ' ' || c == '\n') { + w[w_pos] = '\0'; + w_pos = 0; + char *ww = w; + bool neg = false; + if (w[0] == '-') { + neg = true; + ww = w + 1; + } + int id = atoi(ww); + if (id == 0) + continue; + if (sl->array[id - 1].sym == NULL) + continue; + tristate val = sym_get_tristate_value(sl->array[id - 1].sym); + sym_set_tristate_value(sl->array[id - 1].sym, neg ? no : yes); + sym_calc_value(sl->array[id - 1].sym); + if (neg == + (sym_get_tristate_value(sl->array[id - 1].sym) == + no ? true : false)) + printf("Ok\n"); + else + printf("Problem %s\n", sl->array[id - 1].sym->name); + if (sym_get_tristate_value(sl->array[id - 1].sym) != val) + printf("Change\n"); + } else { + if (w_pos >= w_size) { + w_size *= 2; + w = realloc(w, (w_size + 1) * sizeof(char)); + } + w[w_pos++] = (char) c; + } + } while (c != EOF && c != '\n'); +} |