rcfile: report the correct command location for an invalid 'include'

For each included file, save and restore file name and line number of
the including file, so that an error message about a faulty 'include'
command can indicate the location of this 'include'.

This fixes https://savannah.gnu.org/bugs/?56488.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
master
Brand Huntsman 2019-08-14 14:37:40 -06:00 committed by Benno Schulenberg
parent a2f7e31ba2
commit 82f5fed45a
1 changed files with 7 additions and 0 deletions

View File

@ -560,6 +560,8 @@ bool is_good_file(char *file)
/* Read and parse one included syntax file. */
void parse_one_include(char *file, syntaxtype *syntax)
{
char *was_nanorc = nanorc;
size_t was_lineno = lineno;
augmentstruct *extra;
FILE *rcstream;
@ -583,6 +585,8 @@ void parse_one_include(char *file, syntaxtype *syntax)
/* If this is the first pass, parse only the prologue. */
if (syntax == NULL) {
parse_rcfile(rcstream, TRUE, TRUE);
nanorc = was_nanorc;
lineno = was_lineno;
return;
}
@ -610,6 +614,9 @@ void parse_one_include(char *file, syntaxtype *syntax)
free(syntax->filename);
syntax->filename = NULL;
nanorc = was_nanorc;
lineno = was_lineno;
}
/* Expand globs in the passed name, and parse the resultant files. */