From c115166f5b9f05b85ed9fe96cfee6abb155278f3 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 22 Feb 2016 12:49:08 +0000
Subject: [PATCH] Sorting the prev_word() and next_word() functions in the
 standard way: the backward one first.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5661 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |   2 +
 src/move.c  | 118 ++++++++++++++++++++++++++--------------------------
 src/proto.h |   6 +--
 3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8593a681..dc47ddb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 	* src/nano.c (free_openfilestruct): Elide this function.
 	* scr/global.c (thanks_for_all_the_fish, free_list_item): Condense.
 	* src/winio.c (edit_scroll): The amount to scroll is never zero.
+	* src/prompt.c (do_statusbar_prev_word, do_statusbar_next_word),
+	src/move.c (do_prev_word, do_next_word): Sort these in standard way.
 
 2016-02-21  Benno Schulenberg  <bensberg@justemail.net>
 	* src/files.c (input_tab): If the first Tab added the part that all
diff --git a/src/move.c b/src/move.c
index 82d1e301..16dc3d6f 100644
--- a/src/move.c
+++ b/src/move.c
@@ -215,63 +215,6 @@ void do_para_end_void(void)
 #endif /* !DISABLE_JUSTIFY */
 
 #ifndef NANO_TINY
-/* Move to the next word in the file.  If allow_punct is TRUE, treat
- * punctuation as part of a word.  If allow_update is TRUE, update the
- * screen afterwards.  Return TRUE if we started on a word, and FALSE
- * otherwise. */
-bool do_next_word(bool allow_punct, bool allow_update)
-{
-    size_t pww_save = openfile->placewewant;
-    filestruct *current_save = openfile->current;
-    bool started_on_word = is_word_mbchar(openfile->current->data +
-				openfile->current_x, allow_punct);
-    bool seen_space = !started_on_word;
-
-    assert(openfile->current != NULL && openfile->current->data != NULL);
-
-    /* Move forward until we reach the start of a word. */
-    while (TRUE) {
-	/* If at the end of a line, move to the beginning of the next one. */
-	if (openfile->current->data[openfile->current_x] == '\0') {
-	    /* If at the end of the file, stop. */
-	    if (openfile->current->next == NULL)
-		break;
-	    openfile->current = openfile->current->next;
-	    openfile->current_x = 0;
-	    seen_space = TRUE;
-	} else {
-	    /* Step forward one character. */
-	    openfile->current_x = move_mbright(openfile->current->data,
-						openfile->current_x);
-	}
-
-	/* If this is not a word character, then it's a separator; else
-	 * if we've already seen a separator, then it's a word start. */
-	if (!is_word_mbchar(openfile->current->data + openfile->current_x,
-				allow_punct))
-	    seen_space = TRUE;
-	else if (seen_space)
-	    break;
-    }
-
-    openfile->placewewant = xplustabs();
-
-    /* If allow_update is TRUE, update the screen. */
-    if (allow_update)
-	edit_redraw(current_save, pww_save);
-
-    /* Return whether we started on a word. */
-    return started_on_word;
-}
-
-/* Move to the next word in the file, treating punctuation as part of a
- * word if the WORD_BOUNDS flag is set, and update the screen
- * afterwards. */
-void do_next_word_void(void)
-{
-    do_next_word(ISSET(WORD_BOUNDS), TRUE);
-}
-
 /* Move to the previous word in the file.  If allow_punct is TRUE, treat
  * punctuation as part of a word.  If allow_update is TRUE, update the
  * screen afterwards. */
@@ -321,13 +264,68 @@ void do_prev_word(bool allow_punct, bool allow_update)
 	edit_redraw(current_save, pww_save);
 }
 
-/* Move to the previous word in the file, treating punctuation as part
- * of a word if the WORD_BOUNDS flag is set, and update the screen
- * afterwards. */
+/* Move to the previous word in the file, treating punctuation as part of a
+ * word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
 void do_prev_word_void(void)
 {
     do_prev_word(ISSET(WORD_BOUNDS), TRUE);
 }
+
+/* Move to the next word in the file.  If allow_punct is TRUE, treat
+ * punctuation as part of a word.  If allow_update is TRUE, update the
+ * screen afterwards.  Return TRUE if we started on a word, and FALSE
+ * otherwise. */
+bool do_next_word(bool allow_punct, bool allow_update)
+{
+    size_t pww_save = openfile->placewewant;
+    filestruct *current_save = openfile->current;
+    bool started_on_word = is_word_mbchar(openfile->current->data +
+				openfile->current_x, allow_punct);
+    bool seen_space = !started_on_word;
+
+    assert(openfile->current != NULL && openfile->current->data != NULL);
+
+    /* Move forward until we reach the start of a word. */
+    while (TRUE) {
+	/* If at the end of a line, move to the beginning of the next one. */
+	if (openfile->current->data[openfile->current_x] == '\0') {
+	    /* If at the end of the file, stop. */
+	    if (openfile->current->next == NULL)
+		break;
+	    openfile->current = openfile->current->next;
+	    openfile->current_x = 0;
+	    seen_space = TRUE;
+	} else {
+	    /* Step forward one character. */
+	    openfile->current_x = move_mbright(openfile->current->data,
+						openfile->current_x);
+	}
+
+	/* If this is not a word character, then it's a separator; else
+	 * if we've already seen a separator, then it's a word start. */
+	if (!is_word_mbchar(openfile->current->data + openfile->current_x,
+				allow_punct))
+	    seen_space = TRUE;
+	else if (seen_space)
+	    break;
+    }
+
+    openfile->placewewant = xplustabs();
+
+    /* If allow_update is TRUE, update the screen. */
+    if (allow_update)
+	edit_redraw(current_save, pww_save);
+
+    /* Return whether we started on a word. */
+    return started_on_word;
+}
+
+/* Move to the next word in the file, treating punctuation as part of a word
+ * if the WORD_BOUNDS flag is set, and update the screen afterwards. */
+void do_next_word_void(void)
+{
+    do_next_word(ISSET(WORD_BOUNDS), TRUE);
+}
 #endif /* !NANO_TINY */
 
 /* Move to the beginning of the current line.  If the SMART_HOME flag is
diff --git a/src/proto.h b/src/proto.h
index a3ff103d..48b60518 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -399,10 +399,10 @@ void do_para_end(bool allow_update);
 void do_para_end_void(void);
 #endif
 #ifndef NANO_TINY
-bool do_next_word(bool allow_punct, bool allow_update);
-void do_next_word_void(void);
 void do_prev_word(bool allow_punct, bool allow_update);
 void do_prev_word_void(void);
+bool do_next_word(bool allow_punct, bool allow_update);
+void do_next_word_void(void);
 #endif
 void do_home(void);
 void do_end(void);
@@ -524,8 +524,8 @@ void do_statusbar_backspace(void);
 void do_statusbar_delete(void);
 void do_statusbar_cut_text(void);
 #ifndef NANO_TINY
-void do_statusbar_next_word(void);
 void do_statusbar_prev_word(void);
+void do_statusbar_next_word(void);
 #endif
 void do_statusbar_verbatim_input(bool *got_enter);
 size_t statusbar_xplustabs(void);
-- 
GitLab