Skip to content

Commit

Permalink
Improve line filters and substitution filters (#2032)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka authored Sep 20, 2023
1 parent 1591109 commit 70f1f97
Show file tree
Hide file tree
Showing 3 changed files with 403 additions and 147 deletions.
29 changes: 8 additions & 21 deletions Src/CompareEngines/Wrap_DiffUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,19 @@ int DiffUtils::CompareFiles(DiffFileData* diffData)
/* Determine range of line numbers involved in each file. */
int first0 = 0, last0 = 0, first1 = 0, last1 = 0, deletes = 0, inserts = 0;
analyze_hunk (thisob, &first0, &last0, &first1, &last1, &deletes, &inserts, diffData->m_inf);

/* Reconnect the script so it will all be freed properly. */
end->link = next;

if (deletes!=0 || inserts!=0 || thisob->trivial!=0)
{
/* Print the lines that the first file has. */
int trans_a0 = 0, trans_b0 = 0, trans_a1 = 0, trans_b1 = 0;
translate_range(&diffData->m_inf[0], first0, last0, &trans_a0, &trans_b0);
translate_range(&diffData->m_inf[1], first1, last1, &trans_a1, &trans_b1);

//Determine quantity of lines in this block for both sides
int QtyLinesLeft = (trans_b0 - trans_a0) + 1;
int QtyLinesRight = (trans_b1 - trans_a1) + 1;
if (usefilters)
OP_TYPE op = (deletes == 0 && inserts == 0) ? OP_TRIVIAL : OP_DIFF;

if (op != OP_TRIVIAL && usefilters)
{
OP_TYPE op = OP_NONE;
if (deletes == 0 && inserts == 0)
op = OP_TRIVIAL;
else
op = OP_DIFF;
m_pDiffWrapper->PostFilter(ctxt, trans_a0 - 1, QtyLinesLeft, trans_a1 - 1, QtyLinesRight, op, diffData->m_inf);
if(op == OP_TRIVIAL)
{
thisob->trivial = 1;
}
m_pDiffWrapper->PostFilter(ctxt, thisob, diffData->m_inf);
}
}
/* Reconnect the script so it will all be freed properly. */
end->link = next;
}
}
}
Expand Down
Loading

0 comments on commit 70f1f97

Please sign in to comment.