Karsten Hopp 242d8e
To: vim_dev@googlegroups.com
Karsten Hopp 242d8e
Subject: Patch 7.4.313
Karsten Hopp 242d8e
Fcc: outbox
Karsten Hopp 242d8e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 242d8e
Mime-Version: 1.0
Karsten Hopp 242d8e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 242d8e
Content-Transfer-Encoding: 8bit
Karsten Hopp 242d8e
------------
Karsten Hopp 242d8e
Karsten Hopp 242d8e
Patch 7.4.313 (after 7.4.310)
Karsten Hopp 242d8e
Problem:    Changing the return value of getpos() causes an error. (Jie Zhu)
Karsten Hopp 242d8e
Solution:   Revert getpos() and add getcurpos().
Karsten Hopp 242d8e
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok,
Karsten Hopp 242d8e
	    runtime/doc/eval.txt
Karsten Hopp 242d8e
Karsten Hopp 242d8e
Karsten Hopp 242d8e
*** ../vim-7.4.312/src/eval.c	2014-05-28 18:22:37.876225054 +0200
Karsten Hopp 242d8e
--- src/eval.c	2014-05-28 20:11:55.364282457 +0200
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 560,565 ****
Karsten Hopp 242d8e
--- 560,566 ----
Karsten Hopp 242d8e
  static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
  static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
  static void f_getpid __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
+ static void f_getcurpos __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
  static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
  static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
  static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 7967,7972 ****
Karsten Hopp 242d8e
--- 7968,7974 ----
Karsten Hopp 242d8e
      {"getcmdline",	0, 0, f_getcmdline},
Karsten Hopp 242d8e
      {"getcmdpos",	0, 0, f_getcmdpos},
Karsten Hopp 242d8e
      {"getcmdtype",	0, 0, f_getcmdtype},
Karsten Hopp 242d8e
+     {"getcurpos",	0, 0, f_getcurpos},
Karsten Hopp 242d8e
      {"getcwd",		0, 0, f_getcwd},
Karsten Hopp 242d8e
      {"getfontname",	0, 1, f_getfontname},
Karsten Hopp 242d8e
      {"getfperm",	1, 1, f_getfperm},
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 11780,11785 ****
Karsten Hopp 242d8e
--- 11782,11800 ----
Karsten Hopp 242d8e
      rettv->vval.v_number = mch_get_pid();
Karsten Hopp 242d8e
  }
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
+ static void getpos_both __ARGS((typval_T *argvars, typval_T *rettv, int getcurpos));
Karsten Hopp 242d8e
+ 
Karsten Hopp 242d8e
+ /*
Karsten Hopp 242d8e
+  * "getcurpos()" function
Karsten Hopp 242d8e
+  */
Karsten Hopp 242d8e
+     static void
Karsten Hopp 242d8e
+ f_getcurpos(argvars, rettv)
Karsten Hopp 242d8e
+     typval_T	*argvars;
Karsten Hopp 242d8e
+     typval_T	*rettv;
Karsten Hopp 242d8e
+ {
Karsten Hopp 242d8e
+     getpos_both(argvars, rettv, TRUE);
Karsten Hopp 242d8e
+ }
Karsten Hopp 242d8e
+ 
Karsten Hopp 242d8e
  /*
Karsten Hopp 242d8e
   * "getpos(string)" function
Karsten Hopp 242d8e
   */
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 11788,11793 ****
Karsten Hopp 242d8e
--- 11803,11817 ----
Karsten Hopp 242d8e
      typval_T	*argvars;
Karsten Hopp 242d8e
      typval_T	*rettv;
