* This is the parser for the hilite options. * * parse_status_hl1() separates each hilite entry into * a set of field threshold/action component strings, * then calls parse_status_hl2() to parse further * and configure the hilite. */
| 2590 | * and configure the hilite. |
| 2591 | */ |
| 2592 | boolean |
| 2593 | parse_status_hl1(char *op, boolean from_configfile) |
| 2594 | { |
| 2595 | #define MAX_THRESH 21 |
| 2596 | char hsbuf[MAX_THRESH][QBUFSZ]; |
| 2597 | boolean rslt, badopt = FALSE; |
| 2598 | int i, fldnum, ccount = 0; |
| 2599 | char c; |
| 2600 | |
| 2601 | fldnum = 0; |
| 2602 | for (i = 0; i < MAX_THRESH; ++i) { |
| 2603 | hsbuf[i][0] = '\0'; |
| 2604 | } |
| 2605 | while (*op && fldnum < MAX_THRESH && ccount < (QBUFSZ - 2)) { |
| 2606 | c = lowc(*op); |
| 2607 | if (c == ' ') { |
| 2608 | if (fldnum >= 1) { |
| 2609 | if (fldnum == 1 && strcmpi(hsbuf[0], "title") == 0) { |
| 2610 | /* spaces are allowed in title */ |
| 2611 | hsbuf[fldnum][ccount++] = c; |
| 2612 | hsbuf[fldnum][ccount] = '\0'; |
| 2613 | op++; |
| 2614 | continue; |
| 2615 | } |
| 2616 | rslt = parse_status_hl2(hsbuf, from_configfile); |
| 2617 | if (!rslt) { |
| 2618 | badopt = TRUE; |
| 2619 | break; |
| 2620 | } |
| 2621 | } |
| 2622 | for (i = 0; i < MAX_THRESH; ++i) { |
| 2623 | hsbuf[i][0] = '\0'; |
| 2624 | } |
| 2625 | fldnum = 0; |
| 2626 | ccount = 0; |
| 2627 | } else if (c == '/') { |
| 2628 | fldnum++; |
| 2629 | ccount = 0; |
| 2630 | } else { |
| 2631 | hsbuf[fldnum][ccount++] = c; |
| 2632 | hsbuf[fldnum][ccount] = '\0'; |
| 2633 | } |
| 2634 | op++; |
| 2635 | } |
| 2636 | if (fldnum >= 1 && !badopt) { |
| 2637 | rslt = parse_status_hl2(hsbuf, from_configfile); |
| 2638 | if (!rslt) |
| 2639 | badopt = TRUE; |
| 2640 | } |
| 2641 | if (badopt) |
| 2642 | return FALSE; |
| 2643 | /* make sure highlighting is On; use short duration for temp highlights */ |
| 2644 | if (!iflags.hilite_delta) |
| 2645 | iflags.hilite_delta = 3L; |
| 2646 | return TRUE; |
| 2647 | #undef MAX_THRESH |
| 2648 | } |
| 2649 |
no test coverage detected