Skip to content

Commit bc8e950

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents bf290ef + 10b369f commit bc8e950

File tree

12 files changed

+195
-34
lines changed

12 files changed

+195
-34
lines changed

src/auto/configure

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11969,7 +11969,7 @@ for ac_func in bcmp fchdir fchown fsync getcwd getpseudotty \
1196911969
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
1197011970
sigvec strcasecmp strerror strftime stricmp strncasecmp \
1197111971
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
11972-
usleep utime utimes isnan isinf
11972+
usleep utime utimes
1197311973
do :
1197411974
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1197511975
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -12490,6 +12490,70 @@ if ac_fn_c_try_link "$LINENO"; then :
1249012490
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1249112491
$as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT_FUNCS 1" >>confdefs.h
1249212492

12493+
else
12494+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12495+
$as_echo "no" >&6; }
12496+
fi
12497+
rm -f core conftest.err conftest.$ac_objext \
12498+
conftest$ac_exeext conftest.$ac_ext
12499+
12500+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf()" >&5
12501+
$as_echo_n "checking for isinf()... " >&6; }
12502+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12503+
/* end confdefs.h. */
12504+
12505+
#ifdef HAVE_MATH_H
12506+
# include <math.h>
12507+
#endif
12508+
#if STDC_HEADERS
12509+
# include <stdlib.h>
12510+
# include <stddef.h>
12511+
#endif
12512+
12513+
int
12514+
main ()
12515+
{
12516+
int r = isinf(1.11);
12517+
;
12518+
return 0;
12519+
}
12520+
_ACEOF
12521+
if ac_fn_c_try_link "$LINENO"; then :
12522+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12523+
$as_echo "yes" >&6; }; $as_echo "#define HAVE_ISINF 1" >>confdefs.h
12524+
12525+
else
12526+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
12527+
$as_echo "no" >&6; }
12528+
fi
12529+
rm -f core conftest.err conftest.$ac_objext \
12530+
conftest$ac_exeext conftest.$ac_ext
12531+
12532+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isnan()" >&5
12533+
$as_echo_n "checking for isnan()... " >&6; }
12534+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12535+
/* end confdefs.h. */
12536+
12537+
#ifdef HAVE_MATH_H
12538+
# include <math.h>
12539+
#endif
12540+
#if STDC_HEADERS
12541+
# include <stdlib.h>
12542+
# include <stddef.h>
12543+
#endif
12544+
12545+
int
12546+
main ()
12547+
{
12548+
int r = isnan(1.11);
12549+
;
12550+
return 0;
12551+
}
12552+
_ACEOF
12553+
if ac_fn_c_try_link "$LINENO"; then :
12554+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
12555+
$as_echo "yes" >&6; }; $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
12556+
1249312557
else
1249412558
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1249512559
$as_echo "no" >&6; }

src/channel.c

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,9 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
945945

946946
if ((opt->jo_set & JO_OUT_IO) && opt->jo_io[PART_OUT] == JIO_BUFFER)
947947
{
948-
/* writing output to a buffer. Force mode to NL. */
949-
channel->ch_part[PART_OUT].ch_mode = MODE_NL;
948+
/* writing output to a buffer. Default mode is NL. */
949+
if (!(opt->jo_set & JO_OUT_MODE))
950+
channel->ch_part[PART_OUT].ch_mode = MODE_NL;
950951
channel->ch_part[PART_OUT].ch_buffer =
951952
find_buffer(opt->jo_io_name[PART_OUT]);
952953
ch_logs(channel, "writing to buffer '%s'",
@@ -1579,32 +1580,38 @@ may_invoke_callback(channel_T *channel, int part)
15791580
u_sync(TRUE);
15801581
u_save(lnum, lnum + 1);
15811582

1582-
ml_append(lnum, msg, 0, FALSE);
1583-
appended_lines_mark(lnum, 1L);
1584-
curbuf = save_curbuf;
1585-
1586-
if (buffer->b_nwindows > 0)
1583+
if (msg == NULL)
1584+
/* JSON or JS mode: re-encode the message. */
1585+
msg = json_encode(listtv, ch_mode);
1586+
if (msg != NULL)
15871587
{
1588-
win_T *wp;
1589-
win_T *save_curwin;
1588+
ml_append(lnum, msg, 0, FALSE);
1589+
appended_lines_mark(lnum, 1L);
1590+
curbuf = save_curbuf;
15901591

1591-
FOR_ALL_WINDOWS(wp)
1592+
if (buffer->b_nwindows > 0)
15921593
{
1593-
if (wp->w_buffer == buffer
1594-
&& wp->w_cursor.lnum == lnum
1595-
&& wp->w_cursor.col == 0)
1594+
win_T *wp;
1595+
win_T *save_curwin;
1596+
1597+
FOR_ALL_WINDOWS(wp)
15961598
{
1597-
++wp->w_cursor.lnum;
1598-
save_curwin = curwin;
1599-
curwin = wp;
1600-
curbuf = curwin->w_buffer;
1601-
scroll_cursor_bot(0, FALSE);
1602-
curwin = save_curwin;
1603-
curbuf = curwin->w_buffer;
1599+
if (wp->w_buffer == buffer
1600+
&& wp->w_cursor.lnum == lnum
1601+
&& wp->w_cursor.col == 0)
1602+
{
1603+
++wp->w_cursor.lnum;
1604+
save_curwin = curwin;
1605+
curwin = wp;
1606+
curbuf = curwin->w_buffer;
1607+
scroll_cursor_bot(0, FALSE);
1608+
curwin = save_curwin;
1609+
curbuf = curwin->w_buffer;
1610+
}
16041611
}
1612+
redraw_buf_later(buffer, VALID);
1613+
channel_need_redraw = TRUE;
16051614
}
1606-
redraw_buf_later(buffer, VALID);
1607-
channel_need_redraw = TRUE;
16081615
}
16091616
}
16101617
if (callback != NULL)
@@ -1614,8 +1621,6 @@ may_invoke_callback(channel_T *channel, int part)
16141621
invoke_callback(channel, callback, argv);
16151622
}
16161623
}
1617-
else if (msg != NULL)
1618-
ch_logs(channel, "Dropping message '%s'", (char *)msg);
16191624
else
16201625
ch_log(channel, "Dropping message");
16211626

