nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 82f5fed45a4159e2ac46fe6249e7367be9d18127
parent a2f7e31ba22313b794f6b357508d1e5084a767f1
Author: Brand Huntsman <alpha@qzx.com>
Date:   Wed, 14 Aug 2019 14:37:40 -0600

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>

Diffstat:
Msrc/rcfile.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -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. */