]> git.wh0rd.org Git - nano.git/commitdiff
totsize fix in do_justify
authorRobert Siemborski <rjs3@andrew.cmu.edu>
Sun, 21 Jan 2001 23:23:48 +0000 (23:23 +0000)
committerRobert Siemborski <rjs3@andrew.cmu.edu>
Sun, 21 Jan 2001 23:23:48 +0000 (23:23 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@497 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

nano.c

diff --git a/nano.c b/nano.c
index 24fd97d47c3df66f451bd0504e2b357933af76a6..66af04fa3ce5215c2f506b7b1f8ddd18d401f36a 100644 (file)
--- a/nano.c
+++ b/nano.c
@@ -1782,7 +1782,10 @@ int do_justify(void)
 
     tmptop = current;
     tmpjust = copy_node(current);
+
+    /* This is annoying because it mucks with totsize */
     add_to_cutbuffer(tmpjust);
+
     /* Put the whole paragraph into one big line. */
     while (current->next && !isspace((int) current->next->data[0])
           && current->next->data[0]) {
@@ -1794,6 +1797,9 @@ int do_justify(void)
        tmpjust = copy_node(current->next);
        add_to_cutbuffer(tmpjust);
 
+       /* Wiping out a newline */
+        totsize--;
+
        /* length of both strings plus space between strings and ending \0. */
        current->data = nrealloc(current->data, len + len2 + 2);
        current->data[len++] = ' ';
@@ -1824,12 +1830,14 @@ int do_justify(void)
                i = fill;
            else
                i = slen;
+
            for (; i > 0; i--) {
                if (isspace((int) current->data[i]) &&
                    ((strlenpt(current->data) - strlen(current->data + i))
                     <= fill))
                    break;
            }
+
            if (!i)
                break;