author | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
commit | 3904d85eac20dfd21cf2a3245977f9946865fd92 (patch) (side-by-side diff) | |
tree | 8d5b2217c1b54a0c439815ec02db3f5235c99daa /scripts/kconfig/confdata.c | |
parent | 0eec393ef2dd8b43db96c86e80e307f73a771fae (diff) | |
download | opie-3904d85eac20dfd21cf2a3245977f9946865fd92.zip opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.gz opie-3904d85eac20dfd21cf2a3245977f9946865fd92.tar.bz2 |
Update LinuxKernelConf to 1.3, latest available.
-rw-r--r-- | scripts/kconfig/confdata.c | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 0f5fd97..9bf7af9 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -3,8 +3,8 @@ * Released under the terms of the GNU GPL v2.0. */ +#include <sys/stat.h> #include <ctype.h> -#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -14,7 +14,6 @@ #include "lkc.h" const char conf_def_filename[] = ".config"; -char conf_filename[PATH_MAX+1]; const char conf_defname[] = "arch/$ARCH/defconfig"; @@ -55,13 +54,24 @@ static char *conf_expand_value(const char *in) char *conf_get_default_confname(void) { - return conf_expand_value(conf_defname); + struct stat buf; + static char fullname[PATH_MAX+1]; + char *env, *name; + + name = conf_expand_value(conf_defname); + env = getenv(SRCTREE); + if (env) { + sprintf(fullname, "%s/%s", env, name); + if (!stat(fullname, &buf)) + return fullname; + } + return name; } int conf_read(const char *name) { FILE *in = NULL; - char line[128]; + char line[1024]; char *p, *p2; int lineno = 0; struct symbol *sym; @@ -70,14 +80,12 @@ int conf_read(const char *name) int i; if (name) { - in = fopen(name, "r"); - if (in) - strcpy(conf_filename, name); + in = zconf_fopen(name); } else { const char **names = conf_confnames; while ((name = *names++)) { name = conf_expand_value(name); - in = fopen(name, "r"); + in = zconf_fopen(name); if (in) { printf("#\n" "# using defaults found in %s\n" @@ -91,21 +99,21 @@ int conf_read(const char *name) return 1; for_all_symbols(i, sym) { - sym->flags |= SYMBOL_NEW; + sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; + sym->flags &= ~SYMBOL_VALID; switch (sym->type) { case S_INT: case S_HEX: case S_STRING: - if (S_VAL(sym->def)) { + if (S_VAL(sym->def)) free(S_VAL(sym->def)); - S_VAL(sym->def) = NULL; - } default: - ; + S_VAL(sym->def) = NULL; + S_TRI(sym->def) = no; } } - while (fgets(line, 128, in)) { + while (fgets(line, sizeof(line), in)) { lineno++; switch (line[0]) { case '#': @@ -117,7 +125,6 @@ int conf_read(const char *name) *p++ = 0; if (strncmp(p, "is not set", 10)) continue; - //printf("%s -> n\n", line + 9); sym = sym_lookup(line + 9, 0); switch (sym->type) { case S_BOOLEAN: @@ -139,24 +146,30 @@ int conf_read(const char *name) p2 = strchr(p, '\n'); if (p2) *p2 = 0; - //printf("%s -> %s\n", line + 7, p); sym = sym_find(line + 7); if (!sym) { fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); break; } switch (sym->type) { + case S_TRISTATE: + if (p[0] == 'm') { + S_TRI(sym->def) = mod; + sym->flags &= ~SYMBOL_NEW; + break; + } case S_BOOLEAN: - sym->def = symbol_yes.curr; + if (p[0] == 'y') { + S_TRI(sym->def) = yes; sym->flags &= ~SYMBOL_NEW; break; - case S_TRISTATE: - if (p[0] == 'm') - sym->def = symbol_mod.curr; - else - sym->def = symbol_yes.curr; + } + if (p[0] == 'n') { + S_TRI(sym->def) = no; sym->flags &= ~SYMBOL_NEW; break; + } + break; case S_STRING: if (*p++ != '"') break; @@ -167,13 +180,19 @@ int conf_read(const char *name) } memmove(p2, p2 + 1, strlen(p2)); } + if (!p2) { + fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); + exit(1); + } case S_INT: case S_HEX: if (sym_string_valid(sym, p)) { S_VAL(sym->def) = strdup(p); sym->flags &= ~SYMBOL_NEW; - } else + } else { fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); + exit(1); + } break; default: ; @@ -352,7 +371,6 @@ int conf_write(const char *name) rename(name, oldname); if (rename(".tmpconfig", name)) return 1; - strcpy(conf_filename, name); sym_change_count = 0; |