Skip to contentSkip to conversation

builtin-grep: make pieces of it available as library.

PATCH In review Junio C Hamano 1 participant 1 message Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 builtin-grep: make pieces of it available as library.

This makes three functions and associated option structures from builtin-grep available from other parts of the system.

* options to drive built-in grep engine is stored in struct grep_opt;

* pattern strings and extended grep expressions are added to struct grep_opt with append_grep_pattern();

* when finished calling append_grep_pattern(), call compile_grep_patterns() to prepare for execution;

* call grep_buffer() to find matches in the in-core buffer.

This also adds an internal option "status_only" to grep_opt, which suppresses any output from grep_buffer(). Callers of the function as library can use it to check if there is a match without producing any output.

---
 Makefile       |    2 
 builtin-grep.c |  522 ++------------------------------------------------------
 grep.c         |  440 +++++++++++++++++++++++++++++++++++++++++++++++
 grep.h         |   71 ++++++++
 4 files changed, 530 insertions(+), 505 deletions(-)
Makefile +1 -1
index b987450..b8e679e 100644
@@ -252,7 +252,7 @@ LIB_OBJS = \
 	server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
 	tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
 	fetch-clone.o revision.o pager.o tree-walk.o xdiff-interface.o \
-	write_or_die.o trace.o \
+	write_or_die.o trace.o grep.o \
 	alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS)
 
 BUILTIN_OBJS = \
builtin-grep.c +18 -504

573 lines not on this page · raw message

grep.c new file +440 -0

440 lines not on this page · raw message

grep.h new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
1.4.2.1.g414e5