Skip to content

Commit 8287abd

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents c15c0d6 + d47d837 commit 8287abd

19 files changed

+437
-116
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2731,6 +2731,7 @@ shadow: runtime pixmaps
27312731
mkdir $(SHADOWDIR)/testdir
27322732
cd $(SHADOWDIR)/testdir; ln -s ../../testdir/Makefile \
27332733
../../testdir/Make_all.mak \
2734+
../../testdir/README.txt \
27342735
../../testdir/*.in \
27352736
../../testdir/*.vim \
27362737
../../testdir/*.py \

src/buffer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ close_buffer(
580580

581581
/* When closing the current buffer stop Visual mode before freeing
582582
* anything. */
583-
if (buf == curbuf)
583+
if (buf == curbuf
584+
#if defined(EXITFREE)
585+
&& !entered_free_all_mem
586+
#endif
587+
)
584588
end_visual_mode();
585589

586590
/*

src/ex_getln.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5776,7 +5776,7 @@ add_to_history(
57765776
*/
57775777
if (histype == HIST_SEARCH && in_map)
57785778
{
5779-
if (maptick == last_maptick)
5779+
if (maptick == last_maptick && hisidx[HIST_SEARCH] >= 0)
57805780
{
57815781
/* Current line is from the same mapping, remove it */
57825782
hisptr = &history[HIST_SEARCH][hisidx[HIST_SEARCH]];

src/gui.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,29 @@ typedef enum
553553
# define CONVERT_FROM_UTF8(String) (String)
554554
# define CONVERT_FROM_UTF8_FREE(String) ((String) = (char_u *)NULL)
555555
#endif /* FEAT_GUI_GTK */
556+
557+
#ifdef FEAT_GUI_GTK
558+
/*
559+
* The second parameter of g_signal_handlers_disconnect_by_func() is supposed
560+
* to be a function pointer which was passed to g_signal_connect_*() somewhere
561+
* previously, and hence it must be of type GCallback, i.e., void (*)(void).
562+
*
563+
* Meanwhile, g_signal_handlers_disconnect_by_func() is a macro calling
564+
* g_signal_handlers_disconnect_matched(), and the second parameter of the
565+
* former is to be passed to the sixth parameter of the latter the type of
566+
* which, however, is declared as void * in the function signature.
567+
*
568+
* While the ISO C Standard does not require that function pointers be
569+
* interconvertible to void *, widely-used compilers such as gcc and clang
570+
* do such conversion implicitly and automatically on some platforms without
571+
* issuing any warning.
572+
*
573+
* For Solaris Studio, that is not the case. An explicit type cast is needed
574+
* to suppress warnings on that particular conversion.
575+
*/
576+
# if defined(__SUNPRO_C) && defined(USE_GTK3)
577+
# define FUNC2GENERIC(func) (void *)(func)
578+
# else
579+
# define FUNC2GENERIC(func) G_CALLBACK(func)
580+
# endif
581+
#endif /* FEAT_GUI_GTK */

src/gui_beval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ removeEventHandler(BalloonEval *beval)
508508
/* LINTED: avoid warning: dubious operation on enum */
509509
# if GTK_CHECK_VERSION(3,0,0)
510510
g_signal_handlers_disconnect_by_func(G_OBJECT(beval->target),
511-
G_CALLBACK(target_event_cb),
511+
FUNC2GENERIC(target_event_cb),
512512
beval);
513513
# else
514514
gtk_signal_disconnect_by_func((GtkObject*)(beval->target),
@@ -522,7 +522,7 @@ removeEventHandler(BalloonEval *beval)
522522
/* LINTED: avoid warning: dubious operation on enum */
523523
# if GTK_CHECK_VERSION(3,0,0)
524524
g_signal_handlers_disconnect_by_func(G_OBJECT(gui.mainwin),
525-
G_CALLBACK(mainwin_event_cb),
525+
FUNC2GENERIC(mainwin_event_cb),
526526
beval);
527527
# else
528528
gtk_signal_disconnect_by_func((GtkObject*)(gui.mainwin),

src/gui_gtk_f.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,18 @@ gtk_form_unrealize(GtkWidget *widget)
505505
{
506506
#if GTK_CHECK_VERSION(3,0,0)
507507
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
508-
G_CALLBACK(gtk_form_child_map),
508+
FUNC2GENERIC(gtk_form_child_map),
509509
child);
510510
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
511-
G_CALLBACK(gtk_form_child_unmap),
511+
FUNC2GENERIC(gtk_form_child_unmap),
512512
child);
513513
#else
514514
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
515-
GTK_SIGNAL_FUNC(gtk_form_child_map),
516-
child);
515+
GTK_SIGNAL_FUNC(gtk_form_child_map),
516+
child);
517517
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
518-
GTK_SIGNAL_FUNC(gtk_form_child_unmap),
519-
child);
518+
GTK_SIGNAL_FUNC(gtk_form_child_unmap),
519+
child);
520520
#endif
521521

