diff --git a/src/auto/configure b/src/auto/configure index 39986d946a..3ac3a48a5e 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -11969,7 +11969,7 @@ for ac_func in bcmp fchdir fchown fsync getcwd getpseudotty \ setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ sigvec strcasecmp strerror strftime stricmp strncasecmp \ strnicmp strpbrk strtol tgetent towlower towupper iswupper \ - usleep utime utimes isnan isinf + usleep utime utimes do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -12490,6 +12490,70 @@ if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT_FUNCS 1" >>confdefs.h +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf()" >&5 +$as_echo_n "checking for isinf()... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_MATH_H +# include +#endif +#if STDC_HEADERS +# include +# include +#endif + +int +main () +{ +int r = isinf(1.11); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_ISINF 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isnan()" >&5 +$as_echo_n "checking for isnan()... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_MATH_H +# include +#endif +#if STDC_HEADERS +# include +# include +#endif + +int +main () +{ +int r = isnan(1.11); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_ISNAN 1" >>confdefs.h + else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } diff --git a/src/channel.c b/src/channel.c index ecf967696c..0918d9cf62 100644 --- a/src/channel.c +++ b/src/channel.c @@ -945,8 +945,9 @@ channel_set_options(channel_T *channel, jobopt_T *opt) if ((opt->jo_set & JO_OUT_IO) && opt->jo_io[PART_OUT] == JIO_BUFFER) { - /* writing output to a buffer. Force mode to NL. */ - channel->ch_part[PART_OUT].ch_mode = MODE_NL; + /* writing output to a buffer. Default mode is NL. */ + if (!(opt->jo_set & JO_OUT_MODE)) + channel->ch_part[PART_OUT].ch_mode = MODE_NL; channel->ch_part[PART_OUT].ch_buffer = find_buffer(opt->jo_io_name[PART_OUT]); ch_logs(channel, "writing to buffer '%s'", @@ -1579,32 +1580,38 @@ may_invoke_callback(channel_T *channel, int part) u_sync(TRUE); u_save(lnum, lnum + 1); - ml_append(lnum, msg, 0, FALSE); - appended_lines_mark(lnum, 1L); - curbuf = save_curbuf; - - if (buffer->b_nwindows > 0) + if (msg == NULL) + /* JSON or JS mode: re-encode the message. */ + msg = json_encode(listtv, ch_mode); + if (msg != NULL) { - win_T *wp; - win_T *save_curwin; + ml_append(lnum, msg, 0, FALSE); + appended_lines_mark(lnum, 1L); + curbuf = save_curbuf; - FOR_ALL_WINDOWS(wp) + if (buffer->b_nwindows > 0) { - if (wp->w_buffer == buffer - && wp->w_cursor.lnum == lnum - && wp->w_cursor.col == 0) + win_T *wp; + win_T *save_curwin; + + FOR_ALL_WINDOWS(wp) { - ++wp->w_cursor.lnum; - save_curwin = curwin; - curwin = wp; - curbuf = curwin->w_buffer; - scroll_cursor_bot(0, FALSE); - curwin = save_curwin; - curbuf = curwin->w_buffer; + if (wp->w_buffer == buffer + && wp->w_cursor.lnum == lnum + && wp->w_cursor.col == 0) + { + ++wp->w_cursor.lnum; + save_curwin = curwin; + curwin = wp; + curbuf = curwin->w_buffer; + scroll_cursor_bot(0, FALSE); + curwin = save_curwin; + curbuf = curwin->w_buffer; + } } + redraw_buf_later(buffer, VALID); + channel_need_redraw = TRUE; } - redraw_buf_later(buffer, VALID); - channel_need_redraw = TRUE; } } if (callback != NULL) @@ -1614,8 +1621,6 @@ may_invoke_callback(channel_T *channel, int part) invoke_callback(channel, callback, argv); } } - else if (msg != NULL) - ch_logs(channel, "Dropping message '%s'", (char *)msg); else ch_log(channel, "Dropping message"); diff --git a/src/configure.in b/src/configure.in index 818c7e1189..6dabf63f7f 100644 --- a/src/configure.in +++ b/src/configure.in @@ -3639,7 +3639,7 @@ AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \ setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ sigvec strcasecmp strerror strftime stricmp strncasecmp \ strnicmp strpbrk strtol tgetent towlower towupper iswupper \ - usleep utime utimes isnan isinf) + usleep utime utimes) AC_FUNC_FSEEKO dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when @@ -3742,6 +3742,33 @@ AC_TRY_LINK([ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS), AC_MSG_RESULT(no)) +dnl isinf() and isnan() need to include header files and may need -lm. +AC_MSG_CHECKING([for isinf()]) +AC_TRY_LINK([ +#ifdef HAVE_MATH_H +# include +#endif +#if STDC_HEADERS +# include +# include +#endif +], [int r = isinf(1.11); ], + AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF), + AC_MSG_RESULT(no)) + +AC_MSG_CHECKING([for isnan()]) +AC_TRY_LINK([ +#ifdef HAVE_MATH_H +# include +#endif +#if STDC_HEADERS +# include +# include +#endif +], [int r = isnan(1.11); ], + AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN), + AC_MSG_RESULT(no)) + dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI dnl when -lacl works, also try to use -lattr (required for Debian). dnl On Solaris, use the acl_get/set functions in libsec, if present. diff --git a/src/eval.c b/src/eval.c index ddf39cf7bc..711a286760 100644 --- a/src/eval.c +++ b/src/eval.c @@ -8415,7 +8415,9 @@ static struct fst {"range", 1, 3, f_range}, {"readfile", 1, 3, f_readfile}, {"reltime", 0, 2, f_reltime}, +#ifdef FEAT_FLOAT {"reltimefloat", 1, 1, f_reltimefloat}, +#endif {"reltimestr", 1, 1, f_reltimestr}, {"remote_expr", 2, 3, f_remote_expr}, {"remote_foreground", 1, 1, f_remote_foreground}, @@ -15156,7 +15158,8 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv) #ifdef USE_ARGV argv[argc++] = (char *)s; #else - if (li != l->lv_first) + /* Only escape when needed, double quotes are not always allowed. */ + if (li != l->lv_first && vim_strpbrk(s, (char_u *)" \t\"") != NULL) { s = vim_strsave_shellescape(s, FALSE, TRUE); if (s == NULL) @@ -19221,11 +19224,21 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) goto theend; /* type error; errmsg already given */ if (i == 1) info.item_compare_ic = TRUE; - else + else if (argvars[1].v_type != VAR_NUMBER) info.item_compare_func = get_tv_string(&argvars[1]); + else if (i != 0) + { + EMSG(_(e_invarg)); + goto theend; + } if (info.item_compare_func != NULL) { - if (STRCMP(info.item_compare_func, "n") == 0) + if (*info.item_compare_func == NUL) + { + /* empty string means default sort */ + info.item_compare_func = NULL; + } + else if (STRCMP(info.item_compare_func, "n") == 0) { info.item_compare_func = NULL; info.item_compare_numeric = TRUE; diff --git a/src/json.c b/src/json.c index cf887e5afd..b41d45ee0f 100644 --- a/src/json.c +++ b/src/json.c @@ -733,9 +733,9 @@ json_decode_item(js_read_T *reader, typval_T *res, int options) default: if (VIM_ISDIGIT(*p) || *p == '-') { +#ifdef FEAT_FLOAT char_u *sp = p; -#ifdef FEAT_FLOAT if (*sp == '-') { ++sp; diff --git a/src/misc2.c b/src/misc2.c index 005032d232..45ee92b1c0 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1729,13 +1729,14 @@ vim_memcmp(void *b1, void *b2, size_t len) } #endif +/* skipped when generating prototypes, the prototype is in vim.h */ #ifdef VIM_MEMMOVE /* * Version of memmove() that handles overlapping source and destination. * For systems that don't have a function that is guaranteed to do that (SYSV). */ void -mch_memmove(void *src_arg, *dst_arg, size_t len) +mch_memmove(void *src_arg, void *dst_arg, size_t len) { /* * A void doesn't have a size, we use char pointers. diff --git a/src/os_unix.c b/src/os_unix.c index 34270f6d06..413cd7e67b 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6476,14 +6476,14 @@ have_dollars(int num, char_u **file) } #endif /* ifndef __EMX__ */ -#ifndef HAVE_RENAME +#if !defined(HAVE_RENAME) || defined(PROTO) /* * Scaled-down version of rename(), which is missing in Xenix. * This version can only move regular files and will fail if the * destination exists. */ int -mch_rename(const char *src, *dest) +mch_rename(const char *src, const char *dest) { struct stat st; diff --git a/src/proto/os_unix.pro b/src/proto/os_unix.pro index 25d25797e1..1d025e8284 100644 --- a/src/proto/os_unix.pro +++ b/src/proto/os_unix.pro @@ -66,6 +66,7 @@ int mch_expandpath(garray_T *gap, char_u *path, int flags); int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags); int mch_has_exp_wildcard(char_u *p); int mch_has_wildcard(char_u *p); +int mch_rename(const char *src, const char *dest); int mch_libcall(char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result); void setup_term_clip(void); void start_xterm_trace(int button); diff --git a/src/termlib.c b/src/termlib.c index 9488a320e4..59eab7d97e 100644 --- a/src/termlib.c +++ b/src/termlib.c @@ -140,7 +140,7 @@ tgetent( } static int -getent(char *tbuf, *term, FILE *termcap, int buflen) +getent(char *tbuf, char *term, FILE *termcap, int buflen) { char *tptr; int tlen = strlen(term); diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 0fded018a3..77949945fb 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -426,6 +426,32 @@ func Test_pipe_to_nameless_buffer() endtry endfunc +func Test_pipe_to_buffer_json() + if !has('job') + return + endif + call ch_log('Test_pipe_to_buffer_json()') + let job = job_start(s:python . " test_channel_pipe.py", + \ {'out-io': 'buffer', 'out-mode': 'json'}) + call assert_equal("run", job_status(job)) + try + let handle = job_getchannel(job) + call ch_sendraw(handle, "echo [0, \"hello\"]\n") + call ch_sendraw(handle, "echo [-2, 12.34]\n") + exe ch_getbufnr(handle, "out") . 'sbuf' + for i in range(100) + sleep 10m + if line('$') >= 3 + break + endif + endfor + call assert_equal(['Reading from channel output...', '[0,"hello"]', '[-2,12.34]'], getline(1, '$')) + bwipe! + finally + call job_stop(job) + endtry +endfunc + """""""""" let s:unletResponse = '' diff --git a/src/testdir/test_sort.vim b/src/testdir/test_sort.vim index 2b097ceb96..819514a971 100644 --- a/src/testdir/test_sort.vim +++ b/src/testdir/test_sort.vim @@ -35,3 +35,11 @@ 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 + +func Test_sort_default() + " docs say omitted, empty or zero argument sorts on string representation. + call assert_equal(["2", 1, 3.3], sort([3.3, 1, "2"])) + call assert_equal(["2", 1, 3.3], sort([3.3, 1, "2"], '')) + call assert_equal(["2", 1, 3.3], sort([3.3, 1, "2"], 0)) + call assert_fails('call sort([3.3, 1, "2"], 3)', "E474") +endfunc diff --git a/src/version.c b/src/version.c index 7f608ffeb5..07cbf2c67f 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,22 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1467, +/**/ + 1466, +/**/ + 1465, +/**/ + 1464, +/**/ + 1463, +/**/ + 1462, +/**/ + 1461, +/**/ + 1460, /**/ 1459, /**/