Skip to content

Commit 755e60a

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 132af44 + 9e63f61 commit 755e60a

9 files changed

Lines changed: 263 additions & 180 deletions

File tree

src/eval.c

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3461,7 +3461,7 @@ ex_call(exarg_T *eap)
34613461
int doesrange;
34623462
int failed = FALSE;
34633463
funcdict_T fudi;
3464-
partial_T *partial;
3464+
partial_T *partial = NULL;
34653465

34663466
if (eap->skip)
34673467
{
@@ -3497,12 +3497,6 @@ ex_call(exarg_T *eap)
34973497
name = deref_func_name(tofree, &len,
34983498
partial != NULL ? NULL : &partial, FALSE);
34993499

3500-
/* When calling fdict.func(), where "func" is a partial, use "fdict"
3501-
* instead of the dict in the partial, for backwards compatibility.
3502-
* TODO: Do use the arguments in the partial? */
3503-
if (fudi.fd_dict != NULL)
3504-
partial = NULL;
3505-
35063500
/* Skip white space to allow ":call func ()". Not good, but required for
35073501
* backward compatibility. */
35083502
startarg = skipwhite(arg);
@@ -11814,6 +11808,7 @@ f_function(typval_T *argvars, typval_T *rettv)
1181411808
char_u *s;
1181511809
char_u *name;
1181611810
int use_string = FALSE;
11811+
partial_T *arg_pt = NULL;
1181711812

1181811813
if (argvars[0].v_type == VAR_FUNC)
1181911814
{
@@ -11822,8 +11817,11 @@ f_function(typval_T *argvars, typval_T *rettv)
1182211817
}
1182311818
else if (argvars[0].v_type == VAR_PARTIAL
1182411819
&& argvars[0].vval.v_partial != NULL)
11820+
{
1182511821
/* function(dict.MyFunc, [arg]) */
11826-
s = argvars[0].vval.v_partial->pt_name;
11822+
arg_pt = argvars[0].vval.v_partial;
11823+
s = arg_pt->pt_name;
11824+
}
1182711825
else
1182811826
{
1182911827
/* function('MyFunc', [arg], dict) */
@@ -11901,19 +11899,27 @@ f_function(typval_T *argvars, typval_T *rettv)
1190111899
arg_idx = 0;
1190211900
}
1190311901
}
11904-
if (dict_idx > 0 || arg_idx > 0)
11902+
if (dict_idx > 0 || arg_idx > 0 || arg_pt != NULL)
1190511903
{
1190611904
partial_T *pt = (partial_T *)alloc_clear(sizeof(partial_T));
1190711905

11906+
/* result is a VAR_PARTIAL */
1190811907
if (pt != NULL)
1190911908
{
11910-
if (arg_idx > 0)
11909+
if (arg_idx > 0 || (arg_pt != NULL && arg_pt->pt_argc > 0))
1191111910
{
1191211911
listitem_T *li;
1191311912
int i = 0;
11914-
11913+
int arg_len = 0;
11914+
int lv_len = 0;
11915+
11916+
if (arg_pt != NULL)
11917+
arg_len = arg_pt->pt_argc;
11918+
if (list != NULL)
11919+
lv_len = list->lv_len;
11920+
pt->pt_argc = arg_len + lv_len;
1191511921
pt->pt_argv = (typval_T *)alloc(
11916-
sizeof(typval_T) * list->lv_len);
11922+
sizeof(typval_T) * pt->pt_argc);
1191711923
if (pt->pt_argv == NULL)
1191811924
{
1191911925
vim_free(pt);
@@ -11922,9 +11928,12 @@ f_function(typval_T *argvars, typval_T *rettv)
1192211928
}
1192311929
else
1192411930
{
11925-
pt->pt_argc = list->lv_len;
11926-
for (li = list->lv_first; li != NULL; li = li->li_next)
11927-
copy_tv(&li->li_tv, &pt->pt_argv[i++]);
11931+
for (i = 0; i < arg_len; i++)
11932+
copy_tv(&arg_pt->pt_argv[i], &pt->pt_argv[i]);
11933+
if (lv_len > 0)
11934+
for (li = list->lv_first; li != NULL;
11935+
li = li->li_next)
11936+
copy_tv(&li->li_tv, &pt->pt_argv[i++]);
1192811937
}
1192911938
}
1193011939

@@ -11935,10 +11944,11 @@ f_function(typval_T *argvars, typval_T *rettv)
1193511944
pt->pt_dict = argvars[dict_idx].vval.v_dict;
1193611945
++pt->pt_dict->dv_refcount;
1193711946
}
11938-
else if (argvars[0].v_type == VAR_PARTIAL)
11947+
else if (arg_pt != NULL)
1193911948
{
11940-
pt->pt_dict = argvars[0].vval.v_partial->pt_dict;
11941-
++pt->pt_dict->dv_refcount;
11949+
pt->pt_dict = arg_pt->pt_dict;
11950+
if (pt->pt_dict != NULL)
11951+
++pt->pt_dict->dv_refcount;
1194211952
}
1194311953

