changeset 1983:f54dab7cebab v7.2.280

updated for version 7.2-280
author vimboss
date Tue, 03 Nov 2009 16:20:34 +0000
parents b1b09b68d706
children b57babddb32b
files src/screen.c src/version.c
diffstat 2 files changed, 39 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/screen.c
+++ b/src/screen.c
@@ -132,7 +132,7 @@ static void screen_line __ARGS((int row,
 static void draw_vsep_win __ARGS((win_T *wp, int row));
 #endif
 #ifdef FEAT_STL_OPT
-static void redraw_custum_statusline __ARGS((win_T *wp));
+static void redraw_custom_statusline __ARGS((win_T *wp));
 #endif
 #ifdef FEAT_SEARCH_EXTRA
 #define SEARCH_HL_PRIORITY 0
@@ -5772,7 +5772,7 @@ win_redr_status(wp)
     else if (*p_stl != NUL || *wp->w_p_stl != NUL)
     {
 	/* redraw custom status line */
-	redraw_custum_statusline(wp);
+	redraw_custom_statusline(wp);
     }
 #endif
     else
@@ -5897,18 +5897,31 @@ win_redr_status(wp)
  * errors encountered.
  */
     static void
-redraw_custum_statusline(wp)
+redraw_custom_statusline(wp)
     win_T	    *wp;
 {
-    int	save_called_emsg = called_emsg;
+    static int	    entered = FALSE;
+    int		    save_called_emsg = called_emsg;
+
+    /* When called recursively return.  This can happen when the statusline
+     * contains an expression that triggers a redraw. */
+    if (entered)
+	return;
+    entered = TRUE;
 
     called_emsg = FALSE;
     win_redr_custom(wp, FALSE);
     if (called_emsg)
+    {
+	/* When there is an error disable the statusline, otherwise the
+	 * display is messed up with errors and a redraw triggers the problem
+	 * again and again. */
 	set_string_option_direct((char_u *)"statusline", -1,
 		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
 					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
+    }
     called_emsg |= save_called_emsg;
+    entered = FALSE;
 }
 #endif
 
@@ -6016,6 +6029,7 @@ win_redr_custom(wp, draw_ruler)
     int		len;
     int		fillchar;
     char_u	buf[MAXPATHL];
+    char_u	*stl;
     char_u	*p;
     struct	stl_hlrec hltab[STL_MAX_ITEM];
     struct	stl_hlrec tabtab[STL_MAX_ITEM];
@@ -6025,7 +6039,7 @@ win_redr_custom(wp, draw_ruler)
     if (wp == NULL)
     {
 	/* Use 'tabline'.  Always at the first line of the screen. */
-	p = p_tal;
+	stl = p_tal;
 	row = 0;
 	fillchar = ' ';
 	attr = hl_attr(HLF_TPF);
@@ -6042,17 +6056,17 @@ win_redr_custom(wp, draw_ruler)
 
 	if (draw_ruler)
 	{
-	    p = p_ruf;
+	    stl = p_ruf;
 	    /* advance past any leading group spec - implicit in ru_col */
-	    if (*p == '%')
-	    {
-		if (*++p == '-')
-		    p++;
-		if (atoi((char *) p))
-		    while (VIM_ISDIGIT(*p))
-			p++;
-		if (*p++ != '(')
-		    p = p_ruf;
+	    if (*stl == '%')
+	    {
+		if (*++stl == '-')
+		    stl++;
+		if (atoi((char *)stl))
+		    while (VIM_ISDIGIT(*stl))
+			stl++;
+		if (*stl++ != '(')
+		    stl = p_ruf;
 	    }
 #ifdef FEAT_VERTSPLIT
 	    col = ru_col - (Columns - W_WIDTH(wp));
@@ -6081,9 +6095,9 @@ win_redr_custom(wp, draw_ruler)
 	else
 	{
 	    if (*wp->w_p_stl != NUL)
-		p = wp->w_p_stl;
+		stl = wp->w_p_stl;
 	    else
-		p = p_stl;
+		stl = p_stl;
 # ifdef FEAT_EVAL
 	    use_sandbox = was_set_insecurely((char_u *)"statusline",
 					 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
@@ -6098,10 +6112,14 @@ win_redr_custom(wp, draw_ruler)
     if (maxwidth <= 0)
 	return;
 
+    /* Make a copy, because the statusline may include a function call that
+     * might change the option value and free the memory. */
+    stl = vim_strsave(stl);
     width = build_stl_str_hl(wp == NULL ? curwin : wp,
 				buf, sizeof(buf),
-				p, use_sandbox,
+				stl, use_sandbox,
 				fillchar, maxwidth, hltab, tabtab);
+    vim_free(stl);
     len = (int)STRLEN(buf);
 
     while (width < maxwidth && len < (int)sizeof(buf) - 1)
@@ -9465,7 +9483,7 @@ showruler(always)
 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
     if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
     {
-	redraw_custum_statusline(curwin);
+	redraw_custom_statusline(curwin);
     }
     else
 #endif
--- a/src/version.c
+++ b/src/version.c
@@ -677,6 +677,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    280,
+/**/
     279,
 /**/
     278,