Compare commits

...

20 Commits

Author SHA1 Message Date
Bram Moolenaar
5b3af14b34 patch 8.0.0386: tiny build has a problem with generating the options test
Problem:    Tiny build has a problem with generating the options test.
Solution:   Change the "if" to skip over statements.
2017-02-27 22:59:40 +01:00
Bram Moolenaar
b5e8377364 patch 8.0.0385: no tests for arabic
Problem:    No tests for arabic.
Solution:   Add a first test for arabic. (Dominique Pelle, closes #1518)
2017-02-27 21:48:26 +01:00
Bram Moolenaar
d512e17ea4 patch 8.0.0384: timer test failed for no apparent reason
Problem:    Timer test failed for no apparent reason.
Solution:   Mark the test as flaky.
2017-02-27 21:35:53 +01:00
Bram Moolenaar
10a8da0594 patch 8.0.0383: misplaced #ifdef
Problem:    Misplaced #ifdef. (Christ van Willigen)
Solution:   Split assignment.
2017-02-27 21:11:35 +01:00
Bram Moolenaar
88e7688eda patch 8.0.0382: warning in tiny build for unused variable
Problem:    Warning in tiny build for unused variable. (Tony Mechelynck)
Solution:   Add #ifdefs.
2017-02-27 20:33:46 +01:00
Bram Moolenaar
aeb661e1f4 patch 8.0.0381: diff mode is not sufficiently tested
Problem:    Diff mode is not sufficiently tested.
Solution:   Add more diff mode tests. (Dominique Pelle, closes #1515)
2017-02-26 19:59:59 +01:00
Bram Moolenaar
38632faf63 patch 8.0.0380: with 'linebreak' double wide char wraps badly
Problem:    With 'linebreak' set and 'breakat' includes ">" a double-wide
            character results in "<<" displayed.
Solution:   Check for the character not to be replaced. (Ozaki Kiichi,
            closes #1456)
2017-02-26 19:40:59 +01:00
Bram Moolenaar
74a47162a0 patch 8.0.0379: CTRL-Z and mouse click use CTRL-O unnecessary
Problem:    CTRL-Z and mouse click use CTRL-O unnecessary.
Solution:   Remove stuffing CTRL-O. (James McCoy, closes #1453)
2017-02-26 19:09:05 +01:00
Bram Moolenaar
0c8485f0e4 patch 8.0.0378: possible overflow when reading corrupted undo file
Problem:    Another possible overflow when reading corrupted undo file.
Solution:   Check if allocated size is not too big. (King)
2017-02-26 18:17:10 +01:00
Bram Moolenaar
3eb1637b1b patch 8.0.0377: possible overflow when reading corrupted undo file
Problem:    Possible overflow when reading corrupted undo file.
Solution:   Check if allocated size is not too big. (King)
2017-02-26 18:11:36 +01:00
Bram Moolenaar
6d3c8586fc patch 8.0.0376: size computations in spell file reading are off
Problem:    Size computations in spell file reading are not exactly right.
Solution:   Make "len" a "long" and check with LONG_MAX.
2017-02-26 15:27:23 +01:00
Bram Moolenaar
5074a0e033 patch 8.0.0375: the "+ register is not tested
Problem:    The "+ register is not tested.
Solution:   Add a test using another Vim instance to change the "+ register.
            (Kazuki Kuriyama)
2017-02-26 15:08:21 +01:00
Bram Moolenaar
ba748c8a84 patch 8.0.0374: invalid memory access when using :sc in Ex mode
Problem:    Invalid memory access when using :sc in Ex mode. (Dominique Pelle)
Solution:   Avoid the column being negative.  Also fix a hang in Ex mode.
2017-02-26 14:00:07 +01:00
Bram Moolenaar
376407674f patch 8.0.0373: build fails without +folding
Problem:    Build fails without +folding.
Solution:   Move misplaced #ifdef.
2017-02-25 22:37:15 +01:00
Bram Moolenaar
a713ff819d patch 8.0.0372: more options are not always defined
Problem:    More options are not always defined.
Solution:   Consistently define all possible options.
2017-02-25 22:18:43 +01:00
Bram Moolenaar
14c2e18b63 patch 8.0.0371: leaking memory when setting v:completed_item
Problem:    Leaking memory when setting v:completed_item.
Solution:   Or the flags instead of setting them.
2017-02-25 21:39:17 +01:00
Bram Moolenaar
a12e40351d patch 8.0.0370: invalid memory access when setting wildchar empty
Problem:    Invalid memory access when setting wildchar empty.
Solution:   Avoid going over the end of the option value. (Dominique Pelle,
            closes #1509)  Make option test check all number options with
            empty value.
2017-02-25 21:37:57 +01:00
Bram Moolenaar
c43a8b8de0 patch 8.0.0369: a few options are not defined, depending on features
Problem:    The 'balloondelay', 'ballooneval' and 'balloonexpr' options are
            not defined without the +balloon_eval feature. Testing that an
            option value fails does not work for unsupported options.
Solution:   Make the options defined but not supported.  Don't test if
            setting unsupported options fails.
2017-02-25 21:12:29 +01:00
Bram Moolenaar
2f5463df01 patch 8.0.0368: not all options are tested with a range of values
Problem:    Not all options are tested with a range of values.
Solution:   Generate a test script from the source code.
2017-02-25 20:40:46 +01:00
Bram Moolenaar
f7506cade4 patch 8.0.0367: types in include files may be inconsistent
Problem:    If configure defines _LARGE_FILES some include files are included
            before it is defined.
Solution:   Include vim.h first. (Sam Thursfield, closes #1508)
2017-02-25 16:01:49 +01:00
27 changed files with 752 additions and 98 deletions

View File

@@ -97,6 +97,7 @@ SRC_ALL = \
src/tee/tee.c \
src/xxd/xxd.c \
src/main.aap \
src/gen_opt_test.vim \
src/testdir/main.aap \
src/testdir/README.txt \
src/testdir/Make_all.mak \

View File

@@ -2025,6 +2025,7 @@ test check: scripttests unittests
#
scripttests:
$(MAKE) -f Makefile $(VIMTARGET)
$(MAKE) -f Makefile testdir/opt_test.vim
if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
cd $(PODIR); $(MAKE) -f Makefile check VIM=../$(VIMTARGET); \
fi
@@ -2033,6 +2034,8 @@ scripttests:
fi
cd testdir; $(MAKE) -f Makefile $(GUI_TESTTARGET) VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
testdir/opt_test.vim: option.c gen_opt_test.vim
./$(VIMTARGET) -u gen_opt_test.vim --noplugin --not-a-term
# Run the tests with the GUI. Assumes vim/gvim was already built
testgui:
@@ -2089,6 +2092,7 @@ test1 \
# Run individual NEW style test, assuming that Vim was already compiled.
test_arglist \
test_arabic \
test_assert \
test_assign \
test_autochdir \
@@ -2753,6 +2757,7 @@ clean celan: testclean
-rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o
-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c auto/gui_gtk_gresources.c auto/gui_gtk_gresources.h
-rm -f conftest* *~ auto/link.sed
-rm -f testdir/opt_test.vim
-rm -f $(UNITTEST_TARGETS)
-rm -f runtime pixmaps
-rm -rf $(APPDIR)
@@ -2767,7 +2772,7 @@ SHADOWDIR = shadow
shadow: runtime pixmaps
mkdir $(SHADOWDIR)
cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs .
cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.vim ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs .
mkdir $(SHADOWDIR)/auto
cd $(SHADOWDIR)/auto; ln -s ../../auto/configure .
mkdir $(SHADOWDIR)/po

View File

@@ -1038,8 +1038,10 @@ doESCkey:
if (!p_im)
goto normalchar; /* insert CTRL-Z as normal char */
do_cmdline_cmd((char_u *)"stop");
c = Ctrl_O;
/*FALLTHROUGH*/
#ifdef CURSOR_SHAPE
ui_cursor_shape(); /* may need to update cursor shape */
#endif
continue;
case Ctrl_O: /* execute one command */
#ifdef FEAT_COMPL_FUNC

View File

@@ -6640,7 +6640,7 @@ set_vim_var_dict(int idx, dict_T *val)
if (HASHITEM_EMPTY(hi))
continue;
--todo;
HI2DI(hi)->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
HI2DI(hi)->di_flags |= DI_FLAGS_RO | DI_FLAGS_FIX;
}
}
}

View File

@@ -5288,6 +5288,8 @@ do_sub(exarg_T *eap)
getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);
curwin->w_cursor.col = regmatch.endpos[0].col - 1;
if (curwin->w_cursor.col < 0)
curwin->w_cursor.col = 0;
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);
if (subflags.do_number || curwin->w_p_nu)
{

View File

@@ -2369,9 +2369,16 @@ getexmodeline(
if (ga_grow(&line_ga, 40) == FAIL)
break;
/* Get one character at a time. */
/*
* Get one character at a time.
*/
prev_char = c1;
c1 = vgetc();
/* Check for a ":normal" command and no more characters left. */
if (ex_normal_busy > 0 && typebuf.tb_len == 0)
c1 = '\n';
else
c1 = vgetc();
/*
* Handle line editing.

196
src/gen_opt_test.vim Normal file
View File

@@ -0,0 +1,196 @@
" Script to generate testdir/opt_test.vim from option.c
set cpo=&vim
" Only do this when build with the +eval feature.
if 1
set nomore
let script = [
\ 'let save_columns = &columns',
\ 'let save_lines = &lines',
\ 'let save_term = &term',
\ ]
edit option.c
/#define p_term
let end = line('.')
" Two lists with values: values that work and values that fail.
" When not listed, "othernum" or "otherstring" is used.
let test_values = {
\ 'cmdheight': [[1, 2, 10], [-1, 0]],
\ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
\ 'columns': [[12, 80], [-1, 0, 10]],
\ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
\ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
\ 'helpheight': [[0, 10, 100], [-1]],
\ 'history': [[0, 1, 100], [-1, 10001]],
\ 'iminsert': [[0, 1], [-1, 3, 999]],
\ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
\ 'lines': [[2, 24], [-1, 0, 1]],
\ 'numberwidth': [[1, 4, 8, 10], [-1, 0, 11]],
\ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
\ 'report': [[0, 1, 2, 9999], [-1]],
\ 'scroll': [[0, 1, 2, 20], [-1]],
\ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
\ 'scrolloff': [[0, 1, 2, 20], [-1]],
\ 'shiftwidth': [[0, 1, 8, 999], [-1]],
\ 'sidescroll': [[0, 1, 8, 999], [-1]],
\ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
\ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
\ 'textwidth': [[0, 1, 8, 99], [-1]],
\ 'timeoutlen': [[0, 8, 99999], [-1]],
\ 'titlelen': [[0, 1, 8, 9999], [-1]],
\ 'updatecount': [[0, 1, 8, 9999], [-1]],
\ 'updatetime': [[0, 1, 8, 9999], [-1]],
\ 'verbose': [[-1, 0, 1, 8, 9999], []],
\ 'wildcharm': [[-1, 0, 100], []],
\ 'winheight': [[1, 10, 999], [-1, 0]],
\ 'winminheight': [[0, 1], [-1]],
\ 'winminwidth': [[0, 1, 10], [-1]],
\ 'winwidth': [[1, 10, 999], [-1, 0]],
\
\ 'ambiwidth': [['', 'single'], ['xxx']],
\ 'background': [['', 'light', 'dark'], ['xxx']],
\ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']],
\ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
\ 'backupext': [['xxx'], ['']],
\ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
\ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
\ 'browsedir': [['', 'last', '/tmp/'], ['xxx']],
\ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
\ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
\ 'casemap': [['', 'internal'], ['xxx']],
\ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
\ 'clipboard': [['', 'unnamed', 'autoselect,unnamed'], ['xxx']],
\ 'colorcolumn': [['', '8', '+2'], ['xxx']],
\ 'comments': [['', 'b:#'], ['xxx']],
\ 'commentstring': [['', '/*%s*/'], ['xxx']],
\ 'complete': [['', 'w,b'], ['xxx']],
\ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
\ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
\ 'cryptmethod': [['', 'zip'], ['xxx']],
\ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
\ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
\ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx']],
\ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
\ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
\ 'encoding': [['latin1'], ['xxx', '']],
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
\ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
\ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
\ 'fillchars': [['', 'vert:x'], ['xxx']],
\ 'foldclose': [['', 'all'], ['xxx']],
\ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
\ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
\ 'foldmarker': [['((,))'], ['', 'xxx']],
\ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
\ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
\ 'helplang': [['', 'de', 'de,it'], ['xxx']],
\ 'highlight': [['', 'e:Error'], ['xxx']],
\ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
\ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
\ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
\ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
\ 'keymap': [['', 'accents'], ['xxx']],
\ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
\ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
\ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
\ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
\ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
\ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
\ 'mousemodel': [['', 'popup'], ['xxx']],
\ 'mouseshape': [['', 'n:arrow'], ['xxx']],
\ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
\ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
\ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
\ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
\ 'selection': [['old', 'inclusive'], ['', 'xxx']],
\ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
\ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
\ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
\ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
\ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
\ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
\ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
\ 'term': [['ansi'], ['', 'gui']],
\ 'toolbar': [['', 'icons', 'text'], ['xxx']],
\ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
\ 'ttymouse': [['', 'xterm'], ['xxx']],
\ 'ttytype': [['ansi'], ['', 'gui']],
\ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
\ 'viminfo': [['', '''50', '"30'], ['xxx']],
\ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
\ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
\ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']],
\ 'wildoptions': [['', 'tagfile'], ['xxx']],
\ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
\
\ 'luadll': [[], []],
\ 'perldll': [[], []],
\ 'pythondll': [[], []],
\ 'pythonthreedll': [[], []],
\ 'pyxversion': [[], []],
\ 'rubydll': [[], []],
\ 'tcldll': [[], []],
\
\ 'othernum': [[-1, 0, 100], ['']],
\ 'otherstring': [['', 'xxx'], []],
\}
1
/struct vimoption options
while 1
/{"
if line('.') > end
break
endif
let line = getline('.')
let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
if has_key(test_values, name)
let a = test_values[name]
elseif line =~ 'P_NUM'
let a = test_values['othernum']
else
let a = test_values['otherstring']
endif
if len(a[0]) > 0 || len(a[1]) > 0
if line =~ 'P_BOOL'
call add(script, 'set ' . name)
call add(script, 'set ' . shortname)
call add(script, 'set no' . name)
call add(script, 'set no' . shortname)
else
for val in a[0]
call add(script, 'set ' . name . '=' . val)
call add(script, 'set ' . shortname . '=' . val)
endfor
" setting an option can only fail when it's implemented.
call add(script, "if exists('+" . name . "')")
for val in a[1]
call add(script, "call assert_fails('set " . name . "=" . val . "')")
call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
endfor
call add(script, "endif")
endif
call add(script, 'set ' . name . '&')
call add(script, 'set ' . shortname . '&')
endif
endwhile
call add(script, 'let &term = save_term')
call add(script, 'let &columns = save_columns')
call add(script, 'let &lines = save_lines')
call writefile(script, 'testdir/opt_test.vim')
endif
qa!

View File

@@ -60,11 +60,12 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* created by weissman, Mon Jul 7 13:20:03 1986 */
/* converted by swick, Thu Aug 27 1987 */
#include "vim.h"
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/XawInit.h>
#include "vim.h"
#include "gui_at_sb.h"
#include <X11/Xmu/Drawing.h>

View File

@@ -9,6 +9,8 @@
* See README.txt for an overview of the Vim source code.
*/
#include "vim.h"
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#ifdef FEAT_GUI_NEXTAW
@@ -34,7 +36,6 @@
# include <X11/Xaw/AsciiText.h>
#endif /* FEAT_GUI_NEXTAW */
#include "vim.h"
#ifndef FEAT_GUI_NEXTAW
# include "gui_at_sb.h"
#endif

View File

@@ -8,6 +8,8 @@
* See README.txt for an overview of the Vim source code.
*/
#include "vim.h"
#include <Xm/Form.h>
#include <Xm/RowColumn.h>
#include <Xm/PushB.h>
@@ -33,8 +35,6 @@
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include "vim.h"
#ifdef HAVE_X11_XPM_H
# include <X11/xpm.h>
#else

View File

@@ -12,6 +12,8 @@
* Not used for GTK.
*/
#include "vim.h"
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/StringDefs.h>
@@ -19,8 +21,6 @@
#include <X11/Shell.h>
#include <X11/cursorfont.h>
#include "vim.h"
/*
* For Workshop XpmP.h is preferred, because it makes the signs drawn with a
* transparent background instead of black.

View File

@@ -16,6 +16,8 @@
* when using a dynamic scrollbar policy.
*/
#include "vim.h"
#include <Xm/Form.h>
#include <Xm/PushBG.h>
#include <Xm/Text.h>
@@ -36,8 +38,6 @@
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include "vim.h"
extern Widget vimShell;
#ifdef FEAT_MENU

View File

@@ -2982,8 +2982,6 @@ do_mouse(
|| (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)
&& bt_quickfix(curbuf))
{
if (State & INSERT)
stuffcharReadbuff(Ctrl_O);
if (curwin->w_llist_ref == NULL) /* quickfix window */
do_cmdline_cmd((char_u *)".cc");
else /* location list window */
@@ -6193,10 +6191,12 @@ nv_down(cmdarg_T *cap)
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
/* In a quickfix window a <CR> jumps to the error under the cursor. */
if (bt_quickfix(curbuf) && cap->cmdchar == CAR)
{
if (curwin->w_llist_ref == NULL)
do_cmdline_cmd((char_u *)".cc"); /* quickfix window */
else
do_cmdline_cmd((char_u *)".ll"); /* location list window */
}
else
#endif
{

View File

@@ -559,11 +559,15 @@ static struct vimoption options[] =
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
#ifdef FEAT_AUTOCHDIR
{"autochdir", "acd", P_BOOL|P_VI_DEF,
#ifdef FEAT_AUTOCHDIR
(char_u *)&p_acd, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{(char_u *)FALSE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"autoindent", "ai", P_BOOL|P_VI_DEF,
(char_u *)&p_ai, PV_AI,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
@@ -624,19 +628,33 @@ static struct vimoption options[] =
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
#ifdef FEAT_BEVAL
{"balloondelay","bdlay",P_NUM|P_VI_DEF,
#ifdef FEAT_BEVAL
(char_u *)&p_bdlay, PV_NONE,
{(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
{"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
(char_u *)&p_beval, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
# ifdef FEAT_EVAL
{"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
(char_u *)&p_bexpr, PV_BEXPR,
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
# endif
{(char_u *)600L, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
#ifdef FEAT_BEVAL
(char_u *)&p_beval, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
(char_u *)&p_bexpr, PV_BEXPR,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"beautify", "bf", P_BOOL|P_VI_DEF,
(char_u *)NULL, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
@@ -1196,62 +1214,125 @@ static struct vimoption options[] =
{"flash", "fl", P_BOOL|P_VI_DEF,
(char_u *)NULL, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
#ifdef FEAT_FOLDING
{"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)&p_fcl, PV_NONE,
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FDC,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{(char_u *)FALSE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FEN,
{(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
{(char_u *)TRUE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
# ifdef FEAT_EVAL
#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
(char_u *)VAR_WIN, PV_FDE,
{(char_u *)"0", (char_u *)NULL}
# else
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
# endif
#endif
SCRIPTID_INIT},
{"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FDI,
{(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
{"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
(char_u *)VAR_WIN, PV_FDL,
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
{"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
(char_u *)&p_fdls, PV_NONE,
{(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
{"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
P_RWIN|P_ONECOMMA|P_NODUP,
(char_u *)VAR_WIN, PV_FMR,
{(char_u *)"{{{,}}}", (char_u *)NULL}
SCRIPTID_INIT},
{"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
(char_u *)VAR_WIN, PV_FDM,
{(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
{"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
(char_u *)VAR_WIN, PV_FML,
{(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
{"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
(char_u *)VAR_WIN, PV_FDN,
{(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
{"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
(char_u *)&p_fdo, PV_NONE,
{(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
(char_u *)0L} SCRIPTID_INIT},
{"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
# ifdef FEAT_EVAL
(char_u *)VAR_WIN, PV_FDT,
{(char_u *)"foldtext()", (char_u *)NULL}
# else
{(char_u *)"#", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
# endif
SCRIPTID_INIT},
#endif
SCRIPTID_INIT},
{"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FDL,
{(char_u *)0L, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
#ifdef FEAT_FOLDING
(char_u *)&p_fdls, PV_NONE,
{(char_u *)-1L, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
P_RWIN|P_ONECOMMA|P_NODUP,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FMR,
{(char_u *)"{{{,}}}", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FDM,
{(char_u *)"manual", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FML,
{(char_u *)1L, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
#ifdef FEAT_FOLDING
(char_u *)VAR_WIN, PV_FDN,
{(char_u *)20L, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
#ifdef FEAT_FOLDING
(char_u *)&p_fdo, PV_NONE,
{(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
(char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
(char_u *)VAR_WIN, PV_FDT,
{(char_u *)"foldtext()", (char_u *)NULL}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
#ifdef FEAT_EVAL
(char_u *)&p_fex, PV_FEX,
@@ -1789,17 +1870,24 @@ static struct vimoption options[] =
{"loadplugins", "lpl", P_BOOL|P_VI_DEF,
(char_u *)&p_lpl, PV_NONE,
{(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
#if defined(DYNAMIC_LUA)
{"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_LUA)
(char_u *)&p_luadll, PV_NONE,
{(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)"", (char_u *)0L}
#endif
SCRIPTID_INIT},
#endif
#ifdef FEAT_GUI_MAC
{"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
#ifdef FEAT_GUI_MAC
(char_u *)&p_macatsui, PV_NONE,
{(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
{(char_u *)TRUE, (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)"", (char_u *)0L}
#endif
SCRIPTID_INIT},
{"magic", NULL, P_BOOL|P_VI_DEF,
(char_u *)&p_magic, PV_NONE,
{(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
@@ -2031,12 +2119,15 @@ static struct vimoption options[] =
(char_u *)".,/usr/include,,",
#endif
(char_u *)0L} SCRIPTID_INIT},
#if defined(DYNAMIC_PERL)
{"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_PERL)
(char_u *)&p_perldll, PV_NONE,
{(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
SCRIPTID_INIT},
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_pi, PV_PI,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
@@ -2142,18 +2233,24 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
#if defined(DYNAMIC_PYTHON3)
{"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_PYTHON3)
(char_u *)&p_py3dll, PV_NONE,
{(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
SCRIPTID_INIT},
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
#if defined(DYNAMIC_PYTHON)
SCRIPTID_INIT},
{"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_PYTHON)
(char_u *)&p_pydll, PV_NONE,
{(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
SCRIPTID_INIT},
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
(char_u *)&p_pyx, PV_NONE,
@@ -2235,12 +2332,15 @@ static struct vimoption options[] =
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
#if defined(DYNAMIC_RUBY)
{"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_RUBY)
(char_u *)&p_rubydll, PV_NONE,
{(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
SCRIPTID_INIT},
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
#ifdef FEAT_CMDL_INFO
(char_u *)&p_ru, PV_NONE,
@@ -2628,12 +2728,15 @@ static struct vimoption options[] =
{"tagstack", "tgst", P_BOOL|P_VI_DEF,
(char_u *)&p_tgst, PV_NONE,
{(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
#if defined(DYNAMIC_TCL)
{"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
#if defined(DYNAMIC_TCL)
(char_u *)&p_tcldll, PV_NONE,
{(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
SCRIPTID_INIT},
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
(char_u *)&T_NAME, PV_NONE,
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
@@ -2728,17 +2831,24 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
{"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
(char_u *)&p_toolbar, PV_NONE,
{(char_u *)"icons,tooltips", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
#endif
#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
{"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
(char_u *)&p_tbis, PV_NONE,
{(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
{(char_u *)"small", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_ttimeout, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
@@ -4598,7 +4708,7 @@ do_set(
|| (long *)varp == &p_wcm)
&& (*arg == '<'
|| *arg == '^'
|| ((!arg[1] || vim_iswhite(arg[1]))
|| (*arg != NUL && (!arg[1] || vim_iswhite(arg[1]))
&& !VIM_ISDIGIT(*arg))))
{
value = string_to_key(arg);
@@ -5829,7 +5939,7 @@ set_string_option(
opt_flags)) == NULL)
did_set_option(opt_idx, opt_flags, TRUE);
/* call autocomamnd after handling side effects */
/* call autocommand after handling side effects */
#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
if (saved_oldval != NULL)
{

View File

@@ -4189,6 +4189,10 @@ win_line(
}
else
{
#ifdef FEAT_LINEBREAK
int c0;
#endif
if (p_extra_free != NULL)
{
vim_free(p_extra_free);
@@ -4198,6 +4202,9 @@ win_line(
* Get a character from the line itself.
*/
c = *ptr;
#ifdef FEAT_LINEBREAK
c0 = *ptr;
#endif
#ifdef FEAT_MBYTE
if (has_mbyte)
{
@@ -4214,7 +4221,12 @@ win_line(
/* Overlong encoded ASCII or ASCII with composing char
* is displayed normally, except a NUL. */
if (mb_c < 0x80)
{
c = mb_c;
# ifdef FEAT_LINEBREAK
c0 = mb_c;
# endif
}
mb_utf8 = TRUE;
/* At start of the line we can have a composing char.
@@ -4538,7 +4550,8 @@ win_line(
/*
* Found last space before word: check for line break.
*/
if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr))
if (wp->w_p_lbr && c0 == c
&& vim_isbreak(c) && !vim_isbreak(*ptr))
{
# ifdef FEAT_MBYTE
int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;

View File

@@ -1585,7 +1585,7 @@ spell_read_tree(
int prefixtree, /* TRUE for the prefix tree */
int prefixcnt) /* when "prefixtree" is TRUE: prefix count */
{
int len;
long len;
int idx;
char_u *bp;
idx_T *ip;
@@ -1595,7 +1595,7 @@ spell_read_tree(
len = get4c(fd);
if (len < 0)
return SP_TRUNCERROR;
if (len >= 0x3ffffff)
if (len >= LONG_MAX / (long)sizeof(int))
/* Invalid length, multiply with sizeof(int) would overflow. */
return SP_FORMERROR;
if (len > 0)

View File

@@ -133,7 +133,8 @@ SCRIPTS_GUI =
# Tests using runtest.vim.vim.
# Keep test_alot*.res as the last one, sort the others.
NEW_TESTS = test_arglist.res \
NEW_TESTS = test_arabic.res \
test_arglist.res \
test_assert.res \
test_autochdir.res \
test_backspace_opt.res \

View File

@@ -165,6 +165,7 @@ let s:flaky = [
\ 'Test_collapse_buffers()',
\ 'Test_communicate()',
\ 'Test_nb_basic()',
\ 'Test_oneshot()',
\ 'Test_pipe_through_sort_all()',
\ 'Test_pipe_through_sort_some()',
\ 'Test_reltime()',

View File

@@ -0,0 +1,92 @@
" Simplistic testing of Arabic mode.
if !has('arabic')
finish
endif
set encoding=utf-8
scriptencoding utf-8
" Return list of utf8 sequences of each character at line lnum.
" Combining characters are treated as a single item.
func GetCharsUtf8(lnum)
call cursor(a:lnum, 1)
let chars = []
let numchars = strchars(getline('.'), 1)
for i in range(1, numchars)
exe 'norm ' i . '|'
call add(chars, execute('norm g8'))
endfor
return chars
endfunc
func Test_arabic_toggle()
set arabic
call assert_equal(1, &rightleft)
call assert_equal(1, &arabicshape)
call assert_equal('arabic', &keymap)
call assert_equal(1, &delcombine)
set iminsert=1 imsearch=1
set arabic&
call assert_equal(0, &rightleft)
call assert_equal(1, &arabicshape)
call assert_equal('arabic', &keymap)
call assert_equal(1, &delcombine)
call assert_equal(0, &iminsert)
call assert_equal(-1, &imsearch)
set arabicshape& keymap= delcombine&
endfunc
func Test_arabic_input()
new
set arabic
" Typing sghl in Arabic insert mode should show the
" Arabic word 'Salaam' i.e. 'peace'.
call feedkeys('isghl', 'tx')
redraw
call assert_equal([
\ "\nd8 b3 ",
\ "\nd9 84 + d8 a7 ",
\ "\nd9 85 "], GetCharsUtf8(1))
" Without shaping, it should give individual Arabic letters.
set noarabicshape
redraw
call assert_equal([
\ "\nd8 b3 ",
\ "\nd9 84 ",
\ "\nd8 a7 ",
\ "\nd9 85 "], GetCharsUtf8(1))
set arabicshape&
set arabic&
bwipe!
endfunc
func Test_arabic_toggle_keymap()
new
set arabic
call feedkeys("i12\<C-^>12\<C-^>12", 'tx')
redraw
call assert_equal('١٢12١٢', getline('.'))
set arabic&
bwipe!
endfunc
func Test_delcombine()
new
set arabic
call feedkeys("isghl\<BS>\<BS>", 'tx')
redraw
call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1))
" Now the same with nodelcombine
set nodelcombine
%d
call feedkeys("isghl\<BS>\<BS>", 'tx')
call assert_equal(["\nd8 b3 "], GetCharsUtf8(1))
set arabic&
bwipe!
endfunc

View File

@@ -272,3 +272,78 @@ func Test_setting_cursor()
call delete('Xtest1')
call delete('Xtest2')
endfunc
func Test_diff_move_to()
new
call setline(1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
diffthis
vnew
call setline(1, [1, '2x', 3, 4, 4, 5, '6x', 7, '8x', 9, '10x'])
diffthis
norm ]c
call assert_equal(2, line('.'))
norm 3]c
call assert_equal(9, line('.'))
norm 10]c
call assert_equal(11, line('.'))
norm [c
call assert_equal(9, line('.'))
norm 2[c
call assert_equal(5, line('.'))
norm 10[c
call assert_equal(2, line('.'))
%bwipe!
endfunc
func Test_diffpatch()
" The patch program on MS-Windows may fail or hang.
if !executable('patch') || !has('unix')
return
endif
new
insert
***************
*** 1,3 ****
1
! 2
3
--- 1,4 ----
1
! 2x
3
+ 4
.
saveas Xpatch
bwipe!
new
call assert_fails('diffpatch Xpatch', 'E816:')
call setline(1, ['1', '2', '3'])
diffpatch Xpatch
call assert_equal(['1', '2x', '3', '4'], getline(1, '$'))
call delete('Xpatch')
bwipe!
endfunc
func Test_diff_too_many_buffers()
for i in range(1, 8)
exe "new Xtest" . i
diffthis
endfor
new Xtest9
call assert_fails('diffthis', 'E96:')
%bwipe!
endfunc
func Test_diff_nomodifiable()
new
call setline(1, [1, 2, 3, 4])
setl nomodifiable
diffthis
vnew
call setline(1, ['1x', 2, 3, 3, 4])
diffthis
call assert_fails('norm dp', 'E793:')
setl nomodifiable
call assert_fails('norm do', 'E21:')
%bwipe!
endfunc

View File

@@ -14,7 +14,7 @@ func s:test_expand_dllpath(optname)
endfunc
func s:generate_test_if_exists(optname)
if exists('&' . a:optname)
if exists('+' . a:optname)
execute join([
\ 'func Test_expand_' . a:optname . '()',
\ ' call s:test_expand_dllpath("' . a:optname . '")',

View File

@@ -72,6 +72,47 @@ func Test_getfontname_without_arg()
endif
endfunc
func Test_quoteplus()
let skipped = ''
if !g:x11_based_gui
let skipped = g:not_supported . 'quoteplus'
else
let quoteplus_saved = @+
let test_call = 'Can you hear me?'
let test_response = 'Yes, I can.'
let vim_exe = exepath(v:progpath)
let testee = 'VIMRUNTIME=' . $VIMRUNTIME . '; export VIMRUNTIME;'
\ . vim_exe . ' -f -g -u NONE -U NONE --noplugin -c ''%s'''
let cmd = 'call feedkeys("'
\ . '\"+p'
\ . ':s/' . test_call . '/' . test_response . '/\<CR>'
\ . '\"+yis'
\ . ':q!\<CR>", "tx")'
let run_vimtest = printf(testee, cmd)
" Set the quoteplus register to test_call, and another gvim will launched.
" Then, it first tries to paste the content of its own quotedplus register
" onto it. Second, it tries to substitute test_responce for the pasted
" sentence. If the sentence is identical to test_call, the substitution
" should succeed. Third, it tries to yank the result of the substitution
" to its own quoteplus register, and last it quits. When system()
" returns, the content of the quoteplus register should be identical to
" test_response if those quoteplus registers are synchronized properly
" with/through the X11 clipboard.
let @+ = test_call
call system(run_vimtest)
call assert_equal(test_response, @+)
let @+ = quoteplus_saved
endif
if !empty(skipped)
throw skipped
endif
endfunc
func Test_set_guifont()
let skipped = ''

View File

@@ -193,3 +193,30 @@ func Test_multibyte_sign_and_colorcolumn()
call s:compare_lines(expect, lines)
call s:close_windows()
endfunc
func Test_illegal_byte_and_breakat()
call s:test_windows("setl sbr= brk+=<")
vert resize 18
call setline(1, repeat("\x80", 6))
redraw!
let lines = s:screen_lines([1, 2], winwidth(0))
let expect = [
\ "<80><80><80><80><8",
\ "0><80> ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('setl brk&vim')
endfunc
func Test_multibyte_wrap_and_breakat()
call s:test_windows("setl sbr= brk+=>")
call setline(1, repeat('a', 17) . repeat('あ', 2))
redraw!
let lines = s:screen_lines([1, 2], winwidth(0))
let expect = [
\ "aaaaaaaaaaaaaaaaaあ>",
\ "あ ",
\ ]
call s:compare_lines(expect, lines)
call s:close_windows('setl brk&vim')
endfunc

View File

@@ -29,6 +29,19 @@ function! Test_isfname()
set isfname&
endfunction
function Test_wildchar()
" Empty 'wildchar' used to access invalid memory.
call assert_fails('set wildchar=', 'E521:')
call assert_fails('set wildchar=abc', 'E521:')
set wildchar=<Esc>
let a=execute('set wildchar?')
call assert_equal("\n wildchar=<Esc>", a)
set wildchar=27
let a=execute('set wildchar?')
call assert_equal("\n wildchar=<Esc>", a)
set wildchar&
endfunction
function Test_options()
let caught = 'ok'
try
@@ -275,3 +288,21 @@ func Test_set_ttytype()
call assert_equal(&ttytype, &term)
endif
endfunc
func Test_set_all()
set tw=75
set iskeyword=a-z,A-Z
set nosplitbelow
let out = execute('set all')
call assert_match('textwidth=75', out)
call assert_match('iskeyword=a-z,A-Z', out)
call assert_match('nosplitbelow', out)
set tw& iskeyword& splitbelow&
endfunc
func Test_set_values()
" The file is only generated when running "make test" in the src directory.
if filereadable('opt_test.vim')
source opt_test.vim
endif
endfunc

View File

@@ -106,3 +106,11 @@ function! Test_substitute_variants()
endfor
endfor
endfunction
func Test_substitute_repeat()
" This caused an invalid memory access.
split Xfile
s/^/x
call feedkeys("Qsc\<CR>y", 'tx')
bwipe!
endfunc

View File

@@ -1385,7 +1385,7 @@ unserialize_uep(bufinfo_T *bi, int *error, char_u *file_name)
{
int i;
u_entry_T *uep;
char_u **array;
char_u **array = NULL;
char_u *line;
int line_len;
@@ -1402,7 +1402,8 @@ unserialize_uep(bufinfo_T *bi, int *error, char_u *file_name)
uep->ue_size = undo_read_4c(bi);
if (uep->ue_size > 0)
{
array = (char_u **)U_ALLOC_LINE(sizeof(char_u *) * uep->ue_size);
if (uep->ue_size < LONG_MAX / (int)sizeof(char_u *))
array = (char_u **)U_ALLOC_LINE(sizeof(char_u *) * uep->ue_size);
if (array == NULL)
{
*error = TRUE;
@@ -1410,8 +1411,6 @@ unserialize_uep(bufinfo_T *bi, int *error, char_u *file_name)
}
vim_memset(array, 0, sizeof(char_u *) * uep->ue_size);
}
else
array = NULL;
uep->ue_array = array;
for (i = 0; i < uep->ue_size; ++i)
@@ -1787,7 +1786,7 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
linenr_T line_lnum;
colnr_T line_colnr;
linenr_T line_count;
int num_head = 0;
long num_head = 0;
long old_header_seq, new_header_seq, cur_header_seq;
long seq_last, seq_cur;
long last_save_nr = 0;
@@ -1974,7 +1973,8 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
* When there are no headers uhp_table is NULL. */
if (num_head > 0)
{
uhp_table = (u_header_T **)U_ALLOC_LINE(
if (num_head < LONG_MAX / (long)sizeof(u_header_T *))
uhp_table = (u_header_T **)U_ALLOC_LINE(
num_head * sizeof(u_header_T *));
if (uhp_table == NULL)
goto error;

View File

@@ -764,6 +764,46 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
386,
/**/
385,
/**/
384,
/**/
383,
/**/
382,
/**/
381,
/**/
380,
/**/
379,
/**/
378,
/**/
377,
/**/
376,
/**/
375,
/**/
374,
/**/
373,
/**/
372,
/**/
371,
/**/
370,
/**/
369,
/**/
368,
/**/
367,
/**/
366,
/**/