summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2022-06-29 12:55:36 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-29 12:55:36 +0100
commitee47eaceaa148e07b566ff420f9a3c2edde2fa34 (patch)
tree990dc0d8074d51970ecc83ad94a59e884687a313
parentc207fd2535717030d78f9b92839e5f2ac004cc78 (diff)
downloadvim-git-ee47eaceaa148e07b566ff420f9a3c2edde2fa34.tar.gz
patch 9.0.0003: functions are global while they could be localv9.0.0003
Problem: Functions are global while they could be local. Solution: Add "static". Add a few tests. (Yegappan Lakshmanan, closes #10612)
-rw-r--r--src/crypt.c10
-rw-r--r--src/evalvars.c2
-rw-r--r--src/gui.c5
-rw-r--r--src/highlight.c2
-rw-r--r--src/proto/crypt.pro3
-rw-r--r--src/proto/evalvars.pro1
-rw-r--r--src/proto/gui.pro2
-rw-r--r--src/proto/highlight.pro1
-rw-r--r--src/proto/scriptfile.pro1
-rw-r--r--src/proto/userfunc.pro1
-rw-r--r--src/scriptfile.c2
-rw-r--r--src/testdir/test_fold.vim2
-rw-r--r--src/testdir/test_quickfix.vim7
-rw-r--r--src/testdir/test_vim9_builtin.vim16
-rw-r--r--src/userfunc.c3
-rw-r--r--src/version.c2
16 files changed, 40 insertions, 20 deletions
diff --git a/src/crypt.c b/src/crypt.c
index bed76a96d..b2b50d463 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -73,6 +73,10 @@ typedef struct {
char_u *p2, int last);
} cryptmethod_T;
+static int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len);
+static long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
+static long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
+
// index is method_nr of cryptstate_T, CRYPT_M_*
static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
// PK_Zip; very weak
@@ -850,7 +854,7 @@ crypt_append_msg(
}
}
- int
+ static int
crypt_sodium_init(
cryptstate_T *state UNUSED,
char_u *key UNUSED,
@@ -1030,7 +1034,7 @@ fail:
* Encrypt "from[len]" into "to[len]".
* "from" and "to" can be equal to encrypt in place.
*/
- long
+ static long
crypt_sodium_buffer_encode(
cryptstate_T *state UNUSED,
char_u *from UNUSED,
@@ -1080,7 +1084,7 @@ crypt_sodium_buffer_encode(
* Decrypt "from[len]" into "to[len]".
* "from" and "to" can be equal to encrypt in place.
*/
- long
+ static long
crypt_sodium_buffer_decode(
cryptstate_T *state UNUSED,
char_u *from UNUSED,
diff --git a/src/evalvars.c b/src/evalvars.c
index f7939cbb7..779627c45 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -648,7 +648,7 @@ eval_one_expr_in_str(char_u *p, garray_T *gap, int evaluate)
* Used for a heredoc assignment.
* Returns NULL for an error.
*/
- char_u *
+ static char_u *
eval_all_expr_in_str(char_u *str)
{
garray_T ga;
diff --git a/src/gui.c b/src/gui.c
index 4408545db..e708a2776 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -32,6 +32,7 @@ static void gui_do_scrollbar(win_T *wp, int which, int enable);
static void gui_update_horiz_scrollbar(int);
static void gui_set_fg_color(char_u *name);
static void gui_set_bg_color(char_u *name);
+static void init_gui_options(void);
static win_T *xy2win(int x, int y, mouse_find_T popup);
#ifdef GUI_MAY_FORK
@@ -1395,7 +1396,7 @@ gui_update_cursor(
}
#if defined(FEAT_MENU) || defined(PROTO)
- void
+ static void
gui_position_menu(void)
{
# if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
@@ -4815,7 +4816,7 @@ gui_bg_default(void)
/*
* Option initializations that can only be done after opening the GUI window.
*/
- void
+ static void
init_gui_options(void)
{
// Set the 'background' option according to the lightness of the
diff --git a/src/highlight.c b/src/highlight.c
index 75a310f53..bf876d16f 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -566,7 +566,7 @@ static int color_numbers_8[28] = {0, 4, 2, 6,
* "boldp" will be set to TRUE or FALSE for a foreground color when using 8
* colors, otherwise it will be unchanged.
*/
- int
+ static int
lookup_color(int idx, int foreground, int *boldp)
{
int color = color_numbers_16[idx];
diff --git a/src/proto/crypt.pro b/src/proto/crypt.pro
index d6c7b7ffd..791369491 100644
--- a/src/proto/crypt.pro
+++ b/src/proto/crypt.pro
@@ -24,9 +24,6 @@ void crypt_check_method(int method);
void crypt_check_current_method(void);
char_u *crypt_get_key(int store, int twice);
void crypt_append_msg(buf_T *buf);
-int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len);
-long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
-long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
int crypt_sodium_munlock(void *const addr, const size_t len);
void crypt_sodium_randombytes_buf(void *const buf, const size_t size);
/* vim: set ft=c : */
diff --git a/src/proto/evalvars.pro b/src/proto/evalvars.pro
index 4683c15ff..253af6de6 100644
--- a/src/proto/evalvars.pro
+++ b/src/proto/evalvars.pro
@@ -14,7 +14,6 @@ int get_spellword(list_T *list, char_u **pp);
void prepare_vimvar(int idx, typval_T *save_tv);
void restore_vimvar(int idx, typval_T *save_tv);
char_u *eval_one_expr_in_str(char_u *p, garray_T *gap, int evaluate);
-char_u *eval_all_expr_in_str(char_u *str);
list_T *heredoc_get(exarg_T *eap, char_u *cmd, int script_get, int vim9compile);
void ex_var(exarg_T *eap);
void ex_let(exarg_T *eap);
diff --git a/src/proto/gui.pro b/src/proto/gui.pro
index 2a0ac806f..1a0424844 100644
--- a/src/proto/gui.pro
+++ b/src/proto/gui.pro
@@ -9,7 +9,6 @@ int gui_init_font(char_u *font_list, int fontset);
int gui_get_wide_font(void);
void gui_set_ligatures(void);
void gui_update_cursor(int force, int clear_selection);
-void gui_position_menu(void);
int gui_get_base_width(void);
int gui_get_base_height(void);
void gui_resize_shell(int pixel_width, int pixel_height);
@@ -51,7 +50,6 @@ void gui_check_colors(void);
guicolor_T gui_get_color(char_u *name);
int gui_get_lightness(guicolor_T pixel);
char_u *gui_bg_default(void);
-void init_gui_options(void);
void gui_new_scrollbar_colors(void);
void gui_focus_change(int in_focus);
void gui_mouse_moved(int x, int y);
diff --git a/src/proto/highlight.pro b/src/proto/highlight.pro
index 5635a1738..33f90c652 100644
--- a/src/proto/highlight.pro
+++ b/src/proto/highlight.pro
@@ -4,7 +4,6 @@ char_u *highlight_group_name(int id);
int highlight_link_id(int id);
void init_highlight(int both, int reset);
int load_colors(char_u *name);
-int lookup_color(int idx, int foreground, int *boldp);
void do_highlight(char_u *line, int forceit, int init);
void free_highlight(void);
void restore_cterm_colors(void);
diff --git a/src/proto/scriptfile.pro b/src/proto/scriptfile.pro
index a38f25870..205028d12 100644
--- a/src/proto/scriptfile.pro
+++ b/src/proto/scriptfile.pro
@@ -40,7 +40,6 @@ void ex_scriptversion(exarg_T *eap);
void ex_finish(exarg_T *eap);
void do_finish(exarg_T *eap, int reanimate);
int source_finished(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
-char_u *script_name_after_autoload(scriptitem_T *si);
char_u *get_autoload_prefix(scriptitem_T *si);
char_u *may_prefix_autoload(char_u *name);
char_u *autoload_name(char_u *name);
diff --git a/src/proto/userfunc.pro b/src/proto/userfunc.pro
index 537276013..427d47b24 100644
--- a/src/proto/userfunc.pro
+++ b/src/proto/userfunc.pro
@@ -38,7 +38,6 @@ void user_func_error(int error, char_u *name, funcexe_T *funcexe);
int call_func(char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, funcexe_T *funcexe);
char_u *printable_func_name(ufunc_T *fp);
char_u *trans_function_name(char_u **pp, int *is_global, int skip, int flags, funcdict_T *fdp, partial_T **partial, type_T **type);
-char_u *untrans_function_name(char_u *name);
char_u *get_scriptlocal_funcname(char_u *funcname);
char_u *alloc_printable_func_name(char_u *fname);
char_u *save_function_name(char_u **name, int *is_global, int skip, int flags, funcdict_T *fudi);
diff --git a/src/scriptfile.c b/src/scriptfile.c
index f3a5783db..952f2efd0 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -2346,7 +2346,7 @@ source_finished(
* Find the path of a script below the "autoload" directory.
* Returns NULL if there is no "/autoload/" in the script name.
*/
- char_u *
+ static char_u *
script_name_after_autoload(scriptitem_T *si)
{
char_u *p = si->sn_name;
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 3bdd99fc0..261808402 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -1476,6 +1476,8 @@ func Test_fold_split()
call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)'))
call append(2, 'line 2.5')
call assert_equal([0, 1, 0, 1, 2, 2], range(1, 6)->map('foldlevel(v:val)'))
+ 3d
+ call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)'))
bw!
endfunc
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 182d57047..2a973754d 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -3363,8 +3363,11 @@ func Test_bufoverflow()
cgetexpr ['Compiler: ' . repeat('a', 1015), 'File1:10:Hello World']
set efm=%DEntering\ directory\ %f,%f:%l:%m
- cgetexpr ['Entering directory ' . repeat('a', 1006),
- \ 'File1:10:Hello World']
+ let lines =<< trim eval END
+ Entering directory $"{repeat('a', 1006)}"
+ File1:10:Hello World
+ END
+ cgetexpr lines
set efm&vim
endfunc
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index e83e320c7..024359585 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -3364,6 +3364,22 @@ def Test_searchdecl()
v9.CheckDefAndScriptFailure(['searchdecl(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
v9.CheckDefAndScriptFailure(['searchdecl("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
v9.CheckDefAndScriptFailure(['searchdecl("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+
+ # search for an empty string declaration
+ var lines: list<string> =<< trim END
+ int var1;
+
+ {
+ int var2;
+ var1 = 10;
+ }
+ END
+ new
+ setline(1, lines)
+ cursor(5, 4)
+ searchdecl('')
+ assert_equal([3, 1], [line('.'), col('.')])
+ bw!
enddef
def Test_searchpair()
diff --git a/src/userfunc.c b/src/userfunc.c
index 9b960b775..9f8442277 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -32,6 +32,7 @@ static funccall_T *previous_funccal = NULL;
static void funccal_unref(funccall_T *fc, ufunc_T *fp, int force);
static void func_clear(ufunc_T *fp, int force);
static int func_free(ufunc_T *fp, int force);
+static char_u *untrans_function_name(char_u *name);
void
func_init()
@@ -4073,7 +4074,7 @@ theend:
* This can be used to first search for a script-local function and fall back
* to the global function if not found.
*/
- char_u *
+ static char_u *
untrans_function_name(char_u *name)
{
char_u *p;
diff --git a/src/version.c b/src/version.c
index 74e080ff3..2faf3bdfc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3,
+/**/
2,
/**/
1,