1194411954
pt->pt_refcount = 1;
@@ -11950,6 +11960,7 @@ f_function(typval_T *argvars, typval_T *rettv)
1195011960
}
1195111961
else
1195211962
{
11963+
/* result is a VAR_FUNC */
1195311964
rettv->v_type = VAR_FUNC;
1195411965
rettv->vval.v_string = name;
1195511966
func_ref(name);
@@ -21744,17 +21755,18 @@ handle_subscript(
2174421755
}
2174521756
}
2174621757

21747-
if (rettv->v_type == VAR_FUNC && selfdict != NULL)
21758+
if ((rettv->v_type == VAR_FUNC || rettv->v_type == VAR_PARTIAL)
21759+
&& selfdict != NULL)
2174821760
{
21749-
char_u *fname;
21761+
char_u *fname = rettv->v_type == VAR_FUNC ? rettv->vval.v_string
21762+
: rettv->vval.v_partial->pt_name;
2175021763
char_u *tofree = NULL;
2175121764
ufunc_T *fp;
2175221765
char_u fname_buf[FLEN_FIXED + 1];
2175321766
int error;
2175421767

2175521768
/* Translate "s:func" to the stored function name. */
21756-
fname = fname_trans_sid(rettv->vval.v_string, fname_buf,
21757-
&tofree, &error);
21769+
fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
2175821770
fp = find_func(fname);
2175921771
vim_free(tofree);
2176021772

@@ -21768,7 +21780,34 @@ handle_subscript(
2176821780
pt->pt_refcount = 1;
2176921781
pt->pt_dict = selfdict;
2177021782
selfdict = NULL;
21771-
pt->pt_name = rettv->vval.v_string;
21783+
if (rettv->v_type == VAR_FUNC)
21784+
{
21785+
/* just a function: use selfdict */
21786+
pt->pt_name = rettv->vval.v_string;
21787+
}
21788+
else
21789+
{
21790+
partial_T *ret_pt = rettv->vval.v_partial;
21791+
int i;
21792+
21793+
/* partial: use selfdict and copy args */
21794+
pt->pt_name = vim_strsave(ret_pt->pt_name);
21795+
if (ret_pt->pt_argc > 0)
21796+
{
21797+
pt->pt_argv = (typval_T *)alloc(
21798+
sizeof(typval_T) * ret_pt->pt_argc);
21799+
if (pt->pt_argv == NULL)
21800+
/* out of memory: drop the arguments */
21801+
pt->pt_argc = 0;
21802+
else
21803+
{
21804+
pt->pt_argc = ret_pt->pt_argc;
21805+
for (i = 0; i < pt->pt_argc; i++)
21806+
copy_tv(&ret_pt->pt_argv[i], &pt->pt_argv[i]);
21807+
}
21808+
}
21809+
partial_unref(ret_pt);
21810+
}
2177221811
func_ref(pt->pt_name);
2177321812
rettv->v_type = VAR_PARTIAL;
2177421813
rettv->vval.v_partial = pt;
@@ -23920,6 +23959,14 @@ trans_function_name(
2392023959
name = vim_strsave(lv.ll_tv->vval.v_string);
2392123960
*pp = end;
2392223961
}
23962+
else if (lv.ll_tv->v_type == VAR_PARTIAL
23963+
&& lv.ll_tv->vval.v_partial != NULL)
23964+
{
23965+
name = vim_strsave(lv.ll_tv->vval.v_partial->pt_name);
23966+
*pp = end;
23967+
if (partial != NULL)
23968+
*partial = lv.ll_tv->vval.v_partial;
23969+
}
2392323970
else
2392423971
{
2392523972
if (!skip && !(flags & TFN_QUIET) && (fdp == NULL

src/ex_cmds2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,7 @@ do_in_runtimepath(
33453345

33463346
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START))
33473347
{
3348-
len = STRLEN(start_dir) + STRLEN(name);
3348+
len = (int)(STRLEN(start_dir) + STRLEN(name));
33493349
s = alloc(len);
33503350
if (s == NULL)
33513351
return FAIL;
@@ -3356,7 +3356,7 @@ do_in_runtimepath(
33563356

33573357
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT))
33583358
{
3359-
len = STRLEN(opt_dir) + STRLEN(name);
3359+
len = (int)(STRLEN(opt_dir) + STRLEN(name));
33603360
s = alloc(len);
33613361
if (s == NULL)
33623362
return FAIL;

src/os_win32.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ static void standend(void);
214214
static void visual_bell(void);
215215
static void cursor_visible(BOOL fVisible);
216216
static DWORD write_chars(char_u *pchBuf, DWORD cbToWrite);
217-
static WCHAR tgetch(int *pmodifiers, WCHAR *pch2);
218217
static void create_conin(void);
219218
static int s_cursor_visible = TRUE;
220219
static int did_create_conin = FALSE;
@@ -1502,6 +1501,21 @@ WaitForChar(long msec)
15021501
&& (msec < 0 || (long)dwWaitTime > p_mzq))
15031502
dwWaitTime = p_mzq; /* don't wait longer than 'mzquantum' */
15041503
#endif
1504+
#ifdef FEAT_TIMERS
1505+
{
1506+
long due_time;
1507+
1508+
/* When waiting very briefly don't trigger timers. */
1509+
if (dwWaitTime > 10)
1510+
{
1511+
/* Trigger timers and then get the time in msec until the
1512+
* next one is due. Wait up to that time. */
1513+
due_time = check_due_timer();
1514+
if (due_time > 0 && dwWaitTime > (DWORD)due_time)
1515+
dwWaitTime = due_time;
1516+
}
1517+
}
1518+
#endif
15051519
#ifdef FEAT_CLIENTSERVER
15061520
/* Wait for either an event on the console input or a message in
15071521
* the client-server window. */
@@ -1604,7 +1618,7 @@ create_conin(void)
16041618
}
16051619

16061620
/*
1607-
* Get a keystroke or a mouse event
1621+
* Get a keystroke or a mouse event, use a blocking wait.
16081622
*/
16091623
static WCHAR
16101624
tgetch(int *pmodifiers, WCHAR *pch2)
@@ -6074,7 +6088,7 @@ mch_write(
60746088

60756089

60766090
/*
6077-
* Delay for half a second.
6091+
* Delay for "msec" milliseconds.
60786092
*/
60796093
/*ARGSUSED*/
60806094
void

src/testdir/Make_all.mak

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ SCRIPTS_ALL = \
7979
test93.out \
8080
test94.out \
8181
test95.out \
82-
test96.out \
8382
test98.out \
8483
test99.out \
8584
test101.out \

0 commit comments

Comments
 (0)