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

Function sym_string_within_range

scripts/config/symbol.c:578–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

576}
577
578bool sym_string_within_range(struct symbol *sym, const char *str)
579{
580 struct property *prop;
581 long long val;
582
583 switch (sym->type) {
584 case S_STRING:
585 return sym_string_valid(sym, str);
586 case S_INT:
587 if (!sym_string_valid(sym, str))
588 return false;
589 prop = sym_get_range_prop(sym);
590 if (!prop)
591 return true;
592 val = strtoll(str, NULL, 10);
593 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
594 val <= sym_get_range_val(prop->expr->right.sym, 10);
595 case S_HEX:
596 if (!sym_string_valid(sym, str))
597 return false;
598 prop = sym_get_range_prop(sym);
599 if (!prop)
600 return true;
601 val = strtoll(str, NULL, 16);
602 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
603 val <= sym_get_range_val(prop->expr->right.sym, 16);
604 case S_BOOLEAN:
605 case S_TRISTATE:
606 switch (str[0]) {
607 case 'y': case 'Y':
608 return sym_tristate_within_range(sym, yes);
609 case 'm': case 'M':
610 return sym_tristate_within_range(sym, mod);
611 case 'n': case 'N':
612 return sym_tristate_within_range(sym, no);
613 }
614 return false;
615 default:
616 return false;
617 }
618}
619
620bool sym_set_string_value(struct symbol *sym, const char *newval)
621{

Callers 2

sym_set_string_valueFunction · 0.85
conf_readFunction · 0.85

Calls 4

sym_string_validFunction · 0.85
sym_get_range_propFunction · 0.85
sym_get_range_valFunction · 0.85

Tested by

no test coverage detected