confdata.c (49192f266ffa187bd7adaf5c2d881f85bd53e0ed) | confdata.c (7cf3d73b4360e91b14326632ab1aeda4cb26308d) |
---|---|
1/* 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 3 * Released under the terms of the GNU GPL v2.0. 4 */ 5 6#include <sys/stat.h> 7#include <ctype.h> 8#include <fcntl.h> --- 443 unchanged lines hidden (view full) --- 452 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 453 break; 454 case S_OTHER: 455 case S_UNKNOWN: 456 break; 457 } 458} 459 | 1/* 2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 3 * Released under the terms of the GNU GPL v2.0. 4 */ 5 6#include <sys/stat.h> 7#include <ctype.h> 8#include <fcntl.h> --- 443 unchanged lines hidden (view full) --- 452 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 453 break; 454 case S_OTHER: 455 case S_UNKNOWN: 456 break; 457 } 458} 459 |
460/* 461 * Write out a minimal config. 462 * All values that has default values are skipped as this is redundant. 463 */ 464int conf_write_defconfig(const char *filename) 465{ 466 struct symbol *sym; 467 struct menu *menu; 468 FILE *out; 469 470 out = fopen(filename, "w"); 471 if (!out) 472 return 1; 473 474 sym_clear_all_valid(); 475 476 /* Traverse all menus to find all relevant symbols */ 477 menu = rootmenu.list; 478 479 while (menu != NULL) 480 { 481 sym = menu->sym; 482 if (sym == NULL) { 483 if (!menu_is_visible(menu)) 484 goto next_menu; 485 } else if (!sym_is_choice(sym)) { 486 sym_calc_value(sym); 487 if (!(sym->flags & SYMBOL_WRITE)) 488 goto next_menu; 489 sym->flags &= ~SYMBOL_WRITE; 490 /* If we cannot change the symbol - skip */ 491 if (!sym_is_changable(sym)) 492 goto next_menu; 493 /* If symbol equals to default value - skip */ 494 if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) 495 goto next_menu; 496 497 /* 498 * If symbol is a choice value and equals to the 499 * default for a choice - skip. 500 * But only if value equal to "y". 501 */ 502 if (sym_is_choice_value(sym)) { 503 struct symbol *cs; 504 struct symbol *ds; 505 506 cs = prop_get_symbol(sym_get_choice_prop(sym)); 507 ds = sym_choice_default(cs); 508 if (sym == ds) { 509 if ((sym->type == S_BOOLEAN || 510 sym->type == S_TRISTATE) && 511 sym_get_tristate_value(sym) == yes) 512 goto next_menu; 513 } 514 } 515 conf_write_symbol(sym, sym->type, out, true); 516 } 517next_menu: 518 if (menu->list != NULL) { 519 menu = menu->list; 520 } 521 else if (menu->next != NULL) { 522 menu = menu->next; 523 } else { 524 while ((menu = menu->parent)) { 525 if (menu->next != NULL) { 526 menu = menu->next; 527 break; 528 } 529 } 530 } 531 } 532 fclose(out); 533 return 0; 534} 535 |
|
460int conf_write(const char *name) 461{ 462 FILE *out; 463 struct symbol *sym; 464 struct menu *menu; 465 const char *basename; 466 const char *str; 467 char dirname[128], tmpname[128], newname[128]; --- 468 unchanged lines hidden --- | 536int conf_write(const char *name) 537{ 538 FILE *out; 539 struct symbol *sym; 540 struct menu *menu; 541 const char *basename; 542 const char *str; 543 char dirname[128], tmpname[128], newname[128]; --- 468 unchanged lines hidden --- |