diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 12 | ||||
-rw-r--r-- | src/nvim/fileio.c | 20 | ||||
-rw-r--r-- | src/nvim/normal.c | 5 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 5 | ||||
-rw-r--r-- | src/nvim/regexp.c | 21 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test96.in | 142 | ||||
-rw-r--r-- | src/nvim/testdir/test96.ok | 9 | ||||
-rw-r--r-- | src/nvim/undo.c | 4 | ||||
-rw-r--r-- | src/nvim/version.c | 10 |
10 files changed, 40 insertions, 189 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f291d9f302..8a98eae21f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6363,8 +6363,8 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate) len = get_env_len(arg); if (evaluate) { - if (len == 0) { - return FAIL; // Can't be an environment variable. + if (len == 0) { + return FAIL; // Invalid empty name. } cc = name[len]; name[len] = NUL; @@ -8145,11 +8145,17 @@ static void f_eval(typval_T *argvars, typval_T *rettv) if (s != NULL) s = skipwhite(s); + char_u *p = s; if (s == NULL || eval1(&s, rettv, TRUE) == FAIL) { + if (p != NULL && !aborting()) { + EMSG2(_(e_invexpr2), p); + } + need_clr_eos = FALSE; rettv->v_type = VAR_NUMBER; rettv->vval.v_number = 0; - } else if (*s != NUL) + } else if (*s != NUL) { EMSG(_(e_trailing)); + } } /* diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index d06f49a30b..f5cf226da4 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -7167,14 +7167,14 @@ static bool match_file_pat(char_u *pattern, regprog_T **prog, char_u *fname, * 2. the short file name, when the pattern has a '/'. * 3. the tail of the file name, when the pattern has no '/'. */ - if ( - (regmatch.regprog != NULL - && ((allow_dirs - && (vim_regexec(®match, fname, (colnr_T)0) - || (sfname != NULL - && vim_regexec(®match, sfname, (colnr_T)0)))) - || (!allow_dirs && vim_regexec(®match, tail, (colnr_T)0))))) + if (regmatch.regprog != NULL + && ((allow_dirs + && (vim_regexec(®match, fname, (colnr_T)0) + || (sfname != NULL + && vim_regexec(®match, sfname, (colnr_T)0)))) + || (!allow_dirs && vim_regexec(®match, tail, (colnr_T)0)))) { result = true; + } if (prog != NULL) { *prog = regmatch.regprog; @@ -7233,11 +7233,9 @@ file_pat_to_reg_pat ( int no_bslash /* Don't use a backward slash as pathsep */ ) { - size_t size; char_u *endp; char_u *reg_pat; char_u *p; - int i; int nested = 0; int add_dollar = TRUE; @@ -7246,7 +7244,7 @@ file_pat_to_reg_pat ( if (pat_end == NULL) pat_end = pat + STRLEN(pat); - size = 2; /* '^' at start, '$' at end */ + size_t size = 2; // '^' at start, '$' at end. for (p = pat; p < pat_end; p++) { switch (*p) { @@ -7275,7 +7273,7 @@ file_pat_to_reg_pat ( } reg_pat = xmalloc(size + 1); - i = 0; + size_t i = 0; if (pat[0] == '*') while (pat[0] == '*' && pat < pat_end - 1) diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 3217e06ac2..849bc0ea7d 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7010,10 +7010,7 @@ static void nv_edit(cmdarg_T *cap) break; case 'I': /* "I"nsert before the first non-blank */ - if (vim_strchr(p_cpo, CPO_INSEND) == NULL) - beginline(BL_WHITE); - else - beginline(BL_WHITE|BL_FIX); + beginline(BL_WHITE); break; case 'a': /* "a"ppend is like "i"nsert on the next character. */ diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index e40234f671..278b3f0872 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -95,7 +95,6 @@ #define CPO_EMPTYREGION 'E' /* operating on empty region is an error */ #define CPO_FNAMER 'f' /* set file name for ":r file" */ #define CPO_FNAMEW 'F' /* set file name for ":w file" */ -#define CPO_INSEND 'H' /* "I" inserts before last blank in line */ #define CPO_INTMOD 'i' /* interrupt a read makes buffer modified */ #define CPO_INDENT 'I' /* remove auto-indent more often */ #define CPO_JOINSP 'j' /* only use two spaces for join after '.' */ @@ -144,9 +143,9 @@ * cursor would not move */ /* default values for Vim, Vi and POSIX */ #define CPO_VIM "aABceFs" -#define CPO_VI "aAbBcCdDeEfFHiIjJkKlLmMnoOpPqrRsStuvWxXyZ$!%*-+<>;" +#define CPO_VI "aAbBcCdDeEfFiIjJkKlLmMnoOpPqrRsStuvWxXyZ$!%*-+<>;" #define CPO_ALL \ - "aAbBcCdDeEfFHiIjJkKlLmMnoOpPqrRsStuvWxXyZ$!%*-+<>#{|&/\\.;" + "aAbBcCdDeEfFiIjJkKlLmMnoOpPqrRsStuvWxXyZ$!%*-+<>#{|&/\\.;" /* characters for p_ww option: */ #define WW_ALL "bshl<>[],~" diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 6726b49e77..133935b9c6 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3274,7 +3274,7 @@ static lpos_T reg_endzpos[NSUBEXP]; /* idem, end pos */ * Uses curbuf for line count and 'iskeyword'. * If "line_lbr" is true, consider a "\n" in "line" to be a line break. * - * Return TRUE if there is a match, FALSE if not. + * Returns 0 for failure, number of lines contained in the match otherwise. */ static int bt_regexec_nl ( @@ -3293,7 +3293,10 @@ bt_regexec_nl ( ireg_ic = rmp->rm_ic; ireg_icombine = FALSE; ireg_maxcol = 0; - return bt_regexec_both(line, col, NULL) != 0; + + long r = bt_regexec_both(line, col, NULL); + assert(r <= INT_MAX); + return (int)r; } @@ -3312,8 +3315,6 @@ bt_regexec_nl ( static long bt_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm) { - long r; - reg_match = NULL; reg_mmatch = rmp; reg_buf = buf; @@ -3325,14 +3326,13 @@ static long bt_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, ireg_icombine = FALSE; ireg_maxcol = rmp->rmm_maxcol; - r = bt_regexec_both(NULL, col, tm); - - return r; + return bt_regexec_both(NULL, col, tm); } /* * Match a regexp against a string ("line" points to the string) or multiple * lines ("line" is NULL, use reg_getline()). + * Returns 0 for failure, number of lines contained in the match otherwise. */ static long bt_regexec_both(char_u *line, colnr_T col, /* column to start looking for match */ @@ -7078,10 +7078,11 @@ static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, bool nl) p_re = save_p_re; } - return result; + return result > 0; } // Note: "*prog" may be freed and changed. +// Return TRUE if there is a match, FALSE if not. int vim_regexec_prog(regprog_T **prog, bool ignore_case, char_u *line, colnr_T col) { @@ -7092,6 +7093,7 @@ int vim_regexec_prog(regprog_T **prog, bool ignore_case, char_u *line, } // Note: "rmp->regprog" may be freed and changed. +// Return TRUE if there is a match, FALSE if not. int vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col) { return vim_regexec_both(rmp, line, col, false); @@ -7099,6 +7101,7 @@ int vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col) // Like vim_regexec(), but consider a "\n" in "line" to be a line break. // Note: "rmp->regprog" may be freed and changed. +// Return TRUE if there is a match, FALSE if not. int vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col) { return vim_regexec_both(rmp, line, col, true); @@ -7145,5 +7148,5 @@ long vim_regexec_multi( p_re = save_p_re; } - return result; + return result <= 0 ? 0 : result; } diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 2dedc3db12..ee3eb89bd8 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -27,7 +27,6 @@ SCRIPTS := test_autoformat_join.out \ test76.out test79.out test80.out \ test82.out test83.out \ test86.out test87.out test88.out \ - test96.out \ test_listlbr.out \ test_breakindent.out \ test_argument_count.out \ diff --git a/src/nvim/testdir/test96.in b/src/nvim/testdir/test96.in deleted file mode 100644 index 9d1a2c83a5..0000000000 --- a/src/nvim/testdir/test96.in +++ /dev/null @@ -1,142 +0,0 @@ -This will test for problems in quickfix: -A. incorrectly copying location lists which caused the location list to show a - different name than the file that was actually being displayed. -B. not reusing the window for which the location list window is opened but - instead creating new windows. -C. make sure that the location list window is not reused instead of the window - it belongs to. - -Note: to debug a problem comment out the last ":b 1" in a test and testing will -stop at this point. - -STARTTEST -:so small.vim -: enew -: w! test.out -: b 1 -: " Set up the test environment: -: function! ReadTestProtocol(name) -: let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '') -: let word = substitute(base, '\v(.*)\..*', '\1', '') -: -: setl modifiable -: setl noreadonly -: setl noswapfile -: setl bufhidden=delete -: %del _ -: " For problem 2: -: " 'buftype' has to be set to reproduce the constant opening of new windows -: setl buftype=nofile -: -: call setline(1, word) -: -: setl nomodified -: setl nomodifiable -: setl readonly -: exe 'doautocmd BufRead ' . substitute(a:name, '\v^test://(.*)', '\1', '') -: endfunction -: augroup testgroup -: au! -: autocmd BufReadCmd test://* call ReadTestProtocol(expand("<amatch>")) -: augroup END -: let words = [ "foo", "bar", "baz", "quux", "shmoo", "spam", "eggs" ] -: -: let qflist = [] -: for word in words -: call add(qflist, {'filename': 'test://' . word . '.txt', 'text': 'file ' . word . '.txt', }) -: " NOTE: problem 1: -: " intentionally not setting 'lnum' so that the quickfix entries are not -: " valid -: call setloclist(0, qflist, ' ') -: endfor -ENDTEST - -Test A: -STARTTEST -:lrewind -:enew -:lopen -:lnext -:lnext -:lnext -:lnext -:vert split -:wincmd L -:lopen -:wincmd p -:lnext -:"b 1 -:let fileName = expand("%") -:wincmd p -:let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '') -:wincmd n -:wincmd K -:b test.out -:let fileName = substitute(fileName, '\\', '/', 'g') -:let locationListFileName = substitute(locationListFileName, '\\', '/', 'g') -:call append(line('$'), "Test A:") -:call append(line('$'), " - file name displayed: " . fileName) -:call append(line('$'), " - quickfix claims that the file name displayed is: " . locationListFileName) -:w -:wincmd o -:b 1 -ENDTEST - -Test B: -STARTTEST -:lrewind -:lopen -:2 -:exe "normal \<CR>" -:wincmd p -:3 -:exe "normal \<CR>" -:wincmd p -:4 -:exe "normal \<CR>" -:let numberOfWindowsOpen = winnr('$') -:wincmd n -:wincmd K -:b test.out -:call append(line('$'), "Test B:") -:call append(line('$'), " - number of window open: " . numberOfWindowsOpen) -:w -:wincmd o -:b 1 -ENDTEST - -Test C: -STARTTEST -:lrewind -:lopen -:" Let's move the location list window to the top to check whether it (the first -:" window found) will be reused when we try to open new windows: -:wincmd K -:2 -:exe "normal \<CR>" -:wincmd p -:3 -:exe "normal \<CR>" -:wincmd p -:4 -:exe "normal \<CR>" -:1wincmd w -:let locationListWindowBufType = &buftype -:2wincmd w -:let bufferName = expand("%") -:wincmd n -:wincmd K -:b test.out -:let bufferName = substitute(bufferName, '\\', '/', 'g') -:call append(line('$'), "Test C:") -:call append(line('$'), " - 'buftype' of the location list window: " . locationListWindowBufType) -:call append(line('$'), " - buffer displayed in the 2nd window: " . bufferName) -:w -:wincmd o -:b 1 -ENDTEST - -STARTTEST -:qa -ENDTEST - diff --git a/src/nvim/testdir/test96.ok b/src/nvim/testdir/test96.ok deleted file mode 100644 index 3498e52f73..0000000000 --- a/src/nvim/testdir/test96.ok +++ /dev/null @@ -1,9 +0,0 @@ - -Test A: - - file name displayed: test://bar.txt - - quickfix claims that the file name displayed is: test://bar.txt -Test B: - - number of window open: 2 -Test C: - - 'buftype' of the location list window: quickfix - - buffer displayed in the 2nd window: test://quux.txt diff --git a/src/nvim/undo.c b/src/nvim/undo.c index d74f1c0b03..ef1ac60599 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1035,8 +1035,8 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash) } } - /* strip any s-bit */ - perm = perm & 0777; + // Strip any sticky and executable bits. + perm = perm & 0666; /* If the undo file already exists, verify that it actually is an undo * file, and delete it. */ diff --git a/src/nvim/version.c b/src/nvim/version.c index 76460959ed..e80b653c00 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -76,7 +76,7 @@ static int included_patches[] = { 710, //709, //708, - //707, + 707, 706, //705, //704, @@ -193,7 +193,7 @@ static int included_patches[] = { //593, //592, //591 NA - //590, + 590, //589 NA 588, //587, @@ -209,7 +209,7 @@ static int included_patches[] = { //577, //576, //575, - //574, + 574, //573, 572, //571 NA @@ -219,7 +219,7 @@ static int included_patches[] = { 567, 566, 565, - //564, + //564 NA 563, //562, 561, @@ -257,7 +257,7 @@ static int included_patches[] = { 529, 528, 527, - //526, + 526, 525, //524, //523 NA |