Mercurial > vim
comparison src/ex_eval.c @ 7819:f86adafb28d4 v7.4.1206
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 30 15:52:46 2016 +0100
patch 7.4.1206
Problem: Using old style function declarations.
Solution: Change to new style function declarations. (script by Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jan 2016 16:00:06 +0100 |
parents | a1e71a01dbd6 |
children | 00344cd730f6 |
comparison
equal
deleted
inserted
replaced
7818:19dfb097d82d | 7819:f86adafb28d4 |
---|---|
91 * until the throw point for error messages has been reached. That is, during | 91 * until the throw point for error messages has been reached. That is, during |
92 * cancellation of an expression evaluation after an aborting function call or | 92 * cancellation of an expression evaluation after an aborting function call or |
93 * due to a parsing error, aborting() always returns the same value. | 93 * due to a parsing error, aborting() always returns the same value. |
94 */ | 94 */ |
95 int | 95 int |
96 aborting() | 96 aborting(void) |
97 { | 97 { |
98 return (did_emsg && force_abort) || got_int || did_throw; | 98 return (did_emsg && force_abort) || got_int || did_throw; |
99 } | 99 } |
100 | 100 |
101 /* | 101 /* |
103 * during an expression evaluation, and "cause_abort" is used instead. It might | 103 * during an expression evaluation, and "cause_abort" is used instead. It might |
104 * be necessary to restore "force_abort" even before the throw point for the | 104 * be necessary to restore "force_abort" even before the throw point for the |
105 * error message has been reached. update_force_abort() should be called then. | 105 * error message has been reached. update_force_abort() should be called then. |
106 */ | 106 */ |
107 void | 107 void |
108 update_force_abort() | 108 update_force_abort(void) |
109 { | 109 { |
110 if (cause_abort) | 110 if (cause_abort) |
111 force_abort = TRUE; | 111 force_abort = TRUE; |
112 } | 112 } |
113 | 113 |
116 * abort the script processing. Can be used to suppress an autocommand after | 116 * abort the script processing. Can be used to suppress an autocommand after |
117 * execution of a failing subcommand as long as the error message has not been | 117 * execution of a failing subcommand as long as the error message has not been |
118 * displayed and actually caused the abortion. | 118 * displayed and actually caused the abortion. |
119 */ | 119 */ |
120 int | 120 int |
121 should_abort(retcode) | 121 should_abort(int retcode) |
122 int retcode; | |
123 { | 122 { |
124 return ((retcode == FAIL && trylevel != 0 && !emsg_silent) || aborting()); | 123 return ((retcode == FAIL && trylevel != 0 && !emsg_silent) || aborting()); |
125 } | 124 } |
126 | 125 |
127 /* | 126 /* |
129 * ended on an error. This means that parsing commands is continued in order | 128 * ended on an error. This means that parsing commands is continued in order |
130 * to find finally clauses to be executed, and that some errors in skipped | 129 * to find finally clauses to be executed, and that some errors in skipped |
131 * commands are still reported. | 130 * commands are still reported. |
132 */ | 131 */ |
133 int | 132 int |
134 aborted_in_try() | 133 aborted_in_try(void) |
135 { | 134 { |
136 /* This function is only called after an error. In this case, "force_abort" | 135 /* This function is only called after an error. In this case, "force_abort" |
137 * determines whether searching for finally clauses is necessary. */ | 136 * determines whether searching for finally clauses is necessary. */ |
138 return force_abort; | 137 return force_abort; |
139 } | 138 } |
146 * When several messages appear in the same command, the first is usually the | 145 * When several messages appear in the same command, the first is usually the |
147 * most specific one and used as the exception value. The "severe" flag can be | 146 * most specific one and used as the exception value. The "severe" flag can be |
148 * set to TRUE, if a later but severer message should be used instead. | 147 * set to TRUE, if a later but severer message should be used instead. |
149 */ | 148 */ |
150 int | 149 int |
151 cause_errthrow(mesg, severe, ignore) | 150 cause_errthrow( |
152 char_u *mesg; | 151 char_u *mesg, |
153 int severe; | 152 int severe, |
154 int *ignore; | 153 int *ignore) |
155 { | 154 { |
156 struct msglist *elem; | 155 struct msglist *elem; |
157 struct msglist **plist; | 156 struct msglist **plist; |
158 | 157 |
159 /* | 158 /* |
303 | 302 |
304 /* | 303 /* |
305 * Free a "msg_list" and the messages it contains. | 304 * Free a "msg_list" and the messages it contains. |
306 */ | 305 */ |
307 static void | 306 static void |
308 free_msglist(l) | 307 free_msglist(struct msglist *l) |
309 struct msglist *l; | |
310 { | 308 { |
311 struct msglist *messages, *next; | 309 struct msglist *messages, *next; |
312 | 310 |
313 messages = l; | 311 messages = l; |
314 while (messages != NULL) | 312 while (messages != NULL) |
323 /* | 321 /* |
324 * Free global "*msg_list" and the messages it contains, then set "*msg_list" | 322 * Free global "*msg_list" and the messages it contains, then set "*msg_list" |
325 * to NULL. | 323 * to NULL. |
326 */ | 324 */ |
327 void | 325 void |
328 free_global_msglist() | 326 free_global_msglist(void) |
329 { | 327 { |
330 free_msglist(*msg_list); | 328 free_msglist(*msg_list); |
331 *msg_list = NULL; | 329 *msg_list = NULL; |
332 } | 330 } |
333 | 331 |
335 * Throw the message specified in the call to cause_errthrow() above as an | 333 * Throw the message specified in the call to cause_errthrow() above as an |
336 * error exception. If cstack is NULL, postpone the throw until do_cmdline() | 334 * error exception. If cstack is NULL, postpone the throw until do_cmdline() |
337 * has returned (see do_one_cmd()). | 335 * has returned (see do_one_cmd()). |
338 */ | 336 */ |
339 void | 337 void |
340 do_errthrow(cstack, cmdname) | 338 do_errthrow(struct condstack *cstack, char_u *cmdname) |
341 struct condstack *cstack; | |
342 char_u *cmdname; | |
343 { | 339 { |
344 /* | 340 /* |
345 * Ensure that all commands in nested function calls and sourced files | 341 * Ensure that all commands in nested function calls and sourced files |
346 * are aborted immediately. | 342 * are aborted immediately. |
347 */ | 343 */ |
372 * do_intthrow(): Replace the current exception by an interrupt or interrupt | 368 * do_intthrow(): Replace the current exception by an interrupt or interrupt |
373 * exception if appropriate. Return TRUE if the current exception is discarded, | 369 * exception if appropriate. Return TRUE if the current exception is discarded, |
374 * FALSE otherwise. | 370 * FALSE otherwise. |
375 */ | 371 */ |
376 int | 372 int |
377 do_intthrow(cstack) | 373 do_intthrow(struct condstack *cstack) |
378 struct condstack *cstack; | |
379 { | 374 { |
380 /* | 375 /* |
381 * If no interrupt occurred or no try conditional is active and no exception | 376 * If no interrupt occurred or no try conditional is active and no exception |
382 * is being thrown, do nothing (for compatibility of non-EH scripts). | 377 * is being thrown, do nothing (for compatibility of non-EH scripts). |
383 */ | 378 */ |
423 | 418 |
424 /* | 419 /* |
425 * Get an exception message that is to be stored in current_exception->value. | 420 * Get an exception message that is to be stored in current_exception->value. |
426 */ | 421 */ |
427 char_u * | 422 char_u * |
428 get_exception_string(value, type, cmdname, should_free) | 423 get_exception_string( |
429 void *value; | 424 void *value, |
430 int type; | 425 int type, |
431 char_u *cmdname; | 426 char_u *cmdname, |
432 int *should_free; | 427 int *should_free) |
433 { | 428 { |
434 char_u *ret, *mesg; | 429 char_u *ret, *mesg; |
435 int cmdlen; | 430 int cmdlen; |
436 char_u *p, *val; | 431 char_u *p, *val; |
437 | 432 |
506 * throw an illegal user exception. "value" is the exception string for a | 501 * throw an illegal user exception. "value" is the exception string for a |
507 * user or interrupt exception, or points to a message list in case of an | 502 * user or interrupt exception, or points to a message list in case of an |
508 * error exception. | 503 * error exception. |
509 */ | 504 */ |
510 static int | 505 static int |
511 throw_exception(value, type, cmdname) | 506 throw_exception(void *value, int type, char_u *cmdname) |
512 void *value; | |
513 int type; | |
514 char_u *cmdname; | |
515 { | 507 { |
516 except_T *excp; | 508 except_T *excp; |
517 int should_free; | 509 int should_free; |
518 | 510 |
519 /* | 511 /* |
595 /* | 587 /* |
596 * Discard an exception. "was_finished" is set when the exception has been | 588 * Discard an exception. "was_finished" is set when the exception has been |
597 * caught and the catch clause has been ended normally. | 589 * caught and the catch clause has been ended normally. |
598 */ | 590 */ |
599 static void | 591 static void |
600 discard_exception(excp, was_finished) | 592 discard_exception(except_T *excp, int was_finished) |
601 except_T *excp; | |
602 int was_finished; | |
603 { | 593 { |
604 char_u *saved_IObuff; | 594 char_u *saved_IObuff; |
605 | 595 |
606 if (excp == NULL) | 596 if (excp == NULL) |
607 { | 597 { |
646 | 636 |
647 /* | 637 /* |
648 * Discard the exception currently being thrown. | 638 * Discard the exception currently being thrown. |
649 */ | 639 */ |
650 void | 640 void |
651 discard_current_exception() | 641 discard_current_exception(void) |
652 { | 642 { |
653 discard_exception(current_exception, FALSE); | 643 discard_exception(current_exception, FALSE); |
654 current_exception = NULL; | 644 current_exception = NULL; |
655 did_throw = FALSE; | 645 did_throw = FALSE; |
656 need_rethrow = FALSE; | 646 need_rethrow = FALSE; |
658 | 648 |
659 /* | 649 /* |
660 * Put an exception on the caught stack. | 650 * Put an exception on the caught stack. |
661 */ | 651 */ |
662 static void | 652 static void |
663 catch_exception(excp) | 653 catch_exception(except_T *excp) |
664 except_T *excp; | |
665 { | 654 { |
666 excp->caught = caught_stack; | 655 excp->caught = caught_stack; |
667 caught_stack = excp; | 656 caught_stack = excp; |
668 set_vim_var_string(VV_EXCEPTION, excp->value, -1); | 657 set_vim_var_string(VV_EXCEPTION, excp->value, -1); |
669 if (*excp->throw_name != NUL) | 658 if (*excp->throw_name != NUL) |
706 | 695 |
707 /* | 696 /* |
708 * Remove an exception from the caught stack. | 697 * Remove an exception from the caught stack. |
709 */ | 698 */ |
710 static void | 699 static void |
711 finish_exception(excp) | 700 finish_exception(except_T *excp) |
712 except_T *excp; | |
713 { | 701 { |
714 if (excp != caught_stack) | 702 if (excp != caught_stack) |
715 EMSG(_(e_internal)); | 703 EMSG(_(e_internal)); |
716 caught_stack = caught_stack->caught; | 704 caught_stack = caught_stack->caught; |
717 if (caught_stack != NULL) | 705 if (caught_stack != NULL) |
756 * made pending or something pending is resumed or discarded. "pending" tells | 744 * made pending or something pending is resumed or discarded. "pending" tells |
757 * what is pending. "value" specifies the return value for a pending ":return" | 745 * what is pending. "value" specifies the return value for a pending ":return" |
758 * or the exception value for a pending exception. | 746 * or the exception value for a pending exception. |
759 */ | 747 */ |
760 static void | 748 static void |
761 report_pending(action, pending, value) | 749 report_pending(int action, int pending, void *value) |
762 int action; | |
763 int pending; | |
764 void *value; | |
765 { | 750 { |
766 char_u *mesg; | 751 char_u *mesg; |
767 char *s; | 752 char *s; |
768 int save_msg_silent; | 753 int save_msg_silent; |
769 | 754 |
839 /* | 824 /* |
840 * If something is made pending in a finally clause, report it if required by | 825 * If something is made pending in a finally clause, report it if required by |
841 * the 'verbose' option or when debugging. | 826 * the 'verbose' option or when debugging. |
842 */ | 827 */ |
843 void | 828 void |
844 report_make_pending(pending, value) | 829 report_make_pending(int pending, void *value) |
845 int pending; | |
846 void *value; | |
847 { | 830 { |
848 if (p_verbose >= 14 || debug_break_level > 0) | 831 if (p_verbose >= 14 || debug_break_level > 0) |
849 { | 832 { |
850 if (debug_break_level <= 0) | 833 if (debug_break_level <= 0) |
851 verbose_enter(); | 834 verbose_enter(); |
858 /* | 841 /* |
859 * If something pending in a finally clause is resumed at the ":endtry", report | 842 * If something pending in a finally clause is resumed at the ":endtry", report |
860 * it if required by the 'verbose' option or when debugging. | 843 * it if required by the 'verbose' option or when debugging. |
861 */ | 844 */ |
862 void | 845 void |
863 report_resume_pending(pending, value) | 846 report_resume_pending(int pending, void *value) |
864 int pending; | |
865 void *value; | |
866 { | 847 { |
867 if (p_verbose >= 14 || debug_break_level > 0) | 848 if (p_verbose >= 14 || debug_break_level > 0) |
868 { | 849 { |
869 if (debug_break_level <= 0) | 850 if (debug_break_level <= 0) |
870 verbose_enter(); | 851 verbose_enter(); |
877 /* | 858 /* |
878 * If something pending in a finally clause is discarded, report it if required | 859 * If something pending in a finally clause is discarded, report it if required |
879 * by the 'verbose' option or when debugging. | 860 * by the 'verbose' option or when debugging. |
880 */ | 861 */ |
881 void | 862 void |
882 report_discard_pending(pending, value) | 863 report_discard_pending(int pending, void *value) |
883 int pending; | |
884 void *value; | |
885 { | 864 { |
886 if (p_verbose >= 14 || debug_break_level > 0) | 865 if (p_verbose >= 14 || debug_break_level > 0) |
887 { | 866 { |
888 if (debug_break_level <= 0) | 867 if (debug_break_level <= 0) |
889 verbose_enter(); | 868 verbose_enter(); |
896 | 875 |
897 /* | 876 /* |
898 * ":if". | 877 * ":if". |
899 */ | 878 */ |
900 void | 879 void |
901 ex_if(eap) | 880 ex_if(exarg_T *eap) |
902 exarg_T *eap; | |
903 { | 881 { |
904 int error; | 882 int error; |
905 int skip; | 883 int skip; |
906 int result; | 884 int result; |
907 struct condstack *cstack = eap->cstack; | 885 struct condstack *cstack = eap->cstack; |
935 | 913 |
936 /* | 914 /* |
937 * ":endif". | 915 * ":endif". |
938 */ | 916 */ |
939 void | 917 void |
940 ex_endif(eap) | 918 ex_endif(exarg_T *eap) |
941 exarg_T *eap; | |
942 { | 919 { |
943 did_endif = TRUE; | 920 did_endif = TRUE; |
944 if (eap->cstack->cs_idx < 0 | 921 if (eap->cstack->cs_idx < 0 |
945 || (eap->cstack->cs_flags[eap->cstack->cs_idx] | 922 || (eap->cstack->cs_flags[eap->cstack->cs_idx] |
946 & (CSF_WHILE | CSF_FOR | CSF_TRY))) | 923 & (CSF_WHILE | CSF_FOR | CSF_TRY))) |
966 | 943 |
967 /* | 944 /* |
968 * ":else" and ":elseif". | 945 * ":else" and ":elseif". |
969 */ | 946 */ |
970 void | 947 void |
971 ex_else(eap) | 948 ex_else(exarg_T *eap) |
972 exarg_T *eap; | |
973 { | 949 { |
974 int error; | 950 int error; |
975 int skip; | 951 int skip; |
976 int result; | 952 int result; |
977 struct condstack *cstack = eap->cstack; | 953 struct condstack *cstack = eap->cstack; |
1058 | 1034 |
1059 /* | 1035 /* |
1060 * Handle ":while" and ":for". | 1036 * Handle ":while" and ":for". |
1061 */ | 1037 */ |
1062 void | 1038 void |
1063 ex_while(eap) | 1039 ex_while(exarg_T *eap) |
1064 exarg_T *eap; | |
1065 { | 1040 { |
1066 int error; | 1041 int error; |
1067 int skip; | 1042 int skip; |
1068 int result; | 1043 int result; |
1069 struct condstack *cstack = eap->cstack; | 1044 struct condstack *cstack = eap->cstack; |
1158 | 1133 |
1159 /* | 1134 /* |
1160 * ":continue" | 1135 * ":continue" |
1161 */ | 1136 */ |
1162 void | 1137 void |
1163 ex_continue(eap) | 1138 ex_continue(exarg_T *eap) |
1164 exarg_T *eap; | |
1165 { | 1139 { |
1166 int idx; | 1140 int idx; |
1167 struct condstack *cstack = eap->cstack; | 1141 struct condstack *cstack = eap->cstack; |
1168 | 1142 |
1169 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) | 1143 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) |
1197 | 1171 |
1198 /* | 1172 /* |
1199 * ":break" | 1173 * ":break" |
1200 */ | 1174 */ |
1201 void | 1175 void |
1202 ex_break(eap) | 1176 ex_break(exarg_T *eap) |
1203 exarg_T *eap; | |
1204 { | 1177 { |
1205 int idx; | 1178 int idx; |
1206 struct condstack *cstack = eap->cstack; | 1179 struct condstack *cstack = eap->cstack; |
1207 | 1180 |
1208 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) | 1181 if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) |
1224 | 1197 |
1225 /* | 1198 /* |
1226 * ":endwhile" and ":endfor" | 1199 * ":endwhile" and ":endfor" |
1227 */ | 1200 */ |
1228 void | 1201 void |
1229 ex_endwhile(eap) | 1202 ex_endwhile(exarg_T *eap) |
1230 exarg_T *eap; | |
1231 { | 1203 { |
1232 struct condstack *cstack = eap->cstack; | 1204 struct condstack *cstack = eap->cstack; |
1233 int idx; | 1205 int idx; |
1234 char_u *err; | 1206 char_u *err; |
1235 int csf; | 1207 int csf; |
1311 | 1283 |
1312 /* | 1284 /* |
1313 * ":throw expr" | 1285 * ":throw expr" |
1314 */ | 1286 */ |
1315 void | 1287 void |
1316 ex_throw(eap) | 1288 ex_throw(exarg_T *eap) |
1317 exarg_T *eap; | |
1318 { | 1289 { |
1319 char_u *arg = eap->arg; | 1290 char_u *arg = eap->arg; |
1320 char_u *value; | 1291 char_u *value; |
1321 | 1292 |
1322 if (*arg != NUL && *arg != '|' && *arg != '\n') | 1293 if (*arg != NUL && *arg != '|' && *arg != '\n') |
1342 * Throw the current exception through the specified cstack. Common routine | 1313 * Throw the current exception through the specified cstack. Common routine |
1343 * for ":throw" (user exception) and error and interrupt exceptions. Also | 1314 * for ":throw" (user exception) and error and interrupt exceptions. Also |
1344 * used for rethrowing an uncaught exception. | 1315 * used for rethrowing an uncaught exception. |
1345 */ | 1316 */ |
1346 void | 1317 void |
1347 do_throw(cstack) | 1318 do_throw(struct condstack *cstack) |
1348 struct condstack *cstack; | |
1349 { | 1319 { |
1350 int idx; | 1320 int idx; |
1351 int inactivate_try = FALSE; | 1321 int inactivate_try = FALSE; |
1352 | 1322 |
1353 /* | 1323 /* |
1424 | 1394 |
1425 /* | 1395 /* |
1426 * ":try" | 1396 * ":try" |
1427 */ | 1397 */ |
1428 void | 1398 void |
1429 ex_try(eap) | 1399 ex_try(exarg_T *eap) |
1430 exarg_T *eap; | |
1431 { | 1400 { |
1432 int skip; | 1401 int skip; |
1433 struct condstack *cstack = eap->cstack; | 1402 struct condstack *cstack = eap->cstack; |
1434 | 1403 |
1435 if (cstack->cs_idx == CSTACK_LEN - 1) | 1404 if (cstack->cs_idx == CSTACK_LEN - 1) |
1494 | 1463 |
1495 /* | 1464 /* |
1496 * ":catch /{pattern}/" and ":catch" | 1465 * ":catch /{pattern}/" and ":catch" |
1497 */ | 1466 */ |
1498 void | 1467 void |
1499 ex_catch(eap) | 1468 ex_catch(exarg_T *eap) |
1500 exarg_T *eap; | |
1501 { | 1469 { |
1502 int idx = 0; | 1470 int idx = 0; |
1503 int give_up = FALSE; | 1471 int give_up = FALSE; |
1504 int skip = FALSE; | 1472 int skip = FALSE; |
1505 int caught = FALSE; | 1473 int caught = FALSE; |
1655 | 1623 |
1656 /* | 1624 /* |
1657 * ":finally" | 1625 * ":finally" |
1658 */ | 1626 */ |
1659 void | 1627 void |
1660 ex_finally(eap) | 1628 ex_finally(exarg_T *eap) |
1661 exarg_T *eap; | |
1662 { | 1629 { |
1663 int idx; | 1630 int idx; |
1664 int skip = FALSE; | 1631 int skip = FALSE; |
1665 int pending = CSTP_NONE; | 1632 int pending = CSTP_NONE; |
1666 struct condstack *cstack = eap->cstack; | 1633 struct condstack *cstack = eap->cstack; |
1783 | 1750 |
1784 /* | 1751 /* |
1785 * ":endtry" | 1752 * ":endtry" |
1786 */ | 1753 */ |
1787 void | 1754 void |
1788 ex_endtry(eap) | 1755 ex_endtry(exarg_T *eap) |
1789 exarg_T *eap; | |
1790 { | 1756 { |
1791 int idx; | 1757 int idx; |
1792 int skip; | 1758 int skip; |
1793 int rethrow = FALSE; | 1759 int rethrow = FALSE; |
1794 int pending = CSTP_NONE; | 1760 int pending = CSTP_NONE; |
1982 * saves the error/interrupt/ exception state and prepares for the call to | 1948 * saves the error/interrupt/ exception state and prepares for the call to |
1983 * do_cmdline() that is going to be made for the cleanup autocommand | 1949 * do_cmdline() that is going to be made for the cleanup autocommand |
1984 * execution. | 1950 * execution. |
1985 */ | 1951 */ |
1986 void | 1952 void |
1987 enter_cleanup(csp) | 1953 enter_cleanup(cleanup_T *csp) |
1988 cleanup_T *csp; | |
1989 { | 1954 { |
1990 int pending = CSTP_NONE; | 1955 int pending = CSTP_NONE; |
1991 | 1956 |
1992 /* | 1957 /* |
1993 * Postpone did_emsg, got_int, did_throw. The pending values will be | 1958 * Postpone did_emsg, got_int, did_throw. The pending values will be |
2045 * error, an interrupt or an uncaught exception during execution of the | 2010 * error, an interrupt or an uncaught exception during execution of the |
2046 * cleanup autocommands. In the latter case, the saved error/interrupt/ | 2011 * cleanup autocommands. In the latter case, the saved error/interrupt/ |
2047 * exception state is discarded. | 2012 * exception state is discarded. |
2048 */ | 2013 */ |
2049 void | 2014 void |
2050 leave_cleanup(csp) | 2015 leave_cleanup(cleanup_T *csp) |
2051 cleanup_T *csp; | |
2052 { | 2016 { |
2053 int pending = csp->pending; | 2017 int pending = csp->pending; |
2054 | 2018 |
2055 if (pending == CSTP_NONE) /* nothing to do */ | 2019 if (pending == CSTP_NONE) /* nothing to do */ |
2056 return; | 2020 return; |
2131 * "emsg_silent", if reset when the try conditional finally reached was | 2095 * "emsg_silent", if reset when the try conditional finally reached was |
2132 * entered, is restored (used by ex_endtry()). This is normally done only | 2096 * entered, is restored (used by ex_endtry()). This is normally done only |
2133 * when such a try conditional is left. | 2097 * when such a try conditional is left. |
2134 */ | 2098 */ |
2135 int | 2099 int |
2136 cleanup_conditionals(cstack, searched_cond, inclusive) | 2100 cleanup_conditionals( |
2137 struct condstack *cstack; | 2101 struct condstack *cstack, |
2138 int searched_cond; | 2102 int searched_cond, |
2139 int inclusive; | 2103 int inclusive) |
2140 { | 2104 { |
2141 int idx; | 2105 int idx; |
2142 int stop = FALSE; | 2106 int stop = FALSE; |
2143 | 2107 |
2144 for (idx = cstack->cs_idx; idx >= 0; --idx) | 2108 for (idx = cstack->cs_idx; idx >= 0; --idx) |
2254 | 2218 |
2255 /* | 2219 /* |
2256 * Return an appropriate error message for a missing endwhile/endfor/endif. | 2220 * Return an appropriate error message for a missing endwhile/endfor/endif. |
2257 */ | 2221 */ |
2258 static char_u * | 2222 static char_u * |
2259 get_end_emsg(cstack) | 2223 get_end_emsg(struct condstack *cstack) |
2260 struct condstack *cstack; | |
2261 { | 2224 { |
2262 if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) | 2225 if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) |
2263 return e_endwhile; | 2226 return e_endwhile; |
2264 if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) | 2227 if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) |
2265 return e_endfor; | 2228 return e_endfor; |
2273 * which is to be decremented with each skipped conditional of the specified | 2236 * which is to be decremented with each skipped conditional of the specified |
2274 * type. | 2237 * type. |
2275 * Also free "for info" structures where needed. | 2238 * Also free "for info" structures where needed. |
2276 */ | 2239 */ |
2277 void | 2240 void |
2278 rewind_conditionals(cstack, idx, cond_type, cond_level) | 2241 rewind_conditionals( |
2279 struct condstack *cstack; | 2242 struct condstack *cstack, |
2280 int idx; | 2243 int idx, |
2281 int cond_type; | 2244 int cond_type, |
2282 int *cond_level; | 2245 int *cond_level) |
2283 { | 2246 { |
2284 while (cstack->cs_idx > idx) | 2247 while (cstack->cs_idx > idx) |
2285 { | 2248 { |
2286 if (cstack->cs_flags[cstack->cs_idx] & cond_type) | 2249 if (cstack->cs_flags[cstack->cs_idx] & cond_type) |
2287 --*cond_level; | 2250 --*cond_level; |
2293 | 2256 |
2294 /* | 2257 /* |
2295 * ":endfunction" when not after a ":function" | 2258 * ":endfunction" when not after a ":function" |
2296 */ | 2259 */ |
2297 void | 2260 void |
2298 ex_endfunction(eap) | 2261 ex_endfunction(exarg_T *eap UNUSED) |
2299 exarg_T *eap UNUSED; | |
2300 { | 2262 { |
2301 EMSG(_("E193: :endfunction not inside a function")); | 2263 EMSG(_("E193: :endfunction not inside a function")); |
2302 } | 2264 } |
2303 | 2265 |
2304 /* | 2266 /* |
2305 * Return TRUE if the string "p" looks like a ":while" or ":for" command. | 2267 * Return TRUE if the string "p" looks like a ":while" or ":for" command. |
2306 */ | 2268 */ |
2307 int | 2269 int |
2308 has_loop_cmd(p) | 2270 has_loop_cmd(char_u *p) |
2309 char_u *p; | |
2310 { | 2271 { |
2311 int len; | 2272 int len; |
2312 | 2273 |
2313 /* skip modifiers, white space and ':' */ | 2274 /* skip modifiers, white space and ':' */ |
2314 for (;;) | 2275 for (;;) |