Patch 8.2.4045
Problem:    Some global functions are only used in one file.
Solution:   Make the functions static. (Yegappan Lakshmanan, closes #9492)
Files:      src/ex_getln.c, src/highlight.c, src/proto/ex_getln.pro,
            src/proto/highlight.pro, src/proto/vim9compile.pro,
            src/proto/vim9instr.pro, src/proto/window.pro, src/vim9compile.c,
            src/vim9instr.c, src/window.c


*** ../vim-8.2.4044/src/ex_getln.c      2022-01-05 17:49:10.873225135 +0000
--- src/ex_getln.c      2022-01-08 18:39:36.909675220 +0000
***************
*** 4095,4126 ****
      if (pos >= 0)
        rettv->vval.v_number = set_cmdline_pos(pos);
  }
- 
- /*
-  * "getcmdtype()" function
-  */
-     void
- f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv)
- {
-     rettv->v_type = VAR_STRING;
-     rettv->vval.v_string = alloc(2);
-     if (rettv->vval.v_string != NULL)
-     {
-       rettv->vval.v_string[0] = get_cmdline_type();
-       rettv->vval.v_string[1] = NUL;
-     }
- }
- 
  #endif
  
! #if defined(FEAT_EVAL) || defined(FEAT_CMDWIN) || defined(PROTO)
  /*
   * Get the current command-line type.
   * Returns ':' or '/' or '?' or '@' or '>' or '-'
   * Only works when the command line is being edited.
   * Returns NUL when something is wrong.
   */
!     int
  get_cmdline_type(void)
  {
      cmdline_info_T *p = get_ccline_ptr();
--- 4095,4110 ----
      if (pos >= 0)
        rettv->vval.v_number = set_cmdline_pos(pos);
  }
  #endif
  
! #if defined(FEAT_EVAL) || defined(FEAT_CMDWIN)
  /*
   * Get the current command-line type.
   * Returns ':' or '/' or '?' or '@' or '>' or '-'
   * Only works when the command line is being edited.
   * Returns NUL when something is wrong.
   */
!     static int
  get_cmdline_type(void)
  {
      cmdline_info_T *p = get_ccline_ptr();
***************
*** 4137,4142 ****
--- 4121,4144 ----
  }
  #endif
  
+ #if defined(FEAT_EVAL) || defined(PROTO)
+ /*
+  * "getcmdtype()" function
+  */
+     void
+ f_getcmdtype(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+     rettv->v_type = VAR_STRING;
+     rettv->vval.v_string = alloc(2);
+     if (rettv->vval.v_string != NULL)
+     {
+       rettv->vval.v_string[0] = get_cmdline_type();
+       rettv->vval.v_string[1] = NUL;
+     }
+ }
+ 
+ #endif
+ 
  /*
   * Return the first character of the current command line.
   */
*** ../vim-8.2.4044/src/highlight.c     2022-01-08 12:41:12.204795554 +0000
--- src/highlight.c     2022-01-08 18:36:26.721827558 +0000
***************
*** 460,465 ****
--- 460,480 ----
  #endif
  }
  
+ #if defined(FEAT_EVAL) && (defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS))
+ /*
+  * Load a default color list. Intended to support legacy color names but 
allows
+  * the user to override the color values. Only loaded once.
+  */
+     static void
+ load_default_colors_lists()
+ {
+     // Lacking a default color list isn't the end of the world but it is 
likely
+     // an inconvenience so users should know when it is missing.
+     if (source_runtime((char_u *)"colors/lists/default.vim", DIP_ALL) != OK)
+       msg("failed to load colors/lists/default.vim");
+ }
+ #endif
+ 
  /*
   * Load color file "name".
   * Return OK for success, FAIL for failure.
***************
*** 2272,2278 ****
      return 0x1ffffff;
  }
  
!     guicolor_T
  decode_hex_color(char_u *hex)
  {
      guicolor_T color;
--- 2287,2293 ----
      return 0x1ffffff;
  }
  
!     static guicolor_T
  decode_hex_color(char_u *hex)
  {
      guicolor_T color;
***************
*** 2294,2300 ****
  // such name exists in the color table. The convention is to use lowercase for
  // all keys in the v:colornames dictionary. The value can be either a string 
in
  // the form #rrggbb or a number, either of which is converted to a guicolor_T.
!     guicolor_T
  colorname2rgb(char_u *name)
  {
      dict_T      *colornames_table = get_vim_var_dict(VV_COLORNAMES);
--- 2309,2315 ----
  // such name exists in the color table. The convention is to use lowercase for
  // all keys in the v:colornames dictionary. The value can be either a string 
in
  // the form #rrggbb or a number, either of which is converted to a guicolor_T.
!     static guicolor_T
  colorname2rgb(char_u *name)
  {
      dict_T      *colornames_table = get_vim_var_dict(VV_COLORNAMES);
***************
*** 2335,2352 ****
      return INVALCOLOR;
  }
  
- /*
-  * Load a default color list. Intended to support legacy color names but 
allows
-  * the user to override the color values. Only loaded once.
-  */
-     void
- load_default_colors_lists()
- {
-     // Lacking a default color list isn't the end of the world but it is 
likely
-     // an inconvenience so users should know when it is missing.
-     if (source_runtime((char_u *)"colors/lists/default.vim", DIP_ALL) != OK)
-       msg("failed to load colors/lists/default.vim");
- }
  #endif
  
      guicolor_T
