1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: "getline" argument in do_cmdline() shadows global.
12 Solution: Rename the argument.
16 *** ../vim-7.3.055/src/ex_docmd.c 2010-11-10 18:59:50.000000000 +0100
17 --- src/ex_docmd.c 2010-11-16 11:24:40.000000000 +0100
20 * do_cmdline(): execute one Ex command line
22 * 1. Execute "cmdline" when it is not NULL.
23 ! * If "cmdline" is NULL, or more lines are needed, getline() is used.
24 * 2. Split up in parts separated with '|'.
26 * This function can be called recursively!
28 * do_cmdline(): execute one Ex command line
30 * 1. Execute "cmdline" when it is not NULL.
31 ! * If "cmdline" is NULL, or more lines are needed, fgetline() is used.
32 * 2. Split up in parts separated with '|'.
34 * This function can be called recursively!
38 * DOCMD_VERBOSE - The command will be included in the error message.
39 * DOCMD_NOWAIT - Don't call wait_return() and friends.
40 ! * DOCMD_REPEAT - Repeat execution until getline() returns NULL.
41 * DOCMD_KEYTYPED - Don't reset KeyTyped.
42 * DOCMD_EXCRESET - Reset the exception environment (used for debugging).
43 * DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
46 * DOCMD_VERBOSE - The command will be included in the error message.
47 * DOCMD_NOWAIT - Don't call wait_return() and friends.
48 ! * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL.
49 * DOCMD_KEYTYPED - Don't reset KeyTyped.
50 * DOCMD_EXCRESET - Reset the exception environment (used for debugging).
51 * DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
54 * return FAIL if cmdline could not be executed, OK otherwise
57 ! do_cmdline(cmdline, getline, cookie, flags)
59 ! char_u *(*getline) __ARGS((int, void *, int));
60 ! void *cookie; /* argument for getline() */
63 char_u *next_cmdline; /* next cmd to execute */
64 char_u *cmdline_copy = NULL; /* copy of cmd line */
65 ! int used_getline = FALSE; /* used "getline" to obtain command */
66 static int recursive = 0; /* recursive depth */
67 int msg_didout_before_start = 0;
68 int count = 0; /* line number count */
70 * return FAIL if cmdline could not be executed, OK otherwise
73 ! do_cmdline(cmdline, fgetline, cookie, flags)
75 ! char_u *(*fgetline) __ARGS((int, void *, int));
76 ! void *cookie; /* argument for fgetline() */
79 char_u *next_cmdline; /* next cmd to execute */
80 char_u *cmdline_copy = NULL; /* copy of cmd line */
81 ! int used_getline = FALSE; /* used "fgetline" to obtain command */
82 static int recursive = 0; /* recursive depth */
83 int msg_didout_before_start = 0;
84 int count = 0; /* line number count */
87 struct msglist **saved_msg_list = NULL;
88 struct msglist *private_msg_list;
90 ! /* "getline" and "cookie" passed to do_one_cmd() */
91 char_u *(*cmd_getline) __ARGS((int, void *, int));
93 struct loop_cookie cmd_loop_cookie;
97 ! # define cmd_getline getline
98 # define cmd_cookie cookie
100 static int call_depth = 0; /* recursiveness */
102 struct msglist **saved_msg_list = NULL;
103 struct msglist *private_msg_list;
105 ! /* "fgetline" and "cookie" passed to do_one_cmd() */
106 char_u *(*cmd_getline) __ARGS((int, void *, int));
108 struct loop_cookie cmd_loop_cookie;
112 ! # define cmd_getline fgetline
113 # define cmd_cookie cookie
115 static int call_depth = 0; /* recursiveness */
118 cstack.cs_lflags = 0;
119 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10);
121 ! real_cookie = getline_cookie(getline, cookie);
123 /* Inside a function use a higher nesting level. */
124 ! getline_is_func = getline_equal(getline, cookie, get_func_line);
125 if (getline_is_func && ex_nesting_level == func_level(real_cookie))
129 cstack.cs_lflags = 0;
130 ga_init2(&lines_ga, (int)sizeof(wcmd_T), 10);
132 ! real_cookie = getline_cookie(fgetline, cookie);
134 /* Inside a function use a higher nesting level. */
135 ! getline_is_func = getline_equal(fgetline, cookie, get_func_line);
136 if (getline_is_func && ex_nesting_level == func_level(real_cookie))
141 breakpoint = func_breakpoint(real_cookie);
142 dbg_tick = func_dbg_tick(real_cookie);
144 ! else if (getline_equal(getline, cookie, getsourceline))
146 fname = sourcing_name;
147 breakpoint = source_breakpoint(real_cookie);
149 breakpoint = func_breakpoint(real_cookie);
150 dbg_tick = func_dbg_tick(real_cookie);
152 ! else if (getline_equal(fgetline, cookie, getsourceline))
154 fname = sourcing_name;
155 breakpoint = source_breakpoint(real_cookie);
158 * KeyTyped is only set when calling vgetc(). Reset it here when not
159 * calling vgetc() (sourced command lines).
161 ! if (!(flags & DOCMD_KEYTYPED) && !getline_equal(getline, cookie, getexline))
166 * KeyTyped is only set when calling vgetc(). Reset it here when not
167 * calling vgetc() (sourced command lines).
169 ! if (!(flags & DOCMD_KEYTYPED)
170 ! && !getline_equal(fgetline, cookie, getexline))
179 ! getline_is_func = getline_equal(getline, cookie, get_func_line);
182 /* stop skipping cmds for an error msg after all endif/while/for */
187 ! getline_is_func = getline_equal(fgetline, cookie, get_func_line);
190 /* stop skipping cmds for an error msg after all endif/while/for */
195 * 1. If repeating a line in a loop, get a line from lines_ga.
196 ! * 2. If no line given: Get an allocated line with getline().
197 * 3. If a line is given: Make a copy, so we can mess with it.
203 * 1. If repeating a line in a loop, get a line from lines_ga.
204 ! * 2. If no line given: Get an allocated line with fgetline().
205 * 3. If a line is given: Make a copy, so we can mess with it.
212 else if (do_profiling == PROF_YES
213 ! && getline_equal(getline, cookie, getsourceline))
217 /* Check if a sourced file hit a ":finish" command. */
218 ! if (source_finished(getline, cookie))
225 else if (do_profiling == PROF_YES
226 ! && getline_equal(fgetline, cookie, getsourceline))
230 /* Check if a sourced file hit a ":finish" command. */
231 ! if (source_finished(fgetline, cookie))
237 && *dbg_tick != debug_tick)
239 *breakpoint = dbg_find_breakpoint(
240 ! getline_equal(getline, cookie, getsourceline),
241 fname, sourcing_lnum);
242 *dbg_tick = debug_tick;
245 && *dbg_tick != debug_tick)
247 *breakpoint = dbg_find_breakpoint(
248 ! getline_equal(fgetline, cookie, getsourceline),
249 fname, sourcing_lnum);
250 *dbg_tick = debug_tick;
254 dbg_breakpoint(fname, sourcing_lnum);
255 /* Find next breakpoint. */
256 *breakpoint = dbg_find_breakpoint(
257 ! getline_equal(getline, cookie, getsourceline),
258 fname, sourcing_lnum);
259 *dbg_tick = debug_tick;
262 dbg_breakpoint(fname, sourcing_lnum);
263 /* Find next breakpoint. */
264 *breakpoint = dbg_find_breakpoint(
265 ! getline_equal(fgetline, cookie, getsourceline),
266 fname, sourcing_lnum);
267 *dbg_tick = debug_tick;
273 func_line_start(real_cookie);
274 ! else if (getline_equal(getline, cookie, getsourceline))
281 func_line_start(real_cookie);
282 ! else if (getline_equal(fgetline, cookie, getsourceline))
288 if (cstack.cs_looplevel > 0)
290 /* Inside a while/for loop we need to store the lines and use them
291 ! * again. Pass a different "getline" function to do_one_cmd()
292 * below, so that it stores lines in or reads them from
293 * "lines_ga". Makes it possible to define a function inside a
296 if (cstack.cs_looplevel > 0)
298 /* Inside a while/for loop we need to store the lines and use them
299 ! * again. Pass a different "fgetline" function to do_one_cmd()
300 * below, so that it stores lines in or reads them from
301 * "lines_ga". Makes it possible to define a function inside a
305 cmd_cookie = (void *)&cmd_loop_cookie;
306 cmd_loop_cookie.lines_gap = &lines_ga;
307 cmd_loop_cookie.current_line = current_line;
308 ! cmd_loop_cookie.getline = getline;
309 cmd_loop_cookie.cookie = cookie;
310 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
314 ! cmd_getline = getline;
319 ! /* 2. If no line given, get an allocated line with getline(). */
320 if (next_cmdline == NULL)
323 * Need to set msg_didout for the first line after an ":if",
324 * otherwise the ":if" will be overwritten.
326 ! if (count == 1 && getline_equal(getline, cookie, getexline))
328 ! if (getline == NULL || (next_cmdline = getline(':', cookie,
330 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
333 cmd_cookie = (void *)&cmd_loop_cookie;
334 cmd_loop_cookie.lines_gap = &lines_ga;
335 cmd_loop_cookie.current_line = current_line;
336 ! cmd_loop_cookie.getline = fgetline;
337 cmd_loop_cookie.cookie = cookie;
338 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
342 ! cmd_getline = fgetline;
347 ! /* 2. If no line given, get an allocated line with fgetline(). */
348 if (next_cmdline == NULL)
351 * Need to set msg_didout for the first line after an ":if",
352 * otherwise the ":if" will be overwritten.
354 ! if (count == 1 && getline_equal(fgetline, cookie, getexline))
356 ! if (fgetline == NULL || (next_cmdline = fgetline(':', cookie,
358 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
362 * If the command was typed, remember it for the ':' register.
363 * Do this AFTER executing the command to make :@: work.
365 ! if (getline_equal(getline, cookie, getexline)
366 && new_last_cmdline != NULL)
368 vim_free(last_cmdline);
370 * If the command was typed, remember it for the ':' register.
371 * Do this AFTER executing the command to make :@: work.
373 ! if (getline_equal(fgetline, cookie, getexline)
374 && new_last_cmdline != NULL)
376 vim_free(last_cmdline);
380 /* reset did_emsg for a function that is not aborted by an error */
381 if (did_emsg && !force_abort
382 ! && getline_equal(getline, cookie, get_func_line)
383 && !func_has_abort(real_cookie))
388 /* reset did_emsg for a function that is not aborted by an error */
389 if (did_emsg && !force_abort
390 ! && getline_equal(fgetline, cookie, get_func_line)
391 && !func_has_abort(real_cookie))
396 if (breakpoint != NULL)
398 *breakpoint = dbg_find_breakpoint(
399 ! getline_equal(getline, cookie, getsourceline),
401 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);
402 *dbg_tick = debug_tick;
404 if (breakpoint != NULL)
406 *breakpoint = dbg_find_breakpoint(
407 ! getline_equal(fgetline, cookie, getsourceline),
409 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);
410 *dbg_tick = debug_tick;
415 && !(did_emsg && used_getline
416 ! && (getline_equal(getline, cookie, getexmodeline)
417 ! || getline_equal(getline, cookie, getexline)))
418 && (next_cmdline != NULL
420 || cstack.cs_idx >= 0
424 && !(did_emsg && used_getline
425 ! && (getline_equal(fgetline, cookie, getexmodeline)
426 ! || getline_equal(fgetline, cookie, getexline)))
427 && (next_cmdline != NULL
429 || cstack.cs_idx >= 0
432 * unclosed conditional.
434 if (!got_int && !did_throw
435 ! && ((getline_equal(getline, cookie, getsourceline)
436 ! && !source_finished(getline, cookie))
437 ! || (getline_equal(getline, cookie, get_func_line)
438 && !func_has_ended(real_cookie))))
440 if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)
442 * unclosed conditional.
444 if (!got_int && !did_throw
445 ! && ((getline_equal(fgetline, cookie, getsourceline)
446 ! && !source_finished(fgetline, cookie))
447 ! || (getline_equal(fgetline, cookie, get_func_line)
448 && !func_has_ended(real_cookie))))
450 if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)
453 /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
454 * lack was reported above and the error message is to be converted to an
455 * exception, do this now after rewinding the cstack. */
456 ! do_errthrow(&cstack, getline_equal(getline, cookie, get_func_line)
457 ? (char_u *)"endfunction" : (char_u *)NULL);
461 /* If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
462 * lack was reported above and the error message is to be converted to an
463 * exception, do this now after rewinding the cstack. */
464 ! do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)
465 ? (char_u *)"endfunction" : (char_u *)NULL);
473 ! if ((getline_equal(getline, cookie, getsourceline)
474 && ex_nesting_level > source_level(real_cookie))
475 ! || (getline_equal(getline, cookie, get_func_line)
476 && ex_nesting_level > func_level(real_cookie) + 1))
483 ! if ((getline_equal(fgetline, cookie, getsourceline)
484 && ex_nesting_level > source_level(real_cookie))
485 ! || (getline_equal(fgetline, cookie, get_func_line)
486 && ex_nesting_level > func_level(real_cookie) + 1))
493 /* When leaving a function, reduce nesting level. */
494 ! if (getline_equal(getline, cookie, get_func_line))
497 * Go to debug mode when returning from a function in which we are
500 ! if ((getline_equal(getline, cookie, getsourceline)
501 ! || getline_equal(getline, cookie, get_func_line))
502 && ex_nesting_level + 1 <= debug_break_level)
503 ! do_debug(getline_equal(getline, cookie, getsourceline)
504 ? (char_u *)_("End of sourced file")
505 : (char_u *)_("End of function"));
510 /* When leaving a function, reduce nesting level. */
511 ! if (getline_equal(fgetline, cookie, get_func_line))
514 * Go to debug mode when returning from a function in which we are
517 ! if ((getline_equal(fgetline, cookie, getsourceline)
518 ! || getline_equal(fgetline, cookie, get_func_line))
519 && ex_nesting_level + 1 <= debug_break_level)
520 ! do_debug(getline_equal(fgetline, cookie, getsourceline)
521 ? (char_u *)_("End of sourced file")
522 : (char_u *)_("End of function"));
524 *** ../vim-7.3.055/src/version.c 2010-11-16 11:28:33.000000000 +0100
525 --- src/version.c 2010-11-16 11:27:09.000000000 +0100
529 { /* Add new patch number below this line */
535 Lawmakers made it obligatory for everybody to take at least one bath
536 each week -- on Saturday night.
537 [real standing law in Vermont, United States of America]
539 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
540 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
541 \\\ an exciting new programming language -- http://www.Zimbu.org ///
542 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///