]> git.ipfire.org Git - thirdparty/git.git/blame - grep.h
git-log --author and --committer are not left-anchored by default
[thirdparty/git.git] / grep.h
CommitLineData
83b5d2f5
JH
1#ifndef GREP_H
2#define GREP_H
3
4enum grep_pat_token {
5 GREP_PATTERN,
6 GREP_AND,
7 GREP_OPEN_PAREN,
8 GREP_CLOSE_PAREN,
9 GREP_NOT,
10 GREP_OR,
11};
12
13struct grep_pat {
14 struct grep_pat *next;
15 const char *origin;
16 int no;
17 enum grep_pat_token token;
18 const char *pattern;
19 regex_t regexp;
20};
21
22enum grep_expr_node {
23 GREP_NODE_ATOM,
24 GREP_NODE_NOT,
25 GREP_NODE_AND,
26 GREP_NODE_OR,
27};
28
29struct grep_expr {
30 enum grep_expr_node node;
31 union {
32 struct grep_pat *atom;
33 struct grep_expr *unary;
34 struct {
35 struct grep_expr *left;
36 struct grep_expr *right;
37 } binary;
38 } u;
39};
40
41struct grep_opt {
42 struct grep_pat *pattern_list;
43 struct grep_pat **pattern_tail;
44 struct grep_expr *pattern_expression;
45 int prefix_length;
46 regex_t regexp;
47 unsigned linenum:1;
48 unsigned invert:1;
49 unsigned status_only:1;
50 unsigned name_only:1;
51 unsigned unmatch_name_only:1;
52 unsigned count:1;
53 unsigned word_regexp:1;
54 unsigned fixed:1;
55#define GREP_BINARY_DEFAULT 0
56#define GREP_BINARY_NOMATCH 1
57#define GREP_BINARY_TEXT 2
58 unsigned binary:2;
59 unsigned extended:1;
60 unsigned relative:1;
61 unsigned pathname:1;
62 int regflags;
63 unsigned pre_context;
64 unsigned post_context;
65};
66
67extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
68extern void compile_grep_patterns(struct grep_opt *opt);
69extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
70
71#endif