check for " [ anything-except-bracket-or-empty ] # arbitrary-comment" with spaces optional; returns pointer to "anything-except..." (with trailing " ] #..." stripped) if ok, otherwise Null */
| 520 | with spaces optional; returns pointer to "anything-except..." (with |
| 521 | trailing " ] #..." stripped) if ok, otherwise Null */ |
| 522 | staticfn char * |
| 523 | is_config_section( |
| 524 | char *str) /* trailing spaces are stripped, ']' too iff result is good */ |
| 525 | { |
| 526 | char *a, *c, *z; |
| 527 | |
| 528 | /* remove any spaces at start and end; won't significantly interfere |
| 529 | with echoing the string in a config error message, if warranted */ |
| 530 | a = trimspaces(str); |
| 531 | /* first character should be open square bracket; set pointer past it */ |
| 532 | if (*a++ != '[') |
| 533 | return (char *) 0; |
| 534 | /* last character should be close bracket, ignoring any comment */ |
| 535 | z = strchr(a, ']'); |
| 536 | if (!z) |
| 537 | return (char *) 0; |
| 538 | /* comment, if present, can be preceded by spaces */ |
| 539 | for (c = z + 1; *c == ' '; ++c) |
| 540 | continue; |
| 541 | if (*c && *c != '#') |
| 542 | return (char *) 0; |
| 543 | /* we now know that result is good; there won't be a config error |
| 544 | message so we can modify the input string */ |
| 545 | *z = '\0'; |
| 546 | /* 'a' points past '[' and the string ends where ']' was; remove any |
| 547 | spaces between '[' and choice-start and between choice-end and ']' */ |
| 548 | return trimspaces(a); |
| 549 | } |
| 550 | |
| 551 | staticfn boolean |
| 552 | handle_config_section(char *buf) |
no test coverage detected