Mirror of the Vim source from https://github.com/vim/vim
Revision | c8d4fced1f94ffa1f3c370ec204bf340b3a82684 (tree) |
---|---|
Time | 2022-12-28 05:00:05 |
Author | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -1270,50 +1270,52 @@ | ||
1270 | 1270 | return; |
1271 | 1271 | } |
1272 | 1272 | 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; | |
1287 | 1275 | |
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; | |
1299 | 1301 | } |
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"; | |
1307 | 1305 | |
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; | |
1316 | 1316 | } |
1317 | + else | |
1318 | + copy_tv(&argvars[0], rettv); | |
1317 | 1319 | } |
1318 | 1320 | |
1319 | 1321 | /* |
@@ -1664,49 +1664,49 @@ | ||
1664 | 1664 | { |
1665 | 1665 | int attr; |
1666 | 1666 | |
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; | |
1678 | 1679 | #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) | |
1680 | 1684 | { |
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) | |
1683 | 1688 | { |
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; | |
1692 | 1692 | } |
1693 | 1693 | } |
1694 | - else | |
1694 | + } | |
1695 | + else | |
1695 | 1696 | #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; | |
1709 | 1701 | } |
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); | |
1710 | 1710 | } |
1711 | 1711 | |
1712 | 1712 | #if defined(FEAT_JOB_CHANNEL) || defined(PROTO) |
@@ -1782,11 +1782,11 @@ | ||
1782 | 1782 | void |
1783 | 1783 | undisplay_dollar(void) |
1784 | 1784 | { |
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); | |
1790 | 1790 | } |
1791 | 1791 | |
1792 | 1792 | /* |
@@ -2554,17 +2554,17 @@ | ||
2554 | 2554 | |
2555 | 2555 | vim_free(last_insert); |
2556 | 2556 | 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; | |
2568 | 2568 | } |
2569 | 2569 | |
2570 | 2570 | #if defined(EXITFREE) || defined(PROTO) |
@@ -128,14 +128,15 @@ | ||
128 | 128 | { |
129 | 129 | init_evalarg(evalarg); |
130 | 130 | 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; | |
139 | 140 | } |
140 | 141 | } |
141 | 142 |
@@ -404,15 +405,15 @@ | ||
404 | 405 | static void |
405 | 406 | free_eval_tofree_later(evalarg_T *evalarg) |
406 | 407 | { |
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); | |
416 | 417 | } |
417 | 418 | |
418 | 419 | /* |
@@ -421,39 +422,39 @@ | ||
421 | 422 | void |
422 | 423 | clear_evalarg(evalarg_T *evalarg, exarg_T *eap) |
423 | 424 | { |
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) | |
431 | 441 | { |
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); | |
448 | 447 | } |
449 | 448 | 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); | |
457 | 458 | } |
458 | 459 | |
459 | 460 | /* |
@@ -3219,16 +3220,16 @@ | ||
3219 | 3220 | blob_T *b = blob_alloc(); |
3220 | 3221 | int i; |
3221 | 3222 | |
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); | |
3232 | 3233 | } |
3233 | 3234 | |
3234 | 3235 | /* |
@@ -4818,13 +4819,13 @@ | ||
4818 | 4819 | || check_for_opt_number_arg(argvars, 2) == FAIL)) |
4819 | 4820 | return; |
4820 | 4821 | |
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); | |
4828 | 4829 | } |
4829 | 4830 | |
4830 | 4831 | /* |
@@ -5045,31 +5046,31 @@ | ||
5045 | 5046 | void |
5046 | 5047 | partial_unref(partial_T *pt) |
5047 | 5048 | { |
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])) | |
5071 | 5073 | break; |
5072 | - } | |
5073 | 5074 | } |
5074 | 5075 | } |
5075 | 5076 | } |
@@ -7225,23 +7226,23 @@ | ||
7225 | 7226 | { |
7226 | 7227 | char_u *p; |
7227 | 7228 | |
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); | |
7245 | 7246 | } |
7246 | 7247 | |
7247 | 7248 | #endif // FEAT_EVAL |
@@ -696,6 +696,8 @@ | ||
696 | 696 | static int included_patches[] = |
697 | 697 | { /* Add new patch number below this line */ |
698 | 698 | /**/ |
699 | + 1105, | |
700 | +/**/ | |
699 | 701 | 1104, |
700 | 702 | /**/ |
701 | 703 | 1103, |