tweaks: rename four functions, to make more sense

master
Benno Schulenberg 2019-03-21 17:18:50 +01:00
parent aac4fc46e9
commit 6755b7c0a0
6 changed files with 33 additions and 33 deletions

View File

@ -189,7 +189,7 @@ void chop_word(bool forward)
do_cut_text_void();
/* Discard the cut word and restore the cutbuffer. */
free_filestruct(cutbuffer);
free_lines(cutbuffer);
cutbuffer = is_cutbuffer;
cutbottom = is_cutbottom;
}
@ -287,7 +287,7 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if (!append && (!keep_cutbuffer || marked || cut_till_eof)) {
free_filestruct(cutbuffer);
free_lines(cutbuffer);
cutbuffer = NULL;
/* After a line cut, future line cuts should add to the cutbuffer. */
keep_cutbuffer = !marked && !cut_till_eof;

View File

@ -537,7 +537,7 @@ void replace_buffer(const char *filename)
#ifndef NANO_TINY
update_undo(CUT_TO_EOF);
#endif
free_filestruct(cutbuffer);
free_lines(cutbuffer);
cutbuffer = was_cutbuffer;
/* Insert the processed file into its place. */
@ -576,7 +576,7 @@ void replace_marked_buffer(const char *filename)
add_undo(CUT);
do_cut_text(FALSE, TRUE, FALSE, FALSE);
update_undo(CUT);
free_filestruct(cutbuffer);
free_lines(cutbuffer);
cutbuffer = was_cutbuffer;
/* Insert the processed file where the marked text was. */
@ -2050,7 +2050,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
/* Partition the buffer so that it contains only the marked text. */
mark_order((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
filepart = partition_buffer(top, top_x, bot, bot_x);
/* If we are using a magic line, and the last line of the partition
* isn't blank, then add a newline at the end of the buffer. */
@ -2065,7 +2065,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
remove_magicline();
/* Unpartition the buffer so that it contains all the text again. */
unpartition_filestruct(&filepart);
unpartition_buffer(&filepart);
return retval;
}

View File

@ -139,7 +139,7 @@ void delete_node(linestruct *fileptr)
}
/* Duplicate an entire linked list of linestructs. */
linestruct *copy_filestruct(const linestruct *src)
linestruct *copy_buffer(const linestruct *src)
{
linestruct *head, *copy;
@ -162,7 +162,7 @@ linestruct *copy_filestruct(const linestruct *src)
}
/* Free an entire linked list of linestructs. */
void free_filestruct(linestruct *src)
void free_lines(linestruct *src)
{
if (src == NULL)
return;
@ -197,7 +197,7 @@ void renumber(linestruct *line)
/* Partition the current buffer so that it appears to begin at (top, top_x)
* and appears to end at (bot, bot_x). */
partition *partition_filestruct(linestruct *top, size_t top_x,
partition *partition_buffer(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x)
{
partition *p = nmalloc(sizeof(partition));
@ -241,7 +241,7 @@ partition *partition_filestruct(linestruct *top, size_t top_x,
/* Unpartition the current buffer so that it stretches from (fileage, 0)
* to (filebot, $) again. */
void unpartition_filestruct(partition **p)
void unpartition_buffer(partition **p)
{
/* Reattach the line above the top of the partition, and restore the
* text before top_x from top_data. Free top_data when we're done
@ -301,7 +301,7 @@ void extract_buffer(linestruct **file_top, linestruct **file_bot,
* (top, top_x) to (bot, bot_x), keep track of whether the top of
* the edit window is inside the partition, and keep track of
* whether the mark begins inside the partition. */
filepart = partition_filestruct(top, top_x, bot, bot_x);
filepart = partition_buffer(top, top_x, bot, bot_x);
edittop_inside = (openfile->edittop->lineno >= openfile->fileage->lineno &&
openfile->edittop->lineno <= openfile->filebot->lineno);
#ifndef NANO_TINY
@ -376,7 +376,7 @@ void extract_buffer(linestruct **file_top, linestruct **file_bot,
/* Unpartition the buffer so that it contains all the text
* again, minus the saved text. */
unpartition_filestruct(&filepart);
unpartition_buffer(&filepart);
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
@ -420,10 +420,10 @@ void ingraft_buffer(linestruct *somebuffer)
/* Partition the buffer so that it contains no text, and remember
* whether the current line is at the top of the edit window. */
filepart = partition_filestruct(openfile->current, openfile->current_x,
filepart = partition_buffer(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
edittop_inside = (openfile->edittop == openfile->fileage);
free_filestruct(openfile->fileage);
free_lines(openfile->fileage);
/* Put the top and bottom of the current buffer at the top and
* bottom of the passed buffer. */
@ -480,7 +480,7 @@ void ingraft_buffer(linestruct *somebuffer)
/* Unpartition the buffer so that it contains all the text
* again, plus the copied text. */
unpartition_filestruct(&filepart);
unpartition_buffer(&filepart);
/* Renumber, starting with the beginning line of the old partition. */
renumber(top_save);
@ -493,7 +493,7 @@ void ingraft_buffer(linestruct *somebuffer)
/* Meld a copy of the given buffer into the current file buffer. */
void copy_from_buffer(linestruct *somebuffer)
{
linestruct *the_copy = copy_filestruct(somebuffer);
linestruct *the_copy = copy_buffer(somebuffer);
ingraft_buffer(the_copy);
}
@ -516,7 +516,7 @@ void unlink_opennode(openfilestruct *fileptr)
void delete_opennode(openfilestruct *fileptr)
{
free(fileptr->filename);
free_filestruct(fileptr->fileage);
free_lines(fileptr->fileage);
#ifndef NANO_TINY
free(fileptr->current_stat);
free(fileptr->lock_filename);
@ -613,7 +613,7 @@ void die(const char *msg, ...)
* because it would write files not mentioned on the command line. */
if (openfile->modified && !ISSET(RESTRICTED)) {
if (filepart != NULL)
unpartition_filestruct(&filepart);
unpartition_buffer(&filepart);
emergency_save(openfile->filename, openfile->current_stat);
}

View File

@ -393,12 +393,12 @@ linestruct *make_new_node(linestruct *prevnode);
void splice_node(linestruct *afterthis, linestruct *newnode);
void unlink_node(linestruct *fileptr);
void delete_node(linestruct *fileptr);
linestruct *copy_filestruct(const linestruct *src);
void free_filestruct(linestruct *src);
linestruct *copy_buffer(const linestruct *src);
void free_lines(linestruct *src);
void renumber(linestruct *line);
partition *partition_filestruct(linestruct *top, size_t top_x,
partition *partition_buffer(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void unpartition_filestruct(partition **p);
void unpartition_buffer(partition **p);
void extract_buffer(linestruct **file_top, linestruct **file_bot,
linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *somebuffer);

View File

@ -507,7 +507,7 @@ void redo_cut(undo *u)
do_cut_text(FALSE, TRUE, FALSE, u->type == ZAP);
free_filestruct(cutbuffer);
free_lines(cutbuffer);
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
}
@ -634,7 +634,7 @@ void do_undo(void)
openfile->mark_x = u->mark_begin_x;
goto_line_posx(u->lineno, u->begin);
cut_marked(NULL);
free_filestruct(u->cutbuffer);
free_lines(u->cutbuffer);
u->cutbuffer = cutbuffer;
u->cutbottom = cutbottom;
cutbuffer = oldcutbuffer;
@ -808,7 +808,7 @@ void do_redo(void)
redidmsg = _("insertion");
goto_line_posx(u->lineno, u->begin);
copy_from_buffer(u->cutbuffer);
free_filestruct(u->cutbuffer);
free_lines(u->cutbuffer);
u->cutbuffer = NULL;
break;
case COUPLE_BEGIN:
@ -1057,7 +1057,7 @@ bool execute_command(const char *command)
if (ISSET(MULTIBUFFER))
switch_to_next_buffer();
#endif
free_filestruct(cutbuffer);
free_lines(cutbuffer);
cutbuffer = was_cutbuffer;
}
@ -1115,7 +1115,7 @@ void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep)
while (dropit != NULL && dropit != thisitem) {
thefile->undotop = dropit->next;
free(dropit->strdata);
free_filestruct(dropit->cutbuffer);
free_lines(dropit->cutbuffer);
group = dropit->grouping;
while (group != NULL) {
undo_group *next = group->next;
@ -1247,7 +1247,7 @@ void add_undo(undo_type action)
}
break;
case PASTE:
u->cutbuffer = copy_filestruct(cutbuffer);
u->cutbuffer = copy_buffer(cutbuffer);
u->lineno += cutbottom->lineno - cutbuffer->lineno;
break;
case INSERT:
@ -1372,8 +1372,8 @@ void update_undo(undo_type action)
if (u->type == ZAP)
u->cutbuffer = cutbuffer;
else {
free_filestruct(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
free_lines(u->cutbuffer);
u->cutbuffer = copy_buffer(cutbuffer);
}
if (u->xflags & MARK_WAS_SET) {
/* If the "marking" operation was from right-->left or
@ -3136,7 +3136,7 @@ void do_wordlinechar_count(void)
if (was_mark) {
mark_order((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
filepart = partition_buffer(top, top_x, bot, bot_x);
openfile->mark = NULL;
}
@ -3163,7 +3163,7 @@ void do_wordlinechar_count(void)
/* Unpartition the buffer so that it contains all the text
* again, and turn the mark back on. */
unpartition_filestruct(&filepart);
unpartition_buffer(&filepart);
openfile->mark = was_mark;
} else {
nlines = openfile->filebot->lineno;

View File

@ -454,7 +454,7 @@ void remove_magicline(void)
if (openfile->filebot->data[0] == '\0' &&
openfile->filebot != openfile->fileage) {
openfile->filebot = openfile->filebot->prev;
free_filestruct(openfile->filebot->next);
free_lines(openfile->filebot->next);
openfile->filebot->next = NULL;
openfile->totsize--;
}