From a5bc70a541ba036384967d24b9495a28c792628f Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 3 Jan 2016 16:57:17 +0000 Subject: [PATCH] Aborting reset_multis() when there are zero multiline regexes. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5525 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 1 + src/color.c | 3 ++- src/nano.c | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd995521..7ac85f53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ * src/nano.c (do_output): Let reset_multis() figure out whether after an addition a full refresh is needed (for multiline-regexes' sake), instead of doing it always. + * src/color.c (reset_multis): Abort when having no multiline regexes. 2016-01-02 Benno Schulenberg * src/text.c (do_spell, do_formatter): Plug three tiny memory leaks. diff --git a/src/color.c b/src/color.c index 2508a843..dd93bd7e 100644 --- a/src/color.c +++ b/src/color.c @@ -417,7 +417,8 @@ void reset_multis(filestruct *fileptr, bool force) regmatch_t startmatch, endmatch; const colortype *tmpcolor = openfile->colorstrings; - if (!openfile->syntax) + /* If there is no syntax or no multiline regex, there is nothing to do. */ + if (openfile->syntax == NULL || openfile->syntax->nmultis == 0) return; for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) { diff --git a/src/nano.c b/src/nano.c index 43903453..20ac4ade 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1728,8 +1728,7 @@ int do_input(bool allow_funcs) /* Execute the function of the shortcut. */ s->scfunc(); #ifndef DISABLE_COLOR - if (f && !f->viewok && openfile->syntax != NULL - && openfile->syntax->nmultis > 0) + if (f && !f->viewok) reset_multis(openfile->current, FALSE); #endif if (edit_refresh_needed) { -- 2.39.5