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
Этот коммит содержится в:
родитель
07f40612e1
Коммит
016669128b
@ -1,6 +1,9 @@
|
|||||||
2014-06-22 Mark Majeres <mark@engine12.com>
|
2014-06-22 Mark Majeres <mark@engine12.com>
|
||||||
* src/text.c (do_redo): When redoing a line join at the tail
|
* src/text.c (do_redo): When redoing a line join at the tail
|
||||||
of the file, make sure openfile->filebot is updated.
|
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>
|
2014-06-21 Mark Majeres <mark@engine12.com>
|
||||||
* src/text.c (undo_cut, add_undo): When undoing a cut-till-eof,
|
* src/text.c (undo_cut, add_undo): When undoing a cut-till-eof,
|
||||||
|
28
src/text.c
28
src/text.c
@ -380,21 +380,13 @@ void undo_cut(undo *u)
|
|||||||
if (!u->cutbuffer)
|
if (!u->cutbuffer)
|
||||||
return;
|
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. */
|
/* Get to where we need to uncut from. */
|
||||||
if (u->xflags == UNcut_cutline)
|
if (u->xflags == UNcut_cutline)
|
||||||
goto_line_posx(u->mark_begin_lineno, 0);
|
goto_line_posx(u->mark_begin_lineno, 0);
|
||||||
else
|
else
|
||||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||||
|
|
||||||
copy_from_filestruct(cutbuffer);
|
copy_from_filestruct(u->cutbuffer);
|
||||||
free_filestruct(cutbuffer);
|
|
||||||
cutbuffer = NULL;
|
|
||||||
|
|
||||||
if (u->xflags == UNcut_cutline || u->xflags == UNcut_marked_backwards || u->type == CUT_EOF)
|
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);
|
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||||
@ -414,18 +406,12 @@ void redo_cut(undo *u)
|
|||||||
openfile->placewewant = xplustabs();
|
openfile->placewewant = xplustabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
openfile->mark_set = u->mark_set;
|
openfile->mark_set = ISSET(CUT_TO_END) ? u->mark_set : TRUE;
|
||||||
if (cutbuffer)
|
|
||||||
free(cutbuffer);
|
|
||||||
cutbuffer = NULL;
|
|
||||||
|
|
||||||
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
|
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;
|
openfile->mark_begin_x = (u->xflags == UNcut_cutline) ? 0 : u->mark_begin_x;
|
||||||
|
|
||||||
do_cut_text(FALSE, u->type == CUT_EOF, TRUE);
|
do_cut_text(FALSE, u->type == CUT_EOF, TRUE);
|
||||||
|
|
||||||
openfile->mark_set = FALSE;
|
openfile->mark_set = FALSE;
|
||||||
openfile->mark_begin = NULL;
|
openfile->mark_begin = NULL;
|
||||||
openfile->mark_begin_x = 0;
|
openfile->mark_begin_x = 0;
|
||||||
@ -439,7 +425,6 @@ void do_undo(void)
|
|||||||
filestruct *t = 0;
|
filestruct *t = 0;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char *undidmsg, *data;
|
char *undidmsg, *data;
|
||||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
|
||||||
|
|
||||||
if (!u) {
|
if (!u) {
|
||||||
statusbar(_("Nothing in undo buffer!"));
|
statusbar(_("Nothing in undo buffer!"));
|
||||||
@ -527,6 +512,7 @@ void do_undo(void)
|
|||||||
break;
|
break;
|
||||||
case INSERT:
|
case INSERT:
|
||||||
undidmsg = _("text insert");
|
undidmsg = _("text insert");
|
||||||
|
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||||
cutbuffer = NULL;
|
cutbuffer = NULL;
|
||||||
cutbottom = NULL;
|
cutbottom = NULL;
|
||||||
/* When we updated mark_begin_lineno in update_undo, it was effectively
|
/* 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."));
|
statusbar(_("Internal error: cannot set up uncut. Please save your work."));
|
||||||
else {
|
else {
|
||||||
if (u->cutbuffer)
|
if (u->cutbuffer)
|
||||||
free(u->cutbuffer);
|
free_filestruct(u->cutbuffer);
|
||||||
u->cutbuffer = copy_filestruct(cutbuffer);
|
u->cutbuffer = copy_filestruct(cutbuffer);
|
||||||
u->mark_begin_lineno = fs->current->lineno;
|
u->mark_begin_lineno = fs->current->lineno;
|
||||||
u->mark_begin_x = fs->current_x;
|
u->mark_begin_x = fs->current_x;
|
||||||
@ -1058,7 +1044,7 @@ void update_undo(undo_type action)
|
|||||||
if (!cutbuffer)
|
if (!cutbuffer)
|
||||||
break;
|
break;
|
||||||
if (u->cutbuffer)
|
if (u->cutbuffer)
|
||||||
free(u->cutbuffer);
|
free_filestruct(u->cutbuffer);
|
||||||
u->cutbuffer = copy_filestruct(cutbuffer);
|
u->cutbuffer = copy_filestruct(cutbuffer);
|
||||||
if (u->mark_set) {
|
if (u->mark_set) {
|
||||||
/* If the "marking" operation was from right-->left or
|
/* If the "marking" operation was from right-->left or
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user