Blob Blame History Raw
To: vim-dev@vim.org
Subject: Patch 7.2.011
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.011
Problem:    Get an error when inserting a float value from the expression
	    register.
Solution:   Convert the Float to a String automatically in the same place
	    where a List would be converted to a String.
Files:	    src/eval.c


*** ../vim-7.2.010/src/eval.c	Mon Aug 25 04:48:21 2008
--- src/eval.c	Sun Sep  7 13:50:38 2008
***************
*** 1256,1278 ****
  
  /*
   * Top level evaluation function, returning a string.
   * Return pointer to allocated memory, or NULL for failure.
   */
      char_u *
! eval_to_string(arg, nextcmd, dolist)
      char_u	*arg;
      char_u	**nextcmd;
!     int		dolist;		/* turn List into sequence of lines */
  {
      typval_T	tv;
      char_u	*retval;
      garray_T	ga;
  
      if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
  	retval = NULL;
      else
      {
! 	if (dolist && tv.v_type == VAR_LIST)
  	{
  	    ga_init2(&ga, (int)sizeof(char), 80);
  	    if (tv.vval.v_list != NULL)
--- 1256,1281 ----
  
  /*
   * Top level evaluation function, returning a string.
+  * When "convert" is TRUE convert a List into a sequence of lines and convert
+  * a Float to a String.
   * Return pointer to allocated memory, or NULL for failure.
   */
      char_u *
! eval_to_string(arg, nextcmd, convert)
      char_u	*arg;
      char_u	**nextcmd;
!     int		convert;
  {
      typval_T	tv;
      char_u	*retval;
      garray_T	ga;
+     char_u	numbuf[NUMBUFLEN];
  
      if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
  	retval = NULL;
      else
      {
! 	if (convert && tv.v_type == VAR_LIST)
  	{
  	    ga_init2(&ga, (int)sizeof(char), 80);
  	    if (tv.vval.v_list != NULL)
***************
*** 1280,1285 ****
--- 1283,1295 ----
  	    ga_append(&ga, NUL);
  	    retval = (char_u *)ga.ga_data;
  	}
+ #ifdef FEAT_FLOAT
+ 	else if (convert && tv.v_type == VAR_FLOAT)
+ 	{
+ 	    vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float);
+ 	    retval = vim_strsave(numbuf);
+ 	}
+ #endif
  	else
  	    retval = vim_strsave(get_tv_string(&tv));
  	clear_tv(&tv);
*** ../vim-7.2.010/src/version.c	Sat Sep  6 16:44:06 2008
--- src/version.c	Sun Sep  7 13:52:00 2008
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     11,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
34. You laugh at people with 14400 baud modems.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///