To: vim_dev@googlegroups.com Subject: Patch 8.2.0013 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0013 Problem: Not using a typedef for condstack. Solution: Add a typedef. Files: src/structs.h, src/ex_docmd.c, src/ex_eval.c, src/userfunc.c, src/ex_cmds.h, src/proto/ex_eval.pro *** ../vim-8.2.0012/src/structs.h 2019-11-30 22:40:44.000000000 +0100 --- src/structs.h 2019-12-16 17:01:03.285444629 +0100 *************** *** 863,870 **** */ #define CSTACK_LEN 50 ! struct condstack ! { short cs_flags[CSTACK_LEN]; // CSF_ flags char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally" union { --- 863,869 ---- */ #define CSTACK_LEN 50 ! typedef struct { short cs_flags[CSTACK_LEN]; // CSF_ flags char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally" union { *************** *** 878,884 **** int cs_trylevel; // nr of nested ":try"s eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent" char cs_lflags; // loop flags: CSL_ flags ! }; # define cs_rettv cs_pend.csp_rv # define cs_exception cs_pend.csp_ex --- 877,883 ---- int cs_trylevel; // nr of nested ":try"s eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent" char cs_lflags; // loop flags: CSL_ flags ! } cstack_T; # define cs_rettv cs_pend.csp_rv # define cs_exception cs_pend.csp_ex *************** *** 912,918 **** # define CSTP_FINISH 32 // ":finish" is pending /* ! * Flags for the cs_lflags item in struct condstack. */ # define CSL_HAD_LOOP 1 // just found ":while" or ":for" # define CSL_HAD_ENDLOOP 2 // just found ":endwhile" or ":endfor" --- 911,917 ---- # define CSTP_FINISH 32 // ":finish" is pending /* ! * Flags for the cs_lflags item in cstack_T. */ # define CSL_HAD_LOOP 1 // just found ":while" or ":for" # define CSL_HAD_ENDLOOP 2 // just found ":endwhile" or ":endfor" *** ../vim-8.2.0012/src/ex_docmd.c 2019-12-08 17:06:08.000000000 +0100 --- src/ex_docmd.c 2019-12-16 17:08:17.563677676 +0100 *************** *** 20,26 **** #endif #ifdef FEAT_EVAL ! static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int, int), void *cookie); #else static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie); static int if_level = 0; // depth in :if --- 20,26 ---- #endif #ifdef FEAT_EVAL ! static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, void *, int, int), void *cookie); #else static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie); static int if_level = 0; // depth in :if *************** *** 623,629 **** int did_inc = FALSE; // incremented RedrawingDisabled int retval = OK; #ifdef FEAT_EVAL ! struct condstack cstack; // conditional stack garray_T lines_ga; // keep lines for ":while"/":for" int current_line = 0; // active line in lines_ga char_u *fname = NULL; // function or script name --- 623,629 ---- int did_inc = FALSE; // incremented RedrawingDisabled int retval = OK; #ifdef FEAT_EVAL ! cstack_T cstack; // conditional stack garray_T lines_ga; // keep lines for ":while"/":for" int current_line = 0; // active line in lines_ga char_u *fname = NULL; // function or script name *************** *** 671,677 **** #ifdef FEAT_EVAL // When converting to an exception, we do not include the command name // since this is not an error of the specific command. ! do_errthrow((struct condstack *)NULL, (char_u *)NULL); msg_list = saved_msg_list; #endif return FAIL; --- 671,677 ---- #ifdef FEAT_EVAL // When converting to an exception, we do not include the command name // since this is not an error of the specific command. ! do_errthrow((cstack_T *)NULL, (char_u *)NULL); msg_list = saved_msg_list; #endif return FAIL; *************** *** 1628,1652 **** #endif static char_u * do_one_cmd( ! char_u **cmdlinep, ! int sourcing, #ifdef FEAT_EVAL ! struct condstack *cstack, #endif ! char_u *(*fgetline)(int, void *, int, int), ! void *cookie) // argument for fgetline() { ! char_u *p; ! linenr_T lnum; ! long n; ! char *errormsg = NULL; // error message ! char_u *after_modifier = NULL; ! exarg_T ea; // Ex command arguments ! int save_msg_scroll = msg_scroll; ! cmdmod_T save_cmdmod; ! int save_reg_executing = reg_executing; ! int ni; // set when Not Implemented ! char_u *cmd; vim_memset(&ea, 0, sizeof(ea)); ea.line1 = 1; --- 1628,1652 ---- #endif static char_u * do_one_cmd( ! char_u **cmdlinep, ! int sourcing, #ifdef FEAT_EVAL ! cstack_T *cstack, #endif ! char_u *(*fgetline)(int, void *, int, int), ! void *cookie) // argument for fgetline() { ! char_u *p; ! linenr_T lnum; ! long n; ! char *errormsg = NULL; // error message ! char_u *after_modifier = NULL; ! exarg_T ea; // Ex command arguments ! int save_msg_scroll = msg_scroll; ! cmdmod_T save_cmdmod; ! int save_reg_executing = reg_executing; ! int ni; // set when Not Implemented ! char_u *cmd; vim_memset(&ea, 0, sizeof(ea)); ea.line1 = 1; *** ../vim-8.2.0012/src/ex_eval.c 2019-12-01 21:29:18.000000000 +0100 --- src/ex_eval.c 2019-12-16 16:59:44.085772358 +0100 *************** *** 16,22 **** #if defined(FEAT_EVAL) || defined(PROTO) static int throw_exception(void *, except_type_T, char_u *); ! static char *get_end_emsg(struct condstack *cstack); /* * Exception handling terms: --- 16,22 ---- #if defined(FEAT_EVAL) || defined(PROTO) static int throw_exception(void *, except_type_T, char_u *); ! static char *get_end_emsg(cstack_T *cstack); /* * Exception handling terms: *************** *** 330,336 **** * has returned (see do_one_cmd()). */ void ! do_errthrow(struct condstack *cstack, char_u *cmdname) { /* * Ensure that all commands in nested function calls and sourced files --- 330,336 ---- * has returned (see do_one_cmd()). */ void ! do_errthrow(cstack_T *cstack, char_u *cmdname) { /* * Ensure that all commands in nested function calls and sourced files *************** *** 365,371 **** * FALSE otherwise. */ int ! do_intthrow(struct condstack *cstack) { /* * If no interrupt occurred or no try conditional is active and no exception --- 365,371 ---- * FALSE otherwise. */ int ! do_intthrow(cstack_T *cstack) { /* * If no interrupt occurred or no try conditional is active and no exception *************** *** 892,898 **** int error; int skip; int result; ! struct condstack *cstack = eap->cstack; if (cstack->cs_idx == CSTACK_LEN - 1) eap->errmsg = N_("E579: :if nesting too deep"); --- 892,898 ---- int error; int skip; int result; ! cstack_T *cstack = eap->cstack; if (cstack->cs_idx == CSTACK_LEN - 1) eap->errmsg = N_("E579: :if nesting too deep"); *************** *** 960,966 **** int error; int skip; int result; ! struct condstack *cstack = eap->cstack; /* * Don't do something after an error, interrupt, or throw, or when there is --- 960,966 ---- int error; int skip; int result; ! cstack_T *cstack = eap->cstack; /* * Don't do something after an error, interrupt, or throw, or when there is *************** *** 1051,1057 **** int error; int skip; int result; ! struct condstack *cstack = eap->cstack; if (cstack->cs_idx == CSTACK_LEN - 1) eap->errmsg = N_("E585: :while/:for nesting too deep"); --- 1051,1057 ---- int error; int skip; int result; ! cstack_T *cstack = eap->cstack; if (cstack->cs_idx == CSTACK_LEN - 1) eap->errmsg = N_("E585: :while/:for nesting too deep"); *************** *** 1148,1154 **** ex_continue(exarg_T *eap) { int idx; ! struct condstack *cstack = eap->cstack; if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E586: :continue without :while or :for"); --- 1148,1154 ---- ex_continue(exarg_T *eap) { int idx; ! cstack_T *cstack = eap->cstack; if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E586: :continue without :while or :for"); *************** *** 1186,1192 **** ex_break(exarg_T *eap) { int idx; ! struct condstack *cstack = eap->cstack; if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E587: :break without :while or :for"); --- 1186,1192 ---- ex_break(exarg_T *eap) { int idx; ! cstack_T *cstack = eap->cstack; if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E587: :break without :while or :for"); *************** *** 1211,1221 **** void ex_endwhile(exarg_T *eap) { ! struct condstack *cstack = eap->cstack; ! int idx; ! char *err; ! int csf; ! int fl; if (eap->cmdidx == CMD_endwhile) { --- 1211,1221 ---- void ex_endwhile(exarg_T *eap) { ! cstack_T *cstack = eap->cstack; ! int idx; ! char *err; ! int csf; ! int fl; if (eap->cmdidx == CMD_endwhile) { *************** *** 1325,1331 **** * used for rethrowing an uncaught exception. */ void ! do_throw(struct condstack *cstack) { int idx; int inactivate_try = FALSE; --- 1325,1331 ---- * used for rethrowing an uncaught exception. */ void ! do_throw(cstack_T *cstack) { int idx; int inactivate_try = FALSE; *************** *** 1409,1415 **** ex_try(exarg_T *eap) { int skip; ! struct condstack *cstack = eap->cstack; if (cstack->cs_idx == CSTACK_LEN - 1) eap->errmsg = N_("E601: :try nesting too deep"); --- 1409,1415 ---- ex_try(exarg_T *eap) { int skip; ! cstack_T *cstack = eap->cstack; if (cstack->cs_idx == CSTACK_LEN - 1) eap->errmsg = N_("E601: :try nesting too deep"); *************** *** 1486,1492 **** char_u *save_cpo; regmatch_T regmatch; int prev_got_int; ! struct condstack *cstack = eap->cstack; char_u *pat; if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) --- 1486,1492 ---- char_u *save_cpo; regmatch_T regmatch; int prev_got_int; ! cstack_T *cstack = eap->cstack; char_u *pat; if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) *************** *** 1644,1650 **** int idx; int skip = FALSE; int pending = CSTP_NONE; ! struct condstack *cstack = eap->cstack; if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E606: :finally without :try"); --- 1644,1650 ---- int idx; int skip = FALSE; int pending = CSTP_NONE; ! cstack_T *cstack = eap->cstack; if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E606: :finally without :try"); *************** *** 1773,1779 **** int rethrow = FALSE; int pending = CSTP_NONE; void *rettv = NULL; ! struct condstack *cstack = eap->cstack; if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E602: :endtry without :try"); --- 1773,1779 ---- int rethrow = FALSE; int pending = CSTP_NONE; void *rettv = NULL; ! cstack_T *cstack = eap->cstack; if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) eap->errmsg = N_("E602: :endtry without :try"); *************** *** 2113,2119 **** */ int cleanup_conditionals( ! struct condstack *cstack, int searched_cond, int inclusive) { --- 2113,2119 ---- */ int cleanup_conditionals( ! cstack_T *cstack, int searched_cond, int inclusive) { *************** *** 2235,2241 **** * Return an appropriate error message for a missing endwhile/endfor/endif. */ static char * ! get_end_emsg(struct condstack *cstack) { if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) return e_endwhile; --- 2235,2241 ---- * Return an appropriate error message for a missing endwhile/endfor/endif. */ static char * ! get_end_emsg(cstack_T *cstack) { if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) return e_endwhile; *************** *** 2254,2260 **** */ void rewind_conditionals( ! struct condstack *cstack, int idx, int cond_type, int *cond_level) --- 2254,2260 ---- */ void rewind_conditionals( ! cstack_T *cstack, int idx, int cond_type, int *cond_level) *** ../vim-8.2.0012/src/userfunc.c 2019-12-05 21:42:45.000000000 +0100 --- src/userfunc.c 2019-12-16 16:59:49.161751270 +0100 *************** *** 3234,3240 **** void *rettv) { int idx; ! struct condstack *cstack = eap->cstack; if (reanimate) // Undo the return. --- 3234,3240 ---- void *rettv) { int idx; ! cstack_T *cstack = eap->cstack; if (reanimate) // Undo the return. *** ../vim-8.2.0012/src/ex_cmds.h 2019-12-06 21:02:00.000000000 +0100 --- src/ex_cmds.h 2019-12-16 16:59:54.429729416 +0100 *************** *** 1841,1847 **** char_u *(*getline)(int, void *, int, int); void *cookie; // argument for getline() #ifdef FEAT_EVAL ! struct condstack *cstack; // condition stack for ":if" etc. #endif long verbose_save; // saved value of p_verbose int save_msg_silent; // saved value of msg_silent --- 1841,1847 ---- char_u *(*getline)(int, void *, int, int); void *cookie; // argument for getline() #ifdef FEAT_EVAL ! cstack_T *cstack; // condition stack for ":if" etc. #endif long verbose_save; // saved value of p_verbose int save_msg_silent; // saved value of msg_silent *** ../vim-8.2.0012/src/proto/ex_eval.pro 2019-12-12 12:55:20.000000000 +0100 --- src/proto/ex_eval.pro 2019-12-16 17:01:42.145284598 +0100 *************** *** 5,12 **** int aborted_in_try(void); int cause_errthrow(char_u *mesg, int severe, int *ignore); void free_global_msglist(void); ! void do_errthrow(struct condstack *cstack, char_u *cmdname); ! int do_intthrow(struct condstack *cstack); char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free); void discard_current_exception(void); void report_make_pending(int pending, void *value); --- 5,12 ---- int aborted_in_try(void); int cause_errthrow(char_u *mesg, int severe, int *ignore); void free_global_msglist(void); ! void do_errthrow(cstack_T *cstack, char_u *cmdname); ! int do_intthrow(cstack_T *cstack); char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free); void discard_current_exception(void); void report_make_pending(int pending, void *value); *************** *** 19,33 **** void ex_break(exarg_T *eap); void ex_endwhile(exarg_T *eap); void ex_throw(exarg_T *eap); ! void do_throw(struct condstack *cstack); void ex_try(exarg_T *eap); void ex_catch(exarg_T *eap); void ex_finally(exarg_T *eap); void ex_endtry(exarg_T *eap); void enter_cleanup(cleanup_T *csp); void leave_cleanup(cleanup_T *csp); ! int cleanup_conditionals(struct condstack *cstack, int searched_cond, int inclusive); ! void rewind_conditionals(struct condstack *cstack, int idx, int cond_type, int *cond_level); void ex_endfunction(exarg_T *eap); int has_loop_cmd(char_u *p); /* vim: set ft=c : */ --- 19,33 ---- void ex_break(exarg_T *eap); void ex_endwhile(exarg_T *eap); void ex_throw(exarg_T *eap); ! void do_throw(cstack_T *cstack); void ex_try(exarg_T *eap); void ex_catch(exarg_T *eap); void ex_finally(exarg_T *eap); void ex_endtry(exarg_T *eap); void enter_cleanup(cleanup_T *csp); void leave_cleanup(cleanup_T *csp); ! int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive); ! void rewind_conditionals(cstack_T *cstack, int idx, int cond_type, int *cond_level); void ex_endfunction(exarg_T *eap); int has_loop_cmd(char_u *p); /* vim: set ft=c : */ *** ../vim-8.2.0012/src/version.c 2019-12-15 18:09:15.173552020 +0100 --- src/version.c 2019-12-16 17:09:45.443324354 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 13, /**/ -- Facepalm reply #3: "I had a great time in Manhattan" "I thought you were going to New York?" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///