mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-02 01:17:15 +03:00
color: avoid allocating emptiness when there are no multiline regexes
When a file is saved under a different name, and as a result the applicable syntax changes, and the old syntax had multiline regexes and the new syntax doesn't, then the call of precalc_multicolorinfo() in write_file() should not result in nano setting up a multicache of zero bytes for each line in the buffer. (Problem was found by locally letting nano crash when zero bytes are allocated, and then happening to rename a file.py to a file.sh.)
This commit is contained in:
parent
b9deb883fa
commit
1bbf07b27e
@ -315,7 +315,8 @@ void precalc_multicolorinfo(void)
|
||||
regmatch_t startmatch, endmatch;
|
||||
linestruct *line, *tailline;
|
||||
|
||||
if (openfile->syntax == NULL || ISSET(NO_SYNTAX))
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0 ||
|
||||
openfile->filetop->multidata || ISSET(NO_SYNTAX))
|
||||
return;
|
||||
|
||||
/* For each line, allocate cache space for the multiline-regex info. */
|
||||
|
@ -497,12 +497,8 @@ void prepare_for_display(void)
|
||||
titlebar(NULL);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* If there are multiline coloring regexes, and there is no
|
||||
* multiline cache data yet, precalculate it now. */
|
||||
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
|
||||
openfile->filetop->multidata == NULL)
|
||||
/* Precalculate the data for any multiline coloring regexes. */
|
||||
precalc_multicolorinfo();
|
||||
|
||||
have_palette = FALSE;
|
||||
#endif
|
||||
refresh_needed = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user