Previously a successful match was determined by the score being
positive. Now we will use has_match instead.
| ... | ... |
@@ -77,8 +77,8 @@ void run_search(char *needle){
|
| 77 | 77 |
choices_available = 0; |
| 78 | 78 |
int i; |
| 79 | 79 |
for(i = 0; i < choices_n; i++){
|
| 80 |
- choices_score[i] = match(needle, choices[i]); |
|
| 81 |
- if(choices_score[i] >= 0.0){
|
|
| 80 |
+ if(has_match(needle, choices[i])){
|
|
| 81 |
+ choices_score[i] = match(needle, choices[i]); |
|
| 82 | 82 |
choices_sorted[choices_available++] = i; |
| 83 | 83 |
} |
| 84 | 84 |
} |
| ... | ... |
@@ -7,7 +7,7 @@ |
| 7 | 7 |
|
| 8 | 8 |
#define SCORE_MIN -1 |
| 9 | 9 |
|
| 10 |
-static int is_subset(const char *needle, const char *haystack){
|
|
| 10 |
+int has_match(const char *needle, const char *haystack){
|
|
| 11 | 11 |
while(*needle){
|
| 12 | 12 |
if(!*haystack) |
| 13 | 13 |
return 0; |
| ... | ... |
@@ -115,7 +115,7 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio |
| 115 | 115 |
double match_positions(const char *needle, const char *haystack, size_t *positions){
|
| 116 | 116 |
if(!*needle){
|
| 117 | 117 |
return 1.0; |
| 118 |
- }else if(!is_subset(needle, haystack)){
|
|
| 118 |
+ }else if(!has_match(needle, haystack)){
|
|
| 119 | 119 |
return SCORE_MIN; |
| 120 | 120 |
}else if(!strcasecmp(needle, haystack)){
|
| 121 | 121 |
if(positions){
|