summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-12-30 18:07:46 +0000
committerBram Moolenaar <Bram@vim.org>2022-12-30 18:07:46 +0000
commited0c1d5d4b30d03b26ff08841f6da2ddf44025a7 (patch)
treef30f357f2f6b1e3152cc52d038f41b7adced9840 /src/ex_cmds2.c
parentef91ae4557ac93e581b0ec39bf4c78c3556d7484 (diff)
patch 9.0.1115: code is indented more than neededv9.0.1115
Problem: Code is indented more than needed. Solution: Use an early return to reduce indenting. (Yegappan Lakshmanan, closes #11758)
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c115
1 files changed, 57 insertions, 58 deletions
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 <args>");
}
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 <args>");
- }
- 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 <args>");
- }
- 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 <args>");
+ }
+ 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