Skip to content

Commit df7edfe

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 38ed567 + d8585ed commit df7edfe

File tree

8 files changed

+71
-30
lines changed

8 files changed

+71
-30
lines changed

src/channel.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,28 +3572,15 @@ set_ref_in_channel(int copyID)
35723572
{
35733573
int abort = FALSE;
35743574
channel_T *channel;
3575-
int part;
3575+
typval_T tv;
35763576

35773577
for (channel = first_channel; channel != NULL; channel = channel->ch_next)
3578-
{
3579-
for (part = PART_SOCK; part < PART_IN; ++part)
3578+
if (channel_still_useful(channel))
35803579
{
3581-
jsonq_T *head = &channel->ch_part[part].ch_json_head;
3582-
jsonq_T *item = head->jq_next;
3583-
3584-
while (item != NULL)
3585-
{
3586-
list_T *l = item->jq_value->vval.v_list;
3587-
3588-
if (l->lv_copyID != copyID)
3589-
{
3590-
l->lv_copyID = copyID;
3591-
abort = abort || set_ref_in_list(l, copyID, NULL);
3592-
}
3593-
item = item->jq_next;
3594-
}
3580+
tv.v_type = VAR_CHANNEL;
3581+
tv.vval.v_channel = channel;
3582+
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
35953583
}
3596-
}
35973584
return abort;
35983585
}
35993586

@@ -4111,6 +4098,26 @@ job_still_useful(job_T *job)
41114098
&& channel_still_useful(job->jv_channel)));
41124099
}
41134100

