mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
patch 9.0.0003: functions are global while they could be local
Problem: Functions are global while they could be local. Solution: Add "static". Add a few tests. (Yegappan Lakshmanan, closes #10612)
This commit is contained in:
committed by
Bram Moolenaar
parent
c207fd2535
commit
ee47eaceaa
10
src/crypt.c
10
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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
|
@ -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 : */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -735,6 +735,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3,
|
||||
/**/
|
||||
2,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user