0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 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)
This commit is contained in:
Bram Moolenaar 2011-09-14 15:39:29 +02:00
parent ba4897e6e5
commit b5b5b895f7
2 changed files with 24 additions and 63 deletions

View File

@ -39,7 +39,6 @@ static int do_more_prompt __ARGS((int typed_char));
static void msg_screen_putchar __ARGS((int c, int attr)); static void msg_screen_putchar __ARGS((int c, int attr));
static int msg_check_screen __ARGS((void)); static int msg_check_screen __ARGS((void));
static void redir_write __ARGS((char_u *s, int maxlen)); static void redir_write __ARGS((char_u *s, int maxlen));
static void verbose_write __ARGS((char_u *s, int maxlen));
#ifdef FEAT_CON_DIALOG #ifdef FEAT_CON_DIALOG
static char_u *msg_show_console_dialog __ARGS((char_u *message, char_u *buttons, int dfltbutton)); 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 */ static int confirm_msg_used = FALSE; /* displaying confirm_msg */
@ -58,6 +57,9 @@ static struct msg_hist *first_msg_hist = NULL;
static struct msg_hist *last_msg_hist = NULL; static struct msg_hist *last_msg_hist = NULL;
static int msg_hist_len = 0; 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. * When writing messages to the screen, there are many different situations.
* A number of variables is used to remember the current state: * A number of variables is used to remember the current state:
@ -3065,12 +3067,9 @@ redir_write(str, maxlen)
if (redir_off) if (redir_off)
return; return;
/* /* If 'verbosefile' is set prepare for writing in that file. */
* If 'verbosefile' is set write message in that file. if (*p_vfile != NUL && verbose_fd == NULL)
* Must come before the rest because of updating "msg_col". verbose_open();
*/
if (*p_vfile != NUL)
verbose_write(s, maxlen);
if (redirecting()) if (redirecting())
{ {
@ -3084,9 +3083,12 @@ redir_write(str, maxlen)
write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE); write_reg_contents(redir_reg, (char_u *)" ", -1, TRUE);
else if (redir_vname) else if (redir_vname)
var_redir_str((char_u *)" ", -1); var_redir_str((char_u *)" ", -1);
else if (redir_fd) else
#endif #endif
if (redir_fd != NULL)
fputs(" ", redir_fd); fputs(" ", redir_fd);
if (verbose_fd != NULL)
fputs(" ", verbose_fd);
++cur_col; ++cur_col;
} }
} }
@ -3098,13 +3100,16 @@ redir_write(str, maxlen)
var_redir_str(s, maxlen); var_redir_str(s, maxlen);
#endif #endif
/* Adjust the current column */ /* Write and adjust the current column. */
while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen)) while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
{ {
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
if (!redir_reg && !redir_vname && redir_fd != NULL) if (!redir_reg && !redir_vname)
#endif #endif
if (redir_fd != NULL)
putc(*s, redir_fd); putc(*s, redir_fd);
if (verbose_fd != NULL)
putc(*s, verbose_fd);
if (*s == '\r' || *s == '\n') if (*s == '\r' || *s == '\n')
cur_col = 0; cur_col = 0;
else if (*s == '\t') else if (*s == '\t')
@ -3122,7 +3127,7 @@ redir_write(str, maxlen)
int int
redirecting() redirecting()
{ {
return redir_fd != NULL return redir_fd != NULL || *p_vfile != NUL
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
|| redir_reg || redir_vname || redir_reg || redir_vname
#endif #endif
@ -3180,9 +3185,6 @@ verbose_leave_scroll()
cmdline_row = msg_row; 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. * Called when 'verbosefile' is set: stop writing to the file.
*/ */
@ -3219,49 +3221,6 @@ verbose_open()
return OK; return OK;
} }
/*
* 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). * Give a warning message (for searching).
* Use 'w' highlighting and may repeat the message after redrawing * Use 'w' highlighting and may repeat the message after redrawing

View File

@ -709,6 +709,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
308,
/**/ /**/
307, 307,
/**/ /**/