Skip to content

Commit aa77855

Browse files
authored
Merge pull request #539 from MKadaner/mzk-search-string
Fixed two bugs in the string search algorithm.
2 parents a6c59d3 + c4a19f5 commit aa77855

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

far/changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
--------------------------------------------------------------------------------
2+
MZK 06.08.2022 18:26:39 -0700 - build 6010
3+
4+
1. Fixed two bugs in the string search algorithm.
5+
16
--------------------------------------------------------------------------------
27
drkns 06.08.2022 15:34:28 +0100 - build 6009
38

far/findfile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,9 +1222,9 @@ bool background_searcher::LookForString(string_view const FileName)
12221222

12231223
string_view Where{ buffer, bufferCount };
12241224

1225-
const auto Next = [&](size_t const Offset, size_t const Size)
1225+
const auto Next = [&](size_t const Offset)
12261226
{
1227-
Where.remove_prefix(Offset + Size);
1227+
Where.remove_prefix(Offset + 1);
12281228
};
12291229

12301230
while (!Where.empty())
@@ -1262,7 +1262,7 @@ bool background_searcher::LookForString(string_view const FileName)
12621262
firstWordDiv = true;
12631263
}
12641264

1265-
// Проверяем разделитель в конце, только если найден разделитель вначале
1265+
// Проверяем разделитель в конце, только если найден разделитель в начале
12661266
if (firstWordDiv)
12671267
{
12681268
// Если блок выбран не до конца
@@ -1278,7 +1278,7 @@ bool background_searcher::LookForString(string_view const FileName)
12781278
i.WordFound = true;
12791279
}
12801280

1281-
Next(FoundOffset, FoundSize);
1281+
Next(FoundOffset);
12821282
}
12831283

12841284
// Выходим, если мы вышли за пределы количества байт разрешённых для поиска

far/strmix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,11 +920,11 @@ bool SearchAndReplaceString(
920920
Haystack.substr(0, Position + 1) :
921921
Haystack.substr(Position);
922922

923-
const auto Next = [&](size_t const Offset, size_t const Size)
923+
const auto Next = [&](size_t const Offset)
924924
{
925925
Where = Reverse?
926-
Where.substr(0, Offset - Size + 1) :
927-
Where.substr(Offset + Size);
926+
Where.substr(0, Offset > 0? Offset - 1 : 0) :
927+
Where.substr(Offset + 1);
928928
};
929929

930930
while (!Where.empty())
@@ -939,7 +939,7 @@ bool SearchAndReplaceString(
939939

940940
if (WholeWords && !CanContainWholeWord(Haystack, AbsoluteOffset, FoundSize, WordDiv))
941941
{
942-
Next(FoundOffset, FoundSize);
942+
Next(FoundOffset);
943943
continue;
944944
}
945945

far/vbuild.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6009
1+
6010

0 commit comments

Comments
 (0)