commit 56a111afa31b3dbac8ca22228fd7ef504be397d3
parent 38bbdf8fc35ff4cd7e77df0a889f55dae4f60fa2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 31 Mar 2020 19:30:08 +0200
tweaks: fold two blocks into each other, to elide three overlapping cases
Diffstat:
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git 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;