From: David Lawrence Ramsey Date: Sat, 13 Nov 2004 01:32:17 +0000 (+0000) Subject: in cut_marked_segment(), respect concatenate_cut, as we need to use it X-Git-Tag: v1.3.5~25 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=649b431171fea476b903833083a9453e3c112c66;p=nano.git in cut_marked_segment(), respect concatenate_cut, as we need to use it if we do a marked cut and immediately follow it with a cut-to-end (which uses that function) git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2095 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index c20d1fd2..291f62a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -114,6 +114,10 @@ CVS code - handle this. (DLR) - Convert some ints with predefined boundaries to enums. (DLR) - cut.c: + cut_marked_segment() + - Respect concatenate_cut, as we need to use it if we do a + marked cut and immediately follow it with a cut-to-end (which + uses this function). (DLR) do_cut_text() - Set concatenate_cut to TRUE unconditionally when doing a marked cut. This fixes an incompatibility with Pico where an diff --git a/src/cut.c b/src/cut.c index aa0d0096..573d209b 100644 --- a/src/cut.c +++ b/src/cut.c @@ -59,8 +59,8 @@ void add_to_cutbuffer(filestruct *inptr, bool allow_concat) cutbuffer = inptr; #ifndef NANO_SMALL else if (allow_concat && concatenate_cut) { - /* Just tack the text in inptr onto the text in cutbottom, - * unless allow_concat is FALSE. */ + /* If allow_concat is TRUE and we're concatenating, tack the + * text in inptr onto the text in cutbottom. */ cutbottom->data = charealloc(cutbottom->data, strlen(cutbottom->data) + strlen(inptr->data) + 1); strcat(cutbottom->data, inptr->data); @@ -120,9 +120,26 @@ void cut_marked_segment(void) cutbuffer = tmp; cutbottom = tmp; } else { + if (concatenate_cut) { + /* If we're concatenating, tack the text in the first line + * of tmp onto the text in the bottom of the cutbuffer, and + * move tmp one line down to where its next line begins. */ + cutbottom->data = charealloc(cutbottom->data, + strlen(cutbottom->data) + strlen(tmp->data) + 1); + strcat(cutbottom->data, tmp->data); + tmp = tmp->next; + } + + /* Put tmp on the line after the bottom of the cutbuffer. */ cutbottom->next = tmp; - tmp->prev = cutbottom; - cutbottom = tmp; + + if (!concatenate_cut) { + /* Tf we're not concatenating, attach tmp to the bottom of + * the cutbuffer, and then move the bottom of the cutbuffer + * one line down to where tmp is. */ + tmp->prev = cutbottom; + cutbottom = tmp; + } } /* And make the top remainder line manually too. Update current_x