forked from aniani/vim
patch 8.2.3320: some local functions are not static
Problem: Some local functions are not static. Solution: Add "static". Move snprintf() related code to strings.c. (Yegappan Lakshmanan, closes #8734)
This commit is contained in:
parent
eed9616120
commit
8ee52affe7
24
src/alloc.c
24
src/alloc.c
@ -232,19 +232,15 @@ lalloc(size_t size, int message)
|
||||
mem_pre_alloc_l(&size);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Loop when out of memory: Try to release some memfile blocks and
|
||||
* if some blocks are released call malloc again.
|
||||
*/
|
||||
// Loop when out of memory: Try to release some memfile blocks and
|
||||
// if some blocks are released call malloc again.
|
||||
for (;;)
|
||||
{
|
||||
/*
|
||||
* Handle three kind of systems:
|
||||
* 1. No check for available memory: Just return.
|
||||
* 2. Slow check for available memory: call mch_avail_mem() after
|
||||
* allocating KEEP_ROOM amount of memory.
|
||||
* 3. Strict check for available memory: call mch_avail_mem()
|
||||
*/
|
||||
// Handle three kind of systems:
|
||||
// 1. No check for available memory: Just return.
|
||||
// 2. Slow check for available memory: call mch_avail_mem() after
|
||||
// allocating KEEP_ROOM amount of memory.
|
||||
// 3. Strict check for available memory: call mch_avail_mem()
|
||||
if ((p = malloc(size)) != NULL)
|
||||
{
|
||||
#ifndef HAVE_AVAIL_MEM
|
||||
@ -268,10 +264,8 @@ lalloc(size_t size, int message)
|
||||
goto theend;
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Remember that mf_release_all() is being called to avoid an endless
|
||||
* loop, because mf_release_all() may call alloc() recursively.
|
||||
*/
|
||||
// Remember that mf_release_all() is being called to avoid an endless
|
||||
// loop, because mf_release_all() may call alloc() recursively.
|
||||
if (releasing)
|
||||
break;
|
||||
releasing = TRUE;
|
||||
|
@ -3025,7 +3025,7 @@ channel_has_readahead(channel_T *channel, ch_part_T part)
|
||||
* Return a string indicating the status of the channel.
|
||||
* If "req_part" is not negative check that part.
|
||||
*/
|
||||
char *
|
||||
static char *
|
||||
channel_status(channel_T *channel, int req_part)
|
||||
{
|
||||
ch_part_T part;
|
||||
|
@ -805,7 +805,7 @@ dict2string(typval_T *tv, int copyID, int restore_copyID)
|
||||
* Advance over a literal key, including "-". If the first character is not a
|
||||
* literal key character then "key" is returned.
|
||||
*/
|
||||
char_u *
|
||||
static char_u *
|
||||
skip_literal_key(char_u *key)
|
||||
{
|
||||
char_u *p;
|
||||
|
@ -2029,7 +2029,7 @@ registerdigraph(int char1, int char2, int n)
|
||||
* If they are valid, returns TRUE; otherwise, give an error message and
|
||||
* returns FALSE.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
check_digraph_chars_valid(int char1, int char2)
|
||||
{
|
||||
if (char2 == 0)
|
||||
@ -2193,7 +2193,7 @@ digraph_getlist_appendpair(digr_T *dp, list_T *l)
|
||||
li2->li_tv.vval.v_string = vim_strsave(buf);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
digraph_getlist_common(int list_all, typval_T *rettv)
|
||||
{
|
||||
int i;
|
||||
|
@ -1587,7 +1587,7 @@ ins_ctrl_v(void)
|
||||
* Note that this doesn't wait for characters, they must be in the typeahead
|
||||
* buffer already.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
decodeModifyOtherKeys(int c)
|
||||
{
|
||||
char_u *p = typebuf.tb_buf + typebuf.tb_off;
|
||||
|
@ -598,7 +598,7 @@ do_cmdline_cmd(char_u *cmd)
|
||||
* Execute the "+cmd" argument of "edit +cmd fname" and the like.
|
||||
* This allows for using a range without ":" in Vim9 script.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
do_cmd_argument(char_u *cmd)
|
||||
{
|
||||
return do_cmdline(cmd, NULL, NULL,
|
||||
|
@ -631,7 +631,7 @@ stuffRedoReadbuff(char_u *s)
|
||||
add_buff(&readbuf2, s, -1L);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
stuffReadbuffLen(char_u *s, long len)
|
||||
{
|
||||
add_buff(&readbuf1, s, len);
|
||||
|
@ -1582,7 +1582,7 @@ invoke_prompt_interrupt(void)
|
||||
/*
|
||||
* Return the effective prompt for the specified buffer.
|
||||
*/
|
||||
char_u *
|
||||
static char_u *
|
||||
buf_prompt_text(buf_T* buf)
|
||||
{
|
||||
if (buf->b_prompt_text == NULL)
|
||||
|
@ -620,7 +620,7 @@ list_append_tv(list_T *l, typval_T *tv)
|
||||
* As list_append_tv() but move the value instead of copying it.
|
||||
* Return FAIL when out of memory.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
list_append_tv_move(list_T *l, typval_T *tv)
|
||||
{
|
||||
listitem_T *li = listitem_alloc();
|
||||
|
1110
src/message.c
1110
src/message.c
File diff suppressed because it is too large
Load Diff
@ -554,6 +554,24 @@ func_do_profile(ufunc_T *fp)
|
||||
fp->uf_profiling = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save time when starting to invoke another script or function.
|
||||
*/
|
||||
static void
|
||||
script_prof_save(
|
||||
proftime_T *tm) // place to store wait time
|
||||
{
|
||||
scriptitem_T *si;
|
||||
|
||||
if (SCRIPT_ID_VALID(current_sctx.sc_sid))
|
||||
{
|
||||
si = SCRIPT_ITEM(current_sctx.sc_sid);
|
||||
if (si->sn_prof_on && si->sn_pr_nest++ == 0)
|
||||
profile_start(&si->sn_pr_child);
|
||||
}
|
||||
profile_get_wait(tm);
|
||||
}
|
||||
|
||||
/*
|
||||
* When calling a function: may initialize for profiling.
|
||||
*/
|
||||
@ -792,24 +810,6 @@ script_do_profile(scriptitem_T *si)
|
||||
si->sn_pr_nest = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save time when starting to invoke another script or function.
|
||||
*/
|
||||
void
|
||||
script_prof_save(
|
||||
proftime_T *tm) // place to store wait time
|
||||
{
|
||||
scriptitem_T *si;
|
||||
|
||||
if (SCRIPT_ID_VALID(current_sctx.sc_sid))
|
||||
{
|
||||
si = SCRIPT_ITEM(current_sctx.sc_sid);
|
||||
if (si->sn_prof_on && si->sn_pr_nest++ == 0)
|
||||
profile_start(&si->sn_pr_child);
|
||||
}
|
||||
profile_get_wait(tm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Count time spent in children after invoking another script or function.
|
||||
*/
|
||||
|
@ -24,7 +24,6 @@ void channel_consume(channel_T *channel, ch_part_T part, int len);
|
||||
int channel_collapse(channel_T *channel, ch_part_T part, int want_nl);
|
||||
int channel_can_write_to(channel_T *channel);
|
||||
int channel_is_open(channel_T *channel);
|
||||
char *channel_status(channel_T *channel, int req_part);
|
||||
void channel_close(channel_T *channel, int invoke_close_cb);
|
||||
void channel_clear(channel_T *channel);
|
||||
void channel_free_all(void);
|
||||
|
@ -34,7 +34,6 @@ varnumber_T dict_get_number_def(dict_T *d, char_u *key, int def);
|
||||
varnumber_T dict_get_number_check(dict_T *d, char_u *key);
|
||||
varnumber_T dict_get_bool(dict_T *d, char_u *key, int def);
|
||||
char_u *dict2string(typval_T *tv, int copyID, int restore_copyID);
|
||||
char_u *skip_literal_key(char_u *key);
|
||||
char_u *get_literal_key(char_u **arg);
|
||||
int eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal);
|
||||
void dict_extend(dict_T *d1, dict_T *d2, char_u *action, char *func_name);
|
||||
|
@ -3,10 +3,8 @@ int do_digraph(int c);
|
||||
char_u *get_digraph_for_char(int val_arg);
|
||||
int get_digraph(int cmdline);
|
||||
int digraph_get(int char1, int char2, int meta_char);
|
||||
int check_digraph_chars_valid(int char1, int char2);
|
||||
void putdigraph(char_u *str);
|
||||
void listdigraphs(int use_headers);
|
||||
void digraph_getlist_common(int list_all, typval_T *rettv);
|
||||
void f_digraph_get(typval_T *argvars, typval_T *rettv);
|
||||
void f_digraph_getlist(typval_T *argvars, typval_T *rettv);
|
||||
void f_digraph_set(typval_T *argvars, typval_T *rettv);
|
||||
|
@ -2,7 +2,6 @@
|
||||
int edit(int cmdchar, int startln, long count);
|
||||
int ins_need_undo_get(void);
|
||||
void ins_redraw(int ready);
|
||||
int decodeModifyOtherKeys(int c);
|
||||
void edit_putchar(int c, int highlight);
|
||||
void set_insstart(linenr_T lnum, int col);
|
||||
void edit_unputchar(void);
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* ex_docmd.c */
|
||||
void do_exmode(int improved);
|
||||
int do_cmdline_cmd(char_u *cmd);
|
||||
int do_cmd_argument(char_u *cmd);
|
||||
int do_cmdline(char_u *cmdline, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie, int flags);
|
||||
void handle_did_throw(void);
|
||||
int getline_equal(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie, char_u *(*func)(int, void *, int, getline_opt_T));
|
||||
|
@ -15,7 +15,6 @@ void AppendCharToRedobuff(int c);
|
||||
void AppendNumberToRedobuff(long n);
|
||||
void stuffReadbuff(char_u *s);
|
||||
void stuffRedoReadbuff(char_u *s);
|
||||
void stuffReadbuffLen(char_u *s, long len);
|
||||
void stuffReadbuffSpec(char_u *s);
|
||||
void stuffcharReadbuff(int c);
|
||||
void stuffnumReadbuff(long n);
|
||||
|
@ -20,7 +20,6 @@ char *job_status(job_T *job);
|
||||
int job_stop(job_T *job, typval_T *argvars, char *type);
|
||||
void invoke_prompt_callback(void);
|
||||
int invoke_prompt_interrupt(void);
|
||||
char_u *buf_prompt_text(buf_T *buf);
|
||||
char_u *prompt_text(void);
|
||||
void init_prompt(int cmdchar_todo);
|
||||
int prompt_curpos_editable(void);
|
||||
|
@ -24,7 +24,6 @@ listitem_T *list_find_index(list_T *l, long *idx);
|
||||
long list_idx_of_item(list_T *l, listitem_T *item);
|
||||
void list_append(list_T *l, listitem_T *item);
|
||||
int list_append_tv(list_T *l, typval_T *tv);
|
||||
int list_append_tv_move(list_T *l, typval_T *tv);
|
||||
int list_append_dict(list_T *list, dict_T *dict);
|
||||
int list_append_list(list_T *list1, list_T *list2);
|
||||
int list_append_string(list_T *l, char_u *str, int len);
|
||||
|
@ -27,7 +27,6 @@ void func_line_start(void *cookie, long lnum);
|
||||
void func_line_exec(void *cookie);
|
||||
void func_line_end(void *cookie);
|
||||
void script_do_profile(scriptitem_T *si);
|
||||
void script_prof_save(proftime_T *tm);
|
||||
void script_prof_restore(proftime_T *tm);
|
||||
void profile_dump(void);
|
||||
void script_line_start(void);
|
||||
|
@ -5,7 +5,6 @@ int can_compound(slang_T *slang, char_u *word, char_u *flags);
|
||||
int match_compoundrule(slang_T *slang, char_u *compflags);
|
||||
int valid_word_prefix(int totprefcnt, int arridx, int flags, char_u *word, slang_T *slang, int cond_req);
|
||||
int spell_valid_case(int wordflags, int treeflags);
|
||||
int no_spell_checking(win_T *wp);
|
||||
int spell_move_to(win_T *wp, int dir, int allwords, int curline, hlf_T *attrp);
|
||||
void spell_cat_line(char_u *buf, char_u *line, int maxlen);
|
||||
char_u *spell_enc(void);
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* vim9compile.c */
|
||||
int check_defined(char_u *p, size_t len, cctx_T *cctx, int is_arg);
|
||||
int check_compare_types(exprtype_T type, typval_T *tv1, typval_T *tv2);
|
||||
int use_typecheck(type_T *actual, type_T *expected);
|
||||
int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T *cctx, int silent, int actual_is_const);
|
||||
int func_needs_compiling(ufunc_T *ufunc, compiletype_T compile_type);
|
||||
int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx);
|
||||
@ -9,7 +8,6 @@ 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 *peek_next_line_from_context(cctx_T *cctx);
|
||||
char_u *next_line_from_context(cctx_T *cctx, int skip_comment);
|
||||
char_u *to_name_end(char_u *arg, int use_namespace);
|
||||
char_u *to_name_const_end(char_u *arg);
|
||||
int get_lambda_tv_and_compile(char_u **arg, typval_T *rettv, int types_optional, evalarg_T *evalarg);
|
||||
exprtype_T get_compare_type(char_u *p, int *len, int *type_is);
|
||||
|
@ -11,11 +11,9 @@ void free_imports_and_script_vars(int sid);
|
||||
void mark_imports_for_reload(int sid);
|
||||
void ex_import(exarg_T *eap);
|
||||
int find_exported(int sid, char_u *name, ufunc_T **ufunc, type_T **type, cctx_T *cctx, int verbose);
|
||||
char_u *handle_import(char_u *arg_start, garray_T *gap, int import_sid, evalarg_T *evalarg, void *cctx);
|
||||
char_u *vim9_declare_scriptvar(exarg_T *eap, char_u *arg);
|
||||
void update_vim9_script_var(int create, dictitem_T *di, int flags, typval_T *tv, type_T **type, int do_member);
|
||||
void hide_script_var(scriptitem_T *si, int idx, int func_defined);
|
||||
void free_all_script_vars(scriptitem_T *si);
|
||||
svar_T *find_typval_in_script(typval_T *dest);
|
||||
int check_script_var_type(typval_T *dest, typval_T *value, char_u *name, where_T where);
|
||||
int check_reserved_name(char_u *name);
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* vim9type.c */
|
||||
type_T *get_type_ptr(garray_T *type_gap);
|
||||
void clear_type_list(garray_T *gap);
|
||||
type_T *alloc_type(type_T *type);
|
||||
void free_type(type_T *type);
|
||||
|
@ -1240,7 +1240,7 @@ spell_valid_case(
|
||||
/*
|
||||
* Return TRUE if spell checking is not enabled.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
no_spell_checking(win_T *wp)
|
||||
{
|
||||
if (!wp->w_p_spell || *wp->w_s->b_p_spl == NUL
|
||||
|
1122
src/strings.c
1122
src/strings.c
File diff suppressed because it is too large
Load Diff
@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3320,
|
||||
/**/
|
||||
3319,
|
||||
/**/
|
||||
|
@ -1012,7 +1012,7 @@ generate_SETTYPE(
|
||||
* Return TRUE if "actual" could be "expected" and a runtime typecheck is to be
|
||||
* used. Return FALSE if the types will never match.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
use_typecheck(type_T *actual, type_T *expected)
|
||||
{
|
||||
if (actual->tt_type == VAR_ANY
|
||||
@ -3579,7 +3579,7 @@ theend:
|
||||
* Return a pointer to just after the name. Equal to "arg" if there is no
|
||||
* valid name.
|
||||
*/
|
||||
char_u *
|
||||
static char_u *
|
||||
to_name_end(char_u *arg, int use_namespace)
|
||||
{
|
||||
char_u *p;
|
||||
|
292
src/vim9script.c
292
src/vim9script.c
@ -245,6 +245,48 @@ new_imported(garray_T *gap)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the script variables from "sn_all_vars".
|
||||
*/
|
||||
static void
|
||||
free_all_script_vars(scriptitem_T *si)
|
||||
{
|
||||
int todo;
|
||||
hashtab_T *ht = &si->sn_all_vars.dv_hashtab;
|
||||
hashitem_T *hi;
|
||||
sallvar_T *sav;
|
||||
sallvar_T *sav_next;
|
||||
|
||||
hash_lock(ht);
|
||||
todo = (int)ht->ht_used;
|
||||
for (hi = ht->ht_array; todo > 0; ++hi)
|
||||
{
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
{
|
||||
--todo;
|
||||
|
||||
// Free the variable. Don't remove it from the hashtab, ht_array
|
||||
// might change then. hash_clear() takes care of it later.
|
||||
sav = HI2SAV(hi);
|
||||
while (sav != NULL)
|
||||
{
|
||||
sav_next = sav->sav_next;
|
||||
if (sav->sav_di == NULL)
|
||||
clear_tv(&sav->sav_tv);
|
||||
vim_free(sav);
|
||||
sav = sav_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
hash_clear(ht);
|
||||
hash_init(ht);
|
||||
|
||||
ga_clear(&si->sn_var_vals);
|
||||
|
||||
// existing commands using script variable indexes are no longer valid
|
||||
si->sn_script_seq = current_sctx.sc_seq;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free all imported items in script "sid".
|
||||
*/
|
||||
@ -285,116 +327,13 @@ mark_imports_for_reload(int sid)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ":import Item from 'filename'"
|
||||
* ":import Item as Alias from 'filename'"
|
||||
* ":import {Item} from 'filename'".
|
||||
* ":import {Item as Alias} from 'filename'"
|
||||
* ":import {Item, Item} from 'filename'"
|
||||
* ":import {Item, Item as Alias} from 'filename'"
|
||||
*
|
||||
* ":import * as Name from 'filename'"
|
||||
*/
|
||||
void
|
||||
ex_import(exarg_T *eap)
|
||||
{
|
||||
char_u *cmd_end;
|
||||
evalarg_T evalarg;
|
||||
|
||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
|
||||
{
|
||||
emsg(_(e_import_can_only_be_used_in_script));
|
||||
return;
|
||||
}
|
||||
fill_evalarg_from_eap(&evalarg, eap, eap->skip);
|
||||
|
||||
cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid,
|
||||
&evalarg, NULL);
|
||||
if (cmd_end != NULL)
|
||||
set_nextcmd(eap, cmd_end);
|
||||
clear_evalarg(&evalarg, eap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find an exported item in "sid" matching the name at "*argp".
|
||||
* When it is a variable return the index.
|
||||
* When it is a user function return "*ufunc".
|
||||
* When not found returns -1 and "*ufunc" is NULL.
|
||||
*/
|
||||
int
|
||||
find_exported(
|
||||
int sid,
|
||||
char_u *name,
|
||||
ufunc_T **ufunc,
|
||||
type_T **type,
|
||||
cctx_T *cctx,
|
||||
int verbose)
|
||||
{
|
||||
int idx = -1;
|
||||
svar_T *sv;
|
||||
scriptitem_T *script = SCRIPT_ITEM(sid);
|
||||
|
||||
// Find name in "script".
|
||||
idx = get_script_item_idx(sid, name, 0, cctx);
|
||||
if (idx >= 0)
|
||||
{
|
||||
sv = ((svar_T *)script->sn_var_vals.ga_data) + idx;
|
||||
if (!sv->sv_export)
|
||||
{
|
||||
if (verbose)
|
||||
semsg(_(e_item_not_exported_in_script_str), name);
|
||||
return -1;
|
||||
}
|
||||
*type = sv->sv_type;
|
||||
*ufunc = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
char_u buffer[200];
|
||||
char_u *funcname;
|
||||
|
||||
// it could be a user function.
|
||||
if (STRLEN(name) < sizeof(buffer) - 15)
|
||||
funcname = buffer;
|
||||
else
|
||||
{
|
||||
funcname = alloc(STRLEN(name) + 15);
|
||||
if (funcname == NULL)
|
||||
return -1;
|
||||
}
|
||||
funcname[0] = K_SPECIAL;
|
||||
funcname[1] = KS_EXTRA;
|
||||
funcname[2] = (int)KE_SNR;
|
||||
sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
|
||||
*ufunc = find_func(funcname, FALSE, NULL);
|
||||
if (funcname != buffer)
|
||||
vim_free(funcname);
|
||||
|
||||
if (*ufunc == NULL)
|
||||
{
|
||||
if (verbose)
|
||||
semsg(_(e_item_not_found_in_script_str), name);
|
||||
return -1;
|
||||
}
|
||||
else if (((*ufunc)->uf_flags & FC_EXPORT) == 0)
|
||||
{
|
||||
if (verbose)
|
||||
semsg(_(e_item_not_exported_in_script_str), name);
|
||||
*ufunc = NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle an ":import" command and add the resulting imported_T to "gap", when
|
||||
* not NULL, or script "import_sid" sn_imports.
|
||||
* "cctx" is NULL at the script level.
|
||||
* Returns a pointer to after the command or NULL in case of failure
|
||||
*/
|
||||
char_u *
|
||||
static char_u *
|
||||
handle_import(
|
||||
char_u *arg_start,
|
||||
garray_T *gap,
|
||||
@ -675,6 +614,109 @@ erret:
|
||||
return cmd_end;
|
||||
}
|
||||
|
||||
/*
|
||||
* ":import Item from 'filename'"
|
||||
* ":import Item as Alias from 'filename'"
|
||||
* ":import {Item} from 'filename'".
|
||||
* ":import {Item as Alias} from 'filename'"
|
||||
* ":import {Item, Item} from 'filename'"
|
||||
* ":import {Item, Item as Alias} from 'filename'"
|
||||
*
|
||||
* ":import * as Name from 'filename'"
|
||||
*/
|
||||
void
|
||||
ex_import(exarg_T *eap)
|
||||
{
|
||||
char_u *cmd_end;
|
||||
evalarg_T evalarg;
|
||||
|
||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
|
||||
{
|
||||
emsg(_(e_import_can_only_be_used_in_script));
|
||||
return;
|
||||
}
|
||||
fill_evalarg_from_eap(&evalarg, eap, eap->skip);
|
||||
|
||||
cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid,
|
||||
&evalarg, NULL);
|
||||
if (cmd_end != NULL)
|
||||
set_nextcmd(eap, cmd_end);
|
||||
clear_evalarg(&evalarg, eap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find an exported item in "sid" matching the name at "*argp".
|
||||
* When it is a variable return the index.
|
||||
* When it is a user function return "*ufunc".
|
||||
* When not found returns -1 and "*ufunc" is NULL.
|
||||
*/
|
||||
int
|
||||
find_exported(
|
||||
int sid,
|
||||
char_u *name,
|
||||
ufunc_T **ufunc,
|
||||
type_T **type,
|
||||
cctx_T *cctx,
|
||||
int verbose)
|
||||
{
|
||||
int idx = -1;
|
||||
svar_T *sv;
|
||||
scriptitem_T *script = SCRIPT_ITEM(sid);
|
||||
|
||||
// Find name in "script".
|
||||
idx = get_script_item_idx(sid, name, 0, cctx);
|
||||
if (idx >= 0)
|
||||
{
|
||||
sv = ((svar_T *)script->sn_var_vals.ga_data) + idx;
|
||||
if (!sv->sv_export)
|
||||
{
|
||||
if (verbose)
|
||||
semsg(_(e_item_not_exported_in_script_str), name);
|
||||
return -1;
|
||||
}
|
||||
*type = sv->sv_type;
|
||||
*ufunc = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
char_u buffer[200];
|
||||
char_u *funcname;
|
||||
|
||||
// it could be a user function.
|
||||
if (STRLEN(name) < sizeof(buffer) - 15)
|
||||
funcname = buffer;
|
||||
else
|
||||
{
|
||||
funcname = alloc(STRLEN(name) + 15);
|
||||
if (funcname == NULL)
|
||||
return -1;
|
||||
}
|
||||
funcname[0] = K_SPECIAL;
|
||||
funcname[1] = KS_EXTRA;
|
||||
funcname[2] = (int)KE_SNR;
|
||||
sprintf((char *)funcname + 3, "%ld_%s", (long)sid, name);
|
||||
*ufunc = find_func(funcname, FALSE, NULL);
|
||||
if (funcname != buffer)
|
||||
vim_free(funcname);
|
||||
|
||||
if (*ufunc == NULL)
|
||||
{
|
||||
if (verbose)
|
||||
semsg(_(e_item_not_found_in_script_str), name);
|
||||
return -1;
|
||||
}
|
||||
else if (((*ufunc)->uf_flags & FC_EXPORT) == 0)
|
||||
{
|
||||
if (verbose)
|
||||
semsg(_(e_item_not_exported_in_script_str), name);
|
||||
*ufunc = NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Declare a script-local variable without init: "let var: type".
|
||||
* "const" is an error since the value is missing.
|
||||
@ -903,48 +945,6 @@ hide_script_var(scriptitem_T *si, int idx, int func_defined)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the script variables from "sn_all_vars".
|
||||
*/
|
||||
void
|
||||
free_all_script_vars(scriptitem_T *si)
|
||||
{
|
||||
int todo;
|
||||
hashtab_T *ht = &si->sn_all_vars.dv_hashtab;
|
||||
hashitem_T *hi;
|
||||
sallvar_T *sav;
|
||||
sallvar_T *sav_next;
|
||||
|
||||
hash_lock(ht);
|
||||
todo = (int)ht->ht_used;
|
||||
for (hi = ht->ht_array; todo > 0; ++hi)
|
||||
{
|
||||
if (!HASHITEM_EMPTY(hi))
|
||||
{
|
||||
--todo;
|
||||
|
||||
// Free the variable. Don't remove it from the hashtab, ht_array
|
||||
// might change then. hash_clear() takes care of it later.
|
||||
sav = HI2SAV(hi);
|
||||
while (sav != NULL)
|
||||
{
|
||||
sav_next = sav->sav_next;
|
||||
if (sav->sav_di == NULL)
|
||||
clear_tv(&sav->sav_tv);
|
||||
vim_free(sav);
|
||||
sav = sav_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
hash_clear(ht);
|
||||
hash_init(ht);
|
||||
|
||||
ga_clear(&si->sn_var_vals);
|
||||
|
||||
// existing commands using script variable indexes are no longer valid
|
||||
si->sn_script_seq = current_sctx.sc_seq;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the script-local variable that links to "dest".
|
||||
* Returns NULL if not found and give an internal error.
|
||||
|
@ -24,7 +24,7 @@
|
||||
* Allocate memory for a type_T and add the pointer to type_gap, so that it can
|
||||
* be easily freed later.
|
||||
*/
|
||||
type_T *
|
||||
static type_T *
|
||||
get_type_ptr(garray_T *type_gap)
|
||||
{
|
||||
type_T *type;
|
||||
|
@ -4475,7 +4475,7 @@ win_goto(win_T *wp)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(FEAT_PERL) || defined(FEAT_LUA) || defined(PROTO)
|
||||
#if defined(FEAT_PERL) || defined(PROTO)
|
||||
/*
|
||||
* Find window number "winnr" (counting top to bottom).
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user