tweaks: get rid of a bunch of annoying casts, and thus condense the code

master
Benno Schulenberg 2020-03-29 20:17:32 +02:00
parent 8f6559828d
commit 59040169ed
7 changed files with 14 additions and 22 deletions

View File

@ -434,8 +434,7 @@ void cut_marked_region(void)
linestruct *top, *bot;
size_t top_x, bot_x;
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x);
get_region(&top, &top_x, &bot, &bot_x);
extract_segment(top, top_x, bot, bot_x);

View File

@ -2026,8 +2026,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
size_t top_x, bot_x;
/* Partition the buffer so that it contains only the marked text. */
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x);
get_region(&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

View File

@ -573,9 +573,8 @@ void remove_magicline(void);
#endif
#ifndef NANO_TINY
bool mark_is_before_cursor(void);
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x);
void get_range(const linestruct **top, const linestruct **bot);
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x);
void get_range(linestruct **top, linestruct **bot);
#endif
size_t get_totsize(const linestruct *begin, const linestruct *end);
#ifndef NANO_TINY

View File

@ -522,8 +522,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* If the mark is on, frame the region, and turn the mark off. */
if (openfile->mark) {
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x);
get_region(&top, &top_x, &bot, &bot_x);
openfile->mark = NULL;
modus = INREGION;

View File

@ -120,7 +120,7 @@ void do_indent(void)
linestruct *top, *bot, *line;
/* Use either all the marked lines or just the current line. */
get_range((const linestruct **)&top, (const linestruct **)&bot);
get_range(&top, &bot);
/* Skip any leading empty lines. */
while (top != bot->next && top->data[0] == '\0')
@ -241,7 +241,7 @@ void do_unindent(void)
linestruct *top, *bot, *line;
/* Use either all the marked lines or just the current line. */
get_range((const linestruct **)&top, (const linestruct **)&bot);
get_range(&top, &bot);
/* Skip any leading lines that cannot be unindented. */
while (top != bot->next && length_of_white(top->data) == 0)
@ -386,7 +386,7 @@ void do_comment(void)
#endif
/* Determine which lines to work on. */
get_range((const linestruct **)&top, (const linestruct **)&bot);
get_range(&top, &bot);
/* If only the magic line is selected, don't do anything. */
if (top == bot && bot == openfile->filebot && !ISSET(NO_NEWLINES)) {
@ -1744,8 +1744,7 @@ void do_justify(bool full_justify)
size_t quot_len, fore_len, other_quot_len, other_white_len;
linestruct *sampleline;
get_region((const linestruct **)&startline, &start_x,
(const linestruct **)&endline, &end_x);
get_region(&startline, &start_x, &endline, &end_x);
/* When the marked region is empty, do nothing. */
if (startline == endline && start_x == end_x) {
@ -2034,8 +2033,7 @@ bool fix_spello(const char *word)
#ifndef NANO_TINY
/* If the mark is on, start at the beginning of the marked region. */
if (openfile->mark) {
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x);
get_region(&top, &top_x, &bot, &bot_x);
/* If the region is marked normally, swap the end points, so that
* (current, current_x) (where searching starts) is at the top. */
if (right_side_up) {
@ -2913,8 +2911,7 @@ void do_wordlinechar_count(void)
/* If the mark is on, partition the buffer so that it
* contains only the marked text, and turn the mark off. */
if (openfile->mark) {
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x);
get_region(&top, &top_x, &bot, &bot_x);
partition_buffer(top, top_x, bot, bot_x);
}

View File

@ -460,8 +460,7 @@ bool mark_is_before_cursor(void)
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
* of the marked region. */
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x)
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x)
{
if (mark_is_before_cursor()) {
*top = openfile->mark;
@ -479,7 +478,7 @@ void get_region(const linestruct **top, size_t *top_x,
/* Get the set of lines to work on -- either just the current line, or the
* first to last lines of the marked region. When the cursor (or mark) is
* at the start of the last line of the region, exclude that line. */
void get_range(const linestruct **top, const linestruct **bot)
void get_range(linestruct **top, linestruct **bot)
{
if (!openfile->mark) {
*top = openfile->current;

View File

@ -2677,7 +2677,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
line->lineno <= openfile->current->lineno) ||
(line->lineno <= openfile->mark->lineno &&
line->lineno >= openfile->current->lineno))) {
const linestruct *top, *bot;
linestruct *top, *bot;
/* The lines where the marked region begins and ends. */
size_t top_x, bot_x;
/* The x positions where the marked region begins and ends. */