2bb8465
To: vim_dev@googlegroups.com
2bb8465
Subject: Patch 7.3.308
2bb8465
Fcc: outbox
2bb8465
From: Bram Moolenaar <Bram@moolenaar.net>
2bb8465
Mime-Version: 1.0
2bb8465
Content-Type: text/plain; charset=UTF-8
2bb8465
Content-Transfer-Encoding: 8bit
2bb8465
------------
2bb8465
2bb8465
Patch 7.3.308
2bb8465
Problem:    Writing to 'verbosefile' has problems, e.g. for :highlight.
2bb8465
Solution:   Do not use a separate verbose_write() function but write with the
2bb8465
	    same code that does redirecting. (Yasuhiro Matsumoto)
2bb8465
Files:	    src/message.c
2bb8465
2bb8465
2bb8465
*** ../vim-7.3.307/src/message.c	2011-08-17 20:33:18.000000000 +0200
2bb8465
--- src/message.c	2011-09-14 15:32:57.000000000 +0200
2bb8465
***************
2bb8465
*** 39,45 ****
2bb8465
  static void msg_screen_putchar __ARGS((int c, int attr));
2bb8465
  static int  msg_check_screen __ARGS((void));
2bb8465
  static void redir_write __ARGS((char_u *s, int maxlen));
2bb8465
- static void verbose_write __ARGS((char_u *s, int maxlen));
2bb8465
  #ifdef FEAT_CON_DIALOG
2bb8465
  static char_u *msg_show_console_dialog __ARGS((char_u *message, char_u *buttons, int dfltbutton));
2bb8465
  static int	confirm_msg_used = FALSE;	/* displaying confirm_msg */
2bb8465
--- 39,44 ----
2bb8465
***************
2bb8465
*** 58,63 ****
2bb8465
--- 57,65 ----
2bb8465
  static struct msg_hist *last_msg_hist = NULL;
2bb8465
  static int msg_hist_len = 0;
2bb8465
  
2bb8465
+ static FILE *verbose_fd = NULL;
2bb8465
+ static int  verbose_did_open = FALSE;
2bb8465
+ 
2bb8465
  /*
2bb8465
   * When writing messages to the screen, there are many different situations.
2bb8465
   * A number of variables is used to remember the current state:
2bb8465
***************
2bb8465
*** 1551,1557 ****
2bb8465
  #ifdef FEAT_MBYTE
2bb8465
      if (has_mbyte && !IS_SPECIAL(c))
2bb8465
      {
2bb8465
!         int len = (*mb_ptr2len)(str);
2bb8465
  
2bb8465
  	/* For multi-byte characters check for an illegal byte. */
2bb8465
  	if (has_mbyte && MB_BYTE2LEN(*str) > len)
2bb8465
--- 1553,1559 ----
2bb8465
  #ifdef FEAT_MBYTE
2bb8465
      if (has_mbyte && !IS_SPECIAL(c))
2bb8465
      {
2bb8465
! 	int len = (*mb_ptr2len)(str);
2bb8465
  
2bb8465
  	/* For multi-byte characters check for an illegal byte. */
2bb8465
  	if (has_mbyte && MB_BYTE2LEN(*str) > len)
2bb8465
***************
2bb8465
*** 1560,1569 ****
2bb8465
  	    *sp = str + 1;
2bb8465
  	    return buf;
2bb8465
  	}
2bb8465
!         /* Since 'special' is TRUE the multi-byte character 'c' will be
2bb8465
!          * processed by get_special_key_name() */
2bb8465
!         c = (*mb_ptr2char)(str);
2bb8465
!         *sp = str + len;
2bb8465
      }
2bb8465
      else
2bb8465
  #endif
2bb8465
--- 1562,1571 ----
2bb8465
  	    *sp = str + 1;
2bb8465
  	    return buf;
2bb8465
  	}
