]> git.ipfire.org Git - thirdparty/git.git/blame - grep.h
grep -w: forward to next possible position after rejected match
[thirdparty/git.git] / grep.h
CommitLineData
83b5d2f5
JH
1#ifndef GREP_H
2#define GREP_H
3
4enum grep_pat_token {
5 GREP_PATTERN,
480c1ca6
JH
6 GREP_PATTERN_HEAD,
7 GREP_PATTERN_BODY,
83b5d2f5
JH
8 GREP_AND,
9 GREP_OPEN_PAREN,
10 GREP_CLOSE_PAREN,
11 GREP_NOT,
12 GREP_OR,
13};
14
480c1ca6
JH
15enum grep_context {
16 GREP_CONTEXT_HEAD,
17 GREP_CONTEXT_BODY,
18};
19
a4d7d2c6
JH
20enum grep_header_field {
21 GREP_HEADER_AUTHOR = 0,
22 GREP_HEADER_COMMITTER,
23};
24
83b5d2f5
JH
25struct grep_pat {
26 struct grep_pat *next;
27 const char *origin;
28 int no;
29 enum grep_pat_token token;
30 const char *pattern;
a4d7d2c6 31 enum grep_header_field field;
83b5d2f5
JH
32 regex_t regexp;
33};
34
35enum grep_expr_node {
36 GREP_NODE_ATOM,
37 GREP_NODE_NOT,
38 GREP_NODE_AND,
39 GREP_NODE_OR,
40};
41
42struct grep_expr {
43 enum grep_expr_node node;
0ab7befa 44 unsigned hit;
83b5d2f5
JH
45 union {
46 struct grep_pat *atom;
47 struct grep_expr *unary;
48 struct {
49 struct grep_expr *left;
50 struct grep_expr *right;
51 } binary;
52 } u;
53};
54
55struct grep_opt {
56 struct grep_pat *pattern_list;
57 struct grep_pat **pattern_tail;
58 struct grep_expr *pattern_expression;
59 int prefix_length;
60 regex_t regexp;
61 unsigned linenum:1;
62 unsigned invert:1;
63 unsigned status_only:1;
64 unsigned name_only:1;
65 unsigned unmatch_name_only:1;
66 unsigned count:1;
67 unsigned word_regexp:1;
68 unsigned fixed:1;
0ab7befa 69 unsigned all_match:1;
83b5d2f5
JH
70#define GREP_BINARY_DEFAULT 0
71#define GREP_BINARY_NOMATCH 1
72#define GREP_BINARY_TEXT 2
73 unsigned binary:2;
74 unsigned extended:1;
75 unsigned relative:1;
76 unsigned pathname:1;
83caecca 77 unsigned null_following_name:1;
83b5d2f5
JH
78 int regflags;
79 unsigned pre_context;
80 unsigned post_context;
81};
82
83extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
a4d7d2c6 84extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
83b5d2f5 85extern void compile_grep_patterns(struct grep_opt *opt);
b48fb5b6 86extern void free_grep_patterns(struct grep_opt *opt);
83b5d2f5
JH
87extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
88
89#endif