From 2cd8ca4eb1592dd795b8c58d2457e4c59f202b24 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 23 Oct 2016 17:59:26 +0200 Subject: [PATCH] tweaks: stop compiling the whole_word_only parameter conditionally This make tiny nano slightly less tiny, but makes the code more readable. --- src/proto.h | 16 ++++------------ src/search.c | 36 +++++++++--------------------------- src/text.c | 4 ++-- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/proto.h b/src/proto.h index c4646a9f..dc46766a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -561,12 +561,8 @@ void regexp_cleanup(void); void not_found_msg(const char *str); void search_replace_abort(void); int search_init(bool replacing, bool use_answer); -int findnextstr( -#ifndef DISABLE_SPELLER - bool whole_word_only, -#endif - const filestruct *begin, size_t begin_x, - const char *needle, size_t *match_len); +int findnextstr(const char *needle, bool whole_word_only, size_t *match_len, + const filestruct *begin, size_t begin_x); void do_search(void); #ifndef NANO_TINY void do_findprevious(void); @@ -578,12 +574,8 @@ void go_looking(void); int replace_regexp(char *string, bool create); #endif char *replace_line(const char *needle); -ssize_t do_replace_loop( -#ifndef DISABLE_SPELLER - bool whole_word_only, -#endif - const filestruct *real_current, size_t *real_current_x, - const char *needle); +ssize_t do_replace_loop(const char *needle, bool whole_word_only, + const filestruct *real_current, size_t *real_current_x); void do_replace(void); void goto_line_posx(ssize_t line, size_t pos_x); void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, diff --git a/src/search.c b/src/search.c index 03e9ae25..8a7b9b14 100644 --- a/src/search.c +++ b/src/search.c @@ -237,12 +237,8 @@ int search_init(bool replacing, bool use_answer) * where we first started searching, at column begin_x. Return 1 when we * found something, 0 when nothing, and -2 on cancel. When match_len is * not NULL, set it to the length of the found string, if any. */ -int findnextstr( -#ifndef DISABLE_SPELLER - bool whole_word_only, -#endif - const filestruct *begin, size_t begin_x, - const char *needle, size_t *match_len) +int findnextstr(const char *needle, bool whole_word_only, size_t *match_len, + const filestruct *begin, size_t begin_x) { size_t found_len; /* The length of the match we find. */ @@ -474,11 +470,8 @@ void go_looking(void) came_full_circle = FALSE; - didfind = findnextstr( -#ifndef DISABLE_SPELLER - FALSE, -#endif - openfile->current, openfile->current_x, last_search, NULL); + didfind = findnextstr(last_search, FALSE, NULL, + openfile->current, openfile->current_x); /* If we found something, and we're back at the exact same spot * where we started searching, then this is the only occurrence. */ @@ -587,12 +580,8 @@ char *replace_line(const char *needle) * allow the cursor position to be updated when a word before the cursor * is replaced by a shorter word. Return -1 if needle isn't found, -2 if * the seeking is aborted, else the number of replacements performed. */ -ssize_t do_replace_loop( -#ifndef DISABLE_SPELLER - bool whole_word_only, -#endif - const filestruct *real_current, size_t *real_current_x, - const char *needle) +ssize_t do_replace_loop(const char *needle, bool whole_word_only, + const filestruct *real_current, size_t *real_current_x) { ssize_t numreplaced = -1; size_t match_len; @@ -626,11 +615,8 @@ ssize_t do_replace_loop( while (TRUE) { int i = 0; - int result = findnextstr( -#ifndef DISABLE_SPELLER - whole_word_only, -#endif - real_current, *real_current_x, needle, &match_len); + int result = findnextstr(needle, whole_word_only, &match_len, + real_current, *real_current_x); /* If nothing more was found, or the user aborted, stop looping. */ if (result < 1) { @@ -834,11 +820,7 @@ void do_replace(void) begin = openfile->current; begin_x = openfile->current_x; - numreplaced = do_replace_loop( -#ifndef DISABLE_SPELLER - FALSE, -#endif - begin, &begin_x, last_search); + numreplaced = do_replace_loop(last_search, FALSE, begin, &begin_x); /* Restore where we were. */ openfile->edittop = edittop_save; diff --git a/src/text.c b/src/text.c index 0c73749a..ca777094 100644 --- a/src/text.c +++ b/src/text.c @@ -2663,7 +2663,7 @@ bool do_int_spell_fix(const char *word) } /* Find the first whole occurrence of word. */ - result = findnextstr(TRUE, NULL, 0, word, NULL); + result = findnextstr(word, TRUE, NULL, NULL, 0); /* If the word isn't found, alert the user; if it is, allow correction. */ if (result == 0) { @@ -2700,7 +2700,7 @@ bool do_int_spell_fix(const char *word) /* Replacements should happen only in the marked region. */ openfile->mark_set = old_mark_set; #endif - do_replace_loop(TRUE, current_save, ¤t_x_save, word); + do_replace_loop(word, TRUE, current_save, ¤t_x_save); /* TRANSLATORS: Shown after fixing misspellings in one word. */ statusbar(_("Next word..."));