2bb8465
! 	/* Since 'special' is TRUE the multi-byte character 'c' will be
2bb8465
! 	 * processed by get_special_key_name() */
2bb8465
! 	c = (*mb_ptr2char)(str);
2bb8465
! 	*sp = str + len;
2bb8465
      }
2bb8465
      else
2bb8465
  #endif
2bb8465
***************
2bb8465
*** 3065,3076 ****
2bb8465
      if (redir_off)
2bb8465
  	return;
2bb8465
  
2bb8465
!     /*
2bb8465
!      * If 'verbosefile' is set write message in that file.
2bb8465
!      * Must come before the rest because of updating "msg_col".
2bb8465
!      */
2bb8465
!     if (*p_vfile != NUL)
2bb8465
! 	verbose_write(s, maxlen);
2bb8465
  
2bb8465
      if (redirecting())
2bb8465
      {
2bb8465
--- 3067,3075 ----
2bb8465
      if (redir_off)
2bb8465
  	return;
2bb8465
  
2bb8465
!     /* If 'verbosefile' is set prepare for writing in that file. */
2bb8465
!     if (*p_vfile != NUL && verbose_fd == NULL)
2bb8465
! 	verbose_open();
2bb8465
  
2bb8465
      if (redirecting())
2bb8465
      {
2bb8465
***************
2bb8465
*** 3084,3092 ****
2bb8465
  		    write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
2bb8465
  		else if (redir_vname)
2bb8465
  		    var_redir_str((char_u *)" ", -1);
2bb8465
! 		else if (redir_fd)
2bb8465
  #endif
2bb8465
  		    fputs(" ", redir_fd);
2bb8465
  		++cur_col;
2bb8465
  	    }
2bb8465
  	}
2bb8465
--- 3083,3094 ----
2bb8465
  		    write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
2bb8465
  		else if (redir_vname)
2bb8465
  		    var_redir_str((char_u *)" ", -1);
2bb8465
! 		else
2bb8465
  #endif
2bb8465
+ 		    if (redir_fd != NULL)
2bb8465
  		    fputs(" ", redir_fd);
2bb8465
+ 		if (verbose_fd != NULL)
2bb8465
+ 		    fputs(" ", verbose_fd);
2bb8465
  		++cur_col;
2bb8465
  	    }
2bb8465
  	}
2bb8465
***************
2bb8465
*** 3098,3110 ****
2bb8465
  	    var_redir_str(s, maxlen);
2bb8465
  #endif
2bb8465
  
2bb8465
! 	/* Adjust the current column */
2bb8465
  	while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
