5 #define PCRE2_CODE_UNIT_WIDTH 8
8 typedef int pcre2_code;
9 typedef int pcre2_match_data;
10 typedef int pcre2_compile_context;
12 #ifndef PCRE2_MATCH_INVALID_UTF
13 /* PCRE2_MATCH_* dummy also with !USE_LIBPCRE2, for test-pcre2-config.c */
14 #define PCRE2_MATCH_INVALID_UTF 0
16 #include "thread-utils.h"
37 enum grep_header_field {
38 GREP_HEADER_FIELD_MIN = 0,
39 GREP_HEADER_AUTHOR = GREP_HEADER_FIELD_MIN,
40 GREP_HEADER_COMMITTER,
43 /* Must be at the end of the enum */
53 GREP_COLOR_MATCH_CONTEXT,
54 GREP_COLOR_MATCH_SELECTED,
61 struct grep_pat *next;
64 enum grep_pat_token token;
67 enum grep_header_field field;
69 pcre2_code *pcre2_pattern;
70 pcre2_match_data *pcre2_match_data;
71 pcre2_compile_context *pcre2_compile_context;
72 const uint8_t *pcre2_tables;
73 uint32_t pcre2_jit_on;
76 unsigned ignore_case:1;
77 unsigned word_regexp:1;
88 enum grep_pattern_type {
89 GREP_PATTERN_TYPE_UNSPECIFIED = 0,
90 GREP_PATTERN_TYPE_BRE,
91 GREP_PATTERN_TYPE_ERE,
92 GREP_PATTERN_TYPE_FIXED,
93 GREP_PATTERN_TYPE_PCRE
97 enum grep_expr_node node;
100 struct grep_pat *atom;
101 struct grep_expr *unary;
103 struct grep_expr *left;
104 struct grep_expr *right;
110 struct grep_pat *pattern_list;
111 struct grep_pat **pattern_tail;
112 struct grep_pat *header_list;
113 struct grep_pat **header_tail;
114 struct grep_expr *pattern_expression;
115 struct repository *repo;
125 int unmatch_name_only;
130 #define GREP_BINARY_DEFAULT 0
131 #define GREP_BINARY_NOMATCH 1
132 #define GREP_BINARY_TEXT 2
136 int use_reflog_filter;
140 int null_following_name;
146 int extended_regexp_option;
147 int pattern_type_option;
149 char colors[NR_GREP_COLORS][COLOR_MAXLEN];
150 unsigned pre_context;
151 unsigned post_context;
158 void (*output)(struct grep_opt *opt, const void *data, size_t size);
162 int grep_config(const char *var, const char *value, void *);
163 void grep_init(struct grep_opt *, struct repository *repo, const char *prefix);
164 void grep_destroy(void);
165 void grep_commit_pattern_type(enum grep_pattern_type, struct grep_opt *opt);
167 void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);
168 void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
169 void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
170 void compile_grep_patterns(struct grep_opt *opt);
171 void free_grep_patterns(struct grep_opt *opt);
172 int grep_buffer(struct grep_opt *opt, char *buf, unsigned long size);
177 enum grep_source_type {
187 char *path; /* for attribute lookups */
188 struct userdiff_driver *driver;
191 void grep_source_init(struct grep_source *gs, enum grep_source_type type,
192 const char *name, const char *path,
193 const void *identifier);
194 void grep_source_clear_data(struct grep_source *gs);
195 void grep_source_clear(struct grep_source *gs);
196 void grep_source_load_driver(struct grep_source *gs,
197 struct index_state *istate);
200 int grep_source(struct grep_opt *opt, struct grep_source *gs);
202 struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
203 int grep_threads_ok(const struct grep_opt *opt);
206 * Mutex used around access to the attributes machinery if
207 * opt->use_threads. Must be initialized/destroyed by callers!
209 extern int grep_use_locks;
210 extern pthread_mutex_t grep_attr_mutex;