diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-05-28 20:31:42 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-05-28 20:31:42 +0200 |
commit | 6f6c0f8085a5b0855f9dce8378086fd5e06a219b (patch) | |
tree | b767d281763aba34c4412a442f8d09b77312daf2 /src | |
parent | 2d1fe05fc06a91886635680886c200ad90f0abd7 (diff) | |
download | vim-6f6c0f8085a5b0855f9dce8378086fd5e06a219b.zip |
updated for version 7.4.313
Problem: Changing the return value of getpos() causes an error. (Jie Zhu)
Solution: Revert getpos() and add getcurpos().
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 31 | ||||
-rw-r--r-- | src/testdir/test_eval.in | 4 | ||||
-rw-r--r-- | src/testdir/test_eval.ok | bin | 11007 -> 11010 bytes | |||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 33 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c index 0e9ec9ed0..51ec0b8b9 100644 --- a/src/eval.c +++ b/src/eval.c @@ -560,6 +560,7 @@ static void f_getftype __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getline __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_getcurpos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv)); @@ -7967,6 +7968,7 @@ static struct fst {"getcmdline", 0, 0, f_getcmdline}, {"getcmdpos", 0, 0, f_getcmdpos}, {"getcmdtype", 0, 0, f_getcmdtype}, + {"getcurpos", 0, 0, f_getcurpos}, {"getcwd", 0, 0, f_getcwd}, {"getfontname", 0, 1, f_getfontname}, {"getfperm", 1, 1, f_getfperm}, @@ -11780,6 +11782,19 @@ f_getpid(argvars, rettv) rettv->vval.v_number = mch_get_pid(); } +static void getpos_both __ARGS((typval_T *argvars, typval_T *rettv, int getcurpos)); + +/* + * "getcurpos()" function + */ + static void +f_getcurpos(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + getpos_both(argvars, rettv, TRUE); +} + /* * "getpos(string)" function */ @@ -11788,6 +11803,15 @@ f_getpos(argvars, rettv) typval_T *argvars; typval_T *rettv; { + getpos_both(argvars, rettv, FALSE); +} + + static void +getpos_both(argvars, rettv, getcurpos) + typval_T *argvars; + typval_T *rettv; + int getcurpos; +{ pos_T *fp; list_T *l; int fnum = -1; @@ -11795,7 +11819,10 @@ f_getpos(argvars, rettv) if (rettv_list_alloc(rettv) == OK) { l = rettv->vval.v_list; - fp = var2fpos(&argvars[0], TRUE, &fnum); + if (getcurpos) + fp = &curwin->w_cursor; + else + fp = var2fpos(&argvars[0], TRUE, &fnum); if (fnum != -1) list_append_number(l, (varnumber_T)fnum); else @@ -11810,7 +11837,7 @@ f_getpos(argvars, rettv) (fp != NULL) ? (varnumber_T)fp->coladd : #endif (varnumber_T)0); - if (fp == &curwin->w_cursor) + if (getcurpos) list_append_number(l, (varnumber_T)curwin->w_curswant + 1); } else diff --git a/src/testdir/test_eval.in b/src/testdir/test_eval.in index 5a466d402..cd605af56 100644 --- a/src/testdir/test_eval.in +++ b/src/testdir/test_eval.in @@ -190,9 +190,9 @@ endfun :$put =v:exception :endtry :" -:$put ='{{{1 setpos/getpos' +:$put ='{{{1 getcurpos/setpos' /^012345678 -6l:let sp = getpos('.') +6l:let sp = getcurpos() 0:call setpos('.', sp) jyl:$put :" diff --git a/src/testdir/test_eval.ok b/src/testdir/test_eval.ok Binary files differindex 7bbce810f..59112d028 100644 --- a/src/testdir/test_eval.ok +++ b/src/testdir/test_eval.ok diff --git a/src/version.c b/src/version.c index b3ec0d318..dc5988be5 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 313, +/**/ 312, /**/ 311, |