help: don't fall back to other syntaxes if there is no nanohelp one

Also, an absent nanohelp syntax is not an error, so keep mum.

This fixes https://savannah.gnu.org/bugs/?52147.
master
Benno Schulenberg 2017-10-12 19:06:39 +02:00
parent d0119833c1
commit 4436815725
1 changed files with 5 additions and 5 deletions

View File

@ -172,13 +172,13 @@ void color_update(void)
break; break;
} }
if (sint == NULL) if (sint == NULL && !inhelp)
statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr); statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr);
} }
/* If no syntax-override string was specified, or it didn't match, /* If no syntax-override string was specified, or it didn't match,
* try finding a syntax based on the filename (extension). */ * try finding a syntax based on the filename (extension). */
if (sint == NULL) { if (sint == NULL && !inhelp) {
char *reserved = charalloc(PATH_MAX + 1); char *reserved = charalloc(PATH_MAX + 1);
char *currentdir = getcwd(reserved, PATH_MAX + 1); char *currentdir = getcwd(reserved, PATH_MAX + 1);
char *joinednames = charalloc(PATH_MAX + 1); char *joinednames = charalloc(PATH_MAX + 1);
@ -207,7 +207,7 @@ void color_update(void)
} }
/* If the filename didn't match anything, try the first line. */ /* If the filename didn't match anything, try the first line. */
if (sint == NULL) { if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) { for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (found_in_list(sint->headers, openfile->fileage->data)) if (found_in_list(sint->headers, openfile->fileage->data))
break; break;
@ -216,7 +216,7 @@ void color_update(void)
#ifdef HAVE_LIBMAGIC #ifdef HAVE_LIBMAGIC
/* If we still don't have an answer, try using magic. */ /* If we still don't have an answer, try using magic. */
if (sint == NULL) { if (sint == NULL && !inhelp) {
struct stat fileinfo; struct stat fileinfo;
magic_t cookie = NULL; magic_t cookie = NULL;
const char *magicstring = NULL; const char *magicstring = NULL;
@ -252,7 +252,7 @@ void color_update(void)
#endif /* HAVE_LIBMAGIC */ #endif /* HAVE_LIBMAGIC */
/* If nothing at all matched, see if there is a default syntax. */ /* If nothing at all matched, see if there is a default syntax. */
if (sint == NULL) { if (sint == NULL && !inhelp) {
for (sint = syntaxes; sint != NULL; sint = sint->next) { for (sint = syntaxes; sint != NULL; sint = sint->next) {
if (strcmp(sint->name, "default") == 0) if (strcmp(sint->name, "default") == 0)
break; break;