parse '"regex_string"=color&attr' and add it to menucoloring */
| 614 | |
| 615 | /* parse '"regex_string"=color&attr' and add it to menucoloring */ |
| 616 | boolean |
| 617 | add_menu_coloring(char *tmpstr) /* never Null but could be empty */ |
| 618 | { |
| 619 | int c = NO_COLOR, a = ATR_NONE; |
| 620 | char *tmps, *cs, *amp; |
| 621 | char str[BUFSZ]; |
| 622 | |
| 623 | (void) strncpy(str, tmpstr, sizeof str - 1); |
| 624 | str[sizeof str - 1] = '\0'; |
| 625 | |
| 626 | if ((cs = strchr(str, '=')) == 0) { |
| 627 | config_error_add("Malformed MENUCOLOR"); |
| 628 | return FALSE; |
| 629 | } |
| 630 | |
| 631 | tmps = cs + 1; /* advance past '=' */ |
| 632 | mungspaces(tmps); |
| 633 | if ((amp = strchr(tmps, '&')) != 0) |
| 634 | *amp = '\0'; |
| 635 | |
| 636 | c = match_str2clr(tmps, FALSE); |
| 637 | if (c >= CLR_MAX) |
| 638 | return FALSE; |
| 639 | |
| 640 | if (amp) { |
| 641 | tmps = amp + 1; /* advance past '&' */ |
| 642 | a = match_str2attr(tmps, TRUE); |
| 643 | if (a == -1) |
| 644 | return FALSE; |
| 645 | } |
| 646 | |
| 647 | /* the regexp portion here has not been condensed by mungspaces() */ |
| 648 | *cs = '\0'; |
| 649 | tmps = str; |
| 650 | if (*tmps == '"' || *tmps == '\'') { |
| 651 | cs--; |
| 652 | while (isspace((uchar) *cs)) |
| 653 | cs--; |
| 654 | if (*cs == *tmps) { |
| 655 | *cs = '\0'; |
| 656 | tmps++; |
| 657 | } |
| 658 | } |
| 659 | return add_menu_coloring_parsed(tmps, c, a); |
| 660 | } |
| 661 | |
| 662 | /* release all menu color patterns */ |
| 663 | void |
no test coverage detected