aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-03 14:55:00 +0800
committerGitHub <noreply@github.com>2023-01-03 14:55:00 +0800
commit4dd793a256fefb481159f9f93bf7572391e266de (patch)
tree0a4a2c512f38b1e734fdb22650c2929fcd516c65 /src/nvim/fileio.c
parent3a519d86bf4d5ef3ff5623ad925ed856266d80de (diff)
downloadrneovim-4dd793a256fefb481159f9f93bf7572391e266de.tar.gz
rneovim-4dd793a256fefb481159f9f93bf7572391e266de.tar.bz2
rneovim-4dd793a256fefb481159f9f93bf7572391e266de.zip
vim-patch:9.0.1132: code is indented more than needed (#21626)
Problem: Code is indented more than needed. Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan, closes vim/vim#11769) https://github.com/vim/vim/commit/dc4daa3a3915fba11ac87d27977240d9a5e0d47d Omit expand_autoload_callback(): only applies to Vim9 script. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 5e7c7cb943..841320245b 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -2014,11 +2014,13 @@ void set_file_options(int set_options, exarg_T *eap)
/// Set forced 'fileencoding'.
void set_forced_fenc(exarg_T *eap)
{
- if (eap->force_enc != 0) {
- char *fenc = enc_canonize(eap->cmd + eap->force_enc);
- set_string_option_direct("fenc", -1, fenc, OPT_FREE|OPT_LOCAL, 0);
- xfree(fenc);
+ if (eap->force_enc == 0) {
+ return;
}
+
+ char *fenc = enc_canonize(eap->cmd + eap->force_enc);
+ set_string_option_direct("fenc", -1, fenc, OPT_FREE|OPT_LOCAL, 0);
+ xfree(fenc);
}
/// Find next fileencoding to use from 'fileencodings'.
@@ -5348,35 +5350,40 @@ static void vim_opentempdir(void)
}
DIR *dp = opendir(vim_tempdir);
-
- if (dp != NULL) {
- vim_tempdir_dp = dp;
- flock(dirfd(vim_tempdir_dp), LOCK_SH);
+ if (dp == NULL) {
+ return;
}
+
+ vim_tempdir_dp = dp;
+ flock(dirfd(vim_tempdir_dp), LOCK_SH);
}
/// Close temporary directory - it automatically release file lock.
static void vim_closetempdir(void)
{
- if (vim_tempdir_dp != NULL) {
- closedir(vim_tempdir_dp);
- vim_tempdir_dp = NULL;
+ if (vim_tempdir_dp == NULL) {
+ return;
}
+
+ closedir(vim_tempdir_dp);
+ vim_tempdir_dp = NULL;
}
#endif
/// Delete the temp directory and all files it contains.
void vim_deltempdir(void)
{
- if (vim_tempdir != NULL) {
+ if (vim_tempdir == NULL) {
+ return;
+ }
+
#if defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
- vim_closetempdir();
+ vim_closetempdir();
#endif
- // remove the trailing path separator
- path_tail(vim_tempdir)[-1] = NUL;
- delete_recursive(vim_tempdir);
- XFREE_CLEAR(vim_tempdir);
- }
+ // remove the trailing path separator
+ path_tail(vim_tempdir)[-1] = NUL;
+ delete_recursive(vim_tempdir);
+ XFREE_CLEAR(vim_tempdir);
}
/// Gets path to Nvim's own temp dir (ending with slash).
@@ -5401,9 +5408,10 @@ char *vim_gettempdir(void)
static bool vim_settempdir(char *tempdir)
{
char *buf = verbose_try_malloc(MAXPATHL + 2);
- if (!buf) {
+ if (buf == NULL) {
return false;
}
+
vim_FullName(tempdir, buf, MAXPATHL, false);
add_pathsep(buf);
vim_tempdir = xstrdup(buf);