nano

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

commit d8c840692e75054531709a53ef10dfaf06fe0627
parent 8c7b6bd21a12b75e901f3a5d6cd95b1614314c98
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 23 Jun 2019 12:15:19 +0200

tweaks: reshuffle an 'if' out of a function, and rename the function

Diffstat:
Msrc/color.c | 15+++++++--------
Msrc/proto.h | 2+-
Msrc/winio.c | 4++--
3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/color.c b/src/color.c @@ -295,7 +295,8 @@ void check_the_multis(linestruct *line) if (openfile->syntax == NULL || openfile->syntax->nmultis == 0) return; - alloc_multidata_if_needed(line); + if (line->multidata == NULL) + set_up_multicache(line); for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) { /* If it's not a multiline regex, skip. */ @@ -329,14 +330,12 @@ void check_the_multis(linestruct *line) } /* Allocate (for one line) the cache space for multiline color regexes. */ -void alloc_multidata_if_needed(linestruct *fileptr) +void set_up_multicache(linestruct *line) { - if (fileptr->multidata == NULL) { - fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short)); + line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short)); - for (int i = 0; i < openfile->syntax->nmultis; i++) - fileptr->multidata[i] = -1; - } + for (int index = 0; index < openfile->syntax->nmultis; index++) + line->multidata[index] = -1; } /* Precalculate the multi-line start and end regex info so we can @@ -352,7 +351,7 @@ void precalc_multicolorinfo(void) /* For each line, allocate cache space for the multiline-regex info. */ for (line = openfile->filetop; line != NULL; line = line->next) - alloc_multidata_if_needed(line); + set_up_multicache(line); for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) { /* If this is not a multi-line regex, skip it. */ diff --git a/src/proto.h b/src/proto.h @@ -243,7 +243,7 @@ void set_colorpairs(void); void color_init(void); void color_update(void); void check_the_multis(linestruct *line); -void alloc_multidata_if_needed(linestruct *fileptr); +void set_up_multicache(linestruct *line); void precalc_multicolorinfo(void); #endif diff --git a/src/winio.c b/src/winio.c @@ -2467,8 +2467,8 @@ void edit_draw(linestruct *fileptr, const char *converted, const colortype *varnish = openfile->colorstrings; /* If there are multiline regexes, make sure there is a cache. */ - if (openfile->syntax->nmultis > 0) - alloc_multidata_if_needed(fileptr); + if (openfile->syntax->nmultis > 0 && fileptr->multidata == NULL) + set_up_multicache(fileptr); /* Iterate through all the coloring regexes. */ for (; varnish != NULL; varnish = varnish->next) {