diff --git a/ChangeLog b/ChangeLog index 9a0ff9ea7d5ee1f36277760de40d3f9f3f05e238..d352e6abcf096620220221f39d6214b034881f48 100644 --- 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 index abf6e9f8a6894b73e2de6fe672ca37abedf3551f..98881ed5d3313829449e631f803397131e3c0dbc 100644 --- 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 index e0ee6bae5948ffb7d598f05f93c68f3fdf992134..342fecffe22bc0f027a3caf5b50df525bf5b163c 100644 --- 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;