Patch 9.0.0248
Problem:    Duplicate code in finding a script in the execution stack.
Solution:   Reduce duplicate code. (closes #10961)
Files:      src/scriptfile.c


*** ../vim-9.0.0247/src/scriptfile.c    2022-08-22 13:14:31.892769316 +0100
--- src/scriptfile.c    2022-08-23 19:22:49.339524034 +0100
***************
*** 162,193 ****
      // instead.
      if (which == ESTACK_SCRIPT)
      {
-       entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
        // Walk the stack backwards, starting from the current frame.
        for (idx = exestack.ga_len - 1; idx >= 0; --idx, --entry)
        {
!           if (entry->es_type == ETYPE_UFUNC)
            {
!               sctx_T *def_ctx = &entry->es_info.ufunc->uf_script_ctx;
  
!               if (def_ctx->sc_sid > 0)
!                   return vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name);
!               else
!                   return NULL;
!           }
!           else if (entry->es_type == ETYPE_AUCMD)
!           {
!               sctx_T *def_ctx = acp_script_ctx(entry->es_info.aucmd);
! 
!               if (def_ctx->sc_sid > 0)
!                   return vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name);
!               else
!                   return NULL;
            }
            else if (entry->es_type == ETYPE_SCRIPT)
-           {
                return vim_strsave(entry->es_name);
-           }
        }
        return NULL;
      }
--- 162,182 ----
      // instead.
      if (which == ESTACK_SCRIPT)
      {
        // Walk the stack backwards, starting from the current frame.
        for (idx = exestack.ga_len - 1; idx >= 0; --idx, --entry)
        {
!           if (entry->es_type == ETYPE_UFUNC || entry->es_type == ETYPE_AUCMD)
            {
!               sctx_T *def_ctx = entry->es_type == ETYPE_UFUNC
!                                     ? &entry->es_info.ufunc->uf_script_ctx
!                                     : acp_script_ctx(entry->es_info.aucmd);
  
!               return def_ctx->sc_sid > 0
!                          ? vim_strsave(SCRIPT_ITEM(def_ctx->sc_sid)->sn_name)
!                          : NULL;
            }
            else if (entry->es_type == ETYPE_SCRIPT)
                return vim_strsave(entry->es_name);
        }
        return NULL;
      }
*** ../vim-9.0.0247/src/version.c       2022-08-23 18:39:14.760797662 +0100
--- src/version.c       2022-08-23 19:24:39.919203769 +0100
***************
*** 733,734 ****
--- 733,736 ----
  {   /* Add new patch number below this line */
+ /**/
+     248,
  /**/

-- 
Compilation process failed successfully.

 /// 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/20220823182642.8EABA1C0674%40moolenaar.net.

Raspunde prin e-mail lui