tweaks: rename six symbols, to be more straightforward

master
Benno Schulenberg 2021-01-28 16:11:57 +01:00
parent 85cc99a2a3
commit 3ea2694d9c
3 changed files with 37 additions and 37 deletions

View File

@ -266,17 +266,17 @@ void check_the_multis(linestruct *line)
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
/* Check whether the multidata still matches the current situation. */
if (line->multidata[ink->id] == CNONE ||
line->multidata[ink->id] == CWHOLELINE) {
if (line->multidata[ink->id] == NOTHING ||
line->multidata[ink->id] == WHOLELINE) {
if (!astart && !anend)
continue;
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
} else if (line->multidata[ink->id] == JUSTONTHIS) {
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
continue;
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
} else if (line->multidata[ink->id] == ENDSHERE) {
if (!astart && anend)
continue;
} else if (line->multidata[ink->id] == CENDAFTER) {
} else if (line->multidata[ink->id] == STARTSHERE) {
if (astart && !anend)
continue;
}
@ -318,13 +318,13 @@ void precalc_multicolorinfo(void)
int index = 0;
/* For an unpaired start match, mark each remaining line. */
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
line->multidata[ink->id] = CWOULDBE;
if (line->prev && line->prev->multidata[ink->id] == WOULDBE) {
line->multidata[ink->id] = WOULDBE;
continue;
}
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = CNONE;
line->multidata[ink->id] = NOTHING;
/* When the line contains a start match, look for an end,
* and if found, mark all the lines that are affected. */
@ -337,7 +337,7 @@ void precalc_multicolorinfo(void)
* but continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1,
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = CSTARTENDHERE;
line->multidata[ink->id] = JUSTONTHIS;
index += endmatch.rm_eo;
/* If both start and end are mere anchors, step ahead. */
if (startmatch.rm_so == startmatch.rm_eo &&
@ -358,18 +358,18 @@ void precalc_multicolorinfo(void)
tailline = tailline->next;
if (tailline == NULL) {
line->multidata[ink->id] = CWOULDBE;
line->multidata[ink->id] = WOULDBE;
break;
}
/* We found it, we found it, la lala lala. Mark the lines. */
line->multidata[ink->id] = CENDAFTER;
line->multidata[ink->id] = STARTSHERE;
// Note that this also advances the line in the main loop.
for (line = line->next; line != tailline; line = line->next)
line->multidata[ink->id] = CWHOLELINE;
line->multidata[ink->id] = WHOLELINE;
tailline->multidata[ink->id] = CBEGINBEFORE;
tailline->multidata[ink->id] = ENDSHERE;
/* Look for a possible new start after the end match. */
index = endmatch.rm_eo;

View File

@ -138,17 +138,17 @@
#define BAD_COLOR -2
/* Flags for indicating how a multiline regex pair apply to a line. */
#define CNONE (1<<1)
#define NOTHING (1<<1)
/* The start/end regexes don't cover this line at all. */
#define CBEGINBEFORE (1<<2)
/* The start regex matches on an earlier line, the end regex on this one. */
#define CENDAFTER (1<<3)
#define STARTSHERE (1<<2)
/* The start regex matches on this line, the end regex on a later one. */
#define CWHOLELINE (1<<4)
#define WHOLELINE (1<<3)
/* The start regex matches on an earlier line, the end regex on a later one. */
#define CSTARTENDHERE (1<<5)
#define ENDSHERE (1<<4)
/* The start regex matches on an earlier line, the end regex on this one. */
#define JUSTONTHIS (1<<5)
/* Both the start and end regexes match within this line. */
#define CWOULDBE (1<<6)
#define WOULDBE (1<<6)
/* An unpaired start match is on or before this line. */
#endif

View File

@ -2553,18 +2553,18 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
/* Second case: varnish is a multiline expression. */
/* Assume nothing gets painted until proven otherwise below. */
line->multidata[varnish->id] = CNONE;
line->multidata[varnish->id] = NOTHING;
/* Apart from the first row, check the multidata of the preceding line:
* it tells us about the situation so far, and thus what to do here. */
if (row > 0 && start_line != NULL && start_line->multidata != NULL) {
if (start_line->multidata[varnish->id] == CWHOLELINE ||
start_line->multidata[varnish->id] == CENDAFTER ||
start_line->multidata[varnish->id] == CWOULDBE)
if (start_line->multidata[varnish->id] == WHOLELINE ||
start_line->multidata[varnish->id] == STARTSHERE ||
start_line->multidata[varnish->id] == WOULDBE)
goto seek_an_end;
if (start_line->multidata[varnish->id] == CNONE ||
start_line->multidata[varnish->id] == CBEGINBEFORE ||
start_line->multidata[varnish->id] == CSTARTENDHERE)
if (start_line->multidata[varnish->id] == NOTHING ||
start_line->multidata[varnish->id] == ENDSHERE ||
start_line->multidata[varnish->id] == JUSTONTHIS)
goto step_two;
}
@ -2588,8 +2588,8 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
/* If the start has been qualified as an end earlier, believe it. */
if (start_line->multidata != NULL &&
(start_line->multidata[varnish->id] == CBEGINBEFORE ||
start_line->multidata[varnish->id] == CSTARTENDHERE))
(start_line->multidata[varnish->id] == ENDSHERE ||
start_line->multidata[varnish->id] == JUSTONTHIS))
goto step_two;
/* Maybe there is an end on that same line? If yes, maybe
@ -2629,14 +2629,14 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
/* If there is no end, there is nothing to paint. */
if (end_line == NULL) {
line->multidata[varnish->id] = CWOULDBE;
line->multidata[varnish->id] = WOULDBE;
continue;
}
/* If it was already determined that there is no end... */
if (end_line != line && line->prev == start_line && line->prev->multidata &&
line->prev->multidata[varnish->id] == CWOULDBE) {
line->multidata[varnish->id] = CWOULDBE;
line->prev->multidata[varnish->id] == WOULDBE) {
line->multidata[varnish->id] = WOULDBE;
continue;
}
@ -2645,7 +2645,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
wattron(edit, varnish->attributes);
mvwaddnstr(edit, row, margin, converted, -1);
wattroff(edit, varnish->attributes);
line->multidata[varnish->id] = CWHOLELINE;
line->multidata[varnish->id] = WHOLELINE;
continue;
}
@ -2657,7 +2657,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
mvwaddnstr(edit, row, margin, converted, paintlen);
wattroff(edit, varnish->attributes);
}
line->multidata[varnish->id] = CBEGINBEFORE;
line->multidata[varnish->id] = ENDSHERE;
step_two:
/* Second step: look for starts on this line, but begin
@ -2694,7 +2694,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
thetext, paintlen);
wattroff(edit, varnish->attributes);
line->multidata[varnish->id] = CSTARTENDHERE;
line->multidata[varnish->id] = JUSTONTHIS;
}
index = endmatch.rm_eo;
/* If both start and end match are anchors, advance. */
@ -2716,7 +2716,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
/* If there is no end, we're done with this regex. */
if (end_line == NULL) {
line->multidata[varnish->id] = CWOULDBE;
line->multidata[varnish->id] = WOULDBE;
break;
}
@ -2724,7 +2724,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
wattron(edit, varnish->attributes);
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
wattroff(edit, varnish->attributes);
line->multidata[varnish->id] = CENDAFTER;
line->multidata[varnish->id] = STARTSHERE;
break;
}
}