From: Chris Allegretta Date: Fri, 29 Mar 2002 19:41:57 +0000 (+0000) Subject: rcfile fixes X-Git-Tag: v1.1.8~3 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=78f0fc61ff3aa9914aedbea0afdd693d8593191a;p=nano.git rcfile fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1160 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index edbcf316..4046cedc 100644 --- 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 index 9e4459f0..8531b7ce 100644 --- 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; }