Merge remote-tracking branch 'vim/master'

This commit is contained in:
Kazuki Sakamoto
2017-01-08 16:41:27 -08:00
16 changed files with 408 additions and 21 deletions
+5 -1
View File
@@ -7561,7 +7561,11 @@ system({expr} [, {input}]) *system()* *E677*
If {input} is given and is a |List| it is written to the file
in a way |writefile()| does with {binary} set to "b" (i.e.
with a newline between each list item with newlines inside
list items converted to NULs).
list items converted to NULs).
When {input} is given and is a number that is a valid id for
an existing buffer then the content of the buffer is written
to the file line by line, each line terminated by a NL and
NULs characters where the text has a NL.
Pipes are not used, the 'shelltemp' option is not used.
+2
View File
@@ -2121,6 +2121,7 @@ test_arglist \
test_fileformat \
test_filter_cmd \
test_filter_map \
test_float_func \
test_fnameescape \
test_fnamemodify \
test_fold \
@@ -2181,6 +2182,7 @@ test_arglist \
test_substitute \
test_syn_attr \
test_syntax \
test_system \
test_tabline \
test_tabpage \
test_tagcase \
+1 -1
View File
@@ -1588,7 +1588,7 @@ invoke_callback(channel_T *channel, char_u *callback, partial_T *partial,
int dummy;
if (safe_to_invoke_callback == 0)
EMSG("INTERNAL: Invoking callback when it is not safe");
IEMSG("INTERNAL: Invoking callback when it is not safe");
argv[0].v_type = VAR_CHANNEL;
argv[0].vval.v_channel = channel;
+17 -1
View File
@@ -270,7 +270,7 @@ eval_init(void)
p = &vimvars[i];
if (STRLEN(p->vv_name) > 16)
{
EMSG("INTERNAL: name too long, increase size of dictitem16_T");
IEMSG("INTERNAL: name too long, increase size of dictitem16_T");
getout(1);
}
STRCPY(p->vv_di.di_key, p->vv_name);
@@ -5971,6 +5971,22 @@ string2float(
char *s = (char *)text;
float_T f;
/* MS-Windows does not deal with "inf" and "nan" properly. */
if (STRNICMP(text, "inf", 3) == 0)
{
*value = INFINITY;
return 3;
}
if (STRNICMP(text, "-inf", 3) == 0)
{
*value = -INFINITY;
return 4;
}
if (STRNICMP(text, "nan", 3) == 0)
{
*value = NAN;
return 3;
}
f = strtod(s, &s);
*value = f;
return (int)((char_u *)s - text);
+31 -4
View File
@@ -11844,7 +11844,6 @@ get_cmd_output_as_rettv(
char_u *res = NULL;
char_u *p;
char_u *infile = NULL;
char_u buf[NUMBUFLEN];
int err = FALSE;
FILE *fd;
list_T *list = NULL;
@@ -11858,7 +11857,7 @@ get_cmd_output_as_rettv(
if (argvars[1].v_type != VAR_UNKNOWN)
{
/*
* Write the string to a temp file, to be used for input of the shell
* Write the text to a temp file, to be used for input of the shell
* command.
*/
if ((infile = vim_tempname('i', TRUE)) == NULL)
@@ -11873,14 +11872,42 @@ get_cmd_output_as_rettv(
EMSG2(_(e_notopen), infile);
goto errret;
}
if (argvars[1].v_type == VAR_LIST)
if (argvars[1].v_type == VAR_NUMBER)
{
linenr_T lnum;
buf_T *buf;
buf = buflist_findnr(argvars[1].vval.v_number);
if (buf == NULL)
{
EMSGN(_(e_nobufnr), argvars[1].vval.v_number);
goto errret;
}
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++)
{
for (p = ml_get_buf(buf, lnum, FALSE); *p != NUL; ++p)
if (putc(*p == '\n' ? NUL : *p, fd) == EOF)
{
err = TRUE;
break;
}
if (putc(NL, fd) == EOF)
{
err = TRUE;
break;
}
}
}
else if (argvars[1].v_type == VAR_LIST)
{
if (write_list(fd, argvars[1].vval.v_list, TRUE) == FAIL)
err = TRUE;
}
else
{
size_t len;
size_t len;
char_u buf[NUMBUFLEN];
p = get_tv_string_buf_chk(&argvars[1], buf);
if (p == NULL)
+2
View File
@@ -772,7 +772,9 @@ getcmdline(
/*
* Open a window to edit the command line (and history).
*/
save_cmdline(&save_ccline);
c = ex_window();
restore_cmdline(&save_ccline);
some_key_typed = TRUE;
}
}
+4 -4
View File
@@ -1359,7 +1359,7 @@ nfa_regatom(void)
rc_did_emsg = TRUE;
return FAIL;
}
EMSGN("INTERNAL: Unknown character class char: %ld", c);
IEMSGN("INTERNAL: Unknown character class char: %ld", c);
return FAIL;
}
#ifdef FEAT_MBYTE
@@ -4925,7 +4925,7 @@ check_char_class(int class, int c)
default:
/* should not be here :P */
EMSGN(_(e_ill_char_class), class);
IEMSGN(_(e_ill_char_class), class);
return FAIL;
}
return FAIL;
@@ -6688,7 +6688,7 @@ nfa_regmatch(
#ifdef DEBUG
if (c < 0)
EMSGN("INTERNAL: Negative state char: %ld", c);
IEMSGN("INTERNAL: Negative state char: %ld", c);
#endif
result = (c == curc);
@@ -7216,7 +7216,7 @@ nfa_regcomp(char_u *expr, int re_flags)
{
/* TODO: only give this error for debugging? */
if (post_ptr >= post_end)
EMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
IEMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
goto fail; /* Cascaded (syntax?) error */
}
+3 -1
View File
@@ -3650,7 +3650,7 @@ win_line(
if (fdc > 0)
{
/* Draw the 'foldcolumn'. Allocate a buffer, "extra" may
* already be in used. */
* already be in use. */
p_extra_free = alloc(12 + 1);
if (p_extra_free != NULL)
@@ -10373,6 +10373,8 @@ draw_tabline(void)
#endif
);
if (ScreenLines == NULL)
return;
redraw_tabline = FALSE;
#ifdef FEAT_GUI_TABLINE
+36 -8
View File
@@ -6383,7 +6383,9 @@ syntax_present(win_T *win)
static enum
{
EXP_SUBCMD, /* expand ":syn" sub-commands */
EXP_CASE /* expand ":syn case" arguments */
EXP_CASE, /* expand ":syn case" arguments */
EXP_SPELL, /* expand ":syn spell" arguments */
EXP_SYNC /* expand ":syn sync" arguments */
} expand_what;
/*
@@ -6434,6 +6436,10 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
xp->xp_context = EXPAND_NOTHING;
else if (STRNICMP(arg, "case", p - arg) == 0)
expand_what = EXP_CASE;
else if (STRNICMP(arg, "spell", p - arg) == 0)
expand_what = EXP_SPELL;
else if (STRNICMP(arg, "sync", p - arg) == 0)
expand_what = EXP_SYNC;
else if ( STRNICMP(arg, "keyword", p - arg) == 0
|| STRNICMP(arg, "region", p - arg) == 0
|| STRNICMP(arg, "match", p - arg) == 0
@@ -6445,8 +6451,6 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
}
}
static char *(case_args[]) = {"match", "ignore", NULL};
/*
* Function given to ExpandGeneric() to obtain the list syntax names for
* expansion.
@@ -6454,9 +6458,31 @@ static char *(case_args[]) = {"match", "ignore", NULL};
char_u *
get_syntax_name(expand_T *xp UNUSED, int idx)
{
if (expand_what == EXP_SUBCMD)
return (char_u *)subcommands[idx].name;
return (char_u *)case_args[idx];
switch (expand_what)
{
case EXP_SUBCMD:
return (char_u *)subcommands[idx].name;
case EXP_CASE:
{
static char *case_args[] = {"match", "ignore", NULL};
return (char_u *)case_args[idx];
}
case EXP_SPELL:
{
static char *spell_args[] =
{"toplevel", "notoplevel", "default", NULL};
return (char_u *)spell_args[idx];
}
case EXP_SYNC:
{
static char *sync_args[] =
{"ccomment", "clear", "fromstart",
"linebreaks=", "linecont", "lines=", "match",
"maxlines=", "minlines=", "region", NULL};
return (char_u *)sync_args[idx];
}
}
return NULL;
}
#endif /* FEAT_CMDL_COMPL */
@@ -6704,8 +6730,10 @@ syntime_report(void)
}
}
/* sort on total time */
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
/* Sort on total time. Skip if there are no items to avoid passing NULL
* pointer to qsort(). */
if (ga.ga_len > 1)
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
syn_compare_syntime);
MSG_PUTS_TITLE(_(" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN"));
+1
View File
@@ -184,6 +184,7 @@ NEW_TESTS = test_arglist.res \
test_stat.res \
test_substitute.res \
test_syntax.res \
test_system.res \
test_textobjects.res \
test_undo.res \
test_usercommands.res \
+1
View File
@@ -16,6 +16,7 @@ source test_file_perm.vim
source test_fileformat.vim
source test_filter_cmd.vim
source test_filter_map.vim
source test_float_func.vim
source test_fnamemodify.vim
source test_glob2regpat.vim
source test_goto.vim
-1
View File
@@ -279,7 +279,6 @@ func Ch_channel_handler(port)
endfunc
func Test_channel_handler()
call ch_logfile('channellog', 'w')
call ch_log('Test_channel_handler()')
let g:Ch_reply = ""
let s:chopt.callback = 'Ch_handler'
+231
View File
@@ -0,0 +1,231 @@
" test float functions
if !has('float')
finish
end
func Test_abs()
call assert_equal('1.23', string(abs(1.23)))
call assert_equal('1.23', string(abs(-1.23)))
call assert_equal('0.0', string(abs(0.0)))
call assert_equal('0.0', string(abs(1.0/(1.0/0.0))))
call assert_equal('0.0', string(abs(-1.0/(1.0/0.0))))
call assert_equal('inf', string(abs(1.0/0.0)))
call assert_equal('inf', string(abs(-1.0/0.0)))
call assert_equal('nan', string(abs(0.0/0.0)))
endfunc
func Test_sqrt()
call assert_equal('0.0', string(sqrt(0.0)))
call assert_equal('1.414214', string(sqrt(2.0)))
call assert_equal('inf', string(sqrt(1.0/0.0)))
call assert_equal('nan', string(sqrt(-1.0)))
call assert_equal('nan', string(sqrt(0.0/0.0)))
endfunc
func Test_log()
call assert_equal('0.0', string(log(1.0)))
call assert_equal('-0.693147', string(log(0.5)))
call assert_equal('-inf', string(log(0.0)))
call assert_equal('nan', string(log(-1.0)))
call assert_equal('inf', string(log(1.0/0.0)))
call assert_equal('nan', string(log(0.0/0.0)))
endfunc
func Test_log10()
call assert_equal('0.0', string(log10(1.0)))
call assert_equal('2.0', string(log10(100.0)))
call assert_equal('2.079181', string(log10(120.0)))
call assert_equal('-inf', string(log10(0.0)))
call assert_equal('nan', string(log10(-1.0)))
call assert_equal('inf', string(log10(1.0/0.0)))
call assert_equal('nan', string(log10(0.0/0.0)))
endfunc
func Test_exp()
call assert_equal('1.0', string(exp(0.0)))
call assert_equal('7.389056', string(exp(2.0)))
call assert_equal('0.367879', string(exp(-1.0)))
call assert_equal('inf', string(exp(1.0/0.0)))
call assert_equal('0.0', string(exp(-1.0/0.0)))
call assert_equal('nan', string(exp(0.0/0.0)))
endfunc
func Test_sin()
call assert_equal('0.0', string(sin(0.0)))
call assert_equal('0.841471', string(sin(1.0)))
call assert_equal('-0.479426', string(sin(-0.5)))
call assert_equal('nan', string(sin(0.0/0.0)))
call assert_equal('nan', string(sin(1.0/0.0)))
call assert_equal('0.0', string(sin(1.0/(1.0/0.0))))
call assert_equal('-0.0', string(sin(-1.0/(1.0/0.0))))
endfunc
func Test_asin()
call assert_equal('0.0', string(asin(0.0)))
call assert_equal('1.570796', string(asin(1.0)))
call assert_equal('-0.523599', string(asin(-0.5)))
call assert_equal('nan', string(asin(1.1)))
call assert_equal('nan', string(asin(1.0/0.0)))
call assert_equal('nan', string(asin(0.0/0.0)))
endfunc
func Test_sinh()
call assert_equal('0.0', string(sinh(0.0)))
call assert_equal('0.521095', string(sinh(0.5)))
call assert_equal('-1.026517', string(sinh(-0.9)))
call assert_equal('inf', string(sinh(1.0/0.0)))
call assert_equal('-inf', string(sinh(-1.0/0.0)))
call assert_equal('nan', string(sinh(0.0/0.0)))
endfunc
func Test_cos()
call assert_equal('1.0', string(cos(0.0)))
call assert_equal('0.540302', string(cos(1.0)))
call assert_equal('0.877583', string(cos(-0.5)))
call assert_equal('nan', string(cos(0.0/0.0)))
call assert_equal('nan', string(cos(1.0/0.0)))
endfunc
func Test_acos()
call assert_equal('1.570796', string(acos(0.0)))
call assert_equal('0.0', string(acos(1.0)))
call assert_equal('3.141593', string(acos(-1.0)))
call assert_equal('2.094395', string(acos(-0.5)))
call assert_equal('nan', string(acos(1.1)))
call assert_equal('nan', string(acos(1.0/0.0)))
call assert_equal('nan', string(acos(0.0/0.0)))
endfunc
func Test_cosh()
call assert_equal('1.0', string(cosh(0.0)))
call assert_equal('1.127626', string(cosh(0.5)))
call assert_equal('inf', string(cosh(1.0/0.0)))
call assert_equal('inf', string(cosh(-1.0/0.0)))
call assert_equal('nan', string(cosh(0.0/0.0)))
endfunc
func Test_tan()
call assert_equal('0.0', string(tan(0.0)))
call assert_equal('0.546302', string(tan(0.5)))
call assert_equal('-0.546302', string(tan(-0.5)))
call assert_equal('nan', string(tan(1.0/0.0)))
call assert_equal('nan', string(cos(0.0/0.0)))
call assert_equal('0.0', string(tan(1.0/(1.0/0.0))))
call assert_equal('-0.0', string(tan(-1.0/(1.0/0.0))))
endfunc
func Test_atan()
call assert_equal('0.0', string(atan(0.0)))
call assert_equal('0.463648', string(atan(0.5)))
call assert_equal('-0.785398', string(atan(-1.0)))
call assert_equal('1.570796', string(atan(1.0/0.0)))
call assert_equal('-1.570796', string(atan(-1.0/0.0)))
call assert_equal('nan', string(atan(0.0/0.0)))
endfunc
func Test_atan2()
call assert_equal('-2.356194', string(atan2(-1, -1)))
call assert_equal('2.356194', string(atan2(1, -1)))
call assert_equal('0.0', string(atan2(1.0, 1.0/0.0)))
call assert_equal('1.570796', string(atan2(1.0/0.0, 1.0)))
call assert_equal('nan', string(atan2(0.0/0.0, 1.0)))
endfunc
func Test_tanh()
call assert_equal('0.0', string(tanh(0.0)))
call assert_equal('0.462117', string(tanh(0.5)))
call assert_equal('-0.761594', string(tanh(-1.0)))
call assert_equal('1.0', string(tanh(1.0/0.0)))
call assert_equal('-1.0', string(tanh(-1.0/0.0)))
call assert_equal('nan', string(tanh(0.0/0.0)))
endfunc
func Test_fmod()
call assert_equal('0.13', string(fmod(12.33, 1.22)))
call assert_equal('-0.13', string(fmod(-12.33, 1.22)))
call assert_equal('nan', string(fmod(1.0/0.0, 1.0)))
" On Windows we get "nan" instead of 1.0, accept both.
let res = string(fmod(1.0, 1.0/0.0))
if res != 'nan'
call assert_equal('1.0', res)
endif
call assert_equal('nan', string(fmod(1.0, 0.0)))
endfunc
func Test_pow()
call assert_equal('1.0', string(pow(0.0, 0.0)))
call assert_equal('8.0', string(pow(2.0, 3.0)))
call assert_equal('nan', string(pow(2.0, 0.0/0.0)))
call assert_equal('nan', string(pow(0.0/0.0, 3.0)))
call assert_equal('nan', string(pow(0.0/0.0, 3.0)))
call assert_equal('inf', string(pow(2.0, 1.0/0.0)))
call assert_equal('inf', string(pow(1.0/0.0, 3.0)))
endfunc
func Test_str2float()
call assert_equal('1.0', string(str2float('1')))
call assert_equal('1.23', string(str2float('1.23')))
call assert_equal('1.23', string(str2float('1.23abc')))
call assert_equal('1.0e40', string(str2float('1e40')))
call assert_equal('inf', string(str2float('1e1000')))
call assert_equal('inf', string(str2float('inf')))
call assert_equal('-inf', string(str2float('-inf')))
call assert_equal('inf', string(str2float('Inf')))
call assert_equal('nan', string(str2float('nan')))
call assert_equal('nan', string(str2float('NaN')))
endfunc
func Test_floor()
call assert_equal('2.0', string(floor(2.0)))
call assert_equal('2.0', string(floor(2.11)))
call assert_equal('2.0', string(floor(2.99)))
call assert_equal('-3.0', string(floor(-2.11)))
call assert_equal('-3.0', string(floor(-2.99)))
call assert_equal('nan', string(floor(0.0/0.0)))
call assert_equal('inf', string(floor(1.0/0.0)))
call assert_equal('-inf', string(floor(-1.0/0.0)))
endfunc
func Test_ceil()
call assert_equal('2.0', string(ceil(2.0)))
call assert_equal('3.0', string(ceil(2.11)))
call assert_equal('3.0', string(ceil(2.99)))
call assert_equal('-2.0', string(ceil(-2.11)))
call assert_equal('-2.0', string(ceil(-2.99)))
call assert_equal('nan', string(ceil(0.0/0.0)))
call assert_equal('inf', string(ceil(1.0/0.0)))
call assert_equal('-inf', string(ceil(-1.0/0.0)))
endfunc
func Test_round()
call assert_equal('2.0', string(round(2.1)))
call assert_equal('3.0', string(round(2.5)))
call assert_equal('3.0', string(round(2.9)))
call assert_equal('-2.0', string(round(-2.1)))
call assert_equal('-3.0', string(round(-2.5)))
call assert_equal('-3.0', string(round(-2.9)))
call assert_equal('nan', string(round(0.0/0.0)))
call assert_equal('inf', string(round(1.0/0.0)))
call assert_equal('-inf', string(round(-1.0/0.0)))
endfunc
func Test_trunc()
call assert_equal('2.0', string(trunc(2.1)))
call assert_equal('2.0', string(trunc(2.5)))
call assert_equal('2.0', string(trunc(2.9)))
call assert_equal('-2.0', string(trunc(-2.1)))
call assert_equal('-2.0', string(trunc(-2.5)))
call assert_equal('-2.0', string(trunc(-2.9)))
call assert_equal('nan', string(trunc(0.0/0.0)))
call assert_equal('inf', string(trunc(1.0/0.0)))
call assert_equal('-inf', string(trunc(-1.0/0.0)))
endfunc
func Test_isnan()
call assert_equal(0, isnan(1.0))
call assert_equal(1, isnan(0.0/0.0))
call assert_equal(0, isnan(1.0/0.0))
call assert_equal(0, isnan('a'))
call assert_equal(0, isnan([]))
endfunc
+6
View File
@@ -150,6 +150,12 @@ func Test_syntax_completion()
call feedkeys(":syn case \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn case ignore match', @:)
call feedkeys(":syn spell \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn spell default notoplevel toplevel', @:)
call feedkeys(":syn sync \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:)
call feedkeys(":syn list \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_match('^"syn list Boolean Character ', @:)
+48
View File
@@ -0,0 +1,48 @@
" Tests for system() and systemlist()
function! Test_System()
if !executable('echo') || !executable('cat') || !executable('wc')
return
endif
let out = system('echo 123')
" On Windows we may get a trailing space.
if out != "123 \n"
call assert_equal("123\n", out)
endif
let out = systemlist('echo 123')
" On Windows we may get a trailing space and CR.
if out != ["123 \r"]
call assert_equal(['123'], out)
endif
call assert_equal('123', system('cat', '123'))
call assert_equal(['123'], systemlist('cat', '123'))
call assert_equal(["as\<NL>df"], systemlist('cat', ["as\<NL>df"]))
new Xdummy
call setline(1, ['asdf', "pw\<NL>er", 'xxxx'])
let out = system('wc -l', bufnr('%'))
" On OS/X we get leading spaces
let out = substitute(out, '^ *', '', '')
call assert_equal("3\n", out)
let out = systemlist('wc -l', bufnr('%'))
" On Windows we may get a trailing CR.
if out != ["3\r"]
" On OS/X we get leading spaces
if type(out) == v:t_list
let out[0] = substitute(out[0], '^ *', '', '')
endif
call assert_equal(['3'], out)
endif
let out = systemlist('cat', bufnr('%'))
" On Windows we may get a trailing CR.
if out != ["asdf\r", "pw\<NL>er\r", "xxxx\r"]
call assert_equal(['asdf', "pw\<NL>er", 'xxxx'], out)
endif
bwipe!
call assert_fails('call system("wc -l", 99999)', 'E86:')
endfunction
+20
View File
@@ -779,6 +779,26 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
160,
/**/
159,
/**/
158,
/**/
157,
/**/
156,
/**/
155,
/**/
154,
/**/
153,
/**/
152,
/**/
151,
/**/
150,
/**/