nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH 2/3] tweaks: elide two parameters from the get_regio


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH 2/3] tweaks: elide two parameters from the get_region() function
Date: Wed, 20 Dec 2017 19:49:50 +0100

---
 src/proto.h |  3 +--
 src/text.c  | 12 +++---------
 src/utils.c |  9 +++++----
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/proto.h b/src/proto.h
index 7a5c208c..537e29c9 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 e43319b8..adee7275 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 95dc66a7..dd625ede 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;
 }
 
-- 
2.14.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]