aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/write_config/solution.c4
-rw-r--r--scripts/write_config/solution.h2
-rw-r--r--scripts/write_config/symlist.c3
-rw-r--r--scripts/write_config/symlist.h1
-rw-r--r--scripts/write_config/write.c2
5 files changed, 9 insertions, 3 deletions
diff --git a/scripts/write_config/solution.c b/scripts/write_config/solution.c
index 5a82a01..a8d9fc7 100644
--- a/scripts/write_config/solution.c
+++ b/scripts/write_config/solution.c
@@ -1,6 +1,6 @@
#include "solution.h"
-void solution_set(struct symlist *sl, FILE * f) {
+void solution_check(struct symlist *sl, FILE * f) {
int c;
// skip first line
do
@@ -22,6 +22,8 @@ void solution_set(struct symlist *sl, FILE * f) {
ww = w + 1;
}
int id = atoi(ww);
+ if ((unsigned) id > sl->maxid)
+ break;
if (id == 0)
continue;
if (sl->array[id - 1].sym == NULL)
diff --git a/scripts/write_config/solution.h b/scripts/write_config/solution.h
index fb1ebed..91db619 100644
--- a/scripts/write_config/solution.h
+++ b/scripts/write_config/solution.h
@@ -8,6 +8,6 @@
#ifndef _SOLUTION_H_
#define _SOLUTION_H_
-void solution_set(struct symlist *sl, FILE * f);
+void solution_check(struct symlist *sl, FILE * f);
#endif /* _SOLUTION_H_ */
diff --git a/scripts/write_config/symlist.c b/scripts/write_config/symlist.c
index e0e7a1f..fd0aca8 100644
--- a/scripts/write_config/symlist.c
+++ b/scripts/write_config/symlist.c
@@ -6,6 +6,7 @@ struct symlist *symlist_read(FILE * f) {
struct symlist *ret;
ret = malloc(sizeof(struct symlist));
ret->size = 1;
+ ret->maxid = 0;
ret->array = malloc(ret->size * sizeof(struct symlist_el));
unsigned int id;
@@ -24,6 +25,8 @@ struct symlist *symlist_read(FILE * f) {
realloc(ret->array,
ret->size * sizeof(struct symlist_el));
}
+ if (id > ret->maxid)
+ ret->maxid = id;
ret->array[(size_t) id - 1].id = id;
if (!strncmp(w, NONAMEGEN, strlen(NONAMEGEN)))
ret->array[(size_t) id - 1].sym = NULL;
diff --git a/scripts/write_config/symlist.h b/scripts/write_config/symlist.h
index 3736b2b..8bc61c1 100644
--- a/scripts/write_config/symlist.h
+++ b/scripts/write_config/symlist.h
@@ -15,6 +15,7 @@ struct symlist_el {
struct symlist {
struct symlist_el *array;
size_t size;
+ unsigned maxid;
};
struct symlist *symlist_read(FILE *f);
diff --git a/scripts/write_config/write.c b/scripts/write_config/write.c
index 4bec6aa..86895b6 100644
--- a/scripts/write_config/write.c
+++ b/scripts/write_config/write.c
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
Eprintf("Can't open file: %s\n", solution_file);
exit(2);
}
- solution_set(sl, f);
+ solution_check(sl, f);
fclose(f);
conf_write(".config");