Compare commits

...

33 Commits

Author SHA1 Message Date
Bram Moolenaar
45600ce8f2 patch 8.0.0248: vim_strcat() cannot handle overlapping arguments
Problem:    vim_strcat() cannot handle overlapping arguments.
Solution:   Use mch_memmove() instead of strcpy(). (Justin M Keyes,
            closes #1415)
2017-01-27 21:54:07 +01:00
Bram Moolenaar
aed6d0b81a patch 8.0.0247: need to type Ctrl-N twice to select a completion
Problem:    Under some circumstances, one needs to type Ctrl-N or Ctrl-P twice
            to have a menu entry selected. (Lifepillar)
Solution:   call ins_compl_free(). (Christian Brabandt, closes #1411)
2017-01-27 21:48:54 +01:00
Bram Moolenaar
3a118be150 patch 8.0.0246: compiler warnings for int to pointer conversion
Problem:    Compiler warnings for int to pointer conversion.
Solution:   Fix macro for mch_memmove(). (John Marriott)
2017-01-27 21:22:19 +01:00
Bram Moolenaar
16038d50c4 patch 8.0.0245: zh_CN.cp936.po has a conversion error
Problem:    The generated zh_CN.cp936.po message file is not encoded properly.
Solution:   Instead of using zh_CN.po as input, use zh_CN.UTF-8.po.
2017-01-27 20:37:49 +01:00
Bram Moolenaar
d9c60648e5 patch 8.0.0244: making t_BE empty only has an effect before startup
Problem:    When the user sets t_BE empty after startup to disable bracketed
            paste, this has no direct effect.
Solution:   When t_BE is made empty write t_BD.  When t_BE is made non-empty
            write the new value.
2017-01-27 20:03:18 +01:00
Bram Moolenaar
cc5b22b3bf patch 8.0.0243: tolower() does not work if the byte count changes
Problem:    When making a character lower case with tolower() changes the byte
            cound, it is not made lower case.
Solution:   Add strlow_save(). (Dominique Pelle, closes #1406)
2017-01-26 22:51:56 +01:00
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
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
Bram Moolenaar
2b2207ba69 patch 8.0.0218: no completion for :cexpr and similar commands
Problem:    No command line completion for :cexpr, :cgetexpr, :caddexpr, etc.
Solution:   Make completion work. (Yegappan Lakshmanan)  Add a test.
2017-01-22 16:46:56 +01:00
Bram Moolenaar
e2d74dbe19 patch 8.0.0217: build fails without cscope feature
Problem:    Build fails without the cscope feature.
Solution:   Add #ifdef.
2017-01-22 16:13:35 +01:00
Bram Moolenaar
e2c6037da3 patch 8.0.0216: decoding js style json may fail
Problem:    When decoding JSON with a JS style object the JSON test may use a
            NULL pointer. (Coverity)
Solution:   Check for a NULL pointer.
2017-01-22 15:56:26 +01:00
36 changed files with 807 additions and 149 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.
@@ -2814,6 +2821,7 @@ set_completion(colnr_T startcol, list_T *list)
if (ctrl_x_mode != 0)
ins_compl_prep(' ');
ins_compl_clear();
ins_compl_free();
compl_direction = FORWARD;
if (startcol > curwin->w_cursor.col)
@@ -8620,6 +8628,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 +9464,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 +9514,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 +9540,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
}
}
@@ -12512,39 +12503,8 @@ f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
static void
f_tolower(typval_T *argvars, typval_T *rettv)
{
char_u *p;
p = vim_strsave(get_tv_string(&argvars[0]));
rettv->v_type = VAR_STRING;
rettv->vval.v_string = p;
if (p != NULL)
while (*p != NUL)
{
#ifdef FEAT_MBYTE
int l;
if (enc_utf8)
{
int c, lc;
c = utf_ptr2char(p);
lc = utf_tolower(c);
l = utf_ptr2len(p);
/* TODO: reallocate string when byte count changes. */
if (utf_char2len(lc) == l)
utf_char2bytes(lc, p);
p += l;
}
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
#endif
{
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
++p;
}
}
rettv->vval.v_string = strlow_save(get_tv_string(&argvars[0]));
}
/*

View File

@@ -4109,6 +4109,12 @@ set_one_cmd_context(
case CMD_echoerr:
case CMD_call:
case CMD_return:
case CMD_cexpr:
case CMD_caddexpr:
case CMD_cgetexpr:
case CMD_lexpr:
case CMD_laddexpr:
case CMD_lgetexpr:
set_context_for_expression(xp, arg, ea.cmdidx);
break;

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

@@ -629,10 +629,13 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
key = p = reader->js_buf + reader->js_used;
while (*p != NUL && *p != ':' && *p > ' ')
++p;
cur_item->v_type = VAR_STRING;
cur_item->vval.v_string = vim_strnsave(key, (int)(p - key));
if (cur_item != NULL)
{
cur_item->v_type = VAR_STRING;
cur_item->vval.v_string = vim_strnsave(key, (int)(p - key));
top_item->jd_key = cur_item->vval.v_string;
}
reader->js_used += (int)(p - key);
top_item->jd_key = cur_item->vval.v_string;
}
else
{
@@ -1053,7 +1056,8 @@ json_decode(js_read_T *reader, typval_T *res, int options)
/*
* Decode the JSON from "reader" to find the end of the message.
* "options" can be JSON_JS or zero;
* "options" can be JSON_JS or zero.
* This is only used for testing.
* Return FAIL if the message has a decoding error.
* Return MAYBE if the message is truncated, need to read more.
* This only works reliable if the message contains an object, array or

View File

@@ -107,6 +107,12 @@ test_decode_find_end(void)
reader.js_buf = (char_u *)" { ";
assert(json_find_end(&reader, 0) == MAYBE);
/* JS object with white space */
reader.js_buf = (char_u *)" { a : 123 } ";
assert(json_find_end(&reader, JSON_JS) == OK);
reader.js_buf = (char_u *)" { a : ";
assert(json_find_end(&reader, JSON_JS) == MAYBE);
/* array without white space */
reader.js_buf = (char_u *)"[\"a\",123]";
assert(json_find_end(&reader, 0) == OK);

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

@@ -1602,7 +1602,10 @@ strup_save(char_u *orig)
{
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
if (s == NULL)
break;
{
vim_free(res);
return NULL;
}
mch_memmove(s, res, p - res);
STRCPY(s + (p - res) + newl, p + l);
p = s + (p - res);
@@ -1625,6 +1628,69 @@ strup_save(char_u *orig)
return res;
}
/*
* Make string "s" all lower-case and return it in allocated memory.
* Handles multi-byte characters as well as possible.
* Returns NULL when out of memory.
*/
char_u *
strlow_save(char_u *orig)
{
char_u *p;
char_u *res;
res = p = vim_strsave(orig);
if (res != NULL)
while (*p != NUL)
{
# ifdef FEAT_MBYTE
int l;
if (enc_utf8)
{
int c, lc;
int newl;
char_u *s;
c = utf_ptr2char(p);
lc = utf_tolower(c);
/* Reallocate string when byte count changes. This is rare,
* thus it's OK to do another malloc()/free(). */
l = utf_ptr2len(p);
newl = utf_char2len(lc);
if (newl != l)
{
s = alloc((unsigned)STRLEN(res) + 1 + newl - l);
if (s == NULL)
{
vim_free(res);
return NULL;
}
mch_memmove(s, res, p - res);
STRCPY(s + (p - res) + newl, p + l);
p = s + (p - res);
vim_free(res);
res = s;
}
utf_char2bytes(lc, p);
p += newl;
}
else if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
p += l; /* skip multi-byte character */
else
# endif
{
*p = TOLOWER_LOC(*p); /* note that tolower() can be a macro */
p++;
}
}
return res;
}
#endif
/*
@@ -1653,7 +1719,7 @@ vim_strncpy(char_u *to, char_u *from, size_t len)
/*
* Like strcat(), but make sure the result fits in "tosize" bytes and is
* always NUL terminated.
* always NUL terminated. "from" and "to" may overlap.
*/
void
vim_strcat(char_u *to, char_u *from, size_t tosize)
@@ -1667,7 +1733,7 @@ vim_strcat(char_u *to, char_u *from, size_t tosize)
to[tosize - 1] = NUL;
}
else
STRCPY(to + tolen, from);
mch_memmove(to + tolen, from, fromlen + 1);
}
/*
@@ -1740,34 +1806,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

@@ -6619,6 +6619,15 @@ did_set_string_option(
mch_set_normal_colors();
#endif
}
if (varp == &T_BE && termcap_active)
{
if (*T_BE == NUL)
/* When clearing t_BE we assume the user no longer wants
* bracketed paste, thus disable it by writing t_BD. */
out_str(T_BD);
else
out_str(T_BE);
}
}
#ifdef FEAT_LINEBREAK

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