2bb8465
  	{
2bb8465
  #ifdef FEAT_EVAL
2bb8465
! 	    if (!redir_reg && !redir_vname && redir_fd != NULL)
2bb8465
  #endif
2bb8465
! 		putc(*s, redir_fd);
2bb8465
  	    if (*s == '\r' || *s == '\n')
2bb8465
  		cur_col = 0;
2bb8465
  	    else if (*s == '\t')
2bb8465
--- 3100,3115 ----
2bb8465
  	    var_redir_str(s, maxlen);
2bb8465
  #endif
2bb8465
  
2bb8465
! 	/* Write and adjust the current column. */
2bb8465
  	while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
2bb8465
  	{
2bb8465
  #ifdef FEAT_EVAL
2bb8465
! 	    if (!redir_reg && !redir_vname)
2bb8465
  #endif
2bb8465
! 		if (redir_fd != NULL)
2bb8465
! 		    putc(*s, redir_fd);
2bb8465
! 	    if (verbose_fd != NULL)
2bb8465
! 		putc(*s, verbose_fd);
2bb8465
  	    if (*s == '\r' || *s == '\n')
2bb8465
  		cur_col = 0;
2bb8465
  	    else if (*s == '\t')
2bb8465
***************
2bb8465
*** 3122,3128 ****
2bb8465
      int
2bb8465
  redirecting()
2bb8465
  {
2bb8465
!     return redir_fd != NULL
2bb8465
  #ifdef FEAT_EVAL
2bb8465
  			  || redir_reg || redir_vname
2bb8465
  #endif
2bb8465
--- 3127,3133 ----
2bb8465
      int
2bb8465
  redirecting()
2bb8465
  {
2bb8465
!     return redir_fd != NULL || *p_vfile != NUL
2bb8465
  #ifdef FEAT_EVAL
2bb8465
  			  || redir_reg || redir_vname
2bb8465
  #endif
2bb8465
***************
2bb8465
*** 3180,3188 ****
2bb8465
  	cmdline_row = msg_row;
2bb8465
  }
2bb8465
  
2bb8465
- static FILE *verbose_fd = NULL;
2bb8465
- static int  verbose_did_open = FALSE;
2bb8465
- 
2bb8465
  /*
2bb8465
   * Called when 'verbosefile' is set: stop writing to the file.
2bb8465
   */
2bb8465
--- 3185,3190 ----
2bb8465
***************
2bb8465
*** 3220,3268 ****
2bb8465
  }
2bb8465
  
2bb8465
  /*
2bb8465
-  * Write a string to 'verbosefile'.
2bb8465
-  * When "maxlen" is -1 write the whole string, otherwise up to "maxlen" bytes.
2bb8465
-  */
2bb8465
-     static void
2bb8465
- verbose_write(str, maxlen)
2bb8465
-     char_u	*str;
2bb8465
-     int		maxlen;
2bb8465
- {
2bb8465
-     char_u	*s = str;
2bb8465
-     static int	cur_col = 0;
2bb8465
- 
2bb8465
-     /* Open the file when called the first time. */
2bb8465
-     if (verbose_fd == NULL)
2bb8465
- 	verbose_open();
2bb8465
- 
2bb8465
-     if (verbose_fd != NULL)
2bb8465
-     {
2bb8465
- 	/* If the string doesn't start with CR or NL, go to msg_col */
2bb8465
- 	if (*s != '\n' && *s != '\r')
2bb8465
- 	{
2bb8465
- 	    while (cur_col < msg_col)
2bb8465
- 	    {
2bb8465
- 		fputs(" ", verbose_fd);
2bb8465
- 		++cur_col;
2bb8465
- 	    }
2bb8465
- 	}
2bb8465
- 
2bb8465
- 	/* Adjust the current column */
2bb8465
- 	while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
2bb8465
- 	{
2bb8465
- 	    putc(*s, verbose_fd);
2bb8465
- 	    if (*s == '\r' || *s == '\n')
2bb8465
- 		cur_col = 0;
2bb8465
- 	    else if (*s == '\t')
2bb8465
- 		cur_col += (8 - cur_col % 8);
2bb8465
- 	    else
2bb8465
- 		++cur_col;
2bb8465
- 	    ++s;
2bb8465
- 	}
2bb8465
-     }
2bb8465
- }
2bb8465
- 
2bb8465
- /*
2bb8465
   * Give a warning message (for searching).
2bb8465
   * Use 'w' highlighting and may repeat the message after redrawing
2bb8465
   */
2bb8465
--- 3222,3227 ----
2bb8465
*** ../vim-7.3.307/src/version.c	2011-09-14 15:01:54.000000000 +0200
2bb8465
--- src/version.c	2011-09-14 15:38:31.000000000 +0200
2bb8465
***************
2bb8465
*** 711,712 ****
2bb8465
--- 711,714 ----
2bb8465
  {   /* Add new patch number below this line */
2bb8465
+ /**/
2bb8465
+     308,
2bb8465
  /**/
2bb8465
2bb8465
-- 
2bb8465
The average life of an organization chart is six months.  You can safely
2bb8465
ignore any order from your boss that would take six months to complete.
2bb8465
				(Scott Adams - The Dilbert principle)
2bb8465
2bb8465
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
2bb8465
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
2bb8465
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
2bb8465
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///