]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.231
- initial import
[packages/vim.git] / 6.2.231
1 To: vim-dev@vim.org
2 Subject: Patch 6.2.231
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.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
17             Brandt)
18 Files:      src/eval.c, src/ex_eval.c, src/proto/ex_eval.pro,
19             src/testdir/test49.ok, src/testdir/test49.vim
20
21
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
24 ***************
25 *** 1334,1340 ****
26         if (doesrange || eap->skip)
27             break;
28         /* Stop when immediately aborting on error, or when an interrupt
29 !        * occurred or an exception was thrown but not caught. */
30         if (aborting())
31             break;
32       }
33 --- 1334,1342 ----
34         if (doesrange || eap->skip)
35             break;
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
39 !        * executed. */
40         if (aborting())
41             break;
42       }
43 ***************
44 *** 1345,1351 ****
45 --- 1347,1356 ----
46       {
47         /* Check for trailing illegal characters and a following command. */
48         if (!ends_excmd(*arg))
49 +       {
50 +           emsg_severe = TRUE;
51             EMSG(_(e_trailing));
52 +       }
53         else
54             eap->nextcmd = check_nextcmd(arg);
55       }
56 ***************
57 *** 3009,3022 ****
58       else
59         ret = FAIL;
60   
61 !     if (!aborting())
62 !     {
63 !       if (ret == OK)
64 !           ret = call_func(name, len, retvar, argcount, argvars,
65                                     firstline, lastline, doesrange, evaluate);
66 !       else
67 !           EMSG2(_("E116: Invalid arguments for function %s"), name);
68 !     }
69   
70       while (--argcount >= 0)
71         clear_var(&argvars[argcount]);
72 --- 3014,3024 ----
73       else
74         ret = FAIL;
75   
76 !     if (ret == OK)
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);
81   
82       while (--argcount >= 0)
83         clear_var(&argvars[argcount]);
84 ***************
85 *** 3183,3188 ****
86 --- 3185,3201 ----
87                 }
88             }
89         }
90 +       /*
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.
99 +        */
100 +       update_force_abort();
101       }
102       if (error == ERROR_NONE)
103         ret = OK;
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
106 ***************
107 *** 72,81 ****
108   /*
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).
115    */
116   static int cause_abort = FALSE;
117   
118 --- 72,82 ----
119   /*
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).
127    */
128   static int cause_abort = FALSE;
129   
130 ***************
131 *** 85,92 ****
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.
139    */
140 --- 86,93 ----
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.
148    */
149 ***************
150 *** 97,102 ****
151 --- 98,116 ----
152   }
153   
154   /*
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.
159 +  */
160 +     void
161 + update_force_abort()
162 + {
163 +     if (cause_abort)
164 +       force_abort = TRUE;
165 + }
166
167 + /*
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
173 ***************
174 *** 1,5 ****
175 --- 1,6 ----
176   /* ex_eval.c */
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
184 ***************
185 *** 73,90 ****
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)
204 --- 73,91 ----
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
226 ***************
227 *** 7567,7573 ****
228   
229   
230   "-------------------------------------------------------------------------------
231 ! " Test 74:  Errors, interupts, :throw during expression evaluation        {{{1
232   "
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
235 --- 7567,7754 ----
236   
237   
238   "-------------------------------------------------------------------------------
239 ! " Test 74:  Errors in builtin functions.                                  {{{1
240 ! "
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.
245 ! "
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 ! "-------------------------------------------------------------------------------
255
256 ! XpathINIT
257
258 ! function! F1(arg1)
259 !     Xpath 1                                   " X: 0
260 ! endfunction
261
262 ! function! F2(arg1, arg2)
263 !     Xpath 2                                   " X: 0
264 ! endfunction
265
266 ! function! G()
267 !     Xpath 4                                   " X: 0
268 ! endfunction
269
270 ! function! H()
271 !     Xpath 8                                   " X: 0
272 ! endfunction
273
274 ! function! R()
275 !     while 1
276 !       try
277 !           let caught = 0
278 !           let v:errmsg = ""
279 !           Xpath 16                            " X: 16
280 !           return append(1, "s")
281 !       catch /E21/
282 !           let caught = 1
283 !       catch /.*/
284 !           Xpath 32                            " X: 0
285 !       finally
286 !           Xpath 64                            " X: 64
287 !           if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
288 !               Xpath 128                       " X: 128
289 !           endif
290 !           break               " discard error for $VIMNOERRTHROW
291 !       endtry
292 !     endwhile
293 !     Xpath 256                                 " X: 256
294 ! endfunction
295
296 ! try
297 !     set noma  " let append() fail with "E21"
298
299 !     while 1
300 !       try
301 !           let caught = 0
302 !           let v:errmsg = ""
303 !           Xpath 512                           " X: 512
304 !           call append(1, "s")
305 !       catch /E21/
306 !           let caught = 1
307 !       catch /.*/
308 !           Xpath 1024                          " X: 0
309 !       finally
310 !           Xpath 2048                          " X: 2048
311 !           if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
312 !               Xpath 4096                      " X: 4096
313 !           endif
314 !           break               " discard error for $VIMNOERRTHROW
315 !       endtry
316 !     endwhile
317
318 !     while 1
319 !       try
320 !           let caught = 0
321 !           let v:errmsg = ""
322 !           Xpath 8192                          " X: 8192
323 !           call F1('x' . append(1, "s"))
324 !       catch /E21/
325 !           let caught = 1
326 !       catch /.*/
327 !           Xpath 16384                         " X: 0
328 !       finally
329 !           Xpath 32768                         " X: 32768
330 !           if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
331 !               Xpath 65536                     " X: 65536
332 !           endif
333 !           break               " discard error for $VIMNOERRTHROW
334 !       endtry
335 !     endwhile
336
337 !     while 1
338 !       try
339 !           let caught = 0
340 !           let v:errmsg = ""
341 !           Xpath 131072                        " X: 131072
342 !           call F2('x' . append(1, "s"), G())
343 !       catch /E21/
344 !           let caught = 1
345 !       catch /.*/
346 !           Xpath 262144                        " X: 0
347 !       finally
348 !           Xpath 524288                        " X: 524288
349 !           if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
350 !               Xpath 1048576                   " X: 1048576
351 !           endif
352 !           break               " discard error for $VIMNOERRTHROW
353 !       endtry
354 !     endwhile
355
356 !     call R()
357
358 !     while 1
359 !       try
360 !           let caught = 0
361 !           let v:errmsg = ""
362 !           Xpath 2097152                       " X: 2097152
363 !           throw "T" . append(1, "s")
364 !       catch /E21/
365 !           let caught = 1
366 !       catch /^T.*/
367 !           Xpath 4194304                       " X: 0
368 !       catch /.*/
369 !           Xpath 8388608                       " X: 0
370 !       finally
371 !           Xpath 16777216                      " X: 16777216
372 !           if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
373 !               Xpath 33554432                  " X: 33554432
374 !           endif
375 !           break               " discard error for $VIMNOERRTHROW
376 !       endtry
377 !     endwhile
378
379 !     while 1
380 !       try
381 !           let caught = 0
382 !           let v:errmsg = ""
383 !           Xpath 67108864                      " X: 67108864
384 !           let x = "a"
385 !           let x = x . "b" . append(1, "s") . H()
386 !       catch /E21/
387 !           let caught = 1
388 !       catch /.*/
389 !           Xpath 134217728                     " X: 0
390 !       finally
391 !           Xpath 268435456                     " X: 268435456
392 !           if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
393 !               Xpath 536870912                 " X: 536870912
394 !           endif
395 !           if x == "a"
396 !               Xpath 1073741824                " X: 1073741824
397 !           endif
398 !           break               " discard error for $VIMNOERRTHROW
399 !       endtry
400 !     endwhile
401 ! catch /.*/
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
405 ! finally
406 !     set ma&
407 ! endtry
408
409 ! unlet! caught x
410 ! delfunction F1
411 ! delfunction F2
412 ! delfunction G
413 ! delfunction H
414 ! delfunction R
415
416 ! Xcheck 2000403408
417
418
419 ! "-------------------------------------------------------------------------------
420 ! " Test 75:  Errors, interupts, :throw during expression evaluation        {{{1
421   "
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
424 ***************
425 *** 7853,7859 ****
426   
427   
428   "-------------------------------------------------------------------------------
429 ! " Test 75:  Errors, interupts, :throw in name{brace-expression}                   {{{1
430   "
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
433 --- 8034,8040 ----
434   
435   
436   "-------------------------------------------------------------------------------
437 ! " Test 76:  Errors, interupts, :throw in name{brace-expression}                   {{{1
438   "
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
441 ***************
442 *** 7983,7989 ****
443   
444   
445   "-------------------------------------------------------------------------------
446 ! " Test 76:  Messages on parsing errors in expression evaluation                   {{{1
447   "
448   "         When an expression evaluation detects a parsing error, an error
449   "         message is given and converted to an exception, and the expression
450 --- 8164,8170 ----
451   
452   
453   "-------------------------------------------------------------------------------
454 ! " Test 77:  Messages on parsing errors in expression evaluation                   {{{1
455   "
456   "         When an expression evaluation detects a parsing error, an error
457   "         message is given and converted to an exception, and the expression
458 ***************
459 *** 8172,8178 ****
460   
461   
462   "-------------------------------------------------------------------------------
463 ! " Test 77:  Throwing one of several errors for the same command                   {{{1
464   "
465   "         When several errors appear in a row (for instance during expression
466   "         evaluation), the first as the most specific one is used when
467 --- 8353,8359 ----
468   
469   
470   "-------------------------------------------------------------------------------
471 ! " Test 78:  Throwing one of several errors for the same command                   {{{1
472   "
473   "         When several errors appear in a row (for instance during expression
474   "         evaluation), the first as the most specific one is used when
475 ***************
476 *** 8367,8373 ****
477   
478   
479   "-------------------------------------------------------------------------------
480 ! " Test 78:  Syntax error in expression for illegal :elseif                {{{1
481   "
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)
484 --- 8548,8554 ----
485   
486   
487   "-------------------------------------------------------------------------------
488 ! " Test 79:  Syntax error in expression for illegal :elseif                {{{1
489   "
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)
492 ***************
493 *** 8552,8558 ****
494   
495   
496   "-------------------------------------------------------------------------------
497 ! " Test 79:  Discarding exceptions after an error or interrupt             {{{1
498   "
499   "         When an exception is thrown from inside a :try conditional without
500   "         :catch and :finally clauses and an error or interrupt occurs before
501 --- 8733,8739 ----
502   
503   
504   "-------------------------------------------------------------------------------
505 ! " Test 80:  Discarding exceptions after an error or interrupt             {{{1
506   "
507   "         When an exception is thrown from inside a :try conditional without
508   "         :catch and :finally clauses and an error or interrupt occurs before
509 ***************
510 *** 8598,8604 ****
511   
512   
513   "-------------------------------------------------------------------------------
514 ! " Test 80:  Ignoring :catch clauses after an error or interrupt                   {{{1
515   "
516   "         When an exception is thrown and an error or interrupt occurs before
517   "         the matching :catch clause is reached, the exception is discarded
518 --- 8779,8785 ----
519   
520   
521   "-------------------------------------------------------------------------------
522 ! " Test 81:  Ignoring :catch clauses after an error or interrupt                   {{{1
523   "
524   "         When an exception is thrown and an error or interrupt occurs before
525   "         the matching :catch clause is reached, the exception is discarded
526 ***************
527 *** 8706,8712 ****
528   
529   
530   "-------------------------------------------------------------------------------
531 ! " Test 81:  Executing :finally clauses after an error or interrupt        {{{1
532   "
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
535 --- 8887,8893 ----
536   
537   
538   "-------------------------------------------------------------------------------
539 ! " Test 82:  Executing :finally clauses after an error or interrupt        {{{1
540   "
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
543 ***************
544 *** 8756,8762 ****
545   
546   
547   "-------------------------------------------------------------------------------
548 ! " Test 82:  Exceptions in autocommand sequences.                          {{{1
549   "
550   "         When an exception occurs in a sequence of autocommands for
551   "         a specific event, the rest of the sequence is not executed.  The
552 --- 8937,8943 ----
553   
554   
555   "-------------------------------------------------------------------------------
556 ! " Test 83:  Exceptions in autocommand sequences.                          {{{1
557   "
558   "         When an exception occurs in a sequence of autocommands for
559   "         a specific event, the rest of the sequence is not executed.  The
560 ***************
561 *** 8931,8937 ****
562   
563   
564   "-------------------------------------------------------------------------------
565 ! " Test 83:  Error exceptions in autocommands for I/O command events       {{{1
566   "
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
569 --- 9112,9118 ----
570   
571   
572   "-------------------------------------------------------------------------------
573 ! " Test 84:  Error exceptions in autocommands for I/O command events       {{{1
574   "
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
577 ***************
578 *** 9178,9184 ****
579   
580   
581   "-------------------------------------------------------------------------------
582 ! " Test 84:  $VIMNOERRTHROW and $VIMNOINTTHROW support                     {{{1
583   "
584   "         It is possible to configure Vim for throwing exceptions on error
585   "         or interrupt, controlled by variables $VIMNOERRTHROW and
586 --- 9359,9365 ----
587   
588   
589   "-------------------------------------------------------------------------------
590 ! " Test 85:  $VIMNOERRTHROW and $VIMNOINTTHROW support                     {{{1
591   "
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
596 ***************
597 *** 639,640 ****
598 --- 639,642 ----
599   {   /* Add new patch number below this line */
600 + /**/
601 +     231,
602   /**/
603
604 -- 
605 hundred-and-one symptoms of being an internet addict:
606 29. Your phone bill comes to your doorstep in a box.
607
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  ///
This page took 1.493708 seconds and 3 git commands to generate.