Skip to content

Commit

Permalink
text-regex: introduce function to match arbitrary text
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Apr 3, 2016
1 parent ba23d97 commit 1ea9a99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions text-regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions text-regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 1ea9a99

Please sign in to comment.