vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 6aa3898119038d02623926374a9d43b38d8fbe78 parent b02fe5a2b5cd3a10fe2ea784541d92d263787dad Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 11 Mar 2016 12:55:34 +0100 text-regex: introduce function to match arbitrary text Diffstat:
| M | text-regex.c | | | 4 | ++++ |
| M | text-regex.h | | | 1 | + |
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/text-regex.c b/text-regex.c @@ -30,6 +30,10 @@ void text_regex_free(Regex *r) { free(r); } +int text_regex_match(Regex *r, const char *data, int eflags) { + return regexec(&r->regex, data, 0, NULL, eflags); +} + int text_search_range_forward(Text *txt, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags) { char *buf = text_bytes_alloc0(txt, pos, len); if (!buf) diff --git a/text-regex.h b/text-regex.h @@ -9,6 +9,7 @@ typedef Filerange RegexMatch; Regex *text_regex_new(void); int text_regex_compile(Regex *r, const char *regex, int cflags); void text_regex_free(Regex *r); +int text_regex_match(Regex*, const char *data, int eflags); int text_search_range_forward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags); int text_search_range_backward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags);