4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Crash when editing a command line and typing CTRL-R = to evaluate
12 a function that uses "normal :cmd". (Hari Krishna Dara)
13 Solution: Save and restore the command line when evaluating an expression
15 Files: src/ex_getln.c, src/ops.c, src/proto/ex_getln.pro,
19 *** ../vim-6.3.012/src/ex_getln.c Fri Jul 2 22:00:36 2004
20 --- src/ex_getln.c Fri Jul 9 21:44:08 2004
24 static void alloc_cmdbuff __ARGS((int len));
25 static int realloc_cmdbuff __ARGS((int len));
26 static void draw_cmdline __ARGS((int start, int len));
27 + static int cmdline_paste __ARGS((int regname, int literally));
28 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
29 static void redrawcmd_preedit __ARGS((void));
40 + * paste a yank register into the command line.
41 + * used by CTRL-R command in command-line mode
42 + * insert_reg() can't be used here, because special characters from the
43 + * register contents will be interpreted as commands.
45 + * return FAIL for failure, OK otherwise
48 + cmdline_paste(regname, literally)
50 + int literally; /* Insert text literally instead of "as typed" */
55 + struct cmdline_info save_ccline;
57 + /* check for valid regname; also accept special characters for CTRL-R in
58 + * the command line */
59 + if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W
60 + && regname != Ctrl_A && !valid_yank_reg(regname, FALSE))
63 + /* A register containing CTRL-R can cause an endless loop. Allow using
64 + * CTRL-C to break the loop. */
69 + #ifdef FEAT_CLIPBOARD
70 + regname = may_get_selection(regname);
73 + /* Need to save and restore ccline, because obtaining the "=" register may
74 + * execute "normal :cmd" and overwrite it. */
75 + save_ccline = ccline;
76 + ccline.cmdbuff = NULL;
77 + ccline.cmdprompt = NULL;
78 + i = get_spec_reg(regname, &arg, &allocated, TRUE);
79 + ccline = save_ccline;
83 + /* Got the value of a special register in "arg". */
86 + cmdline_paste_str(arg, literally);
92 + return cmdline_paste_reg(regname, literally);
96 + * Put a string on the command line.
97 + * When "literally" is TRUE, insert literally.
98 + * When "literally" is FALSE, insert as typed, but don't leave the command
102 + cmdline_paste_str(s, literally)
109 + put_on_cmdline(s, -1, TRUE);
114 + if (cv == Ctrl_V && s[1])
119 + c = mb_ptr2char(s);
120 + s += mb_char2len(c);
125 + if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL
129 + || (c == Ctrl_BSL && *s == Ctrl_N))
130 + stuffcharReadbuff(Ctrl_V);
131 + stuffcharReadbuff(c);
136 *** ../vim-6.3.012/src/ops.c Wed Jun 9 14:56:26 2004
137 --- src/ops.c Fri Jul 9 22:13:54 2004
140 static void shift_block __ARGS((oparg_T *oap, int amount));
141 static void block_insert __ARGS((oparg_T *oap, char_u *s, int b_insert, struct block_def*bdp));
143 - static void get_yank_register __ARGS((int regname, int writing));
144 static int stuff_yank __ARGS((int, char_u *));
145 static void put_reedit_in_typebuf __ARGS((void));
146 static int put_in_typebuf __ARGS((char_u *s, int colon));
147 static void stuffescaped __ARGS((char_u *arg, int literally));
148 - static int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg));
149 - static void cmdline_paste_str __ARGS((char_u *s, int literally));
151 static void mb_adjust_opend __ARGS((oparg_T *oap));
156 * If regname is 0 and writing, use register 0
157 * If regname is 0 and reading, use previous register
160 get_yank_register(regname, writing)
164 * If regname is 0 and writing, use register 0
165 * If regname is 0 and reading, use previous register
168 get_yank_register(regname, writing)
173 y_previous = y_current;
176 ! #ifdef FEAT_CLIPBOARD
178 * When "regname" is a clipboard register, obtain the selection. If it's not
179 * available return zero, otherwise return "regname".
181 ! static int may_get_selection __ARGS((int regname));
184 may_get_selection(regname)
188 y_previous = y_current;
191 ! #if defined(FEAT_CLIPBOARD) || defined(PROTO)
193 * When "regname" is a clipboard register, obtain the selection. If it's not
194 * available return zero, otherwise return "regname".
197 may_get_selection(regname)
203 * If "regname" is a special register, return a pointer to its value.
206 get_spec_reg(regname, argp, allocated, errmsg)
211 * If "regname" is a special register, return a pointer to its value.
214 get_spec_reg(regname, argp, allocated, errmsg)
222 ! * paste a yank register into the command line.
223 ! * used by CTRL-R command in command-line mode
224 * insert_reg() can't be used here, because special characters from the
225 * register contents will be interpreted as commands.
227 * return FAIL for failure, OK otherwise
230 ! cmdline_paste(regname, literally)
232 int literally; /* Insert text literally instead of "as typed" */
238 - /* check for valid regname; also accept special characters for CTRL-R in
239 - * the command line */
240 - if (regname != Ctrl_F && regname != Ctrl_P && regname != Ctrl_W
241 - && regname != Ctrl_A && !valid_yank_reg(regname, FALSE))
244 - /* A register containing CTRL-R can cause an endless loop. Allow using
245 - * CTRL-C to break the loop. */
250 - #ifdef FEAT_CLIPBOARD
251 - regname = may_get_selection(regname);
254 - if (get_spec_reg(regname, &arg, &allocated, TRUE))
258 - cmdline_paste_str(arg, literally);
264 get_yank_register(regname, FALSE);
265 if (y_current->y_array == NULL)
270 ! * Paste a yank register into the command line.
271 ! * Only for non-special registers.
272 ! * Used by CTRL-R command in command-line mode
273 * insert_reg() can't be used here, because special characters from the
274 * register contents will be interpreted as commands.
276 * return FAIL for failure, OK otherwise
279 ! cmdline_paste_reg(regname, literally)
281 int literally; /* Insert text literally instead of "as typed" */
285 get_yank_register(regname, FALSE);
286 if (y_current->y_array == NULL)
295 - * Put a string on the command line.
296 - * When "literally" is TRUE, insert literally.
297 - * When "literally" is FALSE, insert as typed, but don't leave the command
301 - cmdline_paste_str(s, literally)
308 - put_on_cmdline(s, -1, TRUE);
313 - if (cv == Ctrl_V && s[1])
318 - c = mb_ptr2char(s);
319 - s += mb_char2len(c);
324 - if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL
328 - || (c == Ctrl_BSL && *s == Ctrl_N))
329 - stuffcharReadbuff(Ctrl_V);
330 - stuffcharReadbuff(c);
334 #if defined(FEAT_CLIPBOARD) || defined(PROTO)
336 *** ../vim-6.3.012/src/proto/ex_getln.pro Wed Jun 9 14:56:24 2004
337 --- src/proto/ex_getln.pro Fri Jul 9 21:46:20 2004
341 void putcmdline __ARGS((int c, int shift));
342 void unputcmdline __ARGS((void));
343 int put_on_cmdline __ARGS((char_u *str, int len, int redraw));
344 + void cmdline_paste_str __ARGS((char_u *s, int literally));
345 void redrawcmdline __ARGS((void));
346 void redrawcmd __ARGS((void));
347 void compute_cmdrow __ARGS((void));
348 *** ../vim-6.3.012/src/proto/ops.pro Wed Jun 9 14:56:24 2004
349 --- src/proto/ops.pro Fri Jul 9 21:46:16 2004
352 void set_expr_line __ARGS((char_u *new_line));
353 char_u *get_expr_line __ARGS((void));
354 int valid_yank_reg __ARGS((int regname, int writing));
355 void *get_register __ARGS((int name, int copy));
356 void put_register __ARGS((int name, void *reg));
357 int yank_register_mline __ARGS((int regname));
358 int do_record __ARGS((int c));
359 int do_execreg __ARGS((int regname, int colon, int addcr));
360 int insert_reg __ARGS((int regname, int literally));
361 ! int cmdline_paste __ARGS((int regname, int literally));
362 void adjust_clip_reg __ARGS((int *rp));
363 int op_delete __ARGS((oparg_T *oap));
364 int op_replace __ARGS((oparg_T *oap, int c));
366 void set_expr_line __ARGS((char_u *new_line));
367 char_u *get_expr_line __ARGS((void));
368 int valid_yank_reg __ARGS((int regname, int writing));
369 + void get_yank_register __ARGS((int regname, int writing));
370 + int may_get_selection __ARGS((int regname));
371 void *get_register __ARGS((int name, int copy));
372 void put_register __ARGS((int name, void *reg));
373 int yank_register_mline __ARGS((int regname));
374 int do_record __ARGS((int c));
375 int do_execreg __ARGS((int regname, int colon, int addcr));
376 int insert_reg __ARGS((int regname, int literally));
377 ! int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg));
378 ! int cmdline_paste_reg __ARGS((int regname, int literally));
379 void adjust_clip_reg __ARGS((int *rp));
380 int op_delete __ARGS((oparg_T *oap));
381 int op_replace __ARGS((oparg_T *oap, int c));
382 *** ../vim-6.3.012/src/version.c Tue Jul 6 14:57:26 2004
383 --- src/version.c Fri Jul 9 22:19:57 2004
387 { /* Add new patch number below this line */
393 CART DRIVER: Bring out your dead!
394 There are legs stick out of windows and doors. Two MEN are fighting in the
395 mud - covered from head to foot in it. Another MAN is on his hands in
396 knees shovelling mud into his mouth. We just catch sight of a MAN falling
398 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
400 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
401 /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
402 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
403 \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///