tweaks: improve four comments, and condense two fragments of code
parent
d675a549de
commit
42fde1cbc6
24
src/rcfile.c
24
src/rcfile.c
|
@ -1053,6 +1053,7 @@ void parse_rule(char *ptr, int rex_flags)
|
||||||
|
|
||||||
names = ptr;
|
names = ptr;
|
||||||
ptr = parse_next_word(ptr);
|
ptr = parse_next_word(ptr);
|
||||||
|
|
||||||
if (!parse_combination(names, &fg, &bg, &attributes))
|
if (!parse_combination(names, &fg, &bg, &attributes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1065,9 +1066,9 @@ void parse_rule(char *ptr, int rex_flags)
|
||||||
regex_t *start_rgx = NULL, *end_rgx = NULL;
|
regex_t *start_rgx = NULL, *end_rgx = NULL;
|
||||||
/* Intermediate storage for compiled regular expressions. */
|
/* Intermediate storage for compiled regular expressions. */
|
||||||
colortype *newcolor = NULL;
|
colortype *newcolor = NULL;
|
||||||
/* Container for a regex (or regex pair) and the color it paints. */
|
/* Container for compiled regex (pair) and the color it paints. */
|
||||||
bool expectend = FALSE;
|
bool expectend = FALSE;
|
||||||
/* Whether to expect an end= expression. */
|
/* Whether it is a start=/end= regex pair. */
|
||||||
|
|
||||||
if (strncmp(ptr, "start=", 6) == 0) {
|
if (strncmp(ptr, "start=", 6) == 0) {
|
||||||
ptr += 6;
|
ptr += 6;
|
||||||
|
@ -1077,11 +1078,8 @@ void parse_rule(char *ptr, int rex_flags)
|
||||||
regexstring = ++ptr;
|
regexstring = ++ptr;
|
||||||
ptr = parse_next_regex(ptr);
|
ptr = parse_next_regex(ptr);
|
||||||
|
|
||||||
if (ptr == NULL)
|
/* When there is no regex, or it is invalid, skip this line. */
|
||||||
return;
|
if (ptr == NULL || !compile(regexstring, rex_flags, &start_rgx))
|
||||||
|
|
||||||
/* When the regex is invalid, abandon the rule. */
|
|
||||||
if (!compile(regexstring, rex_flags, &start_rgx))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (expectend) {
|
if (expectend) {
|
||||||
|
@ -1103,6 +1101,7 @@ void parse_rule(char *ptr, int rex_flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate a rule, fill in the data, and link it into the list. */
|
||||||
newcolor = (colortype *)nmalloc(sizeof(colortype));
|
newcolor = (colortype *)nmalloc(sizeof(colortype));
|
||||||
|
|
||||||
newcolor->start = start_rgx;
|
newcolor->start = start_rgx;
|
||||||
|
@ -1120,12 +1119,11 @@ void parse_rule(char *ptr, int rex_flags)
|
||||||
newcolor->next = NULL;
|
newcolor->next = NULL;
|
||||||
lastcolor = newcolor;
|
lastcolor = newcolor;
|
||||||
|
|
||||||
if (!expectend)
|
/* For a multiline rule, give it a number and increase the count. */
|
||||||
continue;
|
if (expectend) {
|
||||||
|
newcolor->id = live_syntax->nmultis;
|
||||||
/* Lame way to skip another static counter. */
|
live_syntax->nmultis++;
|
||||||
newcolor->id = live_syntax->nmultis;
|
}
|
||||||
live_syntax->nmultis++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue