| 562 | } |
| 563 | |
| 564 | bool sym_string_valid(struct symbol *sym, const char *str) |
| 565 | { |
| 566 | signed char ch; |
| 567 | |
| 568 | switch (sym->type) { |
| 569 | case S_STRING: |
| 570 | return true; |
| 571 | case S_INT: |
| 572 | ch = *str++; |
| 573 | if (ch == '-') |
| 574 | ch = *str++; |
| 575 | if (!isdigit(ch)) |
| 576 | return false; |
| 577 | if (ch == '0' && *str != 0) |
| 578 | return false; |
| 579 | while ((ch = *str++)) { |
| 580 | if (!isdigit(ch)) |
| 581 | return false; |
| 582 | } |
| 583 | return true; |
| 584 | case S_HEX: |
| 585 | if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) |
| 586 | str += 2; |
| 587 | ch = *str++; |
| 588 | do { |
| 589 | if (!isxdigit(ch)) |
| 590 | return false; |
| 591 | } while ((ch = *str++)); |
| 592 | return true; |
| 593 | case S_BOOLEAN: |
| 594 | case S_TRISTATE: |
| 595 | switch (str[0]) { |
| 596 | case 'y': case 'Y': |
| 597 | case 'm': case 'M': |
| 598 | case 'n': case 'N': |
| 599 | return true; |
| 600 | } |
| 601 | return false; |
| 602 | default: |
| 603 | return false; |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | bool sym_string_within_range(struct symbol *sym, const char *str) |
| 608 | { |
no test coverage detected