From ed0c1d5d4b30d03b26ff08841f6da2ddf44025a7 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 30 Dec 2022 18:07:46 +0000 Subject: patch 9.0.1115: code is indented more than needed Problem: Code is indented more than needed. Solution: Use an early return to reduce indenting. (Yegappan Lakshmanan, closes #11758) --- src/ex_cmds2.c | 115 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 58 deletions(-) (limited to 'src/ex_cmds2.c') diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 3bdbede138..c52c227de9 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -135,19 +135,19 @@ check_changed(buf_T *buf, int flags) void browse_save_fname(buf_T *buf) { - if (buf->b_fname == NULL) - { - char_u *fname; + if (buf->b_fname != NULL) + return; - fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"), - NULL, NULL, NULL, NULL, buf); - if (fname != NULL) - { - if (setfname(buf, fname, NULL, TRUE) == OK) - buf->b_flags |= BF_NOTEDITED; - vim_free(fname); - } - } + char_u *fname; + + fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"), + NULL, NULL, NULL, NULL, buf); + if (fname == NULL) + return; + + if (setfname(buf, fname, NULL, TRUE) == OK) + buf->b_flags |= BF_NOTEDITED; + vim_free(fname); } #endif @@ -731,60 +731,59 @@ ex_compiler(exarg_T *eap) // List all compiler scripts. do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')"); // ) keep the indenter happy... + return; + } + + buf = alloc(STRLEN(eap->arg) + 14); + if (buf == NULL) + return; + + if (eap->forceit) + { + // ":compiler! {name}" sets global options + do_cmdline_cmd((char_u *) + "command -nargs=* CompilerSet set "); } else { - buf = alloc(STRLEN(eap->arg) + 14); - if (buf != NULL) - { - if (eap->forceit) - { - // ":compiler! {name}" sets global options - do_cmdline_cmd((char_u *) - "command -nargs=* CompilerSet set "); - } - else - { - // ":compiler! {name}" sets local options. - // To remain backwards compatible "current_compiler" is always - // used. A user's compiler plugin may set it, the distributed - // plugin will then skip the settings. Afterwards set - // "b:current_compiler" and restore "current_compiler". - // Explicitly prepend "g:" to make it work in a function. - old_cur_comp = get_var_value((char_u *)"g:current_compiler"); - if (old_cur_comp != NULL) - old_cur_comp = vim_strsave(old_cur_comp); - do_cmdline_cmd((char_u *) - "command -nargs=* -keepscript CompilerSet setlocal "); - } - do_unlet((char_u *)"g:current_compiler", TRUE); - do_unlet((char_u *)"b:current_compiler", TRUE); + // ":compiler! {name}" sets local options. + // To remain backwards compatible "current_compiler" is always + // used. A user's compiler plugin may set it, the distributed + // plugin will then skip the settings. Afterwards set + // "b:current_compiler" and restore "current_compiler". + // Explicitly prepend "g:" to make it work in a function. + old_cur_comp = get_var_value((char_u *)"g:current_compiler"); + if (old_cur_comp != NULL) + old_cur_comp = vim_strsave(old_cur_comp); + do_cmdline_cmd((char_u *) + "command -nargs=* -keepscript CompilerSet setlocal "); + } + do_unlet((char_u *)"g:current_compiler", TRUE); + do_unlet((char_u *)"b:current_compiler", TRUE); - sprintf((char *)buf, "compiler/%s.vim", eap->arg); - if (source_runtime(buf, DIP_ALL) == FAIL) - semsg(_(e_compiler_not_supported_str), eap->arg); - vim_free(buf); + sprintf((char *)buf, "compiler/%s.vim", eap->arg); + if (source_runtime(buf, DIP_ALL) == FAIL) + semsg(_(e_compiler_not_supported_str), eap->arg); + vim_free(buf); - do_cmdline_cmd((char_u *)":delcommand CompilerSet"); + do_cmdline_cmd((char_u *)":delcommand CompilerSet"); - // Set "b:current_compiler" from "current_compiler". - p = get_var_value((char_u *)"g:current_compiler"); - if (p != NULL) - set_internal_string_var((char_u *)"b:current_compiler", p); + // Set "b:current_compiler" from "current_compiler". + p = get_var_value((char_u *)"g:current_compiler"); + if (p != NULL) + set_internal_string_var((char_u *)"b:current_compiler", p); - // Restore "current_compiler" for ":compiler {name}". - if (!eap->forceit) - { - if (old_cur_comp != NULL) - { - set_internal_string_var((char_u *)"g:current_compiler", - old_cur_comp); - vim_free(old_cur_comp); - } - else - do_unlet((char_u *)"g:current_compiler", TRUE); - } + // Restore "current_compiler" for ":compiler {name}". + if (!eap->forceit) + { + if (old_cur_comp != NULL) + { + set_internal_string_var((char_u *)"g:current_compiler", + old_cur_comp); + vim_free(old_cur_comp); } + else + do_unlet((char_u *)"g:current_compiler", TRUE); } } #endif -- cgit v1.2.3