| 533 | } |
| 534 | |
| 535 | bool 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 | |
| 578 | bool sym_string_within_range(struct symbol *sym, const char *str) |
| 579 | { |
no outgoing calls
no test coverage detected