4101+
/*
4102+
* Mark references in jobs that are still useful.
4103+
*/
4104+
int
4105+
set_ref_in_job(int copyID)
4106+
{
4107+
int abort = FALSE;
4108+
job_T *job;
4109+
typval_T tv;
4110+
4111+
for (job = first_job; job != NULL; job = job->jv_next)
4112+
if (job_still_useful(job))
4113+
{
4114+
tv.v_type = VAR_JOB;
4115+
tv.vval.v_job = job;
4116+
abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
4117+
}
4118+
return abort;
4119+
}
4120+
41144121
void
41154122
job_unref(job_T *job)
41164123
{

src/eval.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3292,11 +3292,16 @@ eval_for_line(
32923292
if (!skip)
32933293
{
32943294
l = tv.vval.v_list;
3295-
if (tv.v_type != VAR_LIST || l == NULL)
3295+
if (tv.v_type != VAR_LIST)
32963296
{
32973297
EMSG(_(e_listreq));
32983298
clear_tv(&tv);
32993299
}
3300+
else if (l == NULL)
3301+
{
3302+
/* a null list is like an empty list: do nothing */
3303+
clear_tv(&tv);
3304+
}
33003305
else
33013306
{
33023307
/* No need to increment the refcount, it's already set for the
@@ -7024,6 +7029,7 @@ garbage_collect(int testing)
70247029

70257030
#ifdef FEAT_JOB_CHANNEL
70267031
abort = abort || set_ref_in_channel(copyID);
7032+
abort = abort || set_ref_in_job(copyID);
70277033
#endif
70287034
#ifdef FEAT_NETBEANS_INTG
70297035
abort = abort || set_ref_in_nb_channel(copyID);

src/proto/channel.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void clear_job_options(jobopt_T *opt);
4949
void free_job_options(jobopt_T *opt);
5050
int get_job_options(typval_T *tv, jobopt_T *opt, int supported);
5151
channel_T *get_channel_arg(typval_T *tv, int check_open, int reading, int part);
52+
int set_ref_in_job(int copyID);
5253
void job_unref(job_T *job);
5354
int free_unused_jobs_contents(int copyID, int mask);
5455
void free_unused_jobs(int copyID, int mask);

src/quickfix.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ qf_init_ext(
207207
char_u *fmtstr = NULL;
208208
char_u *growbuf = NULL;
209209
int growbuflen;
210-
int growbufsiz;
211-
char_u *linebuf;
212-
int linelen;
210+
int growbufsiz = 0;
211+
char_u *linebuf = NULL;
212+
int linelen = 0;
213213
int discard;
214214
int col = 0;
215215
char_u use_viscol = FALSE;
@@ -545,12 +545,12 @@ qf_init_ext(
545545
linelen = len > LINE_MAXLEN ? LINE_MAXLEN - 1 : len;
546546
if (growbuf == NULL)
547547
{
548-
growbuf = alloc(linelen);
548+
growbuf = alloc(linelen + 1);
549549
growbufsiz = linelen;
550550
}
551551
else if (linelen > growbufsiz)
552552
{
553-
growbuf = vim_realloc(growbuf, linelen);
553+
growbuf = vim_realloc(growbuf, linelen + 1);
554554
if (growbuf == NULL)
555555
goto qf_init_end;
556556
growbufsiz = linelen;
@@ -589,13 +589,13 @@ qf_init_ext(
589589
linelen = LINE_MAXLEN - 1;
590590
if (growbuf == NULL)
591591
{
592-
growbuf = alloc(linelen);
592+
growbuf = alloc(linelen + 1);
593593
growbufsiz = linelen;
594594
}
595595
else if (linelen > growbufsiz)
596596
{
597597
if ((growbuf = vim_realloc(growbuf,
598-
linelen)) == NULL)
598+
linelen + 1)) == NULL)
599599
goto qf_init_end;
600600
growbufsiz = linelen;
601601
}
@@ -623,14 +623,14 @@ qf_init_ext(
623623
{
624624
if (growbuf == NULL)
625625
{
626-
growbuf = alloc(linelen);
626+
growbuf = alloc(linelen + 1);
627627
growbufsiz = linelen;
628628
}
629629
else if (linelen > growbufsiz)
630630
{
631631
if (linelen > LINE_MAXLEN)
632632
linelen = LINE_MAXLEN - 1;
633-
if ((growbuf = vim_realloc(growbuf, linelen)) == NULL)
633+
if ((growbuf = vim_realloc(growbuf, linelen + 1)) == NULL)
634634
goto qf_init_end;
635635
growbufsiz = linelen;
636636
}

src/syntax.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9262,8 +9262,8 @@ set_hl_attr(
92629262
at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg;
92639263
at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg;
92649264
# ifdef FEAT_TERMGUICOLORS
9265-
at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB(sgp->sg_gui_fg);
9266-
at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB(sgp->sg_gui_bg);
9265+
at_en.ae_u.cterm.fg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_fg);
9266+
at_en.ae_u.cterm.bg_rgb = GUI_MCH_GET_RGB2(sgp->sg_gui_bg);
92679267
# endif
92689268
sgp->sg_cterm_attr = get_attr_entry(&cterm_attr_table, &at_en);
92699269
}

src/testdir/test_expr.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@ func Test_getreg_empty_list()
8383
call add(x, 'foo')
8484
call assert_equal(['foo'], y)
8585
endfunc
86+
87+
func Test_loop_over_null_list()
88+
let null_list = submatch(1, 1)
89+
for i in null_list
90+
call assert_true(0, 'should not get here')
91+
endfor
92+
endfunc

src/version.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,16 @@ static char *(features[]) =
768768

769769
static int included_patches[] =
770770
{ /* Add new patch number below this line */
771+
/**/
772+
1816,
773+
/**/
774+
1815,
775+
/**/
776+
1814,
777+
/**/
778+
1813,
779+
/**/
780+
1812,
771781
/**/
772782
1811,
773783
/**/

src/vim.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,14 +1564,23 @@ typedef UINT32_TYPEDEF UINT32_T;
15641564
#ifdef FEAT_GUI
15651565
# ifdef FEAT_TERMGUICOLORS
15661566
# define GUI_FUNCTION(f) (gui.in_use ? gui_##f : termgui_##f)
1567+
# define GUI_FUNCTION2(f, pixel) (gui.in_use \
1568+
? ((pixel) != INVALCOLOR \
1569+
? gui_##f((pixel)) \
1570+
: (long_u)INVALCOLOR) \
1571+
: termgui_##f((pixel)))
15671572
# define USE_24BIT (gui.in_use || p_tgc)
15681573
# else
15691574
# define GUI_FUNCTION(f) gui_##f
1575+
# define GUI_FUNCTION2(f,pixel) ((pixel) != INVALCOLOR \
1576+
? gui_##f((pixel)) \
1577+
: (long_u)INVALCOLOR)
15701578
# define USE_24BIT gui.in_use
15711579
# endif
15721580
#else
15731581
# ifdef FEAT_TERMGUICOLORS
15741582
# define GUI_FUNCTION(f) termgui_##f
1583+
# define GUI_FUNCTION2(f, pixel) termgui_##f((pixel))
15751584
# define USE_24BIT p_tgc
15761585
# endif
15771586
#endif
@@ -1582,6 +1591,7 @@ typedef UINT32_TYPEDEF UINT32_T;
15821591
#endif
15831592
#ifdef GUI_FUNCTION
15841593
# define GUI_MCH_GET_RGB GUI_FUNCTION(mch_get_rgb)
1594+
# define GUI_MCH_GET_RGB2(pixel) GUI_FUNCTION2(mch_get_rgb, (pixel))
15851595
# define GUI_MCH_GET_COLOR GUI_FUNCTION(mch_get_color)
15861596
# define GUI_GET_COLOR GUI_FUNCTION(get_color)
15871597
#endif

0 commit comments

Comments
 (0)