nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit c5e46101b1876252af608161ba4dadd3c686d289
parent 53b77cb4c681040990297eb94de6a001d0338b84
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  2 Oct 2019 17:39:45 +0200

tweaks: reshuffle some lines, to elide an unneeded assignment

Diffstat:
Msrc/text.c | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -1120,14 +1120,9 @@ void discard_until(const undostruct *thisitem, openfilestruct *thefile, bool kee /* Add a new undo item of the given type to the top of the current pile. */ void add_undo(undo_type action) { - undostruct *u = openfile->current_undo; - /* The thing we did previously. */ - - /* Blow away newer undo items if we add somewhere in the middle. */ - discard_until(u, openfile, TRUE); + undostruct *u = nmalloc(sizeof(undostruct)); - /* Allocate and initialize a new undo item. */ - u = (undostruct *) nmalloc(sizeof(undostruct)); + /* Initialize the newly allocated undo item. */ u->type = action; u->strdata = NULL; u->cutbuffer = NULL; @@ -1137,8 +1132,11 @@ void add_undo(undo_type action) u->mark_begin_x = openfile->current_x; u->wassize = openfile->totsize; u->newsize = openfile->totsize; - u->xflags = 0; u->grouping = NULL; + u->xflags = 0; + + /* Blow away any undone items. */ + discard_until(openfile->current_undo, openfile, TRUE); #ifdef ENABLE_WRAPPING /* If some action caused automatic long-line wrapping, insert the