commit ba093b0b48c73a2d776ec98736249712f5105c71
parent 33041d0ad5b06c22c2705723dfba4f2a04999fc0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 25 Oct 2021 10:37:15 +0200
tweaks: elide two parameters, as they are now always the same
Diffstat:
4 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/cut.c b/src/cut.c
@@ -185,7 +185,7 @@ void chop_word(bool forward)
* on the edge of the original line, then put the cursor on that
* edge instead, so that lines will not be joined unexpectedly. */
if (!forward) {
- do_prev_word(ISSET(WORD_BOUNDS));
+ do_prev_word();
if (openfile->current != is_current) {
if (is_current_x > 0) {
openfile->current = is_current;
@@ -194,7 +194,7 @@ void chop_word(bool forward)
openfile->current_x = strlen(openfile->current->data);
}
} else {
- do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
+ do_next_word(ISSET(AFTER_ENDS));
if (openfile->current != is_current &&
is_current->data[is_current_x] != '\0') {
openfile->current = is_current;
diff --git a/src/move.c b/src/move.c
@@ -265,10 +265,10 @@ void to_next_block(void)
edit_redraw(was_current, CENTERING);
}
-/* Move to the previous word. If allow_punct is TRUE, treat punctuation
- * as part of a word. */
-void do_prev_word(bool allow_punct)
+/* Move to the previous word. */
+void do_prev_word(void)
{
+ bool punctuation_as_letters = ISSET(WORD_BOUNDS);
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
@@ -286,7 +286,7 @@ void do_prev_word(bool allow_punct)
openfile->current_x);
if (is_word_char(openfile->current->data + openfile->current_x,
- allow_punct)) {
+ punctuation_as_letters)) {
seen_a_word = TRUE;
/* If at the head of a line now, this surely is a word start. */
if (openfile->current_x == 0)
@@ -309,12 +309,12 @@ void do_prev_word(bool allow_punct)
}
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
- * instead of their beginnings. If allow_punct is TRUE, treat punctuation as
- * part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
-bool do_next_word(bool after_ends, bool allow_punct)
+ * instead of at their beginnings. Return TRUE if we started on a word. */
+bool do_next_word(bool after_ends)
{
+ bool punctuation_as_letters = ISSET(WORD_BOUNDS);
bool started_on_word = is_word_char(openfile->current->data +
- openfile->current_x, allow_punct);
+ openfile->current_x, punctuation_as_letters);
bool seen_space = !started_on_word;
#ifndef NANO_TINY
bool seen_word = started_on_word;
@@ -341,7 +341,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_char(openfile->current->data + openfile->current_x,
- allow_punct))
+ punctuation_as_letters))
seen_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(openfile->current->data + openfile->current_x))
@@ -360,7 +360,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
/* 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_char(openfile->current->data + openfile->current_x,
- allow_punct))
+ punctuation_as_letters))
seen_space = TRUE;
else if (seen_space)
break;
@@ -370,25 +370,23 @@ bool do_next_word(bool after_ends, bool allow_punct)
return started_on_word;
}
-/* 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, and update the screen afterwards. */
void to_prev_word(void)
{
linestruct *was_current = openfile->current;
- do_prev_word(ISSET(WORD_BOUNDS));
+ do_prev_word();
edit_redraw(was_current, FLOWING);
}
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
- * at word ends instead of beginnings. If the WORD_BOUNDS flag is set, treat
- * punctuation as part of a word. Update the screen afterwards. */
+ * at word ends instead of beginnings. Update the screen afterwards. */
void to_next_word(void)
{
linestruct *was_current = openfile->current;
- do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
+ do_next_word(ISSET(AFTER_ENDS));
edit_redraw(was_current, FLOWING);
}
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -360,8 +360,8 @@ void to_para_end(void);
#endif
void to_prev_block(void);
void to_next_block(void);
-void do_prev_word(bool allow_punct);
-bool do_next_word(bool after_ends, bool allow_punct);
+void do_prev_word(void);
+bool do_next_word(bool after_ends);
void to_prev_word(void);
void to_next_word(void);
void do_home(void);
diff --git a/src/text.c b/src/text.c
@@ -2960,7 +2960,7 @@ void count_lines_words_and_characters(void)
* incrementing the word count for each successful step. */
while (openfile->current->lineno < botline->lineno ||
(openfile->current == botline && openfile->current_x < bot_x)) {
- if (do_next_word(FALSE, ISSET(WORD_BOUNDS)))
+ if (do_next_word(FALSE))
words++;
}