|
|
e5695f |
diff -up diffutils-3.3/lib/diffseq.h.me diffutils-3.3/lib/diffseq.h
|
|
|
e5695f |
--- diffutils-3.3/lib/diffseq.h.me 2018-08-10 14:26:48.940444056 +0200
|
|
|
e5695f |
+++ diffutils-3.3/lib/diffseq.h 2018-08-10 14:26:50.453439777 +0200
|
|
|
e5695f |
@@ -138,12 +132,6 @@ struct partition
|
|
|
e5695f |
/* Midpoints of this partition. */
|
|
|
e5695f |
OFFSET xmid;
|
|
|
e5695f |
OFFSET ymid;
|
|
|
e5695f |
-
|
|
|
e5695f |
- /* True if low half will be analyzed minimally. */
|
|
|
e5695f |
- bool lo_minimal;
|
|
|
e5695f |
-
|
|
|
e5695f |
- /* Likewise for high half. */
|
|
|
e5695f |
- bool hi_minimal;
|
|
|
e5695f |
};
|
|
|
e5695f |
|
|
|
e5695f |
|
|
|
e5695f |
@@ -175,7 +156,7 @@ struct partition
|
|
|
e5695f |
suboptimal diff output. It cannot cause incorrect diff output. */
|
|
|
e5695f |
|
|
|
e5695f |
static void
|
|
|
e5695f |
-diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, bool find_minimal,
|
|
|
e5695f |
+diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim,
|
|
|
e5695f |
struct partition *part, struct context *ctxt)
|
|
|
e5695f |
{
|
|
|
e5695f |
OFFSET *const fd = ctxt->fdiag; /* Give the compiler a chance. */
|
|
|
e5695f |
@@ -235,7 +216,6 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET y
|
|
|
e5695f |
{
|
|
|
e5695f |
part->xmid = x;
|
|
|
e5695f |
part->ymid = y;
|
|
|
e5695f |
- part->lo_minimal = part->hi_minimal = true;
|
|
|
e5695f |
return;
|
|
|
e5695f |
}
|
|
|
e5695f |
}
|
|
|
e5695f |
@@ -268,14 +248,10 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET y
|
|
|
e5695f |
{
|
|
|
e5695f |
part->xmid = x;
|
|
|
e5695f |
part->ymid = y;
|
|
|
e5695f |
- part->lo_minimal = part->hi_minimal = true;
|
|
|
e5695f |
return;
|
|
|
e5695f |
}
|
|
|
e5695f |
}
|
|
|
e5695f |
|
|
|
e5695f |
- if (find_minimal)
|
|
|
e5695f |
- continue;
|
|
|
e5695f |
-
|
|
|
e5695f |
#ifdef USE_HEURISTIC
|
|
|
e5695f |
/* Heuristic: check occasionally for a diagonal that has made lots
|
|
|
e5695f |
of progress compared with the edit distance. If we have any
|
|
|
e5695f |
@@ -319,11 +295,7 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET y
|
|
|
e5695f |
}
|
|
|
e5695f |
}
|
|
|
e5695f |
if (best > 0)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- part->lo_minimal = true;
|
|
|
e5695f |
- part->hi_minimal = false;
|
|
|
e5695f |
- return;
|
|
|
e5695f |
- }
|
|
|
e5695f |
+ return;
|
|
|
e5695f |
}
|
|
|
e5695f |
|
|
|
e5695f |
{
|
|
|
e5695f |
@@ -358,77 +330,10 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET y
|
|
|
e5695f |
}
|
|
|
e5695f |
}
|
|
|
e5695f |
if (best > 0)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- part->lo_minimal = false;
|
|
|
e5695f |
- part->hi_minimal = true;
|
|
|
e5695f |
- return;
|
|
|
e5695f |
- }
|
|
|
e5695f |
+ return;
|
|
|
e5695f |
}
|
|
|
e5695f |
}
|
|
|
e5695f |
#endif /* USE_HEURISTIC */
|
|
|
e5695f |
-
|
|
|
e5695f |
- /* Heuristic: if we've gone well beyond the call of duty, give up
|
|
|
e5695f |
- and report halfway between our best results so far. */
|
|
|
e5695f |
- if (c >= ctxt->too_expensive)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- OFFSET fxybest;
|
|
|
e5695f |
- OFFSET fxbest IF_LINT (= 0);
|
|
|
e5695f |
- OFFSET bxybest;
|
|
|
e5695f |
- OFFSET bxbest IF_LINT (= 0);
|
|
|
e5695f |
-
|
|
|
e5695f |
- /* Find forward diagonal that maximizes X + Y. */
|
|
|
e5695f |
- fxybest = -1;
|
|
|
e5695f |
- for (d = fmax; d >= fmin; d -= 2)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- OFFSET x = MIN (fd[d], xlim);
|
|
|
e5695f |
- OFFSET y = x - d;
|
|
|
e5695f |
- if (ylim < y)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- x = ylim + d;
|
|
|
e5695f |
- y = ylim;
|
|
|
e5695f |
- }
|
|
|
e5695f |
- if (fxybest < x + y)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- fxybest = x + y;
|
|
|
e5695f |
- fxbest = x;
|
|
|
e5695f |
- }
|
|
|
e5695f |
- }
|
|
|
e5695f |
-
|
|
|
e5695f |
- /* Find backward diagonal that minimizes X + Y. */
|
|
|
e5695f |
- bxybest = OFFSET_MAX;
|
|
|
e5695f |
- for (d = bmax; d >= bmin; d -= 2)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- OFFSET x = MAX (xoff, bd[d]);
|
|
|
e5695f |
- OFFSET y = x - d;
|
|
|
e5695f |
- if (y < yoff)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- x = yoff + d;
|
|
|
e5695f |
- y = yoff;
|
|
|
e5695f |
- }
|
|
|
e5695f |
- if (x + y < bxybest)
|
|
|
e5695f |
- {
|
|
|
e5695f |
- bxybest = x + y;
|
|
|
e5695f |
- bxbest = x;
|
|
|
e5695f |
- }
|
|
|
e5695f |
- }
|
|
|
e5695f |
-
|
|
|
e5695f |
- /* Use the better of the two diagonals. */
|
|
|
e5695f |
- if ((xlim + ylim) - bxybest < fxybest - (xoff + yoff))
|
|
|
e5695f |
- {
|
|
|
e5695f |
- part->xmid = fxbest;
|
|
|
e5695f |
- part->ymid = fxybest - fxbest;
|
|
|
e5695f |
- part->lo_minimal = true;
|
|
|
e5695f |
- part->hi_minimal = false;
|
|
|
e5695f |
- }
|
|
|
e5695f |
- else
|
|
|
e5695f |
- {
|
|
|
e5695f |
- part->xmid = bxbest;
|
|
|
e5695f |
- part->ymid = bxybest - bxbest;
|
|
|
e5695f |
- part->lo_minimal = false;
|
|
|
e5695f |
- part->hi_minimal = true;
|
|
|
e5695f |
- }
|
|
|
e5695f |
- return;
|
|
|
e5695f |
- }
|
|
|
e5695f |
}
|
|
|
e5695f |
#undef XREF_YREF_EQUAL
|
|
|
e5695f |
}
|
|
|
e5695f |
@@ -452,7 +354,7 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET y
|
|
|
e5695f |
|
|
|
e5695f |
static bool
|
|
|
e5695f |
compareseq (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim,
|
|
|
e5695f |
- bool find_minimal, struct context *ctxt)
|
|
|
e5695f |
+ struct context *ctxt)
|
|
|
e5695f |
{
|
|
|
e5695f |
#ifdef ELEMENT
|
|
|
e5695f |
ELEMENT const *xv = ctxt->xvec; /* Help the compiler. */
|
|
|
e5695f |
@@ -498,12 +400,12 @@ compareseq (OFFSET xoff, OFFSET xlim, OF
|
|
|
e5695f |
struct partition part IF_LINT2 (= { .xmid = 0, .ymid = 0 });
|
|
|
e5695f |
|
|
|
e5695f |
/* Find a point of correspondence in the middle of the vectors. */
|
|
|
e5695f |
- diag (xoff, xlim, yoff, ylim, find_minimal, &part, ctxt);
|
|
|
e5695f |
+ diag (xoff, xlim, yoff, ylim, &part, ctxt);
|
|
|
e5695f |
|
|
|
e5695f |
/* Use the partitions to split this problem into subproblems. */
|
|
|
e5695f |
- if (compareseq (xoff, part.xmid, yoff, part.ymid, part.lo_minimal, ctxt))
|
|
|
e5695f |
+ if (compareseq (xoff, part.xmid, yoff, part.ymid, ctxt))
|
|
|
e5695f |
return true;
|
|
|
e5695f |
- if (compareseq (part.xmid, xlim, part.ymid, ylim, part.hi_minimal, ctxt))
|
|
|
e5695f |
+ if (compareseq (part.xmid, xlim, part.ymid, ylim, ctxt))
|
|
|
e5695f |
return true;
|
|
|
e5695f |
}
|
|
|
e5695f |
|
|
|
e5695f |
diff -up diffutils-3.3/src/analyze.c.me diffutils-3.3/src/analyze.c
|
|
|
e5695f |
--- diffutils-3.3/src/analyze.c.me 2018-08-10 14:06:53.473858743 +0200
|
|
|
e5695f |
+++ diffutils-3.3/src/analyze.c 2018-08-10 14:08:30.533579865 +0200
|
|
|
e5695f |
@@ -542,7 +542,6 @@ diff_2_files (struct comparison *cmp)
|
|
|
e5695f |
{
|
|
|
e5695f |
struct context ctxt;
|
|
|
e5695f |
lin diags;
|
|
|
e5695f |
- lin too_expensive;
|
|
|
e5695f |
|
|
|
e5695f |
/* Allocate vectors for the results of comparison:
|
|
|
e5695f |
a flag for each line of each file, saying whether that line
|
|
|
e5695f |
@@ -574,18 +573,11 @@ diff_2_files (struct comparison *cmp)
|
|
|
e5695f |
|
|
|
e5695f |
ctxt.heuristic = speed_large_files;
|
|
|
e5695f |
|
|
|
e5695f |
- /* Set TOO_EXPENSIVE to be approximate square root of input size,
|
|
|
e5695f |
- bounded below by 256. */
|
|
|
e5695f |
- too_expensive = 1;
|
|
|
e5695f |
- for (; diags != 0; diags >>= 2)
|
|
|
e5695f |
- too_expensive <<= 1;
|
|
|
e5695f |
- ctxt.too_expensive = MAX (256, too_expensive);
|
|
|
e5695f |
-
|
|
|
e5695f |
files[0] = cmp->file[0];
|
|
|
e5695f |
files[1] = cmp->file[1];
|
|
|
e5695f |
|
|
|
e5695f |
compareseq (0, cmp->file[0].nondiscarded_lines,
|
|
|
e5695f |
- 0, cmp->file[1].nondiscarded_lines, minimal, &ctxt);
|
|
|
e5695f |
+ 0, cmp->file[1].nondiscarded_lines, &ctxt);
|
|
|
e5695f |
|
|
|
e5695f |
free (ctxt.fdiag - (cmp->file[1].nondiscarded_lines + 1));
|
|
|
e5695f |
|
|
|
e5695f |
diff -up diffutils-3.3/src/diff.h.me diffutils-3.3/src/diff.h
|
|
|
e5695f |
--- diffutils-3.3/src/diff.h.me 2018-08-10 14:28:25.878169926 +0200
|
|
|
e5695f |
+++ diffutils-3.3/src/diff.h 2018-08-10 14:28:40.739127903 +0200
|
|
|
e5695f |
@@ -376,7 +376,7 @@ extern void print_sdiff_script (struct c
|
|
|
e5695f |
extern char const change_letter[4];
|
|
|
e5695f |
extern char const pr_program[];
|
|
|
e5695f |
extern char *concat (char const *, char const *, char const *);
|
|
|
e5695f |
-extern bool (*lines_differ) (char const *, size_t, char const *, size_t) _GL_ATTRIBUTE_PURE;
|
|
|
e5695f |
+extern bool (*lines_differ) (char const *, size_t, char const *, size_t);
|
|
|
e5695f |
extern bool lines_differ_singlebyte (char const *, size_t, char const *, size_t) _GL_ATTRIBUTE_PURE;
|
|
|
e5695f |
#ifdef HANDLE_MULTIBYTE
|
|
|
e5695f |
extern bool lines_differ_multibyte (char const *, size_t, char const *, size_t) _GL_ATTRIBUTE_PURE;
|