files: make an 'if' more transparent and snip an unneeded condition
Also unwrap or improve some comments.master
parent
2faad1230a
commit
0b33ab552b
24
src/files.c
24
src/files.c
|
@ -2195,7 +2195,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||||
{
|
{
|
||||||
bool retval;
|
bool retval;
|
||||||
bool old_modified = openfile->modified;
|
bool old_modified = openfile->modified;
|
||||||
/* write_file() unsets the modified flag. */
|
/* Save the status, because write_file() unsets the modified flag. */
|
||||||
bool added_magicline = FALSE;
|
bool added_magicline = FALSE;
|
||||||
/* Whether we added a magicline after filebot. */
|
/* Whether we added a magicline after filebot. */
|
||||||
filestruct *top, *bot;
|
filestruct *top, *bot;
|
||||||
|
@ -2203,29 +2203,25 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||||
|
|
||||||
assert(openfile->mark_set);
|
assert(openfile->mark_set);
|
||||||
|
|
||||||
/* Partition the filestruct so that it contains only the marked
|
/* Partition the filestruct so that it contains only the marked text. */
|
||||||
* text. */
|
|
||||||
mark_order((const filestruct **)&top, &top_x,
|
mark_order((const filestruct **)&top, &top_x,
|
||||||
(const filestruct **)&bot, &bot_x, NULL);
|
(const filestruct **)&bot, &bot_x, NULL);
|
||||||
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
filepart = partition_filestruct(top, top_x, bot, bot_x);
|
||||||
|
|
||||||
/* Handle the magicline if the NO_NEWLINES flag isn't set. If the
|
/* If we are doing magicline, and the last line of the partition
|
||||||
* line at filebot is blank, treat it as the magicline and hence the
|
* isn't blank, then add a newline at the end of the buffer. */
|
||||||
* end of the file. Otherwise, add a magicline and treat it as the
|
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0') {
|
||||||
* end of the file. */
|
|
||||||
if (!ISSET(NO_NEWLINES) &&
|
|
||||||
(added_magicline = (openfile->filebot->data[0] != '\0')))
|
|
||||||
new_magicline();
|
new_magicline();
|
||||||
|
added_magicline = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
retval = write_file(name, f_open, tmp, append, TRUE);
|
retval = write_file(name, f_open, tmp, append, TRUE);
|
||||||
|
|
||||||
/* If the NO_NEWLINES flag isn't set, and we added a magicline,
|
/* If we added a magicline, remove it now. */
|
||||||
* remove it now. */
|
if (added_magicline)
|
||||||
if (!ISSET(NO_NEWLINES) && added_magicline)
|
|
||||||
remove_magicline();
|
remove_magicline();
|
||||||
|
|
||||||
/* Unpartition the filestruct so that it contains all the text
|
/* Unpartition the filestruct so that it contains all the text again. */
|
||||||
* again. */
|
|
||||||
unpartition_filestruct(&filepart);
|
unpartition_filestruct(&filepart);
|
||||||
|
|
||||||
if (old_modified)
|
if (old_modified)
|
||||||
|
|
Loading…
Reference in New Issue