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

Function ff_regexp

xdiff-interface.c:213–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211};
212
213static long ff_regexp(const char *line, long len,
214 char *buffer, long buffer_size, void *priv)
215{
216 struct ff_regs *regs = priv;
217 regmatch_t pmatch[2];
218 int i;
219 int result;
220
221 /* Exclude terminating newline (and cr) from matching */
222 if (len > 0 && line[len-1] == '\n') {
223 if (len > 1 && line[len-2] == '\r')
224 len -= 2;
225 else
226 len--;
227 }
228
229 for (i = 0; i < regs->nr; i++) {
230 struct ff_reg *reg = regs->array + i;
231 if (!regexec_buf(&reg->re, line, len, 2, pmatch, 0)) {
232 if (reg->negate)
233 return -1;
234 break;
235 }
236 }
237 if (regs->nr <= i)
238 return -1;
239 i = pmatch[1].rm_so >= 0 ? 1 : 0;
240 line += pmatch[i].rm_so;
241 result = pmatch[i].rm_eo - pmatch[i].rm_so;
242 if (result > buffer_size)
243 result = buffer_size;
244 while (result > 0 && (isspace(line[result - 1])))
245 result--;
246 memcpy(buffer, line, result);
247 return result;
248}
249
250void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)
251{

Callers

nothing calls this directly

Calls 1

regexec_bufFunction · 0.85

Tested by

no test coverage detected