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 | 74 |
1 files changed, 46 insertions, 28 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 @@ -1,200 +1,219 @@ /* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * 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> #include <unistd.h> #define LKC_DIRECT_LINK #include "lkc.h" const char conf_def_filename[] = ".config"; -char conf_filename[PATH_MAX+1]; const char conf_defname[] = "arch/$ARCH/defconfig"; const char *conf_confnames[] = { ".config", "/lib/modules/$UNAME_RELEASE/.config", "/etc/kernel-config", "/boot/config-$UNAME_RELEASE", conf_defname, NULL, }; static char *conf_expand_value(const char *in) { struct symbol *sym; const char *src; static char res_value[SYMBOL_MAXLENGTH]; char *dst, name[SYMBOL_MAXLENGTH]; res_value[0] = 0; dst = name; while ((src = strchr(in, '$'))) { strncat(res_value, in, src - in); src++; dst = name; while (isalnum(*src) || *src == '_') *dst++ = *src++; *dst = 0; sym = sym_lookup(name, 0); sym_calc_value(sym); strcat(res_value, sym_get_string_value(sym)); in = src; } strcat(res_value, in); return res_value; } 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; struct property *prop; struct expr *e; 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" "#\n", name); break; } } } if (!in) 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 '#': if (memcmp(line + 2, "CONFIG_", 7)) continue; p = strchr(line + 9, ' '); if (!p) continue; *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: case S_TRISTATE: sym->def = symbol_no.curr; sym->flags &= ~SYMBOL_NEW; break; default: ; } break; case 'C': if (memcmp(line, "CONFIG_", 7)) continue; p = strchr(line + 7, '='); if (!p) continue; *p++ = 0; 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_BOOLEAN: - sym->def = symbol_yes.curr; - sym->flags &= ~SYMBOL_NEW; - break; case S_TRISTATE: - if (p[0] == 'm') - sym->def = symbol_mod.curr; - else - sym->def = symbol_yes.curr; - sym->flags &= ~SYMBOL_NEW; + if (p[0] == 'm') { + S_TRI(sym->def) = mod; + sym->flags &= ~SYMBOL_NEW; + break; + } + case S_BOOLEAN: + if (p[0] == 'y') { + S_TRI(sym->def) = yes; + sym->flags &= ~SYMBOL_NEW; + break; + } + if (p[0] == 'n') { + S_TRI(sym->def) = no; + sym->flags &= ~SYMBOL_NEW; + break; + } break; case S_STRING: if (*p++ != '"') break; for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { if (*p2 == '"') { *p2 = 0; break; } 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 - fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); + } else { + fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); + exit(1); + } break; default: ; } if (sym_is_choice_value(sym)) { prop = sym_get_choice_prop(sym); switch (S_TRI(sym->def)) { case mod: if (S_TRI(prop->def->def) == yes) /* warn? */; break; case yes: if (S_TRI(prop->def->def) != no) /* warn? */; S_VAL(prop->def->def) = sym; break; case no: break; } S_TRI(prop->def->def) = S_TRI(sym->def); } break; case '\n': break; @@ -331,30 +350,29 @@ int conf_write(const char *name) } if (menu->next) menu = menu->next; else while ((menu = menu->parent)) { if (menu->next) { menu = menu->next; break; } } } fclose(out); fclose(out_h); if (!name) { rename(".tmpconfig.h", "include/linux/autoconf.h"); name = conf_def_filename; file_write_dep(NULL); } else unlink(".tmpconfig.h"); sprintf(oldname, "%s.old", name); rename(name, oldname); if (rename(".tmpconfig", name)) return 1; - strcpy(conf_filename, name); sym_change_count = 0; return 0; } |