From 9fa95a3680933e1706392508a43f2d839c1831d8 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Thu, 15 Dec 2016 13:04:52 +0100
Subject: [PATCH] tweaks: put some prototypes in the proper order, and move a
 bit of code

---
 src/proto.h | 18 +++++++++---------
 src/text.c  |  2 +-
 src/utils.c | 40 +++++++++++++++++++---------------------
 3 files changed, 29 insertions(+), 31 deletions(-)

diff --git a/src/proto.h b/src/proto.h
index b9c28a4c..f0f8a175 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -588,18 +588,25 @@ void do_tab(void);
 void do_indent(ssize_t cols);
 void do_indent_void(void);
 void do_unindent(void);
-void do_undo(void);
-void do_redo(void);
 #endif
 bool white_string(const char *s);
 #ifdef ENABLE_COMMENT
 void do_comment(void);
+bool comment_line(undo_type action, filestruct *f, const char *comment_seq);
 #endif
+void do_undo(void);
+void do_redo(void);
 void do_enter(void);
 #ifndef NANO_TINY
 RETSIGTYPE cancel_command(int signal);
 bool execute_command(const char *command);
+void discard_until(const undo *thisitem, openfilestruct *thefile);
+void add_undo(undo_type action);
+#ifndef DISABLE_COMMENT
+void update_comment_undo(ssize_t lineno);
 #endif
+void update_undo(undo_type action);
+#endif /* !NANO_TINY */
 #ifndef DISABLE_WRAPPING
 void wrap_reset(void);
 bool do_wrap(filestruct *line);
@@ -688,13 +695,6 @@ void new_magicline(void);
 void remove_magicline(void);
 void mark_order(const filestruct **top, size_t *top_x, const filestruct
 	**bot, size_t *bot_x, bool *right_side_up);
-void discard_until(const undo *thisitem, openfilestruct *thefile);
-void add_undo(undo_type action);
-void update_undo(undo_type action);
-#ifndef DISABLE_COMMENT
-void update_comment_undo(ssize_t lineno);
-bool comment_line(undo_type action, filestruct *f, const char *comment_seq);
-#endif
 #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 7bfffcd7..fea5c9cb 100644
--- a/src/text.c
+++ b/src/text.c
@@ -981,7 +981,7 @@ void do_redo(void)
 #endif /* !NANO_TINY */
 
 /* Break the current line at the cursor position. */
-void do_enter()
+void do_enter(void)
 {
     filestruct *newnode = make_new_node(openfile->current);
     size_t extra = 0;
diff --git a/src/utils.c b/src/utils.c
index 764e8eb7..9ba9bd85 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -597,27 +597,7 @@ void mark_order(const filestruct **top, size_t *top_x, const filestruct
 	    *right_side_up = FALSE;
     }
 }
-#endif /* !NANO_TINY */
-
-/* Count the number of characters from begin to end, and return it. */
-size_t get_totsize(const filestruct *begin, const filestruct *end)
-{
-    const filestruct *line;
-    size_t totsize = 0;
-
-    /* Sum the number of characters (plus a newline) in each line. */
-    for (line = begin; line != end->next; line = line->next)
-	totsize += mbstrlen(line->data) + 1;
-
-    /* The last line of a file doesn't have a newline -- otherwise it
-     * wouldn't be the last line -- so subtract 1 when at EOF. */
-    if (line == NULL)
-	totsize--;
 
-    return totsize;
-}
-
-#ifndef NANO_TINY
 /* Given a line number, return a pointer to the corresponding struct. */
 filestruct *fsfromline(ssize_t lineno)
 {
@@ -638,7 +618,25 @@ filestruct *fsfromline(ssize_t lineno)
 
     return f;
 }
-#endif
+#endif /* !NANO_TINY */
+
+/* Count the number of characters from begin to end, and return it. */
+size_t get_totsize(const filestruct *begin, const filestruct *end)
+{
+    const filestruct *line;
+    size_t totsize = 0;
+
+    /* Sum the number of characters (plus a newline) in each line. */
+    for (line = begin; line != end->next; line = line->next)
+	totsize += mbstrlen(line->data) + 1;
+
+    /* The last line of a file doesn't have a newline -- otherwise it
+     * wouldn't be the last line -- so subtract 1 when at EOF. */
+    if (line == NULL)
+	totsize--;
+
+    return totsize;
+}
 
 #ifdef DEBUG
 /* Dump the filestruct inptr to stderr. */
-- 
GitLab