6 #ifndef PCRE_NO_UTF8_CHECK
7 #define PCRE_NO_UTF8_CHECK 0
10 #if PCRE_MAJOR >= 8 && PCRE_MINOR >= 32
11 #ifndef NO_LIBPCRE1_JIT
12 #define GIT_PCRE1_USE_JIT
13 #define GIT_PCRE_STUDY_JIT_COMPILE PCRE_STUDY_JIT_COMPILE
17 #ifndef GIT_PCRE_STUDY_JIT_COMPILE
18 #define GIT_PCRE_STUDY_JIT_COMPILE 0
20 #if PCRE_MAJOR <= 8 && PCRE_MINOR < 20
21 typedef int pcre_jit_stack
;
25 typedef int pcre_extra
;
26 typedef int pcre_jit_stack
;
29 #define PCRE2_CODE_UNIT_WIDTH 8
32 typedef int pcre2_code
;
33 typedef int pcre2_match_data
;
34 typedef int pcre2_compile_context
;
35 typedef int pcre2_match_context
;
36 typedef int pcre2_jit_stack
;
39 #include "thread-utils.h"
60 enum grep_header_field
{
61 GREP_HEADER_FIELD_MIN
= 0,
62 GREP_HEADER_AUTHOR
= GREP_HEADER_FIELD_MIN
,
63 GREP_HEADER_COMMITTER
,
66 /* Must be at the end of the enum */
76 GREP_COLOR_MATCH_CONTEXT
,
77 GREP_COLOR_MATCH_SELECTED
,
84 struct grep_pat
*next
;
87 enum grep_pat_token token
;
90 enum grep_header_field field
;
93 pcre_extra
*pcre1_extra_info
;
94 pcre_jit_stack
*pcre1_jit_stack
;
95 const unsigned char *pcre1_tables
;
97 pcre2_code
*pcre2_pattern
;
98 pcre2_match_data
*pcre2_match_data
;
99 pcre2_compile_context
*pcre2_compile_context
;
100 pcre2_match_context
*pcre2_match_context
;
101 pcre2_jit_stack
*pcre2_jit_stack
;
102 uint32_t pcre2_jit_on
;
105 unsigned ignore_case
:1;
106 unsigned word_regexp
:1;
109 enum grep_expr_node
{
117 enum grep_pattern_type
{
118 GREP_PATTERN_TYPE_UNSPECIFIED
= 0,
119 GREP_PATTERN_TYPE_BRE
,
120 GREP_PATTERN_TYPE_ERE
,
121 GREP_PATTERN_TYPE_FIXED
,
122 GREP_PATTERN_TYPE_PCRE
126 enum grep_expr_node node
;
129 struct grep_pat
*atom
;
130 struct grep_expr
*unary
;
132 struct grep_expr
*left
;
133 struct grep_expr
*right
;
139 struct grep_pat
*pattern_list
;
140 struct grep_pat
**pattern_tail
;
141 struct grep_pat
*header_list
;
142 struct grep_pat
**header_tail
;
143 struct grep_expr
*pattern_expression
;
144 struct repository
*repo
;
154 int unmatch_name_only
;
160 #define GREP_BINARY_DEFAULT 0
161 #define GREP_BINARY_NOMATCH 1
162 #define GREP_BINARY_TEXT 2
166 int use_reflog_filter
;
171 int null_following_name
;
177 int extended_regexp_option
;
178 int pattern_type_option
;
179 char colors
[NR_GREP_COLORS
][COLOR_MAXLEN
];
180 unsigned pre_context
;
181 unsigned post_context
;
188 void (*output
)(struct grep_opt
*opt
, const void *data
, size_t size
);
192 void init_grep_defaults(struct repository
*);
193 int grep_config(const char *var
, const char *value
, void *);
194 void grep_init(struct grep_opt
*, struct repository
*repo
, const char *prefix
);
195 void grep_commit_pattern_type(enum grep_pattern_type
, struct grep_opt
*opt
);
197 void append_grep_pat(struct grep_opt
*opt
, const char *pat
, size_t patlen
, const char *origin
, int no
, enum grep_pat_token t
);
198 void append_grep_pattern(struct grep_opt
*opt
, const char *pat
, const char *origin
, int no
, enum grep_pat_token t
);
199 void append_header_grep_pattern(struct grep_opt
*, enum grep_header_field
, const char *);
200 void compile_grep_patterns(struct grep_opt
*opt
);
201 void free_grep_patterns(struct grep_opt
*opt
);
202 int grep_buffer(struct grep_opt
*opt
, char *buf
, unsigned long size
);
207 enum grep_source_type
{
217 char *path
; /* for attribute lookups */
218 struct userdiff_driver
*driver
;
221 void grep_source_init(struct grep_source
*gs
, enum grep_source_type type
,
222 const char *name
, const char *path
,
223 const void *identifier
);
224 void grep_source_clear_data(struct grep_source
*gs
);
225 void grep_source_clear(struct grep_source
*gs
);
226 void grep_source_load_driver(struct grep_source
*gs
,
227 struct index_state
*istate
);
230 int grep_source(struct grep_opt
*opt
, struct grep_source
*gs
);
232 struct grep_opt
*grep_opt_dup(const struct grep_opt
*opt
);
233 int grep_threads_ok(const struct grep_opt
*opt
);
236 * Mutex used around access to the attributes machinery if
237 * opt->use_threads. Must be initialized/destroyed by callers!
239 extern int grep_use_locks
;
240 extern pthread_mutex_t grep_attr_mutex
;
241 extern pthread_mutex_t grep_read_mutex
;
243 static inline void grep_read_lock(void)
246 pthread_mutex_lock(&grep_read_mutex
);
249 static inline void grep_read_unlock(void)
252 pthread_mutex_unlock(&grep_read_mutex
);