diff options
Diffstat (limited to 'diffcore-pickaxe.c')
| -rw-r--r-- | diffcore-pickaxe.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c index 9795ca1c15..9476bd2108 100644 --- a/diffcore-pickaxe.c +++ b/diffcore-pickaxe.c @@ -81,12 +81,15 @@ static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws) regmatch_t regmatch; int flags = 0; - while (*data && + while (sz && *data && !regexec_buf(regexp, data, sz, 1, ®match, flags)) { flags |= REG_NOTBOL; data += regmatch.rm_eo; - if (*data && regmatch.rm_so == regmatch.rm_eo) + sz -= regmatch.rm_eo; + if (sz && *data && regmatch.rm_so == regmatch.rm_eo) { data++; + sz--; + } cnt++; } @@ -128,7 +131,7 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o, if (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two)) return 0; - if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) { + if (o->flags.allow_textconv) { textconv_one = get_textconv(p->one); textconv_two = get_textconv(p->two); } @@ -219,11 +222,11 @@ void diffcore_pickaxe(struct diff_options *o) if (opts & (DIFF_PICKAXE_REGEX | DIFF_PICKAXE_KIND_G)) { int cflags = REG_EXTENDED | REG_NEWLINE; - if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE)) + if (o->flags.pickaxe_ignore_case) cflags |= REG_ICASE; regcomp_or_die(®ex, needle, cflags); regexp = ®ex; - } else if (DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) && + } else if (o->flags.pickaxe_ignore_case && has_non_ascii(needle)) { struct strbuf sb = STRBUF_INIT; int cflags = REG_NEWLINE | REG_ICASE; @@ -233,7 +236,7 @@ void diffcore_pickaxe(struct diff_options *o) strbuf_release(&sb); regexp = ®ex; } else { - kws = kwsalloc(DIFF_OPT_TST(o, PICKAXE_IGNORE_CASE) + kws = kwsalloc(o->flags.pickaxe_ignore_case ? tolower_trans_tbl : NULL); kwsincr(kws, needle, strlen(needle)); kwsprep(kws); |