--- 2350,2355 ----
*** ../vim-8.2.4044/src/proto/ex_getln.pro      2021-12-28 20:59:51.975937080 
+0000
--- src/proto/ex_getln.pro      2022-01-08 18:36:26.721827558 +0000
***************
*** 34,40 ****
  void f_getcmdpos(typval_T *argvars, typval_T *rettv);
  void f_setcmdpos(typval_T *argvars, typval_T *rettv);
  void f_getcmdtype(typval_T *argvars, typval_T *rettv);
- int get_cmdline_type(void);
  int get_cmdline_firstc(void);
  int get_list_range(char_u **str, int *num1, int *num2);
  char *check_cedit(void);
--- 34,39 ----
*** ../vim-8.2.4044/src/proto/highlight.pro     2021-11-13 10:49:26.833952428 
+0000
--- src/proto/highlight.pro     2022-01-08 18:36:26.721827558 +0000
***************
*** 14,22 ****
  void hl_set_bg_color_name(char_u *name);
  void hl_set_fg_color_name(char_u *name);
  guicolor_T color_name2handle(char_u *name);
- guicolor_T decode_hex_color(char_u *hex);
- guicolor_T colorname2rgb(char_u *name);
- void load_default_colors_lists(void);
  guicolor_T gui_get_color_cmn(char_u *name);
  guicolor_T gui_get_rgb_color_cmn(int r, int g, int b);
  int get_cterm_attr_idx(int attr, int fg, int bg);
--- 14,19 ----
*** ../vim-8.2.4044/src/proto/vim9compile.pro   2021-12-20 15:03:23.247346527 
+0000
--- src/proto/vim9compile.pro   2022-01-08 18:36:26.721827558 +0000
***************
*** 8,14 ****
  lvar_T *reserve_local(cctx_T *cctx, char_u *name, size_t len, int isConst, 
type_T *type);
  int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T 
*cctx);
  imported_T *find_imported(char_u *name, size_t len, cctx_T *cctx);
- imported_T *find_imported_in_script(char_u *name, size_t len, int sid);
  char_u *may_peek_next_line(cctx_T *cctx, char_u *arg, char_u **nextp);
  char_u *peek_next_line_from_context(cctx_T *cctx);
  char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
--- 8,13 ----
*** ../vim-8.2.4044/src/proto/vim9instr.pro     2022-01-04 15:16:57.879864882 
+0000
--- src/proto/vim9instr.pro     2022-01-08 18:36:26.721827558 +0000
***************
*** 1,7 ****
  /* vim9instr.c */
  isn_T *generate_instr(cctx_T *cctx, isntype_T isn_type);
  isn_T *generate_instr_drop(cctx_T *cctx, isntype_T isn_type, int drop);
- isn_T *generate_instr_type2(cctx_T *cctx, isntype_T isn_type, type_T *type, 
type_T *decl_type);
  isn_T *generate_instr_type(cctx_T *cctx, isntype_T isn_type, type_T *type);
  isn_T *generate_instr_debug(cctx_T *cctx);
  int may_generate_2STRING(int offset, int tolerant, cctx_T *cctx);
--- 1,6 ----
***************
*** 28,36 ****
  int generate_SLICE(cctx_T *cctx, int count);
  int generate_CHECKLEN(cctx_T *cctx, int min_len, int more_OK);
  int generate_STORE(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name);
