Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 95 lines (85 sloc) 1.976 kb
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
1 #ifndef GREP_H
2 #define GREP_H
7e8f59d grep: color patterns in output
René Scharfe authored
3 #include "color.h"
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
4
5 enum grep_pat_token {
6 GREP_PATTERN,
480c1ca Update grep internal for grepping only in head/body
Junio C Hamano authored
7 GREP_PATTERN_HEAD,
8 GREP_PATTERN_BODY,
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
9 GREP_AND,
10 GREP_OPEN_PAREN,
11 GREP_CLOSE_PAREN,
12 GREP_NOT,
13 GREP_OR,
14 };
15
480c1ca Update grep internal for grepping only in head/body
Junio C Hamano authored
16 enum grep_context {
17 GREP_CONTEXT_HEAD,
18 GREP_CONTEXT_BODY,
19 };
20
a4d7d2c @gitster log --author/--committer: really match only with name part
gitster authored
21 enum grep_header_field {
22 GREP_HEADER_AUTHOR = 0,
23 GREP_HEADER_COMMITTER,
24 };
25
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
26 struct grep_pat {
27 struct grep_pat *next;
28 const char *origin;
29 int no;
30 enum grep_pat_token token;
31 const char *pattern;
a4d7d2c @gitster log --author/--committer: really match only with name part
gitster authored
32 enum grep_header_field field;
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
33 regex_t regexp;
c822255 grep: don't call regexec() for fixed strings
René Scharfe authored
34 unsigned fixed:1;
d7eb527 grep: remove grep_opt argument from match_expr_eval()
René Scharfe authored
35 unsigned word_regexp:1;
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
36 };
37
38 enum grep_expr_node {
39 GREP_NODE_ATOM,
40 GREP_NODE_NOT,
41 GREP_NODE_AND,
42 GREP_NODE_OR,
43 };
44
45 struct grep_expr {
46 enum grep_expr_node node;
0ab7bef grep --all-match
Junio C Hamano authored
47 unsigned hit;
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
48 union {
49 struct grep_pat *atom;
50 struct grep_expr *unary;
51 struct {
52 struct grep_expr *left;
53 struct grep_expr *right;
54 } binary;
55 } u;
56 };
57
58 struct grep_opt {
59 struct grep_pat *pattern_list;
60 struct grep_pat **pattern_tail;
61 struct grep_expr *pattern_expression;
62 int prefix_length;
63 regex_t regexp;
64 unsigned linenum:1;
65 unsigned invert:1;
66 unsigned status_only:1;
67 unsigned name_only:1;
68 unsigned unmatch_name_only:1;
69 unsigned count:1;
70 unsigned word_regexp:1;
71 unsigned fixed:1;
0ab7bef grep --all-match
Junio C Hamano authored
72 unsigned all_match:1;
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
73 #define GREP_BINARY_DEFAULT 0
74 #define GREP_BINARY_NOMATCH 1
75 #define GREP_BINARY_TEXT 2
76 unsigned binary:2;
77 unsigned extended:1;
78 unsigned relative:1;
79 unsigned pathname:1;
83caecc git grep: Add "-z/--null" option as in GNU's grep.
Raphael Zimmerer authored
80 unsigned null_following_name:1;
7e8f59d grep: color patterns in output
René Scharfe authored
81 int color;
82 char color_match[COLOR_MAXLEN];
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
83 int regflags;
84 unsigned pre_context;
85 unsigned post_context;
86 };
87
88 extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
a4d7d2c @gitster log --author/--committer: really match only with name part
gitster authored
89 extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
90 extern void compile_grep_patterns(struct grep_opt *opt);
b48fb5b grep: free expressions and patterns when done.
Junio C Hamano authored
91 extern void free_grep_patterns(struct grep_opt *opt);
83b5d2f builtin-grep: make pieces of it available as library.
Junio C Hamano authored
92 extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
93
94 #endif
Something went wrong with that request. Please try again.