@@ -232,12 +232,13 @@ sk.cp1250.po: sk.po
iconv -f iso-8859-2 -t cp1250 sk.po | \
sed -e 's/charset=ISO-8859-2/charset=cp1250/' -e 's/# Original translations/# Generated from sk.po, DO NOT EDIT/' > sk.cp1250.po
# Convert zh_CN.po to create zh_CN.cp936.po.
# set 'charset' to gbk to avoid that msfmt generates a warning
zh_CN.cp936.po: zh_CN.po
# Convert zh_CN.UTF-8.po to create zh_CN.cp936.po.
# Set 'charset' to gbk to avoid that msfmt generates a warning.
# This used to convert from zh_CN.po, but that results in a conversion error.
zh_CN.cp936.po: zh_CN.UTF-8.po
rm -f zh_CN.cp936.po
iconv -f gb2312 -t cp936 zh_CN.po | \
sed -e 's/charset=gb2312/charset=gbk/' -e 's/# Original translations/# Generated from zh_CN.po, DO NOT EDIT/' > zh_CN.cp936.po
iconv -f UTF-8 -t cp936 zh_CN.UTF-8.po | \
sed -e 's/charset=utf-8/charset=gbk/' -e 's/# Original translations/# Generated from zh_CN.po, DO NOT EDIT/' > zh_CN.cp936.po
# Convert ko.UTF-8.po to create ko.po.
ko.po: ko.UTF-8.po

