nano

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

commit b4fd08fa5efe3e56a3b88cab9567bfc7790113cd
parent 252dc138a2238ccb18128c49254e2b11cc2ebb30
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 15 Aug 2017 17:18:34 +0200

tweaks: keep the const qualifier of the syntax name  [coverity scan]

Also, reduce the scope of the 'line' variable.

Diffstat:
Msrc/files.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1930,9 +1930,9 @@ bool write_file(const char *name, FILE *f_open, bool tmp, /* If we must set the filename, and it changed, adjust things. */ if (!nonamechange && strcmp(openfile->filename, realname) != 0) { #ifndef DISABLE_COLOR - char *newname; - char *oldname = openfile->syntax ? openfile->syntax->name : ""; - filestruct *line = openfile->fileage; + const char *oldname, *newname; + + oldname = openfile->syntax ? openfile->syntax->name : ""; #endif openfile->filename = mallocstrcpy(openfile->filename, realname); @@ -1945,9 +1945,12 @@ bool write_file(const char *name, FILE *f_open, bool tmp, /* If the syntax changed, discard and recompute the multidata. */ if (strcmp(oldname, newname) != 0) { - for (; line != NULL; line = line->next) { + filestruct *line = openfile->fileage; + + while (line != NULL) { free(line->multidata); line->multidata = NULL; + line = line->next; } precalc_multicolorinfo(); refresh_needed = TRUE;