Patch 9.0.1105
Problem:    Code is indented too much.
Solution:   Use an early return. (Yegappan Lakshmanan, closes #11756)
Files:      src/dict.c, src/edit.c, src/eval.c


*** ../vim-9.0.1104/src/dict.c  2022-11-25 16:31:46.964606667 +0000
--- src/dict.c  2022-12-27 19:38:02.329049265 +0000
***************
*** 1270,1319 ****
        return;
      }
      d2 = argvars[1].vval.v_dict;
!     if ((is_new || !value_check_lock(d1->dv_lock, arg_errmsg, TRUE))
!           && d2 != NULL)
!     {
!       if (is_new)
!       {
!           d1 = dict_copy(d1, FALSE, TRUE, get_copyID());
!           if (d1 == NULL)
!               return;
!       }
! 
!       // Check the third argument.
!       if (argvars[2].v_type != VAR_UNKNOWN)
!       {
!           static char *(av[]) = {"keep", "force", "error"};
  
!           action = tv_get_string_chk(&argvars[2]);
!           if (action == NULL)
!               return;
!           for (i = 0; i < 3; ++i)
!               if (STRCMP(action, av[i]) == 0)
!                   break;
!           if (i == 3)
!           {
!               semsg(_(e_invalid_argument_str), action);
!               return;
!           }
!       }
!       else
!           action = (char_u *)"force";
  
!       if (type != NULL && check_typval_arg_type(type, &argvars[1],
!                                                        func_name, 2) == FAIL)
            return;
!       dict_extend(d1, d2, action, func_name);
  
!       if (is_new)
        {
!           rettv->v_type = VAR_DICT;
!           rettv->vval.v_dict = d1;
!           rettv->v_lock = FALSE;
        }
-       else
-           copy_tv(&argvars[0], rettv);
      }
  }
  
  /*
--- 1270,1321 ----
        return;
      }
      d2 = argvars[1].vval.v_dict;
!     if (d2 == NULL)
!       return;
  
!     if (!is_new && value_check_lock(d1->dv_lock, arg_errmsg, TRUE))
!       return;
  
!     if (is_new)
!     {
!       d1 = dict_copy(d1, FALSE, TRUE, get_copyID());
!       if (d1 == NULL)
            return;
!     }
  
!     // Check the third argument.
!     if (argvars[2].v_type != VAR_UNKNOWN)
!     {
!       static char *(av[]) = {"keep", "force", "error"};
! 
!       action = tv_get_string_chk(&argvars[2]);
!       if (action == NULL)
!           return;
!       for (i = 0; i < 3; ++i)
!           if (STRCMP(action, av[i]) == 0)
!               break;
!       if (i == 3)
        {
!           semsg(_(e_invalid_argument_str), action);
!           return;
        }
      }
+     else
+       action = (char_u *)"force";
+ 
+     if (type != NULL && check_typval_arg_type(type, &argvars[1],
+               func_name, 2) == FAIL)
+       return;
+     dict_extend(d1, d2, action, func_name);
+ 
+     if (is_new)
+     {
+       rettv->v_type = VAR_DICT;
+       rettv->vval.v_dict = d1;
+       rettv->v_lock = FALSE;
+     }
+     else
+       copy_tv(&argvars[0], rettv);
  }
  
  /*
*** ../vim-9.0.1104/src/edit.c  2022-12-08 21:49:09.844530541 +0000
--- src/edit.c  2022-12-27 19:38:02.329049265 +0000
***************
*** 1664,1712 ****
  {
      int           attr;
  
!     if (ScreenLines != NULL)
!     {
!       update_topline();       // just in case w_topline isn't valid
!       validate_cursor();
!       if (highlight)
!           attr = HL_ATTR(HLF_8);
!       else
!           attr = 0;
!       pc_row = W_WINROW(curwin) + curwin->w_wrow;
!       pc_col = curwin->w_wincol;
!       pc_status = PC_STATUS_UNSET;
  #ifdef FEAT_RIGHTLEFT
!       if (curwin->w_p_rl)
        {
!           pc_col += curwin->w_width - 1 - curwin->w_wcol;
!           if (has_mbyte)
!           {
!               int fix_col = mb_fix_col(pc_col, pc_row);
  
!               if (fix_col != pc_col)
!               {
!                   screen_putchar(' ', pc_row, fix_col, attr);
!                   --curwin->w_wcol;
!                   pc_status = PC_STATUS_RIGHT;
!               }
            }
        }
!       else
  #endif
!       {
!           pc_col += curwin->w_wcol;
!           if (mb_lefthalve(pc_row, pc_col))
!               pc_status = PC_STATUS_LEFT;
!       }
  
!       // save the character to be able to put it back
!       if (pc_status == PC_STATUS_UNSET)
!       {
!           screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr);
!           pc_status = PC_STATUS_SET;
!       }
!       screen_putchar(c, pc_row, pc_col, attr);
      }
  }
  
  #if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
--- 1664,1712 ----
  {
      int           attr;
  
!     if (ScreenLines == NULL)
!       return;
! 
!     update_topline(); // just in case w_topline isn't valid
!     validate_cursor();
!     if (highlight)
!       attr = HL_ATTR(HLF_8);
!     else
!       attr = 0;
!     pc_row = W_WINROW(curwin) + curwin->w_wrow;
!     pc_col = curwin->w_wincol;
!     pc_status = PC_STATUS_UNSET;
  #ifdef FEAT_RIGHTLEFT
!     if (curwin->w_p_rl)
!     {
!       pc_col += curwin->w_width - 1 - curwin->w_wcol;
!       if (has_mbyte)
        {
!           int fix_col = mb_fix_col(pc_col, pc_row);
  
!           if (fix_col != pc_col)
!           {
!               screen_putchar(' ', pc_row, fix_col, attr);
!               --curwin->w_wcol;
!               pc_status = PC_STATUS_RIGHT;
            }
        }
!     }
!     else
  #endif
!     {
!       pc_col += curwin->w_wcol;
!       if (mb_lefthalve(pc_row, pc_col))
!           pc_status = PC_STATUS_LEFT;
!     }
  
!     // save the character to be able to put it back
!     if (pc_status == PC_STATUS_UNSET)
!     {
!       screen_getbytes(pc_row, pc_col, pc_bytes, &pc_attr);
!       pc_status = PC_STATUS_SET;
      }
+     screen_putchar(c, pc_row, pc_col, attr);
  }
  
  #if defined(FEAT_JOB_CHANNEL) || defined(PROTO)
***************
*** 1782,1792 ****
      void
  undisplay_dollar(void)
  {
!     if (dollar_vcol >= 0)
!     {
!       dollar_vcol = -1;
!       redrawWinline(curwin, curwin->w_cursor.lnum);
!     }
  }
  
  /*
--- 1782,1792 ----
      void
  undisplay_dollar(void)
  {
!     if (dollar_vcol < 0)
!       return;
! 
!     dollar_vcol = -1;
!     redrawWinline(curwin, curwin->w_cursor.lnum);
  }
  
  /*
***************
*** 2554,2570 ****
  
      vim_free(last_insert);
      last_insert = alloc(MB_MAXBYTES * 3 + 5);
!     if (last_insert != NULL)
!     {
!       s = last_insert;
!       // Use the CTRL-V only when entering a special char
!       if (c < ' ' || c == DEL)
!           *s++ = Ctrl_V;
!       s = add_char2buf(c, s);
!       *s++ = ESC;
!       *s++ = NUL;
!       last_insert_skip = 0;
!     }
  }
  
  #if defined(EXITFREE) || defined(PROTO)
--- 2554,2570 ----
  
      vim_free(last_insert);
      last_insert = alloc(MB_MAXBYTES * 3 + 5);
!     if (last_insert == NULL)
!       return;
! 
!     s = last_insert;
!     // Use the CTRL-V only when entering a special char
!     if (c < ' ' || c == DEL)
!       *s++ = Ctrl_V;
!     s = add_char2buf(c, s);
!     *s++ = ESC;
!     *s++ = NUL;
!     last_insert_skip = 0;
  }
  
  #if defined(EXITFREE) || defined(PROTO)
*** ../vim-9.0.1104/src/eval.c  2022-12-19 20:28:34.061118368 +0000
--- src/eval.c  2022-12-27 19:38:02.329049265 +0000
***************
*** 128,141 ****
  {
      init_evalarg(evalarg);
      evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE;
!     if (eap != NULL)
      {
!       evalarg->eval_cstack = eap->cstack;
!       if (sourcing_a_script(eap) || eap->getline == get_list_line)
!       {
!           evalarg->eval_getline = eap->getline;
!           evalarg->eval_cookie = eap->cookie;
!       }
      }
  }
  
--- 128,142 ----
  {
      init_evalarg(evalarg);
      evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE;
! 
!     if (eap == NULL)
!       return;
! 
!     evalarg->eval_cstack = eap->cstack;
!     if (sourcing_a_script(eap) || eap->getline == get_list_line)
      {
!       evalarg->eval_getline = eap->getline;
!       evalarg->eval_cookie = eap->cookie;
      }
  }
  
***************
*** 404,418 ****
      static void
  free_eval_tofree_later(evalarg_T *evalarg)
  {
!     if (evalarg->eval_tofree != NULL)
!     {
!       if (ga_grow(&evalarg->eval_tofree_ga, 1) == OK)
!           ((char_u **)evalarg->eval_tofree_ga.ga_data)
!               [evalarg->eval_tofree_ga.ga_len++]
!               = evalarg->eval_tofree;
!       else
!           vim_free(evalarg->eval_tofree);
!     }
  }
  
  /*
--- 405,419 ----
      static void
  free_eval_tofree_later(evalarg_T *evalarg)
  {
!     if (evalarg->eval_tofree == NULL)
!       return;
! 
!     if (ga_grow(&evalarg->eval_tofree_ga, 1) == OK)
!       ((char_u **)evalarg->eval_tofree_ga.ga_data)
!           [evalarg->eval_tofree_ga.ga_len++]
!           = evalarg->eval_tofree;
!     else
!       vim_free(evalarg->eval_tofree);
  }
  
  /*
***************
*** 421,459 ****
      void
  clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
  {
!     if (evalarg != NULL)
!     {
!       garray_T *etga = &evalarg->eval_tofree_ga;
  
!       if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
        {
!           if (eap != NULL)
!           {
!               // We may need to keep the original command line, e.g. for
!               // ":let" it has the variable names.  But we may also need
!               // the new one, "nextcmd" points into it.  Keep both.
!               vim_free(eap->cmdline_tofree);
!               eap->cmdline_tofree = *eap->cmdlinep;
  
!               if (evalarg->eval_using_cmdline && etga->ga_len > 0)
!               {
!                   // "nextcmd" points into the last line in eval_tofree_ga,
!                   // need to keep it around.
!                   --etga->ga_len;
!                   *eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
!                   vim_free(evalarg->eval_tofree);
!               }
!               else
!                   *eap->cmdlinep = evalarg->eval_tofree;
            }
            else
!               vim_free(evalarg->eval_tofree);
!           evalarg->eval_tofree = NULL;
        }
! 
!       ga_clear_strings(etga);
!       VIM_CLEAR(evalarg->eval_tofree_lambda);
      }
  }
  
  /*
--- 422,460 ----
      void
  clear_evalarg(evalarg_T *evalarg, exarg_T *eap)
  {
!     if (evalarg == NULL)
!       return;
  
!     garray_T *etga = &evalarg->eval_tofree_ga;
! 
!     if (evalarg->eval_tofree != NULL || evalarg->eval_using_cmdline)
!     {
!       if (eap != NULL)
        {
!           // We may need to keep the original command line, e.g. for
!           // ":let" it has the variable names.  But we may also need
!           // the new one, "nextcmd" points into it.  Keep both.
!           vim_free(eap->cmdline_tofree);
!           eap->cmdline_tofree = *eap->cmdlinep;
  
!           if (evalarg->eval_using_cmdline && etga->ga_len > 0)
!           {
!               // "nextcmd" points into the last line in eval_tofree_ga,
!               // need to keep it around.
!               --etga->ga_len;
!               *eap->cmdlinep = ((char_u **)etga->ga_data)[etga->ga_len];
!               vim_free(evalarg->eval_tofree);
            }
            else
!               *eap->cmdlinep = evalarg->eval_tofree;
        }
!       else
!           vim_free(evalarg->eval_tofree);
!       evalarg->eval_tofree = NULL;
      }
+ 
+     ga_clear_strings(etga);
+     VIM_CLEAR(evalarg->eval_tofree_lambda);
  }
  
  /*
***************
*** 3219,3234 ****
      blob_T  *b = blob_alloc();
      int           i;
  
!     if (b != NULL)
!     {
!       for (i = 0; i < blob_len(b1); i++)
!           ga_append(&b->bv_ga, blob_get(b1, i));
!       for (i = 0; i < blob_len(b2); i++)
!           ga_append(&b->bv_ga, blob_get(b2, i));
  
!       clear_tv(tv1);
!       rettv_blob_set(tv1, b);
!     }
  }
  
  /*
--- 3220,3235 ----
      blob_T  *b = blob_alloc();
      int           i;
  
!     if (b == NULL)
!       return;
  
!     for (i = 0; i < blob_len(b1); i++)
!       ga_append(&b->bv_ga, blob_get(b1, i));
!     for (i = 0; i < blob_len(b2); i++)
!       ga_append(&b->bv_ga, blob_get(b2, i));
! 
!     clear_tv(tv1);
!     rettv_blob_set(tv1, b);
  }
  
  /*
***************
*** 4818,4830 ****
                || check_for_opt_number_arg(argvars, 2) == FAIL))
        return;
  
!     if (check_can_index(argvars, TRUE, FALSE) == OK)
!     {
!       copy_tv(argvars, rettv);
!       eval_index_inner(rettv, TRUE, argvars + 1,
!               argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
!               TRUE, NULL, 0, FALSE);
!     }
  }
  
  /*
--- 4819,4831 ----
                || check_for_opt_number_arg(argvars, 2) == FAIL))
        return;
  
!     if (check_can_index(argvars, TRUE, FALSE) != OK)
!       return;
! 
!     copy_tv(argvars, rettv);
!     eval_index_inner(rettv, TRUE, argvars + 1,
!           argvars[2].v_type == VAR_UNKNOWN ? NULL : argvars + 2,
!           TRUE, NULL, 0, FALSE);
  }
  
  /*
***************
*** 5045,5075 ****
      void
  partial_unref(partial_T *pt)
  {
!     if (pt != NULL)
!     {
!       int     done = FALSE;
  
!       if (--pt->pt_refcount <= 0)
!           partial_free(pt);
  
!       // If the reference count goes down to one, the funcstack may be the
!       // only reference and can be freed if no other partials reference it.
!       else if (pt->pt_refcount == 1)
!       {
!           // careful: if the funcstack is freed it may contain this partial
!           // and it gets freed as well
!           if (pt->pt_funcstack != NULL)
!               done = funcstack_check_refcount(pt->pt_funcstack);
  
!           if (!done)
!           {
!               int     depth;
  
!               for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
!                   if (pt->pt_loopvars[depth] != NULL
!                           && loopvars_check_refcount(pt->pt_loopvars[depth]))
                    break;
-           }
        }
      }
  }
--- 5046,5076 ----
      void
  partial_unref(partial_T *pt)
  {
!     if (pt == NULL)
!       return;
  
!     int       done = FALSE;
  
!     if (--pt->pt_refcount <= 0)
!       partial_free(pt);
  
!     // If the reference count goes down to one, the funcstack may be the
!     // only reference and can be freed if no other partials reference it.
!     else if (pt->pt_refcount == 1)
!     {
!       // careful: if the funcstack is freed it may contain this partial
!       // and it gets freed as well
!       if (pt->pt_funcstack != NULL)
!           done = funcstack_check_refcount(pt->pt_funcstack);
  
!       if (!done)
!       {
!           int depth;
! 
!           for (depth = 0; depth < MAX_LOOP_DEPTH; ++depth)
!               if (pt->pt_loopvars[depth] != NULL
!                       && loopvars_check_refcount(pt->pt_loopvars[depth]))
                    break;
        }
      }
  }
***************
*** 7225,7247 ****
  {
      char_u *p;
  
!     if (script_ctx.sc_sid != 0)
      {
!       p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
!       if (p != NULL)
!       {
!           verbose_enter();
!           msg_puts(_("\n\tLast set from "));
!           msg_puts((char *)p);
!           if (script_ctx.sc_lnum > 0)
!           {
!               msg_puts(_(line_msg));
!               msg_outnum((long)script_ctx.sc_lnum);
!           }
!           verbose_leave();
!           vim_free(p);
!       }
      }
  }
  
  #endif // FEAT_EVAL
--- 7226,7248 ----
  {
      char_u *p;
  
!     if (script_ctx.sc_sid == 0)
!       return;
! 
!     p = home_replace_save(NULL, get_scriptname(script_ctx.sc_sid));
!     if (p == NULL)
!       return;
! 
!     verbose_enter();
!     msg_puts(_("\n\tLast set from "));
!     msg_puts((char *)p);
!     if (script_ctx.sc_lnum > 0)
      {
!       msg_puts(_(line_msg));
!       msg_outnum((long)script_ctx.sc_lnum);
      }
+     verbose_leave();
+     vim_free(p);
  }
  
  #endif // FEAT_EVAL
*** ../vim-9.0.1104/src/version.c       2022-12-27 17:24:55.270083348 +0000
--- src/version.c       2022-12-27 19:42:13.304165760 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1105,
  /**/

-- 
An indication you must be a manager:
You give constructive feedback to your dog.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221227200005.E86301C0AA4%40moolenaar.net.

Raspunde prin e-mail lui