patch 9.0.1196: code is indented more than necessary
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11813)
diff --git a/src/main.c b/src/main.c
index 0299c61..d1c42ed 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3099,23 +3099,23 @@
int i;
ESTACK_CHECK_DECLARATION
- if (cnt > 0)
- {
- curwin->w_cursor.lnum = 0; // just in case..
- estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
- ESTACK_CHECK_SETUP
+ if (cnt <= 0)
+ return;
+
+ curwin->w_cursor.lnum = 0; // just in case..
+ estack_push(ETYPE_ARGS, (char_u *)_("pre-vimrc command line"), 0);
+ ESTACK_CHECK_SETUP
# ifdef FEAT_EVAL
current_sctx.sc_sid = SID_CMDARG;
# endif
for (i = 0; i < cnt; ++i)
do_cmdline_cmd(cmds[i]);
- ESTACK_CHECK_NOW
+ ESTACK_CHECK_NOW
estack_pop();
# ifdef FEAT_EVAL
- current_sctx.sc_sid = 0;
+ current_sctx.sc_sid = 0;
# endif
- TIME_MSG("--cmd commands");
- }
+ TIME_MSG("--cmd commands");
}
/*
@@ -3369,28 +3369,27 @@
ESTACK_CHECK_DECLARATION
- if ((initstr = mch_getenv(env)) != NULL && *initstr != NUL)
- {
- if (is_viminit)
- vimrc_found(NULL, NULL);
- estack_push(ETYPE_ENV, env, 0);
- ESTACK_CHECK_SETUP
+ if ((initstr = mch_getenv(env)) == NULL || *initstr == NUL)
+ return FAIL;
+
+ if (is_viminit)
+ vimrc_found(NULL, NULL);
+ estack_push(ETYPE_ENV, env, 0);
+ ESTACK_CHECK_SETUP
save_current_sctx = current_sctx;
- current_sctx.sc_version = 1;
+ current_sctx.sc_version = 1;
#ifdef FEAT_EVAL
- current_sctx.sc_sid = SID_ENV;
- current_sctx.sc_seq = 0;
- current_sctx.sc_lnum = 0;
+ current_sctx.sc_sid = SID_ENV;
+ current_sctx.sc_seq = 0;
+ current_sctx.sc_lnum = 0;
#endif
- do_cmdline_cmd(initstr);
+ do_cmdline_cmd(initstr);
- ESTACK_CHECK_NOW
+ ESTACK_CHECK_NOW
estack_pop();
- current_sctx = save_current_sctx;
- return OK;
- }
- return FAIL;
+ current_sctx = save_current_sctx;
+ return OK;
}
#if (defined(UNIX) || defined(VMS)) && !defined(NO_VIM_MAIN)