Karsten Hopp 242d8e
  {
Karsten Hopp 242d8e
+     getpos_both(argvars, rettv, FALSE);
Karsten Hopp 242d8e
+ }
Karsten Hopp 242d8e
+ 
Karsten Hopp 242d8e
+     static void
Karsten Hopp 242d8e
+ getpos_both(argvars, rettv, getcurpos)
Karsten Hopp 242d8e
+     typval_T	*argvars;
Karsten Hopp 242d8e
+     typval_T	*rettv;
Karsten Hopp 242d8e
+     int		getcurpos;
Karsten Hopp 242d8e
+ {
Karsten Hopp 242d8e
      pos_T	*fp;
Karsten Hopp 242d8e
      list_T	*l;
Karsten Hopp 242d8e
      int		fnum = -1;
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 11795,11801 ****
Karsten Hopp 242d8e
      if (rettv_list_alloc(rettv) == OK)
Karsten Hopp 242d8e
      {
Karsten Hopp 242d8e
  	l = rettv->vval.v_list;
Karsten Hopp 242d8e
! 	fp = var2fpos(&argvars[0], TRUE, &fnum);
Karsten Hopp 242d8e
  	if (fnum != -1)
Karsten Hopp 242d8e
  	    list_append_number(l, (varnumber_T)fnum);
Karsten Hopp 242d8e
  	else
Karsten Hopp 242d8e
--- 11819,11828 ----
Karsten Hopp 242d8e
      if (rettv_list_alloc(rettv) == OK)
Karsten Hopp 242d8e
      {
Karsten Hopp 242d8e
  	l = rettv->vval.v_list;
Karsten Hopp 242d8e
! 	if (getcurpos)
Karsten Hopp 242d8e
! 	    fp = &curwin->w_cursor;
Karsten Hopp 242d8e
! 	else
Karsten Hopp 242d8e
! 	    fp = var2fpos(&argvars[0], TRUE, &fnum);
Karsten Hopp 242d8e
  	if (fnum != -1)
Karsten Hopp 242d8e
  	    list_append_number(l, (varnumber_T)fnum);
Karsten Hopp 242d8e
  	else
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 11810,11816 ****
Karsten Hopp 242d8e
  				(fp != NULL) ? (varnumber_T)fp->coladd :
Karsten Hopp 242d8e
  #endif
Karsten Hopp 242d8e
  							      (varnumber_T)0);
Karsten Hopp 242d8e
! 	if (fp == &curwin->w_cursor)
Karsten Hopp 242d8e
  	    list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
Karsten Hopp 242d8e
      }
Karsten Hopp 242d8e
      else
Karsten Hopp 242d8e
--- 11837,11843 ----
Karsten Hopp 242d8e
  				(fp != NULL) ? (varnumber_T)fp->coladd :
Karsten Hopp 242d8e
  #endif
Karsten Hopp 242d8e
  							      (varnumber_T)0);
Karsten Hopp 242d8e
! 	if (getcurpos)
Karsten Hopp 242d8e
  	    list_append_number(l, (varnumber_T)curwin->w_curswant + 1);
Karsten Hopp 242d8e
      }
Karsten Hopp 242d8e
      else
Karsten Hopp 242d8e
*** ../vim-7.4.312/src/testdir/test_eval.in	2014-05-28 14:32:47.160104334 +0200
Karsten Hopp 242d8e
--- src/testdir/test_eval.in	2014-05-28 20:14:27.048283785 +0200
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 190,198 ****
Karsten Hopp 242d8e
  :$put =v:exception
Karsten Hopp 242d8e
  :endtry
Karsten Hopp 242d8e
  :"
Karsten Hopp 242d8e
! :$put ='{{{1 setpos/getpos'
Karsten Hopp 242d8e
  /^012345678
Karsten Hopp 242d8e
! 6l:let sp = getpos('.')
Karsten Hopp 242d8e
  0:call setpos('.', sp)
Karsten Hopp 242d8e
  jyl:$put
Karsten Hopp 242d8e
  :"
Karsten Hopp 242d8e
--- 190,198 ----
Karsten Hopp 242d8e
  :$put =v:exception
Karsten Hopp 242d8e
  :endtry
Karsten Hopp 242d8e
  :"
Karsten Hopp 242d8e
! :$put ='{{{1 getcurpos/setpos'
Karsten Hopp 242d8e
  /^012345678
Karsten Hopp 242d8e
! 6l:let sp = getcurpos()
Karsten Hopp 242d8e
  0:call setpos('.', sp)
