From 23c463a157b4f5585ad85efc9f453ffc09c245c3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 11:39:27 +0100 Subject: [PATCH 01/12] patch 7.4.1386 Problem: When the Job exit callback is invoked, the job may be freed too soon. (Yasuhiro Matsumoto) Solution: Increase refcount. --- src/eval.c | 6 ++++-- src/version.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/eval.c b/src/eval.c index 3fb06d00ea..cc30308495 100644 --- a/src/eval.c +++ b/src/eval.c @@ -15039,7 +15039,8 @@ job_status(job_T *job) typval_T rettv; int dummy; - /* invoke the exit callback */ + /* invoke the exit callback; make sure the refcount is > 0 */ + ++job->jv_refcount; argv[0].v_type = VAR_JOB; argv[0].vval.v_job = job; argv[1].v_type = VAR_NUMBER; @@ -15047,10 +15048,11 @@ job_status(job_T *job) call_func(job->jv_exit_cb, (int)STRLEN(job->jv_exit_cb), &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL); clear_tv(&rettv); + --job->jv_refcount; } if (job->jv_status == JOB_ENDED && job->jv_refcount == 0) { - /* The job already was unreferenced, now that it ended it can be + /* The job was already unreferenced, now that it ended it can be * freed. Careful: caller must not use "job" after this! */ job_free(job); } diff --git a/src/version.c b/src/version.c index 9e2f4bd81b..778d1fc4ad 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1386, /**/ 1385, /**/ From 8f8ae40ce45822c51c7f3cc58d7c23990f0ecc3d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 20:07:49 +0100 Subject: [PATCH 02/12] patch 7.4.1387 Problem: Win16 docs still referenced. Solution: Remove Win16 files from the docs Makefile. (Kenichi Ito) --- runtime/doc/Makefile | 5 ----- src/version.c | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile index 6bbcbc3676..d36f2ce069 100644 --- a/runtime/doc/Makefile +++ b/runtime/doc/Makefile @@ -32,7 +32,6 @@ DOCS = \ ft_ada.txt \ ft_sql.txt \ gui.txt \ - gui_w16.txt \ gui_w32.txt \ gui_x11.txt \ hangulin.txt \ @@ -167,7 +166,6 @@ HTMLS = \ ft_ada.html \ ft_sql.html \ gui.html \ - gui_w16.html \ gui_w32.html \ gui_x11.html \ hangulin.html \ @@ -388,9 +386,6 @@ hebrew.txt: russian.txt: touch russian.txt -gui_w16.txt: - touch gui_w16.txt - gui_w32.txt: touch gui_w32.txt diff --git a/src/version.c b/src/version.c index 778d1fc4ad..0357cf5974 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1387, /**/ 1386, /**/ From bdcd75275002c3b74015bb9bc0a01b13bb6107d4 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 20:19:03 +0100 Subject: [PATCH 03/12] patch 7.4.1388 Problem: Compiler warning. (Cesar Romani) Solution: Initialize variable. --- src/ex_cmds2.c | 4 +--- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index e26069d85c..9601409a71 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3058,14 +3058,12 @@ source_pack_plugin(char_u *fname, void *cookie UNUSED) int oldlen; int addlen; - p4 = p3 = p2 = p1 = get_past_head(fname); + p6 = p5 = p4 = p3 = p2 = p1 = get_past_head(fname); for (p = p1; *p; mb_ptr_adv(p)) - { if (vim_ispathsep_nocolon(*p)) { p6 = p5; p5 = p4; p4 = p3; p3 = p2; p2 = p1; p1 = p; } - } /* now we have: * rtp/pack/name/ever/name/plugin/name.vim diff --git a/src/version.c b/src/version.c index 0357cf5974..e2717b0474 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1388, /**/ 1387, /**/ From b2bd6a087d0598f6934bba825bed7535f42efc91 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 20:20:25 +0100 Subject: [PATCH 04/12] patch 7.4.1389 Problem: Incomplete function declaration. Solution: Add "void". (Yasuhiro Matsumoto) --- src/eval.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index cc30308495..0a12ff9d4b 100644 --- a/src/eval.c +++ b/src/eval.c @@ -15064,7 +15064,7 @@ job_status(job_T *job) * Called once in a while: check if any jobs with an "exit-cb" have ended. */ void -job_check_ended() +job_check_ended(void) { static time_t last_check = 0; time_t now; diff --git a/src/version.c b/src/version.c index e2717b0474..2e876b09c6 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1389, /**/ 1388, /**/ From 33c31d5abf122806a4a1b4353e5bdc1dbb9468c0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 21:07:06 +0100 Subject: [PATCH 05/12] patch 7.4.1390 Problem: When building with GTK and glib-compile-resources cannot be found building Vim fails. (Michael Gehring) Solution: Make GLIB_COMPILE_RESOURCES empty instead of leaving it at "no". (nuko8, closes #655) --- src/auto/configure | 11 ++++++----- src/configure.in | 11 ++++++----- src/version.c | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/auto/configure b/src/auto/configure index fea1f2cfab..69aec67c65 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -9052,7 +9052,7 @@ $as_echo_n "checking version of Gdk-Pixbuf... " >&6; } gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \ sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/'` if test "x$gdk_pixbuf_version_minor" != x -a \ - $gdk_pixbuf_version_minor -ge 31 ; then + $gdk_pixbuf_version_minor -ge 31 ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: OK." >&5 $as_echo "OK." >&6; } # Extract the first word of "glib-compile-resources", so it can be a program name with args. @@ -9099,15 +9099,16 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking glib-compile-resources" >&5 $as_echo_n "checking glib-compile-resources... " >&6; } if test "x$GLIB_COMPILE_RESOURCES" = xno ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot be found in PATH." >&5 + GLIB_COMPILE_RESOURCES="" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot be found in PATH." >&5 $as_echo "cannot be found in PATH." >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: usable." >&5 $as_echo "usable." >&6; } - $as_echo "#define USE_GRESOURCE 1" >>confdefs.h + $as_echo "#define USE_GRESOURCE 1" >>confdefs.h - GRESOURCE_SRC="auto/gui_gtk_gresources.c" - GRESOURCE_OBJ="objects/gui_gtk_gresources.o" + GRESOURCE_SRC="auto/gui_gtk_gresources.c" + GRESOURCE_OBJ="objects/gui_gtk_gresources.o" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not usable." >&5 diff --git a/src/configure.in b/src/configure.in index 92a1bb5251..9f19c137b6 100644 --- a/src/configure.in +++ b/src/configure.in @@ -2610,17 +2610,18 @@ if test "x$GUITYPE" = "xGTK"; then gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \ sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'` if test "x$gdk_pixbuf_version_minor" != x -a \ - $gdk_pixbuf_version_minor -ge 31 ; then + $gdk_pixbuf_version_minor -ge 31 ; then AC_MSG_RESULT([OK.]) AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no) AC_MSG_CHECKING([glib-compile-resources]) if test "x$GLIB_COMPILE_RESOURCES" = xno ; then - AC_MSG_RESULT([cannot be found in PATH.]) + GLIB_COMPILE_RESOURCES="" + AC_MSG_RESULT([cannot be found in PATH.]) else AC_MSG_RESULT([usable.]) - AC_DEFINE(USE_GRESOURCE) - GRESOURCE_SRC="auto/gui_gtk_gresources.c" - GRESOURCE_OBJ="objects/gui_gtk_gresources.o" + AC_DEFINE(USE_GRESOURCE) + GRESOURCE_SRC="auto/gui_gtk_gresources.c" + GRESOURCE_OBJ="objects/gui_gtk_gresources.o" fi else AC_MSG_RESULT([not usable.]) diff --git a/src/version.c b/src/version.c index 2e876b09c6..2909149066 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1390, /**/ 1389, /**/ From 4db20ab091330e460f08651d6052afd0536c507a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 21:48:30 +0100 Subject: [PATCH 06/12] patch 7.4.1391 Problem: Warning for uninitialzed variable. Solution: Set it to zero. (Christian Brabandt) --- src/eval.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 0a12ff9d4b..1a569bef15 100644 --- a/src/eval.c +++ b/src/eval.c @@ -9489,7 +9489,7 @@ f_asin(typval_T *argvars, typval_T *rettv) static void f_atan(typval_T *argvars, typval_T *rettv) { - float_T f; + float_T f = 0.0; rettv->v_type = VAR_FLOAT; if (get_float_arg(argvars, &f) == OK) diff --git a/src/version.c b/src/version.c index 2909149066..7af412b03b 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1391, /**/ 1390, /**/ From 2cd5bb2505acc001933e97cf788f473f8db60895 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 22:05:32 +0100 Subject: [PATCH 07/12] patch 7.4.1392 Problem: Some tests fail for Win32 console version. Solution: Move the tests to SCRIPTS_MORE2. Pass VIMRUNTIME. (Christian Brabandt) --- src/testdir/Make_all.mak | 6 +++--- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index bb92904bf0..3e645e7ed5 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -15,7 +15,6 @@ SCRIPTS_ALL = \ test7.out \ test8.out \ test9.out \ - test13.out \ test14.out \ test15.out \ test18.out \ @@ -104,7 +103,6 @@ SCRIPTS_ALL = \ test_insertcount.out \ test_listchars.out \ test_listlbr.out \ - test_listlbr_utf8.out \ test_mapping.out \ test_marks.out \ test_match_conceal.out \ @@ -135,9 +133,11 @@ SCRIPTS_MORE2 = \ test2.out \ test10.out \ test12.out \ + test13.out \ test25.out \ test49.out \ - test97.out + test97.out \ + test_listlbr_utf8.out # Tests that run on most systems, but not MingW and Cygwin. diff --git a/src/version.c b/src/version.c index 7af412b03b..b545581842 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1392, /**/ 1391, /**/ From bd73ae1bc63a3b0187ffe7fc8f0caee5a4eb66fa Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 22:19:22 +0100 Subject: [PATCH 08/12] patch 7.4.1393 Problem: Starting a job hangs in the GUI. (Takuya Fujiwara) Solution: Don't check if ch_job is NULL when checking for an error. (Yasuhiro Matsumoto) --- src/channel.c | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/channel.c b/src/channel.c index aa97088b40..f189ac043f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1706,9 +1706,9 @@ channel_read(channel_T *channel, int part, char *func) } #endif - /* Reading a socket disconnection (readlen == 0), or a socket error. + /* Reading a disconnection (readlen == 0), or an error. * TODO: call error callback. */ - if (readlen <= 0 && channel->ch_job == NULL) + if (readlen <= 0) { /* Queue a "DETACH" netbeans message in the command queue in order to * terminate the netbeans session later. Do not end the session here diff --git a/src/version.c b/src/version.c index b545581842..15409a6b33 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1393, /**/ 1392, /**/ From 0b962473ddc7cee3cb45253dea273573bcca9bf9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 22:51:33 +0100 Subject: [PATCH 09/12] patch 7.4.1394 Problem: Can't sort inside a sort function. Solution: Use a struct to store the sort parameters. (Jacob Niehus) --- src/eval.c | 134 +++++++++++++++++++++----------------- src/testdir/test_sort.vim | 14 ++++ src/version.c | 2 + 3 files changed, 91 insertions(+), 59 deletions(-) diff --git a/src/eval.c b/src/eval.c index 1a569bef15..bf3bcb948c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -18790,16 +18790,21 @@ typedef struct int idx; } sortItem_T; -static int item_compare_ic; -static int item_compare_numeric; -static int item_compare_numbers; +/* struct storing information about current sort */ +typedef struct +{ + int item_compare_ic; + int item_compare_numeric; + int item_compare_numbers; #ifdef FEAT_FLOAT -static int item_compare_float; + int item_compare_float; #endif -static char_u *item_compare_func; -static dict_T *item_compare_selfdict; -static int item_compare_func_err; -static int item_compare_keep_zero; + char_u *item_compare_func; + dict_T *item_compare_selfdict; + int item_compare_func_err; + int item_compare_keep_zero; +} sortinfo_T; +static sortinfo_T *sortinfo = NULL; static void do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort); #define ITEM_COMPARE_FAIL 999 @@ -18825,7 +18830,7 @@ item_compare(const void *s1, const void *s2) tv1 = &si1->item->li_tv; tv2 = &si2->item->li_tv; - if (item_compare_numbers) + if (sortinfo->item_compare_numbers) { long v1 = get_tv_number(tv1); long v2 = get_tv_number(tv2); @@ -18834,7 +18839,7 @@ item_compare(const void *s1, const void *s2) } #ifdef FEAT_FLOAT - if (item_compare_float) + if (sortinfo->item_compare_float) { float_T v1 = get_tv_float(tv1); float_T v2 = get_tv_float(tv2); @@ -18848,7 +18853,7 @@ item_compare(const void *s1, const void *s2) * non-string to do what the docs promise. */ if (tv1->v_type == VAR_STRING) { - if (tv2->v_type != VAR_STRING || item_compare_numeric) + if (tv2->v_type != VAR_STRING || sortinfo->item_compare_numeric) p1 = (char_u *)"'"; else p1 = tv1->vval.v_string; @@ -18857,7 +18862,7 @@ item_compare(const void *s1, const void *s2) p1 = tv2string(tv1, &tofree1, numbuf1, 0); if (tv2->v_type == VAR_STRING) { - if (tv1->v_type != VAR_STRING || item_compare_numeric) + if (tv1->v_type != VAR_STRING || sortinfo->item_compare_numeric) p2 = (char_u *)"'"; else p2 = tv2->vval.v_string; @@ -18868,9 +18873,9 @@ item_compare(const void *s1, const void *s2) p1 = (char_u *)""; if (p2 == NULL) p2 = (char_u *)""; - if (!item_compare_numeric) + if (!sortinfo->item_compare_numeric) { - if (item_compare_ic) + if (sortinfo->item_compare_ic) res = STRICMP(p1, p2); else res = STRCMP(p1, p2); @@ -18885,7 +18890,7 @@ item_compare(const void *s1, const void *s2) /* When the result would be zero, compare the item indexes. Makes the * sort stable. */ - if (res == 0 && !item_compare_keep_zero) + if (res == 0 && !sortinfo->item_compare_keep_zero) res = si1->idx > si2->idx ? 1 : -1; vim_free(tofree1); @@ -18906,7 +18911,7 @@ item_compare2(const void *s1, const void *s2) int dummy; /* shortcut after failure in previous call; compare all items equal */ - if (item_compare_func_err) + if (sortinfo->item_compare_func_err) return 0; si1 = (sortItem_T *)s1; @@ -18918,23 +18923,24 @@ item_compare2(const void *s1, const void *s2) copy_tv(&si2->item->li_tv, &argv[1]); rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */ - res = call_func(item_compare_func, (int)STRLEN(item_compare_func), + res = call_func(sortinfo->item_compare_func, + (int)STRLEN(sortinfo->item_compare_func), &rettv, 2, argv, 0L, 0L, &dummy, TRUE, - item_compare_selfdict); + sortinfo->item_compare_selfdict); clear_tv(&argv[0]); clear_tv(&argv[1]); if (res == FAIL) res = ITEM_COMPARE_FAIL; else - res = get_tv_number_chk(&rettv, &item_compare_func_err); - if (item_compare_func_err) + res = get_tv_number_chk(&rettv, &sortinfo->item_compare_func_err); + if (sortinfo->item_compare_func_err) res = ITEM_COMPARE_FAIL; /* return value has wrong type */ clear_tv(&rettv); /* When the result would be zero, compare the pointers themselves. Makes * the sort stable. */ - if (res == 0 && !item_compare_keep_zero) + if (res == 0 && !sortinfo->item_compare_keep_zero) res = si1->idx > si2->idx ? 1 : -1; return res; @@ -18949,9 +18955,16 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) list_T *l; listitem_T *li; sortItem_T *ptrs; + sortinfo_T *old_sortinfo; + sortinfo_T info; long len; long i; + /* Pointer to current info struct used in compare function. Save and + * restore the current one for nested calls. */ + old_sortinfo = sortinfo; + sortinfo = &info; + if (argvars[0].v_type != VAR_LIST) EMSG2(_(e_listarg), sort ? "sort()" : "uniq()"); else @@ -18960,62 +18973,62 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) if (l == NULL || tv_check_lock(l->lv_lock, (char_u *)(sort ? N_("sort() argument") : N_("uniq() argument")), TRUE)) - return; + goto theend; rettv->vval.v_list = l; rettv->v_type = VAR_LIST; ++l->lv_refcount; len = list_len(l); if (len <= 1) - return; /* short list sorts pretty quickly */ + goto theend; /* short list sorts pretty quickly */ - item_compare_ic = FALSE; - item_compare_numeric = FALSE; - item_compare_numbers = FALSE; + info.item_compare_ic = FALSE; + info.item_compare_numeric = FALSE; + info.item_compare_numbers = FALSE; #ifdef FEAT_FLOAT - item_compare_float = FALSE; + info.item_compare_float = FALSE; #endif - item_compare_func = NULL; - item_compare_selfdict = NULL; + info.item_compare_func = NULL; + info.item_compare_selfdict = NULL; if (argvars[1].v_type != VAR_UNKNOWN) { /* optional second argument: {func} */ if (argvars[1].v_type == VAR_FUNC) - item_compare_func = argvars[1].vval.v_string; + info.item_compare_func = argvars[1].vval.v_string; else { int error = FALSE; i = get_tv_number_chk(&argvars[1], &error); if (error) - return; /* type error; errmsg already given */ + goto theend; /* type error; errmsg already given */ if (i == 1) - item_compare_ic = TRUE; + info.item_compare_ic = TRUE; else - item_compare_func = get_tv_string(&argvars[1]); - if (item_compare_func != NULL) + info.item_compare_func = get_tv_string(&argvars[1]); + if (info.item_compare_func != NULL) { - if (STRCMP(item_compare_func, "n") == 0) + if (STRCMP(info.item_compare_func, "n") == 0) { - item_compare_func = NULL; - item_compare_numeric = TRUE; + info.item_compare_func = NULL; + info.item_compare_numeric = TRUE; } - else if (STRCMP(item_compare_func, "N") == 0) + else if (STRCMP(info.item_compare_func, "N") == 0) { - item_compare_func = NULL; - item_compare_numbers = TRUE; + info.item_compare_func = NULL; + info.item_compare_numbers = TRUE; } #ifdef FEAT_FLOAT - else if (STRCMP(item_compare_func, "f") == 0) + else if (STRCMP(info.item_compare_func, "f") == 0) { - item_compare_func = NULL; - item_compare_float = TRUE; + info.item_compare_func = NULL; + info.item_compare_float = TRUE; } #endif - else if (STRCMP(item_compare_func, "i") == 0) + else if (STRCMP(info.item_compare_func, "i") == 0) { - item_compare_func = NULL; - item_compare_ic = TRUE; + info.item_compare_func = NULL; + info.item_compare_ic = TRUE; } } } @@ -19026,16 +19039,16 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) if (argvars[2].v_type != VAR_DICT) { EMSG(_(e_dictreq)); - return; + goto theend; } - item_compare_selfdict = argvars[2].vval.v_dict; + info.item_compare_selfdict = argvars[2].vval.v_dict; } } /* Make an array with each entry pointing to an item in the List. */ ptrs = (sortItem_T *)alloc((int)(len * sizeof(sortItem_T))); if (ptrs == NULL) - return; + goto theend; i = 0; if (sort) @@ -19048,10 +19061,10 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) ++i; } - item_compare_func_err = FALSE; - item_compare_keep_zero = FALSE; + info.item_compare_func_err = FALSE; + info.item_compare_keep_zero = FALSE; /* test the compare function */ - if (item_compare_func != NULL + if (info.item_compare_func != NULL && item_compare2((void *)&ptrs[0], (void *)&ptrs[1]) == ITEM_COMPARE_FAIL) EMSG(_("E702: Sort compare function failed")); @@ -19059,9 +19072,10 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) { /* Sort the array with item pointers. */ qsort((void *)ptrs, (size_t)len, sizeof(sortItem_T), - item_compare_func == NULL ? item_compare : item_compare2); + info.item_compare_func == NULL + ? item_compare : item_compare2); - if (!item_compare_func_err) + if (!info.item_compare_func_err) { /* Clear the List and append the items in sorted order. */ l->lv_first = l->lv_last = l->lv_idx_item = NULL; @@ -19076,9 +19090,9 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) int (*item_compare_func_ptr)(const void *, const void *); /* f_uniq(): ptrs will be a stack of items to remove */ - item_compare_func_err = FALSE; - item_compare_keep_zero = TRUE; - item_compare_func_ptr = item_compare_func + info.item_compare_func_err = FALSE; + info.item_compare_keep_zero = TRUE; + item_compare_func_ptr = info.item_compare_func ? item_compare2 : item_compare; for (li = l->lv_first; li != NULL && li->li_next != NULL; @@ -19087,14 +19101,14 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) if (item_compare_func_ptr((void *)&li, (void *)&li->li_next) == 0) ptrs[i++].item = li; - if (item_compare_func_err) + if (info.item_compare_func_err) { EMSG(_("E882: Uniq compare function failed")); break; } } - if (!item_compare_func_err) + if (!info.item_compare_func_err) { while (--i >= 0) { @@ -19113,6 +19127,8 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) vim_free(ptrs); } +theend: + sortinfo = old_sortinfo; } /* diff --git a/src/testdir/test_sort.vim b/src/testdir/test_sort.vim index 32ad7f8ad5..68021f6de6 100644 --- a/src/testdir/test_sort.vim +++ b/src/testdir/test_sort.vim @@ -1,5 +1,14 @@ " Test sort() +:func Compare1(a, b) abort + call sort(range(3), 'Compare2') + return a:a ># a:b +:endfunc + +:func Compare2(a, b) abort + return a:a <# a:b +:endfunc + func Test_sort_strings() " numbers compared as strings call assert_equal([1, 2, 3], sort([3, 2, 1])) @@ -21,3 +30,8 @@ endfunc func Test_sort_float() call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) endfunc + +func Test_sort_nested() + " test ability to call sort() from a compare function + call assert_equal([1, 3, 5], sort([3, 1, 5], 'Compare1')) +endfunc diff --git a/src/version.c b/src/version.c index 15409a6b33..39b76438f0 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1394, /**/ 1393, /**/ From eed284a16977ab81fa6da8c9562990ba498acd8c Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 23:13:33 +0100 Subject: [PATCH 10/12] patch 7.4.1395 Problem: Using DETACH in quotes is not compatible with the Netbeans interface. (Xavier de Gaye) Solution: Remove the quotes, only use them for JSON and JS mode. --- src/channel.c | 10 +++++++--- src/netbeans.c | 2 +- src/version.c | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/channel.c b/src/channel.c index f189ac043f..71fd4b687b 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1554,7 +1554,8 @@ channel_free_all(void) /* Sent when the channel is found closed when reading. */ -#define DETACH_MSG "\"DETACH\"\n" +#define DETACH_MSG_RAW "DETACH\n" +#define DETACH_MSG_JSON "\"DETACH\"\n" /* Buffer size for reading incoming messages. */ #define MAXMSGSIZE 4096 @@ -1658,6 +1659,7 @@ channel_read(channel_T *channel, int part, char *func) int readlen = 0; sock_T fd; int use_socket = FALSE; + char *msg; fd = channel->ch_part[part].ch_fd; if (fd == INVALID_FD) @@ -1721,8 +1723,10 @@ channel_read(channel_T *channel, int part, char *func) * -> channel_read() */ ch_errors(channel, "%s(): Cannot read", func); - channel_save(channel, part, - (char_u *)DETACH_MSG, (int)STRLEN(DETACH_MSG)); + msg = channel->ch_part[part].ch_mode == MODE_RAW + || channel->ch_part[part].ch_mode == MODE_NL + ? DETACH_MSG_RAW : DETACH_MSG_JSON; + channel_save(channel, part, (char_u *)msg, (int)STRLEN(msg)); /* TODO: When reading from stdout is not possible, should we try to * keep stdin and stderr open? Probably not, assume the other side diff --git a/src/netbeans.c b/src/netbeans.c index 55169ea2a8..05142a8b0e 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -461,7 +461,7 @@ nb_parse_cmd(char_u *cmd) /* NOTREACHED */ } - if (STRCMP(cmd, "\"DETACH\"") == 0) + if (STRCMP(cmd, "DETACH") == 0) { buf_T *buf; diff --git a/src/version.c b/src/version.c index 39b76438f0..d028ca54a6 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1395, /**/ 1394, /**/ From 1daae446e58fd90f98c51ff3af8f54bfa5197751 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 23:25:25 +0100 Subject: [PATCH 11/12] patch 7.4.1396 Problem: Compiler warnings for conversions. Solution: Add type cast. --- src/ex_cmds2.c | 6 +++--- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 9601409a71..e105fa00ba 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3087,8 +3087,8 @@ source_pack_plugin(char_u *fname, void *cookie UNUSED) if (strstr((char *)p_rtp, (char *)fname) == NULL) { /* directory not in 'runtimepath', add it */ - oldlen = STRLEN(p_rtp); - addlen = STRLEN(fname); + oldlen = (int)STRLEN(p_rtp); + addlen = (int)STRLEN(fname); new_rtp = alloc(oldlen + addlen + 2); if (new_rtp == NULL) { @@ -3130,7 +3130,7 @@ ex_loadplugin(exarg_T *eap) int len; char *pat; - len = STRLEN(pattern) + STRLEN(eap->arg); + len = (int)STRLEN(pattern) + (int)STRLEN(eap->arg); pat = (char *)alloc(len); if (pat == NULL) return; diff --git a/src/version.c b/src/version.c index d028ca54a6..a476aaee5f 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1396, /**/ 1395, /**/ From 0bb6108eb4e1ecaed437bc507f514f5da7816d9e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Feb 2016 23:50:28 +0100 Subject: [PATCH 12/12] patch 7.4.1397 Problem: Sort test fails on MS-Windows. Solution: Correct the compare function. --- src/testdir/test_sort.vim | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/testdir/test_sort.vim b/src/testdir/test_sort.vim index 68021f6de6..2b097ceb96 100644 --- a/src/testdir/test_sort.vim +++ b/src/testdir/test_sort.vim @@ -2,11 +2,11 @@ :func Compare1(a, b) abort call sort(range(3), 'Compare2') - return a:a ># a:b + return a:a - a:b :endfunc :func Compare2(a, b) abort - return a:a <# a:b + return a:a - a:b :endfunc func Test_sort_strings() diff --git a/src/version.c b/src/version.c index a476aaee5f..b8cd111335 100644 --- a/src/version.c +++ b/src/version.c @@ -748,6 +748,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1397, /**/ 1396, /**/