diff --git a/src/proto.h b/src/proto.h index a2d523d8..89b6485d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -609,8 +609,7 @@ void remove_magicline(void); #ifndef NANO_TINY void mark_order(const filestruct **top, size_t *top_x, const filestruct **bot, size_t *bot_x, bool *right_side_up); -void get_region(const filestruct **top, size_t *top_x, - const filestruct **bot, size_t *bot_x); +void get_region(const filestruct **top, const filestruct **bot); #endif size_t get_totsize(const filestruct *begin, const filestruct *end); #ifndef NANO_TINY diff --git a/src/text.c b/src/text.c index 3da83ccd..9c0ed3f0 100644 --- a/src/text.c +++ b/src/text.c @@ -296,12 +296,10 @@ void do_indent(void) char *indentation = charalloc(tabsize + 1); /* The whitespace added to each line in order to indent it. */ filestruct *top, *bot, *line; - size_t top_x, bot_x; /* Use either all the marked lines or just the current line. */ if (openfile->mark) - get_region((const filestruct **)&top, &top_x, - (const filestruct **)&bot, &bot_x); + get_region((const filestruct **)&top, (const filestruct **)&bot); else { top = openfile->current; bot = top; @@ -401,12 +399,10 @@ void unindent_a_line(filestruct *line, size_t indent_len) void do_unindent(void) { filestruct *top, *bot, *line; - size_t top_x, bot_x; /* Use either all the marked lines or just the current line. */ if (openfile->mark) - get_region((const filestruct **)&top, &top_x, - (const filestruct **)&bot, &bot_x); + get_region((const filestruct **)&top, (const filestruct **)&bot); else { top = openfile->current; bot = top; @@ -494,7 +490,6 @@ void do_comment(void) const char *comment_seq = GENERAL_COMMENT_CHARACTER; undo_type action = UNCOMMENT; filestruct *top, *bot, *line; - size_t top_x, bot_x; bool empty, all_empty = TRUE; #ifdef ENABLE_COLOR @@ -509,8 +504,7 @@ void do_comment(void) /* Determine which lines to work on. */ if (openfile->mark) - get_region((const filestruct **)&top, &top_x, - (const filestruct **)&bot, &bot_x); + get_region((const filestruct **)&top, (const filestruct **)&bot); else { top = openfile->current; bot = top; diff --git a/src/utils.c b/src/utils.c index a926f248..decad9e9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -534,12 +534,13 @@ void mark_order(const filestruct **top, size_t *top_x, const filestruct /* Get the start and end points of the marked region, but * push the end point back if it's at the start of a line. */ -void get_region(const filestruct **top, size_t *top_x, - const filestruct **bot, size_t *bot_x) +void get_region(const filestruct **top, const filestruct **bot) { - mark_order(top, top_x, bot, bot_x, NULL); + size_t top_x, bot_x; - if (*bot_x == 0) + mark_order(top, &top_x, bot, &bot_x, NULL); + + if (bot_x == 0) *bot = (*bot)->prev; }