X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=grep.h;h=fb205f354231c0e50026c6e7fbfae5e288620611;hb=8eb865ba8a24aad5380a23fc1e331aba2f7c5bbb;hp=970308799664fe6a3871c0b8364c13e43cf96e1f;hpb=03f94ae9f909952ed5a78917ab319a312889354b;p=git.git diff --git a/grep.h b/grep.h index 970308799..fb205f354 100644 --- a/grep.h +++ b/grep.h @@ -1,6 +1,14 @@ #ifndef GREP_H #define GREP_H #include "color.h" +#ifdef USE_LIBPCRE +#include +#else +typedef int pcre; +typedef int pcre_extra; +#endif +#include "kwset.h" +#include "thread-utils.h" enum grep_pat_token { GREP_PATTERN, @@ -10,18 +18,19 @@ enum grep_pat_token { GREP_OPEN_PAREN, GREP_CLOSE_PAREN, GREP_NOT, - GREP_OR, + GREP_OR }; enum grep_context { GREP_CONTEXT_HEAD, - GREP_CONTEXT_BODY, + GREP_CONTEXT_BODY }; enum grep_header_field { GREP_HEADER_AUTHOR = 0, - GREP_HEADER_COMMITTER, + GREP_HEADER_COMMITTER }; +#define GREP_HEADER_FIELD_MAX (GREP_HEADER_COMMITTER + 1) struct grep_pat { struct grep_pat *next; @@ -29,8 +38,12 @@ struct grep_pat { int no; enum grep_pat_token token; const char *pattern; + size_t patternlen; enum grep_header_field field; regex_t regexp; + pcre *pcre_regexp; + pcre_extra *pcre_extra_info; + kwset_t kws; unsigned fixed:1; unsigned ignore_case:1; unsigned word_regexp:1; @@ -40,7 +53,8 @@ enum grep_expr_node { GREP_NODE_ATOM, GREP_NODE_NOT, GREP_NODE_AND, - GREP_NODE_OR, + GREP_NODE_TRUE, + GREP_NODE_OR }; struct grep_expr { @@ -59,6 +73,8 @@ struct grep_expr { struct grep_opt { struct grep_pat *pattern_list; struct grep_pat **pattern_tail; + struct grep_pat *header_list; + struct grep_pat **header_tail; struct grep_expr *pattern_expression; const char *prefix; int prefix_length; @@ -78,24 +94,36 @@ struct grep_opt { #define GREP_BINARY_TEXT 2 int binary; int extended; + int pcre; int relative; int pathname; int null_following_name; int color; int max_depth; int funcname; + int funcbody; + char color_context[COLOR_MAXLEN]; + char color_filename[COLOR_MAXLEN]; + char color_function[COLOR_MAXLEN]; + char color_lineno[COLOR_MAXLEN]; char color_match[COLOR_MAXLEN]; + char color_selected[COLOR_MAXLEN]; + char color_sep[COLOR_MAXLEN]; int regflags; unsigned pre_context; unsigned post_context; unsigned last_shown; int show_hunk_mark; + int file_break; + int heading; + int use_threads; void *priv; void (*output)(struct grep_opt *opt, const void *data, size_t size); void *output_priv; }; +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); extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t); extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *); extern void compile_grep_patterns(struct grep_opt *opt); @@ -105,4 +133,12 @@ extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsign extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt); extern int grep_threads_ok(const struct grep_opt *opt); +#ifndef NO_PTHREADS +/* + * Mutex used around access to the attributes machinery if + * opt->use_threads. Must be initialized/destroyed by callers! + */ +extern pthread_mutex_t grep_attr_mutex; +#endif + #endif