Patch 7.3.308
Problem:    Writing to 'verbosefile' has problems, e.g. for :highlight.
Solution:   Do not use a separate verbose_write() function but write with the
            same code that does redirecting. (Yasuhiro Matsumoto)
Files:      src/message.c


*** ../vim-7.3.307/src/message.c        2011-08-17 20:33:18.000000000 +0200
--- src/message.c       2011-09-14 15:32:57.000000000 +0200
***************
*** 39,45 ****
  static void msg_screen_putchar __ARGS((int c, int attr));
  static int  msg_check_screen __ARGS((void));
  static void redir_write __ARGS((char_u *s, int maxlen));
- static void verbose_write __ARGS((char_u *s, int maxlen));
  #ifdef FEAT_CON_DIALOG
  static char_u *msg_show_console_dialog __ARGS((char_u *message, char_u 
*buttons, int dfltbutton));
  static int    confirm_msg_used = FALSE;       /* displaying confirm_msg */
--- 39,44 ----
***************
*** 58,63 ****
--- 57,65 ----
  static struct msg_hist *last_msg_hist = NULL;
  static int msg_hist_len = 0;
  
+ static FILE *verbose_fd = NULL;
+ static int  verbose_did_open = FALSE;
+ 
  /*
   * When writing messages to the screen, there are many different situations.
   * A number of variables is used to remember the current state:
***************
*** 1551,1557 ****
  #ifdef FEAT_MBYTE
      if (has_mbyte && !IS_SPECIAL(c))
      {
!         int len = (*mb_ptr2len)(str);
  
        /* For multi-byte characters check for an illegal byte. */
        if (has_mbyte && MB_BYTE2LEN(*str) > len)
--- 1553,1559 ----
  #ifdef FEAT_MBYTE
      if (has_mbyte && !IS_SPECIAL(c))
      {
!       int len = (*mb_ptr2len)(str);
  
        /* For multi-byte characters check for an illegal byte. */
        if (has_mbyte && MB_BYTE2LEN(*str) > len)
***************
*** 1560,1569 ****
            *sp = str + 1;
            return buf;
        }
!         /* Since 'special' is TRUE the multi-byte character 'c' will be
!          * processed by get_special_key_name() */
!         c = (*mb_ptr2char)(str);
!         *sp = str + len;
      }
      else
  #endif
--- 1562,1571 ----
            *sp = str + 1;
            return buf;
        }
!       /* Since 'special' is TRUE the multi-byte character 'c' will be
!        * processed by get_special_key_name() */
!       c = (*mb_ptr2char)(str);
!       *sp = str + len;
      }
      else
  #endif
***************
*** 3065,3076 ****
      if (redir_off)
        return;
  
!     /*
!      * If 'verbosefile' is set write message in that file.
!      * Must come before the rest because of updating "msg_col".
!      */
!     if (*p_vfile != NUL)
!       verbose_write(s, maxlen);
  
      if (redirecting())
      {
--- 3067,3075 ----
      if (redir_off)
        return;
  
!     /* If 'verbosefile' is set prepare for writing in that file. */
!     if (*p_vfile != NUL && verbose_fd == NULL)
!       verbose_open();
  
      if (redirecting())
      {
***************
*** 3084,3092 ****
                    write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
                else if (redir_vname)
                    var_redir_str((char_u *)" ", -1);
!               else if (redir_fd)
  #endif
                    fputs(" ", redir_fd);
                ++cur_col;
            }
        }
--- 3083,3094 ----
                    write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
                else if (redir_vname)
                    var_redir_str((char_u *)" ", -1);
!               else
  #endif
+                   if (redir_fd != NULL)
                    fputs(" ", redir_fd);
+               if (verbose_fd != NULL)
+                   fputs(" ", verbose_fd);
                ++cur_col;
            }
        }
***************
*** 3098,3110 ****
            var_redir_str(s, maxlen);
  #endif
  
!       /* Adjust the current column */
        while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
        {
  #ifdef FEAT_EVAL
!           if (!redir_reg && !redir_vname && redir_fd != NULL)
  #endif
!               putc(*s, redir_fd);
            if (*s == '\r' || *s == '\n')
                cur_col = 0;
            else if (*s == '\t')
--- 3100,3115 ----
            var_redir_str(s, maxlen);
  #endif
  
!       /* Write and adjust the current column. */
        while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
        {
  #ifdef FEAT_EVAL
!           if (!redir_reg && !redir_vname)
  #endif
!               if (redir_fd != NULL)
!                   putc(*s, redir_fd);
!           if (verbose_fd != NULL)
!               putc(*s, verbose_fd);
            if (*s == '\r' || *s == '\n')
                cur_col = 0;
            else if (*s == '\t')
***************
*** 3122,3128 ****
      int
  redirecting()
  {
!     return redir_fd != NULL
  #ifdef FEAT_EVAL
                          || redir_reg || redir_vname
  #endif
--- 3127,3133 ----
      int
  redirecting()
  {
!     return redir_fd != NULL || *p_vfile != NUL
  #ifdef FEAT_EVAL
                          || redir_reg || redir_vname
  #endif
***************
*** 3180,3188 ****
        cmdline_row = msg_row;
  }
  
- static FILE *verbose_fd = NULL;
- static int  verbose_did_open = FALSE;
- 
  /*
   * Called when 'verbosefile' is set: stop writing to the file.
   */
--- 3185,3190 ----
***************
*** 3220,3268 ****
  }
  
  /*
-  * Write a string to 'verbosefile'.
-  * When "maxlen" is -1 write the whole string, otherwise up to "maxlen" bytes.
-  */
-     static void
- verbose_write(str, maxlen)
-     char_u    *str;
-     int               maxlen;
- {
-     char_u    *s = str;
-     static int        cur_col = 0;
- 
-     /* Open the file when called the first time. */
-     if (verbose_fd == NULL)
-       verbose_open();
- 
-     if (verbose_fd != NULL)
-     {
-       /* If the string doesn't start with CR or NL, go to msg_col */
-       if (*s != '\n' && *s != '\r')
-       {
-           while (cur_col < msg_col)
-           {
-               fputs(" ", verbose_fd);
-               ++cur_col;
-           }
-       }
- 
-       /* Adjust the current column */
-       while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
-       {
-           putc(*s, verbose_fd);
-           if (*s == '\r' || *s == '\n')
-               cur_col = 0;
-           else if (*s == '\t')
-               cur_col += (8 - cur_col % 8);
-           else
-               ++cur_col;
-           ++s;
-       }
-     }
- }
- 
- /*
   * Give a warning message (for searching).
   * Use 'w' highlighting and may repeat the message after redrawing
   */
--- 3222,3227 ----
*** ../vim-7.3.307/src/version.c        2011-09-14 15:01:54.000000000 +0200
--- src/version.c       2011-09-14 15:38:31.000000000 +0200
***************
*** 711,712 ****
--- 711,714 ----
  {   /* Add new patch number below this line */
+ /**/
+     308,
  /**/

-- 
The average life of an organization chart is six months.  You can safely
ignore any order from your boss that would take six months to complete.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui