Skip to content

Commit acc11d1

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 386ade3 + de33011 commit acc11d1

File tree

16 files changed

+408
-21
lines changed

16 files changed

+408
-21
lines changed

runtime/doc/eval.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7561,7 +7561,11 @@ system({expr} [, {input}]) *system()* *E677*
75617561
If {input} is given and is a |List| it is written to the file
75627562
in a way |writefile()| does with {binary} set to "b" (i.e.
75637563
with a newline between each list item with newlines inside
7564-
list items converted to NULs).
7564+
list items converted to NULs).
7565+
When {input} is given and is a number that is a valid id for
7566+
an existing buffer then the content of the buffer is written
7567+
to the file line by line, each line terminated by a NL and
7568+
NULs characters where the text has a NL.
75657569

75667570
Pipes are not used, the 'shelltemp' option is not used.
75677571

src/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,7 @@ test_arglist \
21212121
test_fileformat \
21222122
test_filter_cmd \
21232123
test_filter_map \
2124+
test_float_func \
21242125
test_fnameescape \
21252126
test_fnamemodify \
21262127
test_fold \
@@ -2181,6 +2182,7 @@ test_arglist \
21812182
test_substitute \
21822183
test_syn_attr \
21832184
test_syntax \
2185+
test_system \
21842186
test_tabline \
21852187
test_tabpage \
21862188
test_tagcase \

