mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.1124: Vim9: no line break allowed in :import command
Problem: Vim9: no line break allowed in :import command. Solution: Skip over line breaks.
This commit is contained in:
parent
effb0cd75d
commit
1c991144c5
@ -4,8 +4,8 @@ void ex_vim9script(exarg_T *eap);
|
|||||||
void ex_export(exarg_T *eap);
|
void ex_export(exarg_T *eap);
|
||||||
void free_imports(int sid);
|
void free_imports(int sid);
|
||||||
void ex_import(exarg_T *eap);
|
void ex_import(exarg_T *eap);
|
||||||
int find_exported(int sid, char_u **argp, int *name_len, ufunc_T **ufunc, type_T **type);
|
int find_exported(int sid, char_u *name, ufunc_T **ufunc, type_T **type);
|
||||||
char_u *handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx);
|
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);
|
char_u *vim9_declare_scriptvar(exarg_T *eap, char_u *arg);
|
||||||
int check_script_var_type(typval_T *dest, typval_T *value, char_u *name);
|
int check_script_var_type(typval_T *dest, typval_T *value, char_u *name);
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@ -686,6 +686,35 @@ def Test_vim9_import_export()
|
|||||||
unlet g:imported_name g:imported_name_appended
|
unlet g:imported_name g:imported_name_appended
|
||||||
delete('Ximport.vim')
|
delete('Ximport.vim')
|
||||||
|
|
||||||
|
# similar, with line breaks
|
||||||
|
let import_line_break_script_lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import {
|
||||||
|
exported,
|
||||||
|
Exported,
|
||||||
|
}
|
||||||
|
from
|
||||||
|
'./Xexport.vim'
|
||||||
|
g:imported = exported
|
||||||
|
exported += 5
|
||||||
|
g:imported_added = exported
|
||||||
|
g:imported_func = Exported()
|
||||||
|
END
|
||||||
|
writefile(import_line_break_script_lines, 'Ximport_lbr.vim')
|
||||||
|
source Ximport_lbr.vim
|
||||||
|
|
||||||
|
assert_equal(9876, g:imported)
|
||||||
|
assert_equal(9881, g:imported_added)
|
||||||
|
assert_equal('Exported', g:imported_func)
|
||||||
|
|
||||||
|
# exported script not sourced again
|
||||||
|
assert_false(exists('g:result'))
|
||||||
|
unlet g:imported
|
||||||
|
unlet g:imported_added
|
||||||
|
unlet g:imported_func
|
||||||
|
delete('Ximport_lbr.vim')
|
||||||
|
|
||||||
|
# import inside :def function
|
||||||
let import_in_def_lines =<< trim END
|
let import_in_def_lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
def ImportInDef()
|
def ImportInDef()
|
||||||
@ -751,6 +780,21 @@ def Test_vim9_import_export()
|
|||||||
writefile(import_star_as_lines_missing_name, 'Ximport.vim')
|
writefile(import_star_as_lines_missing_name, 'Ximport.vim')
|
||||||
assert_fails('source Ximport.vim', 'E1048:')
|
assert_fails('source Ximport.vim', 'E1048:')
|
||||||
|
|
||||||
|
let import_star_as_lbr_lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
import *
|
||||||
|
as Export
|
||||||
|
from
|
||||||
|
'./Xexport.vim'
|
||||||
|
def UseExport()
|
||||||
|
g:imported = Export.exported
|
||||||
|
enddef
|
||||||
|
UseExport()
|
||||||
|
END
|
||||||
|
writefile(import_star_as_lbr_lines, 'Ximport.vim')
|
||||||
|
source Ximport.vim
|
||||||
|
assert_equal(9883, g:imported)
|
||||||
|
|
||||||
let import_star_lines =<< trim END
|
let import_star_lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
import * from './Xexport.vim'
|
import * from './Xexport.vim'
|
||||||
|
@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1124,
|
||||||
/**/
|
/**/
|
||||||
1123,
|
1123,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2613,7 +2613,8 @@ compile_load_scriptvar(
|
|||||||
if (import->imp_all)
|
if (import->imp_all)
|
||||||
{
|
{
|
||||||
char_u *p = skipwhite(*end);
|
char_u *p = skipwhite(*end);
|
||||||
int name_len;
|
char_u *exp_name;
|
||||||
|
int cc;
|
||||||
ufunc_T *ufunc;
|
ufunc_T *ufunc;
|
||||||
type_T *type;
|
type_T *type;
|
||||||
|
|
||||||
@ -2630,7 +2631,17 @@ compile_load_scriptvar(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = find_exported(import->imp_sid, &p, &name_len, &ufunc, &type);
|
// isolate one name
|
||||||
|
exp_name = p;
|
||||||
|
while (eval_isnamec(*p))
|
||||||
|
++p;
|
||||||
|
cc = *p;
|
||||||
|
*p = NUL;
|
||||||
|
|
||||||
|
idx = find_exported(import->imp_sid, exp_name, &ufunc, &type);
|
||||||
|
*p = cc;
|
||||||
|
p = skipwhite(p);
|
||||||
|
|
||||||
// TODO: what if it is a function?
|
// TODO: what if it is a function?
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2981,6 +2992,7 @@ to_name_end(char_u *arg, int namespace)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Like to_name_end() but also skip over a list or dict constant.
|
* Like to_name_end() but also skip over a list or dict constant.
|
||||||
|
* This intentionally does not handle line continuation.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
to_name_const_end(char_u *arg)
|
to_name_const_end(char_u *arg)
|
||||||
@ -5632,7 +5644,7 @@ compile_unletlock(char_u *arg, exarg_T *eap, cctx_T *cctx)
|
|||||||
static char_u *
|
static char_u *
|
||||||
compile_import(char_u *arg, cctx_T *cctx)
|
compile_import(char_u *arg, cctx_T *cctx)
|
||||||
{
|
{
|
||||||
return handle_import(arg, &cctx->ctx_imports, 0, cctx);
|
return handle_import(arg, &cctx->ctx_imports, 0, NULL, cctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
196
src/vim9script.c
196
src/vim9script.c
@ -143,16 +143,20 @@ free_imports(int sid)
|
|||||||
ex_import(exarg_T *eap)
|
ex_import(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *cmd_end;
|
char_u *cmd_end;
|
||||||
|
evalarg_T evalarg;
|
||||||
|
|
||||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
|
if (!getline_equal(eap->getline, eap->cookie, getsourceline))
|
||||||
{
|
{
|
||||||
emsg(_("E1094: import can only be used in a script"));
|
emsg(_("E1094: import can only be used in a script"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
fill_evalarg_from_eap(&evalarg, eap, eap->skip);
|
||||||
|
|
||||||
cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid, NULL);
|
cmd_end = handle_import(eap->arg, NULL, current_sctx.sc_sid,
|
||||||
|
&evalarg, NULL);
|
||||||
if (cmd_end != NULL)
|
if (cmd_end != NULL)
|
||||||
eap->nextcmd = check_nextcmd(cmd_end);
|
eap->nextcmd = check_nextcmd(cmd_end);
|
||||||
|
clear_evalarg(&evalarg, eap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -164,27 +168,16 @@ ex_import(exarg_T *eap)
|
|||||||
int
|
int
|
||||||
find_exported(
|
find_exported(
|
||||||
int sid,
|
int sid,
|
||||||
char_u **argp,
|
char_u *name,
|
||||||
int *name_len,
|
|
||||||
ufunc_T **ufunc,
|
ufunc_T **ufunc,
|
||||||
type_T **type)
|
type_T **type)
|
||||||
{
|
{
|
||||||
char_u *name = *argp;
|
|
||||||
char_u *arg = *argp;
|
|
||||||
int cc;
|
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
svar_T *sv;
|
svar_T *sv;
|
||||||
scriptitem_T *script = SCRIPT_ITEM(sid);
|
scriptitem_T *script = SCRIPT_ITEM(sid);
|
||||||
|
|
||||||
// isolate one name
|
|
||||||
while (eval_isnamec(*arg))
|
|
||||||
++arg;
|
|
||||||
*name_len = (int)(arg - name);
|
|
||||||
|
|
||||||
// find name in "script"
|
// find name in "script"
|
||||||
// TODO: also find script-local user function
|
// TODO: also find script-local user function
|
||||||
cc = *arg;
|
|
||||||
*arg = NUL;
|
|
||||||
idx = get_script_item_idx(sid, name, FALSE);
|
idx = get_script_item_idx(sid, name, FALSE);
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
{
|
{
|
||||||
@ -192,7 +185,6 @@ find_exported(
|
|||||||
if (!sv->sv_export)
|
if (!sv->sv_export)
|
||||||
{
|
{
|
||||||
semsg(_("E1049: Item not exported in script: %s"), name);
|
semsg(_("E1049: Item not exported in script: %s"), name);
|
||||||
*arg = cc;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*type = sv->sv_type;
|
*type = sv->sv_type;
|
||||||
@ -210,11 +202,8 @@ find_exported(
|
|||||||
{
|
{
|
||||||
funcname = alloc(STRLEN(name) + 10);
|
funcname = alloc(STRLEN(name) + 10);
|
||||||
if (funcname == NULL)
|
if (funcname == NULL)
|
||||||
{
|
|
||||||
*arg = cc;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
funcname[0] = K_SPECIAL;
|
funcname[0] = K_SPECIAL;
|
||||||
funcname[1] = KS_EXTRA;
|
funcname[1] = KS_EXTRA;
|
||||||
funcname[2] = (int)KE_SNR;
|
funcname[2] = (int)KE_SNR;
|
||||||
@ -226,13 +215,9 @@ find_exported(
|
|||||||
if (*ufunc == NULL)
|
if (*ufunc == NULL)
|
||||||
{
|
{
|
||||||
semsg(_("E1048: Item not found in script: %s"), name);
|
semsg(_("E1048: Item not found in script: %s"), name);
|
||||||
*arg = cc;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*arg = cc;
|
|
||||||
arg = skipwhite(arg);
|
|
||||||
*argp = arg;
|
|
||||||
|
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
@ -243,62 +228,121 @@ find_exported(
|
|||||||
* Returns a pointer to after the command or NULL in case of failure
|
* Returns a pointer to after the command or NULL in case of failure
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
handle_import(
|
||||||
|
char_u *arg_start,
|
||||||
|
garray_T *gap,
|
||||||
|
int import_sid,
|
||||||
|
evalarg_T *evalarg,
|
||||||
|
void *cctx)
|
||||||
{
|
{
|
||||||
char_u *arg = arg_start;
|
char_u *arg = arg_start;
|
||||||
char_u *cmd_end;
|
char_u *cmd_end = NULL;
|
||||||
char_u *as_ptr = NULL;
|
char_u *as_name = NULL;
|
||||||
char_u *from_ptr;
|
|
||||||
int as_len = 0;
|
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
typval_T tv;
|
typval_T tv;
|
||||||
int sid = -1;
|
int sid = -1;
|
||||||
int res;
|
int res;
|
||||||
|
garray_T names;
|
||||||
|
static char e_import_syntax[] = N_("E1047: syntax error in import");
|
||||||
|
|
||||||
|
ga_init2(&names, sizeof(char_u *), 10);
|
||||||
if (*arg == '{')
|
if (*arg == '{')
|
||||||
{
|
{
|
||||||
// skip over {item} list
|
// "import {item, item} from ..."
|
||||||
while (*arg != NUL && *arg != '}')
|
arg = skipwhite_and_linebreak(arg + 1, evalarg);
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
char_u *p = arg;
|
||||||
|
int had_comma = FALSE;
|
||||||
|
|
||||||
|
while (eval_isnamec(*arg))
|
||||||
++arg;
|
++arg;
|
||||||
|
if (p == arg)
|
||||||
|
break;
|
||||||
|
if (ga_grow(&names, 1) == FAIL)
|
||||||
|
goto erret;
|
||||||
|
((char_u **)names.ga_data)[names.ga_len] =
|
||||||
|
vim_strnsave(p, arg - p);
|
||||||
|
++names.ga_len;
|
||||||
|
if (*arg == ',')
|
||||||
|
{
|
||||||
|
had_comma = TRUE;
|
||||||
|
++arg;
|
||||||
|
}
|
||||||
|
arg = skipwhite_and_linebreak(arg, evalarg);
|
||||||
if (*arg == '}')
|
if (*arg == '}')
|
||||||
arg = skipwhite(arg + 1);
|
{
|
||||||
|
arg = skipwhite_and_linebreak(arg + 1, evalarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!had_comma)
|
||||||
|
{
|
||||||
|
emsg(_("E1046: Missing comma in import"));
|
||||||
|
goto erret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (names.ga_len == 0)
|
||||||
|
{
|
||||||
|
emsg(_(e_import_syntax));
|
||||||
|
goto erret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (*arg == '*')
|
// "import Name from ..."
|
||||||
arg = skipwhite(arg + 1);
|
// "import * as Name from ..."
|
||||||
|
// "import item [as Name] from ..."
|
||||||
|
arg = skipwhite_and_linebreak(arg, evalarg);
|
||||||
|
if (arg[0] == '*' && IS_WHITE_OR_NUL(arg[1]))
|
||||||
|
arg = skipwhite_and_linebreak(arg + 1, evalarg);
|
||||||
else if (eval_isnamec1(*arg))
|
else if (eval_isnamec1(*arg))
|
||||||
{
|
{
|
||||||
|
char_u *p = arg;
|
||||||
|
|
||||||
while (eval_isnamec(*arg))
|
while (eval_isnamec(*arg))
|
||||||
++arg;
|
++arg;
|
||||||
arg = skipwhite(arg);
|
if (ga_grow(&names, 1) == FAIL)
|
||||||
|
goto erret;
|
||||||
|
((char_u **)names.ga_data)[names.ga_len] =
|
||||||
|
vim_strnsave(p, arg - p);
|
||||||
|
++names.ga_len;
|
||||||
|
arg = skipwhite_and_linebreak(arg, evalarg);
|
||||||
}
|
}
|
||||||
if (STRNCMP("as", arg, 2) == 0 && VIM_ISWHITE(arg[2]))
|
else
|
||||||
{
|
{
|
||||||
// skip over "as Name "
|
emsg(_(e_import_syntax));
|
||||||
|
goto erret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (STRNCMP("as", arg, 2) == 0 && IS_WHITE_OR_NUL(arg[2]))
|
||||||
|
{
|
||||||
|
char_u *p;
|
||||||
|
|
||||||
|
// skip over "as Name "; no line break allowed after "as"
|
||||||
arg = skipwhite(arg + 2);
|
arg = skipwhite(arg + 2);
|
||||||
as_ptr = arg;
|
p = arg;
|
||||||
if (eval_isnamec1(*arg))
|
if (eval_isnamec1(*arg))
|
||||||
while (eval_isnamec(*arg))
|
while (eval_isnamec(*arg))
|
||||||
++arg;
|
++arg;
|
||||||
as_len = (int)(arg - as_ptr);
|
if (check_defined(p, (int)(arg - p), cctx) == FAIL)
|
||||||
arg = skipwhite(arg);
|
goto erret;
|
||||||
if (check_defined(as_ptr, as_len, cctx) == FAIL)
|
as_name = vim_strnsave(p, arg - p);
|
||||||
return NULL;
|
arg = skipwhite_and_linebreak(arg, evalarg);
|
||||||
}
|
}
|
||||||
else if (*arg_start == '*')
|
else if (*arg_start == '*')
|
||||||
{
|
{
|
||||||
emsg(_("E1045: Missing \"as\" after *"));
|
emsg(_("E1045: Missing \"as\" after *"));
|
||||||
return NULL;
|
goto erret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (STRNCMP("from", arg, 4) != 0 || !VIM_ISWHITE(arg[4]))
|
|
||||||
|
if (STRNCMP("from", arg, 4) != 0 || !IS_WHITE_OR_NUL(arg[4]))
|
||||||
{
|
{
|
||||||
emsg(_("E1070: Missing \"from\""));
|
emsg(_("E1070: Missing \"from\""));
|
||||||
return NULL;
|
goto erret;
|
||||||
}
|
}
|
||||||
from_ptr = arg;
|
|
||||||
arg = skipwhite(arg + 4);
|
arg = skipwhite_and_linebreak_keep_string(arg + 4, evalarg);
|
||||||
tv.v_type = VAR_UNKNOWN;
|
tv.v_type = VAR_UNKNOWN;
|
||||||
// TODO: should we accept any expression?
|
// TODO: should we accept any expression?
|
||||||
if (*arg == '\'')
|
if (*arg == '\'')
|
||||||
@ -308,11 +352,13 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
|||||||
if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL)
|
if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL)
|
||||||
{
|
{
|
||||||
emsg(_("E1071: Invalid string after \"from\""));
|
emsg(_("E1071: Invalid string after \"from\""));
|
||||||
return NULL;
|
goto erret;
|
||||||
}
|
}
|
||||||
cmd_end = arg;
|
cmd_end = arg;
|
||||||
|
|
||||||
// find script tv.vval.v_string
|
/*
|
||||||
|
* find script file
|
||||||
|
*/
|
||||||
if (*tv.vval.v_string == '.')
|
if (*tv.vval.v_string == '.')
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -326,7 +372,7 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
|||||||
if (from_name == NULL)
|
if (from_name == NULL)
|
||||||
{
|
{
|
||||||
clear_tv(&tv);
|
clear_tv(&tv);
|
||||||
return NULL;
|
goto erret;
|
||||||
}
|
}
|
||||||
vim_strncpy(from_name, si->sn_name, tail - si->sn_name);
|
vim_strncpy(from_name, si->sn_name, tail - si->sn_name);
|
||||||
add_pathsep(from_name);
|
add_pathsep(from_name);
|
||||||
@ -351,7 +397,7 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
|||||||
if (from_name == NULL)
|
if (from_name == NULL)
|
||||||
{
|
{
|
||||||
clear_tv(&tv);
|
clear_tv(&tv);
|
||||||
return NULL;
|
goto erret;
|
||||||
}
|
}
|
||||||
vim_snprintf((char *)from_name, len, "import/%s", tv.vval.v_string);
|
vim_snprintf((char *)from_name, len, "import/%s", tv.vval.v_string);
|
||||||
res = source_in_path(p_rtp, from_name, DIP_NOAFTER, &sid);
|
res = source_in_path(p_rtp, from_name, DIP_NOAFTER, &sid);
|
||||||
@ -362,7 +408,7 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
|||||||
{
|
{
|
||||||
semsg(_("E1053: Could not import \"%s\""), tv.vval.v_string);
|
semsg(_("E1053: Could not import \"%s\""), tv.vval.v_string);
|
||||||
clear_tv(&tv);
|
clear_tv(&tv);
|
||||||
return NULL;
|
goto erret;
|
||||||
}
|
}
|
||||||
clear_tv(&tv);
|
clear_tv(&tv);
|
||||||
|
|
||||||
@ -372,41 +418,44 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
|||||||
: &SCRIPT_ITEM(import_sid)->sn_imports);
|
: &SCRIPT_ITEM(import_sid)->sn_imports);
|
||||||
|
|
||||||
if (imported == NULL)
|
if (imported == NULL)
|
||||||
return NULL;
|
goto erret;
|
||||||
imported->imp_name = vim_strnsave(as_ptr, as_len);
|
imported->imp_name = as_name;
|
||||||
|
as_name = NULL;
|
||||||
imported->imp_sid = sid;
|
imported->imp_sid = sid;
|
||||||
imported->imp_all = TRUE;
|
imported->imp_all = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
arg = arg_start;
|
arg = arg_start;
|
||||||
if (*arg == '{')
|
if (*arg == '{')
|
||||||
arg = skipwhite(arg + 1);
|
arg = skipwhite(arg + 1);
|
||||||
for (;;)
|
for (i = 0; i < names.ga_len; ++i)
|
||||||
{
|
{
|
||||||
char_u *name = arg;
|
char_u *name = ((char_u **)names.ga_data)[i];
|
||||||
int name_len;
|
|
||||||
int idx;
|
int idx;
|
||||||
imported_T *imported;
|
imported_T *imported;
|
||||||
ufunc_T *ufunc = NULL;
|
ufunc_T *ufunc = NULL;
|
||||||
type_T *type;
|
type_T *type;
|
||||||
|
|
||||||
idx = find_exported(sid, &arg, &name_len, &ufunc, &type);
|
idx = find_exported(sid, name, &ufunc, &type);
|
||||||
|
|
||||||
if (idx < 0 && ufunc == NULL)
|
if (idx < 0 && ufunc == NULL)
|
||||||
return NULL;
|
goto erret;
|
||||||
|
|
||||||
if (check_defined(name, name_len, cctx) == FAIL)
|
if (check_defined(name, STRLEN(name), cctx) == FAIL)
|
||||||
return NULL;
|
goto erret;
|
||||||
|
|
||||||
imported = new_imported(gap != NULL ? gap
|
imported = new_imported(gap != NULL ? gap
|
||||||
: &SCRIPT_ITEM(import_sid)->sn_imports);
|
: &SCRIPT_ITEM(import_sid)->sn_imports);
|
||||||
if (imported == NULL)
|
if (imported == NULL)
|
||||||
return NULL;
|
goto erret;
|
||||||
|
|
||||||
// TODO: check for "as" following
|
// TODO: check for "as" following
|
||||||
// imported->imp_name = vim_strnsave(as_ptr, as_len);
|
// imported->imp_name = vim_strsave(as_name);
|
||||||
imported->imp_name = vim_strnsave(name, name_len);
|
imported->imp_name = name;
|
||||||
|
((char_u **)names.ga_data)[i] = NULL;
|
||||||
imported->imp_sid = sid;
|
imported->imp_sid = sid;
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
{
|
{
|
||||||
@ -415,30 +464,11 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid, void *cctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
imported->imp_funcname = ufunc->uf_name;
|
imported->imp_funcname = ufunc->uf_name;
|
||||||
|
|
||||||
arg = skipwhite(arg);
|
|
||||||
if (*arg_start != '{')
|
|
||||||
break;
|
|
||||||
if (*arg == '}')
|
|
||||||
{
|
|
||||||
arg = skipwhite(arg + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*arg != ',')
|
|
||||||
{
|
|
||||||
emsg(_("E1046: Missing comma in import"));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
arg = skipwhite(arg + 1);
|
|
||||||
}
|
|
||||||
if (arg != from_ptr)
|
|
||||||
{
|
|
||||||
// cannot happen, just in case the above has a flaw
|
|
||||||
emsg(_("E1047: syntax error in import"));
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
erret:
|
||||||
|
ga_clear_strings(&names);
|
||||||
|
vim_free(as_name);
|
||||||
return cmd_end;
|
return cmd_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user