tweaks: set the length of a search match in a clearer manner
parent
121c53f3b8
commit
e36e829ad0
13
src/search.c
13
src/search.c
|
@ -234,8 +234,8 @@ int search_init(bool replacing, bool use_answer)
|
||||||
int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||||
const filestruct *begin, size_t begin_x)
|
const filestruct *begin, size_t begin_x)
|
||||||
{
|
{
|
||||||
size_t found_len;
|
size_t found_len = strlen(needle);
|
||||||
/* The length of the match we find. */
|
/* The length of a match -- will be recomputed for a regex. */
|
||||||
int feedback = 0;
|
int feedback = 0;
|
||||||
/* When bigger than zero, show and wipe the "Searching..." message. */
|
/* When bigger than zero, show and wipe the "Searching..." message. */
|
||||||
filestruct *fileptr = openfile->current;
|
filestruct *fileptr = openfile->current;
|
||||||
|
@ -290,14 +290,11 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len,
|
||||||
found = strstrwrapper(fileptr->data, needle, rev_start);
|
found = strstrwrapper(fileptr->data, needle, rev_start);
|
||||||
|
|
||||||
if (found != NULL) {
|
if (found != NULL) {
|
||||||
/* Remember the length of the potential match. */
|
|
||||||
found_len =
|
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
ISSET(USE_REGEXP) ?
|
/* When doing a regex search, compute the length of the match. */
|
||||||
regmatches[0].rm_eo - regmatches[0].rm_so :
|
if (ISSET(USE_REGEXP))
|
||||||
|
found_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||||
#endif
|
#endif
|
||||||
strlen(needle);
|
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
/* When we're spell checking, a match is only a true match when
|
/* When we're spell checking, a match is only a true match when
|
||||||
* it is a separate word. */
|
* it is a separate word. */
|
||||||
|
|
Loading…
Reference in New Issue