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

Function xdiff_set_find_func

xdiff-interface.c:250–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)
251{
252 int i;
253 struct ff_regs *regs;
254
255 xecfg->find_func = ff_regexp;
256 regs = xecfg->find_func_priv = xmalloc(sizeof(struct ff_regs));
257 for (i = 0, regs->nr = 1; value[i]; i++)
258 if (value[i] == '\n')
259 regs->nr++;
260 ALLOC_ARRAY(regs->array, regs->nr);
261 for (i = 0; i < regs->nr; i++) {
262 struct ff_reg *reg = regs->array + i;
263 const char *ep, *expression;
264 char *buffer = NULL;
265
266 if (!value)
267 BUG("mismatch between line count and parsing");
268 ep = strchr(value, '\n');
269
270 reg->negate = (*value == '!');
271 if (reg->negate && i == regs->nr - 1)
272 die("Last expression must not be negated: %s", value);
273 if (*value == '!')
274 value++;
275 if (ep)
276 expression = buffer = xstrndup(value, ep - value);
277 else
278 expression = value;
279 if (regcomp(&reg->re, expression, cflags))
280 die("Invalid regexp to look for hunk header: %s", expression);
281 free(buffer);
282 value = ep ? ep + 1 : NULL;
283 }
284}
285
286void xdiff_clear_find_func(xdemitconf_t *xecfg)
287{

Callers 3

match_funcnameFunction · 0.85
parse_range_funcnameFunction · 0.85
builtin_diffFunction · 0.85

Calls 4

xstrndupFunction · 0.85
regcompFunction · 0.85
xmallocFunction · 0.70
dieFunction · 0.70

Tested by

no test coverage detected