From 6ca8518428d719ee435a7791f330952d319a0da9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 8 Jun 2019 10:03:15 +0200 Subject: [PATCH] tweaks: make better use of two variables, and reshuffle two comments --- src/nano.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/nano.c b/src/nano.c index 24c484bd..8c31a4ed 100644 --- a/src/nano.c +++ b/src/nano.c @@ -246,11 +246,12 @@ void partition_buffer(linestruct *top, size_t top_x, * to (filebot, $) again. */ void unpartition_buffer() { - /* Reattach the line that was above the top of the partition, - * and restore the text that was before top_x. */ + /* Reattach the line that was above the top of the partition. */ openfile->filetop->prev = foreline; - if (openfile->filetop->prev != NULL) - openfile->filetop->prev->next = openfile->filetop; + if (foreline != NULL) + foreline->next = openfile->filetop; + + /* Restore the text that was on the first partition line before its start. */ openfile->filetop->data = charealloc(openfile->filetop->data, strlen(antedata) + strlen(openfile->filetop->data) + 1); charmove(openfile->filetop->data + strlen(antedata), @@ -259,11 +260,12 @@ void unpartition_buffer() free(antedata); antedata = NULL; - /* Reattach the line that was below the bottom of the partition, - * and restore the text that was after bot_x. */ + /* Reattach the line that was below the bottom of the partition. */ openfile->filebot->next = aftline; - if (openfile->filebot->next != NULL) - openfile->filebot->next->prev = openfile->filebot; + if (aftline != NULL) + aftline->prev = openfile->filebot; + + /* Restore the text that was on the last partition line after its end. */ openfile->filebot->data = charealloc(openfile->filebot->data, strlen(openfile->filebot->data) + strlen(postdata) + 1); strcat(openfile->filebot->data, postdata);