From 9e203989084a35f819751694f0fbf080e1a24bec Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 16 Jul 2018 01:40:59 -0400 Subject: diff: refactor diff_a_works to use TriState --- src/nvim/diff.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 61e0b76558..cc4bc1da6a 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -48,9 +48,9 @@ static int diff_flags = DIFF_FILLER; #define LBUFLEN 50 // length of line in diff file -// TRUE when "diff -a" works, FALSE when it doesn't work, MAYBE when not -// checked yet -static int diff_a_works = MAYBE; +// kTrue when "diff -a" works, kFalse when it doesn't work, +// kNone when not checked yet +static TriState diff_a_works = kNone; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -686,9 +686,9 @@ void ex_diffupdate(exarg_T *eap) // there are differences. // May try twice, first with "-a" and then without. int io_error = false; - bool ok = false; + TriState ok = kFalse; for (;;) { - ok = false; + ok = kFalse; FILE *fd = mch_fopen(tmp_orig, "w"); if (fd == NULL) { @@ -722,7 +722,7 @@ void ex_diffupdate(exarg_T *eap) } if (STRNCMP(linebuf, "1c1", 3) == 0) { - ok = TRUE; + ok = kTrue; } } fclose(fd); @@ -739,7 +739,7 @@ void ex_diffupdate(exarg_T *eap) } // If we checked if "-a" works already, break here. - if (diff_a_works != MAYBE) { + if (diff_a_works != kNone) { break; } diff_a_works = ok; @@ -755,7 +755,7 @@ void ex_diffupdate(exarg_T *eap) EMSG(_("E810: Cannot read or write temp files")); } EMSG(_("E97: Cannot create diffs")); - diff_a_works = MAYBE; + diff_a_works = kNone; goto theend; } @@ -830,7 +830,7 @@ static void diff_file(const char *const tmp_orig, const char *const tmp_new, * differences are of no use. Ignore errors, diff returns * non-zero when differences have been found. */ vim_snprintf(cmd, len, "diff %s%s%s%s%s %s", - diff_a_works ? "-a " : "", + diff_a_works == kFalse ? "" : "-a ", "", (diff_flags & DIFF_IWHITE) ? "-b " : "", (diff_flags & DIFF_ICASE) ? "-i " : "", -- cgit From 3de785e7b58e4d99e02382881767934efcd0f82c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 2 Aug 2018 08:31:04 -0400 Subject: fold: add const to hasFoldingWin() variables cache is bool so update callers to pass true/false, not TRUE/FALSE. --- src/nvim/diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/diff.c') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index cc4bc1da6a..8699c16351 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1486,7 +1486,7 @@ int diff_check(win_T *wp, linenr_T lnum) } // A closed fold never has filler lines. - if (hasFoldingWin(wp, lnum, NULL, NULL, TRUE, NULL)) { + if (hasFoldingWin(wp, lnum, NULL, NULL, true, NULL)) { return 0; } @@ -1793,7 +1793,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) check_topfill(towin, false); (void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline, - NULL, TRUE, NULL); + NULL, true, NULL); } /// This is called when 'diffopt' is changed. -- cgit