522522
gdk_window_set_user_data(child->window, NULL);
@@ -793,14 +793,14 @@ gtk_form_remove(GtkContainer *container, GtkWidget *widget)
793793
{
794794
#if GTK_CHECK_VERSION(3,0,0)
795795
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
796-
G_CALLBACK(&gtk_form_child_map), child);
796+
FUNC2GENERIC(&gtk_form_child_map), child);
797797
g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
798-
G_CALLBACK(&gtk_form_child_unmap), child);
798+
FUNC2GENERIC(&gtk_form_child_unmap), child);
799799
#else
800800
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
801-
GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
801+
GTK_SIGNAL_FUNC(&gtk_form_child_map), child);
802802
gtk_signal_disconnect_by_func(GTK_OBJECT(child->widget),
803-
GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
803+
GTK_SIGNAL_FUNC(&gtk_form_child_unmap), child);
804804
#endif
805805

806806
/* FIXME: This will cause problems for reparenting NO_WINDOW

src/message.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,7 @@ msg_puts_printf(char_u *str, int maxlen)
24662466
if (!(silent_mode && p_verbose == 0))
24672467
mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */
24682468
#endif
2469-
while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
2469+
while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
24702470
{
24712471
if (!(silent_mode && p_verbose == 0))
24722472
{

src/regexp_nfa.c

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4340,6 +4340,9 @@ state_in_list(
43404340
return FALSE;
43414341
}
43424342

4343+
/* Offset used for "off" by addstate_here(). */
4344+
#define ADDSTATE_HERE_OFFSET 10
4345+
43434346
/*
43444347
* Add "state" and possibly what follows to state list ".".
43454348
* Returns "subs_arg", possibly copied into temp_subs.
@@ -4350,11 +4353,16 @@ addstate(
43504353
nfa_state_T *state, /* state to update */
43514354
regsubs_T *subs_arg, /* pointers to subexpressions */
43524355
nfa_pim_T *pim, /* postponed look-behind match */
4353-
int off) /* byte offset, when -1 go to next line */
4356+
int off_arg) /* byte offset, when -1 go to next line */
43544357
{
43554358
int subidx;
4359+
int off = off_arg;
4360+
int add_here = FALSE;
4361+
int listindex = 0;
4362+
int k;
4363+
int found = FALSE;
43564364
nfa_thread_T *thread;
4357-
lpos_T save_lpos;
4365+
struct multipos save_multipos;
43584366
int save_in_use;
43594367
char_u *save_ptr;
43604368
int i;
@@ -4365,6 +4373,13 @@ addstate(
43654373
int did_print = FALSE;
43664374
#endif
43674375

4376+
if (off_arg <= -ADDSTATE_HERE_OFFSET)
4377+
{
4378+
add_here = TRUE;
4379+
off = 0;
4380+
listindex = -(off_arg + ADDSTATE_HERE_OFFSET);
4381+
}
4382+
43684383
switch (state->c)
43694384
{
43704385
case NFA_NCLOSE:
@@ -4448,13 +4463,28 @@ addstate(
44484463
if (!nfa_has_backref && pim == NULL && !l->has_pim
44494464
&& state->c != NFA_MATCH)
44504465
{
4466+
/* When called from addstate_here() do insert before
4467+
* existing states. */
4468+
if (add_here)
4469+
{
4470+
for (k = 0; k < l->n && k < listindex; ++k)
4471+
if (l->t[k].state->id == state->id)
4472+
{
4473+
found = TRUE;
4474+
break;
4475+
}
4476+
}
4477+
if (!add_here || found)
4478+
{
44514479
skip_add:
44524480
#ifdef ENABLE_LOG
4453-
nfa_set_code(state->c);
4454-
fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s\n",
4455-
abs(state->id), l->id, state->c, code);
4481+
nfa_set_code(state->c);
4482+
fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s pim: %s has_pim: %d found: %d\n",
4483+
abs(state->id), l->id, state->c, code,
4484+
pim == NULL ? "NULL" : "yes", l->has_pim, found);
44564485
#endif
4457-
return subs;
4486+
return subs;
4487+
}
44584488
}
44594489

44604490
/* Do not add the state again when it exists with the same
@@ -4519,14 +4549,14 @@ addstate(
45194549

45204550
case NFA_SPLIT:
45214551
/* order matters here */
4522-
subs = addstate(l, state->out, subs, pim, off);
4523-
subs = addstate(l, state->out1, subs, pim, off);
4552+
subs = addstate(l, state->out, subs, pim, off_arg);
4553+
subs = addstate(l, state->out1, subs, pim, off_arg);
45244554
break;
45254555

45264556
case NFA_EMPTY:
45274557
case NFA_NOPEN:
45284558
case NFA_NCLOSE:
4529-
subs = addstate(l, state->out, subs, pim, off);
4559+
subs = addstate(l, state->out, subs, pim, off_arg);
45304560
break;
45314561

45324562
case NFA_MOPEN:
@@ -4572,17 +4602,15 @@ addstate(
45724602

45734603
/* avoid compiler warnings */
45744604
save_ptr = NULL;
4575-
save_lpos.lnum = 0;
4576-
save_lpos.col = 0;
4605+
vim_memset(&save_multipos, 0, sizeof(save_multipos));
45774606

45784607
/* Set the position (with "off" added) in the subexpression. Save
45794608
* and restore it when it was in use. Otherwise fill any gap. */
45804609
if (REG_MULTI)
45814610
{
45824611
if (subidx < sub->in_use)
45834612
{
4584-
save_lpos.lnum = sub->list.multi[subidx].start_lnum;
4585-
save_lpos.col = sub->list.multi[subidx].start_col;
4613+
save_multipos = sub->list.multi[subidx];
45864614
save_in_use = -1;
45874615
}
45884616
else
@@ -4628,7 +4656,7 @@ addstate(
46284656
sub->list.line[subidx].start = reginput + off;
46294657
}
46304658

4631-
subs = addstate(l, state->out, subs, pim, off);
4659+
subs = addstate(l, state->out, subs, pim, off_arg);
46324660
/* "subs" may have changed, need to set "sub" again */
46334661
#ifdef FEAT_SYN_HL
46344662
if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9)
@@ -4640,10 +4668,7 @@ addstate(
46404668
if (save_in_use == -1)
46414669
{
46424670
if (REG_MULTI)
4643-
{
4644-
sub->list.multi[subidx].start_lnum = save_lpos.lnum;
4645-
sub->list.multi[subidx].start_col = save_lpos.col;
4646-
}
4671+
sub->list.multi[subidx] = save_multipos;
46474672
else
46484673
sub->list.line[subidx].start = save_ptr;
46494674
}
@@ -4657,7 +4682,7 @@ addstate(
46574682
: subs->norm.list.line[0].end != NULL))
46584683
{
46594684
/* Do not overwrite the position set by \ze. */
4660-
subs = addstate(l, state->out, subs, pim, off);
4685+
subs = addstate(l, state->out, subs, pim, off_arg);
46614686
break;
46624687
}
46634688
case NFA_MCLOSE1:
@@ -4707,8 +4732,7 @@ addstate(
47074732
sub->in_use = subidx + 1;
47084733
if (REG_MULTI)
47094734
{
4710-
save_lpos.lnum = sub->list.multi[subidx].end_lnum;
4711-
save_lpos.col = sub->list.multi[subidx].end_col;
4735+
save_multipos = sub->list.multi[subidx];
47124736
if (off == -1)
47134737
{
47144738
sub->list.multi[subidx].end_lnum = reglnum + 1;
@@ -4728,11 +4752,10 @@ addstate(
47284752
save_ptr = sub->list.line[subidx].end;
47294753
sub->list.line[subidx].end = reginput + off;
47304754
/* avoid compiler warnings */
4731-
save_lpos.lnum = 0;
4732-
save_lpos.col = 0;
4755+
vim_memset(&save_multipos, 0, sizeof(save_multipos));
47334756
}
47344757

4735-
subs = addstate(l, state->out, subs, pim, off);
4758+
subs = addstate(l, state->out, subs, pim, off_arg);
47364759
/* "subs" may have changed, need to set "sub" again */
47374760
#ifdef FEAT_SYN_HL
47384761
if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9)
@@ -4742,10 +4765,7 @@ addstate(
47424765
sub = &subs->norm;
47434766

47444767
if (REG_MULTI)
4745-
{
4746-
sub->list.multi[subidx].end_lnum = save_lpos.lnum;
4747-
sub->list.multi[subidx].end_col = save_lpos.col;
4748-
}
4768+
sub->list.multi[subidx] = save_multipos;
47494769
else
47504770
sub->list.line[subidx].end = save_ptr;
47514771
sub->in_use = save_in_use;
@@ -4772,8 +4792,10 @@ addstate_here(
47724792
int count;
47734793
int listidx = *ip;
47744794

4775-
/* first add the state(s) at the end, so that we know how many there are */
4776-
addstate(l, state, subs, pim, 0);
4795+
/* First add the state(s) at the end, so that we know how many there are.
4796+
* Pass the listidx as offset (avoids adding another argument to
4797+
* addstate(). */
4798+
addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET);
47774799

47784800
/* when "*ip" was at the end of the list, nothing to do */
47794801
if (listidx + 1 == tlen)

src/search.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,14 +1249,13 @@ do_search(
12491249
{
12501250
if (spats[RE_SEARCH].pat == NULL) /* no previous pattern */
12511251
{
1252-
pat = spats[RE_SUBST].pat;
1253-
if (pat == NULL)
1252+
searchstr = spats[RE_SUBST].pat;
1253+
if (searchstr == NULL)
12541254
{
12551255
EMSG(_(e_noprevre));
12561256
retval = 0;
12571257
goto end_do_search;
12581258
}
1259-
searchstr = pat;
12601259
}
12611260
else
12621261
{

src/testdir/test86.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ def ee(expr, g=globals(), l=locals()):
239239
'TypeError:("\'FailingNumber\' object is not iterable",)')
240240
if msg.find('(\'\'') > -1 or msg.find('(\'can\'t') > -1:
241241
msg = msg.replace('(\'', '("').replace('\',)', '",)')
242+
# Some Python versions say can't, others cannot.
243+
if msg.find('can\'t') > -1:
244+
msg = msg.replace('can\'t', 'cannot')
245+
# Some Python versions use single quote, some double quote
246+
if msg.find('"cannot ') > -1:
247+
msg = msg.replace('"cannot ', '\'cannot ')
248+
if msg.find(' attributes"') > -1:
249+
msg = msg.replace(' attributes"', ' attributes\'')
242250
if expr == 'fd(self=[])':
243251
# HACK: PyMapping_Check changed meaning
244252
msg = msg.replace('AttributeError:(\'keys\',)',

src/testdir/test86.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ testdir
628628
test86.in
629629
> Output
630630
>> OutputSetattr
631-
del sys.stdout.softspace:AttributeError:("can't delete OutputObject attributes",)
631+
del sys.stdout.softspace:AttributeError:('cannot delete OutputObject attributes',)
632632
>>> Testing NumberToLong using sys.stdout.softspace = %s
633633
sys.stdout.softspace = []:TypeError:('expected int(), long() or something supporting coercing to long(), but got list',)
634634
sys.stdout.softspace = None:TypeError:('expected int(), long() or something supporting coercing to long(), but got NoneType',)

src/testdir/test87.in

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,18 @@ def ee(expr, g=globals(), l=locals()):
238238
else:
239239
cb.append(expr + ':' + repr((e.__class__, e)))
240240
elif sys.version_info >= (3, 5) and e.__class__ is ValueError and str(e) == 'embedded null byte':
241-
msg = cb.append(expr + ':' + repr((TypeError, TypeError('expected bytes with no null'))))
241+
cb.append(expr + ':' + repr((TypeError, TypeError('expected bytes with no null'))))
242242
else:
243-
cb.append(expr + ':' + repr((e.__class__, e)))
243+
msg = repr((e.__class__, e))
244+
# Some Python versions say can't, others cannot.
245+
if msg.find('can\'t') > -1:
246+
msg = msg.replace('can\'t', 'cannot')
247+
# Some Python versions use single quote, some double quote
248+
if msg.find('"cannot ') > -1:
249+
msg = msg.replace('"cannot ', '\'cannot ')
250+
if msg.find(' attributes"') > -1:
251+
msg = msg.replace(' attributes"', ' attributes\'')
252+
cb.append(expr + ':' + msg)
244253
else:
245254
cb.append(expr + ':NOT FAILED')
246255
except Exception as e:

src/testdir/test87.ok

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ b'testdir'
628628
test87.in
629629
> Output
630630
>> OutputSetattr
631-
del sys.stdout.softspace:(<class 'AttributeError'>, AttributeError("can't delete OutputObject attributes",))
631+
del sys.stdout.softspace:(<class 'AttributeError'>, AttributeError('cannot delete OutputObject attributes',))
632632
>>> Testing NumberToLong using sys.stdout.softspace = %s
633633
sys.stdout.softspace = []:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got list',))
634634
sys.stdout.softspace = None:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',))

0 commit comments

Comments
 (0)