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