View File

@@ -40,6 +40,7 @@ char_u *vim_strsave_up(char_u *string);
char_u *vim_strnsave_up(char_u *string, int len);
void vim_strup(char_u *p);
char_u *strup_save(char_u *orig);
char_u *strlow_save(char_u *orig);
void del_trailing_spaces(char_u *ptr);
void vim_strncpy(char_u *to, char_u *from, size_t len);
void vim_strcat(char_u *to, char_u *from, size_t tosize);

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
@@ -1754,7 +1763,11 @@ line_read_in:
* The file name is followed by a ','.
* Remember etag file name in ebuf.
*/
if (*lbuf == Ctrl_L && !use_cscope)
if (*lbuf == Ctrl_L
# ifdef FEAT_CSCOPE
&& !use_cscope
# endif
)
{
is_etag = 1; /* in case at the start */
state = TS_LINEAR;
@@ -2277,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,6 +25,60 @@ 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')
return
endif
for cmd in [
\ 'let a = ',
\ 'if',
\ 'elseif',
\ 'while',
\ 'for',
\ 'echo',
\ 'echon',
\ 'execute',
\ 'echomsg',
\ 'echoerr',
\ 'call',
\ 'return',
\ 'cexpr',
\ 'caddexpr',
\ 'cgetexpr',
\ 'lexpr',
\ 'laddexpr',
\ 'lgetexpr']
call feedkeys(":" . cmd . " getl\<Tab>\<Home>\"\<CR>", 'xt')
call assert_equal('"' . cmd . ' getline(', getreg(':'))
endfor
endfunc
func Test_getcompletion()
if !has('cmdline_compl')
return
@@ -241,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

@@ -16,3 +16,148 @@ func Test_str2nr()
call assert_equal(123456789, str2nr('123456789'))
call assert_equal(-123456789, str2nr('-123456789'))
endfunc
func Test_tolower()
call assert_equal("", tolower(""))
" Test with all printable ASCII characters.
call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
\ tolower(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
if !has('multi_byte')
return
endif
" Test with a few uppercase diacritics.
call assert_equal("aàáâãäåāăąǎǟǡả", tolower("AÀÁÂÃÄÅĀĂĄǍǞǠẢ"))
call assert_equal("bḃḇ", tolower("BḂḆ"))
call assert_equal("cçćĉċč", tolower("CÇĆĈĊČ"))
call assert_equal("dďđḋḏḑ", tolower("DĎĐḊḎḐ"))
call assert_equal("eèéêëēĕėęěẻẽ", tolower("EÈÉÊËĒĔĖĘĚẺẼ"))
call assert_equal("fḟ ", tolower("FḞ "))
call assert_equal("gĝğġģǥǧǵḡ", tolower("GĜĞĠĢǤǦǴḠ"))
call assert_equal("hĥħḣḧḩ", tolower("HĤĦḢḦḨ"))
call assert_equal("iìíîïĩīĭįiǐỉ", tolower("IÌÍÎÏĨĪĬĮİǏỈ"))
call assert_equal("jĵ", tolower("JĴ"))
call assert_equal("kķǩḱḵ", tolower("KĶǨḰḴ"))
call assert_equal("lĺļľŀłḻ", tolower("LĹĻĽĿŁḺ"))
call assert_equal("mḿṁ", tolower("MḾṀ"))
call assert_equal("nñńņňṅṉ", tolower("NÑŃŅŇṄṈ"))
call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ"))
call assert_equal("pṕṗ", tolower("PṔṖ"))
call assert_equal("q", tolower("Q"))
call assert_equal("rŕŗřṙṟ", tolower("RŔŖŘṘṞ"))
call assert_equal("sśŝşšṡ", tolower("SŚŜŞŠṠ"))
call assert_equal("tţťŧṫṯ", tolower("TŢŤŦṪṮ"))
call assert_equal("uùúûüũūŭůűųưǔủ", tolower("UÙÚÛÜŨŪŬŮŰŲƯǓỦ"))
call assert_equal("vṽ", tolower("VṼ"))
call assert_equal("wŵẁẃẅẇ", tolower("WŴẀẂẄẆ"))
call assert_equal("xẋẍ", tolower("XẊẌ"))
call assert_equal("yýŷÿẏỳỷỹ", tolower("YÝŶŸẎỲỶỸ"))
call assert_equal("zźżžƶẑẕ", tolower("ZŹŻŽƵẐẔ"))
" Test with a few lowercase diacritics, which should remain unchanged.
call assert_equal("aàáâãäåāăąǎǟǡả", tolower("aàáâãäåāăąǎǟǡả"))
call assert_equal("bḃḇ", tolower("bḃḇ"))
call assert_equal("cçćĉċč", tolower("cçćĉċč"))
call assert_equal("dďđḋḏḑ", tolower("dďđḋḏḑ"))
call assert_equal("eèéêëēĕėęěẻẽ", tolower("eèéêëēĕėęěẻẽ"))
call assert_equal("fḟ", tolower("fḟ"))
call assert_equal("gĝğġģǥǧǵḡ", tolower("gĝğġģǥǧǵḡ"))
call assert_equal("hĥħḣḧḩẖ", tolower("hĥħḣḧḩẖ"))
call assert_equal("iìíîïĩīĭįǐỉ", tolower("iìíîïĩīĭįǐỉ"))
call assert_equal("jĵǰ", tolower("jĵǰ"))
call assert_equal("kķǩḱḵ", tolower("kķǩḱḵ"))
call assert_equal("lĺļľŀłḻ", tolower("lĺļľŀłḻ"))
call assert_equal("mḿṁ ", tolower("mḿṁ "))
call assert_equal("nñńņňʼnṅṉ", tolower("nñńņňʼnṅṉ"))
call assert_equal("oòóôõöøōŏőơǒǫǭỏ", tolower("oòóôõöøōŏőơǒǫǭỏ"))
call assert_equal("pṕṗ", tolower("pṕṗ"))
call assert_equal("q", tolower("q"))
call assert_equal("rŕŗřṙṟ", tolower("rŕŗřṙṟ"))
call assert_equal("sśŝşšṡ", tolower("sśŝşšṡ"))
call assert_equal("tţťŧṫṯẗ", tolower("tţťŧṫṯẗ"))
call assert_equal("uùúûüũūŭůűųưǔủ", tolower("uùúûüũūŭůűųưǔủ"))
call assert_equal("vṽ", tolower("vṽ"))
call assert_equal("wŵẁẃẅẇẘ", tolower("wŵẁẃẅẇẘ"))
call assert_equal("ẋẍ", tolower("ẋẍ"))
call assert_equal("yýÿŷẏẙỳỷỹ", tolower("yýÿŷẏẙỳỷỹ"))
call assert_equal("zźżžƶẑẕ", tolower("zźżžƶẑẕ"))
" According to https://twitter.com/jifa/status/625776454479970304
" Ⱥ (U+023A) and Ⱦ (U+023E) are the *only* code points to increase
" in length (2 to 3 bytes) when lowercased. So let's test them.
call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ"))
endfunc
func Test_toupper()
call assert_equal("", toupper(""))
" Test with all printable ASCII characters.
call assert_equal(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~',
\ toupper(' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'))
if !has('multi_byte')
return
endif
" Test with a few lowercase diacritics.
call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("aàáâãäåāăąǎǟǡả"))
call assert_equal("BḂḆ", toupper("bḃḇ"))
call assert_equal("CÇĆĈĊČ", toupper("cçćĉċč"))
call assert_equal("DĎĐḊḎḐ", toupper("dďđḋḏḑ"))
call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("eèéêëēĕėęěẻẽ"))
call assert_equal("FḞ", toupper("fḟ"))
call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("gĝğġģǥǧǵḡ"))
call assert_equal("HĤĦḢḦḨẖ", toupper("hĥħḣḧḩẖ"))
call assert_equal("IÌÍÎÏĨĪĬĮǏỈ", toupper("iìíîïĩīĭįǐỉ"))
call assert_equal("JĴǰ", toupper("jĵǰ"))
call assert_equal("KĶǨḰḴ", toupper("kķǩḱḵ"))
call assert_equal("LĹĻĽĿŁḺ", toupper("lĺļľŀłḻ"))
call assert_equal("MḾṀ ", toupper("mḿṁ "))
call assert_equal("NÑŃŅŇʼnṄṈ", toupper("nñńņňʼnṅṉ"))
call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("oòóôõöøōŏőơǒǫǭỏ"))
call assert_equal("PṔṖ", toupper("pṕṗ"))
call assert_equal("Q", toupper("q"))
call assert_equal("RŔŖŘṘṞ", toupper("rŕŗřṙṟ"))
call assert_equal("SŚŜŞŠṠ", toupper("sśŝşšṡ"))
call assert_equal("TŢŤŦṪṮẗ", toupper("tţťŧṫṯẗ"))
call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("uùúûüũūŭůűųưǔủ"))
call assert_equal("VṼ", toupper("vṽ"))
call assert_equal("WŴẀẂẄẆẘ", toupper("wŵẁẃẅẇẘ"))
call assert_equal("ẊẌ", toupper("ẋẍ"))
call assert_equal("YÝŸŶẎẙỲỶỸ", toupper("yýÿŷẏẙỳỷỹ"))
call assert_equal("ZŹŻŽƵẐẔ", toupper("zźżžƶẑẕ"))
" Test that uppercase diacritics, which should remain unchanged.
call assert_equal("AÀÁÂÃÄÅĀĂĄǍǞǠẢ", toupper("AÀÁÂÃÄÅĀĂĄǍǞǠẢ"))
call assert_equal("BḂḆ", toupper("BḂḆ"))
call assert_equal("CÇĆĈĊČ", toupper("CÇĆĈĊČ"))
call assert_equal("DĎĐḊḎḐ", toupper("DĎĐḊḎḐ"))
call assert_equal("EÈÉÊËĒĔĖĘĚẺẼ", toupper("EÈÉÊËĒĔĖĘĚẺẼ"))
call assert_equal("FḞ ", toupper("FḞ "))
call assert_equal("GĜĞĠĢǤǦǴḠ", toupper("GĜĞĠĢǤǦǴḠ"))
call assert_equal("HĤĦḢḦḨ", toupper("HĤĦḢḦḨ"))
call assert_equal("IÌÍÎÏĨĪĬĮİǏỈ", toupper("IÌÍÎÏĨĪĬĮİǏỈ"))
call assert_equal("JĴ", toupper("JĴ"))
call assert_equal("KĶǨḰḴ", toupper("KĶǨḰḴ"))
call assert_equal("LĹĻĽĿŁḺ", toupper("LĹĻĽĿŁḺ"))
call assert_equal("MḾṀ", toupper("MḾṀ"))
call assert_equal("NÑŃŅŇṄṈ", toupper("NÑŃŅŇṄṈ"))
call assert_equal("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ", toupper("OÒÓÔÕÖØŌŎŐƠǑǪǬỎ"))
call assert_equal("PṔṖ", toupper("PṔṖ"))
call assert_equal("Q", toupper("Q"))
call assert_equal("RŔŖŘṘṞ", toupper("RŔŖŘṘṞ"))
call assert_equal("SŚŜŞŠṠ", toupper("SŚŜŞŠṠ"))
call assert_equal("TŢŤŦṪṮ", toupper("TŢŤŦṪṮ"))
call assert_equal("UÙÚÛÜŨŪŬŮŰŲƯǓỦ", toupper("UÙÚÛÜŨŪŬŮŰŲƯǓỦ"))
call assert_equal("VṼ", toupper("VṼ"))
call assert_equal("WŴẀẂẄẆ", toupper("WŴẀẂẄẆ"))
call assert_equal("XẊẌ", toupper("XẊẌ"))
call assert_equal("YÝŶŸẎỲỶỸ", toupper("YÝŶŸẎỲỶỸ"))
call assert_equal("ZŹŻŽƵẐẔ", toupper("ZŹŻŽƵẐẔ"))
call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ"))
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

