summaryrefslogtreecommitdiffstats
path: root/src/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/diff.c b/src/diff.c
index f996904543..3d61d49d1c 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -90,6 +90,9 @@ static int parse_diff_ed(char_u *line, linenr_T *lnum_orig, long *count_orig, li
static int parse_diff_unified(char_u *line, linenr_T *lnum_orig, long *count_orig, linenr_T *lnum_new, long *count_new);
static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf);
+#define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
+ for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
+
/*
* Called when deleting or unloading a buffer: No longer make a diff with it.
*/
@@ -1857,7 +1860,7 @@ diff_check(win_T *wp, linenr_T lnum)
#endif
// search for a change that includes "lnum" in the list of diffblocks.
- for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+ FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
if (lnum <= dp->df_lnum[idx] + dp->df_count[idx])
break;
if (dp == NULL || lnum < dp->df_lnum[idx])
@@ -2069,7 +2072,7 @@ diff_set_topline(win_T *fromwin, win_T *towin)
towin->w_topfill = 0;
// search for a change that includes "lnum" in the list of diffblocks.
- for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+ FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx])
break;
if (dp == NULL)
@@ -2374,7 +2377,7 @@ diff_find_change(
}
// search for a change that includes "lnum" in the list of diffblocks.
- for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+ FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
if (lnum <= dp->df_lnum[idx] + dp->df_count[idx])
break;
if (dp == NULL || diff_check_sanity(curtab, dp) == FAIL)
@@ -2508,7 +2511,7 @@ diff_infold(win_T *wp, linenr_T lnum)
if (curtab->tp_first_diff == NULL)
return TRUE;
- for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+ FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
{
// If this change is below the line there can't be any further match.
if (dp->df_lnum[idx] - diff_context > lnum)
@@ -3001,7 +3004,7 @@ diff_get_corresponding_line_int(
if (curtab->tp_first_diff == NULL) // no diffs today
return lnum1;
- for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+ FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
{
if (dp->df_lnum[idx1] > lnum1)
return lnum1 - baseline;
@@ -3070,7 +3073,7 @@ diff_lnum_win(linenr_T lnum, win_T *wp)
ex_diffupdate(NULL); // update after a big change
// search for a change that includes "lnum" in the list of diffblocks.
- for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+ FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
if (lnum <= dp->df_lnum[idx] + dp->df_count[idx])
break;