From 56a111afa31b3dbac8ca22228fd7ef504be397d3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 31 Mar 2020 19:30:08 +0200 Subject: [PATCH] tweaks: fold two blocks into each other, to elide three overlapping cases --- src/cut.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/cut.c b/src/cut.c index 3cb96107..3dda5c88 100644 --- a/src/cut.c +++ b/src/cut.c @@ -592,7 +592,6 @@ void copy_text(void) /* Create OR add to the cutbuffer, depending on the mode, the position * of the cursor, and whether or not the cutbuffer is currently empty. */ - if (ISSET(CUT_FROM_CURSOR)) { if (cutbuffer == NULL && sans_newline) { cutbuffer = addition; cutbottom = addition; @@ -606,32 +605,16 @@ void copy_text(void) addition->prev->next = addition; delete_node(cutbottom); cutbottom = addition; - } else { + } else if (ISSET(CUT_FROM_CURSOR)) { addition->prev = cutbottom; cutbottom->next = addition; cutbottom = addition; - } - } else { - if (cutbuffer == NULL && sans_newline ) { - cutbuffer = addition; - cutbottom = addition; - } else if (cutbuffer == NULL) { - cutbuffer = addition; - cutbottom = make_new_node(cutbuffer); - cutbottom->data = copy_of(""); - cutbuffer->next = cutbottom; - } else if (sans_newline) { - addition->prev = cutbottom->prev; - addition->prev->next = addition; - delete_node(cutbottom); - cutbottom = addition; } else { addition->prev = cutbottom->prev; addition->prev->next = addition; addition->next = cutbottom; cutbottom->prev = addition; } - } if ((!ISSET(CUT_FROM_CURSOR) || at_eol) && openfile->current->next) { openfile->current = openfile->current->next;