fixed some bugs in the new word complete
parent
0d5f6e82d3
commit
174ff25d1a
|
@ -50,7 +50,7 @@ search_iter_init(Application_Links *app, Search_Iter *iter, int size){
|
||||||
iter->word.memory_size = str_max;
|
iter->word.memory_size = str_max;
|
||||||
}
|
}
|
||||||
iter->i = 0;
|
iter->i = 0;
|
||||||
iter->pos = 0;
|
iter->range_initialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -221,10 +221,12 @@ search_front_to_back_step(Application_Links *app,
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
found_match = FindResult_PastEnd;
|
found_match = FindResult_PastEnd;
|
||||||
|
*pos = end_pos + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
found_match = FindResult_PastEnd;
|
found_match = FindResult_PastEnd;
|
||||||
|
*pos = end_pos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*result_ptr = result;
|
*result_ptr = result;
|
||||||
|
@ -232,6 +234,19 @@ search_front_to_back_step(Application_Links *app,
|
||||||
return(found_match);
|
return(found_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
search_front_to_back(Application_Links *app,
|
||||||
|
Search_Range *range,
|
||||||
|
String word,
|
||||||
|
int *pos,
|
||||||
|
Search_Match *result_ptr){
|
||||||
|
int found_match = FindResult_None;
|
||||||
|
for (;found_match == FindResult_None;){
|
||||||
|
found_match = search_front_to_back_step(app, range, word, pos, result_ptr);
|
||||||
|
}
|
||||||
|
return(found_match);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
search_back_to_front_step(Application_Links *app,
|
search_back_to_front_step(Application_Links *app,
|
||||||
Search_Range *range,
|
Search_Range *range,
|
||||||
|
@ -283,6 +298,19 @@ search_back_to_front_step(Application_Links *app,
|
||||||
return(found_match);
|
return(found_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
search_back_to_front(Application_Links *app,
|
||||||
|
Search_Range *range,
|
||||||
|
String word,
|
||||||
|
int *pos,
|
||||||
|
Search_Match *result_ptr){
|
||||||
|
int found_match = FindResult_None;
|
||||||
|
for (;found_match == FindResult_None;){
|
||||||
|
found_match = search_back_to_front_step(app, range, word, pos, result_ptr);
|
||||||
|
}
|
||||||
|
return(found_match);
|
||||||
|
}
|
||||||
|
|
||||||
static Search_Match
|
static Search_Match
|
||||||
search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
|
search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
|
||||||
Search_Match result = {0};
|
Search_Match result = {0};
|
||||||
|
@ -314,7 +342,7 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
|
||||||
case SearchRange_FrontToBack:
|
case SearchRange_FrontToBack:
|
||||||
{
|
{
|
||||||
find_result =
|
find_result =
|
||||||
search_front_to_back_step(app, range,
|
search_front_to_back(app, range,
|
||||||
iter.word,
|
iter.word,
|
||||||
&iter.pos,
|
&iter.pos,
|
||||||
&result);
|
&result);
|
||||||
|
@ -323,7 +351,7 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
|
||||||
case SearchRange_BackToFront:
|
case SearchRange_BackToFront:
|
||||||
{
|
{
|
||||||
find_result =
|
find_result =
|
||||||
search_back_to_front_step(app, range,
|
search_back_to_front(app, range,
|
||||||
iter.word,
|
iter.word,
|
||||||
&iter.back_pos,
|
&iter.back_pos,
|
||||||
&result);
|
&result);
|
||||||
|
@ -332,18 +360,24 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
|
||||||
case SearchRange_Wave:
|
case SearchRange_Wave:
|
||||||
{
|
{
|
||||||
Search_Match forward_match = {0};
|
Search_Match forward_match = {0};
|
||||||
int forward_result =
|
Search_Match backward_match = {0};
|
||||||
search_front_to_back_step(app, range,
|
|
||||||
|
int forward_result = FindResult_PastEnd;
|
||||||
|
int backward_result = FindResult_PastEnd;
|
||||||
|
|
||||||
|
if (iter.pos < range->start + range->size){
|
||||||
|
forward_result = search_front_to_back(app, range,
|
||||||
iter.word,
|
iter.word,
|
||||||
&iter.pos,
|
&iter.pos,
|
||||||
&forward_match);
|
&forward_match);
|
||||||
|
}
|
||||||
|
|
||||||
Search_Match backward_match = {0};
|
if (iter.back_pos > range->start){
|
||||||
int backward_result =
|
backward_result = search_back_to_front(app, range,
|
||||||
search_back_to_front_step(app, range,
|
|
||||||
iter.word,
|
iter.word,
|
||||||
&iter.back_pos,
|
&iter.back_pos,
|
||||||
&backward_match);
|
&backward_match);
|
||||||
|
}
|
||||||
|
|
||||||
if (forward_result == FindResult_FoundMatch){
|
if (forward_result == FindResult_FoundMatch){
|
||||||
if (backward_result == FindResult_FoundMatch){
|
if (backward_result == FindResult_FoundMatch){
|
||||||
|
@ -351,15 +385,15 @@ search_next_match(Application_Links *app, Search_Set *set, Search_Iter *it_ptr){
|
||||||
|
|
||||||
int forward_start = range->mid_start + range->mid_size;
|
int forward_start = range->mid_start + range->mid_size;
|
||||||
int forward_distance = (forward_match.start - forward_start);
|
int forward_distance = (forward_match.start - forward_start);
|
||||||
int backward_distance = (forward_match.end - range->mid_start);
|
int backward_distance = (range->mid_start - backward_match.end);
|
||||||
|
|
||||||
if (backward_distance < forward_distance){
|
if (backward_distance < forward_distance){
|
||||||
--iter.pos;
|
iter.pos = forward_match.start;
|
||||||
result = forward_match;
|
result = backward_match;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
++iter.back_pos;
|
iter.back_pos = backward_match.start;
|
||||||
result = backward_match;
|
result = forward_match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Distribution Date: 8.7.2016 (dd.mm.yyyy)
|
Distribution Date: 11.7.2016 (dd.mm.yyyy)
|
||||||
|
|
||||||
Thank you for contributing to the 4coder project!
|
Thank you for contributing to the 4coder project!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue