commit 78f0fc61ff3aa9914aedbea0afdd693d8593191a
parent 77777d4c0d497b2cac51825425cf444e10d5ade5
Author: Chris Allegretta <chrisa@asty.org>
Date: Fri, 29 Mar 2002 19:41:57 +0000
rcfile fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1160 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -40,9 +40,15 @@ CVS code -
- proto.h:
- Missing externs (Rocco).
- rcfile.c:
+ do_rcfile()
+ - Reset lineno between system and local .nanorc file.
+ - Fix errno->strerror(errno) mismatch.
parse_rcfile()
- Don't use i for both for loop and atoi(), fixes lots of
potential crashes, 1st reported by Jean-Philippe Guérard.
+ rcfile_error()
+ - Don't print out the file name if we haven't opened the file
+ yet (lineno == 0).
- search.c:
search_init()
- Fix a missing free (Rocco).
diff --git a/rcfile.c b/rcfile.c
@@ -77,7 +77,9 @@ void rcfile_error(char *msg, ...)
va_list ap;
fprintf(stderr, "\n");
- fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
+ if (lineno > 0)
+ fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
+
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
@@ -464,12 +466,13 @@ void do_rcfile(void)
nanorc = charalloc(strlen(getenv("HOME")) + 10);
sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
+ lineno = 0;
if (stat(nanorc, &fileinfo) == -1) {
/* Abort if the file doesn't exist and there's some other kind
of error stat()ing it */
if (errno != ENOENT)
- rcfile_error(unable, errno);
+ rcfile_error(unable, strerror(errno));
return;
}