Karsten Hopp abe28f
To: vim_dev@googlegroups.com
Karsten Hopp abe28f
Subject: Patch 7.3.614
Karsten Hopp abe28f
Fcc: outbox
Karsten Hopp abe28f
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp abe28f
Mime-Version: 1.0
Karsten Hopp abe28f
Content-Type: text/plain; charset=UTF-8
Karsten Hopp abe28f
Content-Transfer-Encoding: 8bit
Karsten Hopp abe28f
------------
Karsten Hopp abe28f
Karsten Hopp abe28f
Patch 7.3.614
Karsten Hopp abe28f
Problem:    Number argument gets turned into a number while it should be a
Karsten Hopp abe28f
	    string.
Karsten Hopp abe28f
Solution:   Add flag to the call_vim_function() call. (Yasuhiro Matsumoto)
Karsten Hopp abe28f
Files:	    src/edit.c, src/eval.c, src/proto/eval.pro
Karsten Hopp abe28f
Karsten Hopp abe28f
Karsten Hopp abe28f
*** ../vim-7.3.613/src/edit.c	2012-07-10 17:14:50.000000000 +0200
Karsten Hopp abe28f
--- src/edit.c	2012-07-25 16:40:07.000000000 +0200
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 3959,3965 ****
Karsten Hopp abe28f
      curbuf_save = curbuf;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      /* Call a function, which returns a list or dict. */
