patch 8.2.0500: using the same loop in many places

Problem:    Using the same loop in many places.
Solution:   Define more FOR_ALL macros. (Yegappan Lakshmanan, closes #5339)
diff --git a/src/diff.c b/src/diff.c
index f996904..3d61d49 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -90,6 +90,9 @@
 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 @@
 #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 @@
     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 @@
     }
 
     // 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 @@
     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 @@
     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 @@
 	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;