author | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-16 18:04:11 (UTC) |
commit | 3904d85eac20dfd21cf2a3245977f9946865fd92 (patch) (unidiff) | |
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 | |||
@@ -3,8 +3,8 @@ | |||
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <sys/stat.h> | ||
6 | #include <ctype.h> | 7 | #include <ctype.h> |
7 | #include <limits.h> | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
@@ -14,7 +14,6 @@ | |||
14 | #include "lkc.h" | 14 | #include "lkc.h" |
15 | 15 | ||
16 | const char conf_def_filename[] = ".config"; | 16 | const char conf_def_filename[] = ".config"; |
17 | char conf_filename[PATH_MAX+1]; | ||
18 | 17 | ||
19 | const char conf_defname[] = "arch/$ARCH/defconfig"; | 18 | const char conf_defname[] = "arch/$ARCH/defconfig"; |
20 | 19 | ||
@@ -55,13 +54,24 @@ static char *conf_expand_value(const char *in) | |||
55 | 54 | ||
56 | char *conf_get_default_confname(void) | 55 | char *conf_get_default_confname(void) |
57 | { | 56 | { |
58 | return conf_expand_value(conf_defname); | 57 | struct stat buf; |
58 | static char fullname[PATH_MAX+1]; | ||
59 | char *env, *name; | ||
60 | |||
61 | name = conf_expand_value(conf_defname); | ||
62 | env = getenv(SRCTREE); | ||
63 | if (env) { | ||
64 | sprintf(fullname, "%s/%s", env, name); | ||
65 | if (!stat(fullname, &buf)) | ||
66 | return fullname; | ||
67 | } | ||
68 | return name; | ||
59 | } | 69 | } |
60 | 70 | ||
61 | int conf_read(const char *name) | 71 | int conf_read(const char *name) |
62 | { | 72 | { |
63 | FILE *in = NULL; | 73 | FILE *in = NULL; |
64 | char line[128]; | 74 | char line[1024]; |
65 | char *p, *p2; | 75 | char *p, *p2; |
66 | int lineno = 0; | 76 | int lineno = 0; |
67 | struct symbol *sym; | 77 | struct symbol *sym; |
@@ -70,14 +80,12 @@ int conf_read(const char *name) | |||
70 | int i; | 80 | int i; |
71 | 81 | ||
72 | if (name) { | 82 | if (name) { |
73 | in = fopen(name, "r"); | 83 | in = zconf_fopen(name); |
74 | if (in) | ||
75 | strcpy(conf_filename, name); | ||
76 | } else { | 84 | } else { |
77 | const char **names = conf_confnames; | 85 | const char **names = conf_confnames; |
78 | while ((name = *names++)) { | 86 | while ((name = *names++)) { |
79 | name = conf_expand_value(name); | 87 | name = conf_expand_value(name); |
80 | in = fopen(name, "r"); | 88 | in = zconf_fopen(name); |
81 | if (in) { | 89 | if (in) { |
82 | printf("#\n" | 90 | printf("#\n" |
83 | "# using defaults found in %s\n" | 91 | "# using defaults found in %s\n" |
@@ -91,21 +99,21 @@ int conf_read(const char *name) | |||
91 | return 1; | 99 | return 1; |
92 | 100 | ||
93 | for_all_symbols(i, sym) { | 101 | for_all_symbols(i, sym) { |
94 | sym->flags |= SYMBOL_NEW; | 102 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; |
103 | sym->flags &= ~SYMBOL_VALID; | ||
95 | switch (sym->type) { | 104 | switch (sym->type) { |
96 | case S_INT: | 105 | case S_INT: |
97 | case S_HEX: | 106 | case S_HEX: |
98 | case S_STRING: | 107 | case S_STRING: |
99 | if (S_VAL(sym->def)) { | 108 | if (S_VAL(sym->def)) |
100 | free(S_VAL(sym->def)); | 109 | free(S_VAL(sym->def)); |
101 | S_VAL(sym->def) = NULL; | ||
102 | } | ||
103 | default: | 110 | default: |
104 | ; | 111 | S_VAL(sym->def) = NULL; |
112 | S_TRI(sym->def) = no; | ||
105 | } | 113 | } |
106 | } | 114 | } |
107 | 115 | ||
108 | while (fgets(line, 128, in)) { | 116 | while (fgets(line, sizeof(line), in)) { |
109 | lineno++; | 117 | lineno++; |
110 | switch (line[0]) { | 118 | switch (line[0]) { |
111 | case '#': | 119 | case '#': |
@@ -117,7 +125,6 @@ int conf_read(const char *name) | |||
117 | *p++ = 0; | 125 | *p++ = 0; |
118 | if (strncmp(p, "is not set", 10)) | 126 | if (strncmp(p, "is not set", 10)) |
119 | continue; | 127 | continue; |
120 | //printf("%s -> n\n", line + 9); | ||
121 | sym = sym_lookup(line + 9, 0); | 128 | sym = sym_lookup(line + 9, 0); |
122 | switch (sym->type) { | 129 | switch (sym->type) { |
123 | case S_BOOLEAN: | 130 | case S_BOOLEAN: |
@@ -139,23 +146,29 @@ int conf_read(const char *name) | |||
139 | p2 = strchr(p, '\n'); | 146 | p2 = strchr(p, '\n'); |
140 | if (p2) | 147 | if (p2) |
141 | *p2 = 0; | 148 | *p2 = 0; |
142 | //printf("%s -> %s\n", line + 7, p); | ||
143 | sym = sym_find(line + 7); | 149 | sym = sym_find(line + 7); |
144 | if (!sym) { | 150 | if (!sym) { |
145 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); | 151 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 7); |
146 | break; | 152 | break; |
147 | } | 153 | } |
148 | switch (sym->type) { | 154 | switch (sym->type) { |
149 | case S_BOOLEAN: | ||
150 | sym->def = symbol_yes.curr; | ||
151 | sym->flags &= ~SYMBOL_NEW; | ||
152 | break; | ||
153 | case S_TRISTATE: | 155 | case S_TRISTATE: |
154 | if (p[0] == 'm') | 156 | if (p[0] == 'm') { |
155 | sym->def = symbol_mod.curr; | 157 | S_TRI(sym->def) = mod; |
156 | else | 158 | sym->flags &= ~SYMBOL_NEW; |
157 | sym->def = symbol_yes.curr; | 159 | break; |
158 | sym->flags &= ~SYMBOL_NEW; | 160 | } |
161 | case S_BOOLEAN: | ||
162 | if (p[0] == 'y') { | ||
163 | S_TRI(sym->def) = yes; | ||
164 | sym->flags &= ~SYMBOL_NEW; | ||
165 | break; | ||
166 | } | ||
167 | if (p[0] == 'n') { | ||
168 | S_TRI(sym->def) = no; | ||
169 | sym->flags &= ~SYMBOL_NEW; | ||
170 | break; | ||
171 | } | ||
159 | break; | 172 | break; |
160 | case S_STRING: | 173 | case S_STRING: |
161 | if (*p++ != '"') | 174 | if (*p++ != '"') |
@@ -167,13 +180,19 @@ int conf_read(const char *name) | |||
167 | } | 180 | } |
168 | memmove(p2, p2 + 1, strlen(p2)); | 181 | memmove(p2, p2 + 1, strlen(p2)); |
169 | } | 182 | } |
183 | if (!p2) { | ||
184 | fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); | ||
185 | exit(1); | ||
186 | } | ||
170 | case S_INT: | 187 | case S_INT: |
171 | case S_HEX: | 188 | case S_HEX: |
172 | if (sym_string_valid(sym, p)) { | 189 | if (sym_string_valid(sym, p)) { |
173 | S_VAL(sym->def) = strdup(p); | 190 | S_VAL(sym->def) = strdup(p); |
174 | sym->flags &= ~SYMBOL_NEW; | 191 | sym->flags &= ~SYMBOL_NEW; |
175 | } else | 192 | } else { |
176 | fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); | 193 | fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); |
194 | exit(1); | ||
195 | } | ||
177 | break; | 196 | break; |
178 | default: | 197 | default: |
179 | ; | 198 | ; |
@@ -352,7 +371,6 @@ int conf_write(const char *name) | |||
352 | rename(name, oldname); | 371 | rename(name, oldname); |
353 | if (rename(".tmpconfig", name)) | 372 | if (rename(".tmpconfig", name)) |
354 | return 1; | 373 | return 1; |
355 | strcpy(conf_filename, name); | ||
356 | 374 | ||
357 | sym_change_count = 0; | 375 | sym_change_count = 0; |
358 | 376 | ||