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/nanorc.sample.in: Correct the description of 'justifytrim', add
|
||||
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
|
||||
|
||||
|
|
27
src/color.c
27
src/color.c
|
@ -153,8 +153,7 @@ void nfreeregex(regex_t **r)
|
|||
void color_update(void)
|
||||
{
|
||||
syntaxtype *tmpsyntax;
|
||||
syntaxtype *defsyntax = NULL;
|
||||
colortype *tmpcolor, *defcolor = NULL;
|
||||
colortype *tmpcolor;
|
||||
regexlisttype *e;
|
||||
|
||||
assert(openfile != NULL);
|
||||
|
@ -210,15 +209,6 @@ void color_update(void)
|
|||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
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) {
|
||||
bool not_compiled = (e->ext == NULL);
|
||||
|
||||
|
@ -342,11 +332,16 @@ void color_update(void)
|
|||
#endif /* HAVE_LIBMAGIC */
|
||||
}
|
||||
|
||||
/* If we didn't find any syntax yet, and we do have a default one,
|
||||
* use it. */
|
||||
if (openfile->colorstrings == NULL && defcolor != NULL) {
|
||||
openfile->syntax = defsyntax;
|
||||
openfile->colorstrings = defcolor;
|
||||
/* If we didn't find any syntax yet, see if there is a default one. */
|
||||
if (openfile->colorstrings == NULL) {
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
if (strcmp(tmpsyntax->desc, "default") == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
|
||||
|
|
Loading…
Reference in New Issue