aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2014-12-23 15:19:07 -0500
committerJustin M. Keyes <justinkz@gmail.com>2014-12-23 15:19:07 -0500
commitaa08632caf80d2259d94e8f6e30cd806e3c05a1d (patch)
treefac1e6456a15da2a08a857fdc3c5e2d7fc645af6 /src/nvim/eval.c
parent4f6bb8a9a997aacbe9f9f1ca83e7e4c502bdc03c (diff)
parentfc0be5b79dfccc582005367da5ee24bd73592879 (diff)
downloadrneovim-aa08632caf80d2259d94e8f6e30cd806e3c05a1d.tar.gz
rneovim-aa08632caf80d2259d94e8f6e30cd806e3c05a1d.tar.bz2
rneovim-aa08632caf80d2259d94e8f6e30cd806e3c05a1d.zip
Merge pull request #1728 from fwalch/small-patches2
vim-patch: Multiple small patches (2)
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f50a215559..67a68f70d5 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -15278,7 +15278,7 @@ static void f_winrestview(typval_T *argvars, typval_T *rettv)
win_new_width(curwin, curwin->w_width);
changed_window_setting();
- if (curwin->w_topline == 0)
+ if (curwin->w_topline <= 0)
curwin->w_topline = 1;
if (curwin->w_topline > curbuf->b_ml.ml_line_count)
curwin->w_topline = curbuf->b_ml.ml_line_count;
@@ -19665,6 +19665,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
regmatch_T regmatch;
int do_all;
char_u *tail;
+ char_u *end;
garray_T ga;
char_u *save_cpo;
char_u *zero_width = NULL;
@@ -19681,6 +19682,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) {
tail = str;
+ end = str + STRLEN(str);
while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str))) {
/* Skip empty match except for first match. */
if (regmatch.startp[0] == regmatch.endp[0]) {
@@ -19703,7 +19705,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
* - The text after the match.
*/
sublen = vim_regsub(&regmatch, sub, tail, FALSE, TRUE, FALSE);
- ga_grow(&ga, (int)(STRLEN(tail) + sublen -
+ ga_grow(&ga, (int)((end - tail) + sublen -
(regmatch.endp[0] - regmatch.startp[0])));
/* copy the text up to where the match is */