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,
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);
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;
filestruct *t = 0;
size_t len = 0;
char *undidmsg, *data;
- filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
if (!u) {
statusbar(_("Nothing in undo buffer!"));
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
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;
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