rcfile fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1160 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2002-03-29 19:41:57 +00:00
parent 77777d4c0d
commit 78f0fc61ff
2 changed files with 11 additions and 2 deletions

View File

@ -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).

View File

@ -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;
}