aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorckelsel <ckelsel@hotmail.com>2017-09-24 09:16:59 +0800
committerckelsel <ckelsel@hotmail.com>2017-09-24 09:16:59 +0800
commit90fc9039ddcadc61d4236bdd2d638d690081e04d (patch)
treeecf08d95a7c9459fa5a79202d85e6666c3f5ee88 /src
parent6258e33b114dc4386e608a5cf3a48742757441f7 (diff)
parent4bb0e95abbf0a61d383d5261019a2667706c9d39 (diff)
downloadrneovim-90fc9039ddcadc61d4236bdd2d638d690081e04d.tar.gz
rneovim-90fc9039ddcadc61d4236bdd2d638d690081e04d.tar.bz2
rneovim-90fc9039ddcadc61d4236bdd2d638d690081e04d.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c8
-rw-r--r--src/nvim/option.c7
-rw-r--r--src/nvim/regexp.c77
-rw-r--r--src/nvim/testdir/Makefile1
-rw-r--r--src/nvim/testdir/test_cmdline.vim14
-rw-r--r--src/nvim/testdir/test_mksession.vim15
-rw-r--r--src/nvim/testdir/test_options.vim6
-rw-r--r--src/nvim/tui/tui.c94
-rw-r--r--src/nvim/version.c10
9 files changed, 141 insertions, 91 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d1405978b3..47e23b6e80 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1668,8 +1668,8 @@ static char_u * do_one_cmd(char_u **cmdlinep,
if (*ea.cmd == ';') {
if (!ea.skip) {
curwin->w_cursor.lnum = ea.line2;
- // Don't leave the cursor on an illegal line (caused by ';')
- check_cursor_lnum();
+ // don't leave the cursor on an illegal line or column
+ check_cursor();
}
} else if (*ea.cmd != ',') {
break;
@@ -1813,7 +1813,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
if (text_locked() && !(ea.argt & CMDWIN)
&& !IS_USER_CMDIDX(ea.cmdidx)) {
// Command not allowed when editing the command line.
- errormsg = get_text_locked_msg();
+ errormsg = (char_u *)_(get_text_locked_msg());
goto doend;
}
/* Disallow editing another buffer when "curbuf_lock" is set.
@@ -9378,7 +9378,7 @@ ses_arglist (
(void)vim_FullName((char *)s, (char *)buf, MAXPATHL, FALSE);
s = buf;
}
- if (fputs("argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL
+ if (fputs("$argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL
|| put_eol(fd) == FAIL) {
xfree(buf);
return FAIL;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 8ba10fd38a..74250e83e6 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1749,7 +1749,7 @@ do_set (
if (flags & P_FLAGLIST) {
// Remove flags that appear twice.
- for (s = newval; *s; s++) {
+ for (s = newval; *s;) {
// if options have P_FLAGLIST and P_ONECOMMA such as
// 'whichwrap'
if (flags & P_ONECOMMA) {
@@ -1757,15 +1757,16 @@ do_set (
&& vim_strchr(s + 2, *s) != NULL) {
// Remove the duplicated value and the next comma.
STRMOVE(s, s + 2);
- s -= 2;
+ continue;
}
} else {
if ((!(flags & P_COMMA) || *s != ',')
&& vim_strchr(s + 1, *s) != NULL) {
STRMOVE(s, s + 1);
- s--;
+ continue;
}
}
+ s++;
}
}
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 847b2f273e..ae611a0005 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -3316,6 +3316,47 @@ bt_regexec_nl (
return (int)r;
}
+/// Wrapper around strchr which accounts for case-insensitive searches and
+/// non-ASCII characters.
+///
+/// This function is used a lot for simple searches, keep it fast!
+///
+/// @param s string to search
+/// @param c character to find in @a s
+///
+/// @return NULL if no match, otherwise pointer to the position in @a s
+static inline char_u *cstrchr(const char_u *const s, const int c)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
+ FUNC_ATTR_ALWAYS_INLINE
+{
+ if (!rex.reg_ic) {
+ return vim_strchr(s, c);
+ }
+
+ // Use folded case for UTF-8, slow! For ASCII use libc strpbrk which is
+ // expected to be highly optimized.
+ if (c > 0x80) {
+ const int folded_c = utf_fold(c);
+ for (const char_u *p = s; *p != NUL; p += utfc_ptr2len(p)) {
+ if (utf_fold(utf_ptr2char(p)) == folded_c) {
+ return (char_u *)p;
+ }
+ }
+ return NULL;
+ }
+
+ int cc;
+ if (ASCII_ISUPPER(c)) {
+ cc = TOLOWER_ASC(c);
+ } else if (ASCII_ISLOWER(c)) {
+ cc = TOUPPER_ASC(c);
+ } else {
+ return vim_strchr(s, c);
+ }
+
+ char tofind[] = { (char)c, (char)cc, NUL };
+ return (char_u *)strpbrk((const char *)s, tofind);
+}
/// Matches a regexp against multiple lines.
/// "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
@@ -6320,42 +6361,6 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n)
return result;
}
-/*
- * cstrchr: This function is used a lot for simple searches, keep it fast!
- */
-static inline char_u *cstrchr(const char_u *const s, const int c)
- FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
- FUNC_ATTR_ALWAYS_INLINE
-{
- if (!rex.reg_ic) {
- return vim_strchr(s, c);
- }
-
- // Use folded case for UTF-8, slow! For ASCII use libc strpbrk which is
- // expected to be highly optimized.
- if (c > 0x80) {
- const int folded_c = utf_fold(c);
- for (const char_u *p = s; *p != NUL; p += utfc_ptr2len(p)) {
- if (utf_fold(utf_ptr2char(p)) == folded_c) {
- return (char_u *)p;
- }
- }
- return NULL;
- }
-
- int cc;
- if (ASCII_ISUPPER(c)) {
- cc = TOLOWER_ASC(c);
- } else if (ASCII_ISLOWER(c)) {
- cc = TOUPPER_ASC(c);
- } else {
- return vim_strchr(s, c);
- }
-
- char tofind[] = { (char)c, (char)cc, NUL };
- return (char_u *)strpbrk((const char *)s, tofind);
-}
-
/***************************************************************
* regsub stuff *
***************************************************************/
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 96de7224c5..9133bfc0a2 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -58,6 +58,7 @@ NEW_TESTS ?= \
test_match.res \
test_matchadd_conceal.res \
test_matchadd_conceal_utf8.res \
+ test_mksession.res \
test_nested_function.res \
test_normal.res \
test_quickfix.res \
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 2facffb067..c0f04f4730 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -250,9 +250,21 @@ func Test_remove_char_in_cmdline()
call assert_equal('"def', @:)
endfunc
-func Test_illegal_address()
+func Test_illegal_address1()
new
2;'(
2;')
quit
endfunc
+
+func Test_illegal_address2()
+ call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim')
+ new
+ source Xtest.vim
+ " Trigger calling validate_cursor()
+ diffsp Xtest.vim
+ quit!
+ bwipe!
+ call delete('Xtest.vim')
+endfunc
+
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
new file mode 100644
index 0000000000..2238213850
--- /dev/null
+++ b/src/nvim/testdir/test_mksession.vim
@@ -0,0 +1,15 @@
+" Tests for sessions
+
+" Verify that arglist is stored correctly to the session file.
+func Test_mksession_arglist()
+ argdel *
+ next file1 file2 file3 file4
+ mksession! Xtest_mks.out
+ source Xtest_mks.out
+ call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
+
+ call delete('Xtest_mks.out')
+ argdel *
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim
index 5ee0919e18..2ffe63787b 100644
--- a/src/nvim/testdir/test_options.vim
+++ b/src/nvim/testdir/test_options.vim
@@ -13,6 +13,12 @@ function! Test_whichwrap()
set whichwrap+=h,l
call assert_equal('b,s,h,l', &whichwrap)
+ set whichwrap=h,h
+ call assert_equal('h', &whichwrap)
+
+ set whichwrap=h,h,h
+ call assert_equal('h', &whichwrap)
+
set whichwrap&
endfunction
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 1cbd02dfd9..256772489d 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -52,6 +52,15 @@
#define LINUXSET0C "\x1b[?0c"
#define LINUXSET1C "\x1b[?1c"
+#ifdef NVIM_UNIBI_HAS_VAR_FROM
+#define UNIBI_SET_NUM_VAR(var, num) \
+ do { \
+ (var) = unibi_var_from_num((num)); \
+ } while (0)
+#else
+#define UNIBI_SET_NUM_VAR(var, num) (var).i = (num);
+#endif
+
// Per the commentary in terminfo, only a minus sign is a true suffix
// separator.
bool terminfo_is_term_family(const char *term, const char *family)
@@ -391,15 +400,15 @@ static void update_attrs(UI *ui, HlAttrs attrs)
if (unibi_get_str(data->ut, unibi_set_attributes)) {
if (attrs.bold || attrs.reverse || attrs.underline || attrs.undercurl) {
- data->params[0].i = 0; // standout
- data->params[1].i = attrs.underline || attrs.undercurl;
- data->params[2].i = attrs.reverse;
- data->params[3].i = 0; // blink
- data->params[4].i = 0; // dim
- data->params[5].i = attrs.bold;
- data->params[6].i = 0; // blank
- data->params[7].i = 0; // protect
- data->params[8].i = 0; // alternate character set
+ UNIBI_SET_NUM_VAR(data->params[0], 0); // standout
+ UNIBI_SET_NUM_VAR(data->params[1], attrs.underline || attrs.undercurl);
+ UNIBI_SET_NUM_VAR(data->params[2], attrs.reverse);
+ UNIBI_SET_NUM_VAR(data->params[3], 0); // blink
+ UNIBI_SET_NUM_VAR(data->params[4], 0); // dim
+ UNIBI_SET_NUM_VAR(data->params[5], attrs.bold);
+ UNIBI_SET_NUM_VAR(data->params[6], 0); // blank
+ UNIBI_SET_NUM_VAR(data->params[7], 0); // protect
+ UNIBI_SET_NUM_VAR(data->params[8], 0); // alternate character set
unibi_out(ui, unibi_set_attributes);
} else if (!data->default_attr) {
unibi_out(ui, unibi_exit_attribute_mode);
@@ -423,26 +432,26 @@ static void update_attrs(UI *ui, HlAttrs attrs)
}
if (ui->rgb) {
if (fg != -1) {
- data->params[0].i = (fg >> 16) & 0xff; // red
- data->params[1].i = (fg >> 8) & 0xff; // green
- data->params[2].i = fg & 0xff; // blue
+ UNIBI_SET_NUM_VAR(data->params[0], (fg >> 16) & 0xff); // red
+ UNIBI_SET_NUM_VAR(data->params[1], (fg >> 8) & 0xff); // green
+ UNIBI_SET_NUM_VAR(data->params[2], fg & 0xff); // blue
unibi_out_ext(ui, data->unibi_ext.set_rgb_foreground);
}
if (bg != -1) {
- data->params[0].i = (bg >> 16) & 0xff; // red
- data->params[1].i = (bg >> 8) & 0xff; // green
- data->params[2].i = bg & 0xff; // blue
+ UNIBI_SET_NUM_VAR(data->params[0], (bg >> 16) & 0xff); // red
+ UNIBI_SET_NUM_VAR(data->params[1], (bg >> 8) & 0xff); // green
+ UNIBI_SET_NUM_VAR(data->params[2], bg & 0xff); // blue
unibi_out_ext(ui, data->unibi_ext.set_rgb_background);
}
} else {
if (fg != -1) {
- data->params[0].i = fg;
+ UNIBI_SET_NUM_VAR(data->params[0], fg);
unibi_out(ui, unibi_set_a_foreground);
}
if (bg != -1) {
- data->params[0].i = bg;
+ UNIBI_SET_NUM_VAR(data->params[0], bg);
unibi_out(ui, unibi_set_a_background);
}
}
@@ -558,7 +567,7 @@ static void cursor_goto(UI *ui, int row, int col)
unibi_out(ui, unibi_cursor_left);
}
} else {
- data->params[0].i = n;
+ UNIBI_SET_NUM_VAR(data->params[0], n);
unibi_out(ui, unibi_parm_left_cursor);
}
ugrid_goto(grid, row, col);
@@ -570,7 +579,7 @@ static void cursor_goto(UI *ui, int row, int col)
unibi_out(ui, unibi_cursor_right);
}
} else {
- data->params[0].i = n;
+ UNIBI_SET_NUM_VAR(data->params[0], n);
unibi_out(ui, unibi_parm_right_cursor);
}
ugrid_goto(grid, row, col);
@@ -585,7 +594,7 @@ static void cursor_goto(UI *ui, int row, int col)
unibi_out(ui, unibi_cursor_down);
}
} else {
- data->params[0].i = n;
+ UNIBI_SET_NUM_VAR(data->params[0], n);
unibi_out(ui, unibi_parm_down_cursor);
}
ugrid_goto(grid, row, col);
@@ -597,7 +606,7 @@ static void cursor_goto(UI *ui, int row, int col)
unibi_out(ui, unibi_cursor_up);
}
} else {
- data->params[0].i = n;
+ UNIBI_SET_NUM_VAR(data->params[0], n);
unibi_out(ui, unibi_parm_up_cursor);
}
ugrid_goto(grid, row, col);
@@ -675,19 +684,19 @@ static void set_scroll_region(UI *ui)
TUIData *data = ui->data;
UGrid *grid = &data->grid;
- data->params[0].i = grid->top;
- data->params[1].i = grid->bot;
+ UNIBI_SET_NUM_VAR(data->params[0], grid->top);
+ UNIBI_SET_NUM_VAR(data->params[1], grid->bot);
unibi_out(ui, unibi_change_scroll_region);
if (grid->left != 0 || grid->right != ui->width - 1) {
unibi_out_ext(ui, data->unibi_ext.enable_lr_margin);
if (data->can_set_lr_margin) {
- data->params[0].i = grid->left;
- data->params[1].i = grid->right;
+ UNIBI_SET_NUM_VAR(data->params[0], grid->left);
+ UNIBI_SET_NUM_VAR(data->params[1], grid->right);
unibi_out(ui, unibi_set_lr_margin);
} else {
- data->params[0].i = grid->left;
+ UNIBI_SET_NUM_VAR(data->params[0], grid->left);
unibi_out(ui, unibi_set_left_margin_parm);
- data->params[0].i = grid->right;
+ UNIBI_SET_NUM_VAR(data->params[0], grid->right);
unibi_out(ui, unibi_set_right_margin_parm);
}
}
@@ -702,19 +711,19 @@ static void reset_scroll_region(UI *ui)
if (0 <= data->unibi_ext.reset_scroll_region) {
unibi_out_ext(ui, data->unibi_ext.reset_scroll_region);
} else {
- data->params[0].i = 0;
- data->params[1].i = ui->height - 1;
+ UNIBI_SET_NUM_VAR(data->params[0], 0);
+ UNIBI_SET_NUM_VAR(data->params[1], ui->height - 1);
unibi_out(ui, unibi_change_scroll_region);
}
if (grid->left != 0 || grid->right != ui->width - 1) {
if (data->can_set_lr_margin) {
- data->params[0].i = 0;
- data->params[1].i = ui->width - 1;
+ UNIBI_SET_NUM_VAR(data->params[0], 0);
+ UNIBI_SET_NUM_VAR(data->params[1], ui->width - 1);
unibi_out(ui, unibi_set_lr_margin);
} else {
- data->params[0].i = 0;
+ UNIBI_SET_NUM_VAR(data->params[0], 0);
unibi_out(ui, unibi_set_left_margin_parm);
- data->params[0].i = ui->width - 1;
+ UNIBI_SET_NUM_VAR(data->params[0], ui->width - 1);
unibi_out(ui, unibi_set_right_margin_parm);
}
unibi_out_ext(ui, data->unibi_ext.disable_lr_margin);
@@ -728,8 +737,8 @@ static void tui_resize(UI *ui, Integer width, Integer height)
ugrid_resize(&data->grid, (int)width, (int)height);
if (!got_winch) { // Try to resize the terminal window.
- data->params[0].i = (int)height;
- data->params[1].i = (int)width;
+ UNIBI_SET_NUM_VAR(data->params[0], (int)height);
+ UNIBI_SET_NUM_VAR(data->params[1], (int)width);
unibi_out_ext(ui, data->unibi_ext.resize_screen);
// DECSLPP does not reset the scroll region.
if (data->scroll_region_is_full_screen) {
@@ -863,7 +872,7 @@ static void tui_set_mode(UI *ui, ModeShape mode)
int attr = syn_id2attr(c.id);
if (attr > 0) {
attrentry_T *aep = syn_cterm_attr2entry(attr);
- data->params[0].i = aep->rgb_bg_color;
+ UNIBI_SET_NUM_VAR(data->params[0], aep->rgb_bg_color);
unibi_out_ext(ui, data->unibi_ext.set_cursor_color);
}
}
@@ -874,7 +883,7 @@ static void tui_set_mode(UI *ui, ModeShape mode)
case SHAPE_VER: shape = 5; break;
default: WLOG("Unknown shape value %d", shape); break;
}
- data->params[0].i = shape + (int)(c.blinkon == 0);
+ UNIBI_SET_NUM_VAR(data->params[0], shape + (int)(c.blinkon == 0));
unibi_out_ext(ui, data->unibi_ext.set_cursor_style);
}
@@ -927,14 +936,14 @@ static void tui_scroll(UI *ui, Integer count)
if (count == 1) {
unibi_out(ui, unibi_delete_line);
} else {
- data->params[0].i = (int)count;
+ UNIBI_SET_NUM_VAR(data->params[0], (int)count);
unibi_out(ui, unibi_parm_delete_line);
}
} else {
if (count == -1) {
unibi_out(ui, unibi_insert_line);
} else {
- data->params[0].i = -(int)count;
+ UNIBI_SET_NUM_VAR(data->params[0], -(int)count);
unibi_out(ui, unibi_parm_insert_line);
}
}
@@ -1177,8 +1186,8 @@ end:
static void unibi_goto(UI *ui, int row, int col)
{
TUIData *data = ui->data;
- data->params[0].i = row;
- data->params[1].i = col;
+ UNIBI_SET_NUM_VAR(data->params[0], row);
+ UNIBI_SET_NUM_VAR(data->params[1], col);
unibi_out(ui, unibi_cursor_address);
}
@@ -1190,7 +1199,8 @@ static void unibi_goto(UI *ui, int row, int col)
str = fn(data->ut, (unsigned)unibi_index); \
} \
if (str) { \
- unibi_var_t vars[26 + 26] = { { 0 } }; \
+ unibi_var_t vars[26 + 26]; \
+ memset(&vars, 0, sizeof(vars)); \
unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \
} \
} while (0)
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 6f38776a60..d4f9c0232f 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -625,10 +625,10 @@ static const int included_patches[] = {
// 330,
// 329,
// 328,
- // 327,
+ 327,
326,
325,
- // 324,
+ 324,
// 323,
322,
// 321,
@@ -647,10 +647,10 @@ static const int included_patches[] = {
308,
307,
// 306,
- // 305,
+ 305,
// 304,
// 303,
- // 302,
+ // 302, NA
// 301,
300,
// 299,
@@ -658,7 +658,7 @@ static const int included_patches[] = {
297,
// 296,
// 295,
- // 294,
+ 294,
// 293,
// 292,
291,