Karsten Hopp 242d8e
  jyl:$put
Karsten Hopp 242d8e
  :"
Karsten Hopp 242d8e
*** ../vim-7.4.312/src/testdir/test_eval.ok	2014-05-28 14:32:47.160104334 +0200
Karsten Hopp 242d8e
--- src/testdir/test_eval.ok	2014-05-28 20:14:43.316283927 +0200
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 346,350 ****
Karsten Hopp 242d8e
  Bar exists: 1
Karsten Hopp 242d8e
  func Bar exists: 1
Karsten Hopp 242d8e
  Vim(call):E116: Invalid arguments for function append
Karsten Hopp 242d8e
! {{{1 setpos/getpos
Karsten Hopp 242d8e
  6
Karsten Hopp 242d8e
--- 346,350 ----
Karsten Hopp 242d8e
  Bar exists: 1
Karsten Hopp 242d8e
  func Bar exists: 1
Karsten Hopp 242d8e
  Vim(call):E116: Invalid arguments for function append
Karsten Hopp 242d8e
! {{{1 getcurpos/setpos
Karsten Hopp 242d8e
  6
Karsten Hopp 242d8e
*** ../vim-7.4.312/runtime/doc/eval.txt	2014-05-28 18:22:37.872225054 +0200
Karsten Hopp 242d8e
--- runtime/doc/eval.txt	2014-05-28 20:27:57.092290876 +0200
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 1808,1817 ****
Karsten Hopp 242d8e
  getcmdline()			String	return the current command-line
Karsten Hopp 242d8e
  getcmdpos()			Number	return cursor position in command-line
Karsten Hopp 242d8e
  getcmdtype()			String	return the current command-line type
Karsten Hopp 242d8e
  getcwd()			String	the current working directory
Karsten Hopp 242d8e
  getfperm( {fname})		String	file permissions of file {fname}
Karsten Hopp 242d8e
  getfsize( {fname})		Number	size in bytes of file {fname}
Karsten Hopp 242d8e
- getfontname( [{name}])		String	name of font being used
Karsten Hopp 242d8e
  getftime( {fname})		Number	last modification time of file
Karsten Hopp 242d8e
  getftype( {fname})		String	description of type of file {fname}
Karsten Hopp 242d8e
  getline( {lnum})		String	line {lnum} of current buffer
Karsten Hopp 242d8e
--- 1808,1818 ----
Karsten Hopp 242d8e
  getcmdline()			String	return the current command-line
Karsten Hopp 242d8e
  getcmdpos()			Number	return cursor position in command-line
Karsten Hopp 242d8e
  getcmdtype()			String	return the current command-line type
Karsten Hopp 242d8e
+ getcurpos()			List	position of the cursor
Karsten Hopp 242d8e
  getcwd()			String	the current working directory
Karsten Hopp 242d8e
+ getfontname( [{name}])		String	name of font being used
Karsten Hopp 242d8e
  getfperm( {fname})		String	file permissions of file {fname}
Karsten Hopp 242d8e
  getfsize( {fname})		Number	size in bytes of file {fname}
Karsten Hopp 242d8e
  getftime( {fname})		Number	last modification time of file
Karsten Hopp 242d8e
  getftype( {fname})		String	description of type of file {fname}
Karsten Hopp 242d8e
  getline( {lnum})		String	line {lnum} of current buffer
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 2606,2613 ****
Karsten Hopp 242d8e
  		with two, three or four item:
Karsten Hopp 242d8e
  			[{lnum}, {col}, {off}]
Karsten Hopp 242d8e
  			[{lnum}, {col}, {off}, {curswant}]
Karsten Hopp 242d8e
! 		This is like the return value of |getpos()|, but without the
Karsten Hopp 242d8e
! 		first item.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  		Does not change the jumplist.
Karsten Hopp 242d8e
  		If {lnum} is greater than the number of lines in the buffer,
Karsten Hopp 242d8e
--- 2607,2614 ----
Karsten Hopp 242d8e
  		with two, three or four item:
Karsten Hopp 242d8e
  			[{lnum}, {col}, {off}]
Karsten Hopp 242d8e
  			[{lnum}, {col}, {off}, {curswant}]
Karsten Hopp 242d8e
! 		This is like the return value of |getpos()| or |getcurpos|,
Karsten Hopp 242d8e
! 		but without the first item.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  		Does not change the jumplist.
Karsten Hopp 242d8e
  		If {lnum} is greater than the number of lines in the buffer,
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 2617,2622 ****
Karsten Hopp 242d8e
--- 2618,2625 ----
Karsten Hopp 242d8e
  		the cursor will be positioned at the last character in the
Karsten Hopp 242d8e
  		line.
Karsten Hopp 242d8e
  		If {col} is zero, the cursor will stay in the current column.
Karsten Hopp 242d8e
+ 		If {curswant} is given it is used to set the preferred column
Karsten Hopp 242d8e
+ 		for vertical movment.  Otherwise {col} is used.
Karsten Hopp 242d8e
  		When 'virtualedit' is used {off} specifies the offset in
Karsten Hopp 242d8e
  		screen columns from the start of the character.  E.g., a
Karsten Hopp 242d8e
  		position within a <Tab> or after the last character.
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 3339,3344 ****
Karsten Hopp 242d8e
--- 3347,3363 ----
Karsten Hopp 242d8e
  		Returns an empty string otherwise.
Karsten Hopp 242d8e
  		Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
+ 							*getcurpos()*
Karsten Hopp 242d8e
+ getcurpos()	Get the position of the cursor.  This is like getpos('.'), but
Karsten Hopp 242d8e
+ 		includes an extra item in the list:
Karsten Hopp 242d8e
+ 		    [bufnum, lnum, col, off, curswant]
Karsten Hopp 242d8e
+ 		The "curswant" number is the preferred column when moving the
Karsten Hopp 242d8e
+ 		cursor vertically.
Karsten Hopp 242d8e
+ 		This can be used to save and restore the cursor position: >
Karsten Hopp 242d8e
+ 			let save_cursor = getcurpos()
Karsten Hopp 242d8e
+ 			MoveTheCursorAround
Karsten Hopp 242d8e
+ 			call setpos('.', save_cursor)
Karsten Hopp 242d8e
+ 
Karsten Hopp 242d8e
  							*getcwd()*
Karsten Hopp 242d8e
  getcwd()	The result is a String, which is the name of the current
Karsten Hopp 242d8e
  		working directory.
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 4493,4502 ****
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  							*getpos()*
Karsten Hopp 242d8e
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
Karsten Hopp 242d8e
! 		see |line()|.
Karsten Hopp 242d8e
! 		The result is a |List| with four or five numbers:
Karsten Hopp 242d8e
  		    [bufnum, lnum, col, off]
Karsten Hopp 242d8e
- 		    [bufnum, lnum, col, off, curswant]
Karsten Hopp 242d8e
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
Karsten Hopp 242d8e
  		is the buffer number of the mark.
Karsten Hopp 242d8e
  		"lnum" and "col" are the position in the buffer.  The first
Karsten Hopp 242d8e
--- 4517,4526 ----
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  							*getpos()*
Karsten Hopp 242d8e
  getpos({expr})	Get the position for {expr}.  For possible values of {expr}
Karsten Hopp 242d8e
! 		see |line()|.  For getting the cursor position see
Karsten Hopp 242d8e
! 		|getcurpos()|.
Karsten Hopp 242d8e
! 		The result is a |List| with four numbers:
Karsten Hopp 242d8e
  		    [bufnum, lnum, col, off]
Karsten Hopp 242d8e
  		"bufnum" is zero, unless a mark like '0 or 'A is used, then it
Karsten Hopp 242d8e
  		is the buffer number of the mark.
Karsten Hopp 242d8e
  		"lnum" and "col" are the position in the buffer.  The first
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 4505,4520 ****
Karsten Hopp 242d8e
  		it is the offset in screen columns from the start of the
Karsten Hopp 242d8e
  		character.  E.g., a position within a <Tab> or after the last
Karsten Hopp 242d8e
  		character.
Karsten Hopp 242d8e
- 		The "curswant" number is only added for getpos('.'), it is the
Karsten Hopp 242d8e
- 		preferred column when moving the cursor vertically.
Karsten Hopp 242d8e
  		Note that for '< and '> Visual mode matters: when it is "V"
Karsten Hopp 242d8e
  		(visual line mode) the column of '< is zero and the column of
Karsten Hopp 242d8e
  		'> is a large number.
Karsten Hopp 242d8e
! 		This can be used to save and restore the cursor position: >
Karsten Hopp 242d8e
! 			let save_cursor = getpos(".")
Karsten Hopp 242d8e
! 			MoveTheCursorAround
Karsten Hopp 242d8e
! 			call setpos('.', save_cursor)
Karsten Hopp 242d8e
! <		Also see |setpos()|.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  or({expr}, {expr})					*or()*
Karsten Hopp 242d8e
  		Bitwise OR on the two arguments.  The arguments are converted
Karsten Hopp 242d8e
--- 4529,4542 ----
Karsten Hopp 242d8e
  		it is the offset in screen columns from the start of the
Karsten Hopp 242d8e
  		character.  E.g., a position within a <Tab> or after the last
Karsten Hopp 242d8e
  		character.
Karsten Hopp 242d8e
  		Note that for '< and '> Visual mode matters: when it is "V"
Karsten Hopp 242d8e
  		(visual line mode) the column of '< is zero and the column of
Karsten Hopp 242d8e
  		'> is a large number.
Karsten Hopp 242d8e
! 		This can be used to save and restore the position of a mark: >
Karsten Hopp 242d8e
! 			let save_a_mark = getpos("'a")
Karsten Hopp 242d8e
! 			...
Karsten Hopp 242d8e
! 			call setpos(''a', save_a_mark
Karsten Hopp 242d8e
! <		Also see |getcurpos()| and |setpos()|.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  or({expr}, {expr})					*or()*
Karsten Hopp 242d8e
  		Bitwise OR on the two arguments.  The arguments are converted
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 5347,5353 ****
Karsten Hopp 242d8e
  		Returns 0 when the position could be set, -1 otherwise.
Karsten Hopp 242d8e
  		An error message is given if {expr} is invalid.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
! 		Also see |getpos()|
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  		This does not restore the preferred column for moving
Karsten Hopp 242d8e
  		vertically; if you set the cursor position with this, |j| and
Karsten Hopp 242d8e
--- 5369,5375 ----
Karsten Hopp 242d8e
  		Returns 0 when the position could be set, -1 otherwise.
Karsten Hopp 242d8e
  		An error message is given if {expr} is invalid.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
! 		Also see |getpos()| and |getcurpos()|.
Karsten Hopp 242d8e
  
Karsten Hopp 242d8e
  		This does not restore the preferred column for moving
Karsten Hopp 242d8e
  		vertically; if you set the cursor position with this, |j| and
Karsten Hopp 242d8e
*** ../vim-7.4.312/src/version.c	2014-05-28 18:22:37.880225054 +0200
Karsten Hopp 242d8e
--- src/version.c	2014-05-28 20:15:52.164284530 +0200
Karsten Hopp 242d8e
***************
Karsten Hopp 242d8e
*** 736,737 ****
Karsten Hopp 242d8e
--- 736,739 ----
Karsten Hopp 242d8e
  {   /* Add new patch number below this line */
Karsten Hopp 242d8e
+ /**/
Karsten Hopp 242d8e
+     313,
Karsten Hopp 242d8e
  /**/
Karsten Hopp 242d8e
Karsten Hopp 242d8e
-- 
Karsten Hopp 242d8e
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 242d8e
225. You sign up for free subscriptions for all the computer magazines
Karsten Hopp 242d8e
Karsten Hopp 242d8e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 242d8e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 242d8e
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 242d8e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///