diff options
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 0b7f6f266b..2b3010e063 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -18,6 +18,7 @@ #include "auto/config.h" #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" +#include "nvim/autocmd_defs.h" #include "nvim/buffer.h" #include "nvim/bufwrite.h" #include "nvim/change.h" @@ -30,25 +31,30 @@ #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/extmark.h" +#include "nvim/extmark_defs.h" #include "nvim/fileio.h" #include "nvim/fold.h" -#include "nvim/func_attr.h" #include "nvim/garray.h" -#include "nvim/gettext.h" +#include "nvim/garray_defs.h" +#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/linematch.h" #include "nvim/mark.h" #include "nvim/mbyte.h" +#include "nvim/mbyte_defs.h" #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" #include "nvim/option.h" +#include "nvim/option_defs.h" #include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/fs.h" +#include "nvim/os/fs_defs.h" #include "nvim/os/os.h" +#include "nvim/os/os_defs.h" #include "nvim/os/shell.h" #include "nvim/path.h" #include "nvim/pos_defs.h" @@ -60,7 +66,7 @@ #include "nvim/window.h" #include "xdiff/xdiff.h" -static int diff_busy = false; // using diff structs, don't change them +static bool diff_busy = false; // using diff structs, don't change them static bool diff_need_update = false; // ex_diffupdate needs to be called // Flags obtained from the 'diffopt' option @@ -385,7 +391,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, linenr_T } dp->df_lnum[idx] += amount_after; } else { - int check_unchanged = false; + bool check_unchanged = false; // 2. 3. 4. 5.: inserted/deleted lines touching this diff. if (deleted > 0) { @@ -1004,7 +1010,7 @@ theend: static int check_external_diff(diffio_T *diffio) { // May try twice, first with "-a" and then without. - int io_error = false; + bool io_error = false; TriState ok = kFalse; while (true) { ok = kFalse; @@ -1013,7 +1019,7 @@ static int check_external_diff(diffio_T *diffio) if (fd == NULL) { io_error = true; } else { - if (fwrite("line1\n", (size_t)6, (size_t)1, fd) != 1) { + if (fwrite("line1\n", 6, 1, fd) != 1) { io_error = true; } fclose(fd); @@ -1022,7 +1028,7 @@ static int check_external_diff(diffio_T *diffio) if (fd == NULL) { io_error = true; } else { - if (fwrite("line2\n", (size_t)6, (size_t)1, fd) != 1) { + if (fwrite("line2\n", 6, 1, fd) != 1) { io_error = true; } fclose(fd); @@ -1167,9 +1173,9 @@ static int diff_file(diffio_T *dio) tmp_orig, tmp_new); append_redir(cmd, len, p_srr, tmp_diff); block_autocmds(); // Avoid ShellCmdPost stuff - (void)call_shell(cmd, - kShellOptFilter | kShellOptSilent | kShellOptDoOut, - NULL); + call_shell(cmd, + kShellOptFilter | kShellOptSilent | kShellOptDoOut, + NULL); unblock_autocmds(); xfree(cmd); return OK; @@ -1251,7 +1257,7 @@ void ex_diffpatch(exarg_T *eap) vim_snprintf(buf, buflen, "patch -o %s %s < %s", tmp_new, tmp_orig, esc_name); block_autocmds(); // Avoid ShellCmdPost stuff - (void)call_shell(buf, kShellOptFilter, NULL); + call_shell(buf, kShellOptFilter, NULL); unblock_autocmds(); } @@ -1390,7 +1396,7 @@ static void set_diff_option(win_T *wp, bool value) curwin = wp; curbuf = curwin->w_buffer; curbuf->b_ro_locked++; - set_option_value_give_err("diff", BOOLEAN_OPTVAL(value), OPT_LOCAL); + set_option_value_give_err(kOptDiff, BOOLEAN_OPTVAL(value), OPT_LOCAL); curbuf->b_ro_locked--; curwin = old_curwin; curbuf = curwin->w_buffer; @@ -1399,7 +1405,7 @@ static void set_diff_option(win_T *wp, bool value) /// Set options in window "wp" for diff mode. /// /// @param addbuf Add buffer to diff. -void diff_win_options(win_T *wp, int addbuf) +void diff_win_options(win_T *wp, bool addbuf) { win_T *old_curwin = curwin; @@ -1431,7 +1437,7 @@ void diff_win_options(win_T *wp, int addbuf) } wp->w_p_fdm_save = xstrdup(wp->w_p_fdm); } - set_string_option_direct_in_win(wp, "fdm", -1, "diff", OPT_LOCAL | OPT_FREE, 0); + set_string_option_direct_in_win(wp, kOptFoldmethod, "diff", OPT_LOCAL, 0); if (!wp->w_p_diff) { wp->w_p_fen_save = wp->w_p_fen; @@ -1473,7 +1479,7 @@ void diff_win_options(win_T *wp, int addbuf) /// @param eap void ex_diffoff(exarg_T *eap) { - int diffwin = false; + bool diffwin = false; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (eap->forceit ? wp->w_p_diff : (wp == curwin)) { @@ -1889,7 +1895,7 @@ static void count_filler_lines_and_topline(int *curlinenum_to, int *linesfiller, { const diff_T *curdif = thistopdiff; int ch_virtual_lines = 0; - int isfiller = 0; + bool isfiller = false; while (virtual_lines_passed > 0) { if (ch_virtual_lines) { virtual_lines_passed--; @@ -1902,7 +1908,7 @@ static void count_filler_lines_and_topline(int *curlinenum_to, int *linesfiller, } else { (*linesfiller) = 0; ch_virtual_lines = get_max_diff_length(curdif); - isfiller = (curdif->df_count[toidx] ? 0 : 1); + isfiller = (curdif->df_count[toidx] ? false : true); if (isfiller) { while (curdif && curdif->df_next && curdif->df_lnum[toidx] == curdif->df_next->df_lnum[toidx] @@ -2156,12 +2162,12 @@ int diff_check_with_linestatus(win_T *wp, linenr_T lnum, int *linestatus) } if (lnum < dp->df_lnum[idx] + dp->df_count[idx]) { - int zero = false; + bool zero = false; // 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. - int cmp = false; + bool cmp = false; for (int i = 0; i < DB_COUNT; i++) { if ((i != idx) && (curtab->tp_diffbuf[i] != NULL)) { @@ -2196,7 +2202,7 @@ int diff_check_with_linestatus(win_T *wp, linenr_T lnum, int *linestatus) // the difference. Can't remove the entry here, we might be halfway // through updating the window. Just report the text as unchanged. // Other windows might still show the change though. - if (zero == false) { + if (!zero) { return 0; } return -2; @@ -2445,8 +2451,8 @@ void diff_set_topline(win_T *fromwin, win_T *towin) changed_line_abv_curs_win(towin); check_topfill(towin, false); - (void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline, - NULL, true, NULL); + hasFoldingWin(towin, towin->w_topline, &towin->w_topline, + NULL, true, NULL); } /// This is called when 'diffopt' is changed. @@ -2846,7 +2852,7 @@ void ex_diffgetput(exarg_T *eap) } if (*eap->arg == NUL) { - int found_not_ma = false; + bool found_not_ma = false; // No argument: Find the other buffer in the list of diff buffers. for (idx_other = 0; idx_other < DB_COUNT; idx_other++) { if ((curtab->tp_diffbuf[idx_other] != curbuf) |