Karsten Hopp abe28f
!     if (call_vim_function(funcname, 2, args, FALSE, &rettv) == OK)
Karsten Hopp abe28f
      {
Karsten Hopp abe28f
  	switch (rettv.v_type)
Karsten Hopp abe28f
  	{
Karsten Hopp abe28f
--- 3959,3965 ----
Karsten Hopp abe28f
      curbuf_save = curbuf;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      /* Call a function, which returns a list or dict. */
Karsten Hopp abe28f
!     if (call_vim_function(funcname, 2, args, FALSE, FALSE, &rettv) == OK)
Karsten Hopp abe28f
      {
Karsten Hopp abe28f
  	switch (rettv.v_type)
Karsten Hopp abe28f
  	{
Karsten Hopp abe28f
*** ../vim-7.3.613/src/eval.c	2012-07-19 18:05:40.000000000 +0200
Karsten Hopp abe28f
--- src/eval.c	2012-07-25 16:42:41.000000000 +0200
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 1564,1574 ****
Karsten Hopp abe28f
   * Returns OK or FAIL.
Karsten Hopp abe28f
   */
Karsten Hopp abe28f
      int
Karsten Hopp abe28f
! call_vim_function(func, argc, argv, safe, rettv)
Karsten Hopp abe28f
      char_u      *func;
Karsten Hopp abe28f
      int		argc;
Karsten Hopp abe28f
      char_u      **argv;
Karsten Hopp abe28f
      int		safe;		/* use the sandbox */
Karsten Hopp abe28f
      typval_T	*rettv;
Karsten Hopp abe28f
  {
Karsten Hopp abe28f
      typval_T	*argvars;
Karsten Hopp abe28f
--- 1564,1575 ----
Karsten Hopp abe28f
   * Returns OK or FAIL.
Karsten Hopp abe28f
   */
Karsten Hopp abe28f
      int
Karsten Hopp abe28f
! call_vim_function(func, argc, argv, safe, str_arg_only, rettv)
Karsten Hopp abe28f
      char_u      *func;
Karsten Hopp abe28f
      int		argc;
Karsten Hopp abe28f
      char_u      **argv;
Karsten Hopp abe28f
      int		safe;		/* use the sandbox */
Karsten Hopp abe28f
+     int		str_arg_only;	/* all arguments are strings */
Karsten Hopp abe28f
      typval_T	*rettv;
Karsten Hopp abe28f
  {
Karsten Hopp abe28f
      typval_T	*argvars;
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 1593,1600 ****
Karsten Hopp abe28f
  	    continue;
Karsten Hopp abe28f
  	}
Karsten Hopp abe28f
  
Karsten Hopp abe28f
! 	/* Recognize a number argument, the others must be strings. */
Karsten Hopp abe28f
! 	vim_str2nr(argv[i], NULL, &len, TRUE, TRUE, &n, NULL);
Karsten Hopp abe28f
  	if (len != 0 && len == (int)STRLEN(argv[i]))
Karsten Hopp abe28f
  	{
Karsten Hopp abe28f
  	    argvars[i].v_type = VAR_NUMBER;
Karsten Hopp abe28f
--- 1594,1604 ----
Karsten Hopp abe28f
  	    continue;
Karsten Hopp abe28f
  	}
Karsten Hopp abe28f
  
Karsten Hopp abe28f
! 	if (str_arg_only)
Karsten Hopp abe28f
! 	    len = 0;
Karsten Hopp abe28f
! 	else
Karsten Hopp abe28f
! 	    /* Recognize a number argument, the others must be strings. */
Karsten Hopp abe28f
! 	    vim_str2nr(argv[i], NULL, &len, TRUE, TRUE, &n, NULL);
Karsten Hopp abe28f
  	if (len != 0 && len == (int)STRLEN(argv[i]))
Karsten Hopp abe28f
  	{
Karsten Hopp abe28f
  	    argvars[i].v_type = VAR_NUMBER;
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 1646,1652 ****
Karsten Hopp abe28f
      typval_T	rettv;
Karsten Hopp abe28f
      char_u	*retval;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
!     if (call_vim_function(func, argc, argv, safe, &rettv) == FAIL)
Karsten Hopp abe28f
  	return NULL;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      retval = vim_strsave(get_tv_string(&rettv));
Karsten Hopp abe28f
--- 1650,1657 ----
Karsten Hopp abe28f
      typval_T	rettv;
Karsten Hopp abe28f
      char_u	*retval;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
!     /* All arguments are passed as strings, no conversion to number. */
Karsten Hopp abe28f
!     if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
Karsten Hopp abe28f
  	return NULL;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      retval = vim_strsave(get_tv_string(&rettv));
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 1671,1677 ****
Karsten Hopp abe28f
      typval_T	rettv;
Karsten Hopp abe28f
      long	retval;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
!     if (call_vim_function(func, argc, argv, safe, &rettv) == FAIL)
Karsten Hopp abe28f
  	return -1;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      retval = get_tv_number_chk(&rettv, NULL);
Karsten Hopp abe28f
--- 1676,1683 ----
Karsten Hopp abe28f
      typval_T	rettv;
Karsten Hopp abe28f
      long	retval;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
!     /* All arguments are passed as strings, no conversion to number. */
Karsten Hopp abe28f
!     if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
Karsten Hopp abe28f
  	return -1;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      retval = get_tv_number_chk(&rettv, NULL);
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 1694,1700 ****
Karsten Hopp abe28f
  {
Karsten Hopp abe28f
      typval_T	rettv;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
!     if (call_vim_function(func, argc, argv, safe, &rettv) == FAIL)
Karsten Hopp abe28f
  	return NULL;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      if (rettv.v_type != VAR_LIST)
Karsten Hopp abe28f
--- 1700,1707 ----
Karsten Hopp abe28f
  {
Karsten Hopp abe28f
      typval_T	rettv;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
!     /* All arguments are passed as strings, no conversion to number. */
Karsten Hopp abe28f
!     if (call_vim_function(func, argc, argv, safe, TRUE, &rettv) == FAIL)
Karsten Hopp abe28f
  	return NULL;
Karsten Hopp abe28f
  
Karsten Hopp abe28f
      if (rettv.v_type != VAR_LIST)
Karsten Hopp abe28f
*** ../vim-7.3.613/src/proto/eval.pro	2012-07-16 17:31:48.000000000 +0200
Karsten Hopp abe28f
--- src/proto/eval.pro	2012-07-25 16:42:59.000000000 +0200
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 23,29 ****
Karsten Hopp abe28f
  list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
Karsten Hopp abe28f
  int get_spellword __ARGS((list_T *list, char_u **pp));
Karsten Hopp abe28f
  typval_T *eval_expr __ARGS((char_u *arg, char_u **nextcmd));
Karsten Hopp abe28f
! int call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe, typval_T *rettv));
Karsten Hopp abe28f
  void *call_func_retstr __ARGS((char_u *func, int argc, char_u **argv, int safe));
Karsten Hopp abe28f
  long call_func_retnr __ARGS((char_u *func, int argc, char_u **argv, int safe));
Karsten Hopp abe28f
  void *call_func_retlist __ARGS((char_u *func, int argc, char_u **argv, int safe));
Karsten Hopp abe28f
--- 23,29 ----
Karsten Hopp abe28f
  list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
Karsten Hopp abe28f
  int get_spellword __ARGS((list_T *list, char_u **pp));
Karsten Hopp abe28f
  typval_T *eval_expr __ARGS((char_u *arg, char_u **nextcmd));
Karsten Hopp abe28f
! int call_vim_function __ARGS((char_u *func, int argc, char_u **argv, int safe, int str_arg_only, typval_T *rettv));
Karsten Hopp abe28f
  void *call_func_retstr __ARGS((char_u *func, int argc, char_u **argv, int safe));
Karsten Hopp abe28f
  long call_func_retnr __ARGS((char_u *func, int argc, char_u **argv, int safe));
Karsten Hopp abe28f
  void *call_func_retlist __ARGS((char_u *func, int argc, char_u **argv, int safe));
Karsten Hopp abe28f
*** ../vim-7.3.613/src/version.c	2012-07-25 16:32:03.000000000 +0200
Karsten Hopp abe28f
--- src/version.c	2012-07-25 16:46:11.000000000 +0200
Karsten Hopp abe28f
***************
Karsten Hopp abe28f
*** 716,717 ****
Karsten Hopp abe28f
--- 716,719 ----
Karsten Hopp abe28f
  {   /* Add new patch number below this line */
Karsten Hopp abe28f
+ /**/
Karsten Hopp abe28f
+     614,
Karsten Hopp abe28f
  /**/
Karsten Hopp abe28f
Karsten Hopp abe28f
-- 
Karsten Hopp abe28f
hundred-and-one symptoms of being an internet addict:
Karsten Hopp abe28f
171. You invent another person and chat with yourself in empty chat rooms.
Karsten Hopp abe28f
Karsten Hopp abe28f
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp abe28f
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp abe28f
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp abe28f
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///