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