diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2019-01-12 23:06:39 +0000 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-05-19 11:10:08 +0100 |
| commit | 02683b20c0775dab28d72727cc97a96ec77cb20c (patch) | |
| tree | af4fc1c23a5ca20b94ebdf6b0603b88fff686670 /src/diff_driver.c | |
| parent | c9f116f148c9eb64988eb36ec83d1a653dc81ee0 (diff) | |
| download | libgit2-02683b20c0775dab28d72727cc97a96ec77cb20c.tar.gz | |
regexec: prefix all regexec function calls with p_
Prefix all the calls to the the regexec family of functions with `p_`.
This allows us to swap out all the regular expression functions with our
own implementation. Move the declarations to `posix_regex.h` for
simpler inclusion.
Diffstat (limited to 'src/diff_driver.c')
| -rw-r--r-- | src/diff_driver.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c index 959cf6258..0ca652c69 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -9,6 +9,7 @@ #include "git2/attr.h" +#include "common.h" #include "diff.h" #include "strmap.h" #include "map.h" @@ -24,7 +25,7 @@ typedef enum { } git_diff_driver_t; typedef struct { - regex_t re; + p_regex_t re; int flags; } git_diff_driver_pattern; @@ -38,7 +39,7 @@ struct git_diff_driver { uint32_t binary_flags; uint32_t other_flags; git_array_t(git_diff_driver_pattern) fn_patterns; - regex_t word_pattern; + p_regex_t word_pattern; char name[GIT_FLEX_ARRAY]; }; @@ -129,7 +130,7 @@ static int diff_driver_add_patterns( static int diff_driver_xfuncname(const git_config_entry *entry, void *payload) { - return diff_driver_add_patterns(payload, entry->value, REG_EXTENDED); + return diff_driver_add_patterns(payload, entry->value, P_REG_EXTENDED); } static int diff_driver_funcname(const git_config_entry *entry, void *payload) @@ -204,12 +205,12 @@ static int git_diff_driver_builtin( if (ddef->fns && (error = diff_driver_add_patterns( - drv, ddef->fns, ddef->flags | REG_EXTENDED)) < 0) + drv, ddef->fns, ddef->flags | P_REG_EXTENDED)) < 0) goto done; if (ddef->words && (error = p_regcomp( - &drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED))) + &drv->word_pattern, ddef->words, ddef->flags | P_REG_EXTENDED))) { error = git_error_set_regex(&drv->word_pattern, error); goto done; @@ -309,7 +310,7 @@ static int git_diff_driver_load( goto done; if (!ce || !ce->value) /* no diff.<driver>.wordregex, so just continue */; - else if (!(error = p_regcomp(&drv->word_pattern, ce->value, REG_EXTENDED))) + else if (!(error = p_regcomp(&drv->word_pattern, ce->value, P_REG_EXTENDED))) found_driver = true; else { /* TODO: warn about bad regex instead of failure */ @@ -393,10 +394,10 @@ void git_diff_driver_free(git_diff_driver *driver) return; for (i = 0; i < git_array_size(driver->fn_patterns); ++i) - regfree(& git_array_get(driver->fn_patterns, i)->re); + p_regfree(& git_array_get(driver->fn_patterns, i)->re); git_array_clear(driver->fn_patterns); - regfree(&driver->word_pattern); + p_regfree(&driver->word_pattern); git__free(driver); } @@ -444,12 +445,12 @@ static int diff_context_line__pattern_match( git_diff_driver *driver, git_buf *line) { size_t i, maxi = git_array_size(driver->fn_patterns); - regmatch_t pmatch[2]; + p_regmatch_t pmatch[2]; for (i = 0; i < maxi; ++i) { git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i); - if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) { + if (!p_regexec(&pat->re, line->ptr, 2, pmatch, 0)) { if (pat->flags & REG_NEGATE) return false; |
