Add binary type instead of relying on special numbers. Add search_results_t.
This commit is contained in:
parent
d19e6f8498
commit
119c9c1111
2 changed files with 21 additions and 1 deletions
|
|
@ -37,6 +37,7 @@ void search_buf(const char *buf, const size_t buf_len,
|
|||
}
|
||||
|
||||
if (!opts.literal && opts.query_len == 1 && opts.query[0] == '.') {
|
||||
/* Don't even PCRE, just match everything */
|
||||
matches_size = 1;
|
||||
matches = matches == NULL ? ag_malloc(matches_size * sizeof(match_t)) : matches;
|
||||
matches[0].start = 0;
|
||||
|
|
|
|||
21
src/util.h
21
src/util.h
|
|
@ -28,11 +28,31 @@ void *ag_calloc(size_t nelem, size_t elsize);
|
|||
char *ag_strdup(const char *s);
|
||||
char *ag_strndup(const char *s, size_t size);
|
||||
|
||||
typedef enum {
|
||||
AG_BINARY_UNKNOWN,
|
||||
AG_BINARY_FALSE,
|
||||
AG_BINARY_TRUE
|
||||
} ag_binary_type;
|
||||
|
||||
typedef enum {
|
||||
AG_NO_COMPRESSION,
|
||||
AG_GZIP,
|
||||
AG_COMPRESS,
|
||||
AG_ZIP
|
||||
} ag_compression_type;
|
||||
|
||||
typedef struct {
|
||||
size_t start; /* Byte at which the match starts */
|
||||
size_t end; /* and where it ends */
|
||||
} match_t;
|
||||
|
||||
typedef struct {
|
||||
match_t *matches;
|
||||
size_t matches_len;
|
||||
size_t matches_size;
|
||||
ag_binary_type binary;
|
||||
} search_results_t;
|
||||
|
||||
typedef struct {
|
||||
long total_bytes;
|
||||
long total_files;
|
||||
|
|
@ -42,7 +62,6 @@ typedef struct {
|
|||
struct timeval time_end;
|
||||
} ag_stats;
|
||||
|
||||
|
||||
ag_stats stats;
|
||||
|
||||
typedef const char *(*strncmp_fp)(const char *, const char *, const size_t, const size_t, const size_t[], const size_t *);
|
||||
|
|
|
|||
Loading…
Reference in a new issue