-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathscorer.h
More file actions
52 lines (40 loc) · 1.16 KB
/
scorer.h
File metadata and controls
52 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef SCORER_H
#define SCORER_H
#include <limits.h>
struct scorer_query {
const char *pattern;
int right_match;
};
struct filter_result {
int index;
int score;
int dirscore;
short last_match_pos;
short first_dir_match_pos;
};
struct prepared_pattern {
char *translated_pattern;
char *start_of_pattern_word;
unsigned pat_length;
char first_chars[8];
char fc_count;
};
extern int scorer_utf8_mode; // on by default
static inline
int utf8_continuation_p(char p)
{
return (p & 0xc0) == 0x80;
}
// signals that there are no highlight-able match in this pattern position
#define SCORER_MATCH_NONE UINT_MAX
int score_string(const char *string, const struct scorer_query *query, const unsigned string_length, unsigned* match);
int score_simple_string(const char *string, const char *pattern, unsigned *match);
struct prepared_pattern *prepare_pattern(const struct scorer_query *query);
void free_prepared_pattern(struct prepared_pattern *p);
int score_string_prepared(const char *string,
const struct scorer_query *query,
const struct prepared_pattern *prepared_pattern,
const unsigned string_length,
unsigned* match);
void prepare_scorer(void);
#endif