Commit 60cd6aa0 authored by Robert Siemborski's avatar Robert Siemborski
Browse files

totsize fix in do_justify

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@497 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 8 additions and 0 deletions
+8 -0
...@@ -1782,7 +1782,10 @@ int do_justify(void) ...@@ -1782,7 +1782,10 @@ int do_justify(void)
tmptop = current; tmptop = current;
tmpjust = copy_node(current); tmpjust = copy_node(current);
/* This is annoying because it mucks with totsize */
add_to_cutbuffer(tmpjust); add_to_cutbuffer(tmpjust);
/* Put the whole paragraph into one big line. */ /* Put the whole paragraph into one big line. */
while (current->next && !isspace((int) current->next->data[0]) while (current->next && !isspace((int) current->next->data[0])
&& current->next->data[0]) { && current->next->data[0]) {
...@@ -1794,6 +1797,9 @@ int do_justify(void) ...@@ -1794,6 +1797,9 @@ int do_justify(void)
tmpjust = copy_node(current->next); tmpjust = copy_node(current->next);
add_to_cutbuffer(tmpjust); add_to_cutbuffer(tmpjust);
/* Wiping out a newline */
totsize--;
/* length of both strings plus space between strings and ending \0. */ /* length of both strings plus space between strings and ending \0. */
current->data = nrealloc(current->data, len + len2 + 2); current->data = nrealloc(current->data, len + len2 + 2);
current->data[len++] = ' '; current->data[len++] = ' ';
...@@ -1824,12 +1830,14 @@ int do_justify(void) ...@@ -1824,12 +1830,14 @@ int do_justify(void)
i = fill; i = fill;
else else
i = slen; i = slen;
for (; i > 0; i--) { for (; i > 0; i--) {
if (isspace((int) current->data[i]) && if (isspace((int) current->data[i]) &&
((strlenpt(current->data) - strlen(current->data + i)) ((strlenpt(current->data) - strlen(current->data + i))
<= fill)) <= fill))
break; break;
} }
if (!i) if (!i)
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment