nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 76d83070c4ab3242e388d5b6a5f7ff03afd1b4c3
parent 1194a41cdbcee478e0b4d8bf39ef99ef4c7f7eb6
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sat, 21 Jan 2017 16:50:52 +0100

tweaks: elide a variable plus its corresponding dark logic

Just assign the 'CNONE' value upfront, instead of figuring out
at the end of the line whether anything has been assigned yet.

Also, the old logic would leave unmarked a line that contains a
start match without any terminating end match.  Not serious, but
not right.

Diffstat:
Msrc/color.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/color.c b/src/color.c @@ -413,13 +413,15 @@ void precalc_multicolorinfo(void) continue; for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) { - int startx = 0, nostart = 0; + int startx = 0; int linelen = strlen(fileptr->data); alloc_multidata_if_needed(fileptr); + /* Assume nothing applies until proven otherwise below. */ + fileptr->multidata[ink->id] = CNONE; - while ((nostart = regexec(ink->start, &fileptr->data[startx], 1, - &startmatch, (startx == 0) ? 0 : REG_NOTBOL)) == 0) { + while (regexec(ink->start, &fileptr->data[startx], 1, + &startmatch, (startx == 0) ? 0 : REG_NOTBOL) == 0) { /* Look for an end, and start marking how many lines are * encompassed, which should speed up rendering later. */ startx += startmatch.rm_eo; @@ -463,11 +465,6 @@ void precalc_multicolorinfo(void) /* Skip to the end point of the match. */ startx = endmatch.rm_eo; } - - if (nostart && startx == 0) { - fileptr->multidata[ink->id] = CNONE; - continue; - } } } }