diff options
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/src/fileio.c b/src/fileio.c index 1ee08e21ed..d8b395acfd 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2767,15 +2767,15 @@ set_file_options(int set_options, exarg_T *eap) void set_forced_fenc(exarg_T *eap) { - if (eap->force_enc != 0) - { - char_u *fenc = enc_canonize(eap->cmd + eap->force_enc); + if (eap->force_enc == 0) + return; - if (fenc != NULL) - set_string_option_direct((char_u *)"fenc", -1, - fenc, OPT_FREE|OPT_LOCAL, 0); - vim_free(fenc); - } + char_u *fenc = enc_canonize(eap->cmd + eap->force_enc); + + if (fenc != NULL) + set_string_option_direct((char_u *)"fenc", -1, + fenc, OPT_FREE|OPT_LOCAL, 0); + vim_free(fenc); } /* @@ -5070,12 +5070,11 @@ vim_opentempdir(void) return; dp = opendir((const char*)vim_tempdir); + if (dp == NULL) + return; - if (dp != NULL) - { - vim_tempdir_dp = dp; - flock(dirfd(vim_tempdir_dp), LOCK_SH); - } + vim_tempdir_dp = dp; + flock(dirfd(vim_tempdir_dp), LOCK_SH); } /* @@ -5084,11 +5083,11 @@ vim_opentempdir(void) 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 @@ -5098,16 +5097,16 @@ vim_closetempdir(void) void vim_deltempdir(void) { - if (vim_tempdir != NULL) - { + if (vim_tempdir == NULL) + return; + # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD) - vim_closetempdir(); + vim_closetempdir(); # endif - // remove the trailing path separator - gettail(vim_tempdir)[-1] = NUL; - delete_recursive(vim_tempdir); - VIM_CLEAR(vim_tempdir); - } + // remove the trailing path separator + gettail(vim_tempdir)[-1] = NUL; + delete_recursive(vim_tempdir); + VIM_CLEAR(vim_tempdir); } /* @@ -5121,17 +5120,17 @@ vim_settempdir(char_u *tempdir) char_u *buf; buf = alloc(MAXPATHL + 2); - if (buf != NULL) - { - if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL) - STRCPY(buf, tempdir); - add_pathsep(buf); - vim_tempdir = vim_strsave(buf); + if (buf == NULL) + return; + + if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL) + STRCPY(buf, tempdir); + add_pathsep(buf); + vim_tempdir = vim_strsave(buf); # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD) - vim_opentempdir(); + vim_opentempdir(); # endif - vim_free(buf); - } + vim_free(buf); } #endif |