Skip to content

Commit ee47eac

Browse files
yegappanbrammool
authored andcommitted
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)
1 parent c207fd2 commit ee47eac

16 files changed

Lines changed: 40 additions & 20 deletions

src/crypt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ typedef struct {
7373
char_u *p2, int last);
7474
} cryptmethod_T;
7575

76+
static int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len);
77+
static long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
78+
static long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
79+
7680
// index is method_nr of cryptstate_T, CRYPT_M_*
7781
static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
7882
// PK_Zip; very weak
@@ -850,7 +854,7 @@ crypt_append_msg(
850854
}
851855
}
852856

853-
int
857+
static int
854858
crypt_sodium_init(
855859
cryptstate_T *state UNUSED,
856860
char_u *key UNUSED,
@@ -1030,7 +1034,7 @@ crypt_sodium_decode(
10301034
* Encrypt "from[len]" into "to[len]".
10311035
* "from" and "to" can be equal to encrypt in place.
10321036
*/
1033-
long
1037+
static long
10341038
crypt_sodium_buffer_encode(
10351039
cryptstate_T *state UNUSED,
10361040
char_u *from UNUSED,
@@ -1080,7 +1084,7 @@ crypt_sodium_buffer_encode(
10801084
* Decrypt "from[len]" into "to[len]".
10811085
* "from" and "to" can be equal to encrypt in place.
10821086
*/
1083-
long
1087+
static long
10841088
crypt_sodium_buffer_decode(
10851089
cryptstate_T *state UNUSED,
10861090
char_u *from UNUSED,

src/evalvars.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ eval_one_expr_in_str(char_u *p, garray_T *gap, int evaluate)
648648
* Used for a heredoc assignment.
649649
* Returns NULL for an error.
650650
*/
651-
char_u *
651+
static char_u *
652652
eval_all_expr_in_str(char_u *str)
653653
{
654654
garray_T ga;

src/gui.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static void gui_do_scrollbar(win_T *wp, int which, int enable);
3232
static void gui_update_horiz_scrollbar(int);
3333
static void gui_set_fg_color(char_u *name);
3434
static void gui_set_bg_color(char_u *name);
35+
static void init_gui_options(void);
3536
static win_T *xy2win(int x, int y, mouse_find_T popup);
3637

3738
#ifdef GUI_MAY_FORK
@@ -1395,7 +1396,7 @@ gui_update_cursor(
13951396
}
13961397

13971398
#if defined(FEAT_MENU) || defined(PROTO)
1398-
void
1399+
static void
13991400
gui_position_menu(void)
14001401
{
14011402
# if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
@@ -4815,7 +4816,7 @@ gui_bg_default(void)
48154816
/*
48164817
* Option initializations that can only be done after opening the GUI window.
48174818
*/
4818-
void
4819+
static void
48194820
init_gui_options(void)
48204821
{
48214822
// Set the 'background' option according to the lightness of the

src/highlight.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int color_numbers_8[28] = {0, 4, 2, 6,
566566
* "boldp" will be set to TRUE or FALSE for a foreground color when using 8
567567
* colors, otherwise it will be unchanged.
568568
*/
569-
int
569+
static int
570570
lookup_color(int idx, int foreground, int *boldp)
571571
{
572572
int color = color_numbers_16[idx];

src/proto/crypt.pro

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ void crypt_check_method(int method);
2424
void crypt_check_current_method(void);
2525
char_u *crypt_get_key(int store, int twice);
2626
void crypt_append_msg(buf_T *buf);
27-
int crypt_sodium_init(cryptstate_T *state, char_u *key, char_u *salt, int salt_len, char_u *seed, int seed_len);
28-
long crypt_sodium_buffer_encode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
29-
long crypt_sodium_buffer_decode(cryptstate_T *state, char_u *from, size_t len, char_u **buf_out, int last);
3027
int crypt_sodium_munlock(void *const addr, const size_t len);
3128
void crypt_sodium_randombytes_buf(void *const buf, const size_t size);
3229
/* vim: set ft=c : */

src/proto/evalvars.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ int get_spellword(list_T *list, char_u **pp);
1414
void prepare_vimvar(int idx, typval_T *save_tv);
1515
void restore_vimvar(int idx, typval_T *save_tv);
1616
char_u *eval_one_expr_in_str(char_u *p, garray_T *gap, int evaluate);
17-
char_u *eval_all_expr_in_str(char_u *str);
1817
list_T *heredoc_get(exarg_T *eap, char_u *cmd, int script_get, int vim9compile);
1918
void ex_var(exarg_T *eap);
2019
void ex_let(exarg_T *eap);

src/proto/gui.pro

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ int gui_init_font(char_u *font_list, int fontset);
99
int gui_get_wide_font(void);
1010
void gui_set_ligatures(void);
1111
void gui_update_cursor(int force, int clear_selection);
12-
void gui_position_menu(void);
1312
int gui_get_base_width(void);
1413
int gui_get_base_height(void);
1514
void gui_resize_shell(int pixel_width, int pixel_height);
@@ -51,7 +50,6 @@ void gui_check_colors(void);
5150
guicolor_T gui_get_color(char_u *name);
5251
int gui_get_lightness(guicolor_T pixel);
5352
char_u *gui_bg_default(void);
54-
void init_gui_options(void);
5553
void gui_new_scrollbar_colors(void);
5654
void gui_focus_change(int in_focus);
5755
void gui_mouse_moved(int x, int y);

src/proto/highlight.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ char_u *highlight_group_name(int id);
44
int highlight_link_id(int id);
55
void init_highlight(int both, int reset);
66
int load_colors(char_u *name);
7-
int lookup_color(int idx, int foreground, int *boldp);
87
void do_highlight(char_u *line, int forceit, int init);
98
void free_highlight(void);
109
void restore_cterm_colors(void);

src/proto/scriptfile.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ void ex_scriptversion(exarg_T *eap);
4040
void ex_finish(exarg_T *eap);
4141
void do_finish(exarg_T *eap, int reanimate);
4242
int source_finished(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
43-
char_u *script_name_after_autoload(scriptitem_T *si);
4443
char_u *get_autoload_prefix(scriptitem_T *si);
4544
char_u *may_prefix_autoload(char_u *name);
4645
char_u *autoload_name(char_u *name);

src/proto/userfunc.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ void user_func_error(int error, char_u *name, funcexe_T *funcexe);
3838
int call_func(char_u *funcname, int len, typval_T *rettv, int argcount_in, typval_T *argvars_in, funcexe_T *funcexe);
3939
char_u *printable_func_name(ufunc_T *fp);
4040
char_u *trans_function_name(char_u **pp, int *is_global, int skip, int flags, funcdict_T *fdp, partial_T **partial, type_T **type);
41-
char_u *untrans_function_name(char_u *name);
4241
char_u *get_scriptlocal_funcname(char_u *funcname);
4342
char_u *alloc_printable_func_name(char_u *fname);
4443
char_u *save_function_name(char_u **name, int *is_global, int skip, int flags, funcdict_T *fudi);

0 commit comments

Comments
 (0)