]> git.wh0rd.org Git - nano.git/commitdiff
Reducing the number of indentation steps.
authorBenno Schulenberg <bensberg@justemail.net>
Tue, 12 Jan 2016 20:26:59 +0000 (20:26 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Tue, 12 Jan 2016 20:26:59 +0000 (20:26 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5554 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index 49c80ac01e34f69f1ba2e999322b1ffb5af5db6d..f75800a8e72b94df4c8423f0d1f8452fdb58e82e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
        load_poshistory): Differentiate variable name from function names.
        * src/files.c (load_poshistory): Remove a senseless iteration.
        * src/files.c (load_poshistory): Condense the reading of a line.
+       * src/files.c (load_poshistory): Reduce the indentation.
 
 GNU nano 2.5.1 - 2016.01.11
 
index b57a51f5ea858fb391ded23c2d492f1f9ac7b83e..a6da6d351f40353519709397e3e0e64a252566da 100644 (file)
@@ -3201,52 +3201,53 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
 void load_poshistory(void)
 {
     char *poshist = poshistfilename();
+    FILE *hist;
 
-    /* Assume do_rcfile() has reported a missing home directory. */
-    if (poshist != NULL) {
-       FILE *hist = fopen(poshist, "rb");
+    /* If the home directory is missing, do_rcfile() will have reported it. */
+    if (poshist == NULL)
+       return;
 
-       if (hist == NULL) {
-           if (errno != ENOENT) {
-               /* Don't save history when we quit. */
-               UNSET(POS_HISTORY);
-               history_error(N_("Error reading %s: %s"), poshist,
-                       strerror(errno));
-           }
-       } else {
-           char *line = NULL, *lineptr, *xptr;
-           size_t buf_len = 0;
-           ssize_t read;
-           poshiststruct *record_ptr = NULL, *newrecord;
-
-           /* Read and parse each line, and store the extracted data. */
-           while ((read = getline(&line, &buf_len, hist)) > 2) {
-               if (line[read - 1] == '\n')
-                   line[--read] = '\0';
-               unsunder(line, read);
-
-               lineptr = parse_next_word(line);
-               xptr = parse_next_word(lineptr);
-
-               /* Create a new position record. */
-               newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
-               newrecord->filename = mallocstrcpy(NULL, line);
-               newrecord->lineno = atoi(lineptr);
-               newrecord->xno = atoi(xptr);
-               newrecord->next = NULL;
-
-               /* Add the record to the list. */
-               if (position_history == NULL)
-                   position_history = newrecord;
-               else
-                   record_ptr->next = newrecord;
+    hist = fopen(poshist, "rb");
 
-               record_ptr = newrecord;
-           }
-           fclose(hist);
-           free(line);
+    if (hist == NULL) {
+       if (errno != ENOENT) {
+       /* When reading failed, don't save history when we quit. */
+           UNSET(POS_HISTORY);
+           history_error(N_("Error reading %s: %s"), poshist, strerror(errno));
        }
-       free(poshist);
+    } else {
+       char *line = NULL, *lineptr, *xptr;
+       size_t buf_len = 0;
+       ssize_t read;
+       poshiststruct *record_ptr = NULL, *newrecord;
+
+       /* Read and parse each line, and store the extracted data. */
+       while ((read = getline(&line, &buf_len, hist)) > 2) {
+           if (line[read - 1] == '\n')
+               line[--read] = '\0';
+           unsunder(line, read);
+
+           lineptr = parse_next_word(line);
+           xptr = parse_next_word(lineptr);
+
+           /* Create a new position record. */
+           newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
+           newrecord->filename = mallocstrcpy(NULL, line);
+           newrecord->lineno = atoi(lineptr);
+           newrecord->xno = atoi(xptr);
+           newrecord->next = NULL;
+
+           /* Add the record to the list. */
+           if (position_history == NULL)
+               position_history = newrecord;
+           else
+               record_ptr->next = newrecord;
+
+           record_ptr = newrecord;
+       }
+       fclose(hist);
+       free(line);
     }
+    free(poshist);
 }
 #endif /* !DISABLE_HISTORIES */