grep.hon commit reset: add test cases for "--keep" option (ffbc5dc)
   1#ifndef GREP_H
   2#define GREP_H
   3#include "color.h"
   4
   5enum grep_pat_token {
   6        GREP_PATTERN,
   7        GREP_PATTERN_HEAD,
   8        GREP_PATTERN_BODY,
   9        GREP_AND,
  10        GREP_OPEN_PAREN,
  11        GREP_CLOSE_PAREN,
  12        GREP_NOT,
  13        GREP_OR,
  14};
  15
  16enum grep_context {
  17        GREP_CONTEXT_HEAD,
  18        GREP_CONTEXT_BODY,
  19};
  20
  21enum grep_header_field {
  22        GREP_HEADER_AUTHOR = 0,
  23        GREP_HEADER_COMMITTER,
  24};
  25
  26struct grep_pat {
  27        struct grep_pat *next;
  28        const char *origin;
  29        int no;
  30        enum grep_pat_token token;
  31        const char *pattern;
  32        enum grep_header_field field;
  33        regex_t regexp;
  34        unsigned fixed:1;
  35        unsigned ignore_case:1;
  36        unsigned word_regexp:1;
  37};
  38
  39enum grep_expr_node {
  40        GREP_NODE_ATOM,
  41        GREP_NODE_NOT,
  42        GREP_NODE_AND,
  43        GREP_NODE_OR,
  44};
  45
  46struct grep_expr {
  47        enum grep_expr_node node;
  48        unsigned hit;
  49        union {
  50                struct grep_pat *atom;
  51                struct grep_expr *unary;
  52                struct {
  53                        struct grep_expr *left;
  54                        struct grep_expr *right;
  55                } binary;
  56        } u;
  57};
  58
  59struct grep_opt {
  60        struct grep_pat *pattern_list;
  61        struct grep_pat **pattern_tail;
  62        struct grep_expr *pattern_expression;
  63        const char *prefix;
  64        int prefix_length;
  65        regex_t regexp;
  66        int linenum;
  67        int invert;
  68        int ignore_case;
  69        int status_only;
  70        int name_only;
  71        int unmatch_name_only;
  72        int count;
  73        int word_regexp;
  74        int fixed;
  75        int all_match;
  76#define GREP_BINARY_DEFAULT     0
  77#define GREP_BINARY_NOMATCH     1
  78#define GREP_BINARY_TEXT        2
  79        int binary;
  80        int extended;
  81        int relative;
  82        int pathname;
  83        int null_following_name;
  84        int color;
  85        int max_depth;
  86        int funcname;
  87        char color_match[COLOR_MAXLEN];
  88        int regflags;
  89        unsigned pre_context;
  90        unsigned post_context;
  91        unsigned last_shown;
  92        int show_hunk_mark;
  93        void *priv;
  94};
  95
  96extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
  97extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);
  98extern void compile_grep_patterns(struct grep_opt *opt);
  99extern void free_grep_patterns(struct grep_opt *opt);
 100extern int grep_buffer(struct grep_opt *opt, const char *name, char *buf, unsigned long size);
 101
 102#endif