Looking for the default syntax only when all else failed --
foregoing a small, complicating optimization. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5684 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
a69460001e
commit
812f986f2e
|
@ -2,6 +2,8 @@
|
||||||
* doc/man/nanorc.5, doc/texinfo/nano.texi, doc/syntax/nanorc.nanorc,
|
* doc/man/nanorc.5, doc/texinfo/nano.texi, doc/syntax/nanorc.nanorc,
|
||||||
doc/nanorc.sample.in: Correct the description of 'justifytrim', add
|
doc/nanorc.sample.in: Correct the description of 'justifytrim', add
|
||||||
it to the Info document, sort it, and tweak a wording.
|
it to the Info document, sort it, and tweak a wording.
|
||||||
|
* src/color.c (color_update): Look for a default syntax only when
|
||||||
|
all else failed -- forego the small, complicating optimization.
|
||||||
|
|
||||||
GNU nano 2.5.3 - 2016.02.25
|
GNU nano 2.5.3 - 2016.02.25
|
||||||
|
|
||||||
|
|
27
src/color.c
27
src/color.c
|
@ -153,8 +153,7 @@ void nfreeregex(regex_t **r)
|
||||||
void color_update(void)
|
void color_update(void)
|
||||||
{
|
{
|
||||||
syntaxtype *tmpsyntax;
|
syntaxtype *tmpsyntax;
|
||||||
syntaxtype *defsyntax = NULL;
|
colortype *tmpcolor;
|
||||||
colortype *tmpcolor, *defcolor = NULL;
|
|
||||||
regexlisttype *e;
|
regexlisttype *e;
|
||||||
|
|
||||||
assert(openfile != NULL);
|
assert(openfile != NULL);
|
||||||
|
@ -210,15 +209,6 @@ void color_update(void)
|
||||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||||
tmpsyntax = tmpsyntax->next) {
|
tmpsyntax = tmpsyntax->next) {
|
||||||
|
|
||||||
/* If this is the default syntax, it has no associated
|
|
||||||
* extensions, which we've checked for elsewhere. Skip over
|
|
||||||
* it here, but keep track of its color regexes. */
|
|
||||||
if (strcmp(tmpsyntax->desc, "default") == 0) {
|
|
||||||
defsyntax = tmpsyntax;
|
|
||||||
defcolor = tmpsyntax->color;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
||||||
bool not_compiled = (e->ext == NULL);
|
bool not_compiled = (e->ext == NULL);
|
||||||
|
|
||||||
|
@ -342,11 +332,16 @@ void color_update(void)
|
||||||
#endif /* HAVE_LIBMAGIC */
|
#endif /* HAVE_LIBMAGIC */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we didn't find any syntax yet, and we do have a default one,
|
/* If we didn't find any syntax yet, see if there is a default one. */
|
||||||
* use it. */
|
if (openfile->colorstrings == NULL) {
|
||||||
if (openfile->colorstrings == NULL && defcolor != NULL) {
|
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||||
openfile->syntax = defsyntax;
|
tmpsyntax = tmpsyntax->next) {
|
||||||
openfile->colorstrings = defcolor;
|
if (strcmp(tmpsyntax->desc, "default") == 0) {
|
||||||
|
openfile->syntax = tmpsyntax;
|
||||||
|
openfile->colorstrings = tmpsyntax->color;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
||||||
|
|
Loading…
Reference in New Issue