MCPcopy Create free account
hub / github.com/NetHack/NetHack / add_menu_coloring

Function add_menu_coloring

src/coloratt.c:616–660  ·  view source on GitHub ↗

parse '"regex_string"=color&attr' and add it to menucoloring */

Source from the content-addressed store, hash-verified

614
615/* parse '"regex_string"=color&attr' and add it to menucoloring */
616boolean
617add_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 */
663void

Callers 1

cnf_line_MENUCOLORFunction · 0.85

Calls 6

config_error_addFunction · 0.85
mungspacesFunction · 0.85
match_str2clrFunction · 0.85
match_str2attrFunction · 0.85
isspaceFunction · 0.85
add_menu_coloring_parsedFunction · 0.85

Tested by

no test coverage detected