• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionc8d4fced1f94ffa1f3c370ec204bf340b3a82684 (tree)
Time2022-12-28 05:00:05
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.1105: code is indented too much

Commit: https://github.com/vim/vim/commit/87c1cbbe984e60582f2536e4d3c2ce88cd474bb7
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Dec 27 19:54:52 2022 +0000

patch 9.0.1105: code is indented too much
Problem: Code is indented too much.
Solution: Use an early return. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11756)

Change Summary

Incremental Difference

diff -r 922e7109afcf -r c8d4fced1f94 src/dict.c
--- a/src/dict.c Tue Dec 27 18:30:07 2022 +0100
+++ b/src/dict.c Tue Dec 27 21:00:05 2022 +0100
@@ -1270,50 +1270,52 @@
12701270 return;
12711271 }
12721272 d2 = argvars[1].vval.v_dict;
1273- if ((is_new || !value_check_lock(d1->dv_lock, arg_errmsg, TRUE))
1274- && d2 != NULL)
1275- {
1276- if (is_new)
1277- {
1278- d1 = dict_copy(d1, FALSE, TRUE, get_copyID());
1279- if (d1 == NULL)
1280- return;
1281- }
1282-
1283- // Check the third argument.
1284- if (argvars[2].v_type != VAR_UNKNOWN)
1285- {
1286- static char *(av[]) = {"keep", "force", "error"};
1273+ if (d2 == NULL)
1274+ return;
12871275
1288- action = tv_get_string_chk(&argvars[2]);
1289- if (action == NULL)
1290- return;
1291- for (i = 0; i < 3; ++i)
1292- if (STRCMP(action, av[i]) == 0)
1293- break;
1294- if (i == 3)
1295- {
1296- semsg(_(e_invalid_argument_str), action);
1297- return;
1298- }
1276+ if (!is_new && value_check_lock(d1->dv_lock, arg_errmsg, TRUE))
1277+ return;
1278+
1279+ if (is_new)
1280+ {
1281+ d1 = dict_copy(d1, FALSE, TRUE, get_copyID());
1282+ if (d1 == NULL)
1283+ return;
1284+ }
1285+
1286+ // Check the third argument.
1287+ if (argvars[2].v_type != VAR_UNKNOWN)
1288+ {
1289+ static char *(av[]) = {"keep", "force", "error"};
1290+
1291+ action = tv_get_string_chk(&argvars[2]);
1292+ if (action == NULL)
1293+ return;
1294+ for (i = 0; i < 3; ++i)
1295+ if (STRCMP(action, av[i]) == 0)
1296+ break;
1297+ if (i == 3)
1298+ {
1299+ semsg(_(e_invalid_argument_str), action);
1300+ return;
12991301 }
1300- else
1301- action = (char_u *)"force";
1302-
1303- if (type != NULL && check_typval_arg_type(type, &argvars[1],
1304- func_name, 2) == FAIL)
1305- return;
1306- dict_extend(d1, d2, action, func_name);
1302+ }
1303+ else
1304+ action = (char_u *)"force";
13071305
1308- if (is_new)
1309- {
1310- rettv->v_type = VAR_DICT;
1311- rettv->vval.v_dict = d1;
1312- rettv->v_lock = FALSE;
1313- }
1314- else
1315- copy_tv(&argvars[0], rettv);
1306+ if (type != NULL && check_typval_arg_type(type, &argvars[1],
1307+ func_name, 2) == FAIL)
1308+ return;
1309+ dict_extend(d1, d2, action, func_name);
1310+
1311+ if (is_new)
1312+ {
1313+ rettv->v_type = VAR_DICT;
1314+ rettv->vval.v_dict = d1;
1315+ rettv->v_lock = FALSE;
13161316 }
1317+ else
1318+ copy_tv(&argvars[0], rettv);
13171319 }
13181320
13191321 /*
diff -r 922e7109afcf -r c8d4fced1f94 src/edit.c
--- a/src/edit.c Tue Dec 27 18:30:07 2022 +0100
+++ b/src/edit.c Tue Dec 27 21:00:05 2022 +0100
@@ -1664,49 +1664,49 @@
16641664 {
16651665 int attr;
16661666
1667- if (ScreenLines != NULL)
1668- {
1669- update_topline(); // just in case w_topline isn't valid
1670- validate_cursor();
1671- if (highlight)
1672- attr = HL_ATTR(HLF_8);
1673- else
1674- attr = 0;
1675- pc_row = W_WINROW(curwin) + curwin->w_wrow;
1676- pc_col = curwin->w_wincol;
1677- pc_status = PC_STATUS_UNSET;
1667+ if (ScreenLines == NULL)
1668+ return;
1669+
1670+ update_topline(); // just in case w_topline isn't valid
1671+ validate_cursor();
1672+ if (highlight)
1673+ attr = HL_ATTR(HLF_8);
1674+ else
1675+ attr = 0;
1676+ pc_row = W_WINROW(curwin) + curwin->w_wrow;
1677+ pc_col = curwin->w_wincol;
1678+ pc_status = PC_STATUS_UNSET;
16781679 #ifdef FEAT_RIGHTLEFT
1679- if (curwin->w_p_rl)
1680+ if (curwin->w_p_rl)
1681+ {
1682+ pc_col += curwin->w_width - 1 - curwin->w_wcol;
1683+ if (has_mbyte)
16801684 {
1681- pc_col += curwin->w_width - 1 - curwin->w_wcol;
1682- if (has_mbyte)
1685+ int fix_col = mb_fix_col(pc_col, pc_row);
1686+
1687+ if (fix_col != pc_col)
16831688 {
1684- int fix_col = mb_fix_col(pc_col, pc_row);
1685-
1686- if (fix_col != pc_col)
1687- {
1688- screen_putchar(' ', pc_row, fix_col, attr);
1689- --curwin->w_wcol;
1690- pc_status = PC_STATUS_RIGHT;
1691- }
1689+ screen_putchar(' ', pc_row, fix_col, attr);
1690+ --curwin->w_wcol;
1691+ pc_status = PC_STATUS_RIGHT;
16921692 }
16931693 }
1694- else
1694+ }
1695+ else
16951696 #endif
1696- {
1697- pc_col += curwin->w_wcol;
1698- if (mb_lefthalve(pc_row, pc_col))
1699- pc_status = PC_STATUS_LEFT;
1700- }
1701-
1702- // save the character to be able to put it back
1703- if (pc_status == PC_STATUS_UNSET)
1704- {
1705- screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr);
1706- pc_status = PC_STATUS_SET;
1707- }
1708- screen_putchar(c, pc_row, pc_col, attr);
1697+ {
1698+ pc_col += curwin->w_wcol;
1699+ if (mb_lefthalve(pc_row, pc_col))
1700+ pc_status = PC_STATUS_LEFT;
17091701 }
1702+
1703+ // save the character to be able to put it back
1704+ if (pc_status == PC_STATUS_UNSET)
1705+ {
1706+ screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr);
1707+ pc_status = PC_STATUS_SET;
1708+ }
1709+ screen_putchar(c, pc_row, pc_col, attr);
17101710 }
17111711
17121712 #if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
@@ -1782,11 +1782,11 @@
17821782 void
17831783 undisplay_dollar(void)
17841784 {
1785- if (dollar_vcol >= 0)
1786- {
1787- dollar_vcol = -1;
1788- redrawWinline(curwin, curwin->w_cursor.lnum);
1789- }
1785+ if (dollar_vcol < 0)
1786+ return;
1787+
1788+ dollar_vcol = -1;
1789+ redrawWinline(curwin, curwin->w_cursor.lnum);
17901790 }
17911791
17921792 /*
@@ -2554,17 +2554,17 @@
25542554
25552555 vim_free(last_insert);
25562556 last_insert = alloc(MB_MAXBYTES * 3 + 5);
2557- if (last_insert != NULL)
2558- {
2559- s = last_insert;
2560- // Use the CTRL-V only when entering a special char
2561- if (c < ' ' || c == DEL)
2562- *s++ = Ctrl_V;
2563- s = add_char2buf(c, s);
2564- *s++ = ESC;
2565- *s++ = NUL;
2566- last_insert_skip = 0;
2567- }
2557+ if (last_insert == NULL)
2558+ return;
2559+
2560+ s = last_insert;
2561+ // Use the CTRL-V only when entering a special char
2562+ if (c < ' ' || c == DEL)
2563+ *s++ = Ctrl_V;
2564+ s = add_char2buf(c, s);
2565+ *s++ = ESC;
2566+ *s++ = NUL;
2567+ last_insert_skip = 0;
25682568 }
25692569
25702570 #if defined(EXITFREE) || defined(PROTO)
diff -r 922e7109afcf -r c8d4fced1f94 src/eval.c
--- a/src/eval.c Tue Dec 27 18:30:07 2022 +0100
+++ b/src/eval.c Tue Dec 27 21:00:05 2022 +0100
@@ -128,14 +128,15 @@
128128 {
129129 init_evalarg(evalarg);
130130 evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE;
131- if (eap != NULL)
132- {
133- evalarg->eval_cstack = eap->cstack;
134- if (sourcing_a_script(eap) || eap->getline == get_list_line)
135- {
136- evalarg->eval_getline = eap->getline;
137- evalarg->eval_cookie = eap->cookie;
138- }
131+
132+ if (eap == NULL)
133+ return;
134+
135+ evalarg->eval_cstack = eap->cstack;
136+ if (sourcing_a_script(eap) || eap->getline == get_list_line)
137+ {
138+ evalarg->eval_getline = eap->getline;
139+ evalarg->eval_cookie = eap->cookie;
139140 }
140141 }
141142
@@ -404,15 +405,15 @@
404405 static void
405406 free_eval_tofree_later(evalarg_T *evalarg)
406407 {
407- if (evalarg->eval_tofree != NULL)
408- {
409- if (ga_grow(&evalarg->eval_tofree_ga, 1) == OK)
410- ((char_u **)evalarg->eval_tofree_ga.ga_data)
411- [evalarg->eval_tofree_ga.ga_len++]
412- = evalarg->eval_tofree;
413- else
414- vim_free(evalarg->eval_tofree);
415- }
408+ if (evalarg->eval_tofree == NULL)
409+ return;
410+
411+ if (ga_grow(&evalarg->eval_tofree_ga, 1) == OK)
412+ ((char_u **)evalarg->eval_tofree_ga.ga_data)
413+ [evalarg->eval_tofree_ga.ga_len++]
414+ = evalarg->eval_tofree;
415+ else
416+ vim_free(evalarg->eval_tofree);
416417 }
417418
418419 /*
@@ -421,39 +422,39 @@
421422 void
422423 clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
423424 {
424- if (evalarg != NULL)
425- {
426- garray_T *etga = &evalarg->eval_tofree_ga;
427-
428- if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
429- {
430- if (eap != NULL)
425+ if (evalarg == NULL)
426+ return;
427+
428+ garray_T *etga = &evalarg->eval_tofree_ga;
429+
430+ if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
431+ {
432+ if (eap != NULL)
433+ {
434+ // We may need to keep the original command line, e.g. for
435+ // ":let" it has the variable names. But we may also need
436+ // the new one, "nextcmd" points into it. Keep both.
437+ vim_free(eap->cmdline_tofree);
438+ eap->cmdline_tofree = *eap->cmdlinep;
439+
440+ if (evalarg->eval_using_cmdline && etga->ga_len > 0)
431441 {
432- // We may need to keep the original command line, e.g. for
433- // ":let" it has the variable names. But we may also need
434- // the new one, "nextcmd" points into it. Keep both.
435- vim_free(eap->cmdline_tofree);
436- eap->cmdline_tofree = *eap->cmdlinep;
437-
438- if (evalarg->eval_using_cmdline && etga->ga_len > 0)
439- {
440- // "nextcmd" points into the last line in eval_tofree_ga,
441- // need to keep it around.
442- --etga->ga_len;
443- *eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
444- vim_free(evalarg->eval_tofree);
445- }
446- else
447- *eap->cmdlinep = evalarg->eval_tofree;
442+ // "nextcmd" points into the last line in eval_tofree_ga,
443+ // need to keep it around.
444+ --etga->ga_len;
445+ *eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
446+ vim_free(evalarg->eval_tofree);
448447 }
449448 else
450- vim_free(evalarg->eval_tofree);
451- evalarg->eval_tofree = NULL;
452- }
453-
454- ga_clear_strings(etga);
455- VIM_CLEAR(evalarg->eval_tofree_lambda);
456- }
449+ *eap->cmdlinep = evalarg->eval_tofree;
450+ }
451+ else
452+ vim_free(evalarg->eval_tofree);
453+ evalarg->eval_tofree = NULL;
454+ }
455+
456+ ga_clear_strings(etga);
457+ VIM_CLEAR(evalarg->eval_tofree_lambda);
457458 }
458459
459460 /*
@@ -3219,16 +3220,16 @@
32193220 blob_T *b = blob_alloc();
32203221 int i;
32213222
3222- if (b != NULL)
3223- {
3224- for (i = 0; i < blob_len(b1); i++)
3225- ga_append(&b->bv_ga, blob_get(b1, i));
3226- for (i = 0; i < blob_len(b2); i++)
3227- ga_append(&b->bv_ga, blob_get(b2, i));
3228-
3229- clear_tv(tv1);
3230- rettv_blob_set(tv1, b);
3231- }
3223+ if (b == NULL)
3224+ return;
3225+
3226+ for (i = 0; i < blob_len(b1); i++)
3227+ ga_append(&b->bv_ga, blob_get(b1, i));
3228+ for (i = 0; i < blob_len(b2); i++)
3229+ ga_append(&b->bv_ga, blob_get(b2, i));
3230+
3231+ clear_tv(tv1);
3232+ rettv_blob_set(tv1, b);
32323233 }
32333234
32343235 /*
@@ -4818,13 +4819,13 @@
48184819 || check_for_opt_number_arg(argvars, 2) == FAIL))
48194820 return;
48204821
4821- if (check_can_index(argvars, TRUE, FALSE) == OK)
4822- {
4823- copy_tv(argvars, rettv);
4824- eval_index_inner(rettv, TRUE, argvars + 1,
4825- argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
4826- TRUE, NULL, 0, FALSE);
4827- }
4822+ if (check_can_index(argvars, TRUE, FALSE) != OK)
4823+ return;
4824+
4825+ copy_tv(argvars, rettv);
4826+ eval_index_inner(rettv, TRUE, argvars + 1,
4827+ argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
4828+ TRUE, NULL, 0, FALSE);
48284829 }
48294830
48304831 /*
@@ -5045,31 +5046,31 @@
50455046 void
50465047 partial_unref(partial_T *pt)
50475048 {
5048- if (pt != NULL)
5049- {
5050- int done = FALSE;
5051-
5052- if (--pt->pt_refcount <= 0)
5053- partial_free(pt);
5054-
5055- // If the reference count goes down to one, the funcstack may be the
5056- // only reference and can be freed if no other partials reference it.
5057- else if (pt->pt_refcount == 1)
5058- {
5059- // careful: if the funcstack is freed it may contain this partial
5060- // and it gets freed as well
5061- if (pt->pt_funcstack != NULL)
5062- done = funcstack_check_refcount(pt->pt_funcstack);
5063-
5064- if (!done)
5065- {
5066- int depth;
5067-
5068- for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
5069- if (pt->pt_loopvars[depth] != NULL
5070- && loopvars_check_refcount(pt->pt_loopvars[depth]))
5049+ if (pt == NULL)
5050+ return;
5051+
5052+ int done = FALSE;
5053+
5054+ if (--pt->pt_refcount <= 0)
5055+ partial_free(pt);
5056+
5057+ // If the reference count goes down to one, the funcstack may be the
5058+ // only reference and can be freed if no other partials reference it.
5059+ else if (pt->pt_refcount == 1)
5060+ {
5061+ // careful: if the funcstack is freed it may contain this partial
5062+ // and it gets freed as well
5063+ if (pt->pt_funcstack != NULL)
5064+ done = funcstack_check_refcount(pt->pt_funcstack);
5065+
5066+ if (!done)
5067+ {
5068+ int depth;
5069+
5070+ for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
5071+ if (pt->pt_loopvars[depth] != NULL
5072+ && loopvars_check_refcount(pt->pt_loopvars[depth]))
50715073 break;
5072- }
50735074 }
50745075 }
50755076 }
@@ -7225,23 +7226,23 @@
72257226 {
72267227 char_u *p;
72277228
7228- if (script_ctx.sc_sid != 0)
7229- {
7230- p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
7231- if (p != NULL)
7232- {
7233- verbose_enter();
7234- msg_puts(_("\n\tLast set from "));
7235- msg_puts((char *)p);
7236- if (script_ctx.sc_lnum > 0)
7237- {
7238- msg_puts(_(line_msg));
7239- msg_outnum((long)script_ctx.sc_lnum);
7240- }
7241- verbose_leave();
7242- vim_free(p);
7243- }
7244- }
7229+ if (script_ctx.sc_sid == 0)
7230+ return;
7231+
7232+ p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
7233+ if (p == NULL)
7234+ return;
7235+
7236+ verbose_enter();
7237+ msg_puts(_("\n\tLast set from "));
7238+ msg_puts((char *)p);
7239+ if (script_ctx.sc_lnum > 0)
7240+ {
7241+ msg_puts(_(line_msg));
7242+ msg_outnum((long)script_ctx.sc_lnum);
7243+ }
7244+ verbose_leave();
7245+ vim_free(p);
72457246 }
72467247
72477248 #endif // FEAT_EVAL
diff -r 922e7109afcf -r c8d4fced1f94 src/version.c
--- a/src/version.c Tue Dec 27 18:30:07 2022 +0100
+++ b/src/version.c Tue Dec 27 21:00:05 2022 +0100
@@ -696,6 +696,8 @@
696696 static int included_patches[] =
697697 { /* Add new patch number below this line */
698698 /**/
699+ 1105,
700+/**/
699701 1104,
700702 /**/
701703 1103,
Show on old repository browser