aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-08-01 04:20:35 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-08-01 04:20:35 -0400
commit28946c285b41f199ae1d2ddd214e57b7f442fbb1 (patch)
treeb38eaa0f0909c9488ec7a84f57996cdadc7b439d /src
parent309296545cf0c8556d82f81703eef4cdc7e539d3 (diff)
downloadrneovim-28946c285b41f199ae1d2ddd214e57b7f442fbb1.tar.gz
rneovim-28946c285b41f199ae1d2ddd214e57b7f442fbb1.tar.bz2
rneovim-28946c285b41f199ae1d2ddd214e57b7f442fbb1.zip
lint
Diffstat (limited to 'src')
-rw-r--r--src/nvim/fileio.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 82cf79722e..56c74fbfd6 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -4807,13 +4807,12 @@ buf_check_timestamp(
char_u *path;
char *mesg = NULL;
char *mesg2 = "";
- int helpmesg = FALSE;
- int reload = FALSE;
- int can_reload = FALSE;
+ bool helpmesg = false;
+ bool reload = false;
+ bool can_reload = false;
uint64_t orig_size = buf->b_orig_size;
int orig_mode = buf->b_orig_mode;
- static int busy = FALSE;
- int n;
+ static bool busy = false;
char_u *s;
char *reason;
@@ -4838,8 +4837,7 @@ buf_check_timestamp(
&& buf->b_mtime != 0
&& (!(file_info_ok = os_fileinfo((char *)buf->b_ffname, &file_info))
|| time_differs(file_info.stat.st_mtim.tv_sec, buf->b_mtime)
- || (int)file_info.stat.st_mode != buf->b_orig_mode
- )) {
+ || (int)file_info.stat.st_mode != buf->b_orig_mode)) {
const long prev_b_mtime = buf->b_mtime;
retval = 1;
@@ -4858,28 +4856,25 @@ buf_check_timestamp(
/* Don't do anything for a directory. Might contain the file
* explorer. */
- if (os_isdir(buf->b_fname))
- ;
-
- /*
- * If 'autoread' is set, the buffer has no changes and the file still
- * exists, reload the buffer. Use the buffer-local option value if it
- * was set, the global option value otherwise.
- */
- else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
- && !bufIsChanged(buf) && file_info_ok)
- reload = TRUE;
- else {
- if (!file_info_ok)
+ if (os_isdir(buf->b_fname)) {
+ } else if ((buf->b_p_ar >= 0 ? buf->b_p_ar : p_ar)
+ && !bufIsChanged(buf) && file_info_ok) {
+ // If 'autoread' is set, the buffer has no changes and the file still
+ // exists, reload the buffer. Use the buffer-local option value if it
+ // was set, the global option value otherwise.
+ reload = true;
+ } else {
+ if (!file_info_ok) {
reason = "deleted";
- else if (bufIsChanged(buf))
+ } else if (bufIsChanged(buf)) {
reason = "conflict";
- else if (orig_size != buf->b_orig_size || buf_contents_changed(buf))
+ } else if (orig_size != buf->b_orig_size || buf_contents_changed(buf)) {
reason = "changed";
- else if (orig_mode != buf->b_orig_mode)
+ } else if (orig_mode != buf->b_orig_mode) {
reason = "mode";
- else
+ } else {
reason = "time";
+ }
// Only give the warning if there are no FileChangedShell
// autocommands.
@@ -4888,8 +4883,8 @@ buf_check_timestamp(
set_vim_var_string(VV_FCS_REASON, reason, -1);
set_vim_var_string(VV_FCS_CHOICE, "", -1);
allbuf_lock++;
- n = apply_autocmds(EVENT_FILECHANGEDSHELL,
- buf->b_fname, buf->b_fname, false, buf);
+ bool n = apply_autocmds(EVENT_FILECHANGEDSHELL,
+ buf->b_fname, buf->b_fname, false, buf);
allbuf_lock--;
busy = false;
if (n) {
@@ -4897,12 +4892,13 @@ buf_check_timestamp(
EMSG(_("E246: FileChangedShell autocommand deleted buffer"));
}
s = get_vim_var_str(VV_FCS_CHOICE);
- if (STRCMP(s, "reload") == 0 && *reason != 'd')
- reload = TRUE;
- else if (STRCMP(s, "ask") == 0)
- n = FALSE;
- else
+ if (STRCMP(s, "reload") == 0 && *reason != 'd') {
+ reload = true;
+ } else if (STRCMP(s, "ask") == 0) {
+ n = false;
+ } else {
return 2;
+ }
}
if (!n) {
if (*reason == 'd') {
@@ -4911,14 +4907,13 @@ buf_check_timestamp(
mesg = _("E211: File \"%s\" no longer available");
}
} else {
- helpmesg = TRUE;
- can_reload = TRUE;
- /*
- * Check if the file contents really changed to avoid
- * giving a warning when only the timestamp was set (e.g.,
- * checked out of CVS). Always warn when the buffer was
- * changed.
- */
+ helpmesg = true;
+ can_reload = true;
+
+ // Check if the file contents really changed to avoid
+ // giving a warning when only the timestamp was set (e.g.,
+ // checked out of CVS). Always warn when the buffer was
+ // changed.
if (reason[2] == 'n') {
mesg = _(
"W12: Warning: File \"%s\" has changed and the buffer was changed in Vim as well");
@@ -4944,7 +4939,7 @@ buf_check_timestamp(
retval = 1;
mesg = _("W13: Warning: File \"%s\" has been created after editing started");
buf->b_flags |= BF_NEW_W;
- can_reload = TRUE;
+ can_reload = true;
}
if (mesg != NULL) {