7bbe6f2
To: vim-dev@vim.org
7bbe6f2
Subject: Patch 7.2.011
7bbe6f2
Fcc: outbox
7bbe6f2
From: Bram Moolenaar <Bram@moolenaar.net>
7bbe6f2
Mime-Version: 1.0
7bbe6f2
Content-Type: text/plain; charset=ISO-8859-1
7bbe6f2
Content-Transfer-Encoding: 8bit
7bbe6f2
------------
7bbe6f2
7bbe6f2
Patch 7.2.011
7bbe6f2
Problem:    Get an error when inserting a float value from the expression
7bbe6f2
	    register.
7bbe6f2
Solution:   Convert the Float to a String automatically in the same place
7bbe6f2
	    where a List would be converted to a String.
7bbe6f2
Files:	    src/eval.c
7bbe6f2
7bbe6f2
7bbe6f2
*** ../vim-7.2.010/src/eval.c	Mon Aug 25 04:48:21 2008
7bbe6f2
--- src/eval.c	Sun Sep  7 13:50:38 2008
7bbe6f2
***************
7bbe6f2
*** 1256,1278 ****
7bbe6f2
  
7bbe6f2
  /*
7bbe6f2
   * Top level evaluation function, returning a string.
7bbe6f2
   * Return pointer to allocated memory, or NULL for failure.
7bbe6f2
   */
7bbe6f2
      char_u *
7bbe6f2
! eval_to_string(arg, nextcmd, dolist)
7bbe6f2
      char_u	*arg;
7bbe6f2
      char_u	**nextcmd;
7bbe6f2
!     int		dolist;		/* turn List into sequence of lines */
7bbe6f2
  {
7bbe6f2
      typval_T	tv;
7bbe6f2
      char_u	*retval;
7bbe6f2
      garray_T	ga;
7bbe6f2
  
7bbe6f2
      if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
7bbe6f2
  	retval = NULL;
7bbe6f2
      else
7bbe6f2
      {
7bbe6f2
! 	if (dolist && tv.v_type == VAR_LIST)
7bbe6f2
  	{
7bbe6f2
  	    ga_init2(&ga, (int)sizeof(char), 80);
7bbe6f2
  	    if (tv.vval.v_list != NULL)
7bbe6f2
--- 1256,1281 ----
7bbe6f2
  
7bbe6f2
  /*
7bbe6f2
   * Top level evaluation function, returning a string.
7bbe6f2
+  * When "convert" is TRUE convert a List into a sequence of lines and convert
7bbe6f2
+  * a Float to a String.
7bbe6f2
   * Return pointer to allocated memory, or NULL for failure.
7bbe6f2
   */
7bbe6f2
      char_u *
7bbe6f2
! eval_to_string(arg, nextcmd, convert)
7bbe6f2
      char_u	*arg;
7bbe6f2
      char_u	**nextcmd;
7bbe6f2
!     int		convert;
7bbe6f2
  {
7bbe6f2
      typval_T	tv;
7bbe6f2
      char_u	*retval;
7bbe6f2
      garray_T	ga;
7bbe6f2
+     char_u	numbuf[NUMBUFLEN];
7bbe6f2
  
7bbe6f2
      if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
7bbe6f2
  	retval = NULL;
7bbe6f2
      else
7bbe6f2
      {
7bbe6f2
! 	if (convert && tv.v_type == VAR_LIST)
7bbe6f2
  	{
7bbe6f2
  	    ga_init2(&ga, (int)sizeof(char), 80);
7bbe6f2
  	    if (tv.vval.v_list != NULL)
7bbe6f2
***************
7bbe6f2
*** 1280,1285 ****
7bbe6f2
--- 1283,1295 ----
7bbe6f2
  	    ga_append(&ga, NUL);
7bbe6f2
  	    retval = (char_u *)ga.ga_data;
7bbe6f2
  	}
7bbe6f2
+ #ifdef FEAT_FLOAT
7bbe6f2
+ 	else if (convert && tv.v_type == VAR_FLOAT)
7bbe6f2
+ 	{
7bbe6f2
+ 	    vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float);
7bbe6f2
+ 	    retval = vim_strsave(numbuf);
7bbe6f2
+ 	}
7bbe6f2
+ #endif
7bbe6f2
  	else
7bbe6f2
  	    retval = vim_strsave(get_tv_string(&tv));
7bbe6f2
  	clear_tv(&tv;;
7bbe6f2
*** ../vim-7.2.010/src/version.c	Sat Sep  6 16:44:06 2008
7bbe6f2
--- src/version.c	Sun Sep  7 13:52:00 2008
7bbe6f2
***************
7bbe6f2
*** 678,679 ****
7bbe6f2
--- 678,681 ----
7bbe6f2
  {   /* Add new patch number below this line */
7bbe6f2
+ /**/
7bbe6f2
+     11,
7bbe6f2
  /**/
7bbe6f2
7bbe6f2
-- 
7bbe6f2
hundred-and-one symptoms of being an internet addict:
7bbe6f2
34. You laugh at people with 14400 baud modems.
7bbe6f2
7bbe6f2
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
7bbe6f2
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
7bbe6f2
\\\        download, build and distribute -- http://www.A-A-P.org        ///
7bbe6f2
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///