diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-09-23 15:15:48 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-09-23 15:15:48 -0700 |
| commit | 8e1e6572feabd291cbd5048459c0a58c6460ff91 (patch) | |
| tree | adf66d019c271dc58cd9d47abdb7b1b20ab2226f /match.c | |
| parent | d20afd10b693180b667ebdb0bfab7b9afabc0b42 (diff) | |
Moved type defs into their own files instead of types.h
Diffstat (limited to 'match.c')
| -rw-r--r-- | match.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -12,7 +12,6 @@ #include "definitions.h" #include "match.h" #include "pattern.h" -#include "types.h" #include "utils.h" #include "utf8.h" @@ -518,19 +517,13 @@ static match_t *match(def_t *defs, cache_t *cache, file_t *f, const char *str, p if (m1->pat->type == BP_CAPTURE && m1->pat->args.capture.name) { // Temporarily add a rule that the backref name matches the // exact string of the original match (no replacements) - pat_t *backref = bp_backref(f, m1); + pat_t *backref = bp_raw_literal(f, m1->start, (size_t)(m1->end - m1->start)); def_t *defs2 = with_def(defs, m1->pat->args.capture.namelen, m1->pat->args.capture.name, backref); ++m1->refcount; { m2 = match(defs2, cache, f, m1->end, pat->args.multiple.second, ignorecase); if (!m2) { // No need to keep the backref in memory if it didn't match - for (pat_t **rem = &f->pats; *rem; rem = &(*rem)->next) { - if ((*rem) == backref) { - pat_t *tmp = *rem; - *rem = (*rem)->next; - free(tmp); - break; - } - } + free_pat(backref); + backref = NULL; } defs = free_defs(defs2, defs); } --m1->refcount; |
