aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
authordundargoc <gocdundar@gmail.com>2022-10-22 12:36:38 +0200
committerdundargoc <gocdundar@gmail.com>2022-11-06 11:44:10 +0100
commit731cdde28ea8d48cc23ba2752a08c261c87eee92 (patch)
tree92e814050fdbca64aca435f03975b6d5678fbdf3 /src/nvim/diff.c
parenta79d28e4d7939c13f38cf4ce63ff240011bca96d (diff)
downloadrneovim-731cdde28ea8d48cc23ba2752a08c261c87eee92.tar.gz
rneovim-731cdde28ea8d48cc23ba2752a08c261c87eee92.tar.bz2
rneovim-731cdde28ea8d48cc23ba2752a08c261c87eee92.zip
refactor: fix clang-tidy warnings
Enable and fix bugprone-misplaced-widening-cast warning. Fix some modernize-macro-to-enum and readability-else-after-return warnings, but don't enable them. While the warnings can be useful, they are in general too noisy to enable.
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 503e546562..b20d0976e4 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1133,37 +1133,36 @@ static int diff_file(diffio_T *dio)
// Use xdiff for generating the diff.
if (dio->dio_internal) {
return diff_file_internal(dio);
- } else {
- const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
- + strlen(p_srr) + 27);
- char *const cmd = xmalloc(len);
-
- // We don't want $DIFF_OPTIONS to get in the way.
- if (os_getenv("DIFF_OPTIONS")) {
- os_unsetenv("DIFF_OPTIONS");
- }
-
- // Build the diff command and execute it. Always use -a, binary
- // 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%s%s %s",
- diff_a_works == kFalse ? "" : "-a ",
- "",
- (diff_flags & DIFF_IWHITE) ? "-b " : "",
- (diff_flags & DIFF_IWHITEALL) ? "-w " : "",
- (diff_flags & DIFF_IWHITEEOL) ? "-Z " : "",
- (diff_flags & DIFF_IBLANK) ? "-B " : "",
- (diff_flags & DIFF_ICASE) ? "-i " : "",
- tmp_orig, tmp_new);
- append_redir(cmd, len, p_srr, tmp_diff);
- block_autocmds(); // Avoid ShellCmdPost stuff
- (void)call_shell((char_u *)cmd,
- kShellOptFilter | kShellOptSilent | kShellOptDoOut,
- NULL);
- unblock_autocmds();
- xfree(cmd);
- return OK;
}
+ const size_t len = (strlen(tmp_orig) + strlen(tmp_new) + strlen(tmp_diff)
+ + strlen(p_srr) + 27);
+ char *const cmd = xmalloc(len);
+
+ // We don't want $DIFF_OPTIONS to get in the way.
+ if (os_getenv("DIFF_OPTIONS")) {
+ os_unsetenv("DIFF_OPTIONS");
+ }
+
+ // Build the diff command and execute it. Always use -a, binary
+ // 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%s%s %s",
+ diff_a_works == kFalse ? "" : "-a ",
+ "",
+ (diff_flags & DIFF_IWHITE) ? "-b " : "",
+ (diff_flags & DIFF_IWHITEALL) ? "-w " : "",
+ (diff_flags & DIFF_IWHITEEOL) ? "-Z " : "",
+ (diff_flags & DIFF_IBLANK) ? "-B " : "",
+ (diff_flags & DIFF_ICASE) ? "-i " : "",
+ tmp_orig, tmp_new);
+ append_redir(cmd, len, p_srr, tmp_diff);
+ block_autocmds(); // Avoid ShellCmdPost stuff
+ (void)call_shell((char_u *)cmd,
+ kShellOptFilter | kShellOptSilent | kShellOptDoOut,
+ NULL);
+ unblock_autocmds();
+ xfree(cmd);
+ return OK;
}
/// Create a new version of a file from the current buffer and a diff file.