From 8257bf145e50c03d528adf32692c15d6e5011677 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Wed, 11 Feb 2009 05:45:57 +0000 Subject: [PATCH] 2009-02-11 Chris Allegretta * nanorc.c (parse_include): Do call real_dir_from_tilde() on included files in .nanorc, but still avoiding bug #25297. Fixes ~ and ~user specifications for nanorc include files, as reported by Eitan Adler. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4375 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/rcfile.c | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1628c2a0..41b0eb80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-02-11 Chris Allegretta + * nanorc.c (parse_include): Do call real_dir_from_tilde() on included + files in .nanorc, but still avoiding bug #25297. Fixes ~ and ~user + specifications for nanorc include files, as reported by Eitan Adler. + 2009-02-09 Chris Allegretta * New option -q, --quiet, rcfile option "quiet" implemented. Skips printing errors about the rcfile and asking user to press enter. Also, nano should diff --git a/src/rcfile.c b/src/rcfile.c index dd4c059e..4704e85e 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -474,7 +474,7 @@ void parse_include(char *ptr) { struct stat rcinfo; FILE *rcstream; - char *option, *nanorc_save = nanorc; + char *option, *nanorc_save = nanorc, *expanded; size_t lineno_save = lineno; option = ptr; @@ -495,20 +495,22 @@ void parse_include(char *ptr) } } + expanded = real_dir_from_tilde(option); + /* Open the new syntax file. */ - if ((rcstream = fopen(option, "rb")) == NULL) { - rcfile_error(_("Error reading %s: %s"), option, + if ((rcstream = fopen(expanded, "rb")) == NULL) { + rcfile_error(_("Error reading %s: %s"), expanded, strerror(errno)); return; } /* Use the name and line number position of the new syntax file * while parsing it, so we can know where any errors in it are. */ - nanorc = option; + nanorc = expanded; lineno = 0; #ifdef DEBUG - fprintf(stderr, "Parsing file \"%s\"\n", option); + fprintf(stderr, "Parsing file \"%s\" (expanded from \"%s\")\n", expanded, option); #endif parse_rcfile(rcstream -- 2.39.5