From ce32cb0f6b001a772cfb23fdfe2ced33cc2d9566 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 1 Mar 2016 11:21:05 +0000 Subject: [PATCH] Allowing to select an empty syntax. And selecting the last instead of the first syntax that matches a certain magic string (forgotten in the previous commit). git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5705 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 1 + src/color.c | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d352e6ab..5700aab8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ 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. + * src/color.c (color_update): Allow to select an empty syntax. 2016-02-29 Benno Schulenberg * src/nano.h, src/rcfile.c, src/color.c: Rename a struct member. diff --git a/src/color.c b/src/color.c index 98881ed5..438ebc8d 100644 --- a/src/color.c +++ b/src/color.c @@ -196,14 +196,14 @@ void color_update(void) } } - if (openfile->colorstrings == NULL) + if (openfile->syntax == NULL) statusbar(_("Unknown syntax name: %s"), syntaxstr); } /* If we didn't specify a syntax override string, or if we did and * there was no syntax by that name, get the syntax based on the * file extension, then try the headerline, and then try magic. */ - if (openfile->colorstrings == NULL) { + if (openfile->syntax == NULL) { char *currentdir = getcwd(NULL, PATH_MAX + 1); char *joinednames = charalloc(PATH_MAX + 1); char *fullname = NULL; @@ -230,7 +230,7 @@ void color_update(void) free(fullname); /* Check the headerline if the extension didn't match anything. */ - if (openfile->colorstrings == NULL) { + if (openfile->syntax == NULL) { #ifdef DEBUG fprintf(stderr, "No result from file extension, trying headerline...\n"); #endif @@ -244,7 +244,7 @@ void color_update(void) #ifdef HAVE_LIBMAGIC /* Check magic if we don't have an answer yet. */ - if (openfile->colorstrings == NULL) { + if (openfile->syntax == NULL) { struct stat fileinfo; magic_t cookie = NULL; const char *magicstring = NULL; @@ -278,7 +278,6 @@ void color_update(void) if (found_in_list(sint->magics, magicstring)) { openfile->syntax = sint; openfile->colorstrings = sint->color; - break; } } } @@ -290,7 +289,7 @@ void color_update(void) } /* If we didn't find any syntax yet, see if there is a default one. */ - if (openfile->colorstrings == NULL) { + if (openfile->syntax == NULL) { for (sint = syntaxes; sint != NULL; sint = sint->next) { if (strcmp(sint->name, "default") == 0) { openfile->syntax = sint; -- 2.39.5