Commit 78f0fc61 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

rcfile fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1160 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 77777d4c
Showing with 11 additions and 2 deletions
+11 -2
......@@ -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 Gurard.
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).
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment