* 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
void color_update(void)
{
syntaxtype *tmpsyntax;
- syntaxtype *defsyntax = NULL;
- colortype *tmpcolor, *defcolor = NULL;
+ colortype *tmpcolor;
regexlisttype *e;
assert(openfile != NULL);
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);
#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;