aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/clint.py10
-rw-r--r--src/nvim/buffer.c3
-rw-r--r--src/nvim/charset.c21
-rw-r--r--src/nvim/eval.c58
-rw-r--r--src/nvim/message.c6
-rw-r--r--src/nvim/path.c27
-rw-r--r--src/nvim/testdir/test_alot.vim1
-rw-r--r--src/nvim/testdir/test_find_complete.vim6
-rw-r--r--src/nvim/testdir/test_global.vim11
-rw-r--r--src/nvim/testdir/test_vimscript.vim1
-rw-r--r--src/nvim/tui/tui.c49
11 files changed, 110 insertions, 83 deletions
diff --git a/src/clint.py b/src/clint.py
index 79ab91ebe1..c0cedc0e5b 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -571,10 +571,10 @@ class _CppLintState(object):
def PrintErrorCounts(self):
"""Print a summary of errors by category, and the total."""
for category, count in self.errors_by_category.items():
- sys.stderr.write('Category \'%s\' errors found: %d\n' %
+ sys.stdout.write('Category \'%s\' errors found: %d\n' %
(category, count))
if self.error_count:
- sys.stderr.write('Total errors found: %d\n' % self.error_count)
+ sys.stdout.write('Total errors found: %d\n' % self.error_count)
def SuppressErrorsFrom(self, fname):
"""Open file and read a list of suppressed errors from it"""
@@ -821,13 +821,13 @@ def Error(filename, linenum, category, confidence, message):
if _ShouldPrintError(category, confidence, linenum):
_cpplint_state.IncrementErrorCount(category)
if _cpplint_state.output_format == 'vs7':
- sys.stderr.write('%s(%s): %s [%s] [%d]\n' % (
+ sys.stdout.write('%s(%s): %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
elif _cpplint_state.output_format == 'eclipse':
- sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % (
+ sys.stdout.write('%s:%s: warning: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
else:
- sys.stderr.write('%s:%s: %s [%s] [%d]\n' % (
+ sys.stdout.write('%s:%s: %s [%s] [%d]\n' % (
filename, linenum, message, category, confidence))
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 19c17a9d68..95eaf4dcf6 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -3273,9 +3273,6 @@ int build_stl_str_hl(
// Two `%` in a row is the escape sequence to print a
// single `%` in the output buffer.
if (*fmt_p == '%') {
- // Ignore the character if we're out of room in the output buffer.
- if (out_p >= out_end_p)
- break;
*out_p++ = *fmt_p++;
prevchar_isflag = prevchar_isitem = false;
continue;
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index ab20996df7..a02d2a812d 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -331,14 +331,14 @@ size_t transstr_len(const char *const s)
while (*p) {
const size_t l = (size_t)utfc_ptr2len((const char_u *)p);
if (l > 1) {
- int pcc[MAX_MCO + 2];
+ int pcc[MAX_MCO + 1];
pcc[0] = utfc_ptr2char((const char_u *)p, &pcc[1]);
if (vim_isprintc(pcc[0])) {
len += l;
} else {
- for (size_t i = 0; i < ARRAY_SIZE(pcc); i++) {
- char hexbuf[11];
+ for (size_t i = 0; i < ARRAY_SIZE(pcc) && pcc[i]; i++) {
+ char hexbuf[9];
len += transchar_hex(hexbuf, pcc[i]);
}
}
@@ -370,20 +370,20 @@ size_t transstr_buf(const char *const s, char *const buf, const size_t len)
while (*p != NUL && buf_p < buf_e) {
const size_t l = (size_t)utfc_ptr2len((const char_u *)p);
if (l > 1) {
- if (buf_p + l >= buf_e) {
- break;
+ if (buf_p + l > buf_e) {
+ break; // Exceeded `buf` size.
}
- int pcc[MAX_MCO + 2];
+ int pcc[MAX_MCO + 1];
pcc[0] = utfc_ptr2char((const char_u *)p, &pcc[1]);
if (vim_isprintc(pcc[0])) {
memmove(buf_p, p, l);
buf_p += l;
} else {
- for (size_t i = 0; i < ARRAY_SIZE(pcc); i++) {
- char hexbuf[11];
+ for (size_t i = 0; i < ARRAY_SIZE(pcc) && pcc[i]; i++) {
+ char hexbuf[9]; // <up to 6 bytes>NUL
const size_t hexlen = transchar_hex(hexbuf, pcc[i]);
- if (buf_p + hexlen >= buf_e) {
+ if (buf_p + hexlen > buf_e) {
break;
}
memmove(buf_p, hexbuf, hexlen);
@@ -394,6 +394,9 @@ size_t transstr_buf(const char *const s, char *const buf, const size_t len)
} else {
const char *const tb = (const char *)transchar_byte((uint8_t)(*p++));
const size_t tb_len = strlen(tb);
+ if (buf_p + tb_len > buf_e) {
+ break; // Exceeded `buf` size.
+ }
memmove(buf_p, tb, tb_len);
buf_p += tb_len;
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 2ea0c0116b..e6880f58e7 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -19584,6 +19584,7 @@ static const char *find_option_end(const char **const arg, int *const opt_flags)
void ex_function(exarg_T *eap)
{
char_u *theline;
+ char_u *line_to_free = NULL;
int c;
int saved_did_emsg;
int saved_wait_return = need_wait_return;
@@ -19815,7 +19816,6 @@ void ex_function(exarg_T *eap)
/* When there is a line break use what follows for the function body.
* Makes 'exe "func Test()\n...\nendfunc"' work. */
- const char *const end = (const char *)p + STRLEN(p);
if (*p == '\n') {
line_arg = p + 1;
} else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) {
@@ -19865,12 +19865,18 @@ void ex_function(exarg_T *eap)
*p = NUL;
line_arg = p + 1;
}
- } else if (eap->getline == NULL)
- theline = getcmdline(':', 0L, indent);
- else
- theline = eap->getline(':', eap->cookie, indent);
- if (KeyTyped)
+ } else {
+ xfree(line_to_free);
+ if (eap->getline == NULL) {
+ theline = getcmdline(':', 0L, indent);
+ } else {
+ theline = eap->getline(':', eap->cookie, indent);
+ }
+ line_to_free = theline;
+ }
+ if (KeyTyped) {
lines_left = Rows - 1;
+ }
if (theline == NULL) {
EMSG(_("E126: Missing :endfunction"));
goto erret;
@@ -19902,25 +19908,24 @@ void ex_function(exarg_T *eap)
if (*p == '!') {
p++;
}
- const char *const comment_start = strchr((const char *)p, '"');
- const char *const endfunc_end = (comment_start
- ? strchr(comment_start, '\n')
- : strpbrk((const char *)p, "\n|"));
- p = (endfunc_end
- ? (char_u *)endfunc_end
- : p + STRLEN(p));
+ char_u *nextcmd = NULL;
if (*p == '|') {
- emsgf(_(e_trailing2), p);
- if (line_arg == NULL) {
- xfree(theline);
- }
- goto erret;
+ nextcmd = p + 1;
+ } else if (line_arg != NULL && *skipwhite(line_arg) != NUL) {
+ nextcmd = line_arg;
+ } else if (*p != NUL && *p != '"' && p_verbose > 0) {
+ give_warning2((char_u *)_("W22: Text found after :endfunction: %s"),
+ p, true);
}
- if (line_arg == NULL) {
- xfree(theline);
- } else {
- if ((const char *)p < end) {
- eap->nextcmd = p + 1;
+ if (nextcmd != NULL) {
+ // Another command follows. If the line came from "eap" we
+ // can simply point into it, otherwise we need to change
+ // "eap->cmdlinep".
+ eap->nextcmd = nextcmd;
+ if (line_to_free != NULL) {
+ xfree(*eap->cmdlinep);
+ *eap->cmdlinep = line_to_free;
+ line_to_free = NULL;
}
}
break;
@@ -19997,11 +20002,7 @@ void ex_function(exarg_T *eap)
* allocates 250 bytes per line, this saves 80% on average. The cost
* is an extra alloc/free. */
p = vim_strsave(theline);
- if (line_arg == NULL)
- xfree(theline);
- theline = p;
-
- ((char_u **)(newlines.ga_data))[newlines.ga_len++] = theline;
+ ((char_u **)(newlines.ga_data))[newlines.ga_len++] = p;
/* Add NULL lines for continuation lines, so that the line count is
* equal to the index in the growarray. */
@@ -20166,6 +20167,7 @@ errret_2:
ga_clear_strings(&newlines);
ret_free:
xfree(skip_until);
+ xfree(line_to_free);
xfree(fudi.fd_newkey);
xfree(name);
did_emsg |= saved_did_emsg;
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 097c8b16e4..9d4d421941 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2763,6 +2763,12 @@ void give_warning(char_u *message, bool hl) FUNC_ATTR_NONNULL_ARG(1)
--no_wait_return;
}
+void give_warning2(char_u *const message, char_u *const a1, bool hl)
+{
+ vim_snprintf((char *)IObuff, IOSIZE, (char *)message, a1);
+ give_warning(IObuff, hl);
+}
+
/*
* Advance msg cursor to column "col".
*/
diff --git a/src/nvim/path.c b/src/nvim/path.c
index b1e1bf3b2f..d5c636ff08 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1051,30 +1051,35 @@ const char *gettail_dir(const char *const fname)
* result in "gap".
* Returns the total number of matches.
*/
-static int
-expand_in_path (
- garray_T *gap,
- char_u *pattern,
- int flags /* EW_* flags */
+static int expand_in_path(
+ garray_T *const gap,
+ char_u *const pattern,
+ const int flags // EW_* flags
)
{
- char_u *curdir;
garray_T path_ga;
- char_u *paths = NULL;
- curdir = xmalloc(MAXPATHL);
+ char_u *const curdir = xmalloc(MAXPATHL);
os_dirname(curdir, MAXPATHL);
ga_init(&path_ga, (int)sizeof(char_u *), 1);
expand_path_option(curdir, &path_ga);
xfree(curdir);
- if (GA_EMPTY(&path_ga))
+ if (GA_EMPTY(&path_ga)) {
return 0;
+ }
- paths = ga_concat_strings(&path_ga);
+ char_u *const paths = ga_concat_strings(&path_ga);
ga_clear_strings(&path_ga);
- globpath(paths, pattern, gap, (flags & EW_ICASE) ? WILD_ICASE : 0);
+ int glob_flags = 0;
+ if (flags & EW_ICASE) {
+ glob_flags |= WILD_ICASE;
+ }
+ if (flags & EW_ADDSLASH) {
+ glob_flags |= WILD_ADD_SLASH;
+ }
+ globpath(paths, pattern, gap, glob_flags);
xfree(paths);
return gap->ga_len;
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index f77310e19f..1a70ac152f 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -15,6 +15,7 @@ source test_findfile.vim
source test_float_func.vim
source test_functions.vim
source test_ga.vim
+source test_global.vim
source test_goto.vim
source test_jumps.vim
source test_fileformat.vim
diff --git a/src/nvim/testdir/test_find_complete.vim b/src/nvim/testdir/test_find_complete.vim
index 1019246404..7592b16192 100644
--- a/src/nvim/testdir/test_find_complete.vim
+++ b/src/nvim/testdir/test_find_complete.vim
@@ -88,6 +88,12 @@ func Test_find_complete()
call feedkeys(":find f\t\n", "xt")
call assert_equal('Holy Grail', getline(1))
+ " Test that find completion on directory appends a slash
+ call feedkeys(":find in/pa\tfile.txt\n", "xt")
+ call assert_equal('E.T.', getline(1))
+ call feedkeys(":find ./i\tstuff.txt\n", "xt")
+ call assert_equal('Another Holy Grail', getline(1))
+
" Test shortening of
"
" foo/x/bar/voyager.txt
diff --git a/src/nvim/testdir/test_global.vim b/src/nvim/testdir/test_global.vim
new file mode 100644
index 0000000000..be8aa69623
--- /dev/null
+++ b/src/nvim/testdir/test_global.vim
@@ -0,0 +1,11 @@
+
+func Test_yank_put_clipboard()
+ new
+ call setline(1, ['a', 'b', 'c'])
+ set clipboard=unnamed
+ g/^/normal yyp
+ call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6))
+
+ set clipboard&
+ bwipe!
+endfunc
diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim
index 42176d8d34..5b16f6d205 100644
--- a/src/nvim/testdir/test_vimscript.vim
+++ b/src/nvim/testdir/test_vimscript.vim
@@ -1061,6 +1061,7 @@ func Test_echo_and_string()
let l = split(result, "\n")
call assert_equal(["{'a': [], 'b': []}",
\ "{'a': [], 'b': []}"], l)
+endfunc
"-------------------------------------------------------------------------------
" Test 94: 64-bit Numbers {{{1
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 211b9bc544..f41c715696 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -459,8 +459,8 @@ static void update_attrs(UI *ui, HlAttrs attrs)
bool underline = attr & (HL_UNDERLINE), undercurl = attr & (HL_UNDERCURL);
if (unibi_get_str(data->ut, unibi_set_attributes)) {
- if (bold || reverse || underline || undercurl) {
- UNIBI_SET_NUM_VAR(data->params[0], 0); // standout
+ if (bold || reverse || underline || undercurl || standout) {
+ UNIBI_SET_NUM_VAR(data->params[0], standout);
UNIBI_SET_NUM_VAR(data->params[1], underline || undercurl);
UNIBI_SET_NUM_VAR(data->params[2], reverse);
UNIBI_SET_NUM_VAR(data->params[3], 0); // blink
@@ -520,7 +520,7 @@ static void update_attrs(UI *ui, HlAttrs attrs)
}
data->default_attr = fg == -1 && bg == -1
- && !bold && !italic && !underline && !undercurl && !reverse;
+ && !bold && !italic && !underline && !undercurl && !reverse && !standout;
}
static void final_column_wrap(UI *ui)
@@ -1722,30 +1722,25 @@ static void augment_terminfo(TUIData *data, const char *term,
/// Terminals usually ignore unrecognized private modes, and there is no
/// known ambiguity with these. So we just set them unconditionally.
- data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(ut,
- "ext.enable_lr_margin",
- "\x1b[?69h");
- data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(ut,
- "ext.disable_lr_margin",
- "\x1b[?69l");
- data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str(ut,
- "ext.enable_bpaste",
- "\x1b[?2004h");
- data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut,
- "ext.disable_bpaste",
- "\x1b[?2004l");
- data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut,
- "ext.enable_focus",
- rxvt ? "\x1b]777;focus;on\x7" : "\x1b[?1004h");
- data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut,
- "ext.disable_focus",
- rxvt ? "\x1b]777;focus;off\x7" : "\x1b[?1004l");
- data->unibi_ext.enable_mouse = (int)unibi_add_ext_str(ut,
- "ext.enable_mouse",
- "\x1b[?1002h\x1b[?1006h");
- data->unibi_ext.disable_mouse = (int)unibi_add_ext_str(ut,
- "ext.disable_mouse",
- "\x1b[?1002l\x1b[?1006l");
+ data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(
+ ut, "ext.enable_lr_margin", "\x1b[?69h");
+ data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(
+ ut, "ext.disable_lr_margin", "\x1b[?69l");
+ data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str(
+ ut, "ext.enable_bpaste", "\x1b[?2004h");
+ data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(
+ ut, "ext.disable_bpaste", "\x1b[?2004l");
+ // For urxvt send BOTH xterm and old urxvt sequences. #8695
+ data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(
+ ut, "ext.enable_focus",
+ rxvt ? "\x1b[?1004h\x1b]777;focus;on\x7" : "\x1b[?1004h");
+ data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(
+ ut, "ext.disable_focus",
+ rxvt ? "\x1b[?1004l\x1b]777;focus;off\x7" : "\x1b[?1004l");
+ data->unibi_ext.enable_mouse = (int)unibi_add_ext_str(
+ ut, "ext.enable_mouse", "\x1b[?1002h\x1b[?1006h");
+ data->unibi_ext.disable_mouse = (int)unibi_add_ext_str(
+ ut, "ext.disable_mouse", "\x1b[?1002l\x1b[?1006l");
}
static void flush_buf(UI *ui)