]> git.wh0rd.org Git - nano.git/commitdiff
Condensing the preparsing of a line.
authorBenno Schulenberg <bensberg@justemail.net>
Tue, 12 Jan 2016 20:17:05 +0000 (20:17 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Tue, 12 Jan 2016 20:17:05 +0000 (20:17 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5553 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index cd1696197fac752e3a86a80b5e89b5ee502c5762..49c80ac01e34f69f1ba2e999322b1ffb5af5db6d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
        * src/files.c (save_poshistory, update_poshistory, check_poshistory,
        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.
 
 GNU nano 2.5.1 - 2016.01.11
 
index f494a38e5047106cf4af9a8ab6ab6588ce09c235..b57a51f5ea858fb391ded23c2d492f1f9ac7b83e 100644 (file)
@@ -3220,13 +3220,11 @@ void load_poshistory(void)
            poshiststruct *record_ptr = NULL, *newrecord;
 
            /* Read and parse each line, and store the extracted data. */
-           while ((read = getline(&line, &buf_len, hist)) >= 0) {
-               if (read > 0 && line[read - 1] == '\n') {
-                   read--;
-                   line[read] = '\0';
-               }
-               if (read > 0)
-                   unsunder(line, read);
+           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);