- int generate_STOREOUTER(cctx_T *cctx, int idx, int level);
  int generate_STORENR(cctx_T *cctx, int idx, varnumber_T value);
- int generate_STOREOPT(cctx_T *cctx, isntype_T isn_type, char_u *name, int 
opt_flags);
  int generate_LOAD(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name, 
type_T *type);
  int generate_LOADOUTER(cctx_T *cctx, int idx, int nesting, type_T *type);
  int generate_LOADV(cctx_T *cctx, char_u *name, int error);
--- 27,33 ----
*** ../vim-8.2.4044/src/proto/window.pro        2021-12-09 11:57:19.159557375 
+0000
--- src/proto/window.pro        2022-01-08 18:36:26.721827558 +0000
***************
*** 43,49 ****
  win_T *win_vert_neighbor(tabpage_T *tp, win_T *wp, int up, long count);
  win_T *win_horz_neighbor(tabpage_T *tp, win_T *wp, int left, long count);
  void win_enter(win_T *wp, int undo_sync);
- void fix_current_dir(void);
  win_T *buf_jump_open_win(buf_T *buf);
  win_T *buf_jump_open_tab(buf_T *buf);
  void win_free_popup(win_T *win);
--- 43,48 ----
*** ../vim-8.2.4044/src/vim9compile.c   2022-01-08 15:39:35.410385289 +0000
--- src/vim9compile.c   2022-01-08 18:36:26.721827558 +0000
***************
*** 557,562 ****
--- 557,583 ----
      return -1;
  }
  
+     static imported_T *
+ find_imported_in_script(char_u *name, size_t len, int sid)
+ {
+     scriptitem_T    *si;
+     int                   idx;
+ 
+     if (!SCRIPT_ID_VALID(sid))
+       return NULL;
+     si = SCRIPT_ITEM(sid);
+     for (idx = 0; idx < si->sn_imports.ga_len; ++idx)
+     {
+       imported_T *import = ((imported_T *)si->sn_imports.ga_data) + idx;
+ 
+       if (len == 0 ? STRCMP(name, import->imp_name) == 0
+                    : STRLEN(import->imp_name) == len
+                                 && STRNCMP(name, import->imp_name, len) == 0)
+           return import;
+     }
+     return NULL;
+ }
+ 
  /*
   * Find "name" in imported items of the current script or in "cctx" if not
   * NULL.
***************
*** 583,609 ****
      return find_imported_in_script(name, len, current_sctx.sc_sid);
  }
  
-     imported_T *
- find_imported_in_script(char_u *name, size_t len, int sid)
- {
-     scriptitem_T    *si;
-     int                   idx;
- 
-     if (!SCRIPT_ID_VALID(sid))
-       return NULL;
-     si = SCRIPT_ITEM(sid);
-     for (idx = 0; idx < si->sn_imports.ga_len; ++idx)
-     {
-       imported_T *import = ((imported_T *)si->sn_imports.ga_data) + idx;
- 
-       if (len == 0 ? STRCMP(name, import->imp_name) == 0
-                    : STRLEN(import->imp_name) == len
-                                 && STRNCMP(name, import->imp_name, len) == 0)
-           return import;
-     }
-     return NULL;
- }
- 
  /*
   * Free all imported variables.
   */
--- 604,609 ----
*** ../vim-8.2.4044/src/vim9instr.c     2022-01-04 15:16:57.879864882 +0000
--- src/vim9instr.c     2022-01-08 18:36:26.721827558 +0000
***************
*** 66,72 ****
   * Generate instruction "isn_type" and put "type" on the type stack,
   * use "decl_type" for the declared type.
   */
