From ecf3cd724417d01429d2a7f021739caf0e7f0062 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 13 Jan 2016 20:08:36 +0000 Subject: [PATCH] Reducing the number of indentation steps elsewhere too. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5555 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 3 +++ src/files.c | 39 ++++++++++++++++++--------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index f75800a8..6e9ece41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2016-01-13 Benno Schulenberg + * src/files.c (save_poshistory): Reduce the indentation. + 2016-01-12 Benno Schulenberg * NEWS: Fix some typos and whitespace, and normalize the dates. * src/files.c (load_poshistory): Rename a variable. diff --git a/src/files.c b/src/files.c index a6da6d35..a5c5ed0f 100644 --- a/src/files.c +++ b/src/files.c @@ -3107,36 +3107,33 @@ void save_history(void) /* Save the recorded last file positions to ~/.nano/filepos_history. */ void save_poshistory(void) { - char *poshist; + char *poshist = poshistfilename(); char *statusstr = NULL; poshiststruct *posptr; + FILE *hist; - poshist = poshistfilename(); + if (poshist == NULL) + return; - if (poshist != NULL) { - FILE *hist = fopen(poshist, "wb"); + hist = fopen(poshist, "wb"); - if (hist == NULL) - fprintf(stderr, _("Error writing %s: %s\n"), poshist, - strerror(errno)); - else { - /* Make sure no one else can read from or write to the - * history file. */ - chmod(poshist, S_IRUSR | S_IWUSR); + if (hist == NULL) + fprintf(stderr, _("Error writing %s: %s\n"), poshist, strerror(errno)); + else { + /* Don't allow others to read or write the history file. */ + chmod(poshist, S_IRUSR | S_IWUSR); - for (posptr = position_history; posptr != NULL; posptr = posptr->next) { - statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4); - sprintf(statusstr, "%s %ld %ld\n", posptr->filename, (long)posptr->lineno, + for (posptr = position_history; posptr != NULL; posptr = posptr->next) { + statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4); + sprintf(statusstr, "%s %ld %ld\n", posptr->filename, (long)posptr->lineno, (long)posptr->xno); - if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr)) - fprintf(stderr, _("Error writing %s: %s\n"), poshist, - strerror(errno)); - free(statusstr); - } - fclose(hist); + if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr)) + fprintf(stderr, _("Error writing %s: %s\n"), poshist, strerror(errno)); + free(statusstr); } - free(poshist); + fclose(hist); } + free(poshist); } /* Update the recorded last file positions, given a filename, a line -- 2.39.5