From 5864edac7be49a0cd0080a65330dd7661ffb5641 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 29 Dec 2021 02:01:02 +0000 Subject: vim-patch:8.1.2302: :lockmarks does not work for '[ and '] Problem: :lockmarks does not work for '[ and ']. Solution: save and restore '[ and '] marks. (James McCoy, closes vim/vim#5222) https://github.com/vim/vim/commit/f4a1d1c0542df151bc59ac3b798ed198b5c71ccc Test_diff_maintains_change_mark doesn't actually fail without these changes. This is fixed in v8.2.3936. --- src/nvim/diff.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 340fec230c..233753839b 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -790,9 +790,14 @@ static int diff_write(buf_T *buf, diffin_T *din) // Always use 'fileformat' set to "unix". char_u *save_ff = buf->b_p_ff; buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); + const bool save_lockmarks = cmdmod.lockmarks; + // Writing the buffer is an implementation detail of performing the diff, + // so it shouldn't update the '[ and '] marks. + cmdmod.lockmarks = true; int r = buf_write(buf, din->din_fname, NULL, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, false, false, true); + cmdmod.lockmarks = save_lockmarks; free_string_option(buf->b_p_ff); buf->b_p_ff = save_ff; return r; -- cgit From 991e472881bf29805982b402c1a010cde051ded3 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 28 May 2021 15:45:34 -0400 Subject: feat(lua): add api and lua autocmds --- src/nvim/diff.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 233753839b..80bd3229c6 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -85,9 +85,9 @@ typedef struct { // used for recording hunks from xdiff typedef struct { linenr_T lnum_orig; - long count_orig; + long count_orig; linenr_T lnum_new; - long count_new; + long count_new; } diffhunk_T; // two diff inputs and one result @@ -1285,7 +1285,7 @@ void ex_diffpatch(exarg_T *eap) ex_file(eap); // Do filetype detection with the new name. - if (au_has_group((char_u *)"filetypedetect")) { + if (augroup_exists("filetypedetect")) { do_cmdline_cmd(":doau filetypedetect BufRead"); } } @@ -3159,8 +3159,7 @@ static int parse_diff_unified(char_u *line, diffhunk_T *hunk) /// Callback function for the xdl_diff() function. /// Stores the diff output in a grow array. /// -static int xdiff_out(long start_a, long count_a, long start_b, long count_b, - void *priv) +static int xdiff_out(long start_a, long count_a, long start_b, long count_b, void *priv) { diffout_T *dout = (diffout_T *)priv; diffhunk_T *p = xmalloc(sizeof(*p)); -- cgit From 4ba12b3dda34472c193c9fa8ffd7d3bd5b6c04d6 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 13 Mar 2022 15:11:17 +0100 Subject: refactor: fix clint warnings (#17682) --- src/nvim/diff.c | 68 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 80bd3229c6..a3e45b8784 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -167,7 +167,7 @@ void diff_buf_add(buf_T *buf) } int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (curtab->tp_diffbuf[i] == NULL) { curtab->tp_diffbuf[i] = buf; curtab->tp_diff_invalid = true; @@ -201,7 +201,7 @@ static void diff_buf_clear(void) static int diff_buf_idx(buf_T *buf) { int idx; - for (idx = 0; idx < DB_COUNT; ++idx) { + for (idx = 0; idx < DB_COUNT; idx++) { if (curtab->tp_diffbuf[idx] == buf) { break; } @@ -218,7 +218,7 @@ static int diff_buf_idx(buf_T *buf) static int diff_buf_idx_tp(buf_T *buf, tabpage_T *tp) { int idx; - for (idx = 0; idx < DB_COUNT; ++idx) { + for (idx = 0; idx < DB_COUNT; idx++) { if (tp->tp_diffbuf[idx] == buf) { break; } @@ -323,7 +323,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T dnext->df_lnum[idx] = line1; dnext->df_count[idx] = inserted; int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((tp->tp_diffbuf[i] != NULL) && (i != idx)) { if (dprev == NULL) { dnext->df_lnum[i] = line1; @@ -421,7 +421,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T } int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((tp->tp_diffbuf[i] != NULL) && (i != idx)) { dp->df_lnum[i] -= off; dp->df_count[i] += n; @@ -442,7 +442,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T // Check if inserted lines are equal, may reduce the size of the // diff. // - // TODO: also check for equal lines in the middle and perhaps split + // TODO(unknown): also check for equal lines in the middle and perhaps split // the block. diff_check_unchanged(tp, dp); } @@ -453,7 +453,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T if ((dprev != NULL) && (dprev->df_lnum[idx] + dprev->df_count[idx] == dp->df_lnum[idx])) { int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (tp->tp_diffbuf[i] != NULL) { dprev->df_count[i] += dp->df_count[i]; } @@ -474,7 +474,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T while (dp != NULL) { // All counts are zero, remove this entry. int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((tp->tp_diffbuf[i] != NULL) && (dp->df_count[i] != 0)) { break; } @@ -542,7 +542,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) // Find the first buffers, use it as the original, compare the other // buffer lines against this one. int i_org; - for (i_org = 0; i_org < DB_COUNT; ++i_org) { + for (i_org = 0; i_org < DB_COUNT; i_org++) { if (tp->tp_diffbuf[i_org] != NULL) { break; } @@ -574,7 +574,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) false)); int i_new; - for (i_new = i_org + 1; i_new < DB_COUNT; ++i_new) { + for (i_new = i_org + 1; i_new < DB_COUNT; i_new++) { if (tp->tp_diffbuf[i_new] == NULL) { continue; } @@ -602,7 +602,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) } // Line matched in all buffers, remove it from the diff. - for (i_new = i_org; i_new < DB_COUNT; ++i_new) { + for (i_new = i_org; i_new < DB_COUNT; i_new++) { if (tp->tp_diffbuf[i_new] != NULL) { if (dir == FORWARD) { dp->df_lnum[i_new]++; @@ -629,7 +629,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) static int diff_check_sanity(tabpage_T *tp, diff_T *dp) { int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (tp->tp_diffbuf[i] != NULL) { if (dp->df_lnum[i] + dp->df_count[i] - 1 > tp->tp_diffbuf[i]->b_ml.ml_line_count) { @@ -927,7 +927,7 @@ void ex_diffupdate(exarg_T *eap) // Use the first buffer as the original text. int idx_orig; - for (idx_orig = 0; idx_orig < DB_COUNT; ++idx_orig) { + for (idx_orig = 0; idx_orig < DB_COUNT; idx_orig++) { if (curtab->tp_diffbuf[idx_orig] != NULL) { break; } @@ -939,7 +939,7 @@ void ex_diffupdate(exarg_T *eap) // Only need to do something when there is another buffer. int idx_new; - for (idx_new = idx_orig + 1; idx_new < DB_COUNT; ++idx_new) { + for (idx_new = idx_orig + 1; idx_new < DB_COUNT; idx_new++) { if (curtab->tp_diffbuf[idx_new] != NULL) { break; } @@ -1659,7 +1659,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) off = dp->df_lnum[idx_orig] - hunk->lnum_orig; if (off > 0) { - for (i = idx_orig; i < idx_new; ++i) { + for (i = idx_orig; i < idx_new; i++) { if (curtab->tp_diffbuf[i] != NULL) { dp->df_lnum[i] -= off; } @@ -1693,7 +1693,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) off = 0; } - for (i = idx_orig; i < idx_new; ++i) { + for (i = idx_orig; i < idx_new; i++) { if (curtab->tp_diffbuf[i] != NULL) { dp->df_count[i] = dpl->df_lnum[i] + dpl->df_count[i] - dp->df_lnum[i] + off; @@ -1721,7 +1721,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) // Set values for other buffers, these must be equal to the // original buffer, otherwise there would have been a change // already. - for (i = idx_orig + 1; i < idx_new; ++i) { + for (i = idx_orig + 1; i < idx_new; i++) { if (curtab->tp_diffbuf[i] != NULL) { diff_copy_entry(dprev, dp, idx_orig, i); } @@ -1852,7 +1852,7 @@ int diff_check(win_T *wp, linenr_T lnum) // count, check if the lines are identical. cmp = false; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL)) { if (dp->df_count[i] == 0) { zero = true; @@ -1869,7 +1869,7 @@ int diff_check(win_T *wp, linenr_T lnum) if (cmp) { // Compare all lines. If they are equal the lines were inserted // in some buffers, deleted in others, but not changed. - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] != 0)) { @@ -1899,7 +1899,7 @@ int diff_check(win_T *wp, linenr_T lnum) // Insert filler lines above the line just below the change. Will return // 0 when this buf had the max count. maxcount = 0; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] > maxcount)) { maxcount = dp->df_count[i]; } @@ -2073,7 +2073,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) // buffers we need to know the largest count. max_count = 0; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (max_count < dp->df_count[i])) { max_count = dp->df_count[i]; } @@ -2219,7 +2219,7 @@ int diffopt_changed(void) } if (*p == ',') { - ++p; + p++; } } @@ -2322,7 +2322,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) int off = lnum - dp->df_lnum[idx]; int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (i != idx)) { // Skip lines that are not in the other change (filler lines). if (off >= dp->df_count[i]) { @@ -2430,7 +2430,7 @@ bool diff_infold(win_T *wp, linenr_T lnum) int idx = -1; int i; - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if (curtab->tp_diffbuf[i] == wp->w_buffer) { idx = i; } else if (curtab->tp_diffbuf[i] != NULL) { @@ -2480,7 +2480,7 @@ void nv_diffgetput(bool put, size_t count) if (count == 0) { ea.arg = (char_u *)""; } else { - vim_snprintf(buf, 30, "%zu", count); + vim_snprintf(buf, sizeof(buf), "%zu", count); ea.arg = (char_u *)buf; } @@ -2529,7 +2529,7 @@ void ex_diffgetput(exarg_T *eap) if (*eap->arg == NUL) { // No argument: Find the other buffer in the list of diff buffers. - for (idx_other = 0; idx_other < DB_COUNT; ++idx_other) { + for (idx_other = 0; idx_other < DB_COUNT; idx_other++) { if ((curtab->tp_diffbuf[idx_other] != curbuf) && (curtab->tp_diffbuf[idx_other] != NULL)) { if ((eap->cmdidx != CMD_diffput) @@ -2550,7 +2550,7 @@ void ex_diffgetput(exarg_T *eap) } // Check that there isn't a third buffer in the list - for (i = idx_other + 1; i < DB_COUNT; ++i) { + for (i = idx_other + 1; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != curbuf) && (curtab->tp_diffbuf[i] != NULL) && ((eap->cmdidx != CMD_diffput) @@ -2567,7 +2567,7 @@ void ex_diffgetput(exarg_T *eap) p--; } - for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; ++i) { + for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) { } if (eap->arg + i == p) { @@ -2610,9 +2610,9 @@ void ex_diffgetput(exarg_T *eap) && (eap->line1 == curbuf->b_ml.ml_line_count) && (diff_check(curwin, eap->line1) == 0) && ((eap->line1 == 1) || (diff_check(curwin, eap->line1 - 1) == 0))) { - ++eap->line2; + eap->line2++; } else if (eap->line1 > 0) { - --eap->line1; + eap->line1--; } } @@ -2703,14 +2703,14 @@ void ex_diffgetput(exarg_T *eap) buf_empty = buf_is_empty(curbuf); added = 0; - for (i = 0; i < count; ++i) { + for (i = 0; i < count; i++) { // remember deleting the last line of the buffer buf_empty = curbuf->b_ml.ml_line_count == 1; ml_delete(lnum, false); added--; } - for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i) { + for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; i++) { linenr_T nr = dp->df_lnum[idx_from] + start_skip + i; if (nr > curtab->tp_diffbuf[idx_from]->b_ml.ml_line_count) { break; @@ -2732,7 +2732,7 @@ void ex_diffgetput(exarg_T *eap) if ((start_skip == 0) && (end_skip == 0)) { // Check if there are any other buffers and if the diff is // equal in them. - for (i = 0; i < DB_COUNT; ++i) { + for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (i != idx_from) && (i != idx_to) @@ -2835,7 +2835,7 @@ theend: static void diff_fold_update(diff_T *dp, int skip_idx) { FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - for (int i = 0; i < DB_COUNT; ++i) { + for (int i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] == wp->w_buffer) && (i != skip_idx)) { foldUpdate(wp, dp->df_lnum[i], dp->df_lnum[i] + dp->df_count[i]); } -- cgit From 198bf3a8f2897d679a297fd04e3183dbac8bd61e Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Sat, 12 Mar 2022 17:54:31 +0100 Subject: refactor: minimize variable scope and eliminate empty declarations --- src/nvim/diff.c | 104 +++++++++++++++++++++----------------------------------- 1 file changed, 39 insertions(+), 65 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index a3e45b8784..1b8a9f41e9 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -166,8 +166,7 @@ void diff_buf_add(buf_T *buf) return; } - int i; - for (i = 0; i < DB_COUNT; i++) { + for (int i = 0; i < DB_COUNT; i++) { if (curtab->tp_diffbuf[i] == NULL) { curtab->tp_diffbuf[i] = buf; curtab->tp_diff_invalid = true; @@ -304,7 +303,6 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T diff_T *dprev = NULL; diff_T *dp = tp->tp_first_diff; - linenr_T last; linenr_T lnum_deleted = line1; // lnum of remaining deletion int n; int off; @@ -354,7 +352,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T // 3 5 6 // compute last line of this change - last = dp->df_lnum[idx] + dp->df_count[idx] - 1; + linenr_T last = dp->df_lnum[idx] + dp->df_count[idx] - 1; // 1. change completely above line1: nothing to do if (last >= line1 - 1) { @@ -628,8 +626,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) /// @return OK if the diff block doesn't contain invalid line numbers. static int diff_check_sanity(tabpage_T *tp, diff_T *dp) { - int i; - for (i = 0; i < DB_COUNT; i++) { + for (int i = 0; i < DB_COUNT; i++) { if (tp->tp_diffbuf[i] != NULL) { if (dp->df_lnum[i] + dp->df_count[i] - 1 > tp->tp_diffbuf[i]->b_ml.ml_line_count) { @@ -719,16 +716,13 @@ static void clear_diffout(diffout_T *dout) /// @return FAIL for failure. static int diff_write_buffer(buf_T *buf, diffin_T *din) { - linenr_T lnum; - char_u *s; long len = 0; - char_u *ptr; // xdiff requires one big block of memory with all the text. - for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { + for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { len += (long)STRLEN(ml_get_buf(buf, lnum, false)) + 1; } - ptr = try_malloc(len); + char_u *ptr = try_malloc(len); if (ptr == NULL) { // Allocating memory failed. This can happen, because we try to read // the whole buffer text into memory. Set the failed flag, the diff @@ -746,8 +740,8 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) din->din_mmfile.size = len; len = 0; - for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { - for (s = ml_get_buf(buf, lnum, false); *s != NUL;) { + for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { + for (char_u *s = ml_get_buf(buf, lnum, false); *s != NUL;) { if (diff_flags & DIFF_ICASE) { char_u cbuf[MB_MAXBYTES + 1]; @@ -811,9 +805,6 @@ static int diff_write(buf_T *buf, diffin_T *din) /// @param eap can be NULL static void diff_try_update(diffio_T *dio, int idx_orig, exarg_T *eap) { - buf_T *buf; - int idx_new; - if (dio->dio_internal) { ga_init(&dio->dio_diff.dout_ga, sizeof(char *), 1000); } else { @@ -833,9 +824,11 @@ static void diff_try_update(diffio_T *dio, int idx_orig, exarg_T *eap) goto theend; } + buf_T *buf; + // :diffupdate! if (eap != NULL && eap->forceit) { - for (idx_new = idx_orig; idx_new < DB_COUNT; idx_new++) { + for (int idx_new = idx_orig; idx_new < DB_COUNT; idx_new++) { buf = curtab->tp_diffbuf[idx_new]; if (buf_valid(buf)) { buf_check_timestamp(buf); @@ -850,7 +843,7 @@ static void diff_try_update(diffio_T *dio, int idx_orig, exarg_T *eap) } // Make a difference between the first buffer and every other. - for (idx_new = idx_orig + 1; idx_new < DB_COUNT; idx_new++) { + for (int idx_new = idx_orig + 1; idx_new < DB_COUNT; idx_new++) { buf = curtab->tp_diffbuf[idx_new]; if (buf == NULL || buf->b_ml.ml_mfp == NULL) { continue; // skip buffer that isn't loaded @@ -893,10 +886,8 @@ int diff_internal(void) /// static int diff_internal_failed(void) { - int idx; - // Only need to do something when there is another buffer. - for (idx = 0; idx < DB_COUNT; idx++) { + for (int idx = 0; idx < DB_COUNT; idx++) { if (curtab->tp_diffbuf[idx] != NULL && curtab->tp_diffbuf[idx]->b_diff_failed) { return true; @@ -1775,9 +1766,8 @@ static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int idx_new void diff_clear(tabpage_T *tp) FUNC_ATTR_NONNULL_ALL { - diff_T *p; diff_T *next_p; - for (p = tp->tp_first_diff; p != NULL; p = next_p) { + for (diff_T *p = tp->tp_first_diff; p != NULL; p = next_p) { next_p = p->df_next; xfree(p); } @@ -1799,12 +1789,8 @@ void diff_clear(tabpage_T *tp) /// @return diff status. int diff_check(win_T *wp, linenr_T lnum) { - int idx; // index in tp_diffbuf[] for this buffer diff_T *dp; - int maxcount; - int i; buf_T *buf = wp->w_buffer; - int cmp; if (curtab->tp_diff_invalid) { // update after a big change @@ -1821,7 +1807,7 @@ int diff_check(win_T *wp, linenr_T lnum) return 0; } - idx = diff_buf_idx(buf); + int idx = diff_buf_idx(buf); // index in tp_diffbuf[] for this buffer if (idx == DB_COUNT) { // no diffs for buffer "buf" @@ -1850,9 +1836,9 @@ int diff_check(win_T *wp, linenr_T lnum) // Changed or inserted line. If the other buffers have a count of // zero, the lines were inserted. If the other buffers have the same // count, check if the lines are identical. - cmp = false; + int cmp = false; - for (i = 0; i < DB_COUNT; i++) { + for (int i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL)) { if (dp->df_count[i] == 0) { zero = true; @@ -1869,7 +1855,7 @@ int diff_check(win_T *wp, linenr_T lnum) if (cmp) { // Compare all lines. If they are equal the lines were inserted // in some buffers, deleted in others, but not changed. - for (i = 0; i < DB_COUNT; i++) { + for (int i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] != 0)) { @@ -1898,8 +1884,8 @@ int diff_check(win_T *wp, linenr_T lnum) // Insert filler lines above the line just below the change. Will return // 0 when this buf had the max count. - maxcount = 0; - for (i = 0; i < DB_COUNT; i++) { + int maxcount = 0; + for (int i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] > maxcount)) { maxcount = dp->df_count[i]; } @@ -2030,8 +2016,6 @@ void diff_set_topline(win_T *fromwin, win_T *towin) buf_T *frombuf = fromwin->w_buffer; linenr_T lnum = fromwin->w_topline; diff_T *dp; - int max_count; - int i; int fromidx = diff_buf_idx(frombuf); if (fromidx == DB_COUNT) { @@ -2071,9 +2055,9 @@ void diff_set_topline(win_T *fromwin, win_T *towin) if (lnum >= dp->df_lnum[fromidx]) { // Inside a change: compute filler lines. With three or more // buffers we need to know the largest count. - max_count = 0; + int max_count = 0; - for (i = 0; i < DB_COUNT; i++) { + for (int i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (max_count < dp->df_count[i])) { max_count = dp->df_count[i]; } @@ -2421,7 +2405,6 @@ bool diff_infold(win_T *wp, linenr_T lnum) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1) { bool other = false; - diff_T *dp; // Return if 'diff' isn't set. if (!wp->w_p_diff) { @@ -2453,7 +2436,7 @@ bool diff_infold(win_T *wp, linenr_T lnum) return true; } - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { + for (diff_T *dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { // If this change is below the line there can't be any further match. if (dp->df_lnum[idx] - diff_context > lnum) { break; @@ -2505,7 +2488,6 @@ void ex_diffgetput(exarg_T *eap) int count; linenr_T off = 0; diff_T *dp; - diff_T *dprev; diff_T *dfree; int i; int added; @@ -2641,7 +2623,7 @@ void ex_diffgetput(exarg_T *eap) } } - dprev = NULL; + diff_T *dprev = NULL; for (dp = curtab->tp_first_diff; dp != NULL;) { if (dp->df_lnum[idx_cur] > eap->line2 + off) { @@ -2924,13 +2906,10 @@ int diff_move_to(int dir, long count) /// "buf1" in diff mode. static linenr_T diff_get_corresponding_line_int(buf_T *buf1, linenr_T lnum1) { - int idx1; - int idx2; - diff_T *dp; int baseline = 0; - idx1 = diff_buf_idx(buf1); - idx2 = diff_buf_idx(curbuf); + int idx1 = diff_buf_idx(buf1); + int idx2 = diff_buf_idx(curbuf); if ((idx1 == DB_COUNT) || (idx2 == DB_COUNT) @@ -2948,7 +2927,7 @@ static linenr_T diff_get_corresponding_line_int(buf_T *buf1, linenr_T lnum1) return lnum1; } - for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { + for (diff_T *dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { if (dp->df_lnum[idx1] > lnum1) { return lnum1 - baseline; } @@ -3004,11 +2983,8 @@ linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1) linenr_T diff_lnum_win(linenr_T lnum, win_T *wp) { diff_T *dp; - int idx; - int i; - linenr_T n; - idx = diff_buf_idx(curbuf); + int idx = diff_buf_idx(curbuf); if (idx == DB_COUNT) { // safety check @@ -3034,14 +3010,14 @@ linenr_T diff_lnum_win(linenr_T lnum, win_T *wp) } // Find index for "wp". - i = diff_buf_idx(wp->w_buffer); + int i = diff_buf_idx(wp->w_buffer); if (i == DB_COUNT) { // safety check return (linenr_T)0; } - n = lnum + (dp->df_lnum[i] - dp->df_lnum[idx]); + linenr_T n = lnum + (dp->df_lnum[i] - dp->df_lnum[idx]); if (n > dp->df_lnum[i] + dp->df_count[i]) { n = dp->df_lnum[i] + dp->df_count[i]; } @@ -3054,16 +3030,14 @@ linenr_T diff_lnum_win(linenr_T lnum, win_T *wp) /// static int parse_diff_ed(char_u *line, diffhunk_T *hunk) { - char_u *p; - long f1, l1, f2, l2; - int difftype; + long l1, l2; // The line must be one of three formats: // change: {first}[,{last}]c{first}[,{last}] // append: {first}a{first}[,{last}] // delete: {first}[,{last}]d{first} - p = line; - f1 = getdigits(&p, true, 0); + char_u *p = line; + long f1 = getdigits(&p, true, 0); if (*p == ',') { p++; l1 = getdigits(&p, true, 0); @@ -3073,8 +3047,8 @@ static int parse_diff_ed(char_u *line, diffhunk_T *hunk) if (*p != 'a' && *p != 'c' && *p != 'd') { return FAIL; // invalid diff format } - difftype = *p++; - f2 = getdigits(&p, true, 0); + int difftype = *p++; + long f2 = getdigits(&p, true, 0); if (*p == ',') { p++; l2 = getdigits(&p, true, 0); @@ -3108,14 +3082,14 @@ static int parse_diff_ed(char_u *line, diffhunk_T *hunk) /// static int parse_diff_unified(char_u *line, diffhunk_T *hunk) { - char_u *p; - long oldline, oldcount, newline, newcount; - // Parse unified diff hunk header: // @@ -oldline,oldcount +newline,newcount @@ - p = line; + char_u *p = line; if (*p++ == '@' && *p++ == '@' && *p++ == ' ' && *p++ == '-') { - oldline = getdigits(&p, true, 0); + long oldcount; + long newline; + long newcount; + long oldline = getdigits(&p, true, 0); if (*p == ',') { p++; oldcount = getdigits(&p, true, 0); -- cgit From 82304038a239bb833e88c9c342aae19ab5dda489 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Sat, 26 Mar 2022 11:54:31 +0100 Subject: vim-patch:8.2.3943: compiler warning from gcc for uninitialized variable Problem: Compiler warning from gcc for uninitialized variable. Solution: Initialize variable. (closes vim/vim#9429) https://github.com/vim/vim/commit/491669701c72578f273db53e579d8a03a9deac0c --- src/nvim/diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 1b8a9f41e9..a6bbe40999 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1536,7 +1536,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) long off; int i; int notset = true; // block "*dp" not set yet - diffhunk_T *hunk; + diffhunk_T *hunk = NULL; // init to avoid gcc warning enum { DIFF_ED, DIFF_UNIFIED, -- cgit From 2c7dc648ca796786b4847771c1df71dea20a1774 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 8 Apr 2022 10:45:42 +0800 Subject: vim-patch:8.2.3925: diff mode confused by NUL bytes (#18033) Problem: Diff mode confused by NUL bytes. Solution: Handle NUL bytes differently. (Christian Brabandt, closes vim/vim#9421, closes vim/vim#9418) https://github.com/vim/vim/commit/06f6095623cfcc72da08748c058d13b465652fd4 --- src/nvim/diff.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index a6bbe40999..0b55fb877c 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -743,11 +743,16 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { for (char_u *s = ml_get_buf(buf, lnum, false); *s != NUL;) { if (diff_flags & DIFF_ICASE) { + int c; char_u cbuf[MB_MAXBYTES + 1]; - // xdiff doesn't support ignoring case, fold-case the text. - int c = utf_ptr2char(s); - c = utf_fold(c); + if (*s == NL) { + c = NUL; + } else { + // xdiff doesn't support ignoring case, fold-case the text. + c = utf_ptr2char(s); + c = utf_fold(c); + } const int orig_len = utfc_ptr2len(s); if (utf_char2bytes(c, cbuf) != orig_len) { // TODO(Bram): handle byte length difference @@ -759,7 +764,8 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) s += orig_len; len += orig_len; } else { - ptr[len++] = *s++; + ptr[len++] = *s == NL ? NUL : *s; + s++; } } ptr[len++] = NL; -- cgit From 0fb571e3b5043f136f2394d84b942b8c93fdde45 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Mon, 11 Apr 2022 18:29:48 +0200 Subject: refactor: add pure attribute to pure functions This will allow compilers that support the pure attribute to make further optimizations to functions. --- src/nvim/diff.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 0b55fb877c..9e8fa2e62d 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -883,6 +883,7 @@ theend: /// diff will be used anyway. /// int diff_internal(void) + FUNC_ATTR_PURE { return (diff_flags & DIFF_INTERNAL) != 0 && *p_dex == NUL; } @@ -2250,6 +2251,7 @@ bool diffopt_horizontal(void) // Return true if 'diffopt' contains "hiddenoff". bool diffopt_hiddenoff(void) + FUNC_ATTR_PURE { return (diff_flags & DIFF_HIDDEN_OFF) != 0; } -- cgit From 7813fa2f8cc3885788abc5c5dceea6638d8416e6 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:13:59 +0200 Subject: refactor: enable Wconversion warning for diff (#18094) Work on https://github.com/neovim/neovim/issues/567 --- src/nvim/diff.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 9e8fa2e62d..2fa96e4fc2 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -284,8 +284,8 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T tp->tp_diff_update = true; } - int inserted; - int deleted; + long inserted; + long deleted; if (line2 == MAXLNUM) { // mark_adjust(99, MAXLNUM, 9, 0): insert lines inserted = amount; @@ -304,8 +304,8 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T diff_T *dp = tp->tp_first_diff; linenr_T lnum_deleted = line1; // lnum of remaining deletion - int n; - int off; + linenr_T n; + linenr_T off; for (;;) { // If the change is after the previous diff block and before the next // diff block, thus not touching an existing change, create a new diff @@ -556,8 +556,8 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp) } // First check lines at the top, then at the bottom. - int off_org = 0; - int off_new = 0; + linenr_T off_org = 0; + linenr_T off_new = 0; int dir = FORWARD; for (;;) { // Repeat until a line is found which is different or the number of @@ -722,7 +722,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { len += (long)STRLEN(ml_get_buf(buf, lnum, false)) + 1; } - char_u *ptr = try_malloc(len); + char_u *ptr = try_malloc((size_t)len); if (ptr == NULL) { // Allocating memory failed. This can happen, because we try to read // the whole buffer text into memory. Set the failed flag, the diff @@ -756,9 +756,9 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) const int orig_len = utfc_ptr2len(s); if (utf_char2bytes(c, cbuf) != orig_len) { // TODO(Bram): handle byte length difference - memmove(ptr + len, s, orig_len); + memmove(ptr + len, s, (size_t)orig_len); } else { - memmove(ptr + len, cbuf, orig_len); + memmove(ptr + len, cbuf, (size_t)orig_len); } s += orig_len; @@ -1072,7 +1072,7 @@ static int diff_file_internal(diffio_T *diffio) memset(&emit_cfg, 0, sizeof(emit_cfg)); memset(&emit_cb, 0, sizeof(emit_cb)); - param.flags = diff_algorithm; + param.flags = (unsigned long)diff_algorithm; if (diff_flags & DIFF_IWHITE) { param.flags |= XDF_IGNORE_WHITESPACE_CHANGE; @@ -1891,13 +1891,13 @@ int diff_check(win_T *wp, linenr_T lnum) // Insert filler lines above the line just below the change. Will return // 0 when this buf had the max count. - int maxcount = 0; + linenr_T maxcount = 0; for (int i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (dp->df_count[i] > maxcount)) { maxcount = dp->df_count[i]; } } - return maxcount - dp->df_count[idx]; + return (int)(maxcount - dp->df_count[idx]); } /// Compare two entries in diff "dp" and return true if they are equal. @@ -2062,7 +2062,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) if (lnum >= dp->df_lnum[fromidx]) { // Inside a change: compute filler lines. With three or more // buffers we need to know the largest count. - int max_count = 0; + linenr_T max_count = 0; for (int i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (max_count < dp->df_count[i])) { @@ -2099,7 +2099,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) towin->w_topfill = fromwin->w_topfill; } else { // fromwin has some diff lines - towin->w_topfill = dp->df_lnum[fromidx] + max_count - lnum; + towin->w_topfill = (int)(dp->df_lnum[fromidx] + max_count - lnum); } } } @@ -2312,7 +2312,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) return false; } - int off = lnum - dp->df_lnum[idx]; + linenr_T off = lnum - dp->df_lnum[idx]; int i; for (i = 0; i < DB_COUNT; i++) { if ((curtab->tp_diffbuf[i] != NULL) && (i != idx)) { @@ -2493,7 +2493,7 @@ void nv_diffgetput(bool put, size_t count) void ex_diffgetput(exarg_T *eap) { linenr_T lnum; - int count; + linenr_T count; linenr_T off = 0; diff_T *dp; diff_T *dfree; @@ -2502,8 +2502,9 @@ void ex_diffgetput(exarg_T *eap) char_u *p; aco_save_T aco; buf_T *buf; - int start_skip, end_skip; - int new_count; + linenr_T start_skip; + linenr_T end_skip; + linenr_T new_count; int buf_empty; int found_not_ma = false; int idx_other; @@ -2562,7 +2563,7 @@ void ex_diffgetput(exarg_T *eap) if (eap->arg + i == p) { // digits only - i = atol((char *)eap->arg); + i = (int)atol((char *)eap->arg); } else { i = buflist_findpat(eap->arg, p, false, true, false); @@ -2671,7 +2672,7 @@ void ex_diffgetput(exarg_T *eap) // range ends above end of current/from diff block if (idx_cur == idx_from) { // :diffput - i = dp->df_count[idx_cur] - start_skip - end_skip; + i = (int)(dp->df_count[idx_cur] - start_skip - end_skip); if (count > i) { count = i; @@ -2914,7 +2915,7 @@ int diff_move_to(int dir, long count) /// "buf1" in diff mode. static linenr_T diff_get_corresponding_line_int(buf_T *buf1, linenr_T lnum1) { - int baseline = 0; + linenr_T baseline = 0; int idx1 = diff_buf_idx(buf1); int idx2 = diff_buf_idx(curbuf); -- cgit From eef8de4df0247157e57f306062b1b86e01a41454 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Fri, 29 Apr 2022 13:53:42 +0200 Subject: refactor(uncrustify): change rules to better align with the style guide Add space around arithmetic operators '+' and '-'. Remove space between back-to-back parentheses, i.e. ')(' vs. ') ('. Remove space between '((' or '))' of control statements. Add space between ')' and '{' of control statements. Remove space between function name and '(' on function declaration. Collapse empty blocks between '{' and '}'. Remove newline at the end of the file. Remove newline between 'enum' and '{'. Remove newline between '}' and ')' in a function invocation. Remove newline between '}' and 'while' of 'do' statement. --- src/nvim/diff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 2fa96e4fc2..cfb1c35817 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2558,8 +2558,7 @@ void ex_diffgetput(exarg_T *eap) p--; } - for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) { - } + for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) {} if (eap->arg + i == p) { // digits only -- cgit From 5576d30e89153c817fb1a8d23c30cfc0432bc7c6 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Tue, 3 May 2022 11:06:27 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index cfb1c35817..52ae1bc819 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1186,9 +1186,9 @@ void ex_diffpatch(exarg_T *eap) #ifdef UNIX // Get the absolute path of the patchfile, changing directory below. - fullname = FullName_save((char *)eap->arg, false); + fullname = FullName_save(eap->arg, false); esc_name = - vim_strsave_shellescape((fullname != NULL ? (char_u *)fullname : eap->arg), true, true); + vim_strsave_shellescape((char_u *)(fullname != NULL ? fullname : eap->arg), true, true); #else esc_name = vim_strsave_shellescape(eap->arg, true, true); #endif @@ -1219,7 +1219,7 @@ void ex_diffpatch(exarg_T *eap) // Use 'patchexpr' to generate the new file. #ifdef UNIX eval_patch((char *)tmp_orig, - (fullname != NULL ? fullname : (char *)eap->arg), + (fullname != NULL ? fullname : eap->arg), (char *)tmp_new); #else eval_patch((char *)tmp_orig, (char *)eap->arg, (char *)tmp_new); @@ -1268,7 +1268,7 @@ void ex_diffpatch(exarg_T *eap) if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { // Pretend it was a ":split fname" command eap->cmdidx = CMD_split; - eap->arg = tmp_new; + eap->arg = (char *)tmp_new; do_exedit(eap, old_curwin); // check that split worked and editing tmp_new @@ -1279,7 +1279,7 @@ void ex_diffpatch(exarg_T *eap) if (newname != NULL) { // do a ":file filename.new" on the patched buffer - eap->arg = newname; + eap->arg = (char *)newname; ex_file(eap); // Do filetype detection with the new name. @@ -2469,10 +2469,10 @@ void nv_diffgetput(bool put, size_t count) return; } if (count == 0) { - ea.arg = (char_u *)""; + ea.arg = ""; } else { vim_snprintf(buf, sizeof(buf), "%zu", count); - ea.arg = (char_u *)buf; + ea.arg = buf; } if (put) { @@ -2553,18 +2553,18 @@ void ex_diffgetput(exarg_T *eap) } } else { // Buffer number or pattern given. Ignore trailing white space. - p = eap->arg + STRLEN(eap->arg); - while (p > eap->arg && ascii_iswhite(p[-1])) { + p = (char_u *)eap->arg + STRLEN(eap->arg); + while (p > (char_u *)eap->arg && ascii_iswhite(p[-1])) { p--; } - for (i = 0; ascii_isdigit(eap->arg[i]) && eap->arg + i < p; i++) {} + for (i = 0; ascii_isdigit(eap->arg[i]) && (char_u *)eap->arg + i < p; i++) {} - if (eap->arg + i == p) { + if ((char_u *)eap->arg + i == p) { // digits only - i = (int)atol((char *)eap->arg); + i = (int)atol(eap->arg); } else { - i = buflist_findpat(eap->arg, p, false, true, false); + i = buflist_findpat((char_u *)eap->arg, p, false, true, false); if (i < 0) { // error message already given -- cgit From 9a671e6a24243a5ff2879599d91ab5aec8b4e77d Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Wed, 4 May 2022 18:27:22 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 52ae1bc819..6b606f50a1 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2706,7 +2706,7 @@ void ex_diffgetput(exarg_T *eap) break; } p = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx_from], nr, false)); - ml_append(lnum + i - 1, p, 0, false); + ml_append(lnum + i - 1, (char *)p, 0, false); xfree(p); added++; if (buf_empty && (curbuf->b_ml.ml_line_count == 2)) { -- cgit From 2a378e6e82cececb12339f2df51ffe107039d867 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Wed, 4 May 2022 22:35:50 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 6b606f50a1..7e296ebf52 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -750,10 +750,10 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) c = NUL; } else { // xdiff doesn't support ignoring case, fold-case the text. - c = utf_ptr2char(s); + c = utf_ptr2char((char *)s); c = utf_fold(c); } - const int orig_len = utfc_ptr2len(s); + const int orig_len = utfc_ptr2len((char *)s); if (utf_char2bytes(c, cbuf) != orig_len) { // TODO(Bram): handle byte length difference memmove(ptr + len, s, (size_t)orig_len); @@ -1937,15 +1937,15 @@ static bool diff_equal_entry(diff_T *dp, int idx1, int idx2) // ignoring case) return true and set "len" to the number of bytes. static bool diff_equal_char(const char_u *const p1, const char_u *const p2, int *const len) { - const int l = utfc_ptr2len(p1); + const int l = utfc_ptr2len((char *)p1); - if (l != utfc_ptr2len(p2)) { + if (l != utfc_ptr2len((char *)p2)) { return false; } if (l > 1) { if (STRNCMP(p1, p2, l) != 0 && (!(diff_flags & DIFF_ICASE) - || utf_fold(utf_ptr2char(p1)) != utf_fold(utf_ptr2char(p2)))) { + || utf_fold(utf_ptr2char((char *)p1)) != utf_fold(utf_ptr2char((char *)p2)))) { return false; } *len = l; -- cgit From e31b32a293f6ba8708499a176234f8be1df6a145 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Thu, 5 May 2022 13:36:14 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 7e296ebf52..55992f3fae 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -754,7 +754,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) c = utf_fold(c); } const int orig_len = utfc_ptr2len((char *)s); - if (utf_char2bytes(c, cbuf) != orig_len) { + if (utf_char2bytes(c, (char *)cbuf) != orig_len) { // TODO(Bram): handle byte length difference memmove(ptr + len, s, (size_t)orig_len); } else { @@ -1970,7 +1970,7 @@ static bool diff_equal_char(const char_u *const p1, const char_u *const p2, int static int diff_cmp(char_u *s1, char_u *s2) { if ((diff_flags & DIFF_IBLANK) - && (*skipwhite(s1) == NUL || *skipwhite(s2) == NUL)) { + && (*(char_u *)skipwhite((char *)s1) == NUL || *skipwhite((char *)s2) == NUL)) { return 0; } @@ -1991,8 +1991,8 @@ static int diff_cmp(char_u *s1, char_u *s2) && ascii_iswhite(*p1) && ascii_iswhite(*p2)) || ((diff_flags & DIFF_IWHITEALL) && (ascii_iswhite(*p1) || ascii_iswhite(*p2)))) { - p1 = skipwhite(p1); - p2 = skipwhite(p2); + p1 = (char_u *)skipwhite((char *)p1); + p2 = (char_u *)skipwhite((char *)p2); } else { int l; if (!diff_equal_char(p1, p2, &l)) { @@ -2004,8 +2004,8 @@ static int diff_cmp(char_u *s1, char_u *s2) } // Ignore trailing white space. - p1 = skipwhite(p1); - p2 = skipwhite(p2); + p1 = (char_u *)skipwhite((char *)p1); + p2 = (char_u *)skipwhite((char *)p2); if ((*p1 != NUL) || (*p2 != NUL)) { return 1; @@ -2334,8 +2334,8 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) || ((diff_flags & DIFF_IWHITEALL) && (ascii_iswhite(line_org[si_org]) || ascii_iswhite(line_new[si_new])))) { - si_org = (int)(skipwhite(line_org + si_org) - line_org); - si_new = (int)(skipwhite(line_new + si_new) - line_new); + si_org = (int)((char_u *)skipwhite((char *)line_org + si_org) - line_org); + si_new = (int)((char_u *)skipwhite((char *)line_new + si_new) - line_new); } else { if (!diff_equal_char(line_org + si_org, line_new + si_new, &l)) { break; -- cgit From 85aae12a6dea48621ea2d24a946b3e7b86f9014d Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Sun, 8 May 2022 14:43:16 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 55992f3fae..dcc9b51431 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -744,7 +744,7 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) for (char_u *s = ml_get_buf(buf, lnum, false); *s != NUL;) { if (diff_flags & DIFF_ICASE) { int c; - char_u cbuf[MB_MAXBYTES + 1]; + char cbuf[MB_MAXBYTES + 1]; if (*s == NL) { c = NUL; @@ -794,7 +794,7 @@ static int diff_write(buf_T *buf, diffin_T *din) // Writing the buffer is an implementation detail of performing the diff, // so it shouldn't update the '[ and '] marks. cmdmod.lockmarks = true; - int r = buf_write(buf, din->din_fname, NULL, + int r = buf_write(buf, (char *)din->din_fname, NULL, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, false, false, true); cmdmod.lockmarks = save_lockmarks; @@ -1178,7 +1178,7 @@ void ex_diffpatch(exarg_T *eap) } // Write the current buffer to "tmp_orig". - if (buf_write(curbuf, tmp_orig, NULL, + if (buf_write(curbuf, (char *)tmp_orig, NULL, (linenr_T)1, curbuf->b_ml.ml_line_count, NULL, false, false, false, true) == FAIL) { goto theend; @@ -1982,8 +1982,8 @@ static int diff_cmp(char_u *s1, char_u *s2) return mb_stricmp((const char *)s1, (const char *)s2); } - char_u *p1 = s1; - char_u *p2 = s2; + char *p1 = (char *)s1; + char *p2 = (char *)s2; // Ignore white space changes and possibly ignore case. while (*p1 != NUL && *p2 != NUL) { @@ -1991,11 +1991,11 @@ static int diff_cmp(char_u *s1, char_u *s2) && ascii_iswhite(*p1) && ascii_iswhite(*p2)) || ((diff_flags & DIFF_IWHITEALL) && (ascii_iswhite(*p1) || ascii_iswhite(*p2)))) { - p1 = (char_u *)skipwhite((char *)p1); - p2 = (char_u *)skipwhite((char *)p2); + p1 = skipwhite(p1); + p2 = skipwhite(p2); } else { int l; - if (!diff_equal_char(p1, p2, &l)) { + if (!diff_equal_char((char_u *)p1, (char_u *)p2, &l)) { break; } p1 += l; @@ -2004,8 +2004,8 @@ static int diff_cmp(char_u *s1, char_u *s2) } // Ignore trailing white space. - p1 = (char_u *)skipwhite((char *)p1); - p2 = (char_u *)skipwhite((char *)p2); + p1 = skipwhite(p1); + p2 = skipwhite(p2); if ((*p1 != NUL) || (*p2 != NUL)) { return 1; -- cgit From f0148de7907ec297647816d51c79745be729439e Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Mon, 9 May 2022 11:49:32 +0200 Subject: refactor: replace char_u variables and functions with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index dcc9b51431..e8d54d7030 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1160,7 +1160,7 @@ void ex_diffpatch(exarg_T *eap) { char_u *buf = NULL; win_T *old_curwin = curwin; - char_u *newname = NULL; // name of patched file buffer + char *newname = NULL; // name of patched file buffer char_u *esc_name = NULL; #ifdef UNIX @@ -1258,7 +1258,7 @@ void ex_diffpatch(exarg_T *eap) emsg(_("E816: Cannot read patch output")); } else { if (curbuf->b_fname != NULL) { - newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4); + newname = xstrnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4); STRCAT(newname, ".new"); } @@ -1279,7 +1279,7 @@ void ex_diffpatch(exarg_T *eap) if (newname != NULL) { // do a ":file filename.new" on the patched buffer - eap->arg = (char *)newname; + eap->arg = newname; ex_file(eap); // Do filetype detection with the new name. -- cgit From 9fec6dc9a25b5cf9c9a444ac2bd0728e8af3229e Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 25 May 2022 20:31:14 +0200 Subject: refactor(uncrustify): set maximum number of consecutive newlines to 2 (#18695) --- src/nvim/diff.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index e8d54d7030..8c98c1ef23 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1371,7 +1371,6 @@ static void set_diff_option(win_T *wp, int value) curbuf = curwin->w_buffer; } - /// Set options in window "wp" for diff mode. /// /// @param addbuf Add buffer to diff. @@ -2036,7 +2035,6 @@ void 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) { if (lnum <= dp->df_lnum[fromidx] + dp->df_count[fromidx]) { -- cgit From 6d57bb89c1ee376b60198f4a4b75430905844138 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 9 Jun 2022 17:09:24 +0200 Subject: build: add a cmake target for all used linters #18543 * build: move the logic for linters to cmake Cmake is our source of truth. We should have as much of our build process there as possible so everyone can make use of it. * build: remove redundant check for ninja generator The minimum cmake version as of writing this is 3.10, which has ninja support. --- src/nvim/diff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 8c98c1ef23..1625632842 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2307,6 +2307,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp) if ((dp == NULL) || (diff_check_sanity(curtab, dp) == FAIL)) { xfree(line_org); + return false; } -- cgit From a732c253b71f89702285d5ec6fd7803045f6add9 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Sat, 7 May 2022 12:53:37 +0200 Subject: refactor: change type of linenr_T from long to int32_t The size of long varies depending on architecture, in contrast to the MAXLNUM constant which sets the maximum allowable number of lines to 2^32-1. This discrepancy may lead to hard to detect bugs, for example https://github.com/neovim/neovim/issues/18454. Setting linenr_T to a fix maximum size of 2^32-1 will prevent this type of errors in the future. Also change the variables `amount` and `amount_after` to be linenr_T since they're referring to "the line number difference" between two texts. --- src/nvim/diff.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 1625632842..a622100918 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -248,7 +248,7 @@ void diff_invalidate(buf_T *buf) /// @param line2 /// @param amount /// @param amount_after -void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after) +void diff_mark_adjust(linenr_T line1, linenr_T line2, linenr_T amount, linenr_T amount_after) { // Handle all tab pages that use the current buffer in a diff. FOR_ALL_TABS(tp) { @@ -272,8 +272,8 @@ void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_a /// @param line2 /// @param amount /// @amount_after -static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T line2, long amount, - long amount_after) +static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T line2, + linenr_T amount, linenr_T amount_after) { if (diff_internal()) { // Will update diffs before redrawing. Set _invalid to update the @@ -284,8 +284,8 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T tp->tp_diff_update = true; } - long inserted; - long deleted; + linenr_T inserted; + linenr_T deleted; if (line2 == MAXLNUM) { // mark_adjust(99, MAXLNUM, 9, 0): insert lines inserted = amount; @@ -1539,7 +1539,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) diffout_T *dout = &dio->dio_diff; char_u linebuf[LBUFLEN]; // only need to hold the diff line char_u *line; - long off; + linenr_T off; int i; int notset = true; // block "*dp" not set yet diffhunk_T *hunk = NULL; // init to avoid gcc warning @@ -1662,14 +1662,14 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) } } dp->df_lnum[idx_new] = hunk->lnum_new; - dp->df_count[idx_new] = hunk->count_new; + dp->df_count[idx_new] = (linenr_T)hunk->count_new; } else if (notset) { // new block inside existing one, adjust new block dp->df_lnum[idx_new] = hunk->lnum_new + off; - dp->df_count[idx_new] = hunk->count_new - off; + dp->df_count[idx_new] = (linenr_T)hunk->count_new - off; } else { // second overlap of new block with existing block - dp->df_count[idx_new] += hunk->count_new - hunk->count_orig + dp->df_count[idx_new] += (linenr_T)hunk->count_new - (linenr_T)hunk->count_orig + dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig] - (dp->df_lnum[idx_orig] + @@ -1678,7 +1678,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) // Adjust the size of the block to include all the lines to the // end of the existing block or the new diff, whatever ends last. - off = (hunk->lnum_orig + hunk->count_orig) + off = (hunk->lnum_orig + (linenr_T)hunk->count_orig) - (dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]); if (off < 0) { @@ -1711,9 +1711,9 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) dp = diff_alloc_new(curtab, dprev, dp); dp->df_lnum[idx_orig] = hunk->lnum_orig; - dp->df_count[idx_orig] = hunk->count_orig; + dp->df_count[idx_orig] = (linenr_T)hunk->count_orig; dp->df_lnum[idx_new] = hunk->lnum_new; - dp->df_count[idx_new] = hunk->count_new; + dp->df_count[idx_new] = (linenr_T)hunk->count_new; // Set values for other buffers, these must be equal to the // original buffer, otherwise there would have been a change @@ -1754,7 +1754,7 @@ static void diff_read(int idx_orig, int idx_new, diffio_T *dio) /// @param idx_new static void diff_copy_entry(diff_T *dprev, diff_T *dp, int idx_orig, int idx_new) { - long off; + linenr_T off; if (dprev == NULL) { off = 0; @@ -1896,7 +1896,7 @@ int diff_check(win_T *wp, linenr_T lnum) maxcount = dp->df_count[i]; } } - return (int)(maxcount - dp->df_count[idx]); + return maxcount - dp->df_count[idx]; } /// Compare two entries in diff "dp" and return true if they are equal. @@ -2097,7 +2097,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) towin->w_topfill = fromwin->w_topfill; } else { // fromwin has some diff lines - towin->w_topfill = (int)(dp->df_lnum[fromidx] + max_count - lnum); + towin->w_topfill = dp->df_lnum[fromidx] + max_count - lnum; } } } @@ -2670,7 +2670,7 @@ void ex_diffgetput(exarg_T *eap) // range ends above end of current/from diff block if (idx_cur == idx_from) { // :diffput - i = (int)(dp->df_count[idx_cur] - start_skip - end_skip); + i = dp->df_count[idx_cur] - start_skip - end_skip; if (count > i) { count = i; @@ -2745,7 +2745,7 @@ void ex_diffgetput(exarg_T *eap) // Adjust marks. This will change the following entries! if (added != 0) { - mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added, + mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, added, kExtmarkUndo); if (curwin->w_cursor.lnum >= lnum) { // Adjust the cursor position if it's in/after the changed @@ -2757,7 +2757,7 @@ void ex_diffgetput(exarg_T *eap) } } } - changed_lines(lnum, 0, lnum + count, (long)added, true); + changed_lines(lnum, 0, lnum + count, added, true); if (dfree != NULL) { // Diff is deleted, update folds in other windows. @@ -3044,7 +3044,7 @@ static int parse_diff_ed(char_u *line, diffhunk_T *hunk) // append: {first}a{first}[,{last}] // delete: {first}[,{last}]d{first} char_u *p = line; - long f1 = getdigits(&p, true, 0); + linenr_T f1 = getdigits_int32((char **)&p, true, 0); if (*p == ',') { p++; l1 = getdigits(&p, true, 0); @@ -3074,10 +3074,10 @@ static int parse_diff_ed(char_u *line, diffhunk_T *hunk) hunk->count_orig = l1 - f1 + 1; } if (difftype == 'd') { - hunk->lnum_new = f2 + 1; + hunk->lnum_new = (linenr_T)f2 + 1; hunk->count_new = 0; } else { - hunk->lnum_new = f2; + hunk->lnum_new = (linenr_T)f2; hunk->count_new = l2 - f2 + 1; } return OK; @@ -3125,9 +3125,9 @@ static int parse_diff_unified(char_u *line, diffhunk_T *hunk) newline = 1; } - hunk->lnum_orig = oldline; + hunk->lnum_orig = (linenr_T)oldline; hunk->count_orig = oldcount; - hunk->lnum_new = newline; + hunk->lnum_new = (linenr_T)newline; hunk->count_new = newcount; return OK; @@ -3146,9 +3146,9 @@ static int xdiff_out(long start_a, long count_a, long start_b, long count_b, voi diffhunk_T *p = xmalloc(sizeof(*p)); ga_grow(&dout->dout_ga, 1); - p->lnum_orig = start_a + 1; + p->lnum_orig = (linenr_T)start_a + 1; p->count_orig = count_a; - p->lnum_new = start_b + 1; + p->lnum_new = (linenr_T)start_b + 1; p->count_new = count_b; ((diffhunk_T **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p; return 0; -- cgit From 6130b4a84b41b71f4c0c58093a29585c6c67ff16 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 13 Jun 2022 20:20:34 +0800 Subject: vim-patch:8.2.1898: command modifier parsing always uses global cmdmod Problem: Command modifier parsing always uses global cmdmod. Solution: Pass in cmdmod_T to use. Rename struct fields consistently. https://github.com/vim/vim/commit/e10044015841711b989f9a898d427bcc1fdb4c32 --- src/nvim/diff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index a622100918..700e79ac75 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -790,14 +790,14 @@ static int diff_write(buf_T *buf, diffin_T *din) // Always use 'fileformat' set to "unix". char_u *save_ff = buf->b_p_ff; buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); - const bool save_lockmarks = cmdmod.lockmarks; + const bool save_cmod_flags = cmdmod.cmod_flags; // Writing the buffer is an implementation detail of performing the diff, // so it shouldn't update the '[ and '] marks. - cmdmod.lockmarks = true; + cmdmod.cmod_flags |= CMOD_LOCKMARKS; int r = buf_write(buf, (char *)din->din_fname, NULL, (linenr_T)1, buf->b_ml.ml_line_count, NULL, false, false, false, true); - cmdmod.lockmarks = save_lockmarks; + cmdmod.cmod_flags = save_cmod_flags; free_string_option(buf->b_p_ff); buf->b_p_ff = save_ff; return r; @@ -1263,7 +1263,7 @@ void ex_diffpatch(exarg_T *eap) } // don't use a new tab page, each tab page has its own diffs - cmdmod.tab = 0; + cmdmod.cmod_tab = 0; if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { // Pretend it was a ":split fname" command @@ -1323,7 +1323,7 @@ void ex_diffsplit(exarg_T *eap) set_fraction(curwin); // don't use a new tab page, each tab page has its own diffs - cmdmod.tab = 0; + cmdmod.cmod_tab = 0; if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL) { // Pretend it was a ":split fname" command -- cgit From 014a88799a1d175ad121c520c9cc5bd0bb2d8813 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 28 Jun 2022 11:31:54 +0200 Subject: refactor: replace char_u #18429 Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 700e79ac75..f22933ec3c 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1408,8 +1408,7 @@ void diff_win_options(win_T *wp, int addbuf) } wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm); } - set_string_option_direct("fdm", -1, (char_u *)"diff", - OPT_LOCAL | OPT_FREE, 0); + set_string_option_direct("fdm", -1, "diff", OPT_LOCAL | OPT_FREE, 0); curwin = old_curwin; curbuf = curwin->w_buffer; -- cgit From f50135a32e11c535e1dc3a8e9460c5b4e640ee86 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 30 Jun 2022 13:16:46 +0200 Subject: feat: stdpath('run'), /tmp/nvim.user/ #18993 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Since c57f6b28d71d #8519, sockets are created in ~/.local/… but XDG spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which implies that XDG_STATE_DIR is potentially non-local. - Not easy to inspect Nvim-created temp files (for debugging etc). Solution: - Store sockets in stdpath('run') ($XDG_RUNTIME_DIR). - Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims. - Make ok() actually useful. - Introduce assert_nolog(). closes #3517 closes #17093 --- src/nvim/diff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index f22933ec3c..e4d77cec9c 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1206,7 +1206,7 @@ void ex_diffpatch(exarg_T *eap) || (os_chdir((char *)dirbuf) != 0)) { dirbuf[0] = NUL; } else { - char *tempdir = (char *)vim_gettempdir(); + char *tempdir = vim_gettempdir(); if (tempdir == NULL) { tempdir = "/tmp"; } -- cgit From 3b8804571c565a91c9ce729bb487c7ba21b659e0 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Tue, 28 Jun 2022 13:03:09 +0200 Subject: refactor: replace char_u Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/diff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index e4d77cec9c..75021e90d6 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -2143,7 +2143,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_FILLER; } else if ((STRNCMP(p, "context:", 8) == 0) && ascii_isdigit(p[8])) { p += 8; - diff_context_new = getdigits_int(&p, false, diff_context_new); + diff_context_new = getdigits_int((char **)&p, false, diff_context_new); } else if (STRNCMP(p, "iblank", 6) == 0) { p += 6; diff_flags_new |= DIFF_IBLANK; @@ -2167,7 +2167,7 @@ int diffopt_changed(void) diff_flags_new |= DIFF_VERTICAL; } else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && ascii_isdigit(p[11])) { p += 11; - diff_foldcolumn_new = getdigits_int(&p, false, diff_foldcolumn_new); + diff_foldcolumn_new = getdigits_int((char **)&p, false, diff_foldcolumn_new); } else if (STRNCMP(p, "hiddenoff", 9) == 0) { p += 9; diff_flags_new |= DIFF_HIDDEN_OFF; @@ -2562,7 +2562,7 @@ void ex_diffgetput(exarg_T *eap) // digits only i = (int)atol(eap->arg); } else { - i = buflist_findpat((char_u *)eap->arg, p, false, true, false); + i = buflist_findpat(eap->arg, (char *)p, false, true, false); if (i < 0) { // error message already given -- cgit