comparison src/ex_eval.c @ 15470:55ccc2d353bd v8.1.0743

patch 8.1.0743: giving error messages is not flexible commit https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 13 23:38:42 2019 +0100 patch 8.1.0743: giving error messages is not flexible Problem: Giving error messages is not flexible. Solution: Add semsg(). Change argument from "char_u *" to "char *", also for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes #3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Jan 2019 23:45:08 +0100
parents 27b9a84395b5
children dd725a8ab112
comparison
equal deleted inserted replaced
15469:bc9b5261ed01 15470:55ccc2d353bd
14 #include "vim.h" 14 #include "vim.h"
15 15
16 #if defined(FEAT_EVAL) || defined(PROTO) 16 #if defined(FEAT_EVAL) || defined(PROTO)
17 17
18 static int throw_exception(void *, except_type_T, char_u *); 18 static int throw_exception(void *, except_type_T, char_u *);
19 static char_u *get_end_emsg(struct condstack *cstack); 19 static char *get_end_emsg(struct condstack *cstack);
20 20
21 /* 21 /*
22 * Exception handling terms: 22 * Exception handling terms:
23 * 23 *
24 * :try ":try" command \ 24 * :try ":try" command \
253 253
254 elem = (struct msglist *)alloc((unsigned)sizeof(struct msglist)); 254 elem = (struct msglist *)alloc((unsigned)sizeof(struct msglist));
255 if (elem == NULL) 255 if (elem == NULL)
256 { 256 {
257 suppress_errthrow = TRUE; 257 suppress_errthrow = TRUE;
258 EMSG(_(e_outofmem)); 258 emsg(_(e_outofmem));
259 } 259 }
260 else 260 else
261 { 261 {
262 elem->msg = vim_strsave(mesg); 262 elem->msg = (char *)vim_strsave(mesg);
263 if (elem->msg == NULL) 263 if (elem->msg == NULL)
264 { 264 {
265 vim_free(elem); 265 vim_free(elem);
266 suppress_errthrow = TRUE; 266 suppress_errthrow = TRUE;
267 EMSG(_(e_outofmem)); 267 emsg(_(e_outofmem));
268 } 268 }
269 else 269 else
270 { 270 {
271 elem->next = NULL; 271 elem->next = NULL;
272 elem->throw_msg = NULL; 272 elem->throw_msg = NULL;
273 *plist = elem; 273 *plist = elem;
274 if (plist == msg_list || severe) 274 if (plist == msg_list || severe)
275 { 275 {
276 char_u *tmsg; 276 char *tmsg;
277 277
278 /* Skip the extra "Vim " prefix for message "E458". */ 278 /* Skip the extra "Vim " prefix for message "E458". */
279 tmsg = elem->msg; 279 tmsg = elem->msg;
280 if (STRNCMP(tmsg, "Vim E", 5) == 0 280 if (STRNCMP(tmsg, "Vim E", 5) == 0
281 && VIM_ISDIGIT(tmsg[5]) 281 && VIM_ISDIGIT(tmsg[5])
411 } 411 }
412 412
413 /* 413 /*
414 * Get an exception message that is to be stored in current_exception->value. 414 * Get an exception message that is to be stored in current_exception->value.
415 */ 415 */
416 char_u * 416 char *
417 get_exception_string( 417 get_exception_string(
418 void *value, 418 void *value,
419 except_type_T type, 419 except_type_T type,
420 char_u *cmdname, 420 char_u *cmdname,
421 int *should_free) 421 int *should_free)
422 { 422 {
423 char_u *ret, *mesg; 423 char *ret;
424 char *mesg;
424 int cmdlen; 425 int cmdlen;
425 char_u *p, *val; 426 char *p, *val;
426 427
427 if (type == ET_ERROR) 428 if (type == ET_ERROR)
428 { 429 {
429 *should_free = TRUE; 430 *should_free = TRUE;
430 mesg = ((struct msglist *)value)->throw_msg; 431 mesg = ((struct msglist *)value)->throw_msg;
431 if (cmdname != NULL && *cmdname != NUL) 432 if (cmdname != NULL && *cmdname != NUL)
432 { 433 {
433 cmdlen = (int)STRLEN(cmdname); 434 cmdlen = (int)STRLEN(cmdname);
434 ret = vim_strnsave((char_u *)"Vim(", 435 ret = (char *)vim_strnsave((char_u *)"Vim(",
435 4 + cmdlen + 2 + (int)STRLEN(mesg)); 436 4 + cmdlen + 2 + (int)STRLEN(mesg));
436 if (ret == NULL) 437 if (ret == NULL)
437 return ret; 438 return ret;
438 STRCPY(&ret[4], cmdname); 439 STRCPY(&ret[4], cmdname);
439 STRCPY(&ret[4 + cmdlen], "):"); 440 STRCPY(&ret[4 + cmdlen], "):");
440 val = ret + 4 + cmdlen + 2; 441 val = ret + 4 + cmdlen + 2;
441 } 442 }
442 else 443 else
443 { 444 {
444 ret = vim_strnsave((char_u *)"Vim:", 4 + (int)STRLEN(mesg)); 445 ret = (char *)vim_strnsave((char_u *)"Vim:", 4 + (int)STRLEN(mesg));
445 if (ret == NULL) 446 if (ret == NULL)
446 return ret; 447 return ret;
447 val = ret + 4; 448 val = ret + 4;
448 } 449 }
449 450
481 } 482 }
482 } 483 }
483 else 484 else
484 { 485 {
485 *should_free = FALSE; 486 *should_free = FALSE;
486 ret = (char_u *)value; 487 ret = value;
487 } 488 }
488 489
489 return ret; 490 return ret;
490 } 491 }
491 492
511 { 512 {
512 if (STRNCMP((char_u *)value, "Vim", 3) == 0 513 if (STRNCMP((char_u *)value, "Vim", 3) == 0
513 && (((char_u *)value)[3] == NUL || ((char_u *)value)[3] == ':' 514 && (((char_u *)value)[3] == NUL || ((char_u *)value)[3] == ':'
514 || ((char_u *)value)[3] == '(')) 515 || ((char_u *)value)[3] == '('))
515 { 516 {
516 EMSG(_("E608: Cannot :throw exceptions with 'Vim' prefix")); 517 emsg(_("E608: Cannot :throw exceptions with 'Vim' prefix"));
517 goto fail; 518 goto fail;
518 } 519 }
519 } 520 }
520 521
521 excp = (except_T *)alloc((unsigned)sizeof(except_T)); 522 excp = (except_T *)alloc((unsigned)sizeof(except_T));
552 verbose_enter(); 553 verbose_enter();
553 ++no_wait_return; 554 ++no_wait_return;
554 if (debug_break_level > 0 || *p_vfile == NUL) 555 if (debug_break_level > 0 || *p_vfile == NUL)
555 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 556 msg_scroll = TRUE; /* always scroll up, don't overwrite */
556 557
557 smsg((char_u *)_("Exception thrown: %s"), excp->value); 558 smsg(_("Exception thrown: %s"), excp->value);
558 msg_puts((char_u *)"\n"); /* don't overwrite this either */ 559 msg_puts((char_u *)"\n"); /* don't overwrite this either */
559 560
560 if (debug_break_level > 0 || *p_vfile == NUL) 561 if (debug_break_level > 0 || *p_vfile == NUL)
561 cmdline_row = msg_row; 562 cmdline_row = msg_row;
562 --no_wait_return; 563 --no_wait_return;
570 return OK; 571 return OK;
571 572
572 nomem: 573 nomem:
573 vim_free(excp); 574 vim_free(excp);
574 suppress_errthrow = TRUE; 575 suppress_errthrow = TRUE;
575 EMSG(_(e_outofmem)); 576 emsg(_(e_outofmem));
576 fail: 577 fail:
577 current_exception = NULL; 578 current_exception = NULL;
578 return FAIL; 579 return FAIL;
579 } 580 }
580 581
604 verbose_enter(); 605 verbose_enter();
605 ++no_wait_return; 606 ++no_wait_return;
606 if (debug_break_level > 0 || *p_vfile == NUL) 607 if (debug_break_level > 0 || *p_vfile == NUL)
607 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 608 msg_scroll = TRUE; /* always scroll up, don't overwrite */
608 smsg(was_finished 609 smsg(was_finished
609 ? (char_u *)_("Exception finished: %s") 610 ? _("Exception finished: %s")
610 : (char_u *)_("Exception discarded: %s"), 611 : _("Exception discarded: %s"),
611 excp->value); 612 excp->value);
612 msg_puts((char_u *)"\n"); /* don't overwrite this either */ 613 msg_puts((char_u *)"\n"); /* don't overwrite this either */
613 if (debug_break_level > 0 || *p_vfile == NUL) 614 if (debug_break_level > 0 || *p_vfile == NUL)
614 cmdline_row = msg_row; 615 cmdline_row = msg_row;
615 --no_wait_return; 616 --no_wait_return;
649 static void 650 static void
650 catch_exception(except_T *excp) 651 catch_exception(except_T *excp)
651 { 652 {
652 excp->caught = caught_stack; 653 excp->caught = caught_stack;
653 caught_stack = excp; 654 caught_stack = excp;
654 set_vim_var_string(VV_EXCEPTION, excp->value, -1); 655 set_vim_var_string(VV_EXCEPTION, (char_u *)excp->value, -1);
655 if (*excp->throw_name != NUL) 656 if (*excp->throw_name != NUL)
656 { 657 {
657 if (excp->throw_lnum != 0) 658 if (excp->throw_lnum != 0)
658 vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %ld"), 659 vim_snprintf((char *)IObuff, IOSIZE, _("%s, line %ld"),
659 excp->throw_name, (long)excp->throw_lnum); 660 excp->throw_name, (long)excp->throw_lnum);
675 verbose_enter(); 676 verbose_enter();
676 ++no_wait_return; 677 ++no_wait_return;
677 if (debug_break_level > 0 || *p_vfile == NUL) 678 if (debug_break_level > 0 || *p_vfile == NUL)
678 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 679 msg_scroll = TRUE; /* always scroll up, don't overwrite */
679 680
680 smsg((char_u *)_("Exception caught: %s"), excp->value); 681 smsg(_("Exception caught: %s"), excp->value);
681 msg_puts((char_u *)"\n"); /* don't overwrite this either */ 682 msg_puts((char_u *)"\n"); /* don't overwrite this either */
682 683
683 if (debug_break_level > 0 || *p_vfile == NUL) 684 if (debug_break_level > 0 || *p_vfile == NUL)
684 cmdline_row = msg_row; 685 cmdline_row = msg_row;
685 --no_wait_return; 686 --no_wait_return;
699 if (excp != caught_stack) 700 if (excp != caught_stack)
700 internal_error("finish_exception()"); 701 internal_error("finish_exception()");
701 caught_stack = caught_stack->caught; 702 caught_stack = caught_stack->caught;
702 if (caught_stack != NULL) 703 if (caught_stack != NULL)
703 { 704 {
704 set_vim_var_string(VV_EXCEPTION, caught_stack->value, -1); 705 set_vim_var_string(VV_EXCEPTION, (char_u *)caught_stack->value, -1);
705 if (*caught_stack->throw_name != NUL) 706 if (*caught_stack->throw_name != NUL)
706 { 707 {
707 if (caught_stack->throw_lnum != 0) 708 if (caught_stack->throw_lnum != 0)
708 vim_snprintf((char *)IObuff, IOSIZE, 709 vim_snprintf((char *)IObuff, IOSIZE,
709 _("%s, line %ld"), caught_stack->throw_name, 710 _("%s, line %ld"), caught_stack->throw_name,
743 * or the exception value for a pending exception. 744 * or the exception value for a pending exception.
744 */ 745 */
745 static void 746 static void
746 report_pending(int action, int pending, void *value) 747 report_pending(int action, int pending, void *value)
747 { 748 {
748 char_u *mesg; 749 char *mesg;
749 char *s; 750 char *s;
750 int save_msg_silent; 751 int save_msg_silent;
751 752
752 753
753 switch (action) 754 switch (action)
754 { 755 {
755 case RP_MAKE: 756 case RP_MAKE:
756 mesg = (char_u *)_("%s made pending"); 757 mesg = _("%s made pending");
757 break; 758 break;
758 case RP_RESUME: 759 case RP_RESUME:
759 mesg = (char_u *)_("%s resumed"); 760 mesg = _("%s resumed");
760 break; 761 break;
761 /* case RP_DISCARD: */ 762 /* case RP_DISCARD: */
762 default: 763 default:
763 mesg = (char_u *)_("%s discarded"); 764 mesg = _("%s discarded");
764 break; 765 break;
765 } 766 }
766 767
767 switch (pending) 768 switch (pending)
768 { 769 {
784 break; 785 break;
785 786
786 default: 787 default:
787 if (pending & CSTP_THROW) 788 if (pending & CSTP_THROW)
788 { 789 {
789 vim_snprintf((char *)IObuff, IOSIZE, 790 vim_snprintf((char *)IObuff, IOSIZE, mesg, _("Exception"));
790 (char *)mesg, _("Exception")); 791 mesg = (char *)vim_strnsave(IObuff, (int)STRLEN(IObuff) + 4);
791 mesg = vim_strnsave(IObuff, (int)STRLEN(IObuff) + 4);
792 STRCAT(mesg, ": %s"); 792 STRCAT(mesg, ": %s");
793 s = (char *)((except_T *)value)->value; 793 s = (char *)((except_T *)value)->value;
794 } 794 }
795 else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT)) 795 else if ((pending & CSTP_ERROR) && (pending & CSTP_INTERRUPT))
796 s = _("Error and interrupt"); 796 s = _("Error and interrupt");
803 save_msg_silent = msg_silent; 803 save_msg_silent = msg_silent;
804 if (debug_break_level > 0) 804 if (debug_break_level > 0)
805 msg_silent = FALSE; /* display messages */ 805 msg_silent = FALSE; /* display messages */
806 ++no_wait_return; 806 ++no_wait_return;
807 msg_scroll = TRUE; /* always scroll up, don't overwrite */ 807 msg_scroll = TRUE; /* always scroll up, don't overwrite */
808 smsg(mesg, (char_u *)s); 808 smsg(mesg, s);
809 msg_puts((char_u *)"\n"); /* don't overwrite this either */ 809 msg_puts((char_u *)"\n"); /* don't overwrite this either */
810 cmdline_row = msg_row; 810 cmdline_row = msg_row;
811 --no_wait_return; 811 --no_wait_return;
812 if (debug_break_level > 0) 812 if (debug_break_level > 0)
813 msg_silent = save_msg_silent; 813 msg_silent = save_msg_silent;
880 int skip; 880 int skip;
881 int result; 881 int result;
882 struct condstack *cstack = eap->cstack; 882 struct condstack *cstack = eap->cstack;
883 883
884 if (cstack->cs_idx == CSTACK_LEN - 1) 884 if (cstack->cs_idx == CSTACK_LEN - 1)
885 eap->errmsg = (char_u *)N_("E579: :if nesting too deep"); 885 eap->errmsg = N_("E579: :if nesting too deep");
886 else 886 else
887 { 887 {
888 ++cstack->cs_idx; 888 ++cstack->cs_idx;
889 cstack->cs_flags[cstack->cs_idx] = 0; 889 cstack->cs_flags[cstack->cs_idx] = 0;
890 890
916 { 916 {
917 did_endif = TRUE; 917 did_endif = TRUE;
918 if (eap->cstack->cs_idx < 0 918 if (eap->cstack->cs_idx < 0
919 || (eap->cstack->cs_flags[eap->cstack->cs_idx] 919 || (eap->cstack->cs_flags[eap->cstack->cs_idx]
920 & (CSF_WHILE | CSF_FOR | CSF_TRY))) 920 & (CSF_WHILE | CSF_FOR | CSF_TRY)))
921 eap->errmsg = (char_u *)N_("E580: :endif without :if"); 921 eap->errmsg = N_("E580: :endif without :if");
922 else 922 else
923 { 923 {
924 /* 924 /*
925 * When debugging or a breakpoint was encountered, display the debug 925 * When debugging or a breakpoint was encountered, display the debug
926 * prompt (if not already done). This shows the user that an ":endif" 926 * prompt (if not already done). This shows the user that an ":endif"
960 || (cstack->cs_flags[cstack->cs_idx] 960 || (cstack->cs_flags[cstack->cs_idx]
961 & (CSF_WHILE | CSF_FOR | CSF_TRY))) 961 & (CSF_WHILE | CSF_FOR | CSF_TRY)))
962 { 962 {
963 if (eap->cmdidx == CMD_else) 963 if (eap->cmdidx == CMD_else)
964 { 964 {
965 eap->errmsg = (char_u *)N_("E581: :else without :if"); 965 eap->errmsg = N_("E581: :else without :if");
966 return; 966 return;
967 } 967 }
968 eap->errmsg = (char_u *)N_("E582: :elseif without :if"); 968 eap->errmsg = N_("E582: :elseif without :if");
969 skip = TRUE; 969 skip = TRUE;
970 } 970 }
971 else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE) 971 else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE)
972 { 972 {
973 if (eap->cmdidx == CMD_else) 973 if (eap->cmdidx == CMD_else)
974 { 974 {
975 eap->errmsg = (char_u *)N_("E583: multiple :else"); 975 eap->errmsg = N_("E583: multiple :else");
976 return; 976 return;
977 } 977 }
978 eap->errmsg = (char_u *)N_("E584: :elseif after :else"); 978 eap->errmsg = N_("E584: :elseif after :else");
979 skip = TRUE; 979 skip = TRUE;
980 } 980 }
981 981
982 /* if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it */ 982 /* if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it */
983 if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE) 983 if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE)
1039 int skip; 1039 int skip;
1040 int result; 1040 int result;
1041 struct condstack *cstack = eap->cstack; 1041 struct condstack *cstack = eap->cstack;
1042 1042
1043 if (cstack->cs_idx == CSTACK_LEN - 1) 1043 if (cstack->cs_idx == CSTACK_LEN - 1)
1044 eap->errmsg = (char_u *)N_("E585: :while/:for nesting too deep"); 1044 eap->errmsg = N_("E585: :while/:for nesting too deep");
1045 else 1045 else
1046 { 1046 {
1047 /* 1047 /*
1048 * The loop flag is set when we have jumped back from the matching 1048 * The loop flag is set when we have jumped back from the matching
1049 * ":endwhile" or ":endfor". When not set, need to initialise this 1049 * ":endwhile" or ":endfor". When not set, need to initialise this
1136 { 1136 {
1137 int idx; 1137 int idx;
1138 struct condstack *cstack = eap->cstack; 1138 struct condstack *cstack = eap->cstack;
1139 1139
1140 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) 1140 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
1141 eap->errmsg = (char_u *)N_("E586: :continue without :while or :for"); 1141 eap->errmsg = N_("E586: :continue without :while or :for");
1142 else 1142 else
1143 { 1143 {
1144 /* Try to find the matching ":while". This might stop at a try 1144 /* Try to find the matching ":while". This might stop at a try
1145 * conditional not in its finally clause (which is then to be executed 1145 * conditional not in its finally clause (which is then to be executed
1146 * next). Therefor, inactivate all conditionals except the ":while" 1146 * next). Therefor, inactivate all conditionals except the ":while"
1174 { 1174 {
1175 int idx; 1175 int idx;
1176 struct condstack *cstack = eap->cstack; 1176 struct condstack *cstack = eap->cstack;
1177 1177
1178 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) 1178 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
1179 eap->errmsg = (char_u *)N_("E587: :break without :while or :for"); 1179 eap->errmsg = N_("E587: :break without :while or :for");
1180 else 1180 else
1181 { 1181 {
1182 /* Inactivate conditionals until the matching ":while" or a try 1182 /* Inactivate conditionals until the matching ":while" or a try
1183 * conditional not in its finally clause (which is then to be 1183 * conditional not in its finally clause (which is then to be
1184 * executed next) is found. In the latter case, make the ":break" 1184 * executed next) is found. In the latter case, make the ":break"
1198 void 1198 void
1199 ex_endwhile(exarg_T *eap) 1199 ex_endwhile(exarg_T *eap)
1200 { 1200 {
1201 struct condstack *cstack = eap->cstack; 1201 struct condstack *cstack = eap->cstack;
1202 int idx; 1202 int idx;
1203 char_u *err; 1203 char *err;
1204 int csf; 1204 int csf;
1205 int fl; 1205 int fl;
1206 1206
1207 if (eap->cmdidx == CMD_endwhile) 1207 if (eap->cmdidx == CMD_endwhile)
1208 { 1208 {
1223 if (!(fl & csf)) 1223 if (!(fl & csf))
1224 { 1224 {
1225 /* If we are in a ":while" or ":for" but used the wrong endloop 1225 /* If we are in a ":while" or ":for" but used the wrong endloop
1226 * command, do not rewind to the next enclosing ":for"/":while". */ 1226 * command, do not rewind to the next enclosing ":for"/":while". */
1227 if (fl & CSF_WHILE) 1227 if (fl & CSF_WHILE)
1228 eap->errmsg = (char_u *)_("E732: Using :endfor with :while"); 1228 eap->errmsg = _("E732: Using :endfor with :while");
1229 else if (fl & CSF_FOR) 1229 else if (fl & CSF_FOR)
1230 eap->errmsg = (char_u *)_("E733: Using :endwhile with :for"); 1230 eap->errmsg = _("E733: Using :endwhile with :for");
1231 } 1231 }
1232 if (!(fl & (CSF_WHILE | CSF_FOR))) 1232 if (!(fl & (CSF_WHILE | CSF_FOR)))
1233 { 1233 {
1234 if (!(fl & CSF_TRY)) 1234 if (!(fl & CSF_TRY))
1235 eap->errmsg = e_endif; 1235 eap->errmsg = e_endif;
1289 1289
1290 if (*arg != NUL && *arg != '|' && *arg != '\n') 1290 if (*arg != NUL && *arg != '|' && *arg != '\n')
1291 value = eval_to_string_skip(arg, &eap->nextcmd, eap->skip); 1291 value = eval_to_string_skip(arg, &eap->nextcmd, eap->skip);
1292 else 1292 else
1293 { 1293 {
1294 EMSG(_(e_argreq)); 1294 emsg(_(e_argreq));
1295 value = NULL; 1295 value = NULL;
1296 } 1296 }
1297 1297
1298 /* On error or when an exception is thrown during argument evaluation, do 1298 /* On error or when an exception is thrown during argument evaluation, do
1299 * not throw. */ 1299 * not throw. */
1397 { 1397 {
1398 int skip; 1398 int skip;
1399 struct condstack *cstack = eap->cstack; 1399 struct condstack *cstack = eap->cstack;
1400 1400
1401 if (cstack->cs_idx == CSTACK_LEN - 1) 1401 if (cstack->cs_idx == CSTACK_LEN - 1)
1402 eap->errmsg = (char_u *)N_("E601: :try nesting too deep"); 1402 eap->errmsg = N_("E601: :try nesting too deep");
1403 else 1403 else
1404 { 1404 {
1405 ++cstack->cs_idx; 1405 ++cstack->cs_idx;
1406 ++cstack->cs_trylevel; 1406 ++cstack->cs_trylevel;
1407 cstack->cs_flags[cstack->cs_idx] = CSF_TRY; 1407 cstack->cs_flags[cstack->cs_idx] = CSF_TRY;
1441 { 1441 {
1442 eslist_T *elem; 1442 eslist_T *elem;
1443 1443
1444 elem = (eslist_T *)alloc((unsigned)sizeof(struct eslist_elem)); 1444 elem = (eslist_T *)alloc((unsigned)sizeof(struct eslist_elem));
1445 if (elem == NULL) 1445 if (elem == NULL)
1446 EMSG(_(e_outofmem)); 1446 emsg(_(e_outofmem));
1447 else 1447 else
1448 { 1448 {
1449 elem->saved_emsg_silent = emsg_silent; 1449 elem->saved_emsg_silent = emsg_silent;
1450 elem->next = cstack->cs_emsg_silent_list; 1450 elem->next = cstack->cs_emsg_silent_list;
1451 cstack->cs_emsg_silent_list = elem; 1451 cstack->cs_emsg_silent_list = elem;
1476 struct condstack *cstack = eap->cstack; 1476 struct condstack *cstack = eap->cstack;
1477 char_u *pat; 1477 char_u *pat;
1478 1478
1479 if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) 1479 if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
1480 { 1480 {
1481 eap->errmsg = (char_u *)N_("E603: :catch without :try"); 1481 eap->errmsg = N_("E603: :catch without :try");
1482 give_up = TRUE; 1482 give_up = TRUE;
1483 } 1483 }
1484 else 1484 else
1485 { 1485 {
1486 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) 1486 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
1495 break; 1495 break;
1496 if (cstack->cs_flags[idx] & CSF_FINALLY) 1496 if (cstack->cs_flags[idx] & CSF_FINALLY)
1497 { 1497 {
1498 /* Give up for a ":catch" after ":finally" and ignore it. 1498 /* Give up for a ":catch" after ":finally" and ignore it.
1499 * Just parse. */ 1499 * Just parse. */
1500 eap->errmsg = (char_u *)N_("E604: :catch after :finally"); 1500 eap->errmsg = N_("E604: :catch after :finally");
1501 give_up = TRUE; 1501 give_up = TRUE;
1502 } 1502 }
1503 else 1503 else
1504 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, 1504 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
1505 &cstack->cs_looplevel); 1505 &cstack->cs_looplevel);
1535 if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) 1535 if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
1536 && !(cstack->cs_flags[idx] & CSF_CAUGHT)) 1536 && !(cstack->cs_flags[idx] & CSF_CAUGHT))
1537 { 1537 {
1538 if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) 1538 if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1)))
1539 { 1539 {
1540 EMSG(_(e_trailing)); 1540 emsg(_(e_trailing));
1541 return; 1541 return;
1542 } 1542 }
1543 1543
1544 /* When debugging or a breakpoint was encountered, display the 1544 /* When debugging or a breakpoint was encountered, display the
1545 * debug prompt (if not already done) before checking for a match. 1545 * debug prompt (if not already done) before checking for a match.
1567 regmatch.rm_ic = FALSE; 1567 regmatch.rm_ic = FALSE;
1568 if (end != NULL) 1568 if (end != NULL)
1569 *end = save_char; 1569 *end = save_char;
1570 p_cpo = save_cpo; 1570 p_cpo = save_cpo;
1571 if (regmatch.regprog == NULL) 1571 if (regmatch.regprog == NULL)
1572 EMSG2(_(e_invarg2), pat); 1572 semsg(_(e_invarg2), pat);
1573 else 1573 else
1574 { 1574 {
1575 /* 1575 /*
1576 * Save the value of got_int and reset it. We don't want 1576 * Save the value of got_int and reset it. We don't want
1577 * a previous interruption cancel matching, only hitting 1577 * a previous interruption cancel matching, only hitting
1578 * CTRL-C while matching should abort it. 1578 * CTRL-C while matching should abort it.
1579 */ 1579 */
1580 prev_got_int = got_int; 1580 prev_got_int = got_int;
1581 got_int = FALSE; 1581 got_int = FALSE;
1582 caught = vim_regexec_nl(&regmatch, current_exception->value, 1582 caught = vim_regexec_nl(&regmatch,
1583 (colnr_T)0); 1583 (char_u *)current_exception->value, (colnr_T)0);
1584 got_int |= prev_got_int; 1584 got_int |= prev_got_int;
1585 vim_regfree(regmatch.regprog); 1585 vim_regfree(regmatch.regprog);
1586 } 1586 }
1587 } 1587 }
1588 } 1588 }
1632 int skip = FALSE; 1632 int skip = FALSE;
1633 int pending = CSTP_NONE; 1633 int pending = CSTP_NONE;
1634 struct condstack *cstack = eap->cstack; 1634 struct condstack *cstack = eap->cstack;
1635 1635
1636 if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) 1636 if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
1637 eap->errmsg = (char_u *)N_("E606: :finally without :try"); 1637 eap->errmsg = N_("E606: :finally without :try");
1638 else 1638 else
1639 { 1639 {
1640 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) 1640 if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY))
1641 { 1641 {
1642 eap->errmsg = get_end_emsg(cstack); 1642 eap->errmsg = get_end_emsg(cstack);
1652 idx = cstack->cs_idx; 1652 idx = cstack->cs_idx;
1653 1653
1654 if (cstack->cs_flags[idx] & CSF_FINALLY) 1654 if (cstack->cs_flags[idx] & CSF_FINALLY)
1655 { 1655 {
1656 /* Give up for a multiple ":finally" and ignore it. */ 1656 /* Give up for a multiple ":finally" and ignore it. */
1657 eap->errmsg = (char_u *)N_("E607: multiple :finally"); 1657 eap->errmsg = N_("E607: multiple :finally");
1658 return; 1658 return;
1659 } 1659 }
1660 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, 1660 rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
1661 &cstack->cs_looplevel); 1661 &cstack->cs_looplevel);
1662 1662
1761 int pending = CSTP_NONE; 1761 int pending = CSTP_NONE;
1762 void *rettv = NULL; 1762 void *rettv = NULL;
1763 struct condstack *cstack = eap->cstack; 1763 struct condstack *cstack = eap->cstack;
1764 1764
1765 if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) 1765 if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
1766 eap->errmsg = (char_u *)N_("E602: :endtry without :try"); 1766 eap->errmsg = N_("E602: :endtry without :try");
1767 else 1767 else
1768 { 1768 {
1769 /* 1769 /*
1770 * Don't do something after an error, interrupt or throw in the try 1770 * Don't do something after an error, interrupt or throw in the try
1771 * block, catch clause, or finally clause preceding this ":endtry" or 1771 * block, catch clause, or finally clause preceding this ":endtry" or
2221 } 2221 }
2222 2222
2223 /* 2223 /*
2224 * Return an appropriate error message for a missing endwhile/endfor/endif. 2224 * Return an appropriate error message for a missing endwhile/endfor/endif.
2225 */ 2225 */
2226 static char_u * 2226 static char *
2227 get_end_emsg(struct condstack *cstack) 2227 get_end_emsg(struct condstack *cstack)
2228 { 2228 {
2229 if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) 2229 if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE)
2230 return e_endwhile; 2230 return e_endwhile;
2231 if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) 2231 if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR)
2262 * ":endfunction" when not after a ":function" 2262 * ":endfunction" when not after a ":function"
2263 */ 2263 */
2264 void 2264 void
2265 ex_endfunction(exarg_T *eap UNUSED) 2265 ex_endfunction(exarg_T *eap UNUSED)
2266 { 2266 {
2267 EMSG(_("E193: :endfunction not inside a function")); 2267 emsg(_("E193: :endfunction not inside a function"));
2268 } 2268 }
2269 2269
2270 /* 2270 /*
2271 * Return TRUE if the string "p" looks like a ":while" or ":for" command. 2271 * Return TRUE if the string "p" looks like a ":while" or ":for" command.
2272 */ 2272 */