tweaks: stop compiling the whole_word_only parameter conditionally

This make tiny nano slightly less tiny, but makes the code more readable.
master
Benno Schulenberg 2016-10-23 17:59:26 +02:00
parent 55b1403542
commit 2cd8ca4eb1
3 changed files with 15 additions and 41 deletions

View File

@ -561,12 +561,8 @@ void regexp_cleanup(void);
void not_found_msg(const char *str); void not_found_msg(const char *str);
void search_replace_abort(void); void search_replace_abort(void);
int search_init(bool replacing, bool use_answer); int search_init(bool replacing, bool use_answer);
int findnextstr( int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
#ifndef DISABLE_SPELLER const filestruct *begin, size_t begin_x);
bool whole_word_only,
#endif
const filestruct *begin, size_t begin_x,
const char *needle, size_t *match_len);
void do_search(void); void do_search(void);
#ifndef NANO_TINY #ifndef NANO_TINY
void do_findprevious(void); void do_findprevious(void);
@ -578,12 +574,8 @@ void go_looking(void);
int replace_regexp(char *string, bool create); int replace_regexp(char *string, bool create);
#endif #endif
char *replace_line(const char *needle); char *replace_line(const char *needle);
ssize_t do_replace_loop( ssize_t do_replace_loop(const char *needle, bool whole_word_only,
#ifndef DISABLE_SPELLER const filestruct *real_current, size_t *real_current_x);
bool whole_word_only,
#endif
const filestruct *real_current, size_t *real_current_x,
const char *needle);
void do_replace(void); void do_replace(void);
void goto_line_posx(ssize_t line, size_t pos_x); void goto_line_posx(ssize_t line, size_t pos_x);
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,

View File

@ -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 * 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 * 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. */ * not NULL, set it to the length of the found string, if any. */
int findnextstr( int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
#ifndef DISABLE_SPELLER const filestruct *begin, size_t begin_x)
bool whole_word_only,
#endif
const filestruct *begin, size_t begin_x,
const char *needle, size_t *match_len)
{ {
size_t found_len; size_t found_len;
/* The length of the match we find. */ /* The length of the match we find. */
@ -474,11 +470,8 @@ void go_looking(void)
came_full_circle = FALSE; came_full_circle = FALSE;
didfind = findnextstr( didfind = findnextstr(last_search, FALSE, NULL,
#ifndef DISABLE_SPELLER openfile->current, openfile->current_x);
FALSE,
#endif
openfile->current, openfile->current_x, last_search, NULL);
/* If we found something, and we're back at the exact same spot /* If we found something, and we're back at the exact same spot
* where we started searching, then this is the only occurrence. */ * 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 * 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 * 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. */ * the seeking is aborted, else the number of replacements performed. */
ssize_t do_replace_loop( ssize_t do_replace_loop(const char *needle, bool whole_word_only,
#ifndef DISABLE_SPELLER const filestruct *real_current, size_t *real_current_x)
bool whole_word_only,
#endif
const filestruct *real_current, size_t *real_current_x,
const char *needle)
{ {
ssize_t numreplaced = -1; ssize_t numreplaced = -1;
size_t match_len; size_t match_len;
@ -626,11 +615,8 @@ ssize_t do_replace_loop(
while (TRUE) { while (TRUE) {
int i = 0; int i = 0;
int result = findnextstr( int result = findnextstr(needle, whole_word_only, &match_len,
#ifndef DISABLE_SPELLER real_current, *real_current_x);
whole_word_only,
#endif
real_current, *real_current_x, needle, &match_len);
/* If nothing more was found, or the user aborted, stop looping. */ /* If nothing more was found, or the user aborted, stop looping. */
if (result < 1) { if (result < 1) {
@ -834,11 +820,7 @@ void do_replace(void)
begin = openfile->current; begin = openfile->current;
begin_x = openfile->current_x; begin_x = openfile->current_x;
numreplaced = do_replace_loop( numreplaced = do_replace_loop(last_search, FALSE, begin, &begin_x);
#ifndef DISABLE_SPELLER
FALSE,
#endif
begin, &begin_x, last_search);
/* Restore where we were. */ /* Restore where we were. */
openfile->edittop = edittop_save; openfile->edittop = edittop_save;

View File

@ -2663,7 +2663,7 @@ bool do_int_spell_fix(const char *word)
} }
/* Find the first whole occurrence of 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 the word isn't found, alert the user; if it is, allow correction. */
if (result == 0) { if (result == 0) {
@ -2700,7 +2700,7 @@ bool do_int_spell_fix(const char *word)
/* Replacements should happen only in the marked region. */ /* Replacements should happen only in the marked region. */
openfile->mark_set = old_mark_set; openfile->mark_set = old_mark_set;
#endif #endif
do_replace_loop(TRUE, current_save, &current_x_save, word); do_replace_loop(word, TRUE, current_save, &current_x_save);
/* TRANSLATORS: Shown after fixing misspellings in one word. */ /* TRANSLATORS: Shown after fixing misspellings in one word. */
statusbar(_("Next word...")); statusbar(_("Next word..."));