!     isn_T *
  generate_instr_type2(
        cctx_T      *cctx,
        isntype_T   isn_type,
--- 66,72 ----
   * Generate instruction "isn_type" and put "type" on the type stack,
   * use "decl_type" for the declared type.
   */
!     static isn_T *
  generate_instr_type2(
        cctx_T      *cctx,
        isntype_T   isn_type,
***************
*** 828,834 ****
  /*
   * Generate an ISN_STOREOUTER instruction.
   */
!     int
  generate_STOREOUTER(cctx_T *cctx, int idx, int level)
  {
      isn_T     *isn;
--- 828,834 ----
  /*
   * Generate an ISN_STOREOUTER instruction.
   */
!     static int
  generate_STOREOUTER(cctx_T *cctx, int idx, int level)
  {
      isn_T     *isn;
***************
*** 862,868 ****
  /*
   * Generate an ISN_STOREOPT or ISN_STOREFUNCOPT instruction
   */
!     int
  generate_STOREOPT(
        cctx_T      *cctx,
        isntype_T   isn_type,
--- 862,868 ----
  /*
   * Generate an ISN_STOREOPT or ISN_STOREFUNCOPT instruction
   */
!     static int
  generate_STOREOPT(
        cctx_T      *cctx,
        isntype_T   isn_type,
*** ../vim-8.2.4044/src/window.c        2022-01-08 16:19:18.513639814 +0000
--- src/window.c        2022-01-08 18:36:26.721827558 +0000
***************
*** 4735,4740 ****
--- 4735,4788 ----
  }
  
  /*
+  * Used after making another window the current one: change directory if
+  * needed.
+  */
+     static void
+ fix_current_dir(void)
+ {
+ #ifdef FEAT_AUTOCHDIR
+     if (p_acd)
+       do_autochdir();
+     else
+ #endif
+     if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL)
+     {
+       char_u  *dirname;
+ 
+       // Window or tab has a local directory: Save current directory as
+       // global directory (unless that was done already) and change to the
+       // local directory.
+       if (globaldir == NULL)
+       {
+           char_u      cwd[MAXPATHL];
+ 
+           if (mch_dirname(cwd, MAXPATHL) == OK)
+               globaldir = vim_strsave(cwd);
+       }
+       if (curwin->w_localdir != NULL)
+           dirname = curwin->w_localdir;
+       else
+           dirname = curtab->tp_localdir;
+ 
+       if (mch_chdir((char *)dirname) == 0)
+       {
+           last_chdir_reason = NULL;
+           shorten_fnames(TRUE);
+       }
+     }
+     else if (globaldir != NULL)
+     {
+       // Window doesn't have a local directory and we are not in the global
+       // directory: Change to the global directory.
+       vim_ignored = mch_chdir((char *)globaldir);
+       VIM_CLEAR(globaldir);
+       last_chdir_reason = NULL;
+       shorten_fnames(TRUE);
+     }
+ }
+ 
+ /*
   * Make window "wp" the current window.
   * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that
   * curwin has just been closed and isn't valid.
***************
*** 4859,4912 ****
  }
  
  /*
-  * Used after making another window the current one: change directory if
-  * needed.
-  */
-     void
- fix_current_dir(void)
- {
- #ifdef FEAT_AUTOCHDIR
-     if (p_acd)
-       do_autochdir();
-     else
- #endif
-     if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL)
-     {
-       char_u  *dirname;
- 
-       // Window or tab has a local directory: Save current directory as
-       // global directory (unless that was done already) and change to the
-       // local directory.
-       if (globaldir == NULL)
-       {
-           char_u      cwd[MAXPATHL];
- 
-           if (mch_dirname(cwd, MAXPATHL) == OK)
-               globaldir = vim_strsave(cwd);
-       }
-       if (curwin->w_localdir != NULL)
-           dirname = curwin->w_localdir;
-       else
-           dirname = curtab->tp_localdir;
- 
-       if (mch_chdir((char *)dirname) == 0)
-       {
-           last_chdir_reason = NULL;
-           shorten_fnames(TRUE);
-       }
-     }
-     else if (globaldir != NULL)
-     {
-       // Window doesn't have a local directory and we are not in the global
-       // directory: Change to the global directory.
-       vim_ignored = mch_chdir((char *)globaldir);
-       VIM_CLEAR(globaldir);
-       last_chdir_reason = NULL;
-       shorten_fnames(TRUE);
-     }
- }
- 
- /*
   * Jump to the first open window that contains buffer "buf", if one exists.
   * Returns a pointer to the window found, otherwise NULL.
   */
--- 4907,4912 ----
*** ../vim-8.2.4044/src/version.c       2022-01-08 17:03:51.600942321 +0000
--- src/version.c       2022-01-08 18:37:57.549758702 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4045,
  /**/

-- 
XML is a nice language for computers.  Not for humans.

 /// 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/20220108184412.361891C0D8A%40moolenaar.net.

Raspunde prin e-mail lui