mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-10 03:22:04 +03:00
tweaks: elide a parameter and a return value
As 'filepart' is a global variable, there is no need to pass it around. Just use it directly.
This commit is contained in:
parent
2e81023553
commit
7e9dd385f5
@ -2000,7 +2000,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
/* Partition the buffer so that it contains only the marked text. */
|
||||
get_region((const linestruct **)&top, &top_x,
|
||||
(const linestruct **)&bot, &bot_x, NULL);
|
||||
filepart = partition_buffer(top, top_x, bot, bot_x);
|
||||
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. */
|
||||
@ -2015,7 +2015,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_buffer(&filepart);
|
||||
unpartition_buffer();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
27
src/nano.c
27
src/nano.c
@ -192,8 +192,8 @@ void renumber_from(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_buffer(linestruct *top, size_t top_x,
|
||||
linestruct *bot, size_t bot_x)
|
||||
void partition_buffer(linestruct *top, size_t top_x,
|
||||
linestruct *bot, size_t bot_x)
|
||||
{
|
||||
partition *p = nmalloc(sizeof(partition));
|
||||
|
||||
@ -230,14 +230,15 @@ partition *partition_buffer(linestruct *top, size_t top_x,
|
||||
/* Remove all text before top_x at the top of the partition. */
|
||||
charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
|
||||
|
||||
/* Return the partition. */
|
||||
return p;
|
||||
filepart = p;
|
||||
}
|
||||
|
||||
/* Unpartition the current buffer so that it stretches from (filetop, 0)
|
||||
* to (filebot, $) again. */
|
||||
void unpartition_buffer(partition **p)
|
||||
void unpartition_buffer()
|
||||
{
|
||||
partition **p = &filepart;
|
||||
|
||||
/* 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
|
||||
* with it. */
|
||||
@ -270,8 +271,8 @@ void unpartition_buffer(partition **p)
|
||||
openfile->filebot = (*p)->filebot;
|
||||
|
||||
/* Uninitialize the partition. */
|
||||
free(*p);
|
||||
*p = NULL;
|
||||
free(filepart);
|
||||
filepart = NULL;
|
||||
}
|
||||
|
||||
/* Move all text between (top, top_x) and (bot, bot_x) from the current buffer
|
||||
@ -293,7 +294,7 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
|
||||
* (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_buffer(top, top_x, bot, bot_x);
|
||||
partition_buffer(top, top_x, bot, bot_x);
|
||||
edittop_inside = (openfile->edittop->lineno >= openfile->filetop->lineno &&
|
||||
openfile->edittop->lineno <= openfile->filebot->lineno);
|
||||
#ifndef NANO_TINY
|
||||
@ -358,7 +359,7 @@ void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
|
||||
|
||||
/* Unpartition the buffer so that it contains all the text
|
||||
* again, minus the saved text. */
|
||||
unpartition_buffer(&filepart);
|
||||
unpartition_buffer();
|
||||
|
||||
renumber_from(openfile->current);
|
||||
|
||||
@ -394,8 +395,8 @@ void ingraft_buffer(linestruct *topline)
|
||||
|
||||
/* 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_buffer(openfile->current, openfile->current_x,
|
||||
openfile->current, openfile->current_x);
|
||||
partition_buffer(openfile->current, openfile->current_x,
|
||||
openfile->current, openfile->current_x);
|
||||
edittop_inside = (openfile->edittop == openfile->filetop);
|
||||
delete_node(openfile->filetop);
|
||||
|
||||
@ -437,7 +438,7 @@ void ingraft_buffer(linestruct *topline)
|
||||
|
||||
/* Unpartition the buffer so that it contains all the text
|
||||
* again, plus the copied text. */
|
||||
unpartition_buffer(&filepart);
|
||||
unpartition_buffer();
|
||||
|
||||
renumber_from(topline);
|
||||
|
||||
@ -576,7 +577,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_buffer(&filepart);
|
||||
unpartition_buffer();
|
||||
|
||||
emergency_save(openfile->filename, openfile->current_stat);
|
||||
}
|
||||
|
@ -393,9 +393,9 @@ void delete_node(linestruct *fileptr);
|
||||
linestruct *copy_buffer(const linestruct *src);
|
||||
void free_lines(linestruct *src);
|
||||
void renumber_from(linestruct *line);
|
||||
partition *partition_buffer(linestruct *top, size_t top_x,
|
||||
void partition_buffer(linestruct *top, size_t top_x,
|
||||
linestruct *bot, size_t bot_x);
|
||||
void unpartition_buffer(partition **p);
|
||||
void unpartition_buffer();
|
||||
void extract(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
|
||||
void ingraft_buffer(linestruct *somebuffer);
|
||||
void copy_from_buffer(linestruct *somebuffer);
|
||||
|
@ -3039,7 +3039,7 @@ void do_wordlinechar_count(void)
|
||||
if (openfile->mark) {
|
||||
get_region((const linestruct **)&top, &top_x,
|
||||
(const linestruct **)&bot, &bot_x, NULL);
|
||||
filepart = partition_buffer(top, top_x, bot, bot_x);
|
||||
partition_buffer(top, top_x, bot, bot_x);
|
||||
}
|
||||
|
||||
/* Start at the top of the file. */
|
||||
@ -3063,7 +3063,7 @@ void do_wordlinechar_count(void)
|
||||
/* Get the number of multibyte characters, similar to "wc -c". */
|
||||
if (openfile->mark) {
|
||||
chars = get_totsize(openfile->filetop, openfile->filebot);
|
||||
unpartition_buffer(&filepart);
|
||||
unpartition_buffer();
|
||||
} else
|
||||
chars = openfile->totsize;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user