src/configure.in

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3639,7 +3639,7 @@ AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
36393639
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
36403640
sigvec strcasecmp strerror strftime stricmp strncasecmp \
36413641
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
3642-
usleep utime utimes isnan isinf)
3642+
usleep utime utimes)
36433643
AC_FUNC_FSEEKO
36443644

36453645
dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when
@@ -3742,6 +3742,33 @@ AC_TRY_LINK([
37423742
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT_FUNCS),
37433743
AC_MSG_RESULT(no))
37443744

3745+
dnl isinf() and isnan() need to include header files and may need -lm.
3746+
AC_MSG_CHECKING([for isinf()])
3747+
AC_TRY_LINK([
3748+
#ifdef HAVE_MATH_H
3749+
# include <math.h>
3750+
#endif
3751+
#if STDC_HEADERS
3752+
# include <stdlib.h>
3753+
# include <stddef.h>
3754+
#endif
3755+
], [int r = isinf(1.11); ],
3756+
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISINF),
3757+
AC_MSG_RESULT(no))
3758+
3759+
AC_MSG_CHECKING([for isnan()])
3760+
AC_TRY_LINK([
3761+
#ifdef HAVE_MATH_H
3762+
# include <math.h>
3763+
#endif
3764+
#if STDC_HEADERS
3765+
# include <stdlib.h>
3766+
# include <stddef.h>
3767+
#endif
3768+
], [int r = isnan(1.11); ],
3769+
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ISNAN),
3770+
AC_MSG_RESULT(no))
3771+
37453772
dnl Link with -lposix1e for ACL stuff; if not found, try -lacl for SGI
37463773
dnl when -lacl works, also try to use -lattr (required for Debian).
37473774
dnl On Solaris, use the acl_get/set functions in libsec, if present.

