* Write out a minimal config. * All values that has default values are skipped as this is redundant. */
| 839 | * All values that has default values are skipped as this is redundant. |
| 840 | */ |
| 841 | int conf_write_defconfig(const char *filename) |
| 842 | { |
| 843 | struct symbol *sym; |
| 844 | struct menu *menu; |
| 845 | FILE *out; |
| 846 | |
| 847 | out = fopen(filename, "w"); |
| 848 | if (!out) |
| 849 | return 1; |
| 850 | |
| 851 | sym_clear_all_valid(); |
| 852 | |
| 853 | /* Traverse all menus to find all relevant symbols */ |
| 854 | menu = rootmenu.list; |
| 855 | |
| 856 | while (menu != NULL) |
| 857 | { |
| 858 | sym = menu->sym; |
| 859 | if (sym == NULL) { |
| 860 | if (!menu_is_visible(menu)) |
| 861 | goto next_menu; |
| 862 | } else if (!sym_is_choice(sym)) { |
| 863 | sym_calc_value(sym); |
| 864 | if (!(sym->flags & SYMBOL_WRITE)) |
| 865 | goto next_menu; |
| 866 | sym->flags &= ~SYMBOL_WRITE; |
| 867 | /* If we cannot change the symbol - skip */ |
| 868 | if (!sym_is_changeable(sym)) |
| 869 | goto next_menu; |
| 870 | /* If symbol equals to default value - skip */ |
| 871 | if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) |
| 872 | goto next_menu; |
| 873 | |
| 874 | /* |
| 875 | * If symbol is a choice value and equals to the |
| 876 | * default for a choice - skip. |
| 877 | * But only if value is bool and equal to "y" and |
| 878 | * choice is not "optional". |
| 879 | * (If choice is "optional" then all values can be "n") |
| 880 | */ |
| 881 | if (sym_is_choice_value(sym)) { |
| 882 | struct symbol *cs; |
| 883 | struct symbol *ds; |
| 884 | |
| 885 | cs = prop_get_symbol(sym_get_choice_prop(sym)); |
| 886 | ds = sym_choice_default(cs); |
| 887 | if (!sym_is_optional(cs) && sym == ds) { |
| 888 | if ((sym->type == S_BOOLEAN) && |
| 889 | sym_get_tristate_value(sym) == yes) |
| 890 | goto next_menu; |
| 891 | } |
| 892 | } |
| 893 | print_symbol_for_dotconfig(out, sym); |
| 894 | } |
| 895 | next_menu: |
| 896 | if (menu->list != NULL) { |
| 897 | menu = menu->list; |
| 898 | } |
no test coverage detected