Commit 01666912 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Fixing three leaks of the cutbuffer, shortening and regrouping some stuff,

and removing an unneeded iteration of cutbottom.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5008 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 10 additions and 21 deletions
+10 -21
2014-06-22 Mark Majeres <mark@engine12.com>
* src/text.c (do_redo): When redoing a line join at the tail
of the file, make sure openfile->filebot is updated.
* src/text.c (undo_cut, redo_cut, do_undo, add_undo, update_undo):
Fix three leaks of the cutbuffer, shorten and regroup some stuff,
and remove an unneeded iteration of cutbottom.
2014-06-21 Mark Majeres <mark@engine12.com>
* src/text.c (undo_cut, add_undo): When undoing a cut-till-eof,
......
......@@ -380,21 +380,13 @@ void undo_cut(undo *u)
if (!u->cutbuffer)
return;
cutbuffer = copy_filestruct(u->cutbuffer);
/* Compute cutbottom for the uncut using our copy. */
for (cutbottom = cutbuffer; cutbottom->next != NULL; cutbottom = cutbottom->next)
;
/* Get to where we need to uncut from. */
if (u->xflags == UNcut_cutline)
goto_line_posx(u->mark_begin_lineno, 0);
else
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
copy_from_filestruct(cutbuffer);
free_filestruct(cutbuffer);
cutbuffer = NULL;
copy_from_filestruct(u->cutbuffer);
if (u->xflags == UNcut_cutline || u->xflags == UNcut_marked_backwards || u->type == CUT_EOF)
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
......@@ -414,18 +406,12 @@ void redo_cut(undo *u)
openfile->placewewant = xplustabs();
}
openfile->mark_set = u->mark_set;
if (cutbuffer)
free(cutbuffer);
cutbuffer = NULL;
openfile->mark_set = ISSET(CUT_TO_END) ? u->mark_set : TRUE;
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
if (!ISSET(CUT_TO_END))
openfile->mark_set = TRUE;
openfile->mark_begin_x = (u->xflags == UNcut_cutline) ? 0 : u->mark_begin_x;
do_cut_text(FALSE, u->type == CUT_EOF, TRUE);
openfile->mark_set = FALSE;
openfile->mark_begin = NULL;
openfile->mark_begin_x = 0;
......@@ -439,7 +425,6 @@ void do_undo(void)
filestruct *t = 0;
size_t len = 0;
char *undidmsg, *data;
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
if (!u) {
statusbar(_("Nothing in undo buffer!"));
......@@ -527,6 +512,7 @@ void do_undo(void)
break;
case INSERT:
undidmsg = _("text insert");
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
/* When we updated mark_begin_lineno in update_undo, it was effectively
......@@ -961,7 +947,7 @@ void add_undo(undo_type current_action)
statusbar(_("Internal error: cannot set up uncut. Please save your work."));
else {
if (u->cutbuffer)
free(u->cutbuffer);
free_filestruct(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
u->mark_begin_lineno = fs->current->lineno;
u->mark_begin_x = fs->current_x;
......@@ -1058,7 +1044,7 @@ void update_undo(undo_type action)
if (!cutbuffer)
break;
if (u->cutbuffer)
free(u->cutbuffer);
free_filestruct(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
if (u->mark_set) {
/* If the "marking" operation was from right-->left or
......
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