in parse_syntax(), don't generate an error if we find a duplicate syntax
name, since we might be trying to override a syntax in the global nanorc with one in our local nanorc; instead, free any duplicate syntaxes we find, so that we always use the last syntax with a given name git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3382 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
8f6fb3c6b6
Коммит
39b7189a13
@ -67,6 +67,11 @@ CVS code -
|
|||||||
parse_syntax()
|
parse_syntax()
|
||||||
- Properly generate an error if we've read in a previous syntax
|
- Properly generate an error if we've read in a previous syntax
|
||||||
without any associated color commands. (DLR)
|
without any associated color commands. (DLR)
|
||||||
|
- Don't generate an error if we find a duplicate syntax name,
|
||||||
|
since we might be trying to override a syntax in the global
|
||||||
|
nanorc with one in our local nanorc. Instead, free any
|
||||||
|
duplicate syntaxes we find, so that we always use the last
|
||||||
|
syntax with a given name. (DLR)
|
||||||
parse_colors()
|
parse_colors()
|
||||||
- Check for a color command's not following a syntax line before
|
- Check for a color command's not following a syntax line before
|
||||||
anything else. (DLR)
|
anything else. (DLR)
|
||||||
|
11
src/rcfile.c
11
src/rcfile.c
@ -276,7 +276,7 @@ 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;
|
||||||
const syntaxtype *tmpsyntax;
|
syntaxtype *tmpsyntax;
|
||||||
exttype *endext = NULL;
|
exttype *endext = NULL;
|
||||||
/* The end of the extensions list for this syntax. */
|
/* The end of the extensions list for this syntax. */
|
||||||
|
|
||||||
@ -306,11 +306,16 @@ void parse_syntax(char *ptr)
|
|||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
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. */
|
||||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||||
tmpsyntax = tmpsyntax->next) {
|
tmpsyntax = tmpsyntax->next) {
|
||||||
if (strcmp(nameptr, tmpsyntax->desc) == 0) {
|
if (strcmp(nameptr, tmpsyntax->desc) == 0) {
|
||||||
rcfile_error(N_("Duplicate syntax name %s"), nameptr);
|
syntaxtype *prev_syntax = tmpsyntax;
|
||||||
return;
|
|
||||||
|
tmpsyntax = tmpsyntax->next;
|
||||||
|
free(prev_syntax);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user