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

Function sym_string_valid

scripts/config/symbol.c:535–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

533}
534
535bool sym_string_valid(struct symbol *sym, const char *str)
536{
537 signed char ch;
538
539 switch (sym->type) {
540 case S_STRING:
541 return true;
542 case S_INT:
543 ch = *str++;
544 if (ch == '-')
545 ch = *str++;
546 if (!isdigit(ch))
547 return false;
548 if (ch == '0' && *str != 0)
549 return false;
550 while ((ch = *str++)) {
551 if (!isdigit(ch))
552 return false;
553 }
554 return true;
555 case S_HEX:
556 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
557 str += 2;
558 ch = *str++;
559 do {
560 if (!isxdigit(ch))
561 return false;
562 } while ((ch = *str++));
563 return true;
564 case S_BOOLEAN:
565 case S_TRISTATE:
566 switch (str[0]) {
567 case 'y': case 'Y':
568 case 'm': case 'M':
569 case 'n': case 'N':
570 return true;
571 }
572 return false;
573 default:
574 return false;
575 }
576}
577
578bool sym_string_within_range(struct symbol *sym, const char *str)
579{

Callers 3

sym_string_within_rangeFunction · 0.85
conf_set_sym_valFunction · 0.85
menu_validate_numberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected