commit - ab699b5cc3fb94b67d92e8c8a90535a94f99f30b
commit + d362ea2e854f8c315f7f54d125439540e0649383
blob - 0f70fdefe19e056855268e0ccc659fb2b49aff20
blob + 51927b8761a00249104a282f106a3653fb5b046b
--- include/diff/diff_main.h
+++ include/diff/diff_main.h
#define MIN(A,B) ((A)<(B)?(A):(B))
#endif
-struct range {
+struct diff_range {
int start;
int end;
};
static inline bool
-range_empty(const struct range *r)
+diff_range_empty(const struct diff_range *r)
{
return r->start == r->end;
}
static inline bool
-ranges_touch(const struct range *a, const struct range *b)
+diff_ranges_touch(const struct diff_range *a, const struct diff_range *b)
{
return (a->end >= b->start) && (a->start <= b->end);
}
static inline void
-ranges_merge(struct range *a, const struct range *b)
+diff_ranges_merge(struct diff_range *a, const struct diff_range *b)
{
- *a = (struct range){
+ *a = (struct diff_range){
.start = MIN(a->start, b->start),
.end = MAX(a->end, b->end),
};
}
static inline int
-range_len(const struct range *r)
+diff_range_len(const struct diff_range *r)
{
if (!r)
return 0;
bool unique_in_both;
struct diff_atom *pos_in_other;
struct diff_atom *prev_stack;
- struct range identical_lines;
+ struct diff_range identical_lines;
} patience;
};
blob - 869c38d01b3d1953319161eaad4cb107ca3332d8
blob + 55f348231b92db3f47e8600ae6c5bf0799c23725
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
}
struct chunk_context {
- struct range chunk;
- struct range left, right;
+ struct diff_range chunk;
+ struct diff_range left, right;
};
static bool
chunk_context_empty(const struct chunk_context *cc)
{
- return range_empty(&cc->chunk);
+ return diff_range_empty(&cc->chunk);
}
static void
chunk_contexts_touch(const struct chunk_context *cc,
const struct chunk_context *other)
{
- return ranges_touch(&cc->chunk, &other->chunk)
- || ranges_touch(&cc->left, &other->left)
- || ranges_touch(&cc->right, &other->right);
+ return diff_ranges_touch(&cc->chunk, &other->chunk)
+ || diff_ranges_touch(&cc->left, &other->left)
+ || diff_ranges_touch(&cc->right, &other->right);
}
static void
chunk_contexts_merge(struct chunk_context *cc,
const struct chunk_context *other)
{
- ranges_merge(&cc->chunk, &other->chunk);
- ranges_merge(&cc->left, &other->left);
- ranges_merge(&cc->right, &other->right);
+ diff_ranges_merge(&cc->chunk, &other->chunk);
+ diff_ranges_merge(&cc->left, &other->left);
+ diff_ranges_merge(&cc->right, &other->right);
}
static void
const struct diff_result *result,
const struct chunk_context *cc)
{
- if (range_empty(&cc->left) && range_empty(&cc->right))
+ if (diff_range_empty(&cc->left) && diff_range_empty(&cc->right))
return;
if (!(*header_printed)) {
blob - 579043b08b7229d4604cfc69e0b2ce55fb46c8f5
blob + 1692de85f77fcbbdf88845d243be3b335741190c
--- lib/diff_patience.c
+++ lib/diff_patience.c
unsigned int r_idx = diff_atom_idx(right,
l->patience.pos_in_other);
- struct range identical_l;
- struct range identical_r;
+ struct diff_range identical_l;
+ struct diff_range identical_r;
/* Swallow upwards.
* Each common-unique line swallows identical lines upwards and
l_min = identical_l.end;
r_min = identical_r.end;
- if (!range_empty(&l->patience.identical_lines)) {
+ if (!diff_range_empty(&l->patience.identical_lines)) {
debug("common-unique line at l=%u r=%u swallowed"
" identical lines l=%u-%u r=%u-%u\n",
l_idx, r_idx,
ok = diff_state_add_chunk(state, true,
left->atoms.head
+ atom->patience.identical_lines.start,
- range_len(&atom->patience.identical_lines),
+ diff_range_len(&atom->patience.identical_lines),
right->atoms.head
+ atom_r->patience.identical_lines.start,
- range_len(&atom_r->patience.identical_lines));
+ diff_range_len(&atom_r->patience.identical_lines));
if (!ok)
goto return_rc;
left_pos = atom->patience.identical_lines.end;