]> granicus.if.org Git - vim/commitdiff
patch 8.2.4045: some global functions are only used in one file v8.2.4045
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 8 Jan 2022 18:43:40 +0000 (18:43 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 8 Jan 2022 18:43:40 +0000 (18:43 +0000)
Problem:    Some global functions are only used in one file.
Solution:   Make the functions static. (Yegappan Lakshmanan, closes #9492)

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/version.c
src/vim9compile.c
src/vim9instr.c
src/window.c

index ede0f2020f9e5be8c1fed052cdbe42a45016945d..c63c8960f5136a6d0df2c9b235e89ca5cee74768 100644 (file)
@@ -4095,32 +4095,16 @@ f_setcmdpos(typval_T *argvars, typval_T *rettv)
     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)
+#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.
  */
-    int
+    static int
 get_cmdline_type(void)
 {
     cmdline_info_T *p = get_ccline_ptr();
@@ -4137,6 +4121,24 @@ get_cmdline_type(void)
 }
 #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.
  */
index efbc5b10e29b6ecbc7f1f3d421016c96d837028e..a8af2b18cfa132f911140873295ba7a79d4a8044 100644 (file)
@@ -460,6 +460,21 @@ init_highlight(
 #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,7 +2287,7 @@ hex_digit(int c)
     return 0x1ffffff;
 }
 
-    guicolor_T
+    static guicolor_T
 decode_hex_color(char_u *hex)
 {
     guicolor_T color;
@@ -2294,7 +2309,7 @@ decode_hex_color(char_u *hex)
 // 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
+    static guicolor_T
 colorname2rgb(char_u *name)
 {
     dict_T      *colornames_table = get_vim_var_dict(VV_COLORNAMES);
@@ -2335,18 +2350,6 @@ colorname2rgb(char_u *name)
     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
index d56893a65766bf694d247c6b7497965ca2f33c6f..f97719b756cfba314647ad972eb42b21bc6fb3c0 100644 (file)
@@ -34,7 +34,6 @@ void f_getcmdline(typval_T *argvars, typval_T *rettv);
 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);
index b17f40df303e4f4dbc0989a07811f19a30a3e48a..5635a17384b4b7e73fe48381a5c308ef29dead8f 100644 (file)
@@ -14,9 +14,6 @@ void hl_set_font_name(char_u *font_name);
 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);
index 33290d09e711e822c15c64c59ca008a64ee16520..98c40c86cbaa0a06f832cdee9d5aa17faf31b079 100644 (file)
@@ -8,7 +8,6 @@ int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T
 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);
index b20dcf7d1b153a3f6da4ace558d93ae234ff8047..c9455003e9fc6a90380ac968cc1a00c091882ea2 100644 (file)
@@ -1,7 +1,6 @@
 /* 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);
@@ -28,9 +27,7 @@ int generate_GETITEM(cctx_T *cctx, int index, int with_op);
 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);
index 740d310b76092d889b0543666c174d33416e210a..654d36a6e3d622c9f8649a546ce485a63ca19703 100644 (file)
@@ -43,7 +43,6 @@ tabpage_T *win_find_tabpage(win_T *win);
 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);
index 86ab08594acabb5ad4d8ae68a3539598e256c50f..a1dea1fea009a11fec46a352f8b36f976b1d276f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4045,
 /**/
     4044,
 /**/
index 90d7adbb7981884eb5148c4a3c3c244c18283e44..11e322645107fd528786c072b5ba0a8bfd6a2553 100644 (file)
@@ -557,6 +557,27 @@ get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx)
     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,27 +604,6 @@ find_imported(char_u *name, size_t len, cctx_T *cctx)
     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.
  */
index 4961695f07992caf6ee4cdbc3aab2a90cdce39d7..8ce32a766ac3512046bb6451376739beaeff1e62 100644 (file)
@@ -66,7 +66,7 @@ generate_instr_drop(cctx_T *cctx, isntype_T isn_type, int drop)
  * Generate instruction "isn_type" and put "type" on the type stack,
  * use "decl_type" for the declared type.
  */
-    isn_T *
+    static isn_T *
 generate_instr_type2(
        cctx_T      *cctx,
        isntype_T   isn_type,
@@ -828,7 +828,7 @@ generate_STORE(cctx_T *cctx, isntype_T isn_type, int idx, char_u *name)
 /*
  * Generate an ISN_STOREOUTER instruction.
  */
-    int
+    static int
 generate_STOREOUTER(cctx_T *cctx, int idx, int level)
 {
     isn_T      *isn;
@@ -862,7 +862,7 @@ generate_STORENR(cctx_T *cctx, int idx, varnumber_T value)
 /*
  * Generate an ISN_STOREOPT or ISN_STOREFUNCOPT instruction
  */
-    int
+    static int
 generate_STOREOPT(
        cctx_T      *cctx,
        isntype_T   isn_type,
index 6d5d0a4b8a834405645d4dd1aa80fc88bea70add..05e85baf366a8c5aa8415424ee61a65852c59b24 100644 (file)
@@ -4734,6 +4734,54 @@ win_enter(win_T *wp, int undo_sync)
                    | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS);
 }
 
+/*
+ * 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
@@ -4858,54 +4906,6 @@ win_enter_ext(win_T *wp, int flags)
     return did_decrement;
 }
 
-/*
- * 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.