comparison src/ex_eval.c @ 18779:8f05b3cf8557 v8.1.2379

patch 8.1.2379: using old C style comments Commit: https://github.com/vim/vim/commit/217e1b8359447f5550dcb0d1ee43380a90c253c5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 1 21:41:28 2019 +0100 patch 8.1.2379: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Sun, 01 Dec 2019 21:45:04 +0100
parents 1febd1aa9930
children 2bdc2e1f6e1f
comparison
equal deleted inserted replaced
18778:2182f82b04e4 18779:8f05b3cf8557
50 * && did_emsg is not a reliant test that the exception currently being thrown 50 * && did_emsg is not a reliant test that the exception currently being thrown
51 * is an error exception.) - The macros can be defined as expressions checking 51 * is an error exception.) - The macros can be defined as expressions checking
52 * for a variable that is allowed to be changed during execution of a script. 52 * for a variable that is allowed to be changed during execution of a script.
53 */ 53 */
54 #if 0 54 #if 0
55 /* Expressions used for testing during the development phase. */ 55 // Expressions used for testing during the development phase.
56 # define THROW_ON_ERROR (!eval_to_number("$VIMNOERRTHROW")) 56 # define THROW_ON_ERROR (!eval_to_number("$VIMNOERRTHROW"))
57 # define THROW_ON_INTERRUPT (!eval_to_number("$VIMNOINTTHROW")) 57 # define THROW_ON_INTERRUPT (!eval_to_number("$VIMNOINTTHROW"))
58 # define THROW_TEST 58 # define THROW_TEST
59 #else 59 #else
60 /* Values used for the Vim release. */ 60 // Values used for the Vim release.
61 # define THROW_ON_ERROR TRUE 61 # define THROW_ON_ERROR TRUE
62 # define THROW_ON_ERROR_TRUE 62 # define THROW_ON_ERROR_TRUE
63 # define THROW_ON_INTERRUPT TRUE 63 # define THROW_ON_INTERRUPT TRUE
64 # define THROW_ON_INTERRUPT_TRUE 64 # define THROW_ON_INTERRUPT_TRUE
65 #endif 65 #endif
125 * commands are still reported. 125 * commands are still reported.
126 */ 126 */
127 int 127 int
128 aborted_in_try(void) 128 aborted_in_try(void)
129 { 129 {
130 /* This function is only called after an error. In this case, "force_abort" 130 // This function is only called after an error. In this case, "force_abort"
131 * determines whether searching for finally clauses is necessary. */ 131 // determines whether searching for finally clauses is necessary.
132 return force_abort; 132 return force_abort;
133 } 133 }
134 134
135 /* 135 /*
136 * cause_errthrow(): Cause a throw of an error exception if appropriate. 136 * cause_errthrow(): Cause a throw of an error exception if appropriate.
213 * exception currently being thrown to prevent it from being caught. Just 213 * exception currently being thrown to prevent it from being caught. Just
214 * execute finally clauses and terminate. 214 * execute finally clauses and terminate.
215 */ 215 */
216 if (did_throw) 216 if (did_throw)
217 { 217 {
218 /* When discarding an interrupt exception, reset got_int to prevent the 218 // When discarding an interrupt exception, reset got_int to prevent the
219 * same interrupt being converted to an exception again and discarding 219 // same interrupt being converted to an exception again and discarding
220 * the error exception we are about to throw here. */ 220 // the error exception we are about to throw here.
221 if (current_exception->type == ET_INTERRUPT) 221 if (current_exception->type == ET_INTERRUPT)
222 got_int = FALSE; 222 got_int = FALSE;
223 discard_current_exception(); 223 discard_current_exception();
224 } 224 }
225 225
274 *plist = elem; 274 *plist = elem;
275 if (plist == msg_list || severe) 275 if (plist == msg_list || severe)
276 { 276 {
277 char *tmsg; 277 char *tmsg;
278 278
279 /* Skip the extra "Vim " prefix for message "E458". */ 279 // Skip the extra "Vim " prefix for message "E458".
280 tmsg = elem->msg; 280 tmsg = elem->msg;
281 if (STRNCMP(tmsg, "Vim E", 5) == 0 281 if (STRNCMP(tmsg, "Vim E", 5) == 0
282 && VIM_ISDIGIT(tmsg[5]) 282 && VIM_ISDIGIT(tmsg[5])
283 && VIM_ISDIGIT(tmsg[6]) 283 && VIM_ISDIGIT(tmsg[6])
284 && VIM_ISDIGIT(tmsg[7]) 284 && VIM_ISDIGIT(tmsg[7])
340 { 340 {
341 cause_abort = FALSE; 341 cause_abort = FALSE;
342 force_abort = TRUE; 342 force_abort = TRUE;
343 } 343 }
344 344
345 /* If no exception is to be thrown or the conversion should be done after 345 // If no exception is to be thrown or the conversion should be done after
346 * returning to a previous invocation of do_one_cmd(), do nothing. */ 346 // returning to a previous invocation of do_one_cmd(), do nothing.
347 if (msg_list == NULL || *msg_list == NULL) 347 if (msg_list == NULL || *msg_list == NULL)
348 return; 348 return;
349 349
350 if (throw_exception(*msg_list, ET_ERROR, cmdname) == FAIL) 350 if (throw_exception(*msg_list, ET_ERROR, cmdname) == FAIL)
351 free_msglist(*msg_list); 351 free_msglist(*msg_list);
372 * is being thrown, do nothing (for compatibility of non-EH scripts). 372 * is being thrown, do nothing (for compatibility of non-EH scripts).
373 */ 373 */
374 if (!got_int || (trylevel == 0 && !did_throw)) 374 if (!got_int || (trylevel == 0 && !did_throw))
375 return FALSE; 375 return FALSE;
376 376
377 #ifdef THROW_TEST /* avoid warning for condition always true */ 377 #ifdef THROW_TEST // avoid warning for condition always true
378 if (!THROW_ON_INTERRUPT) 378 if (!THROW_ON_INTERRUPT)
379 { 379 {
380 /* 380 /*
381 * The interrupt aborts everything except for executing finally clauses. 381 * The interrupt aborts everything except for executing finally clauses.
382 * Discard any user or error or interrupt exception currently being 382 * Discard any user or error or interrupt exception currently being
399 if (did_throw) 399 if (did_throw)
400 { 400 {
401 if (current_exception->type == ET_INTERRUPT) 401 if (current_exception->type == ET_INTERRUPT)
402 return FALSE; 402 return FALSE;
403 403
404 /* An interrupt exception replaces any user or error exception. */ 404 // An interrupt exception replaces any user or error exception.
405 discard_current_exception(); 405 discard_current_exception();
406 } 406 }
407 if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) != FAIL) 407 if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) != FAIL)
408 do_throw(cstack); 408 do_throw(cstack);
409 } 409 }
447 if (ret == NULL) 447 if (ret == NULL)
448 return ret; 448 return ret;
449 val = ret + 4; 449 val = ret + 4;
450 } 450 }
451 451
452 /* msg_add_fname may have been used to prefix the message with a file 452 // msg_add_fname may have been used to prefix the message with a file
453 * name in quotes. In the exception value, put the file name in 453 // name in quotes. In the exception value, put the file name in
454 * parentheses and move it to the end. */ 454 // parentheses and move it to the end.
455 for (p = mesg; ; p++) 455 for (p = mesg; ; p++)
456 { 456 {
457 if (*p == NUL 457 if (*p == NUL
458 || (*p == 'E' 458 || (*p == 'E'
459 && VIM_ISDIGIT(p[1]) 459 && VIM_ISDIGIT(p[1])
462 && (p[3] == ':' 462 && (p[3] == ':'
463 || (VIM_ISDIGIT(p[3]) 463 || (VIM_ISDIGIT(p[3])
464 && p[4] == ':')))))) 464 && p[4] == ':'))))))
465 { 465 {
466 if (*p == NUL || p == mesg) 466 if (*p == NUL || p == mesg)
467 STRCAT(val, mesg); /* 'E123' missing or at beginning */ 467 STRCAT(val, mesg); // 'E123' missing or at beginning
468 else 468 else
469 { 469 {
470 /* '"filename" E123: message text' */ 470 // '"filename" E123: message text'
471 if (mesg[0] != '"' || p-2 < &mesg[1] || 471 if (mesg[0] != '"' || p-2 < &mesg[1] ||
472 p[-2] != '"' || p[-1] != ' ') 472 p[-2] != '"' || p[-1] != ' ')
473 /* "E123:" is part of the file name. */ 473 // "E123:" is part of the file name.
474 continue; 474 continue;
475 475
476 STRCAT(val, p); 476 STRCAT(val, p);
477 p[-2] = NUL; 477 p[-2] = NUL;
478 sprintf((char *)(val + STRLEN(p)), " (%s)", &mesg[1]); 478 sprintf((char *)(val + STRLEN(p)), " (%s)", &mesg[1]);
523 excp = ALLOC_ONE(except_T); 523 excp = ALLOC_ONE(except_T);
524 if (excp == NULL) 524 if (excp == NULL)
525 goto nomem; 525 goto nomem;
526 526
527 if (type == ET_ERROR) 527 if (type == ET_ERROR)
528 /* Store the original message and prefix the exception value with 528 // Store the original message and prefix the exception value with
529 * "Vim:" or, if a command name is given, "Vim(cmdname):". */ 529 // "Vim:" or, if a command name is given, "Vim(cmdname):".
530 excp->messages = (struct msglist *)value; 530 excp->messages = (struct msglist *)value;
531 531
532 excp->value = get_exception_string(value, type, cmdname, &should_free); 532 excp->value = get_exception_string(value, type, cmdname, &should_free);
533 if (excp->value == NULL && should_free) 533 if (excp->value == NULL && should_free)
534 goto nomem; 534 goto nomem;
547 if (p_verbose >= 13 || debug_break_level > 0) 547 if (p_verbose >= 13 || debug_break_level > 0)
548 { 548 {
549 int save_msg_silent = msg_silent; 549 int save_msg_silent = msg_silent;
550 550
551 if (debug_break_level > 0) 551 if (debug_break_level > 0)
552 msg_silent = FALSE; /* display messages */ 552 msg_silent = FALSE; // display messages
553 else 553 else
554 verbose_enter(); 554 verbose_enter();
555 ++no_wait_return; 555 ++no_wait_return;
556 if (debug_break_level > 0 || *p_vfile == NUL) 556 if (debug_break_level > 0 || *p_vfile == NUL)
557 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 557 msg_scroll = TRUE; // always scroll up, don't overwrite
558 558
559 smsg(_("Exception thrown: %s"), excp->value); 559 smsg(_("Exception thrown: %s"), excp->value);
560 msg_puts("\n"); /* don't overwrite this either */ 560 msg_puts("\n"); // don't overwrite this either
561 561
562 if (debug_break_level > 0 || *p_vfile == NUL) 562 if (debug_break_level > 0 || *p_vfile == NUL)
563 cmdline_row = msg_row; 563 cmdline_row = msg_row;
564 --no_wait_return; 564 --no_wait_return;
565 if (debug_break_level > 0) 565 if (debug_break_level > 0)
599 { 599 {
600 int save_msg_silent = msg_silent; 600 int save_msg_silent = msg_silent;
601 601
602 saved_IObuff = vim_strsave(IObuff); 602 saved_IObuff = vim_strsave(IObuff);
603 if (debug_break_level > 0) 603 if (debug_break_level > 0)
604 msg_silent = FALSE; /* display messages */ 604 msg_silent = FALSE; // display messages
605 else 605 else
606 verbose_enter(); 606 verbose_enter();
607 ++no_wait_return; 607 ++no_wait_return;
608 if (debug_break_level > 0 || *p_vfile == NUL) 608 if (debug_break_level > 0 || *p_vfile == NUL)
609 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 609 msg_scroll = TRUE; // always scroll up, don't overwrite
610 smsg(was_finished 610 smsg(was_finished
611 ? _("Exception finished: %s") 611 ? _("Exception finished: %s")
612 : _("Exception discarded: %s"), 612 : _("Exception discarded: %s"),
613 excp->value); 613 excp->value);
614 msg_puts("\n"); /* don't overwrite this either */ 614 msg_puts("\n"); // don't overwrite this either
615 if (debug_break_level > 0 || *p_vfile == NUL) 615 if (debug_break_level > 0 || *p_vfile == NUL)
616 cmdline_row = msg_row; 616 cmdline_row = msg_row;
617 --no_wait_return; 617 --no_wait_return;
618 if (debug_break_level > 0) 618 if (debug_break_level > 0)
619 msg_silent = save_msg_silent; 619 msg_silent = save_msg_silent;
662 else 662 else
663 vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name); 663 vim_snprintf((char *)IObuff, IOSIZE, "%s", excp->throw_name);
664 set_vim_var_string(VV_THROWPOINT, IObuff, -1); 664 set_vim_var_string(VV_THROWPOINT, IObuff, -1);
665 } 665 }
666 else 666 else
667 /* throw_name not set on an exception from a command that was typed. */ 667 // throw_name not set on an exception from a command that was typed.
668 set_vim_var_string(VV_THROWPOINT, NULL, -1); 668 set_vim_var_string(VV_THROWPOINT, NULL, -1);
669 669
670 if (p_verbose >= 13 || debug_break_level > 0) 670 if (p_verbose >= 13 || debug_break_level > 0)
671 { 671 {
672 int save_msg_silent = msg_silent; 672 int save_msg_silent = msg_silent;
673 673
674 if (debug_break_level > 0) 674 if (debug_break_level > 0)
675 msg_silent = FALSE; /* display messages */ 675 msg_silent = FALSE; // display messages
676 else 676 else
677 verbose_enter(); 677 verbose_enter();
678 ++no_wait_return; 678 ++no_wait_return;
679 if (debug_break_level > 0 || *p_vfile == NUL) 679 if (debug_break_level > 0 || *p_vfile == NUL)
680 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 680 msg_scroll = TRUE; // always scroll up, don't overwrite
681 681
682 smsg(_("Exception caught: %s"), excp->value); 682 smsg(_("Exception caught: %s"), excp->value);
683 msg_puts("\n"); /* don't overwrite this either */ 683 msg_puts("\n"); // don't overwrite this either
684 684
685 if (debug_break_level > 0 || *p_vfile == NUL) 685 if (debug_break_level > 0 || *p_vfile == NUL)
686 cmdline_row = msg_row; 686 cmdline_row = msg_row;
687 --no_wait_return; 687 --no_wait_return;
688 if (debug_break_level > 0) 688 if (debug_break_level > 0)
714 vim_snprintf((char *)IObuff, IOSIZE, "%s", 714 vim_snprintf((char *)IObuff, IOSIZE, "%s",
715 caught_stack->throw_name); 715 caught_stack->throw_name);
716 set_vim_var_string(VV_THROWPOINT, IObuff, -1); 716 set_vim_var_string(VV_THROWPOINT, IObuff, -1);
717 } 717 }
718 else 718 else
719 /* throw_name not set on an exception from a command that was 719 // throw_name not set on an exception from a command that was
720 * typed. */ 720 // typed.
721 set_vim_var_string(VV_THROWPOINT, NULL, -1); 721 set_vim_var_string(VV_THROWPOINT, NULL, -1);
722 } 722 }
723 else 723 else
724 { 724 {
725 set_vim_var_string(VV_EXCEPTION, NULL, -1); 725 set_vim_var_string(VV_EXCEPTION, NULL, -1);
726 set_vim_var_string(VV_THROWPOINT, NULL, -1); 726 set_vim_var_string(VV_THROWPOINT, NULL, -1);
727 } 727 }
728 728
729 /* Discard the exception, but use the finish message for 'verbose'. */ 729 // Discard the exception, but use the finish message for 'verbose'.
730 discard_exception(excp, TRUE); 730 discard_exception(excp, TRUE);
731 } 731 }
732 732
733 /* 733 /*
734 * Flags specifying the message displayed by report_pending. 734 * Flags specifying the message displayed by report_pending.
758 mesg = _("%s made pending"); 758 mesg = _("%s made pending");
759 break; 759 break;
760 case RP_RESUME: 760 case RP_RESUME:
761 mesg = _("%s resumed"); 761 mesg = _("%s resumed");
762 break; 762 break;
763 /* case RP_DISCARD: */ 763 // case RP_DISCARD:
764 default: 764 default:
765 mesg = _("%s discarded"); 765 mesg = _("%s discarded");
766 break; 766 break;
767 } 767 }
768 768
779 break; 779 break;
780 case CSTP_FINISH: 780 case CSTP_FINISH:
781 s = ":finish"; 781 s = ":finish";
782 break; 782 break;
783 case CSTP_RETURN: 783 case CSTP_RETURN:
784 /* ":return" command producing value, allocated */ 784 // ":return" command producing value, allocated
785 s = (char *)get_return_cmd(value); 785 s = (char *)get_return_cmd(value);
786 break; 786 break;
787 787
788 default: 788 default:
789 if (pending & CSTP_THROW) 789 if (pending & CSTP_THROW)
795 } 795 }
796 else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) 796 else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT))
797 s = _("Error and interrupt"); 797 s = _("Error and interrupt");
798 else if (pending & CSTP_ERROR) 798 else if (pending & CSTP_ERROR)
799 s = _("Error"); 799 s = _("Error");
800 else /* if (pending & CSTP_INTERRUPT) */ 800 else // if (pending & CSTP_INTERRUPT)
801 s = _("Interrupt"); 801 s = _("Interrupt");
802 } 802 }
803 803
804 save_msg_silent = msg_silent; 804 save_msg_silent = msg_silent;
805 if (debug_break_level > 0) 805 if (debug_break_level > 0)
806 msg_silent = FALSE; /* display messages */ 806 msg_silent = FALSE; // display messages
807 ++no_wait_return; 807 ++no_wait_return;
808 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 808 msg_scroll = TRUE; // always scroll up, don't overwrite
809 smsg(mesg, s); 809 smsg(mesg, s);
810 msg_puts("\n"); /* don't overwrite this either */ 810 msg_puts("\n"); // don't overwrite this either
811 cmdline_row = msg_row; 811 cmdline_row = msg_row;
812 --no_wait_return; 812 --no_wait_return;
813 if (debug_break_level > 0) 813 if (debug_break_level > 0)
814 msg_silent = save_msg_silent; 814 msg_silent = save_msg_silent;
815 815
914 { 914 {
915 if (result) 915 if (result)
916 cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE; 916 cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE;
917 } 917 }
918 else 918 else
919 /* set TRUE, so this conditional will never get active */ 919 // set TRUE, so this conditional will never get active
920 cstack->cs_flags[cstack->cs_idx] = CSF_TRUE; 920 cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
921 } 921 }
922 } 922 }
923 923
924 /* 924 /*
990 } 990 }
991 eap->errmsg = N_("E584: :elseif after :else"); 991 eap->errmsg = N_("E584: :elseif after :else");
992 skip = TRUE; 992 skip = TRUE;
993 } 993 }
994 994
995 /* if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it */ 995 // if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it
996 if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE) 996 if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE)
997 { 997 {
998 if (eap->errmsg == NULL) 998 if (eap->errmsg == NULL)
999 cstack->cs_flags[cstack->cs_idx] = CSF_TRUE; 999 cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
1000 skip = TRUE; /* don't evaluate an ":elseif" */ 1000 skip = TRUE; // don't evaluate an ":elseif"
1001 } 1001 }
1002 else 1002 else
1003 cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE; 1003 cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE;
1004 1004
1005 /* 1005 /*
1019 } 1019 }
1020 1020
1021 if (eap->cmdidx == CMD_elseif) 1021 if (eap->cmdidx == CMD_elseif)
1022 { 1022 {
1023 result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip); 1023 result = eval_to_bool(eap->arg, &error, &eap->nextcmd, skip);
1024 /* When throwing error exceptions, we want to throw always the first 1024 // When throwing error exceptions, we want to throw always the first
1025 * of several errors in a row. This is what actually happens when 1025 // of several errors in a row. This is what actually happens when
1026 * a conditional error was detected above and there is another failure 1026 // a conditional error was detected above and there is another failure
1027 * when parsing the expression. Since the skip flag is set in this 1027 // when parsing the expression. Since the skip flag is set in this
1028 * case, the parsing error will be ignored by emsg(). */ 1028 // case, the parsing error will be ignored by emsg().
1029 1029
1030 if (!skip && !error) 1030 if (!skip && !error)
1031 { 1031 {
1032 if (result) 1032 if (result)
1033 cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE; 1033 cstack->cs_flags[cstack->cs_idx] = CSF_ACTIVE | CSF_TRUE;
1034 else 1034 else
1035 cstack->cs_flags[cstack->cs_idx] = 0; 1035 cstack->cs_flags[cstack->cs_idx] = 0;
1036 } 1036 }
1037 else if (eap->errmsg == NULL) 1037 else if (eap->errmsg == NULL)
1038 /* set TRUE, so this conditional will never get active */ 1038 // set TRUE, so this conditional will never get active
1039 cstack->cs_flags[cstack->cs_idx] = CSF_TRUE; 1039 cstack->cs_flags[cstack->cs_idx] = CSF_TRUE;
1040 } 1040 }
1041 else 1041 else
1042 cstack->cs_flags[cstack->cs_idx] |= CSF_ELSE; 1042 cstack->cs_flags[cstack->cs_idx] |= CSF_ELSE;
1043 } 1043 }
1091 /* 1091 /*
1092 * ":for var in list-expr" 1092 * ":for var in list-expr"
1093 */ 1093 */
1094 if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0) 1094 if ((cstack->cs_lflags & CSL_HAD_LOOP) != 0)
1095 { 1095 {
1096 /* Jumping here from a ":continue" or ":endfor": use the 1096 // Jumping here from a ":continue" or ":endfor": use the
1097 * previously evaluated list. */ 1097 // previously evaluated list.
1098 fi = cstack->cs_forinfo[cstack->cs_idx]; 1098 fi = cstack->cs_forinfo[cstack->cs_idx];
1099 error = FALSE; 1099 error = FALSE;
1100 } 1100 }
1101 else 1101 else
1102 { 1102 {
1103 /* Evaluate the argument and get the info in a structure. */ 1103 // Evaluate the argument and get the info in a structure.
1104 fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip); 1104 fi = eval_for_line(eap->arg, &error, &eap->nextcmd, skip);
1105 cstack->cs_forinfo[cstack->cs_idx] = fi; 1105 cstack->cs_forinfo[cstack->cs_idx] = fi;
1106 } 1106 }
1107 1107
1108 /* use the element at the start of the list and advance */ 1108 // use the element at the start of the list and advance
1109 if (!error && fi != NULL && !skip) 1109 if (!error && fi != NULL && !skip)
1110 result = next_for_item(fi, eap->arg); 1110 result = next_for_item(fi, eap->arg);
1111 else 1111 else
1112 result = FALSE; 1112 result = FALSE;
1113 1113
1129 cstack->cs_lflags ^= CSL_HAD_LOOP; 1129 cstack->cs_lflags ^= CSL_HAD_LOOP;
1130 } 1130 }
1131 else 1131 else
1132 { 1132 {
1133 cstack->cs_lflags &= ~CSL_HAD_LOOP; 1133 cstack->cs_lflags &= ~CSL_HAD_LOOP;
1134 /* If the ":while" evaluates to FALSE or ":for" is past the end of 1134 // If the ":while" evaluates to FALSE or ":for" is past the end of
1135 * the list, show the debug prompt at the ":endwhile"/":endfor" as 1135 // the list, show the debug prompt at the ":endwhile"/":endfor" as
1136 * if there was a ":break" in a ":while"/":for" evaluating to 1136 // if there was a ":break" in a ":while"/":for" evaluating to
1137 * TRUE. */ 1137 // TRUE.
1138 if (!skip && !error) 1138 if (!skip && !error)
1139 cstack->cs_flags[cstack->cs_idx] |= CSF_TRUE; 1139 cstack->cs_flags[cstack->cs_idx] |= CSF_TRUE;
1140 } 1140 }
1141 } 1141 }
1142 } 1142 }
1152 1152
1153 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) 1153 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
1154 eap->errmsg = N_("E586: :continue without :while or :for"); 1154 eap->errmsg = N_("E586: :continue without :while or :for");
1155 else 1155 else
1156 { 1156 {
1157 /* Try to find the matching ":while". This might stop at a try 1157 // Try to find the matching ":while". This might stop at a try
1158 * conditional not in its finally clause (which is then to be executed 1158 // conditional not in its finally clause (which is then to be executed
1159 * next). Therefor, inactivate all conditionals except the ":while" 1159 // next). Therefor, inactivate all conditionals except the ":while"
1160 * itself (if reached). */ 1160 // itself (if reached).
1161 idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE); 1161 idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
1162 if (idx >= 0 && (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR))) 1162 if (idx >= 0 && (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
1163 { 1163 {
1164 rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel); 1164 rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
1165 1165
1166 /* 1166 /*
1167 * Set CSL_HAD_CONT, so do_cmdline() will jump back to the 1167 * Set CSL_HAD_CONT, so do_cmdline() will jump back to the
1168 * matching ":while". 1168 * matching ":while".
1169 */ 1169 */
1170 cstack->cs_lflags |= CSL_HAD_CONT; /* let do_cmdline() handle it */ 1170 cstack->cs_lflags |= CSL_HAD_CONT; // let do_cmdline() handle it
1171 } 1171 }
1172 else 1172 else
1173 { 1173 {
1174 /* If a try conditional not in its finally clause is reached first, 1174 // If a try conditional not in its finally clause is reached first,
1175 * make the ":continue" pending for execution at the ":endtry". */ 1175 // make the ":continue" pending for execution at the ":endtry".
1176 cstack->cs_pending[idx] = CSTP_CONTINUE; 1176 cstack->cs_pending[idx] = CSTP_CONTINUE;
1177 report_make_pending(CSTP_CONTINUE, NULL); 1177 report_make_pending(CSTP_CONTINUE, NULL);
1178 } 1178 }
1179 } 1179 }
1180 } 1180 }
1190 1190
1191 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) 1191 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
1192 eap->errmsg = N_("E587: :break without :while or :for"); 1192 eap->errmsg = N_("E587: :break without :while or :for");
1193 else 1193 else
1194 { 1194 {
1195 /* Inactivate conditionals until the matching ":while" or a try 1195 // Inactivate conditionals until the matching ":while" or a try
1196 * conditional not in its finally clause (which is then to be 1196 // conditional not in its finally clause (which is then to be
1197 * executed next) is found. In the latter case, make the ":break" 1197 // executed next) is found. In the latter case, make the ":break"
1198 * pending for execution at the ":endtry". */ 1198 // pending for execution at the ":endtry".
1199 idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, TRUE); 1199 idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, TRUE);
1200 if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR))) 1200 if (idx >= 0 && !(cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))
1201 { 1201 {
1202 cstack->cs_pending[idx] = CSTP_BREAK; 1202 cstack->cs_pending[idx] = CSTP_BREAK;
1203 report_make_pending(CSTP_BREAK, NULL); 1203 report_make_pending(CSTP_BREAK, NULL);
1233 else 1233 else
1234 { 1234 {
1235 fl = cstack->cs_flags[cstack->cs_idx]; 1235 fl = cstack->cs_flags[cstack->cs_idx];
1236 if (!(fl & csf)) 1236 if (!(fl & csf))
1237 { 1237 {
1238 /* If we are in a ":while" or ":for" but used the wrong endloop 1238 // If we are in a ":while" or ":for" but used the wrong endloop
1239 * command, do not rewind to the next enclosing ":for"/":while". */ 1239 // command, do not rewind to the next enclosing ":for"/":while".
1240 if (fl & CSF_WHILE) 1240 if (fl & CSF_WHILE)
1241 eap->errmsg = _("E732: Using :endfor with :while"); 1241 eap->errmsg = _("E732: Using :endfor with :while");
1242 else if (fl & CSF_FOR) 1242 else if (fl & CSF_FOR)
1243 eap->errmsg = _("E733: Using :endwhile with :for"); 1243 eap->errmsg = _("E733: Using :endwhile with :for");
1244 } 1244 }
1246 { 1246 {
1247 if (!(fl & CSF_TRY)) 1247 if (!(fl & CSF_TRY))
1248 eap->errmsg = e_endif; 1248 eap->errmsg = e_endif;
1249 else if (fl & CSF_FINALLY) 1249 else if (fl & CSF_FINALLY)
1250 eap->errmsg = e_endtry; 1250 eap->errmsg = e_endtry;
1251 /* Try to find the matching ":while" and report what's missing. */ 1251 // Try to find the matching ":while" and report what's missing.
1252 for (idx = cstack->cs_idx; idx > 0; --idx) 1252 for (idx = cstack->cs_idx; idx > 0; --idx)
1253 { 1253 {
1254 fl = cstack->cs_flags[idx]; 1254 fl = cstack->cs_flags[idx];
1255 if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) 1255 if ((fl & CSF_TRY) && !(fl & CSF_FINALLY))
1256 { 1256 {
1257 /* Give up at a try conditional not in its finally clause. 1257 // Give up at a try conditional not in its finally clause.
1258 * Ignore the ":endwhile"/":endfor". */ 1258 // Ignore the ":endwhile"/":endfor".
1259 eap->errmsg = err; 1259 eap->errmsg = err;
1260 return; 1260 return;
1261 } 1261 }
1262 if (fl & csf) 1262 if (fl & csf)
1263 break; 1263 break;
1264 } 1264 }
1265 /* Cleanup and rewind all contained (and unclosed) conditionals. */ 1265 // Cleanup and rewind all contained (and unclosed) conditionals.
1266 (void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE); 1266 (void)cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
1267 rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel); 1267 rewind_conditionals(cstack, idx, CSF_TRY, &cstack->cs_trylevel);
1268 } 1268 }
1269 1269
1270 /* 1270 /*
1306 { 1306 {
1307 emsg(_(e_argreq)); 1307 emsg(_(e_argreq));
1308 value = NULL; 1308 value = NULL;
1309 } 1309 }
1310 1310
1311 /* On error or when an exception is thrown during argument evaluation, do 1311 // On error or when an exception is thrown during argument evaluation, do
1312 * not throw. */ 1312 // not throw.
1313 if (!eap->skip && value != NULL) 1313 if (!eap->skip && value != NULL)
1314 { 1314 {
1315 if (throw_exception(value, ET_USER, NULL) == FAIL) 1315 if (throw_exception(value, ET_USER, NULL) == FAIL)
1316 vim_free(value); 1316 vim_free(value);
1317 else 1317 else
1372 if (!(cstack->cs_flags[idx] & CSF_CAUGHT)) 1372 if (!(cstack->cs_flags[idx] & CSF_CAUGHT))
1373 { 1373 {
1374 if (cstack->cs_flags[idx] & CSF_ACTIVE) 1374 if (cstack->cs_flags[idx] & CSF_ACTIVE)
1375 cstack->cs_flags[idx] |= CSF_THROWN; 1375 cstack->cs_flags[idx] |= CSF_THROWN;
1376 else 1376 else
1377 /* THROWN may have already been set for a catchable exception 1377 // THROWN may have already been set for a catchable exception
1378 * that has been discarded. Ensure it is reset for the new 1378 // that has been discarded. Ensure it is reset for the new
1379 * exception. */ 1379 // exception.
1380 cstack->cs_flags[idx] &= ~CSF_THROWN; 1380 cstack->cs_flags[idx] &= ~CSF_THROWN;
1381 } 1381 }
1382 cstack->cs_flags[idx] &= ~CSF_ACTIVE; 1382 cstack->cs_flags[idx] &= ~CSF_ACTIVE;
1383 cstack->cs_exception[idx] = current_exception; 1383 cstack->cs_exception[idx] = current_exception;
1384 } 1384 }
1385 #if 0 1385 #if 0
1386 /* TODO: Add optimization below. Not yet done because of interface 1386 // TODO: Add optimization below. Not yet done because of interface
1387 * problems to eval.c and ex_cmds2.c. (Servatius) */ 1387 // problems to eval.c and ex_cmds2.c. (Servatius)
1388 else 1388 else
1389 { 1389 {
1390 /* 1390 /*
1391 * There are no catch clauses to check or finally clauses to execute. 1391 * There are no catch clauses to check or finally clauses to execute.
1392 * End the current script or function. The exception will be rethrown 1392 * End the current script or function. The exception will be rethrown
1427 skip = did_emsg || got_int || did_throw || (cstack->cs_idx > 0 1427 skip = did_emsg || got_int || did_throw || (cstack->cs_idx > 0
1428 && !(cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE)); 1428 && !(cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE));
1429 1429
1430 if (!skip) 1430 if (!skip)
1431 { 1431 {
1432 /* Set ACTIVE and TRUE. TRUE means that the corresponding ":catch" 1432 // Set ACTIVE and TRUE. TRUE means that the corresponding ":catch"
1433 * commands should check for a match if an exception is thrown and 1433 // commands should check for a match if an exception is thrown and
1434 * that the finally clause needs to be executed. */ 1434 // that the finally clause needs to be executed.
1435 cstack->cs_flags[cstack->cs_idx] |= CSF_ACTIVE | CSF_TRUE; 1435 cstack->cs_flags[cstack->cs_idx] |= CSF_ACTIVE | CSF_TRUE;
1436 1436
1437 /* 1437 /*
1438 * ":silent!", even when used in a try conditional, disables 1438 * ":silent!", even when used in a try conditional, disables
1439 * displaying of error messages and conversion of errors to 1439 * displaying of error messages and conversion of errors to
1496 } 1496 }
1497 else 1497 else
1498 { 1498 {
1499 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) 1499 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
1500 { 1500 {
1501 /* Report what's missing if the matching ":try" is not in its 1501 // Report what's missing if the matching ":try" is not in its
1502 * finally clause. */ 1502 // finally clause.
1503 eap->errmsg = get_end_emsg(cstack); 1503 eap->errmsg = get_end_emsg(cstack);
1504 skip = TRUE; 1504 skip = TRUE;
1505 } 1505 }
1506 for (idx = cstack->cs_idx; idx > 0; --idx) 1506 for (idx = cstack->cs_idx; idx > 0; --idx)
1507 if (cstack->cs_flags[idx] & CSF_TRY) 1507 if (cstack->cs_flags[idx] & CSF_TRY)
1508 break; 1508 break;
1509 if (cstack->cs_flags[idx] & CSF_FINALLY) 1509 if (cstack->cs_flags[idx] & CSF_FINALLY)
1510 { 1510 {
1511 /* Give up for a ":catch" after ":finally" and ignore it. 1511 // Give up for a ":catch" after ":finally" and ignore it.
1512 * Just parse. */ 1512 // Just parse.
1513 eap->errmsg = N_("E604: :catch after :finally"); 1513 eap->errmsg = N_("E604: :catch after :finally");
1514 give_up = TRUE; 1514 give_up = TRUE;
1515 } 1515 }
1516 else 1516 else
1517 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, 1517 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
1518 &cstack->cs_looplevel); 1518 &cstack->cs_looplevel);
1519 } 1519 }
1520 1520
1521 if (ends_excmd(*eap->arg)) /* no argument, catch all errors */ 1521 if (ends_excmd(*eap->arg)) // no argument, catch all errors
1522 { 1522 {
1523 pat = (char_u *)".*"; 1523 pat = (char_u *)".*";
1524 end = NULL; 1524 end = NULL;
1525 eap->nextcmd = find_nextcmd(eap->arg); 1525 eap->nextcmd = find_nextcmd(eap->arg);
1526 } 1526 }
1552 { 1552 {
1553 emsg(_(e_trailing)); 1553 emsg(_(e_trailing));
1554 return; 1554 return;
1555 } 1555 }
1556 1556
1557 /* When debugging or a breakpoint was encountered, display the 1557 // When debugging or a breakpoint was encountered, display the
1558 * debug prompt (if not already done) before checking for a match. 1558 // debug prompt (if not already done) before checking for a match.
1559 * This is a helpful hint for the user when the regular expression 1559 // This is a helpful hint for the user when the regular expression
1560 * matching fails. Handle a ">quit" debug command as if an 1560 // matching fails. Handle a ">quit" debug command as if an
1561 * interrupt had occurred before the ":catch". That is, discard 1561 // interrupt had occurred before the ":catch". That is, discard
1562 * the original exception, replace it by an interrupt exception, 1562 // the original exception, replace it by an interrupt exception,
1563 * and don't catch it in this try block. */ 1563 // and don't catch it in this try block.
1564 if (!dbg_check_skipped(eap) || !do_intthrow(cstack)) 1564 if (!dbg_check_skipped(eap) || !do_intthrow(cstack))
1565 { 1565 {
1566 /* Terminate the pattern and avoid the 'l' flag in 'cpoptions' 1566 // Terminate the pattern and avoid the 'l' flag in 'cpoptions'
1567 * while compiling it. */ 1567 // while compiling it.
1568 if (end != NULL) 1568 if (end != NULL)
1569 { 1569 {
1570 save_char = *end; 1570 save_char = *end;
1571 *end = NUL; 1571 *end = NUL;
1572 } 1572 }
1573 save_cpo = p_cpo; 1573 save_cpo = p_cpo;
1574 p_cpo = (char_u *)""; 1574 p_cpo = (char_u *)"";
1575 /* Disable error messages, it will make current_exception 1575 // Disable error messages, it will make current_exception
1576 * invalid. */ 1576 // invalid.
1577 ++emsg_off; 1577 ++emsg_off;
1578 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING); 1578 regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
1579 --emsg_off; 1579 --emsg_off;
1580 regmatch.rm_ic = FALSE; 1580 regmatch.rm_ic = FALSE;
1581 if (end != NULL) 1581 if (end != NULL)
1600 } 1600 }
1601 } 1601 }
1602 1602
1603 if (caught) 1603 if (caught)
1604 { 1604 {
1605 /* Make this ":catch" clause active and reset did_emsg, got_int, 1605 // Make this ":catch" clause active and reset did_emsg, got_int,
1606 * and did_throw. Put the exception on the caught stack. */ 1606 // and did_throw. Put the exception on the caught stack.
1607 cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT; 1607 cstack->cs_flags[idx] |= CSF_ACTIVE | CSF_CAUGHT;
1608 did_emsg = got_int = did_throw = FALSE; 1608 did_emsg = got_int = did_throw = FALSE;
1609 catch_exception((except_T *)cstack->cs_exception[idx]); 1609 catch_exception((except_T *)cstack->cs_exception[idx]);
1610 /* It's mandatory that the current exception is stored in the cstack 1610 // It's mandatory that the current exception is stored in the cstack
1611 * so that it can be discarded at the next ":catch", ":finally", or 1611 // so that it can be discarded at the next ":catch", ":finally", or
1612 * ":endtry" or when the catch clause is left by a ":continue", 1612 // ":endtry" or when the catch clause is left by a ":continue",
1613 * ":break", ":return", ":finish", error, interrupt, or another 1613 // ":break", ":return", ":finish", error, interrupt, or another
1614 * exception. */ 1614 // exception.
1615 if (cstack->cs_exception[cstack->cs_idx] != current_exception) 1615 if (cstack->cs_exception[cstack->cs_idx] != current_exception)
1616 internal_error("ex_catch()"); 1616 internal_error("ex_catch()");
1617 } 1617 }
1618 else 1618 else
1619 { 1619 {
1654 { 1654 {
1655 eap->errmsg = get_end_emsg(cstack); 1655 eap->errmsg = get_end_emsg(cstack);
1656 for (idx = cstack->cs_idx - 1; idx > 0; --idx) 1656 for (idx = cstack->cs_idx - 1; idx > 0; --idx)
1657 if (cstack->cs_flags[idx] & CSF_TRY) 1657 if (cstack->cs_flags[idx] & CSF_TRY)
1658 break; 1658 break;
1659 /* Make this error pending, so that the commands in the following 1659 // Make this error pending, so that the commands in the following
1660 * finally clause can be executed. This overrules also a pending 1660 // finally clause can be executed. This overrules also a pending
1661 * ":continue", ":break", ":return", or ":finish". */ 1661 // ":continue", ":break", ":return", or ":finish".
1662 pending = CSTP_ERROR; 1662 pending = CSTP_ERROR;
1663 } 1663 }
1664 else 1664 else
1665 idx = cstack->cs_idx; 1665 idx = cstack->cs_idx;
1666 1666
1667 if (cstack->cs_flags[idx] & CSF_FINALLY) 1667 if (cstack->cs_flags[idx] & CSF_FINALLY)
1668 { 1668 {
1669 /* Give up for a multiple ":finally" and ignore it. */ 1669 // Give up for a multiple ":finally" and ignore it.
1670 eap->errmsg = N_("E607: multiple :finally"); 1670 eap->errmsg = N_("E607: multiple :finally");
1671 return; 1671 return;
1672 } 1672 }
1673 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, 1673 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
1674 &cstack->cs_looplevel); 1674 &cstack->cs_looplevel);
1683 */ 1683 */
1684 skip = !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE); 1684 skip = !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE);
1685 1685
1686 if (!skip) 1686 if (!skip)
1687 { 1687 {
1688 /* When debugging or a breakpoint was encountered, display the 1688 // When debugging or a breakpoint was encountered, display the
1689 * debug prompt (if not already done). The user then knows that the 1689 // debug prompt (if not already done). The user then knows that the
1690 * finally clause is executed. */ 1690 // finally clause is executed.
1691 if (dbg_check_skipped(eap)) 1691 if (dbg_check_skipped(eap))
1692 { 1692 {
1693 /* Handle a ">quit" debug command as if an interrupt had 1693 // Handle a ">quit" debug command as if an interrupt had
1694 * occurred before the ":finally". That is, discard the 1694 // occurred before the ":finally". That is, discard the
1695 * original exception and replace it by an interrupt 1695 // original exception and replace it by an interrupt
1696 * exception. */ 1696 // exception.
1697 (void)do_intthrow(cstack); 1697 (void)do_intthrow(cstack);
1698 } 1698 }
1699 1699
1700 /* 1700 /*
1701 * If there is a preceding catch clause and it caught the exception, 1701 * If there is a preceding catch clause and it caught the exception,
1736 pending |= did_throw ? CSTP_THROW : 0; 1736 pending |= did_throw ? CSTP_THROW : 0;
1737 pending |= did_emsg ? CSTP_ERROR : 0; 1737 pending |= did_emsg ? CSTP_ERROR : 0;
1738 pending |= got_int ? CSTP_INTERRUPT : 0; 1738 pending |= got_int ? CSTP_INTERRUPT : 0;
1739 cstack->cs_pending[cstack->cs_idx] = pending; 1739 cstack->cs_pending[cstack->cs_idx] = pending;
1740 1740
1741 /* It's mandatory that the current exception is stored in the 1741 // It's mandatory that the current exception is stored in the
1742 * cstack so that it can be rethrown at the ":endtry" or be 1742 // cstack so that it can be rethrown at the ":endtry" or be
1743 * discarded if the finally clause is left by a ":continue", 1743 // discarded if the finally clause is left by a ":continue",
1744 * ":break", ":return", ":finish", error, interrupt, or another 1744 // ":break", ":return", ":finish", error, interrupt, or another
1745 * exception. When emsg() is called for a missing ":endif" or 1745 // exception. When emsg() is called for a missing ":endif" or
1746 * a missing ":endwhile"/":endfor" detected here, the 1746 // a missing ":endwhile"/":endfor" detected here, the
1747 * exception will be discarded. */ 1747 // exception will be discarded.
1748 if (did_throw && cstack->cs_exception[cstack->cs_idx] 1748 if (did_throw && cstack->cs_exception[cstack->cs_idx]
1749 != current_exception) 1749 != current_exception)
1750 internal_error("ex_finally()"); 1750 internal_error("ex_finally()");
1751 } 1751 }
1752 1752
1794 !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE); 1794 !(cstack->cs_flags[cstack->cs_idx] & CSF_TRUE);
1795 1795
1796 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) 1796 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
1797 { 1797 {
1798 eap->errmsg = get_end_emsg(cstack); 1798 eap->errmsg = get_end_emsg(cstack);
1799 /* Find the matching ":try" and report what's missing. */ 1799 // Find the matching ":try" and report what's missing.
1800 idx = cstack->cs_idx; 1800 idx = cstack->cs_idx;
1801 do 1801 do
1802 --idx; 1802 --idx;
1803 while (idx > 0 && !(cstack->cs_flags[idx] & CSF_TRY)); 1803 while (idx > 0 && !(cstack->cs_flags[idx] & CSF_TRY));
1804 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, 1804 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
1828 if (did_throw && (cstack->cs_flags[idx] & CSF_TRUE) 1828 if (did_throw && (cstack->cs_flags[idx] & CSF_TRUE)
1829 && !(cstack->cs_flags[idx] & CSF_FINALLY)) 1829 && !(cstack->cs_flags[idx] & CSF_FINALLY))
1830 rethrow = TRUE; 1830 rethrow = TRUE;
1831 } 1831 }
1832 1832
1833 /* If there was no finally clause, show the user when debugging or 1833 // If there was no finally clause, show the user when debugging or
1834 * a breakpoint was encountered that the end of the try conditional has 1834 // a breakpoint was encountered that the end of the try conditional has
1835 * been reached: display the debug prompt (if not already done). Do 1835 // been reached: display the debug prompt (if not already done). Do
1836 * this on normal control flow or when an exception was thrown, but not 1836 // this on normal control flow or when an exception was thrown, but not
1837 * on an interrupt or error not converted to an exception or when 1837 // on an interrupt or error not converted to an exception or when
1838 * a ":break", ":continue", ":return", or ":finish" is pending. These 1838 // a ":break", ":continue", ":return", or ":finish" is pending. These
1839 * actions are carried out immediately. 1839 // actions are carried out immediately.
1840 */
1841 if ((rethrow || (!skip 1840 if ((rethrow || (!skip
1842 && !(cstack->cs_flags[idx] & CSF_FINALLY) 1841 && !(cstack->cs_flags[idx] & CSF_FINALLY)
1843 && !cstack->cs_pending[idx])) 1842 && !cstack->cs_pending[idx]))
1844 && dbg_check_skipped(eap)) 1843 && dbg_check_skipped(eap))
1845 { 1844 {
1846 /* Handle a ">quit" debug command as if an interrupt had occurred 1845 // Handle a ">quit" debug command as if an interrupt had occurred
1847 * before the ":endtry". That is, throw an interrupt exception and 1846 // before the ":endtry". That is, throw an interrupt exception and
1848 * set "skip" and "rethrow". */ 1847 // set "skip" and "rethrow".
1849 if (got_int) 1848 if (got_int)
1850 { 1849 {
1851 skip = TRUE; 1850 skip = TRUE;
1852 (void)do_intthrow(cstack); 1851 (void)do_intthrow(cstack);
1853 /* The do_intthrow() call may have reset did_throw or 1852 // The do_intthrow() call may have reset did_throw or
1854 * cstack->cs_pending[idx].*/ 1853 // cstack->cs_pending[idx].
1855 rethrow = FALSE; 1854 rethrow = FALSE;
1856 if (did_throw && !(cstack->cs_flags[idx] & CSF_FINALLY)) 1855 if (did_throw && !(cstack->cs_flags[idx] & CSF_FINALLY))
1857 rethrow = TRUE; 1856 rethrow = TRUE;
1858 } 1857 }
1859 } 1858 }
1897 switch (pending) 1896 switch (pending)
1898 { 1897 {
1899 case CSTP_NONE: 1898 case CSTP_NONE:
1900 break; 1899 break;
1901 1900
1902 /* Reactivate a pending ":continue", ":break", ":return", 1901 // Reactivate a pending ":continue", ":break", ":return",
1903 * ":finish" from the try block or a catch clause of this try 1902 // ":finish" from the try block or a catch clause of this try
1904 * conditional. This is skipped, if there was an error in an 1903 // conditional. This is skipped, if there was an error in an
1905 * (unskipped) conditional command or an interrupt afterwards 1904 // (unskipped) conditional command or an interrupt afterwards
1906 * or if the finally clause is present and executed a new error, 1905 // or if the finally clause is present and executed a new error,
1907 * interrupt, throw, ":continue", ":break", ":return", or 1906 // interrupt, throw, ":continue", ":break", ":return", or
1908 * ":finish". */ 1907 // ":finish".
1909 case CSTP_CONTINUE: 1908 case CSTP_CONTINUE:
1910 ex_continue(eap); 1909 ex_continue(eap);
1911 break; 1910 break;
1912 case CSTP_BREAK: 1911 case CSTP_BREAK:
1913 ex_break(eap); 1912 ex_break(eap);
1917 break; 1916 break;
1918 case CSTP_FINISH: 1917 case CSTP_FINISH:
1919 do_finish(eap, FALSE); 1918 do_finish(eap, FALSE);
1920 break; 1919 break;
1921 1920
1922 /* When the finally clause was entered due to an error, 1921 // When the finally clause was entered due to an error,
1923 * interrupt or throw (as opposed to a ":continue", ":break", 1922 // interrupt or throw (as opposed to a ":continue", ":break",
1924 * ":return", or ":finish"), restore the pending values of 1923 // ":return", or ":finish"), restore the pending values of
1925 * did_emsg, got_int, and did_throw. This is skipped, if there 1924 // did_emsg, got_int, and did_throw. This is skipped, if there
1926 * was a new error, interrupt, throw, ":continue", ":break", 1925 // was a new error, interrupt, throw, ":continue", ":break",
1927 * ":return", or ":finish". in the finally clause. */ 1926 // ":return", or ":finish". in the finally clause.
1928 default: 1927 default:
1929 if (pending & CSTP_ERROR) 1928 if (pending & CSTP_ERROR)
1930 did_emsg = TRUE; 1929 did_emsg = TRUE;
1931 if (pending & CSTP_INTERRUPT) 1930 if (pending & CSTP_INTERRUPT)
1932 got_int = TRUE; 1931 got_int = TRUE;
1935 break; 1934 break;
1936 } 1935 }
1937 } 1936 }
1938 1937
1939 if (rethrow) 1938 if (rethrow)
1940 /* Rethrow the current exception (within this cstack). */ 1939 // Rethrow the current exception (within this cstack).
1941 do_throw(cstack); 1940 do_throw(cstack);
1942 } 1941 }
1943 } 1942 }
1944 1943
1945 /* 1944 /*
1978 csp->pending = (did_emsg ? CSTP_ERROR : 0) 1977 csp->pending = (did_emsg ? CSTP_ERROR : 0)
1979 | (got_int ? CSTP_INTERRUPT : 0) 1978 | (got_int ? CSTP_INTERRUPT : 0)
1980 | (did_throw ? CSTP_THROW : 0) 1979 | (did_throw ? CSTP_THROW : 0)
1981 | (need_rethrow ? CSTP_THROW : 0); 1980 | (need_rethrow ? CSTP_THROW : 0);
1982 1981
1983 /* If we are currently throwing an exception (did_throw), save it as 1982 // If we are currently throwing an exception (did_throw), save it as
1984 * well. On an error not yet converted to an exception, update 1983 // well. On an error not yet converted to an exception, update
1985 * "force_abort" and reset "cause_abort" (as do_errthrow() would do). 1984 // "force_abort" and reset "cause_abort" (as do_errthrow() would do).
1986 * This is needed for the do_cmdline() call that is going to be made 1985 // This is needed for the do_cmdline() call that is going to be made
1987 * for autocommand execution. We need not save *msg_list because 1986 // for autocommand execution. We need not save *msg_list because
1988 * there is an extra instance for every call of do_cmdline(), anyway. 1987 // there is an extra instance for every call of do_cmdline(), anyway.
1989 */
1990 if (did_throw || need_rethrow) 1988 if (did_throw || need_rethrow)
1991 { 1989 {
1992 csp->exception = current_exception; 1990 csp->exception = current_exception;
1993 current_exception = NULL; 1991 current_exception = NULL;
1994 } 1992 }
2001 cause_abort = FALSE; 1999 cause_abort = FALSE;
2002 } 2000 }
2003 } 2001 }
2004 did_emsg = got_int = did_throw = need_rethrow = FALSE; 2002 did_emsg = got_int = did_throw = need_rethrow = FALSE;
2005 2003
2006 /* Report if required by the 'verbose' option or when debugging. */ 2004 // Report if required by the 'verbose' option or when debugging.
2007 report_make_pending(pending, csp->exception); 2005 report_make_pending(pending, csp->exception);
2008 } 2006 }
2009 else 2007 else
2010 { 2008 {
2011 csp->pending = CSTP_NONE; 2009 csp->pending = CSTP_NONE;
2031 void 2029 void
2032 leave_cleanup(cleanup_T *csp) 2030 leave_cleanup(cleanup_T *csp)
2033 { 2031 {
2034 int pending = csp->pending; 2032 int pending = csp->pending;
2035 2033
2036 if (pending == CSTP_NONE) /* nothing to do */ 2034 if (pending == CSTP_NONE) // nothing to do
2037 return; 2035 return;
2038 2036
2039 /* If there was an aborting error, an interrupt, or an uncaught exception 2037 // If there was an aborting error, an interrupt, or an uncaught exception
2040 * after the corresponding call to enter_cleanup(), discard what has been 2038 // after the corresponding call to enter_cleanup(), discard what has been
2041 * made pending by it. Report this to the user if required by the 2039 // made pending by it. Report this to the user if required by the
2042 * 'verbose' option or when debugging. */ 2040 // 'verbose' option or when debugging.
2043 if (aborting() || need_rethrow) 2041 if (aborting() || need_rethrow)
2044 { 2042 {
2045 if (pending & CSTP_THROW) 2043 if (pending & CSTP_THROW)
2046 /* Cancel the pending exception (includes report). */ 2044 // Cancel the pending exception (includes report).
2047 discard_exception((except_T *)csp->exception, FALSE); 2045 discard_exception((except_T *)csp->exception, FALSE);
2048 else 2046 else
2049 report_discard_pending(pending, NULL); 2047 report_discard_pending(pending, NULL);
2050 2048
2051 /* If an error was about to be converted to an exception when 2049 // If an error was about to be converted to an exception when
2052 * enter_cleanup() was called, free the message list. */ 2050 // enter_cleanup() was called, free the message list.
2053 if (msg_list != NULL) 2051 if (msg_list != NULL)
2054 free_global_msglist(); 2052 free_global_msglist();
2055 } 2053 }
2056 2054
2057 /* 2055 /*
2086 if (pending & CSTP_ERROR) 2084 if (pending & CSTP_ERROR)
2087 did_emsg = TRUE; 2085 did_emsg = TRUE;
2088 if (pending & CSTP_INTERRUPT) 2086 if (pending & CSTP_INTERRUPT)
2089 got_int = TRUE; 2087 got_int = TRUE;
2090 if (pending & CSTP_THROW) 2088 if (pending & CSTP_THROW)
2091 need_rethrow = TRUE; /* did_throw will be set by do_one_cmd() */ 2089 need_rethrow = TRUE; // did_throw will be set by do_one_cmd()
2092 2090
2093 /* Report if required by the 'verbose' option or when debugging. */ 2091 // Report if required by the 'verbose' option or when debugging.
2094 report_resume_pending(pending, 2092 report_resume_pending(pending,
2095 (pending & CSTP_THROW) ? (void *)current_exception : NULL); 2093 (pending & CSTP_THROW) ? (void *)current_exception : NULL);
2096 } 2094 }
2097 } 2095 }
2098 2096
2156 default: 2154 default:
2157 if (cstack->cs_flags[idx] & CSF_FINALLY) 2155 if (cstack->cs_flags[idx] & CSF_FINALLY)
2158 { 2156 {
2159 if (cstack->cs_pending[idx] & CSTP_THROW) 2157 if (cstack->cs_pending[idx] & CSTP_THROW)
2160 { 2158 {
2161 /* Cancel the pending exception. This is in the 2159 // Cancel the pending exception. This is in the
2162 * finally clause, so that the stack of the 2160 // finally clause, so that the stack of the
2163 * caught exceptions is not involved. */ 2161 // caught exceptions is not involved.
2164 discard_exception((except_T *) 2162 discard_exception((except_T *)
2165 cstack->cs_exception[idx], 2163 cstack->cs_exception[idx],
2166 FALSE); 2164 FALSE);
2167 } 2165 }
2168 else 2166 else
2182 if (!(cstack->cs_flags[idx] & CSF_FINALLY)) 2180 if (!(cstack->cs_flags[idx] & CSF_FINALLY))
2183 { 2181 {
2184 if ((cstack->cs_flags[idx] & CSF_ACTIVE) 2182 if ((cstack->cs_flags[idx] & CSF_ACTIVE)
2185 && (cstack->cs_flags[idx] & CSF_CAUGHT)) 2183 && (cstack->cs_flags[idx] & CSF_CAUGHT))
2186 finish_exception((except_T *)cstack->cs_exception[idx]); 2184 finish_exception((except_T *)cstack->cs_exception[idx]);
2187 /* Stop at this try conditional - except the try block never 2185 // Stop at this try conditional - except the try block never
2188 * got active (because of an inactive surrounding conditional 2186 // got active (because of an inactive surrounding conditional
2189 * or when the ":try" appeared after an error or interrupt or 2187 // or when the ":try" appeared after an error or interrupt or
2190 * throw). */ 2188 // throw).
2191 if (cstack->cs_flags[idx] & CSF_TRUE) 2189 if (cstack->cs_flags[idx] & CSF_TRUE)
2192 { 2190 {
2193 if (searched_cond == 0 && !inclusive) 2191 if (searched_cond == 0 && !inclusive)
2194 break; 2192 break;
2195 stop = TRUE; 2193 stop = TRUE;
2196 } 2194 }
2197 } 2195 }
2198 } 2196 }
2199 2197
2200 /* Stop on the searched conditional type (even when the surrounding 2198 // Stop on the searched conditional type (even when the surrounding
2201 * conditional is not active or something has been made pending). 2199 // conditional is not active or something has been made pending).
2202 * If "inclusive" is TRUE and "searched_cond" is CSF_TRY|CSF_SILENT, 2200 // If "inclusive" is TRUE and "searched_cond" is CSF_TRY|CSF_SILENT,
2203 * check first whether "emsg_silent" needs to be restored. */ 2201 // check first whether "emsg_silent" needs to be restored.
2204 if (cstack->cs_flags[idx] & searched_cond) 2202 if (cstack->cs_flags[idx] & searched_cond)
2205 { 2203 {
2206 if (!inclusive) 2204 if (!inclusive)
2207 break; 2205 break;
2208 stop = TRUE; 2206 stop = TRUE;
2286 int 2284 int
2287 has_loop_cmd(char_u *p) 2285 has_loop_cmd(char_u *p)
2288 { 2286 {
2289 int len; 2287 int len;
2290 2288
2291 /* skip modifiers, white space and ':' */ 2289 // skip modifiers, white space and ':'
2292 for (;;) 2290 for (;;)
2293 { 2291 {
2294 while (*p == ' ' || *p == '\t' || *p == ':') 2292 while (*p == ' ' || *p == '\t' || *p == ':')
2295 ++p; 2293 ++p;
2296 len = modifier_len(p); 2294 len = modifier_len(p);
2302 || (p[0] == 'f' && p[1] == 'o' && p[2] == 'r')) 2300 || (p[0] == 'f' && p[1] == 'o' && p[2] == 'r'))
2303 return TRUE; 2301 return TRUE;
2304 return FALSE; 2302 return FALSE;
2305 } 2303 }
2306 2304
2307 #endif /* FEAT_EVAL */ 2305 #endif // FEAT_EVAL