mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 02:46:31 +00:00
vim-patch:8.1.1891: functions used in one file are global
Problem: Functions used in one file are global.
Solution: Add "static". (Yegappan Lakshmanan, closes vim/vim#4840)
5843f5f37b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -1566,7 +1566,7 @@ bool has_event(event_T event) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
|
||||
/// Return true when there is a CursorHold/CursorHoldI autocommand defined for
|
||||
/// the current mode.
|
||||
bool has_cursorhold(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
static bool has_cursorhold(void) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
return has_event((get_real_state() == MODE_NORMAL_BUSY ? EVENT_CURSORHOLD : EVENT_CURSORHOLDI));
|
||||
}
|
||||
|
@@ -1683,7 +1683,7 @@ void set_curbuf(buf_T *buf, int action, bool update_jumplist)
|
||||
/// Enter a new current buffer.
|
||||
/// Old curbuf must have been abandoned already! This also means "curbuf" may
|
||||
/// be pointing to freed memory.
|
||||
void enter_buffer(buf_T *buf)
|
||||
static void enter_buffer(buf_T *buf)
|
||||
{
|
||||
// when closing the current buffer stop Visual mode
|
||||
if (VIsual_active
|
||||
@@ -2207,7 +2207,7 @@ int buflist_getfile(int n, linenr_T lnum, int options, int forceit)
|
||||
}
|
||||
|
||||
/// Go to the last known line number for the current buffer.
|
||||
void buflist_getfpos(void)
|
||||
static void buflist_getfpos(void)
|
||||
{
|
||||
pos_T *fpos = &buflist_findfmark(curbuf)->mark;
|
||||
|
||||
|
@@ -1791,7 +1791,7 @@ void digraph_getlist_common(bool list_all, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
|
||||
struct dg_header_entry {
|
||||
static struct dg_header_entry {
|
||||
int dg_start;
|
||||
const char *dg_header;
|
||||
} header_table[] = {
|
||||
|
@@ -190,7 +190,7 @@ void tv_list_watch_remove(list_T *const l, listwatch_T *const lwrem)
|
||||
///
|
||||
/// @param[out] l List from which item is removed.
|
||||
/// @param[in] item List item being removed.
|
||||
void tv_list_watch_fix(list_T *const l, const listitem_T *const item)
|
||||
static void tv_list_watch_fix(list_T *const l, const listitem_T *const item)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
for (listwatch_T *lw = l->lv_watch; lw != NULL; lw = lw->lw_next) {
|
||||
|
@@ -2144,7 +2144,7 @@ void do_wqall(exarg_T *eap)
|
||||
/// Check the 'write' option.
|
||||
///
|
||||
/// @return true and give a message when it's not st.
|
||||
bool not_writing(void)
|
||||
static bool not_writing(void)
|
||||
{
|
||||
if (p_write) {
|
||||
return false;
|
||||
|
@@ -799,7 +799,7 @@ void report_make_pending(int pending, void *value)
|
||||
|
||||
/// If something pending in a finally clause is resumed at the ":endtry", report
|
||||
/// it if required by the 'verbose' option or when debugging.
|
||||
void report_resume_pending(int pending, void *value)
|
||||
static void report_resume_pending(int pending, void *value)
|
||||
{
|
||||
if (p_verbose >= 14 || debug_break_level > 0) {
|
||||
if (debug_break_level <= 0) {
|
||||
@@ -814,7 +814,7 @@ void report_resume_pending(int pending, void *value)
|
||||
|
||||
/// If something pending in a finally clause is discarded, report it if required
|
||||
/// by the 'verbose' option or when debugging.
|
||||
void report_discard_pending(int pending, void *value)
|
||||
static void report_discard_pending(int pending, void *value)
|
||||
{
|
||||
if (p_verbose >= 14 || debug_break_level > 0) {
|
||||
if (debug_break_level <= 0) {
|
||||
|
@@ -1031,7 +1031,7 @@ fail:
|
||||
|
||||
/// Free the list of lists of visited files and directories
|
||||
/// Can handle it if the passed search_context is NULL;
|
||||
void vim_findfile_free_visited(void *search_ctx_arg)
|
||||
static void vim_findfile_free_visited(void *search_ctx_arg)
|
||||
{
|
||||
if (search_ctx_arg == NULL) {
|
||||
return;
|
||||
|
@@ -1282,7 +1282,7 @@ void may_sync_undo(void)
|
||||
}
|
||||
|
||||
/// Make "typebuf" empty and allocate new buffers.
|
||||
void alloc_typebuf(void)
|
||||
static void alloc_typebuf(void)
|
||||
{
|
||||
typebuf.tb_buf = xmalloc(TYPELEN_INIT);
|
||||
typebuf.tb_noremap = xmalloc(TYPELEN_INIT);
|
||||
@@ -1298,7 +1298,7 @@ void alloc_typebuf(void)
|
||||
}
|
||||
|
||||
/// Free the buffers of "typebuf".
|
||||
void free_typebuf(void)
|
||||
static void free_typebuf(void)
|
||||
{
|
||||
if (typebuf.tb_buf == typebuf_init) {
|
||||
internal_error("Free typebuf 1");
|
||||
|
@@ -335,7 +335,7 @@ int get_sw_value(buf_T *buf)
|
||||
}
|
||||
|
||||
/// Idem, using "pos".
|
||||
int get_sw_value_pos(buf_T *buf, pos_T *pos, bool left)
|
||||
static int get_sw_value_pos(buf_T *buf, pos_T *pos, bool left)
|
||||
{
|
||||
pos_T save_cursor = curwin->w_cursor;
|
||||
|
||||
|
@@ -355,7 +355,7 @@ static bool cin_islabel_skip(const char **s)
|
||||
|
||||
// Recognize a label: "label:".
|
||||
// Note: curwin->w_cursor must be where we are looking for the label.
|
||||
bool cin_islabel(void) // XXX
|
||||
static bool cin_islabel(void) // XXX
|
||||
{
|
||||
const char *s = cin_skipcomment(get_cursor_line_ptr());
|
||||
|
||||
@@ -454,7 +454,7 @@ static int cin_isinit(void)
|
||||
/// Recognize a switch label: "case .*:" or "default:".
|
||||
///
|
||||
/// @param strict Allow relaxed check of case statement for JS
|
||||
bool cin_iscase(const char *s, bool strict)
|
||||
static bool cin_iscase(const char *s, bool strict)
|
||||
{
|
||||
s = cin_skipcomment(s);
|
||||
if (cin_starts_with(s, "case")) {
|
||||
@@ -500,7 +500,7 @@ static int cin_isdefault(const char *s)
|
||||
}
|
||||
|
||||
/// Recognize a scope declaration label set in 'cinscopedecls'.
|
||||
bool cin_isscopedecl(const char *p)
|
||||
static bool cin_isscopedecl(const char *p)
|
||||
{
|
||||
const char *s = cin_skipcomment(p);
|
||||
|
||||
|
@@ -1090,7 +1090,7 @@ char *get_menu_names(expand_T *xp, int idx)
|
||||
///
|
||||
/// @param name may be modified.
|
||||
/// @return start of the next element
|
||||
char *menu_name_skip(char *const name)
|
||||
static char *menu_name_skip(char *const name)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
@@ -662,7 +662,7 @@ void msg_source(int hl_id)
|
||||
/// If "emsg_off" is set: no error messages at the moment.
|
||||
/// If "msg" is in 'debug': do error message but without side effects.
|
||||
/// If "emsg_skip" is set: never do error messages.
|
||||
int emsg_not_now(void)
|
||||
static int emsg_not_now(void)
|
||||
{
|
||||
if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL
|
||||
&& vim_strchr(p_debug, 't') == NULL)
|
||||
@@ -3045,7 +3045,7 @@ static bool do_more_prompt(int typed_char)
|
||||
return retval;
|
||||
}
|
||||
|
||||
void msg_moremsg(bool full)
|
||||
static void msg_moremsg(bool full)
|
||||
{
|
||||
int attr = hl_combine_attr(HL_ATTR(HLF_MSG), HL_ATTR(HLF_M));
|
||||
grid_line_start(&msg_grid_adj, Rows - 1);
|
||||
@@ -3739,7 +3739,7 @@ static void copy_confirm_hotkeys(const char *buttons, int default_button_idx,
|
||||
}
|
||||
|
||||
/// Display the ":confirm" message. Also called when screen resized.
|
||||
void display_confirm_msg(void)
|
||||
static void display_confirm_msg(void)
|
||||
{
|
||||
// Avoid that 'q' at the more prompt truncates the message here.
|
||||
confirm_msg_used++;
|
||||
|
@@ -4916,7 +4916,7 @@ void copy_winopt(winopt_T *from, winopt_T *to)
|
||||
}
|
||||
|
||||
/// Check string options in a window for a NULL value.
|
||||
void check_win_options(win_T *win)
|
||||
static void check_win_options(win_T *win)
|
||||
{
|
||||
check_winopt(&win->w_onebuf_opt);
|
||||
check_winopt(&win->w_allbuf_opt);
|
||||
|
@@ -171,7 +171,7 @@ proftime_T profile_self(proftime_T self, proftime_T total, proftime_T children)
|
||||
/// Gets the current waittime.
|
||||
///
|
||||
/// @return the current waittime
|
||||
proftime_T profile_get_wait(void) FUNC_ATTR_PURE
|
||||
static proftime_T profile_get_wait(void) FUNC_ATTR_PURE
|
||||
{
|
||||
return prof_wait_time;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ proftime_T profile_sub_wait(proftime_T tm, proftime_T tma) FUNC_ATTR_PURE
|
||||
/// Checks if time `tm1` is equal to `tm2`.
|
||||
///
|
||||
/// @return true if `tm1` == `tm2`
|
||||
bool profile_equal(proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
|
||||
static bool profile_equal(proftime_T tm1, proftime_T tm2) FUNC_ATTR_CONST
|
||||
{
|
||||
return tm1 == tm2;
|
||||
}
|
||||
|
@@ -2991,7 +2991,7 @@ void u_clearallandblockfree(buf_T *buf)
|
||||
}
|
||||
|
||||
/// Save the line "lnum" for the "U" command.
|
||||
void u_saveline(buf_T *buf, linenr_T lnum)
|
||||
static void u_saveline(buf_T *buf, linenr_T lnum)
|
||||
{
|
||||
if (lnum == buf->b_u_line_lnum) { // line is already saved
|
||||
return;
|
||||
|
@@ -4262,7 +4262,7 @@ int win_new_tabpage(int after, char *filename)
|
||||
// Open a new tab page if ":tab cmd" was used. It will edit the same buffer,
|
||||
// like with ":split".
|
||||
// Returns OK if a new tab page was created, FAIL otherwise.
|
||||
int may_open_tabpage(void)
|
||||
static int may_open_tabpage(void)
|
||||
{
|
||||
int n = (cmdmod.cmod_tab == 0) ? postponed_split_tab : cmdmod.cmod_tab;
|
||||
|
||||
|
@@ -96,9 +96,6 @@ describe('profiling related functions', function()
|
||||
local function profile_cmp(t1, t2)
|
||||
return prof.profile_cmp(t1, t2)
|
||||
end
|
||||
local function profile_equal(t1, t2)
|
||||
return prof.profile_equal(t1, t2)
|
||||
end
|
||||
local function profile_msg(q)
|
||||
return ffi.string(prof.profile_msg(q))
|
||||
end
|
||||
@@ -110,20 +107,6 @@ describe('profiling related functions', function()
|
||||
return tonumber(s) + tonumber(us) / 1000000
|
||||
end
|
||||
|
||||
describe('profile_equal', function()
|
||||
itp('times are equal to themselves', function()
|
||||
local start = profile_start()
|
||||
assert.is_true(profile_equal(start, start))
|
||||
|
||||
local e = profile_end(start)
|
||||
assert.is_true(profile_equal(e, e))
|
||||
end)
|
||||
|
||||
itp('times are unequal to others', function()
|
||||
assert.is_false(profile_equal(profile_start(), profile_start()))
|
||||
end)
|
||||
end)
|
||||
|
||||
-- this is quite difficult to test, as it would rely on other functions in
|
||||
-- the profiling package. Those functions in turn will probably be tested
|
||||
-- using profile_cmp... circular reasoning.
|
||||
@@ -169,7 +152,6 @@ describe('profiling related functions', function()
|
||||
describe('profile_zero', function()
|
||||
itp('returns the same value on each call', function()
|
||||
eq(0, profile_zero())
|
||||
assert.is_true(profile_equal(profile_zero(), profile_zero()))
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -203,7 +185,7 @@ describe('profiling related functions', function()
|
||||
|
||||
describe('profile_setlimit', function()
|
||||
itp('sets no limit when 0 is passed', function()
|
||||
eq(true, profile_equal(profile_setlimit(0), profile_zero()))
|
||||
eq(profile_setlimit(0), profile_zero())
|
||||
end)
|
||||
|
||||
itp('sets a limit in the future otherwise', function()
|
||||
|
Reference in New Issue
Block a user