View File

@@ -7,10 +7,10 @@ func! ListMonths()
if g:setting != ''
exe ":set" g:setting
endif
let mth=copy(g:months)
let mth = copy(g:months)
let entered = strcharpart(getline('.'),0,col('.'))
if !empty(entered)
let mth=filter(mth, 'v:val=~"^".entered')
let mth = filter(mth, 'v:val=~"^".entered')
endif
call complete(1, mth)
return ''
@@ -468,7 +468,7 @@ endfunc
" auto-wrap text.
func Test_completion_ctrl_e_without_autowrap()
new
let tw_save=&tw
let tw_save = &tw
set tw=78
let li = [
\ '" zzz',
@@ -478,8 +478,37 @@ func Test_completion_ctrl_e_without_autowrap()
call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx")
call assert_equal(li, getline(1, '$'))
let &tw=tw_save
let &tw = tw_save
q!
endfunc
function! DummyCompleteSix()
call complete(1, ['Hello', 'World'])
return ''
endfunction
" complete() correctly clears the list of autocomplete candidates
" See #1411
func Test_completion_clear_candidate_list()
new
%d
" select first entry from the completion popup
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>", "tx")
call assert_equal('Hello', getline(1))
%d
" select second entry from the completion popup
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>", "tx")
call assert_equal('World', getline(1))
%d
" select original text
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>", "tx")
call assert_equal(' xxx', getline(1))
%d
" back at first entry from completion list
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>\<C-N>", "tx")
call assert_equal('Hello', getline(1))
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab

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,72 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
248,
/**/
247,
/**/
246,
/**/
245,
/**/
244,
/**/
243,
/**/
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,
/**/
217,
/**/
216,
/**/
215,
/**/

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), (size_t)(len))
#endif
/*