aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-07-16 01:40:59 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-01 15:28:44 -0400
commit9e203989084a35f819751694f0fbf080e1a24bec (patch)
tree00946ea57c694dbb1ac72424a6267503d16bbddb /src/nvim/diff.c
parenta095a48987469865577d1035109877354bb67f5c (diff)
downloadrneovim-9e203989084a35f819751694f0fbf080e1a24bec.tar.gz
rneovim-9e203989084a35f819751694f0fbf080e1a24bec.tar.bz2
rneovim-9e203989084a35f819751694f0fbf080e1a24bec.zip
diff: refactor diff_a_works to use TriState
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c18
1 files changed, 9 insertions, 9 deletions
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 " : "",