4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
10 Patch 6.2.231 (after 6.2.046)
11 Problem: Various problems when an error exception is raised from within a
12 builtin function. When it is invoked while evaluating arguments
13 to a function following arguments are still evaluated. When
14 invoked with a line range it will be called for remaining lines.
15 Solution: Update "force_abort" also after calling a builtin function, so
16 that aborting() always returns the correct value. (Servatius
18 Files: src/eval.c, src/ex_eval.c, src/proto/ex_eval.pro,
19 src/testdir/test49.ok, src/testdir/test49.vim
22 *** ../vim-6.2.230/src/eval.c Tue Feb 3 16:33:22 2004
23 --- src/eval.c Mon Feb 2 16:49:46 2004
26 if (doesrange || eap->skip)
28 /* Stop when immediately aborting on error, or when an interrupt
29 ! * occurred or an exception was thrown but not caught. */
34 if (doesrange || eap->skip)
36 /* Stop when immediately aborting on error, or when an interrupt
37 ! * occurred or an exception was thrown but not caught. get_func_var()
38 ! * returned OK, so that the check for trailing characters below is
47 /* Check for trailing illegal characters and a following command. */
48 if (!ends_excmd(*arg))
54 eap->nextcmd = check_nextcmd(arg);
64 ! ret = call_func(name, len, retvar, argcount, argvars,
65 firstline, lastline, doesrange, evaluate);
67 ! EMSG2(_("E116: Invalid arguments for function %s"), name);
70 while (--argcount >= 0)
71 clear_var(&argvars[argcount]);
77 ! ret = call_func(name, len, retvar, argcount, argvars,
78 firstline, lastline, doesrange, evaluate);
79 ! else if (!aborting())
80 ! EMSG2(_("E116: Invalid arguments for function %s"), name);
82 while (--argcount >= 0)
83 clear_var(&argvars[argcount]);
91 + * The function call (or "FuncUndefined" autocommand sequence) might
92 + * have been aborted by an error, an interrupt, or an explicitly thrown
93 + * exception that has not been caught so far. This situation can be
94 + * tested for by calling aborting(). For an error in an internal
95 + * function or for the "E132" error in call_user_func(), however, the
96 + * throw point at which the "force_abort" flag (temporarily reset by
97 + * emsg()) is normally updated has not been reached yet. We need to
98 + * update that flag first to make aborting() reliable.
100 + update_force_abort();
102 if (error == ERROR_NONE)
104 *** ../vim-6.2.230/src/ex_eval.c Fri May 30 21:45:31 2003
105 --- src/ex_eval.c Mon Feb 2 22:04:59 2004
109 * When several errors appear in a row, setting "force_abort" is delayed until
110 * the failing command returned. "cause_abort" is set to TRUE meanwhile, in
111 ! * order to indicate that situation. This is useful for aborting expression
112 ! * evaluation when a function call set "force_abort" without producing any
113 ! * error messages, but giving all error messages on a parsing error during the
114 ! * expression evaluation (even if a try conditional is active).
116 static int cause_abort = FALSE;
120 * When several errors appear in a row, setting "force_abort" is delayed until
121 * the failing command returned. "cause_abort" is set to TRUE meanwhile, in
122 ! * order to indicate that situation. This is useful when "force_abort" was set
123 ! * during execution of a function call from an expression: the aborting of the
124 ! * expression evaluation is done without producing any error messages, but all
125 ! * error messages on parsing errors during the expression evaluation are given
126 ! * (even if a try conditional is active).
128 static int cause_abort = FALSE;
132 * to check whether an aborted function that does not handle a range itself
133 * should be called again for the next line in the range. Also used for
134 * cancelling expression evaluation after a function call caused an immediate
135 ! * abort. Note that the first emsg() call temporarily resets force_abort until
136 ! * the throw point for error messages has been reached. That is, during
137 * cancellation of an expression evaluation after an aborting function call or
138 * due to a parsing error, aborting() always returns the same value.
141 * to check whether an aborted function that does not handle a range itself
142 * should be called again for the next line in the range. Also used for
143 * cancelling expression evaluation after a function call caused an immediate
144 ! * abort. Note that the first emsg() call temporarily resets "force_abort"
145 ! * until the throw point for error messages has been reached. That is, during
146 * cancellation of an expression evaluation after an aborting function call or
147 * due to a parsing error, aborting() always returns the same value.
155 + * The value of "force_abort" is temporarily reset by the first emsg() call
156 + * during an expression evaluation, and "cause_abort" is used instead. It might
157 + * be necessary to restore "force_abort" even before the throw point for the
158 + * error message has been reached. update_force_abort() should be called then.
161 + update_force_abort()
164 + force_abort = TRUE;
168 * Return TRUE if a command with a subcommand resulting in "retcode" should
169 * abort the script processing. Can be used to suppress an autocommand after
170 * execution of a failing subcommand as long as the error message has not been
171 *** ../vim-6.2.230/src/proto/ex_eval.pro Sun Jun 1 12:26:09 2003
172 --- src/proto/ex_eval.pro Mon Feb 2 16:05:23 2004
177 int aborting __ARGS((void));
178 + void update_force_abort __ARGS((void));
179 int should_abort __ARGS((int retcode));
180 int aborted_in_try __ARGS((void));
181 int cause_errthrow __ARGS((char_u *msg, int severe, int *ignore));
182 *** ../vim-6.2.230/src/testdir/test49.ok Fri May 30 21:45:31 2003
183 --- src/testdir/test49.ok Mon Feb 2 16:05:23 2004
186 *** Test 71: OK (1789569365)
187 *** Test 72: OK (9032615)
188 *** Test 73: OK (224907669)
189 ! *** Test 74: OK (1610087935)
190 ! *** Test 75: OK (1388671)
191 ! *** Test 76: OK (134217728)
192 ! *** Test 77: OK (70288929)
193 ! *** Test 78: OK (17895765)
194 ! *** Test 79: OK (387)
195 ! *** Test 80: OK (8454401)
196 ! *** Test 81: OK (2835)
197 ! *** Test 82: OK (934782101)
198 ! *** Test 83: OK (198689)
199 ! --- Test 84: All tests were run with throwing exceptions on error.
200 The $VIMNOERRTHROW control is not configured.
201 ! --- Test 84: All tests were run with throwing exceptions on interrupt.
202 The $VIMNOINTTHROW control is not configured.
203 ! *** Test 84: OK (50443995)
205 *** Test 71: OK (1789569365)
206 *** Test 72: OK (9032615)
207 *** Test 73: OK (224907669)
208 ! *** Test 74: OK (2000403408)
209 ! *** Test 75: OK (1610087935)
210 ! *** Test 76: OK (1388671)
211 ! *** Test 77: OK (134217728)
212 ! *** Test 78: OK (70288929)
213 ! *** Test 79: OK (17895765)
214 ! *** Test 80: OK (387)
215 ! *** Test 81: OK (8454401)
216 ! *** Test 82: OK (2835)
217 ! *** Test 83: OK (934782101)
218 ! *** Test 84: OK (198689)
219 ! --- Test 85: All tests were run with throwing exceptions on error.
220 The $VIMNOERRTHROW control is not configured.
221 ! --- Test 85: All tests were run with throwing exceptions on interrupt.
222 The $VIMNOINTTHROW control is not configured.
223 ! *** Test 85: OK (50443995)
224 *** ../vim-6.2.230/src/testdir/test49.vim Sun Aug 10 22:31:29 2003
225 --- src/testdir/test49.vim Mon Feb 2 16:05:23 2004
230 "-------------------------------------------------------------------------------
231 ! " Test 74: Errors, interupts, :throw during expression evaluation {{{1
233 " When a function call made during expression evaluation is aborted
234 " due to an error inside a :try/:endtry region or due to an interrupt
238 "-------------------------------------------------------------------------------
239 ! " Test 74: Errors in builtin functions. {{{1
241 ! " On an error in a builtin function called inside a :try/:endtry
242 ! " region, the evaluation of the expression calling that function and
243 ! " the command containing that expression are abandoned. The error can
244 ! " be caught as an exception.
246 ! " A simple :call of the builtin function is a trivial case. If the
247 ! " builtin function is called in the argument list of another function,
248 ! " no further arguments are evaluated, and the other function is not
249 ! " executed. If the builtin function is called from the argument of
250 ! " a :return command, the :return command is not executed. If the
251 ! " builtin function is called from the argument of a :throw command,
252 ! " the :throw command is not executed. The evaluation of the
253 ! " expression calling the builtin function is abandoned.
254 ! "-------------------------------------------------------------------------------
262 ! function! F2(arg1, arg2)
280 ! return append(1, "s")
287 ! if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
290 ! break " discard error for $VIMNOERRTHROW
297 ! set noma " let append() fail with "E21"
304 ! call append(1, "s")
310 ! Xpath 2048 " X: 2048
311 ! if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
312 ! Xpath 4096 " X: 4096
314 ! break " discard error for $VIMNOERRTHROW
322 ! Xpath 8192 " X: 8192
323 ! call F1('x' . append(1, "s"))
329 ! Xpath 32768 " X: 32768
330 ! if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
331 ! Xpath 65536 " X: 65536
333 ! break " discard error for $VIMNOERRTHROW
341 ! Xpath 131072 " X: 131072
342 ! call F2('x' . append(1, "s"), G())
346 ! Xpath 262144 " X: 0
348 ! Xpath 524288 " X: 524288
349 ! if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
350 ! Xpath 1048576 " X: 1048576
352 ! break " discard error for $VIMNOERRTHROW
362 ! Xpath 2097152 " X: 2097152
363 ! throw "T" . append(1, "s")
367 ! Xpath 4194304 " X: 0
369 ! Xpath 8388608 " X: 0
371 ! Xpath 16777216 " X: 16777216
372 ! if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
373 ! Xpath 33554432 " X: 33554432
375 ! break " discard error for $VIMNOERRTHROW
383 ! Xpath 67108864 " X: 67108864
385 ! let x = x . "b" . append(1, "s") . H()
389 ! Xpath 134217728 " X: 0
391 ! Xpath 268435456 " X: 268435456
392 ! if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
393 ! Xpath 536870912 " X: 536870912
396 ! Xpath 1073741824 " X: 1073741824
398 ! break " discard error for $VIMNOERRTHROW
402 ! " The Xpath command does not accept 2^31 (negative); add explicitly:
403 ! let Xpath = Xpath + 2147483648 " X: 0
404 ! Xout v:exception "in" v:throwpoint
419 ! "-------------------------------------------------------------------------------
420 ! " Test 75: Errors, interupts, :throw during expression evaluation {{{1
422 " When a function call made during expression evaluation is aborted
423 " due to an error inside a :try/:endtry region or due to an interrupt
428 "-------------------------------------------------------------------------------
429 ! " Test 75: Errors, interupts, :throw in name{brace-expression} {{{1
431 " When a function call made during evaluation of an expression in
432 " braces as part of a function name after ":function" is aborted due
436 "-------------------------------------------------------------------------------
437 ! " Test 76: Errors, interupts, :throw in name{brace-expression} {{{1
439 " When a function call made during evaluation of an expression in
440 " braces as part of a function name after ":function" is aborted due
445 "-------------------------------------------------------------------------------
446 ! " Test 76: Messages on parsing errors in expression evaluation {{{1
448 " When an expression evaluation detects a parsing error, an error
449 " message is given and converted to an exception, and the expression
453 "-------------------------------------------------------------------------------
454 ! " Test 77: Messages on parsing errors in expression evaluation {{{1
456 " When an expression evaluation detects a parsing error, an error
457 " message is given and converted to an exception, and the expression
462 "-------------------------------------------------------------------------------
463 ! " Test 77: Throwing one of several errors for the same command {{{1
465 " When several errors appear in a row (for instance during expression
466 " evaluation), the first as the most specific one is used when
470 "-------------------------------------------------------------------------------
471 ! " Test 78: Throwing one of several errors for the same command {{{1
473 " When several errors appear in a row (for instance during expression
474 " evaluation), the first as the most specific one is used when
479 "-------------------------------------------------------------------------------
480 ! " Test 78: Syntax error in expression for illegal :elseif {{{1
482 " If there is a syntax error in the expression after an illegal
483 " :elseif, an error message is given (or an error exception thrown)
487 "-------------------------------------------------------------------------------
488 ! " Test 79: Syntax error in expression for illegal :elseif {{{1
490 " If there is a syntax error in the expression after an illegal
491 " :elseif, an error message is given (or an error exception thrown)
496 "-------------------------------------------------------------------------------
497 ! " Test 79: Discarding exceptions after an error or interrupt {{{1
499 " When an exception is thrown from inside a :try conditional without
500 " :catch and :finally clauses and an error or interrupt occurs before
504 "-------------------------------------------------------------------------------
505 ! " Test 80: Discarding exceptions after an error or interrupt {{{1
507 " When an exception is thrown from inside a :try conditional without
508 " :catch and :finally clauses and an error or interrupt occurs before
513 "-------------------------------------------------------------------------------
514 ! " Test 80: Ignoring :catch clauses after an error or interrupt {{{1
516 " When an exception is thrown and an error or interrupt occurs before
517 " the matching :catch clause is reached, the exception is discarded
521 "-------------------------------------------------------------------------------
522 ! " Test 81: Ignoring :catch clauses after an error or interrupt {{{1
524 " When an exception is thrown and an error or interrupt occurs before
525 " the matching :catch clause is reached, the exception is discarded
530 "-------------------------------------------------------------------------------
531 ! " Test 81: Executing :finally clauses after an error or interrupt {{{1
533 " When an exception is thrown and an error or interrupt occurs before
534 " the :finally of the innermost :try is reached, the exception is
538 "-------------------------------------------------------------------------------
539 ! " Test 82: Executing :finally clauses after an error or interrupt {{{1
541 " When an exception is thrown and an error or interrupt occurs before
542 " the :finally of the innermost :try is reached, the exception is
547 "-------------------------------------------------------------------------------
548 ! " Test 82: Exceptions in autocommand sequences. {{{1
550 " When an exception occurs in a sequence of autocommands for
551 " a specific event, the rest of the sequence is not executed. The
555 "-------------------------------------------------------------------------------
556 ! " Test 83: Exceptions in autocommand sequences. {{{1
558 " When an exception occurs in a sequence of autocommands for
559 " a specific event, the rest of the sequence is not executed. The
564 "-------------------------------------------------------------------------------
565 ! " Test 83: Error exceptions in autocommands for I/O command events {{{1
567 " When an I/O command is inside :try/:endtry, autocommands to be
568 " executed after it should be skipped on an error (exception) in the
572 "-------------------------------------------------------------------------------
573 ! " Test 84: Error exceptions in autocommands for I/O command events {{{1
575 " When an I/O command is inside :try/:endtry, autocommands to be
576 " executed after it should be skipped on an error (exception) in the
581 "-------------------------------------------------------------------------------
582 ! " Test 84: $VIMNOERRTHROW and $VIMNOINTTHROW support {{{1
584 " It is possible to configure Vim for throwing exceptions on error
585 " or interrupt, controlled by variables $VIMNOERRTHROW and
589 "-------------------------------------------------------------------------------
590 ! " Test 85: $VIMNOERRTHROW and $VIMNOINTTHROW support {{{1
592 " It is possible to configure Vim for throwing exceptions on error
593 " or interrupt, controlled by variables $VIMNOERRTHROW and
594 *** ../vim-6.2.230/src/version.c Tue Feb 3 16:55:34 2004
595 --- src/version.c Tue Feb 3 17:23:01 2004
599 { /* Add new patch number below this line */
605 hundred-and-one symptoms of being an internet addict:
606 29. Your phone bill comes to your doorstep in a box.
608 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
609 /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
610 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
611 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///