6 #ifndef PCRE_STUDY_JIT_COMPILE
7 #define PCRE_STUDY_JIT_COMPILE 0
11 typedef int pcre_extra
;
12 typedef int pcre_jit_stack
;
15 #include "thread-utils.h"
34 enum grep_header_field
{
35 GREP_HEADER_FIELD_MIN
= 0,
36 GREP_HEADER_AUTHOR
= GREP_HEADER_FIELD_MIN
,
37 GREP_HEADER_COMMITTER
,
40 /* Must be at the end of the enum */
45 struct grep_pat
*next
;
48 enum grep_pat_token token
;
51 enum grep_header_field field
;
54 pcre_extra
*pcre1_extra_info
;
55 pcre_jit_stack
*pcre1_jit_stack
;
56 const unsigned char *pcre1_tables
;
60 unsigned ignore_case
:1;
61 unsigned word_regexp
:1;
72 enum grep_pattern_type
{
73 GREP_PATTERN_TYPE_UNSPECIFIED
= 0,
74 GREP_PATTERN_TYPE_BRE
,
75 GREP_PATTERN_TYPE_ERE
,
76 GREP_PATTERN_TYPE_FIXED
,
77 GREP_PATTERN_TYPE_PCRE
81 enum grep_expr_node node
;
84 struct grep_pat
*atom
;
85 struct grep_expr
*unary
;
87 struct grep_expr
*left
;
88 struct grep_expr
*right
;
94 struct grep_pat
*pattern_list
;
95 struct grep_pat
**pattern_tail
;
96 struct grep_pat
*header_list
;
97 struct grep_pat
**header_tail
;
98 struct grep_expr
*pattern_expression
;
107 int unmatch_name_only
;
113 #define GREP_BINARY_DEFAULT 0
114 #define GREP_BINARY_NOMATCH 1
115 #define GREP_BINARY_TEXT 2
119 int use_reflog_filter
;
123 int null_following_name
;
128 int extended_regexp_option
;
129 int pattern_type_option
;
130 char color_context
[COLOR_MAXLEN
];
131 char color_filename
[COLOR_MAXLEN
];
132 char color_function
[COLOR_MAXLEN
];
133 char color_lineno
[COLOR_MAXLEN
];
134 char color_match_context
[COLOR_MAXLEN
];
135 char color_match_selected
[COLOR_MAXLEN
];
136 char color_selected
[COLOR_MAXLEN
];
137 char color_sep
[COLOR_MAXLEN
];
139 unsigned pre_context
;
140 unsigned post_context
;
147 void (*output
)(struct grep_opt
*opt
, const void *data
, size_t size
);
151 extern void init_grep_defaults(void);
152 extern int grep_config(const char *var
, const char *value
, void *);
153 extern void grep_init(struct grep_opt
*, const char *prefix
);
154 void grep_commit_pattern_type(enum grep_pattern_type
, struct grep_opt
*opt
);
156 extern void append_grep_pat(struct grep_opt
*opt
, const char *pat
, size_t patlen
, const char *origin
, int no
, enum grep_pat_token t
);
157 extern void append_grep_pattern(struct grep_opt
*opt
, const char *pat
, const char *origin
, int no
, enum grep_pat_token t
);
158 extern void append_header_grep_pattern(struct grep_opt
*, enum grep_header_field
, const char *);
159 extern void compile_grep_patterns(struct grep_opt
*opt
);
160 extern void free_grep_patterns(struct grep_opt
*opt
);
161 extern int grep_buffer(struct grep_opt
*opt
, char *buf
, unsigned long size
);
166 enum grep_source_type
{
170 GREP_SOURCE_SUBMODULE
,
177 char *path
; /* for attribute lookups */
178 struct userdiff_driver
*driver
;
181 void grep_source_init(struct grep_source
*gs
, enum grep_source_type type
,
182 const char *name
, const char *path
,
183 const void *identifier
);
184 void grep_source_clear_data(struct grep_source
*gs
);
185 void grep_source_clear(struct grep_source
*gs
);
186 void grep_source_load_driver(struct grep_source
*gs
);
189 int grep_source(struct grep_opt
*opt
, struct grep_source
*gs
);
191 extern struct grep_opt
*grep_opt_dup(const struct grep_opt
*opt
);
192 extern int grep_threads_ok(const struct grep_opt
*opt
);
196 * Mutex used around access to the attributes machinery if
197 * opt->use_threads. Must be initialized/destroyed by callers!
199 extern int grep_use_locks
;
200 extern pthread_mutex_t grep_attr_mutex
;
201 extern pthread_mutex_t grep_read_mutex
;
203 static inline void grep_read_lock(void)
206 pthread_mutex_lock(&grep_read_mutex
);
209 static inline void grep_read_unlock(void)
212 pthread_mutex_unlock(&grep_read_mutex
);
216 #define grep_read_lock()
217 #define grep_read_unlock()