]> git.pld-linux.org Git - packages/vim.git/blob - 6.3.013
- license change to GPL
[packages/vim.git] / 6.3.013
1 To: vim-dev@vim.org
2 Subject: Patch 6.3.013
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 6.3.013
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
14             for CTRL-R =.
15 Files:      src/ex_getln.c, src/ops.c, src/proto/ex_getln.pro,
16             src/proto/ops.pro
17
18
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
21 ***************
22 *** 80,85 ****
23 --- 80,86 ----
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));
30   #endif
31 ***************
32 *** 2534,2539 ****
33 --- 2535,2636 ----
34       if (redraw)
35         msg_check();
36       return retval;
37 + }
38
39 + /*
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.
44 +  *
45 +  * return FAIL for failure, OK otherwise
46 +  */
47 +     static int
48 + cmdline_paste(regname, literally)
49 +     int regname;
50 +     int literally;    /* Insert text literally instead of "as typed" */
51 + {
52 +     long              i;
53 +     char_u            *arg;
54 +     int                       allocated;
55 +     struct cmdline_info       save_ccline;
56
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))
61 +       return FAIL;
62
63 +     /* A register containing CTRL-R can cause an endless loop.  Allow using
64 +      * CTRL-C to break the loop. */
65 +     line_breakcheck();
66 +     if (got_int)
67 +       return FAIL;
68
69 + #ifdef FEAT_CLIPBOARD
70 +     regname = may_get_selection(regname);
71 + #endif
72
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;
80
81 +     if (i)
82 +     {
83 +       /* Got the value of a special register in "arg". */
84 +       if (arg == NULL)
85 +           return FAIL;
86 +       cmdline_paste_str(arg, literally);
87 +       if (allocated)
88 +           vim_free(arg);
89 +       return OK;
90 +     }
91
92 +     return cmdline_paste_reg(regname, literally);
93 + }
94
95 + /*
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
99 +  * line.
100 +  */
101 +     void
102 + cmdline_paste_str(s, literally)
103 +     char_u    *s;
104 +     int               literally;
105 + {
106 +     int               c, cv;
107
108 +     if (literally)
109 +       put_on_cmdline(s, -1, TRUE);
110 +     else
111 +       while (*s != NUL)
112 +       {
113 +           cv = *s;
114 +           if (cv == Ctrl_V && s[1])
115 +               ++s;
116 + #ifdef FEAT_MBYTE
117 +           if (has_mbyte)
118 +           {
119 +               c = mb_ptr2char(s);
120 +               s += mb_char2len(c);
121 +           }
122 +           else
123 + #endif
124 +               c = *s++;
125 +           if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL
126 + #ifdef UNIX
127 +                   || c == intr_char
128 + #endif
129 +                   || (c == Ctrl_BSL && *s == Ctrl_N))
130 +               stuffcharReadbuff(Ctrl_V);
131 +           stuffcharReadbuff(c);
132 +       }
133   }
134   
135   #ifdef FEAT_WILDMENU
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
138 ***************
139 *** 94,106 ****
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));
142   #endif
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));
150   #ifdef FEAT_MBYTE
151   static void   mb_adjust_opend __ARGS((oparg_T *oap));
152   #endif
153 --- 94,103 ----
154 ***************
155 *** 820,826 ****
156    * If regname is 0 and writing, use register 0
157    * If regname is 0 and reading, use previous register
158    */
159 !     static void
160   get_yank_register(regname, writing)
161       int           regname;
162       int           writing;
163 --- 817,823 ----
164    * If regname is 0 and writing, use register 0
165    * If regname is 0 and reading, use previous register
166    */
167 !     void
168   get_yank_register(regname, writing)
169       int           regname;
170       int           writing;
171 ***************
172 *** 864,877 ****
173         y_previous = y_current;
174   }
175   
176 ! #ifdef FEAT_CLIPBOARD
177   /*
178    * When "regname" is a clipboard register, obtain the selection.  If it's not
179    * available return zero, otherwise return "regname".
180    */
181 ! static int may_get_selection __ARGS((int regname));
182
183 !     static int
184   may_get_selection(regname)
185       int regname;
186   {
187 --- 861,872 ----
188         y_previous = y_current;
189   }
190   
191 ! #if defined(FEAT_CLIPBOARD) || defined(PROTO)
192   /*
193    * When "regname" is a clipboard register, obtain the selection.  If it's not
194    * available return zero, otherwise return "regname".
195    */
196 !     int
197   may_get_selection(regname)
198       int regname;
199   {
200 ***************
201 *** 1347,1353 ****
202   /*
203    * If "regname" is a special register, return a pointer to its value.
204    */
205 !     static int
206   get_spec_reg(regname, argp, allocated, errmsg)
207       int               regname;
208       char_u    **argp;
209 --- 1342,1348 ----
210   /*
211    * If "regname" is a special register, return a pointer to its value.
212    */
213 !     int
214   get_spec_reg(regname, argp, allocated, errmsg)
215       int               regname;
216       char_u    **argp;
217 ***************
218 *** 1426,1472 ****
219   }
220   
221   /*
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.
226    *
227    * return FAIL for failure, OK otherwise
228    */
229       int
230 ! cmdline_paste(regname, literally)
231       int regname;
232       int literally;    /* Insert text literally instead of "as typed" */
233   {
234       long      i;
235 -     char_u    *arg;
236 -     int               allocated;
237
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))
242 -       return FAIL;
243
244 -     /* A register containing CTRL-R can cause an endless loop.  Allow using
245 -      * CTRL-C to break the loop. */
246 -     line_breakcheck();
247 -     if (got_int)
248 -       return FAIL;
249
250 - #ifdef FEAT_CLIPBOARD
251 -     regname = may_get_selection(regname);
252 - #endif
253
254 -     if (get_spec_reg(regname, &arg, &allocated, TRUE))
255 -     {
256 -       if (arg == NULL)
257 -           return FAIL;
258 -       cmdline_paste_str(arg, literally);
259 -       if (allocated)
260 -           vim_free(arg);
261 -       return OK;
262 -     }
263   
264       get_yank_register(regname, FALSE);
265       if (y_current->y_array == NULL)
266 --- 1421,1440 ----
267   }
268   
269   /*
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.
275    *
276    * return FAIL for failure, OK otherwise
277    */
278       int
279 ! cmdline_paste_reg(regname, literally)
280       int regname;
281       int literally;    /* Insert text literally instead of "as typed" */
282   {
283       long      i;
284   
285       get_yank_register(regname, FALSE);
286       if (y_current->y_array == NULL)
287 ***************
288 *** 1487,1532 ****
289             return FAIL;
290       }
291       return OK;
292 - }
293
294 - /*
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
298 -  * line.
299 -  */
300 -     static void
301 - cmdline_paste_str(s, literally)
302 -     char_u    *s;
303 -     int               literally;
304 - {
305 -     int               c, cv;
306
307 -     if (literally)
308 -       put_on_cmdline(s, -1, TRUE);
309 -     else
310 -       while (*s != NUL)
311 -       {
312 -           cv = *s;
313 -           if (cv == Ctrl_V && s[1])
314 -               ++s;
315 - #ifdef FEAT_MBYTE
316 -           if (has_mbyte)
317 -           {
318 -               c = mb_ptr2char(s);
319 -               s += mb_char2len(c);
320 -           }
321 -           else
322 - #endif
323 -               c = *s++;
324 -           if (cv == Ctrl_V || c == ESC || c == Ctrl_C || c == CAR || c == NL
325 - #ifdef UNIX
326 -                   || c == intr_char
327 - #endif
328 -                   || (c == Ctrl_BSL && *s == Ctrl_N))
329 -               stuffcharReadbuff(Ctrl_V);
330 -           stuffcharReadbuff(c);
331 -       }
332   }
333   
334   #if defined(FEAT_CLIPBOARD) || defined(PROTO)
335 --- 1455,1460 ----
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
338 ***************
339 *** 9,14 ****
340 --- 9,15 ----
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
350 ***************
351 *** 10,22 ****
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));
365 --- 10,25 ----
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
384 ***************
385 *** 643,644 ****
386 --- 643,646 ----
387   {   /* Add new patch number below this line */
388 + /**/
389 +     13,
390   /**/
391
392 -- 
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
397    into a well.
398                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
399
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 ///
This page took 0.04757 seconds and 3 git commands to generate.