src/eval.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8415,7 +8415,9 @@ static struct fst
84158415
{"range", 1, 3, f_range},
84168416
{"readfile", 1, 3, f_readfile},
84178417
{"reltime", 0, 2, f_reltime},
8418+
#ifdef FEAT_FLOAT
84188419
{"reltimefloat", 1, 1, f_reltimefloat},
8420+
#endif
84198421
{"reltimestr", 1, 1, f_reltimestr},
84208422
{"remote_expr", 2, 3, f_remote_expr},
84218423
{"remote_foreground", 1, 1, f_remote_foreground},
@@ -15156,7 +15158,8 @@ f_job_start(typval_T *argvars UNUSED, typval_T *rettv)
1515615158
#ifdef USE_ARGV
1515715159
argv[argc++] = (char *)s;
1515815160
#else
15159-
if (li != l->lv_first)
15161+
/* Only escape when needed, double quotes are not always allowed. */
15162+
if (li != l->lv_first && vim_strpbrk(s, (char_u *)" \t\"") != NULL)
1516015163
{
1516115164
s = vim_strsave_shellescape(s, FALSE, TRUE);
1516215165
if (s == NULL)
@@ -19221,11 +19224,21 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort)
1922119224
goto theend; /* type error; errmsg already given */
1922219225
if (i == 1)
1922319226
info.item_compare_ic = TRUE;
19224-
else
19227+
else if (argvars[1].v_type != VAR_NUMBER)
1922519228
info.item_compare_func = get_tv_string(&argvars[1]);
19229+
else if (i != 0)
19230+
{
19231+
EMSG(_(e_invarg));
19232+
goto theend;
19233+
}
1922619234
if (info.item_compare_func != NULL)
1922719235
{
19228-
if (STRCMP(info.item_compare_func, "n") == 0)
19236+
if (*info.item_compare_func == NUL)
19237+
{
19238+
/* empty string means default sort */
19239+
info.item_compare_func = NULL;
19240+
}
19241+
else if (STRCMP(info.item_compare_func, "n") == 0)
1922919242
{
1923019243
info.item_compare_func = NULL;
1923119244
info.item_compare_numeric = TRUE;

src/json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,9 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
733733
default:
734734
if (VIM_ISDIGIT(*p) || *p == '-')
735735
{
736+
#ifdef FEAT_FLOAT
736737
char_u *sp = p;
737738

738-
#ifdef FEAT_FLOAT
739739
if (*sp == '-')
740740
{
741741
++sp;

src/misc2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,13 +1729,14 @@ vim_memcmp(void *b1, void *b2, size_t len)
17291729
}
17301730
#endif
17311731

1732+
/* skipped when generating prototypes, the prototype is in vim.h */
17321733
#ifdef VIM_MEMMOVE
17331734
/*
17341735
* Version of memmove() that handles overlapping source and destination.
17351736
* For systems that don't have a function that is guaranteed to do that (SYSV).
17361737
*/
17371738
void
1738-
mch_memmove(void *src_arg, *dst_arg, size_t len)
1739+
mch_memmove(void *src_arg, void *dst_arg, size_t len)
17391740
{
17401741
/*
17411742
* A void doesn't have a size, we use char pointers.

src/os_unix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6476,14 +6476,14 @@ have_dollars(int num, char_u **file)
64766476
}
64776477
#endif /* ifndef __EMX__ */
64786478

6479-
#ifndef HAVE_RENAME
6479+
#if !defined(HAVE_RENAME) || defined(PROTO)
64806480
/*
64816481
* Scaled-down version of rename(), which is missing in Xenix.
64826482
* This version can only move regular files and will fail if the
64836483
* destination exists.
64846484
*/
64856485
int
6486-
mch_rename(const char *src, *dest)
6486+
mch_rename(const char *src, const char *dest)
64876487
{
64886488
struct stat st;
64896489

src/proto/os_unix.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ int mch_expandpath(garray_T *gap, char_u *path, int flags);
6666
int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags);
6767
int mch_has_exp_wildcard(char_u *p);
6868
int mch_has_wildcard(char_u *p);
69+
int mch_rename(const char *src, const char *dest);
6970
int mch_libcall(char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result);
7071
void setup_term_clip(void);
7172
void start_xterm_trace(int button);

src/termlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ tgetent(
140140
}
141141

142142
static int
143-
getent(char *tbuf, *term, FILE *termcap, int buflen)
143+
getent(char *tbuf, char *term, FILE *termcap, int buflen)
144144
{
145145
char *tptr;
146146
int tlen = strlen(term);

src/testdir/test_channel.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,32 @@ func Test_pipe_to_nameless_buffer()
426426
endtry
427427
endfunc
428428

429+
func Test_pipe_to_buffer_json()
430+
if !has('job')
431+
return
432+
endif
433+
call ch_log('Test_pipe_to_buffer_json()')
434+
let job = job_start(s:python . " test_channel_pipe.py",
435+
\ {'out-io': 'buffer', 'out-mode': 'json'})
436+
call assert_equal("run", job_status(job))
437+
try
438+
let handle = job_getchannel(job)
439+
call ch_sendraw(handle, "echo [0, \"hello\"]\n")
440+
call ch_sendraw(handle, "echo [-2, 12.34]\n")
441+
exe ch_getbufnr(handle, "out") . 'sbuf'
442+
for i in range(100)
443+
sleep 10m
444+
if line('$') >= 3
445+
break
446+
endif
447+
endfor
448+
call assert_equal(['Reading from channel output...', '[0,"hello"]', '[-2,12.34]'], getline(1, '$'))
449+
bwipe!
450+
finally
451+
call job_stop(job)
452+
endtry
453+
endfunc
454+
429455
""""""""""
430456

431457
let s:unletResponse = ''

src/testdir/test_sort.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,11 @@ func Test_sort_nested()
3535
" test ability to call sort() from a compare function
3636
call assert_equal([1, 3, 5], sort([3, 1, 5], 'Compare1'))
3737
endfunc
38+
39+
func Test_sort_default()
40+
" docs say omitted, empty or zero argument sorts on string representation.
41+
call assert_equal(["2", 1, 3.3], sort([3.3, 1, "2"]))
42+
call assert_equal(["2", 1, 3.3], sort([3.3, 1, "2"], ''))
43+
call assert_equal(["2", 1, 3.3], sort([3.3, 1, "2"], 0))
44+
call assert_fails('call sort([3.3, 1, "2"], 3)', "E474")
45+
endfunc

src/version.c

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

759759
static int included_patches[] =
760760
{ /* Add new patch number below this line */
761+
/**/
762+
1467,
763+
/**/
764+
1466,
765+
/**/
766+
1465,
767+
/**/
768+
1464,
769+
/**/
770+
1463,
771+
/**/
772+
1462,
773+
/**/
774+
1461,
775+
/**/
776+
1460,
761777
/**/
762778
1459,
763779
/**/

0 commit comments

Comments
 (0)