4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: A redraw in a custom statusline with %! may cause a crash.
13 Solution: Make a copy of 'statusline'. Also fix typo in function name
14 redraw_custum_statusline. (party by Dominique Pelle)
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
22 static void draw_vsep_win __ARGS((win_T *wp, int row));
25 ! static void redraw_custum_statusline __ARGS((win_T *wp));
27 #ifdef FEAT_SEARCH_EXTRA
28 #define SEARCH_HL_PRIORITY 0
30 static void draw_vsep_win __ARGS((win_T *wp, int row));
33 ! static void redraw_custom_statusline __ARGS((win_T *wp));
35 #ifdef FEAT_SEARCH_EXTRA
36 #define SEARCH_HL_PRIORITY 0
39 else if (*p_stl != NUL || *wp->w_p_stl != NUL)
41 /* redraw custom status line */
42 ! redraw_custum_statusline(wp);
47 else if (*p_stl != NUL || *wp->w_p_stl != NUL)
49 /* redraw custom status line */
50 ! redraw_custom_statusline(wp);
59 ! redraw_custum_statusline(wp)
62 ! int save_called_emsg = called_emsg;
65 win_redr_custom(wp, FALSE);
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;
78 ! redraw_custom_statusline(wp)
81 ! static int entered = FALSE;
82 ! int save_called_emsg = called_emsg;
84 ! /* When called recursively return. This can happen when the statusline
85 ! * contains an expression that triggers a redraw. */
91 win_redr_custom(wp, FALSE);
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);
101 called_emsg |= save_called_emsg;
111 char_u buf[MAXPATHL];
114 struct stl_hlrec hltab[STL_MAX_ITEM];
115 struct stl_hlrec tabtab[STL_MAX_ITEM];
120 /* Use 'tabline'. Always at the first line of the screen. */
124 attr = hl_attr(HLF_TPF);
128 /* Use 'tabline'. Always at the first line of the screen. */
132 attr = hl_attr(HLF_TPF);
139 /* advance past any leading group spec - implicit in ru_col */
144 ! if (atoi((char *) p))
145 ! while (VIM_ISDIGIT(*p))
150 #ifdef FEAT_VERTSPLIT
151 col = ru_col - (Columns - W_WIDTH(wp));
157 /* advance past any leading group spec - implicit in ru_col */
162 ! if (atoi((char *)stl))
163 ! while (VIM_ISDIGIT(*stl))
168 #ifdef FEAT_VERTSPLIT
169 col = ru_col - (Columns - W_WIDTH(wp));
174 if (*wp->w_p_stl != NUL)
179 use_sandbox = was_set_insecurely((char_u *)"statusline",
180 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
184 if (*wp->w_p_stl != NUL)
189 use_sandbox = was_set_insecurely((char_u *)"statusline",
190 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
196 width = build_stl_str_hl(wp == NULL ? curwin : wp,
199 fillchar, maxwidth, hltab, tabtab);
200 len = (int)STRLEN(buf);
202 while (width < maxwidth && len < (int)sizeof(buf) - 1)
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,
213 fillchar, maxwidth, hltab, tabtab);
215 len = (int)STRLEN(buf);
217 while (width < maxwidth && len < (int)sizeof(buf) - 1)
220 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
221 if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
223 ! redraw_custum_statusline(curwin);
228 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
229 if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
231 ! redraw_custom_statusline(curwin);
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
240 { /* Add new patch number below this line */
246 Every exit is an entrance into something else.
248 /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///