Lines Matching refs:dp

78 static void diff_check_unchanged(tabpage_T *tp, diff_T *dp);
79 static int diff_check_sanity(tabpage_T *tp, diff_T *dp);
82 static int diff_equal_entry(diff_T *dp, int idx1, int idx2);
85 static void diff_fold_update(diff_T *dp, int skip_idx);
88 static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int idx_new);
89 static diff_T *diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp);
94 #define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \ argument
95 for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
286 diff_T *dp; in diff_mark_adjust_tp() local
326 dp = tp->tp_first_diff; in diff_mark_adjust_tp()
332 if ((dp == NULL || dp->df_lnum[idx] - 1 > line2 in diff_mark_adjust_tp()
333 || (line2 == MAXLNUM && dp->df_lnum[idx] > line1)) in diff_mark_adjust_tp()
338 dnext = diff_alloc_new(tp, dprev, dp); in diff_mark_adjust_tp()
358 if (dp == NULL) in diff_mark_adjust_tp()
373 last = dp->df_lnum[idx] + dp->df_count[idx] - 1; in diff_mark_adjust_tp()
380 if (dp->df_lnum[idx] - (deleted + inserted != 0) > line2) in diff_mark_adjust_tp()
384 dp->df_lnum[idx] += amount_after; in diff_mark_adjust_tp()
393 if (dp->df_lnum[idx] >= line1) in diff_mark_adjust_tp()
395 off = dp->df_lnum[idx] - lnum_deleted; in diff_mark_adjust_tp()
399 if (dp->df_next != NULL in diff_mark_adjust_tp()
400 && dp->df_next->df_lnum[idx] - 1 <= line2) in diff_mark_adjust_tp()
404 n = dp->df_next->df_lnum[idx] - lnum_deleted; in diff_mark_adjust_tp()
406 n -= dp->df_count[idx]; in diff_mark_adjust_tp()
407 lnum_deleted = dp->df_next->df_lnum[idx]; in diff_mark_adjust_tp()
410 n = deleted - dp->df_count[idx]; in diff_mark_adjust_tp()
411 dp->df_count[idx] = 0; in diff_mark_adjust_tp()
417 dp->df_count[idx] -= line2 - dp->df_lnum[idx] + 1; in diff_mark_adjust_tp()
420 dp->df_lnum[idx] = line1; in diff_mark_adjust_tp()
428 dp->df_count[idx] -= last - lnum_deleted + 1; in diff_mark_adjust_tp()
429 if (dp->df_next != NULL in diff_mark_adjust_tp()
430 && dp->df_next->df_lnum[idx] - 1 <= line2) in diff_mark_adjust_tp()
434 n = dp->df_next->df_lnum[idx] - 1 - last; in diff_mark_adjust_tp()
435 deleted -= dp->df_next->df_lnum[idx] in diff_mark_adjust_tp()
437 lnum_deleted = dp->df_next->df_lnum[idx]; in diff_mark_adjust_tp()
447 dp->df_count[idx] -= deleted; in diff_mark_adjust_tp()
454 dp->df_lnum[i] -= off; in diff_mark_adjust_tp()
455 dp->df_count[i] += n; in diff_mark_adjust_tp()
460 if (dp->df_lnum[idx] <= line1) in diff_mark_adjust_tp()
463 dp->df_count[idx] += inserted; in diff_mark_adjust_tp()
468 dp->df_lnum[idx] += inserted; in diff_mark_adjust_tp()
475 diff_check_unchanged(tp, dp); in diff_mark_adjust_tp()
481 == dp->df_lnum[idx]) in diff_mark_adjust_tp()
485 dprev->df_count[i] += dp->df_count[i]; in diff_mark_adjust_tp()
486 dprev->df_next = dp->df_next; in diff_mark_adjust_tp()
487 vim_free(dp); in diff_mark_adjust_tp()
488 dp = dprev->df_next; in diff_mark_adjust_tp()
493 dprev = dp; in diff_mark_adjust_tp()
494 dp = dp->df_next; in diff_mark_adjust_tp()
499 dp = tp->tp_first_diff; in diff_mark_adjust_tp()
500 while (dp != NULL) in diff_mark_adjust_tp()
504 if (tp->tp_diffbuf[i] != NULL && dp->df_count[i] != 0) in diff_mark_adjust_tp()
508 dnext = dp->df_next; in diff_mark_adjust_tp()
509 vim_free(dp); in diff_mark_adjust_tp()
510 dp = dnext; in diff_mark_adjust_tp()
519 dprev = dp; in diff_mark_adjust_tp()
520 dp = dp->df_next; in diff_mark_adjust_tp()
541 diff_alloc_new(tabpage_T *tp, diff_T *dprev, diff_T *dp) in diff_alloc_new() argument
548 dnew->df_next = dp; in diff_alloc_new()
564 diff_check_unchanged(tabpage_T *tp, diff_T *dp) in diff_check_unchanged() argument
580 if (diff_check_sanity(tp, dp) == FAIL) in diff_check_unchanged()
590 while (dp->df_count[i_org] > 0) in diff_check_unchanged()
594 off_org = dp->df_count[i_org] - 1; in diff_check_unchanged()
596 dp->df_lnum[i_org] + off_org, FALSE)); in diff_check_unchanged()
604 off_new = dp->df_count[i_new] - 1; in diff_check_unchanged()
606 if (off_new < 0 || off_new >= dp->df_count[i_new]) in diff_check_unchanged()
609 dp->df_lnum[i_new] + off_new, FALSE)) != 0) in diff_check_unchanged()
623 ++dp->df_lnum[i_new]; in diff_check_unchanged()
624 --dp->df_count[i_new]; in diff_check_unchanged()
638 diff_check_sanity(tabpage_T *tp, diff_T *dp) in diff_check_sanity() argument
644 if (dp->df_lnum[i] + dp->df_count[i] - 1 in diff_check_sanity()
1615 diff_T *dp = curtab->tp_first_diff; in diff_read() local
1711 while (dp != NULL in diff_read()
1712 && lnum_orig > dp->df_lnum[idx_orig] + dp->df_count[idx_orig]) in diff_read()
1715 diff_copy_entry(dprev, dp, idx_orig, idx_new); in diff_read()
1716 dprev = dp; in diff_read()
1717 dp = dp->df_next; in diff_read()
1721 if (dp != NULL in diff_read()
1722 && lnum_orig <= dp->df_lnum[idx_orig] + dp->df_count[idx_orig] in diff_read()
1723 && lnum_orig + count_orig >= dp->df_lnum[idx_orig]) in diff_read()
1727 for (dpl = dp; dpl->df_next != NULL; dpl = dpl->df_next) in diff_read()
1733 off = dp->df_lnum[idx_orig] - lnum_orig; in diff_read()
1738 dp->df_lnum[i] -= off; in diff_read()
1739 dp->df_lnum[idx_new] = lnum_new; in diff_read()
1740 dp->df_count[idx_new] = count_new; in diff_read()
1745 dp->df_lnum[idx_new] = lnum_new + off; in diff_read()
1746 dp->df_count[idx_new] = count_new - off; in diff_read()
1750 dp->df_count[idx_new] += count_new - count_orig in diff_read()
1752 - (dp->df_lnum[idx_orig] + dp->df_count[idx_orig]); in diff_read()
1763 dp->df_count[idx_new] += -off; in diff_read()
1768 dp->df_count[i] = dpl->df_lnum[i] + dpl->df_count[i] in diff_read()
1769 - dp->df_lnum[i] + off; in diff_read()
1772 dn = dp->df_next; in diff_read()
1773 dp->df_next = dpl->df_next; in diff_read()
1774 while (dn != dp->df_next) in diff_read()
1784 dp = diff_alloc_new(curtab, dprev, dp); in diff_read()
1785 if (dp == NULL) in diff_read()
1788 dp->df_lnum[idx_orig] = lnum_orig; in diff_read()
1789 dp->df_count[idx_orig] = count_orig; in diff_read()
1790 dp->df_lnum[idx_new] = lnum_new; in diff_read()
1791 dp->df_count[idx_new] = count_new; in diff_read()
1798 diff_copy_entry(dprev, dp, idx_orig, i); in diff_read()
1804 while (dp != NULL) in diff_read()
1807 diff_copy_entry(dprev, dp, idx_orig, idx_new); in diff_read()
1808 dprev = dp; in diff_read()
1809 dp = dp->df_next; in diff_read()
1824 diff_T *dp, in diff_copy_entry() argument
1835 dp->df_lnum[idx_new] = dp->df_lnum[idx_orig] - off; in diff_copy_entry()
1836 dp->df_count[idx_new] = dp->df_count[idx_orig]; in diff_copy_entry()
1868 diff_T *dp; in diff_check() local
1895 FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) in diff_check()
1896 if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) in diff_check()
1898 if (dp == NULL || lnum < dp->df_lnum[idx]) in diff_check()
1901 if (lnum < dp->df_lnum[idx] + dp->df_count[idx]) in diff_check()
1912 if (dp->df_count[i] == 0) in diff_check()
1916 if (dp->df_count[i] != dp->df_count[idx]) in diff_check()
1927 && dp->df_count[i] != 0) in diff_check()
1928 if (!diff_equal_entry(dp, idx, i)) in diff_check()
1949 if (curtab->tp_diffbuf[i] != NULL && dp->df_count[i] > maxcount) in diff_check()
1950 maxcount = dp->df_count[i]; in diff_check()
1951 return maxcount - dp->df_count[idx]; in diff_check()
1958 diff_equal_entry(diff_T *dp, int idx1, int idx2) in diff_equal_entry() argument
1964 if (dp->df_count[idx1] != dp->df_count[idx2]) in diff_equal_entry()
1966 if (diff_check_sanity(curtab, dp) == FAIL) in diff_equal_entry()
1968 for (i = 0; i < dp->df_count[idx1]; ++i) in diff_equal_entry()
1971 dp->df_lnum[idx1] + i, FALSE)); in diff_equal_entry()
1975 dp->df_lnum[idx2] + i, FALSE)); in diff_equal_entry()
2093 diff_T *dp; in diff_set_topline() local
2107 FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) in diff_set_topline()
2108 if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx]) in diff_set_topline()
2110 if (dp == NULL) in diff_set_topline()
2124 towin->w_topline = lnum + (dp->df_lnum[toidx] - dp->df_lnum[fromidx]); in diff_set_topline()
2125 if (lnum >= dp->df_lnum[fromidx]) in diff_set_topline()
2132 && max_count < dp->df_count[i]) in diff_set_topline()
2133 max_count = dp->df_count[i]; in diff_set_topline()
2135 if (dp->df_count[toidx] == dp->df_count[fromidx]) in diff_set_topline()
2140 else if (dp->df_count[toidx] > dp->df_count[fromidx]) in diff_set_topline()
2142 if (lnum == dp->df_lnum[fromidx] + dp->df_count[fromidx]) in diff_set_topline()
2146 if (max_count - fromwin->w_topfill >= dp->df_count[toidx]) in diff_set_topline()
2149 towin->w_topline = dp->df_lnum[toidx] in diff_set_topline()
2150 + dp->df_count[toidx]; in diff_set_topline()
2155 towin->w_topline = dp->df_lnum[toidx] in diff_set_topline()
2159 else if (towin->w_topline >= dp->df_lnum[toidx] in diff_set_topline()
2160 + dp->df_count[toidx]) in diff_set_topline()
2164 towin->w_topline = dp->df_lnum[toidx] + dp->df_count[toidx]; in diff_set_topline()
2167 if (lnum == dp->df_lnum[fromidx] + dp->df_count[fromidx]) in diff_set_topline()
2172 towin->w_topfill = dp->df_lnum[fromidx] in diff_set_topline()
2397 diff_T *dp; in diff_find_change() local
2417 FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) in diff_find_change()
2418 if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) in diff_find_change()
2420 if (dp == NULL || diff_check_sanity(curtab, dp) == FAIL) in diff_find_change()
2426 off = lnum - dp->df_lnum[idx]; in diff_find_change()
2432 if (off >= dp->df_count[i]) in diff_find_change()
2436 dp->df_lnum[i] + off, FALSE); in diff_find_change()
2526 diff_T *dp; in diff_infold() local
2551 FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) in diff_infold()
2554 if (dp->df_lnum[idx] - diff_context > lnum) in diff_infold()
2557 if (dp->df_lnum[idx] + dp->df_count[idx] + diff_context > lnum) in diff_infold()
2607 diff_T *dp; in ex_diffgetput() local
2740 for (dp = curtab->tp_first_diff; dp != NULL; ) in ex_diffgetput()
2742 if (dp->df_lnum[idx_cur] > eap->line2 + off) in ex_diffgetput()
2746 lnum = dp->df_lnum[idx_to]; in ex_diffgetput()
2747 count = dp->df_count[idx_to]; in ex_diffgetput()
2748 if (dp->df_lnum[idx_cur] + dp->df_count[idx_cur] > eap->line1 + off in ex_diffgetput()
2757 start_skip = eap->line1 + off - dp->df_lnum[idx_cur]; in ex_diffgetput()
2775 end_skip = dp->df_lnum[idx_cur] + dp->df_count[idx_cur] - 1 in ex_diffgetput()
2782 i = dp->df_count[idx_cur] - start_skip - end_skip; in ex_diffgetput()
2789 end_skip = dp->df_count[idx_from] - start_skip - count; in ex_diffgetput()
2807 for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i) in ex_diffgetput()
2811 nr = dp->df_lnum[idx_from] + start_skip + i; in ex_diffgetput()
2830 new_count = dp->df_count[idx_to] + added; in ex_diffgetput()
2831 dp->df_count[idx_to] = new_count; in ex_diffgetput()
2840 && !diff_equal_entry(dp, idx_from, i)) in ex_diffgetput()
2845 dfree = dp; in ex_diffgetput()
2846 dp = dp->df_next; in ex_diffgetput()
2848 curtab->tp_first_diff = dp; in ex_diffgetput()
2850 dprev->df_next = dp; in ex_diffgetput()
2880 dp->df_count[idx_to] = new_count; in ex_diffgetput()
2890 dprev = dp; in ex_diffgetput()
2891 dp = dp->df_next; in ex_diffgetput()
2935 diff_fold_update(diff_T *dp, int skip_idx) in diff_fold_update() argument
2943 foldUpdate(wp, dp->df_lnum[i], in diff_fold_update()
2944 dp->df_lnum[i] + dp->df_count[i]); in diff_fold_update()
2971 diff_T *dp; in diff_move_to() local
2989 for (dp = curtab->tp_first_diff; ; dp = dp->df_next) in diff_move_to()
2991 if (dp == NULL) in diff_move_to()
2993 if ((dir == FORWARD && lnum < dp->df_lnum[idx]) in diff_move_to()
2995 && (dp->df_next == NULL in diff_move_to()
2996 || lnum <= dp->df_next->df_lnum[idx]))) in diff_move_to()
2998 lnum = dp->df_lnum[idx]; in diff_move_to()
3030 diff_T *dp; in diff_get_corresponding_line_int() local
3044 FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) in diff_get_corresponding_line_int()
3046 if (dp->df_lnum[idx1] > lnum1) in diff_get_corresponding_line_int()
3048 if ((dp->df_lnum[idx1] + dp->df_count[idx1]) > lnum1) in diff_get_corresponding_line_int()
3051 baseline = lnum1 - dp->df_lnum[idx1]; in diff_get_corresponding_line_int()
3052 if (baseline > dp->df_count[idx2]) in diff_get_corresponding_line_int()
3053 baseline = dp->df_count[idx2]; in diff_get_corresponding_line_int()
3055 return dp->df_lnum[idx2] + baseline; in diff_get_corresponding_line_int()
3057 if ( (dp->df_lnum[idx1] == lnum1) in diff_get_corresponding_line_int()
3058 && (dp->df_count[idx1] == 0) in diff_get_corresponding_line_int()
3059 && (dp->df_lnum[idx2] <= curwin->w_cursor.lnum) in diff_get_corresponding_line_int()
3060 && ((dp->df_lnum[idx2] + dp->df_count[idx2]) in diff_get_corresponding_line_int()
3070 baseline = (dp->df_lnum[idx1] + dp->df_count[idx1]) in diff_get_corresponding_line_int()
3071 - (dp->df_lnum[idx2] + dp->df_count[idx2]); in diff_get_corresponding_line_int()
3100 diff_T *dp; in diff_lnum_win() local
3113 FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp) in diff_lnum_win()
3114 if (lnum <= dp->df_lnum[idx] + dp->df_count[idx]) in diff_lnum_win()
3118 if (dp == NULL) in diff_lnum_win()
3127 n = lnum + (dp->df_lnum[i] - dp->df_lnum[idx]); in diff_lnum_win()
3128 if (n > dp->df_lnum[i] + dp->df_count[i]) in diff_lnum_win()
3129 n = dp->df_lnum[i] + dp->df_count[i]; in diff_lnum_win()