MCPcopy Create free account
hub / github.com/Entware/Entware / sym_get_string_default

Function sym_get_string_default

scripts/config/symbol.c:676–744  ·  view source on GitHub ↗

* Find the default value associated to a symbol. * For tristate symbol handle the modules=n case * in which case "m" becomes "y". * If the symbol does not have any default then fallback * to the fixed default values. */

Source from the content-addressed store, hash-verified

674 * to the fixed default values.
675 */
676const char *sym_get_string_default(struct symbol *sym)
677{
678 struct property *prop;
679 struct symbol *ds;
680 const char *str;
681 tristate val;
682
683 sym_calc_visibility(sym);
684 sym_calc_value(modules_sym);
685 val = symbol_no.curr.tri;
686 str = symbol_empty.curr.val;
687
688 /* If symbol has a default value look it up */
689 prop = sym_get_default_prop(sym);
690 if (prop != NULL) {
691 switch (sym->type) {
692 case S_BOOLEAN:
693 case S_TRISTATE:
694 /* The visibility may limit the value from yes => mod */
695 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
696 break;
697 default:
698 /*
699 * The following fails to handle the situation
700 * where a default value is further limited by
701 * the valid range.
702 */
703 ds = prop_get_symbol(prop);
704 if (ds != NULL) {
705 sym_calc_value(ds);
706 str = (const char *)ds->curr.val;
707 }
708 }
709 }
710
711 /* Handle select statements */
712 val = EXPR_OR(val, sym->rev_dep.tri);
713
714 /* transpose mod to yes if modules are not enabled */
715 if (val == mod)
716 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
717 val = yes;
718
719 /* transpose mod to yes if type is bool */
720 if (sym->type == S_BOOLEAN && val == mod)
721 val = yes;
722
723 /* adjust the default value if this symbol is implied by another */
724 if (val < sym->implied.tri)
725 val = sym->implied.tri;
726
727 switch (sym->type) {
728 case S_BOOLEAN:
729 case S_TRISTATE:
730 switch (val) {
731 case no: return "n";
732 case mod: return "m";
733 case yes: return "y";

Callers 1

conf_write_defconfigFunction · 0.85

Calls 6

sym_calc_visibilityFunction · 0.85
sym_calc_valueFunction · 0.85
sym_get_default_propFunction · 0.85
expr_calc_valueFunction · 0.85
prop_get_symbolFunction · 0.85
sym_is_choice_valueFunction · 0.85

Tested by

no test coverage detected