commit - c620ba7f923e0e2cca34aeafbc93133ed727a052
commit + 54fa822893d2fcc170a2d3051d1640bf5303894e
blob - 073e0a21c0a312a7c09f13092e23da0decdec43a
blob + 94cc6fad7ecce1ff97127e1643d5ed82cb5ea3f0
--- include/diff/diff_main.h
+++ include/diff/diff_main.h
#include <diff/arraylist.h>
+#ifndef MAX
+#define MAX(A,B) ((A)>(B)?(A):(B))
+#endif
+#ifndef MIN
+#define MIN(A,B) ((A)<(B)?(A):(B))
+#endif
+
+struct range {
+ int start;
+ int end;
+};
+
+static inline bool range_empty(const struct range *r)
+{
+ return r->start == r->end;
+}
+
+static inline bool ranges_touch(const struct range *a, const struct range *b)
+{
+ return (a->end >= b->start) && (a->start <= b->end);
+}
+
+static inline void ranges_merge(struct range *a, const struct range *b)
+{
+ *a = (struct range){
+ .start = MIN(a->start, b->start),
+ .end = MAX(a->end, b->end),
+ };
+}
+
+static inline int range_len(const struct range *r)
+{
+ if (!r)
+ return 0;
+ return r->end - r->start;
+}
+
/* List of all possible return codes of a diff invocation. */
enum diff_rc {
DIFF_RC_USE_DIFF_ALGO_FALLBACK = -1,
blob - d12e4c0b5d67538e6f0dbd89b84c22447ec44d25
blob + 986d06cbf5ec125bca1bfbce84d7cd3378501735
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
return CHUNK_SAME;
}
-#define MAX(A,B) ((A)>(B)?(A):(B))
-#define MIN(A,B) ((A)<(B)?(A):(B))
-
-struct range {
- int start;
- int end;
-};
-
-static bool range_empty(const struct range *r)
-{
- return r->start == r->end;
-}
-
-static bool ranges_touch(const struct range *a, const struct range *b)
-{
- return (a->end >= b->start) && (a->start <= b->end);
-}
-
-static void ranges_merge(struct range *a, const struct range *b)
-{
- *a = (struct range){
- .start = MIN(a->start, b->start),
- .end = MAX(a->end, b->end),
- };
-}
-
struct chunk_context {
struct range chunk;
struct range left, right;