components/vim/vim72-patches/7.2.280
changeset 379 c6a17bba1da3
parent 378 f0b61ed1d10d
child 380 e92b3b4a1c66
equal deleted inserted replaced
378:f0b61ed1d10d 379:c6a17bba1da3
     1 To: [email protected]
       
     2 Subject: Patch 7.2.280
       
     3 Fcc: outbox
       
     4 From: Bram Moolenaar <[email protected]>
       
     5 Mime-Version: 1.0
       
     6 Content-Type: text/plain; charset=UTF-8
       
     7 Content-Transfer-Encoding: 8bit
       
     8 ------------
       
     9 
       
    10 Patch 7.2.280
       
    11 Problem:    A redraw in a custom statusline with %! may cause a crash.
       
    12             (Yukihiro Nakadaira)
       
    13 Solution:   Make a copy of 'statusline'.  Also fix typo in function name
       
    14             redraw_custum_statusline. (party by Dominique Pelle)
       
    15 Files:      src/screen.c
       
    16 
       
    17 
       
    18 *** ../vim-7.2.279/src/screen.c	2009-07-29 16:13:35.000000000 +0200
       
    19 --- src/screen.c	2009-11-03 17:13:16.000000000 +0100
       
    20 ***************
       
    21 *** 132,138 ****
       
    22   static void draw_vsep_win __ARGS((win_T *wp, int row));
       
    23   #endif
       
    24   #ifdef FEAT_STL_OPT
       
    25 ! static void redraw_custum_statusline __ARGS((win_T *wp));
       
    26   #endif
       
    27   #ifdef FEAT_SEARCH_EXTRA
       
    28   #define SEARCH_HL_PRIORITY 0
       
    29 --- 132,138 ----
       
    30   static void draw_vsep_win __ARGS((win_T *wp, int row));
       
    31   #endif
       
    32   #ifdef FEAT_STL_OPT
       
    33 ! static void redraw_custom_statusline __ARGS((win_T *wp));
       
    34   #endif
       
    35   #ifdef FEAT_SEARCH_EXTRA
       
    36   #define SEARCH_HL_PRIORITY 0
       
    37 ***************
       
    38 *** 5772,5778 ****
       
    39       else if (*p_stl != NUL || *wp->w_p_stl != NUL)
       
    40       {
       
    41   	/* redraw custom status line */
       
    42 ! 	redraw_custum_statusline(wp);
       
    43       }
       
    44   #endif
       
    45       else
       
    46 --- 5794,5800 ----
       
    47       else if (*p_stl != NUL || *wp->w_p_stl != NUL)
       
    48       {
       
    49   	/* redraw custom status line */
       
    50 ! 	redraw_custom_statusline(wp);
       
    51       }
       
    52   #endif
       
    53       else
       
    54 ***************
       
    55 *** 5897,5914 ****
       
    56    * errors encountered.
       
    57    */
       
    58       static void
       
    59 ! redraw_custum_statusline(wp)
       
    60       win_T	    *wp;
       
    61   {
       
    62 !     int	save_called_emsg = called_emsg;
       
    63   
       
    64       called_emsg = FALSE;
       
    65       win_redr_custom(wp, FALSE);
       
    66       if (called_emsg)
       
    67   	set_string_option_direct((char_u *)"statusline", -1,
       
    68   		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
       
    69   					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
       
    70       called_emsg |= save_called_emsg;
       
    71   }
       
    72   #endif
       
    73   
       
    74 --- 5919,5949 ----
       
    75    * errors encountered.
       
    76    */
       
    77       static void
       
    78 ! redraw_custom_statusline(wp)
       
    79       win_T	    *wp;
       
    80   {
       
    81 !     static int	    entered = FALSE;
       
    82 !     int		    save_called_emsg = called_emsg;
       
    83 ! 
       
    84 !     /* When called recursively return.  This can happen when the statusline
       
    85 !      * contains an expression that triggers a redraw. */
       
    86 !     if (entered)
       
    87 ! 	return;
       
    88 !     entered = TRUE;
       
    89   
       
    90       called_emsg = FALSE;
       
    91       win_redr_custom(wp, FALSE);
       
    92       if (called_emsg)
       
    93 +     {
       
    94 + 	/* When there is an error disable the statusline, otherwise the
       
    95 + 	 * display is messed up with errors and a redraw triggers the problem
       
    96 + 	 * again and again. */
       
    97   	set_string_option_direct((char_u *)"statusline", -1,
       
    98   		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
       
    99   					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
       
   100 +     }
       
   101       called_emsg |= save_called_emsg;
       
   102 +     entered = FALSE;
       
   103   }
       
   104   #endif
       
   105   
       
   106 ***************
       
   107 *** 6016,6021 ****
       
   108 --- 6051,6057 ----
       
   109       int		len;
       
   110       int		fillchar;
       
   111       char_u	buf[MAXPATHL];
       
   112 +     char_u	*stl;
       
   113       char_u	*p;
       
   114       struct	stl_hlrec hltab[STL_MAX_ITEM];
       
   115       struct	stl_hlrec tabtab[STL_MAX_ITEM];
       
   116 ***************
       
   117 *** 6025,6031 ****
       
   118       if (wp == NULL)
       
   119       {
       
   120   	/* Use 'tabline'.  Always at the first line of the screen. */
       
   121 ! 	p = p_tal;
       
   122   	row = 0;
       
   123   	fillchar = ' ';
       
   124   	attr = hl_attr(HLF_TPF);
       
   125 --- 6061,6067 ----
       
   126       if (wp == NULL)
       
   127       {
       
   128   	/* Use 'tabline'.  Always at the first line of the screen. */
       
   129 ! 	stl = p_tal;
       
   130   	row = 0;
       
   131   	fillchar = ' ';
       
   132   	attr = hl_attr(HLF_TPF);
       
   133 ***************
       
   134 *** 6042,6058 ****
       
   135   
       
   136   	if (draw_ruler)
       
   137   	{
       
   138 ! 	    p = p_ruf;
       
   139   	    /* advance past any leading group spec - implicit in ru_col */
       
   140 ! 	    if (*p == '%')
       
   141   	    {
       
   142 ! 		if (*++p == '-')
       
   143 ! 		    p++;
       
   144 ! 		if (atoi((char *) p))
       
   145 ! 		    while (VIM_ISDIGIT(*p))
       
   146 ! 			p++;
       
   147 ! 		if (*p++ != '(')
       
   148 ! 		    p = p_ruf;
       
   149   	    }
       
   150   #ifdef FEAT_VERTSPLIT
       
   151   	    col = ru_col - (Columns - W_WIDTH(wp));
       
   152 --- 6078,6094 ----
       
   153   
       
   154   	if (draw_ruler)
       
   155   	{
       
   156 ! 	    stl = p_ruf;
       
   157   	    /* advance past any leading group spec - implicit in ru_col */
       
   158 ! 	    if (*stl == '%')
       
   159   	    {
       
   160 ! 		if (*++stl == '-')
       
   161 ! 		    stl++;
       
   162 ! 		if (atoi((char *)stl))
       
   163 ! 		    while (VIM_ISDIGIT(*stl))
       
   164 ! 			stl++;
       
   165 ! 		if (*stl++ != '(')
       
   166 ! 		    stl = p_ruf;
       
   167   	    }
       
   168   #ifdef FEAT_VERTSPLIT
       
   169   	    col = ru_col - (Columns - W_WIDTH(wp));
       
   170 ***************
       
   171 *** 6081,6089 ****
       
   172   	else
       
   173   	{
       
   174   	    if (*wp->w_p_stl != NUL)
       
   175 ! 		p = wp->w_p_stl;
       
   176   	    else
       
   177 ! 		p = p_stl;
       
   178   # ifdef FEAT_EVAL
       
   179   	    use_sandbox = was_set_insecurely((char_u *)"statusline",
       
   180   					 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
       
   181 --- 6117,6125 ----
       
   182   	else
       
   183   	{
       
   184   	    if (*wp->w_p_stl != NUL)
       
   185 ! 		stl = wp->w_p_stl;
       
   186   	    else
       
   187 ! 		stl = p_stl;
       
   188   # ifdef FEAT_EVAL
       
   189   	    use_sandbox = was_set_insecurely((char_u *)"statusline",
       
   190   					 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
       
   191 ***************
       
   192 *** 6098,6107 ****
       
   193       if (maxwidth <= 0)
       
   194   	return;
       
   195   
       
   196       width = build_stl_str_hl(wp == NULL ? curwin : wp,
       
   197   				buf, sizeof(buf),
       
   198 ! 				p, use_sandbox,
       
   199   				fillchar, maxwidth, hltab, tabtab);
       
   200       len = (int)STRLEN(buf);
       
   201   
       
   202       while (width < maxwidth && len < (int)sizeof(buf) - 1)
       
   203 --- 6134,6147 ----
       
   204       if (maxwidth <= 0)
       
   205   	return;
       
   206   
       
   207 +     /* Make a copy, because the statusline may include a function call that
       
   208 +      * might change the option value and free the memory. */
       
   209 +     stl = vim_strsave(stl);
       
   210       width = build_stl_str_hl(wp == NULL ? curwin : wp,
       
   211   				buf, sizeof(buf),
       
   212 ! 				stl, use_sandbox,
       
   213   				fillchar, maxwidth, hltab, tabtab);
       
   214 +     vim_free(stl);
       
   215       len = (int)STRLEN(buf);
       
   216   
       
   217       while (width < maxwidth && len < (int)sizeof(buf) - 1)
       
   218 ***************
       
   219 *** 9465,9471 ****
       
   220   #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
       
   221       if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
       
   222       {
       
   223 ! 	redraw_custum_statusline(curwin);
       
   224       }
       
   225       else
       
   226   #endif
       
   227 --- 9505,9511 ----
       
   228   #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
       
   229       if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
       
   230       {
       
   231 ! 	redraw_custom_statusline(curwin);
       
   232       }
       
   233       else
       
   234   #endif
       
   235 *** ../vim-7.2.279/src/version.c	2009-11-03 16:44:04.000000000 +0100
       
   236 --- src/version.c	2009-11-03 17:15:35.000000000 +0100
       
   237 ***************
       
   238 *** 678,679 ****
       
   239 --- 678,681 ----
       
   240   {   /* Add new patch number below this line */
       
   241 + /**/
       
   242 +     280,
       
   243   /**/
       
   244 
       
   245 -- 
       
   246 Every exit is an entrance into something else.
       
   247 
       
   248  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
       
   249 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
       
   250 \\\        download, build and distribute -- http://www.A-A-P.org        ///
       
   251  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///