Example #1
0
static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb) {
	long size, psize = strlen(pre);
	char const *rec;

	size = xdl_get_rec(xdf, ri, &rec);
	if (xdl_emit_diffrec(rec, size, pre, psize, ecb) < 0) {

		return -1;
	}

	return 0;
}
Example #2
0
File: xemit.c Project: certik/git
static void xdl_find_func(xdfile_t *xf, long i, char *buf, long sz, long *ll,
		find_func_t ff, void *ff_priv) {

	/*
	 * Be quite stupid about this for now.  Find a line in the old file
	 * before the start of the hunk (and context) which starts with a
	 * plausible character.
	 */

	const char *rec;
	long len;

	while (i-- > 0) {
		len = xdl_get_rec(xf, i, &rec);
		if ((*ll = ff(rec, len, buf, sz, ff_priv)) >= 0)
			return;
	}
	*ll = 0;
}
Example #3
0
static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg,
			  struct func_line *func_line, long start, long limit)
{
	find_func_t ff = xecfg->find_func ? xecfg->find_func : def_ff;
	long l, size, step = (start > limit) ? -1 : 1;
	char *buf, dummy[1];

	buf = func_line ? func_line->buf : dummy;
	size = func_line ? sizeof(func_line->buf) : sizeof(dummy);

	for (l = start; l != limit && 0 <= l && l < xe->xdf1.nrec; l += step) {
		const char *rec;
		long reclen = xdl_get_rec(&xe->xdf1, l, &rec);
		long len = ff(rec, reclen, buf, size, xecfg->find_func_priv);
		if (len >= 0) {
			if (func_line)
				func_line->len = len;
			return l;
		}
	}
	return -1;
}