From ba093b0b48c73a2d776ec98736249712f5105c71 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 25 Oct 2021 10:37:15 +0200 Subject: [PATCH] tweaks: elide two parameters, as they are now always the same --- src/cut.c | 4 ++-- src/move.c | 30 ++++++++++++++---------------- src/prototypes.h | 4 ++-- src/text.c | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/cut.c b/src/cut.c index 98c9aa85..3ce07f0c 100644 --- 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 index c6429a50..df21d5b7 100644 --- 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 index 75ee9b8e..a16209a9 100644 --- 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 index 2c4a822d..fb40aa6b 100644 --- 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++; }