4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
10 Patch 6.3.055 (after 6.3.013)
11 Problem: Can't use getcmdline(), getcmdpos() or setcmdpos() with <C-R>=
12 when editing a command line. Using <C-\>e may crash Vim. (Peter
14 Solution: When moving ccline out of the way for recursive use, make it
15 available to the functions that need it. Also save and restore
16 ccline when calling get_expr_line(). Make ccline.cmdbuf NULL at
17 the end of getcmdline().
21 *** ../vim-6.3.054/src/ex_getln.c Fri Oct 22 11:45:17 2004
22 --- src/ex_getln.c Thu Jan 13 14:06:56 2005
26 static void alloc_cmdbuff __ARGS((int len));
27 static int realloc_cmdbuff __ARGS((int len));
28 static void draw_cmdline __ARGS((int start, int len));
29 + static void save_cmdline __ARGS((struct cmdline_info *ccp));
30 + static void restore_cmdline __ARGS((struct cmdline_info *ccp));
31 static int cmdline_paste __ARGS((int regname, int literally));
32 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
33 static void redrawcmd_preedit __ARGS((void));
39 ! struct cmdline_info save_ccline;
43 * Replace the command line with the result of an expression.
48 ! struct cmdline_info save_ccline;
52 * Replace the command line with the result of an expression.
55 new_cmdpos = 99999; /* keep it at the end */
57 new_cmdpos = ccline.cmdpos;
58 ! save_ccline = ccline;
59 ! ccline.cmdbuff = NULL;
60 ! ccline.cmdprompt = NULL;
61 c = get_expr_register();
62 ! ccline = save_ccline;
67 && realloc_cmdbuff((int)STRLEN(p) + 1) == OK)
70 new_cmdpos = 99999; /* keep it at the end */
72 new_cmdpos = ccline.cmdpos;
74 ! save_cmdline(&save_ccline);
75 c = get_expr_register();
76 ! restore_cmdline(&save_ccline);
79 + save_cmdline(&save_ccline);
81 + restore_cmdline(&save_ccline);
84 && realloc_cmdbuff((int)STRLEN(p) + 1) == OK)
91 ! save_ccline = ccline;
92 ! ccline.cmdbuff = NULL;
93 ! ccline.cmdprompt = NULL;
94 c = get_expr_register();
95 ! ccline = save_ccline;
103 ! save_cmdline(&save_ccline);
104 c = get_expr_register();
105 ! restore_cmdline(&save_ccline);
111 ui_cursor_shape(); /* may show different cursor shape */
114 ! return ccline.cmdbuff;
117 #if (defined(FEAT_CRYPT) || defined(FEAT_EVAL)) || defined(PROTO)
119 ui_cursor_shape(); /* may show different cursor shape */
123 ! char_u *p = ccline.cmdbuff;
125 ! /* Make ccline empty, getcmdline() may try to use it. */
126 ! ccline.cmdbuff = NULL;
131 #if (defined(FEAT_CRYPT) || defined(FEAT_EVAL)) || defined(PROTO)
134 struct cmdline_info save_ccline;
135 int msg_col_save = msg_col;
137 ! save_ccline = ccline;
138 ! ccline.cmdbuff = NULL;
139 ccline.cmdprompt = prompt;
140 ccline.cmdattr = attr;
141 s = getcmdline(firstc, 1L, 0);
142 ! ccline = save_ccline;
143 /* Restore msg_col, the prompt from input() may have changed it. */
144 msg_col = msg_col_save;
147 struct cmdline_info save_ccline;
148 int msg_col_save = msg_col;
150 ! save_cmdline(&save_ccline);
151 ccline.cmdprompt = prompt;
152 ccline.cmdattr = attr;
153 s = getcmdline(firstc, 1L, 0);
154 ! restore_cmdline(&save_ccline);
155 /* Restore msg_col, the prompt from input() may have changed it. */
156 msg_col = msg_col_save;
164 + static struct cmdline_info prev_ccline;
165 + static int prev_ccline_used = FALSE;
168 + * Save ccline, because obtaining the "=" register may execute "normal :cmd"
169 + * and overwrite it. But get_cmdline_str() may need it, thus make it
170 + * available globally in prev_ccline.
174 + struct cmdline_info *ccp;
176 + if (!prev_ccline_used)
178 + vim_memset(&prev_ccline, 0, sizeof(struct cmdline_info));
179 + prev_ccline_used = TRUE;
181 + *ccp = prev_ccline;
182 + prev_ccline = ccline;
183 + ccline.cmdbuff = NULL;
184 + ccline.cmdprompt = NULL;
188 + * Resture ccline after it has been saved with save_cmdline().
191 + restore_cmdline(ccp)
192 + struct cmdline_info *ccp;
194 + ccline = prev_ccline;
195 + prev_ccline = *ccp;
199 * paste a yank register into the command line.
200 * used by CTRL-R command in command-line mode
203 regname = may_get_selection(regname);
206 ! /* Need to save and restore ccline, because obtaining the "=" register may
207 ! * execute "normal :cmd" and overwrite it. */
208 ! save_ccline = ccline;
209 ! ccline.cmdbuff = NULL;
210 ! ccline.cmdprompt = NULL;
211 i = get_spec_reg(regname, &arg, &allocated, TRUE);
212 ! ccline = save_ccline;
217 regname = may_get_selection(regname);
220 ! /* Need to save and restore ccline. */
221 ! save_cmdline(&save_ccline);
222 i = get_spec_reg(regname, &arg, &allocated, TRUE);
223 ! restore_cmdline(&save_ccline);
230 return history[histype][hisidx[histype]].hisnum;
233 + static struct cmdline_info *get_ccline_ptr __ARGS((void));
236 + * Get pointer to the command line info to use. cmdline_paste() may clear
237 + * ccline and put the previous value in prev_ccline.
239 + static struct cmdline_info *
242 + if ((State & CMDLINE) == 0)
244 + if (ccline.cmdbuff != NULL)
246 + if (prev_ccline_used && prev_ccline.cmdbuff != NULL)
247 + return &prev_ccline;
252 * Get the current command line in allocated memory.
253 * Only works when the command line is being edited.
259 ! if (ccline.cmdbuff == NULL || (State & CMDLINE) == 0)
261 ! return vim_strnsave(ccline.cmdbuff, ccline.cmdlen);
269 ! struct cmdline_info *p = get_ccline_ptr();
273 ! return vim_strnsave(p->cmdbuff, p->cmdlen);
282 ! if (ccline.cmdbuff == NULL || (State & CMDLINE) == 0)
284 ! return ccline.cmdpos;
292 ! struct cmdline_info *p = get_ccline_ptr();
305 ! if (ccline.cmdbuff == NULL || (State & CMDLINE) == 0)
308 /* The position is not set directly but after CTRL-\ e or CTRL-R = has
313 ! struct cmdline_info *p = get_ccline_ptr();
318 /* The position is not set directly but after CTRL-\ e or CTRL-R = has
319 *** ../vim-6.3.054/src/version.c Wed Jan 5 11:17:36 2005
320 --- src/version.c Thu Jan 13 14:08:12 2005
324 { /* Add new patch number below this line */
330 ARTHUR: Well, I AM king...
331 DENNIS: Oh king, eh, very nice. An' how'd you get that, eh? By exploitin'
332 the workers -- by 'angin' on to outdated imperialist dogma which
333 perpetuates the economic an' social differences in our society! If
334 there's ever going to be any progress--
335 The Quest for the Holy Grail (Monty Python)
337 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
338 /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
339 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
340 \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///