Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
| 3 | * Released under the terms of the GNU GPL v2.0. |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 6 | #include <sys/stat.h> |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 7 | #include <ctype.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <string.h> |
| 11 | #include <unistd.h> |
| 12 | |
| 13 | #define LKC_DIRECT_LINK |
| 14 | #include "lkc.h" |
| 15 | |
| 16 | const char conf_def_filename[] = ".config"; |
| 17 | |
Eric Andersen | fa7532b | 2003-06-12 22:09:08 +0000 | [diff] [blame] | 18 | const char conf_defname[] = "sysdeps/linux/defconfig"; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 19 | |
| 20 | const char *conf_confnames[] = { |
| 21 | ".config", |
| 22 | conf_defname, |
| 23 | NULL, |
| 24 | }; |
| 25 | |
| 26 | static char *conf_expand_value(const char *in) |
| 27 | { |
| 28 | struct symbol *sym; |
| 29 | const char *src; |
| 30 | static char res_value[SYMBOL_MAXLENGTH]; |
| 31 | char *dst, name[SYMBOL_MAXLENGTH]; |
| 32 | |
| 33 | res_value[0] = 0; |
| 34 | dst = name; |
| 35 | while ((src = strchr(in, '$'))) { |
| 36 | strncat(res_value, in, src - in); |
| 37 | src++; |
| 38 | dst = name; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 39 | while (isalnum(*src) || *src == '_') |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 40 | *dst++ = *src++; |
| 41 | *dst = 0; |
| 42 | sym = sym_lookup(name, 0); |
| 43 | sym_calc_value(sym); |
| 44 | strcat(res_value, sym_get_string_value(sym)); |
| 45 | in = src; |
| 46 | } |
| 47 | strcat(res_value, in); |
| 48 | |
| 49 | return res_value; |
| 50 | } |
| 51 | |
| 52 | char *conf_get_default_confname(void) |
| 53 | { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 54 | struct stat buf; |
| 55 | static char fullname[4096+1]; |
| 56 | char *env, *name; |
| 57 | |
| 58 | name = conf_expand_value(conf_defname); |
| 59 | env = getenv(SRCTREE); |
| 60 | if (env) { |
| 61 | sprintf(fullname, "%s/%s", env, name); |
| 62 | if (!stat(fullname, &buf)) |
| 63 | return fullname; |
| 64 | } |
| 65 | return name; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | int conf_read(const char *name) |
| 69 | { |
| 70 | FILE *in = NULL; |
| 71 | char line[1024]; |
| 72 | char *p, *p2; |
| 73 | int lineno = 0; |
| 74 | struct symbol *sym; |
| 75 | struct property *prop; |
| 76 | struct expr *e; |
| 77 | int i; |
| 78 | |
| 79 | if (name) { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 80 | in = zconf_fopen(name); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 81 | } else { |
| 82 | const char **names = conf_confnames; |
| 83 | while ((name = *names++)) { |
| 84 | name = conf_expand_value(name); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 85 | in = zconf_fopen(name); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 86 | if (in) { |
| 87 | printf("#\n" |
| 88 | "# using defaults found in %s\n" |
| 89 | "#\n", name); |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | if (!in) |
| 96 | return 1; |
| 97 | |
| 98 | for_all_symbols(i, sym) { |
| 99 | sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED; |
| 100 | sym->flags &= ~SYMBOL_VALID; |
| 101 | switch (sym->type) { |
| 102 | case S_INT: |
| 103 | case S_HEX: |
| 104 | case S_STRING: |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 105 | if (sym->user.val) |
| 106 | free(sym->user.val); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 107 | default: |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 108 | sym->user.val = NULL; |
| 109 | sym->user.tri = no; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 110 | } |
| 111 | } |
| 112 | |
| 113 | while (fgets(line, sizeof(line), in)) { |
| 114 | lineno++; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 115 | sym = NULL; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 116 | switch (line[0]) { |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 117 | case '#': |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 118 | if (line[1]!=' ') |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 119 | continue; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 120 | p = strchr(line + 2, ' '); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 121 | if (!p) |
| 122 | continue; |
| 123 | *p++ = 0; |
| 124 | if (strncmp(p, "is not set", 10)) |
| 125 | continue; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 126 | sym = sym_find(line + 2); |
| 127 | if (!sym) { |
| 128 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2); |
| 129 | break; |
| 130 | } |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 131 | switch (sym->type) { |
| 132 | case S_BOOLEAN: |
| 133 | case S_TRISTATE: |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 134 | sym->user.tri = no; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 135 | sym->flags &= ~SYMBOL_NEW; |
| 136 | break; |
| 137 | default: |
| 138 | ; |
| 139 | } |
| 140 | break; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 141 | |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 142 | case 'A' ... 'Z': |
| 143 | p = strchr(line, '='); |
| 144 | if (!p) |
| 145 | continue; |
| 146 | *p++ = 0; |
| 147 | p2 = strchr(p, '\n'); |
| 148 | if (p2) |
| 149 | *p2 = 0; |
| 150 | sym = sym_find(line); |
| 151 | if (!sym) { |
| 152 | fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line); |
| 153 | break; |
| 154 | } |
| 155 | switch (sym->type) { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 156 | case S_TRISTATE: |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 157 | if (p[0] == 'm') { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 158 | sym->user.tri = mod; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 159 | sym->flags &= ~SYMBOL_NEW; |
| 160 | break; |
| 161 | } |
| 162 | case S_BOOLEAN: |
| 163 | if (p[0] == 'y') { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 164 | sym->user.tri = yes; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 165 | sym->flags &= ~SYMBOL_NEW; |
| 166 | break; |
| 167 | } |
| 168 | if (p[0] == 'n') { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 169 | sym->user.tri = no; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 170 | sym->flags &= ~SYMBOL_NEW; |
| 171 | break; |
| 172 | } |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 173 | break; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 174 | case S_STRING: |
| 175 | if (*p++ != '"') |
| 176 | break; |
| 177 | for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) { |
| 178 | if (*p2 == '"') { |
| 179 | *p2 = 0; |
| 180 | break; |
| 181 | } |
| 182 | memmove(p2, p2 + 1, strlen(p2)); |
| 183 | } |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 184 | if (!p2) { |
| 185 | fprintf(stderr, "%s:%d: invalid string found\n", name, lineno); |
| 186 | exit(1); |
| 187 | } |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 188 | case S_INT: |
| 189 | case S_HEX: |
| 190 | if (sym_string_valid(sym, p)) { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 191 | sym->user.val = strdup(p); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 192 | sym->flags &= ~SYMBOL_NEW; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 193 | } else { |
| 194 | fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name); |
| 195 | exit(1); |
| 196 | } |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 197 | break; |
| 198 | default: |
| 199 | ; |
| 200 | } |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 201 | break; |
| 202 | case '\n': |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 203 | break; |
| 204 | default: |
| 205 | continue; |
| 206 | } |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 207 | if (sym && sym_is_choice_value(sym)) { |
| 208 | struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); |
| 209 | switch (sym->user.tri) { |
| 210 | case no: |
| 211 | break; |
| 212 | case mod: |
| 213 | if (cs->user.tri == yes) |
| 214 | /* warn? */; |
| 215 | break; |
| 216 | case yes: |
| 217 | if (cs->user.tri != no) |
| 218 | /* warn? */; |
| 219 | cs->user.val = sym; |
| 220 | break; |
| 221 | } |
| 222 | cs->user.tri = E_OR(cs->user.tri, sym->user.tri); |
| 223 | cs->flags &= ~SYMBOL_NEW; |
| 224 | } |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 225 | } |
| 226 | fclose(in); |
| 227 | |
| 228 | for_all_symbols(i, sym) { |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 229 | sym_calc_value(sym); |
| 230 | if (sym_has_value(sym) && !sym_is_choice_value(sym)) { |
| 231 | if (sym->visible == no) |
| 232 | sym->flags |= SYMBOL_NEW; |
| 233 | switch (sym->type) { |
| 234 | case S_STRING: |
| 235 | case S_INT: |
| 236 | case S_HEX: |
| 237 | if (!sym_string_within_range(sym, sym->user.val)) |
| 238 | sym->flags |= SYMBOL_NEW; |
| 239 | default: |
| 240 | break; |
| 241 | } |
| 242 | } |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 243 | if (!sym_is_choice(sym)) |
| 244 | continue; |
| 245 | prop = sym_get_choice_prop(sym); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 246 | for (e = prop->expr; e; e = e->left.expr) |
| 247 | if (e->right.sym->visible != no) |
| 248 | sym->flags |= e->right.sym->flags & SYMBOL_NEW; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | sym_change_count = 1; |
| 252 | |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | int conf_write(const char *name) |
| 257 | { |
| 258 | FILE *out, *out_h; |
| 259 | struct symbol *sym; |
| 260 | struct menu *menu; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 261 | const char *basename; |
| 262 | char dirname[128], tmpname[128], newname[128]; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 263 | int type, l; |
| 264 | const char *str; |
| 265 | |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 266 | dirname[0] = 0; |
| 267 | if (name && name[0]) { |
| 268 | char *slash = strrchr(name, '/'); |
| 269 | if (slash) { |
| 270 | int size = slash - name + 1; |
| 271 | memcpy(dirname, name, size); |
| 272 | dirname[size] = 0; |
| 273 | if (slash[1]) |
| 274 | basename = slash + 1; |
| 275 | else |
| 276 | basename = conf_def_filename; |
| 277 | } else |
| 278 | basename = name; |
| 279 | } else |
| 280 | basename = conf_def_filename; |
| 281 | |
| 282 | sprintf(newname, "%s.tmpconfig.%d", dirname, getpid()); |
| 283 | out = fopen(newname, "w"); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 284 | if (!out) |
| 285 | return 1; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 286 | out_h = NULL; |
| 287 | if (!name) { |
| 288 | out_h = fopen(".tmpconfig.h", "w"); |
| 289 | if (!out_h) |
| 290 | return 1; |
| 291 | } |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 292 | fprintf(out, "#\n" |
| 293 | "# Automatically generated make config: don't edit\n" |
| 294 | "#\n"); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 295 | if (out_h) |
| 296 | fprintf(out_h, "/*\n" |
| 297 | " * Automatically generated header file: don't edit\n" |
| 298 | " */\n\n" |
| 299 | "#define AUTOCONF_INCLUDED\n\n" |
| 300 | "/* Version Number */\n" |
| 301 | "#define BB_VER \"%s\"\n" |
| 302 | "#define BB_BT \"%s\"\n\n", |
| 303 | getenv("VERSION"), |
| 304 | getenv("BUILDTIME")); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 305 | |
| 306 | if (!sym_change_count) |
| 307 | sym_clear_all_valid(); |
| 308 | |
| 309 | menu = rootmenu.list; |
| 310 | while (menu) { |
| 311 | sym = menu->sym; |
| 312 | if (!sym) { |
| 313 | if (!menu_is_visible(menu)) |
| 314 | goto next; |
| 315 | str = menu_get_prompt(menu); |
| 316 | fprintf(out, "\n" |
| 317 | "#\n" |
| 318 | "# %s\n" |
| 319 | "#\n", str); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 320 | if (out_h) |
| 321 | fprintf(out_h, "\n" |
| 322 | "/*\n" |
| 323 | " * %s\n" |
| 324 | " */\n", str); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 325 | } else if (!(sym->flags & SYMBOL_CHOICE)) { |
| 326 | sym_calc_value(sym); |
| 327 | if (!(sym->flags & SYMBOL_WRITE)) |
| 328 | goto next; |
| 329 | sym->flags &= ~SYMBOL_WRITE; |
| 330 | type = sym->type; |
| 331 | if (type == S_TRISTATE) { |
| 332 | sym_calc_value(modules_sym); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 333 | if (modules_sym->curr.tri == no) |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 334 | type = S_BOOLEAN; |
| 335 | } |
| 336 | switch (type) { |
| 337 | case S_BOOLEAN: |
| 338 | case S_TRISTATE: |
| 339 | switch (sym_get_tristate_value(sym)) { |
| 340 | case no: |
| 341 | fprintf(out, "# %s is not set\n", sym->name); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 342 | if (out_h) |
| 343 | fprintf(out_h, "#undef %s\n", sym->name); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 344 | break; |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 345 | case mod: |
Glenn L McGrath | 8ac86e3 | 2003-10-03 08:28:59 +0000 | [diff] [blame] | 346 | #if 0 |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 347 | fprintf(out, "%s=m\n", sym->name); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 348 | if (out_h) |
| 349 | fprintf(out_h, "#define %s_MODULE 1\n", sym->name); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 350 | #endif |
Glenn L McGrath | 8ac86e3 | 2003-10-03 08:28:59 +0000 | [diff] [blame] | 351 | break; |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 352 | case yes: |
| 353 | fprintf(out, "%s=y\n", sym->name); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 354 | if (out_h) |
| 355 | fprintf(out_h, "#define %s 1\n", sym->name); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 356 | break; |
| 357 | } |
| 358 | break; |
| 359 | case S_STRING: |
| 360 | // fix me |
| 361 | str = sym_get_string_value(sym); |
| 362 | fprintf(out, "%s=\"", sym->name); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 363 | if (out_h) |
| 364 | fprintf(out_h, "#define %s \"", sym->name); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 365 | do { |
| 366 | l = strcspn(str, "\"\\"); |
| 367 | if (l) { |
| 368 | fwrite(str, l, 1, out); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 369 | if (out_h) |
| 370 | fwrite(str, l, 1, out_h); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 371 | } |
| 372 | str += l; |
| 373 | while (*str == '\\' || *str == '"') { |
| 374 | fprintf(out, "\\%c", *str); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 375 | if (out_h) |
| 376 | fprintf(out_h, "\\%c", *str); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 377 | str++; |
| 378 | } |
| 379 | } while (*str); |
| 380 | fputs("\"\n", out); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 381 | if (out_h) |
| 382 | fputs("\"\n", out_h); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 383 | break; |
| 384 | case S_HEX: |
| 385 | str = sym_get_string_value(sym); |
| 386 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { |
| 387 | fprintf(out, "%s=%s\n", sym->name, str); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 388 | if (out_h) |
| 389 | fprintf(out_h, "#define %s 0x%s\n", sym->name, str); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 390 | break; |
| 391 | } |
| 392 | case S_INT: |
| 393 | str = sym_get_string_value(sym); |
| 394 | fprintf(out, "%s=%s\n", sym->name, str); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 395 | if (out_h) |
| 396 | fprintf(out_h, "#define %s %s\n", sym->name, str); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 397 | break; |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | next: |
| 402 | if (menu->list) { |
| 403 | menu = menu->list; |
| 404 | continue; |
| 405 | } |
| 406 | if (menu->next) |
| 407 | menu = menu->next; |
| 408 | else while ((menu = menu->parent)) { |
| 409 | if (menu->next) { |
| 410 | menu = menu->next; |
| 411 | break; |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | fclose(out); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 416 | if (out_h) { |
| 417 | fclose(out_h); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 418 | rename(".tmpconfig.h", "include/config.h"); |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 419 | file_write_dep(NULL); |
Eric Andersen | 72d8e44 | 2003-08-05 02:18:25 +0000 | [diff] [blame] | 420 | } |
| 421 | if (!name || basename != conf_def_filename) { |
| 422 | if (!name) |
| 423 | name = conf_def_filename; |
| 424 | sprintf(tmpname, "%s.old", name); |
| 425 | rename(name, tmpname); |
| 426 | } |
| 427 | sprintf(tmpname, "%s%s", dirname, basename); |
| 428 | if (rename(newname, tmpname)) |
Eric Andersen | c9f20d9 | 2002-12-05 08:41:41 +0000 | [diff] [blame] | 429 | return 1; |
| 430 | |
| 431 | sym_change_count = 0; |
| 432 | |
| 433 | return 0; |
| 434 | } |