Compare commits

...

24 Commits

Author SHA1 Message Date
65c836e600 patch 8.0.0242: no tests for user command completion
Problem:    Completion of user defined functions is not covered by tests.
Solution:   Add tests.  Also test various errors of user-defined commands.
            (Dominique Pelle, closes #1413)
2017-01-26 22:07:33 +01:00
52c0de1de1 patch 8.0.0241: fallback implementation of mch_memmove is unused
Problem:    Vim defines a mch_memmove() function but it doesn't work, thus is
            always unused.
Solution:   Remove the mch_memmove implementation. (suggested by Dominique
            Pelle)
2017-01-26 21:36:34 +01:00
4f7090b93d patch 8.0.0240: failure with one build on CI
Problem:    The clang build on CI fails with one configuration.
Solution:   Redo a previous patch that was accidentally reverted.
2017-01-26 21:24:02 +01:00
1e07633a5d patch 8.0.0239: no CI with an address sanitizer
Problem:    The address sanitizer sometimes finds errors, but it needs to be
            run manually.
Solution:   Add an environment to Travis with clang and the address sanitizer.
            (Christian Brabandt)  Also include changes only on github.
2017-01-26 20:11:12 +01:00
9e817c8a31 patch 8.0.0238: bracketed paste does not disable autoindent
Problem:    When using bracketed paste autoindent causes indent to be
            increased.
Solution:   Disable 'ai' and set 'paste' temporarily. (Ken Takata)
2017-01-25 21:36:17 +01:00
ba47b51ff8 patch 8.0.0237: when 'wildoptions' is "tagfile" completion may not work
Problem:    When setting wildoptions=tagfile the completion context is not set
            correctly. (desjardins)
Solution:   Check for EXPAND_TAGS_LISTFILES. (Christian Brabandt, closes #1399)
2017-01-24 21:18:19 +01:00
6a717f17ec patch 8.0.0236: gcc complains about uninitialized variable
Problem:    Gcc complains that a variable may be used uninitialized. Confusion
            between variable and label name. (John Marriott)
Solution:   Initialize it.  Rename end to end_lnum.
2017-01-24 20:47:50 +01:00
b031c4ea04 patch 8.0.0235: memory leak in diff mode
Problem:    Memory leak detected when running tests for diff mode.
Solution:   Free p_extra_free.
2017-01-24 20:14:48 +01:00
941c12da3c patch 8.0.0234: crash when using put in Visual mode
Problem:    When several lines are visually selected and one of them is short,
            using put may cause a crash. (Axel Bender)
Solution:   Check for a short line. (Christian Brabandt)
2017-01-24 19:55:43 +01:00
bff6ad1331 patch 8.0.0233: paste test fails in the GUI
Problem:    The paste test fails if the GUI is being used.
Solution:   Skip the test in the GUI.
2017-01-24 19:18:13 +01:00
48c9f3b123 patch 8.0.0232: paste does not work when 'esckeys' is off
Problem:    Pasting in Insert mode does not work when bracketed paste is used
            and 'esckeys' is off.
Solution:   When 'esckeys' is off disable bracketed paste in Insert mode.
2017-01-24 19:08:15 +01:00
076e502199 patch 8.0.0231: bracketed paste mode is not tested
Problem:    There are no tests for bracketed paste mode.
Solution:   Add a test.  Fix repeating with "normal .".
2017-01-24 18:58:30 +01:00
915350edec patch 8.0.0230: bracketed paste does not support line breaks
Problem:    When using bracketed paste line breaks are not respected.
Solution:   Turn CR characters into a line break if the text is being
            inserted. (closes #1404)
2017-01-24 17:50:52 +01:00
24a2d416ec patch 8.0.0229: local 'formatprg' option value leaks
Problem:    When freeing a buffer the local value of the 'formatprg' option is
            not cleared.
Solution:   Add missing change.
2017-01-24 17:48:36 +01:00
abbc448bc0 patch 8.0.0228: pasting in xterm on the command line has PasteStart
Problem:    When pasting test in an xterm on the command line it is surrounded
            by <PasteStart> and <PasteEnd>. (Johannes Kaltenbach)
Solution:   Add missing changes.
2017-01-24 15:57:55 +01:00
2aa5f696b9 patch 8.0.0227: crash with ff=dos when first line in file has no CR
Problem:    Crash when 'fileformat' is forced to "dos" and the first line in
            the file is empty and does not have a CR character.
Solution:   Don't check for CR before the start of the buffer.
2017-01-24 15:46:48 +01:00
1695f99d08 patch 8.0.0226: test for patch 8.0.0224 missing CR characters
Problem:    The test for patch 8.0.0224 misses the CR characters and passes
            even without the fix. (Christian Brabandt)
Solution:   Use double quotes and \<CR>.
2017-01-24 13:18:43 +01:00
9957a10d0f patch 8.0.0225: put in Visual block mode terminates early
Problem:    When a block is visually selected and put is used on the end of
            the selection only one line is changed.
Solution:   Check for the end properly. (Christian Brabandt, neovim issue
            5781)
2017-01-23 21:53:53 +01:00
7a2699e868 patch 8.0.0224: change to 'fileformats' from autocmd does not take effect
Problem:    When 'fileformats' is changed in a BufReadPre auto command, it
            does not take effect in readfile(). (Gary Johnson)
Solution:   Check the value of 'fileformats' after executing auto commands.
            (Christian Brabandt)
2017-01-23 21:31:09 +01:00
fffbf308dd patch 8.0.0223: Coverity warns for an uninitialized variable
Problem:    Coverity gets confused by the flags passed to find_tags() and
            warnts for an uninitialized variable.
Solution:   Disallow using cscope and help tags at the same time.
2017-01-23 20:47:12 +01:00
c81299684b patch 8.0.0222: blockwise put on multi-byte character misplaced
Problem:    When a multi-byte character ends in a zero byte, putting blockwise
            text puts it before the character instead of after it.
Solution:   Use int instead of char for the character under the cursor.
            (Luchr, closes #1403)  Add a test.
2017-01-22 20:04:51 +01:00
6a8ede99dd patch 8.0.0221: unnecessary condition on PROTO
Problem:    Checking if PROTO is defined inside a function has no effect.
Solution:   Remove the check for PROTO. (Hirohito Higashi)
2017-01-22 19:49:12 +01:00
15eedf1d62 patch 8.0.0220: completion of highlight names misses a few values
Problem:    Completion for :match does not show "none" and other missing
            highlight names.
Solution:   Skip over cleared entries before checking the index to be at the
            end.
2017-01-22 19:25:33 +01:00
7a40ea2138 patch 8.0.0219: ubsan reports errors for overflow
Problem:    Ubsan reports errors for integer overflow.
Solution:   Define macros for minimum and maximum values.  Select an
            expression based on the value. (Mike Williams)
2017-01-22 18:34:57 +01:00
28 changed files with 472 additions and 101 deletions

View File

@ -18,13 +18,16 @@ env:
# Mac OSX build
- BUILD=yes TEST=test COVERAGE=no FEATURES=huge SHADOWOPT= SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
# ASAN build
- BUILD=yes TEST=test SANITIZER_CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" FEATURES=huge SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
sudo: false
git:
depth: 1
# instead of a 6*2*2 matrix (2*os + 2*compiler + 6*env),
# instead of a 2*2*8 matrix (2*os + 2*compiler + 8*env),
# exclude some builds on mac os x and linux
# linux: 2*compiler + 5*env + mac: 2*compiler + 2*env
matrix:
@ -38,6 +41,13 @@ matrix:
- os: osx
env: BUILD=yes TEST=scripttests COVERAGE=yes CFLAGS=--coverage LDFLAGS=--coverage FEATURES=huge SHADOWOPT= SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-python3interp --enable-rubyinterp --enable-luainterp'"
- os: osx
env: BUILD=yes TEST=test SANITIZER_CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" FEATURES=huge SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
- os: linux
compiler: gcc
env: BUILD=yes TEST=test SANITIZER_CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" FEATURES=huge SRCDIR=./src CHECK_AUTOCONF=no
"CONFOPT='--enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-luainterp'"
- os: linux
compiler: clang
env: BUILD=no TEST=unittests COVERAGE=yes CFLAGS=--coverage LDFLAGS=--coverage FEATURES=huge SHADOWOPT= SRCDIR=./src CHECK_AUTOCONF=yes

View File

@ -2147,9 +2147,11 @@ test_arglist \
test_options \
test_packadd \
test_partial \
test_paste \
test_perl \
test_popup \
test_profile \
test_put \
test_quickfix \
test_regexp_latin \
test_regexp_utf8 \
@ -2160,9 +2162,9 @@ test_arglist \
test_searchpos \
test_set \
test_signs \
test_smartindent \
test_sort \
test_source_utf8 \
test_smartindent \
test_startup \
test_startup_utf8 \
test_stat \

View File

@ -2153,6 +2153,7 @@ free_buf_options(
#if defined(FEAT_CRYPT)
clear_string_option(&buf->b_p_cm);
#endif
clear_string_option(&buf->b_p_fp);
#if defined(FEAT_EVAL)
clear_string_option(&buf->b_p_fex);
#endif

View File

@ -1901,7 +1901,11 @@ vim_str2nr(
n += 2; /* skip over "0b" */
while ('0' <= *ptr && *ptr <= '1')
{
un = 2 * un + (unsigned long)(*ptr - '0');
/* avoid ubsan error for overflow */
if (un < UVARNUM_MAX / 2)
un = 2 * un + (unsigned long)(*ptr - '0');
else
un = UVARNUM_MAX;
++ptr;
if (n++ == maxlen)
break;
@ -1912,7 +1916,11 @@ vim_str2nr(
/* octal */
while ('0' <= *ptr && *ptr <= '7')
{
un = 8 * un + (uvarnumber_T)(*ptr - '0');
/* avoid ubsan error for overflow */
if (un < UVARNUM_MAX / 8)
un = 8 * un + (uvarnumber_T)(*ptr - '0');
else
un = UVARNUM_MAX;
++ptr;
if (n++ == maxlen)
break;
@ -1925,7 +1933,11 @@ vim_str2nr(
n += 2; /* skip over "0x" */
while (vim_isxdigit(*ptr))
{
un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
/* avoid ubsan error for overflow */
if (un < UVARNUM_MAX / 16)
un = 16 * un + (uvarnumber_T)hex2nr(*ptr);
else
un = UVARNUM_MAX;
++ptr;
if (n++ == maxlen)
break;
@ -1936,7 +1948,11 @@ vim_str2nr(
/* decimal */
while (VIM_ISDIGIT(*ptr))
{
un = 10 * un + (uvarnumber_T)(*ptr - '0');
/* avoid ubsan error for overflow */
if (un < UVARNUM_MAX / 10)
un = 10 * un + (uvarnumber_T)(*ptr - '0');
else
un = UVARNUM_MAX;
++ptr;
if (n++ == maxlen)
break;
@ -1950,9 +1966,19 @@ vim_str2nr(
if (nptr != NULL)
{
if (negative) /* account for leading '-' for decimal numbers */
*nptr = -(varnumber_T)un;
{
/* avoid ubsan error for overflow */
if (un > VARNUM_MAX)
*nptr = VARNUM_MIN;
else
*nptr = -(varnumber_T)un;
}
else
{
if (un > VARNUM_MAX)
un = VARNUM_MAX;
*nptr = (varnumber_T)un;
}
}
if (unptr != NULL)
*unptr = un;

View File

@ -463,7 +463,10 @@ edit(
else
#endif
{
AppendCharToRedobuff(cmdchar);
if (cmdchar == K_PS)
AppendCharToRedobuff('a');
else
AppendCharToRedobuff(cmdchar);
if (cmdchar == 'g') /* "gI" command */
AppendCharToRedobuff('I');
else if (cmdchar == 'r') /* "r<CR>" command */
@ -531,6 +534,10 @@ edit(
revins_legal = 0;
revins_scol = -1;
#endif
if (!p_ek)
/* Disable bracketed paste mode, we won't recognize the escape
* sequences. */
out_str(T_BD);
/*
* Handle restarting Insert mode.
@ -8620,6 +8627,9 @@ ins_esc(
#ifdef CURSOR_SHAPE
ui_cursor_shape(); /* may show different cursor shape */
#endif
if (!p_ek)
/* Re-enable bracketed paste mode. */
out_str(T_BE);
/*
* When recording or for CTRL-O, need to display the new mode.
@ -9453,12 +9463,17 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
char_u *end = find_termcode((char_u *)"PE");
int ret_char = -1;
int save_allow_keys = allow_keys;
int save_paste = p_paste;
int save_ai = curbuf->b_p_ai;
/* If the end code is too long we can't detect it, read everything. */
if (STRLEN(end) >= NUMBUFLEN)
end = NULL;
++no_mapping;
allow_keys = 0;
p_paste = TRUE;
curbuf->b_p_ai = FALSE;
for (;;)
{
/* When the end is not defined read everything. */
@ -9498,8 +9513,14 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
case PASTE_INSERT:
if (stop_arrow() == OK)
{
ins_char_bytes(buf, idx);
AppendToRedobuffLit(buf, idx);
c = buf[0];
if (idx == 1 && (c == CAR || c == K_KENTER || c == NL))
ins_eol(c);
else
{
ins_char_bytes(buf, idx);
AppendToRedobuffLit(buf, idx);
}
}
break;
@ -9518,8 +9539,11 @@ bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
}
idx = 0;
}
--no_mapping;
allow_keys = save_allow_keys;
p_paste = save_paste;
curbuf->b_p_ai = save_ai;
return ret_char;
}

View File

@ -4109,21 +4109,12 @@ eval6(
{
if (n2 == 0) /* give an error message? */
{
#ifdef FEAT_NUM64
if (n1 == 0)
n1 = -0x7fffffffffffffffLL - 1; /* similar to NaN */
n1 = VARNUM_MIN; /* similar to NaN */
else if (n1 < 0)
n1 = -0x7fffffffffffffffLL;
n1 = -VARNUM_MAX;
else
n1 = 0x7fffffffffffffffLL;
#else
if (n1 == 0)
n1 = -0x7fffffffL - 1L; /* similar to NaN */
else if (n1 < 0)
n1 = -0x7fffffffL;
else
n1 = 0x7fffffffL;
#endif
n1 = VARNUM_MAX;
}
else
n1 = n1 / n2;

View File

@ -3304,21 +3304,12 @@ f_float2nr(typval_T *argvars, typval_T *rettv)
if (get_float_arg(argvars, &f) == OK)
{
# ifdef FEAT_NUM64
if (f < -0x7fffffffffffffffLL)
rettv->vval.v_number = -0x7fffffffffffffffLL;
else if (f > 0x7fffffffffffffffLL)
rettv->vval.v_number = 0x7fffffffffffffffLL;
if (f < -VARNUM_MAX)
rettv->vval.v_number = -VARNUM_MAX;
else if (f > VARNUM_MAX)
rettv->vval.v_number = VARNUM_MAX;
else
rettv->vval.v_number = (varnumber_T)f;
# else
if (f < -0x7fffffff)
rettv->vval.v_number = -0x7fffffff;
else if (f > 0x7fffffff)
rettv->vval.v_number = 0x7fffffff;
else
rettv->vval.v_number = (varnumber_T)f;
# endif
}
}

View File

@ -1794,6 +1794,10 @@ getcmdline(
goto cmdline_not_changed;
#endif
case K_PS:
bracketed_paste(PASTE_CMDLINE, FALSE, NULL);
goto cmdline_changed;
default:
#ifdef UNIX
if (c == intr_char)
@ -2366,8 +2370,7 @@ getexmodeline(
if (ga_grow(&line_ga, 40) == FAIL)
break;
/* Get one character at a time. Don't use inchar(), it can't handle
* special characters. */
/* Get one character at a time. */
prev_char = c1;
c1 = vgetc();
@ -2382,6 +2385,12 @@ getexmodeline(
break;
}
if (c1 == K_PS)
{
bracketed_paste(PASTE_EX, FALSE, &line_ga);
goto redraw;
}
if (!escaped)
{
/* CR typed means "enter", which is NL */
@ -4357,7 +4366,9 @@ addstar(
|| context == EXPAND_OWNSYNTAX
|| context == EXPAND_FILETYPE
|| context == EXPAND_PACKADD
|| (context == EXPAND_TAGS && fname[0] == '/'))
|| ((context == EXPAND_TAGS_LISTFILES
|| context == EXPAND_TAGS)
&& fname[0] == '/'))
retval = vim_strnsave(fname, len);
else
{

View File

@ -274,9 +274,9 @@ readfile(
int msg_save = msg_scroll;
linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of
* last read was missing the eol */
int try_mac = (vim_strchr(p_ffs, 'm') != NULL);
int try_dos = (vim_strchr(p_ffs, 'd') != NULL);
int try_unix = (vim_strchr(p_ffs, 'x') != NULL);
int try_mac;
int try_dos;
int try_unix;
int file_rewind = FALSE;
#ifdef FEAT_MBYTE
int can_retry;
@ -738,6 +738,10 @@ readfile(
curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
curbuf->b_op_start.col = 0;
try_mac = (vim_strchr(p_ffs, 'm') != NULL);
try_dos = (vim_strchr(p_ffs, 'd') != NULL);
try_unix = (vim_strchr(p_ffs, 'x') != NULL);
#ifdef FEAT_AUTOCMD
if (!read_buffer)
{
@ -769,6 +773,11 @@ readfile(
else
apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname,
FALSE, NULL, eap);
/* autocommands may have changed it */
try_mac = (vim_strchr(p_ffs, 'm') != NULL);
try_dos = (vim_strchr(p_ffs, 'd') != NULL);
try_unix = (vim_strchr(p_ffs, 'x') != NULL);
if (msg_scrolled == n)
msg_scroll = m;
@ -2242,8 +2251,9 @@ rewind_retry:
len = (colnr_T)(ptr - line_start + 1);
if (fileformat == EOL_DOS)
{
if (ptr[-1] == CAR) /* remove CR */
if (ptr > line_start && ptr[-1] == CAR)
{
/* remove CR before NL */
ptr[-1] = NUL;
--len;
}

View File

@ -2180,7 +2180,7 @@ ins_char(int c)
char_u buf[MB_MAXBYTES + 1];
int n = 1;
#if defined(FEAT_MBYTE) || defined(PROTO)
#ifdef FEAT_MBYTE
n = (*mb_char2bytes)(c, buf);
/* When "c" is 0x100, 0x200, etc. we don't want to insert a NUL byte.

View File

@ -1740,34 +1740,6 @@ vim_memset(void *ptr, int c, size_t size)
}
#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, void *dst_arg, size_t len)
{
/*
* A void doesn't have a size, we use char pointers.
*/
char *dst = dst_arg, *src = src_arg;
/* overlap, copy backwards */
if (dst > src && dst < src + len)
{
src += len;
dst += len;
while (len-- > 0)
*--dst = *--src;
}
else /* copy forwards */
while (len-- > 0)
*dst++ = *src++;
}
#endif
#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)) || defined(PROTO)
/*
* Compare two strings, ignoring case, using current locale.

View File

@ -3550,7 +3550,7 @@ do_put(
*/
if (y_type == MBLOCK)
{
char c = gchar_cursor();
int c = gchar_cursor();
colnr_T endcol2 = 0;
if (dir == FORWARD && c != NUL)
@ -3774,11 +3774,25 @@ do_put(
*/
if (y_type == MCHAR && y_size == 1)
{
linenr_T end_lnum = 0; /* init for gcc */
if (VIsual_active)
{
end_lnum = curbuf->b_visual.vi_end.lnum;
if (end_lnum < curbuf->b_visual.vi_start.lnum)
end_lnum = curbuf->b_visual.vi_start.lnum;
}
do {
totlen = count * yanklen;
if (totlen > 0)
{
oldp = ml_get(lnum);
if (VIsual_active && col > (int)STRLEN(oldp))
{
lnum++;
continue;
}
newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
if (newp == NULL)
goto end; /* alloc() gave an error message */
@ -3801,7 +3815,7 @@ do_put(
}
if (VIsual_active)
lnum++;
} while (VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum);
} while (VIsual_active && lnum <= end_lnum);
if (VIsual_active) /* reset lnum to the last visual line */
lnum--;

View File

@ -423,21 +423,17 @@ typedef struct dsc$descriptor DESC;
# endif
#endif
/* memmove is not present on all systems, use memmove, bcopy, memcpy or our
* own version */
/* Some systems have (void *) arguments, some (char *). If we use (char *) it
/* memmove() is not present on all systems, use memmove, bcopy or memcpy.
* Some systems have (void *) arguments, some (char *). If we use (char *) it
* works for all */
#ifdef USEMEMMOVE
#if defined(USEMEMMOVE) || (!defined(USEBCOPY) && !defined(USEMEMCPY))
# define mch_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
#else
# ifdef USEBCOPY
# define mch_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
# else
# ifdef USEMEMCPY
/* ifdef USEMEMCPY */
# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
# else
# define VIM_MEMMOVE /* found in misc2.c */
# endif
# endif
#endif

View File

@ -3651,6 +3651,7 @@ win_line(
{
/* Draw the 'foldcolumn'. Allocate a buffer, "extra" may
* already be in use. */
vim_free(p_extra_free);
p_extra_free = alloc(12 + 1);
if (p_extra_free != NULL)
@ -4695,6 +4696,7 @@ win_line(
p = alloc((unsigned)(len + 1));
vim_memset(p, ' ', len);
p[len] = NUL;
vim_free(p_extra_free);
p_extra_free = p;
for (i = 0; i < tab_len; i++)
{
@ -4857,6 +4859,7 @@ win_line(
vim_memset(p, ' ', n_extra);
STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1);
p[n_extra] = NUL;
vim_free(p_extra_free);
p_extra_free = p_extra = p;
}
else
@ -5784,6 +5787,7 @@ win_line(
}
#endif
vim_free(p_extra_free);
return row;
}

View File

@ -1133,25 +1133,43 @@ typedef long_u hash_T; /* Type for hi_hash */
# ifdef PROTO
typedef long varnumber_T;
typedef unsigned long uvarnumber_T;
#define VARNUM_MIN LONG_MIN
#define VARNUM_MAX LONG_MAX
#define UVARNUM_MAX ULONG_MAX
# else
typedef __int64 varnumber_T;
typedef unsigned __int64 uvarnumber_T;
#define VARNUM_MIN _I64_MIN
#define VARNUM_MAX _I64_MAX
#define UVARNUM_MAX _UI64_MAX
# endif
# elif defined(HAVE_STDINT_H)
typedef int64_t varnumber_T;
typedef uint64_t uvarnumber_T;
#define VARNUM_MIN INT64_MIN
#define VARNUM_MAX INT64_MAX
#define UVARNUM_MAX UINT64_MAX
# else
typedef long varnumber_T;
typedef unsigned long uvarnumber_T;
#define VARNUM_MIN LONG_MIN
#define VARNUM_MAX LONG_MAX
#define UVARNUM_MAX ULONG_MAX
# endif
#else
/* Use 32-bit Number. */
# if VIM_SIZEOF_INT <= 3 /* use long if int is smaller than 32 bits */
typedef long varnumber_T;
typedef unsigned long uvarnumber_T;
#define VARNUM_MIN LONG_MIN
#define VARNUM_MAX LONG_MAX
#define UVARNUM_MAX ULONG_MAX
# else
typedef int varnumber_T;
typedef unsigned int uvarnumber_T;
#define VARNUM_MIN INT_MIN
#define VARNUM_MAX INT_MAX
#define UVARNUM_MAX UINT_MAX
# endif
#endif

View File

@ -9956,6 +9956,13 @@ highlight_list_two(int cnt, int attr)
char_u *
get_highlight_name(expand_T *xp UNUSED, int idx)
{
if (idx < 0)
return NULL;
/* Items are never removed from the table, skip the ones that were cleared.
*/
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
++idx;
#ifdef FEAT_CMDL_COMPL
if (idx == highlight_ga.ga_len && include_none != 0)
return (char_u *)"none";
@ -9968,12 +9975,6 @@ get_highlight_name(expand_T *xp UNUSED, int idx)
&& include_link != 0)
return (char_u *)"clear";
#endif
if (idx < 0)
return NULL;
/* Items are never removed from the table, skip the ones that were cleared.
*/
while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
++idx;
if (idx >= highlight_ga.ga_len)
return NULL;
return HL_TABLE()[idx].sg_name;

View File

@ -1256,6 +1256,7 @@ prepare_pats(pat_T *pats, int has_re)
* TAG_REGEXP use "pat" as a regexp
* TAG_NOIC don't always ignore case
* TAG_KEEP_LANG keep language
* TAG_CSCOPE use cscope results for tags
*/
int
find_tags(
@ -1423,6 +1424,14 @@ find_tags(
*/
if (help_only) /* want tags from help file */
curbuf->b_help = TRUE; /* will be restored later */
#ifdef FEAT_CSCOPE
else if (use_cscope)
{
/* Make sure we don't mix help and cscope, confuses Coverity. */
help_only = FALSE;
curbuf->b_help = FALSE;
}
#endif
orgpat.len = (int)STRLEN(pat);
#ifdef FEAT_MULTI_LANG
@ -2281,7 +2290,8 @@ parse_line:
*/
*tagp.tagname_end = NUL;
len = (int)(tagp.tagname_end - tagp.tagname);
mfp = (char_u *)alloc((int)sizeof(char_u) + len + 10 + ML_EXTRA + 1);
mfp = (char_u *)alloc((int)sizeof(char_u)
+ len + 10 + ML_EXTRA + 1);
if (mfp != NULL)
{
int heuristic;

View File

@ -3148,7 +3148,7 @@ starttermcap(void)
{
out_str(T_TI); /* start termcap mode */
out_str(T_KS); /* start "keypad transmit" mode */
out_str(T_BE); /* enable bracketed paste moe */
out_str(T_BE); /* enable bracketed paste mode */
out_flush();
termcap_active = TRUE;
screen_start(); /* don't know where cursor is now */
@ -3198,7 +3198,7 @@ stoptermcap(void)
check_for_codes_from_term();
}
#endif
out_str(T_BD); /* disable bracketed paste moe */
out_str(T_BD); /* disable bracketed paste mode */
out_str(T_KE); /* stop "keypad transmit" mode */
out_flush();
termcap_active = FALSE;

View File

@ -173,6 +173,7 @@ NEW_TESTS = test_arglist.res \
test_nested_function.res \
test_netbeans.res \
test_normal.res \
test_paste.res \
test_packadd.res \
test_perl.res \
test_profile.res \

View File

@ -31,6 +31,7 @@ source test_mapping.vim
source test_messages.vim
source test_partial.vim
source test_popup.vim
source test_put.vim
source test_reltime.vim
source test_searchpos.vim
source test_set.vim

View File

@ -25,8 +25,34 @@ func Test_complete_wildmenu()
set nowildmenu
endfunc
func Test_match_completion()
if !has('cmdline_compl')
return
endif
hi Aardig ctermfg=green
call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"match Aardig', getreg(':'))
call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"match none', getreg(':'))
endfunc
func Test_highlight_completion()
if !has('cmdline_compl')
return
endif
hi Aardig ctermfg=green
call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"hi Aardig', getreg(':'))
call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"hi link', getreg(':'))
call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"hi default', getreg(':'))
call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"hi clear', getreg(':'))
endfunc
func Test_expr_completion()
if !(has('cmdline_compl') && has('eval'))
if !has('cmdline_compl')
return
endif
for cmd in [
@ -269,3 +295,14 @@ func Test_illegal_address()
2;')
quit
endfunc
func Test_cmdline_complete_wildoptions()
help
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
let a = join(sort(split(@:)),' ')
set wildoptions=tagfile
call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx')
let b = join(sort(split(@:)),' ')
call assert_equal(a, b)
bw!
endfunc

View File

@ -15,3 +15,19 @@ func Test_fileformat_after_bw()
call assert_equal(test_fileformats, &fileformat)
set fileformats&
endfunc
func Test_fileformat_autocommand()
let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""]
let ffs = &ffs
call writefile(filecnt, 'Xfile', 'b')
au BufReadPre Xfile set ffs=dos ff=dos
new Xfile
call assert_equal('dos', &l:ff)
call assert_equal('dos', &ffs)
" cleanup
call delete('Xfile')
let &ffs = ffs
au! BufReadPre Xfile
bw!
endfunc

View File

@ -0,0 +1,54 @@
" Tests for bracketed paste.
" Bracketed paste only works with "xterm". Not in GUI.
if has('gui_running')
finish
endif
set term=xterm
func Test_paste_normal_mode()
new
call setline(1, ['a', 'b', 'c'])
2
call feedkeys("\<Esc>[200~foo\<CR>bar\<Esc>[201~", 'xt')
call assert_equal('bfoo', getline(2))
call assert_equal('bar', getline(3))
call assert_equal('c', getline(4))
normal .
call assert_equal('barfoo', getline(3))
call assert_equal('bar', getline(4))
call assert_equal('c', getline(5))
bwipe!
endfunc
func Test_paste_insert_mode()
new
call setline(1, ['a', 'b', 'c'])
2
call feedkeys("i\<Esc>[200~foo\<CR>bar\<Esc>[201~ done\<Esc>", 'xt')
call assert_equal('foo', getline(2))
call assert_equal('bar doneb', getline(3))
call assert_equal('c', getline(4))
normal .
call assert_equal('bar donfoo', getline(3))
call assert_equal('bar doneeb', getline(4))
call assert_equal('c', getline(5))
set ai et tw=10
call setline(1, ['a', ' b', 'c'])
2
call feedkeys("A\<Esc>[200~foo\<CR> bar bar bar\<Esc>[201~\<Esc>", 'xt')
call assert_equal(' bfoo', getline(2))
call assert_equal(' bar bar bar', getline(3))
call assert_equal('c', getline(4))
set ai& et& tw=0
bwipe!
endfunc
func Test_paste_cmdline()
call feedkeys(":a\<Esc>[200~foo\<CR>bar\<Esc>[201~b\<Home>\"\<CR>", 'xt')
call assert_equal("\"afoo\<CR>barb", getreg(':'))
endfunc

36
src/testdir/test_put.vim Normal file
View File

@ -0,0 +1,36 @@
func Test_put_block()
if !has('multi_byte')
return
endif
new
call feedkeys("i\<C-V>u2500\<CR>x\<ESC>", 'x')
call feedkeys("\<C-V>y", 'x')
call feedkeys("gg0p", 'x')
call assert_equal("\u2500x", getline(1))
bwipe!
endfunc
func Test_put_char_block()
new
call setline(1, ['Line 1', 'Line 2'])
f Xfile_put
" visually select both lines and put the cursor at the top of the visual
" selection and then put the buffer name over it
exe "norm! G0\<c-v>ke\"%p"
call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2))
bw!
endfunc
func Test_put_char_block2()
new
let a = [ getreg('a'), getregtype('a') ]
call setreg('a', ' one ', 'v')
call setline(1, ['Line 1', '', 'Line 3', ''])
" visually select the first 3 lines and put register a over it
exe "norm! ggl\<c-v>2j2l\"ap"
call assert_equal(['L one 1', '', 'L one 3', ''], getline(1,4))
" clean up
bw!
call setreg('a', a[0], a[1])
endfunc

View File

@ -102,3 +102,107 @@ func Test_CmdUndefined()
call assert_fails('Dothat', 'E492:')
call assert_equal('yes', g:didnot)
endfunc
func Test_CmdErrors()
call assert_fails('com! docmd :', 'E183:')
call assert_fails('com! \<Tab> :', 'E182:')
call assert_fails('com! _ :', 'E182:')
call assert_fails('com! X :', 'E841:')
call assert_fails('com! - DoCmd :', 'E175:')
call assert_fails('com! -xxx DoCmd :', 'E181:')
call assert_fails('com! -addr DoCmd :', 'E179:')
call assert_fails('com! -complete DoCmd :', 'E179:')
call assert_fails('com! -complete=xxx DoCmd :', 'E180:')
call assert_fails('com! -complete=custom DoCmd :', 'E467:')
call assert_fails('com! -complete=customlist DoCmd :', 'E467:')
call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:')
call assert_fails('com! -nargs=x DoCmd :', 'E176:')
call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:')
call assert_fails('com! -count=x DoCmd :', 'E178:')
call assert_fails('com! -range=x DoCmd :', 'E178:')
com! -nargs=0 DoCmd :
call assert_fails('DoCmd x', 'E488:')
com! -nargs=1 DoCmd :
call assert_fails('DoCmd', 'E471:')
com! -nargs=+ DoCmd :
call assert_fails('DoCmd', 'E471:')
call assert_fails('com DoCmd :', 'E174:')
comclear
call assert_fails('delcom DoCmd', 'E184:')
endfunc
func CustomComplete(A, L, P)
return "January\nFebruary\nMars\n"
endfunc
func CustomCompleteList(A, L, P)
return [ "Monday", "Tuesday", "Wednesday" ]
endfunc
func Test_CmdCompletion()
call feedkeys(":com -\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -addr bang bar buffer complete count nargs range register', @:)
call feedkeys(":com -nargs=0 -\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -nargs=0 -addr bang bar buffer complete count nargs range register', @:)
call feedkeys(":com -nargs=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -nargs=* + 0 1 ?', @:)
call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:)
call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com -complete=color command compiler', @:)
command! DoCmd1 :
command! DoCmd2 :
call feedkeys(":com \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoCmd1 DoCmd2', @:)
call feedkeys(":DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd1 DoCmd2', @:)
call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"delcom DoCmd1 DoCmd2', @:)
delcom DoCmd1
call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"delcom DoCmd2', @:)
call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoCmd2', @:)
delcom DoCmd2
call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"delcom DoC', @:)
call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"com DoC', @:)
com! -complete=behave DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd mswin xterm', @:)
" This does not work. Why?
"call feedkeys(":DoCmd x\<C-A>\<C-B>\"\<CR>", 'tx')
"call assert_equal('"DoCmd xterm', @:)
com! -complete=custom,CustomComplete DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd January February Mars', @:)
com! -complete=customlist,CustomCompleteList DoCmd :
call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"DoCmd Monday Tuesday Wednesday', @:)
com! -complete=custom,CustomCompleteList DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E730:')
com! -complete=customlist,CustomComp DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
endfunc

View File

@ -1226,7 +1226,7 @@ func Test_num64()
call assert_equal( 9223372036854775807, 1 / 0)
call assert_equal(-9223372036854775807, -1 / 0)
call assert_equal(-9223372036854775808, 0 / 0)
call assert_equal(-9223372036854775807 - 1, 0 / 0)
call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))

View File

@ -764,6 +764,54 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
242,
/**/
241,
/**/
240,
/**/
239,
/**/
238,
/**/
237,
/**/
236,
/**/
235,
/**/
234,
/**/
233,
/**/
232,
/**/
231,
/**/
230,
/**/
229,
/**/
228,
/**/
227,
/**/
226,
/**/
225,
/**/
224,
/**/
223,
/**/
222,
/**/
221,
/**/
220,
/**/
219,
/**/
218,
/**/

View File

@ -1714,15 +1714,8 @@ typedef unsigned short disptick_T; /* display tick type */
typedef void *vim_acl_T; /* dummy to pass an ACL to a function */
/*
* Include a prototype for mch_memmove(), it may not be in alloc.pro.
*/
#ifdef VIM_MEMMOVE
void mch_memmove(void *, void *, size_t);
#else
# ifndef mch_memmove
# define mch_memmove(to, from, len) memmove(to, from, len)
# endif
#ifndef mch_memmove
# define mch_memmove(to, from, len) memmove((char*)(to), (char*)(from), (char*)(len))
#endif
/*