nano

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

commit ca2c808f6987a44dcca8f79862ee8ff477179f66
parent d87c357abe0cb397a958cbcae9e4de9227070d95
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Wed,  8 Jun 2016 12:56:46 +0200

files: free all the multidata when a file is saved, then recompute it

This fixes https://savannah.gnu.org/bugs/?48103.

(The fix is wasteful -- it should only discard the multidata if actually
the name *did* change, *and* if the applicable syntax changed.)

Diffstat:
Msrc/files.c | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -2123,13 +2123,22 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type if (!tmp && append == OVERWRITE) { if (!nonamechange) { + filestruct *line; + openfile->filename = mallocstrcpy(openfile->filename, realname); #ifndef DISABLE_COLOR + /* Discard all the now (possibly) obsolete multidata. */ + for (line = openfile->fileage; line != NULL; line = line->next) { + free(line->multidata); + line->multidata = NULL; + } + /* We might have changed the filename, so update the colors * to account for it, and then make sure we're using them. */ color_update(); color_init(); + precalc_multicolorinfo(); /* If color syntaxes are available and turned on, we need to * call edit_refresh(). */