src/channel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ invoke_callback(channel_T *channel, char_u *callback, partial_T *partial,
15881588
int dummy;
15891589

15901590
if (safe_to_invoke_callback == 0)
1591-
EMSG("INTERNAL: Invoking callback when it is not safe");
1591+
IEMSG("INTERNAL: Invoking callback when it is not safe");
15921592

15931593
argv[0].v_type = VAR_CHANNEL;
15941594
argv[0].vval.v_channel = channel;

src/eval.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ eval_init(void)
270270
p = &vimvars[i];
271271
if (STRLEN(p->vv_name) > 16)
272272
{
273-
EMSG("INTERNAL: name too long, increase size of dictitem16_T");
273+
IEMSG("INTERNAL: name too long, increase size of dictitem16_T");
274274
getout(1);
275275
}
276276
STRCPY(p->vv_di.di_key, p->vv_name);
@@ -5971,6 +5971,22 @@ string2float(
59715971
char *s = (char *)text;
59725972
float_T f;
59735973

5974+
/* MS-Windows does not deal with "inf" and "nan" properly. */
5975+
if (STRNICMP(text, "inf", 3) == 0)
5976+
{
5977+
*value = INFINITY;
5978+
return 3;
5979+
}
5980+
if (STRNICMP(text, "-inf", 3) == 0)
5981+
{
5982+
*value = -INFINITY;
5983+
return 4;
5984+
}
5985+
if (STRNICMP(text, "nan", 3) == 0)
5986+
{
5987+
*value = NAN;
5988+
return 3;
5989+
}
59745990
f = strtod(s, &s);
59755991
*value = f;
59765992
return (int)((char_u *)s - text);

src/evalfunc.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11844,7 +11844,6 @@ get_cmd_output_as_rettv(
1184411844
char_u *res = NULL;
1184511845
char_u *p;
1184611846
char_u *infile = NULL;
11847-
char_u buf[NUMBUFLEN];
1184811847
int err = FALSE;
1184911848
FILE *fd;
1185011849
list_T *list = NULL;
@@ -11858,7 +11857,7 @@ get_cmd_output_as_rettv(
1185811857
if (argvars[1].v_type != VAR_UNKNOWN)
1185911858
{
1186011859
/*
11861-
* Write the string to a temp file, to be used for input of the shell
11860+
* Write the text to a temp file, to be used for input of the shell
1186211861
* command.
1186311862
*/
1186411863
if ((infile = vim_tempname('i', TRUE)) == NULL)
@@ -11873,14 +11872,42 @@ get_cmd_output_as_rettv(
1187311872
EMSG2(_(e_notopen), infile);
1187411873
goto errret;
1187511874
}
11876-
if (argvars[1].v_type == VAR_LIST)
11875+
if (argvars[1].v_type == VAR_NUMBER)
11876+
{
11877+
linenr_T lnum;
11878+
buf_T *buf;
11879+
11880+
buf = buflist_findnr(argvars[1].vval.v_number);
11881+
if (buf == NULL)
11882+
{
11883+
EMSGN(_(e_nobufnr), argvars[1].vval.v_number);
11884+
goto errret;
11885+
}
11886+
11887+
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++)
11888+
{
11889+
for (p = ml_get_buf(buf, lnum, FALSE); *p != NUL; ++p)
11890+
if (putc(*p == '\n' ? NUL : *p, fd) == EOF)
11891+
{
11892+
err = TRUE;
11893+
break;
11894+
}
11895+
if (putc(NL, fd) == EOF)
11896+
{
11897+
err = TRUE;
11898+
break;
11899+
}
11900+
}
11901+
}
11902+
else if (argvars[1].v_type == VAR_LIST)
1187711903
{
1187811904
if (write_list(fd, argvars[1].vval.v_list, TRUE) == FAIL)
1187911905
err = TRUE;
1188011906
}
1188111907
else
1188211908
{
11883-
size_t len;
11909+
size_t len;
11910+
char_u buf[NUMBUFLEN];
1188411911

1188511912
p = get_tv_string_buf_chk(&argvars[1], buf);
1188611913
if (p == NULL)

src/ex_getln.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,9 @@ getcmdline(
772772
/*
773773
* Open a window to edit the command line (and history).
774774
*/
775+
save_cmdline(&save_ccline);
775776
c = ex_window();
777+
restore_cmdline(&save_ccline);
776778
some_key_typed = TRUE;
777779
}
778780
}

src/regexp_nfa.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ nfa_regatom(void)
13591359
rc_did_emsg = TRUE;
13601360
return FAIL;
13611361
}
1362-
EMSGN("INTERNAL: Unknown character class char: %ld", c);
1362+
IEMSGN("INTERNAL: Unknown character class char: %ld", c);
13631363
return FAIL;
13641364
}
13651365
#ifdef FEAT_MBYTE
@@ -4925,7 +4925,7 @@ check_char_class(int class, int c)
49254925

49264926
default:
49274927
/* should not be here :P */
4928-
EMSGN(_(e_ill_char_class), class);
4928+
IEMSGN(_(e_ill_char_class), class);
49294929
return FAIL;
49304930
}
49314931
return FAIL;
@@ -6688,7 +6688,7 @@ nfa_regmatch(
66886688

66896689
#ifdef DEBUG
66906690
if (c < 0)
6691-
EMSGN("INTERNAL: Negative state char: %ld", c);
6691+
IEMSGN("INTERNAL: Negative state char: %ld", c);
66926692
#endif
66936693
result = (c == curc);
66946694

@@ -7216,7 +7216,7 @@ nfa_regcomp(char_u *expr, int re_flags)
72167216
{
72177217
/* TODO: only give this error for debugging? */
72187218
if (post_ptr >= post_end)
7219-
EMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
7219+
IEMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
72207220
goto fail; /* Cascaded (syntax?) error */
72217221
}
72227222

src/screen.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3650,7 +3650,7 @@ win_line(
36503650
if (fdc > 0)
36513651
{
36523652
/* Draw the 'foldcolumn'. Allocate a buffer, "extra" may
3653-
* already be in used. */
3653+
* already be in use. */
36543654
p_extra_free = alloc(12 + 1);
36553655

36563656
if (p_extra_free != NULL)
@@ -10373,6 +10373,8 @@ draw_tabline(void)
1037310373
#endif
1037410374
);
1037510375

10376+
if (ScreenLines == NULL)
10377+
return;
1037610378
redraw_tabline = FALSE;
1037710379

1037810380
#ifdef FEAT_GUI_TABLINE

src/syntax.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,7 +6383,9 @@ syntax_present(win_T *win)
63836383
static enum
63846384
{
63856385
EXP_SUBCMD, /* expand ":syn" sub-commands */
6386-
EXP_CASE /* expand ":syn case" arguments */
6386+
EXP_CASE, /* expand ":syn case" arguments */
6387+
EXP_SPELL, /* expand ":syn spell" arguments */
6388+
EXP_SYNC /* expand ":syn sync" arguments */
63876389
} expand_what;
63886390

63896391
/*
@@ -6434,6 +6436,10 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
64346436
xp->xp_context = EXPAND_NOTHING;
64356437
else if (STRNICMP(arg, "case", p - arg) == 0)
64366438
expand_what = EXP_CASE;
6439+
else if (STRNICMP(arg, "spell", p - arg) == 0)
6440+
expand_what = EXP_SPELL;
6441+
else if (STRNICMP(arg, "sync", p - arg) == 0)
6442+
expand_what = EXP_SYNC;
64376443
else if ( STRNICMP(arg, "keyword", p - arg) == 0
64386444
|| STRNICMP(arg, "region", p - arg) == 0
64396445
|| STRNICMP(arg, "match", p - arg) == 0
@@ -6445,18 +6451,38 @@ set_context_in_syntax_cmd(expand_T *xp, char_u *arg)
64456451
}
64466452
}
64476453

6448-
static char *(case_args[]) = {"match", "ignore", NULL};
6449-
64506454
/*
64516455
* Function given to ExpandGeneric() to obtain the list syntax names for
64526456
* expansion.
64536457
*/
64546458
char_u *
64556459
get_syntax_name(expand_T *xp UNUSED, int idx)
64566460
{
6457-
if (expand_what == EXP_SUBCMD)
6458-
return (char_u *)subcommands[idx].name;
6459-
return (char_u *)case_args[idx];
6461+
switch (expand_what)
6462+
{
6463+
case EXP_SUBCMD:
6464+
return (char_u *)subcommands[idx].name;
6465+
case EXP_CASE:
6466+
{
6467+
static char *case_args[] = {"match", "ignore", NULL};
6468+
return (char_u *)case_args[idx];
6469+
}
6470+
case EXP_SPELL:
6471+
{
6472+
static char *spell_args[] =
6473+
{"toplevel", "notoplevel", "default", NULL};
6474+
return (char_u *)spell_args[idx];
6475+
}
6476+
case EXP_SYNC:
6477+
{
6478+
static char *sync_args[] =
6479+
{"ccomment", "clear", "fromstart",
6480+
"linebreaks=", "linecont", "lines=", "match",
6481+
"maxlines=", "minlines=", "region", NULL};
6482+
return (char_u *)sync_args[idx];
6483+
}
6484+
}
6485+
return NULL;
64606486
}
64616487

64626488
#endif /* FEAT_CMDL_COMPL */
@@ -6704,8 +6730,10 @@ syntime_report(void)
67046730
}
67056731
}
67066732

6707-
/* sort on total time */
6708-
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
6733+
/* Sort on total time. Skip if there are no items to avoid passing NULL
6734+
* pointer to qsort(). */
6735+
if (ga.ga_len > 1)
6736+
qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T),
67096737
syn_compare_syntime);
67106738

67116739
MSG_PUTS_TITLE(_(" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN"));

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ NEW_TESTS = test_arglist.res \
184184
test_stat.res \
185185
test_substitute.res \
186186
test_syntax.res \
187+
test_system.res \
187188
test_textobjects.res \
188189
test_undo.res \
189190
test_usercommands.res \

0 commit comments

Comments
 (0)