commit 3df1a3f0f4c9355abf8ad642be05e3568ed500ac
parent 83975027e5a9d2e2c9916b92c239e4f9e76fa53d
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 1 Mar 2016 11:06:00 +0000
Not bothering to discard a duplicate syntax -- selecting simply the
last-defined one. This addresses Savannah bug #47303.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5704 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,9 @@
+2016-03-01 Benno Schulenberg <bensberg@justemail.net>
+ * src/rcfile.c (parse_syntax), src/color.c (color_update): Don't
+ bother discarding a duplicate syntax (it's too rare, saves little
+ memory, and freeing it properly would cost even more code), just
+ select the last-defined one. This addresses Savannah bug #47303.
+
2016-02-29 Benno Schulenberg <bensberg@justemail.net>
* src/nano.h, src/rcfile.c, src/color.c: Rename a struct member.
* src/rcfile.c (parse_rcfile): Don't allocate a struct for the "none"
diff --git a/src/color.c b/src/color.c
@@ -194,9 +194,6 @@ void color_update(void)
openfile->syntax = sint;
openfile->colorstrings = sint->color;
}
-
- if (openfile->colorstrings != NULL)
- break;
}
if (openfile->colorstrings == NULL)
@@ -298,7 +295,6 @@ void color_update(void)
if (strcmp(sint->name, "default") == 0) {
openfile->syntax = sint;
openfile->colorstrings = sint->color;
- break;
}
}
}
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -267,7 +267,6 @@ bool nregcomp(const char *regex, int eflags)
void parse_syntax(char *ptr)
{
const char *fileregptr = NULL, *nameptr = NULL;
- syntaxtype *tmpsyntax, *prev_syntax;
regexlisttype *endext = NULL;
/* The end of the extensions list for this syntax. */
@@ -297,30 +296,6 @@ void parse_syntax(char *ptr)
return;
}
- /* Search for a duplicate syntax name. If we find one, free it, so
- * that we always use the last syntax with a given name. */
- prev_syntax = NULL;
- for (tmpsyntax = syntaxes; tmpsyntax != NULL;
- tmpsyntax = tmpsyntax->next) {
- if (strcmp(nameptr, tmpsyntax->name) == 0) {
- syntaxtype *old_syntax = tmpsyntax;
-
- if (endsyntax == tmpsyntax)
- endsyntax = prev_syntax;
-
- tmpsyntax = tmpsyntax->next;
- if (prev_syntax != NULL)
- prev_syntax->next = tmpsyntax;
- else
- syntaxes = tmpsyntax;
-
- free(old_syntax->name);
- free(old_syntax);
- break;
- }
- prev_syntax = tmpsyntax;
- }
-
if (syntaxes == NULL) {
syntaxes = (syntaxtype *)nmalloc(sizeof(syntaxtype));
endsyntax = syntaxes;