MCPcopy Create free account
hub / github.com/git/git / contains

Function contains

diffcore-pickaxe.c:77–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws,
78 unsigned int limit)
79{
80 unsigned int cnt = 0;
81 unsigned long sz = mf->size;
82 const char *data = mf->ptr;
83
84 if (regexp) {
85 regmatch_t regmatch;
86 int flags = 0;
87
88 while (sz &&
89 !regexec_buf(regexp, data, sz, 1, &regmatch, flags)) {
90 flags |= REG_NOTBOL;
91 data += regmatch.rm_eo;
92 sz -= regmatch.rm_eo;
93 if (sz && regmatch.rm_so == regmatch.rm_eo) {
94 data++;
95 sz--;
96 }
97 cnt++;
98
99 if (limit && cnt == limit)
100 return cnt;
101 }
102
103 } else { /* Classic exact string match */
104 while (sz) {
105 struct kwsmatch kwsm;
106 size_t offset = kwsexec(kws, data, sz, &kwsm);
107 if (offset == -1)
108 break;
109 sz -= offset + kwsm.size[0];
110 data += offset + kwsm.size[0];
111 cnt++;
112
113 if (limit && cnt == limit)
114 return cnt;
115 }
116 }
117 return cnt;
118}
119
120static int has_changes(mmfile_t *one, mmfile_t *two,
121 struct diff_options *o UNUSED,

Callers 1

has_changesFunction · 0.85

Calls 2

regexec_bufFunction · 0.85
kwsexecFunction · 0.85

Tested by

no test coverage detected