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
master
Benno Schulenberg 2016-03-01 11:06:00 +00:00
parent 83975027e5
commit 3df1a3f0f4
3 changed files with 6 additions and 29 deletions

View File

@ -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> 2016-02-29 Benno Schulenberg <bensberg@justemail.net>
* src/nano.h, src/rcfile.c, src/color.c: Rename a struct member. * 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" * src/rcfile.c (parse_rcfile): Don't allocate a struct for the "none"

View File

@ -194,9 +194,6 @@ void color_update(void)
openfile->syntax = sint; openfile->syntax = sint;
openfile->colorstrings = sint->color; openfile->colorstrings = sint->color;
} }
if (openfile->colorstrings != NULL)
break;
} }
if (openfile->colorstrings == NULL) if (openfile->colorstrings == NULL)
@ -298,7 +295,6 @@ void color_update(void)
if (strcmp(sint->name, "default") == 0) { if (strcmp(sint->name, "default") == 0) {
openfile->syntax = sint; openfile->syntax = sint;
openfile->colorstrings = sint->color; openfile->colorstrings = sint->color;
break;
} }
} }
} }

View File

@ -267,7 +267,6 @@ bool nregcomp(const char *regex, int eflags)
void parse_syntax(char *ptr) void parse_syntax(char *ptr)
{ {
const char *fileregptr = NULL, *nameptr = NULL; const char *fileregptr = NULL, *nameptr = NULL;
syntaxtype *tmpsyntax, *prev_syntax;
regexlisttype *endext = NULL; regexlisttype *endext = NULL;
/* The end of the extensions list for this syntax. */ /* The end of the extensions list for this syntax. */
@ -297,30 +296,6 @@ void parse_syntax(char *ptr)
return; 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) { if (syntaxes == NULL) {
syntaxes = (syntaxtype *)nmalloc(sizeof(syntaxtype)); syntaxes = (syntaxtype *)nmalloc(sizeof(syntaxtype));
endsyntax = syntaxes; endsyntax = syntaxes;