0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.0013: not using a typedef for condstack

Problem:    Not using a typedef for condstack.
Solution:   Add a typedef.
This commit is contained in:
Bram Moolenaar
2019-12-16 17:10:33 +01:00
parent 559b9c68fe
commit ddef129160
7 changed files with 52 additions and 51 deletions

View File

@@ -1841,7 +1841,7 @@ struct exarg
char_u *(*getline)(int, void *, int, int); char_u *(*getline)(int, void *, int, int);
void *cookie; // argument for getline() void *cookie; // argument for getline()
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
struct condstack *cstack; // condition stack for ":if" etc. cstack_T *cstack; // condition stack for ":if" etc.
#endif #endif
long verbose_save; // saved value of p_verbose long verbose_save; // saved value of p_verbose
int save_msg_silent; // saved value of msg_silent int save_msg_silent; // saved value of msg_silent

View File

@@ -20,7 +20,7 @@ static int ex_pressedreturn = FALSE;
#endif #endif
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int, int), void *cookie); static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, void *, int, int), void *cookie);
#else #else
static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, int), void *cookie); 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 static int if_level = 0; // depth in :if
@@ -623,7 +623,7 @@ do_cmdline(
int did_inc = FALSE; // incremented RedrawingDisabled int did_inc = FALSE; // incremented RedrawingDisabled
int retval = OK; int retval = OK;
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
struct condstack cstack; // conditional stack cstack_T cstack; // conditional stack
garray_T lines_ga; // keep lines for ":while"/":for" garray_T lines_ga; // keep lines for ":while"/":for"
int current_line = 0; // active line in lines_ga int current_line = 0; // active line in lines_ga
char_u *fname = NULL; // function or script name char_u *fname = NULL; // function or script name
@@ -671,7 +671,7 @@ do_cmdline(
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
// When converting to an exception, we do not include the command name // When converting to an exception, we do not include the command name
// since this is not an error of the specific command. // since this is not an error of the specific command.
do_errthrow((struct condstack *)NULL, (char_u *)NULL); do_errthrow((cstack_T *)NULL, (char_u *)NULL);
msg_list = saved_msg_list; msg_list = saved_msg_list;
#endif #endif
return FAIL; return FAIL;
@@ -1628,25 +1628,25 @@ current_tab_nr(tabpage_T *tab)
#endif #endif
static char_u * static char_u *
do_one_cmd( do_one_cmd(
char_u **cmdlinep, char_u **cmdlinep,
int sourcing, int sourcing,
#ifdef FEAT_EVAL #ifdef FEAT_EVAL
struct condstack *cstack, cstack_T *cstack,
#endif #endif
char_u *(*fgetline)(int, void *, int, int), char_u *(*fgetline)(int, void *, int, int),
void *cookie) // argument for fgetline() void *cookie) // argument for fgetline()
{ {
char_u *p; char_u *p;
linenr_T lnum; linenr_T lnum;
long n; long n;
char *errormsg = NULL; // error message char *errormsg = NULL; // error message
char_u *after_modifier = NULL; char_u *after_modifier = NULL;
exarg_T ea; // Ex command arguments exarg_T ea; // Ex command arguments
int save_msg_scroll = msg_scroll; int save_msg_scroll = msg_scroll;
cmdmod_T save_cmdmod; cmdmod_T save_cmdmod;
int save_reg_executing = reg_executing; int save_reg_executing = reg_executing;
int ni; // set when Not Implemented int ni; // set when Not Implemented
char_u *cmd; char_u *cmd;
vim_memset(&ea, 0, sizeof(ea)); vim_memset(&ea, 0, sizeof(ea));
ea.line1 = 1; ea.line1 = 1;

View File

@@ -16,7 +16,7 @@
#if defined(FEAT_EVAL) || defined(PROTO) #if defined(FEAT_EVAL) || defined(PROTO)
static int throw_exception(void *, except_type_T, char_u *); static int throw_exception(void *, except_type_T, char_u *);
static char *get_end_emsg(struct condstack *cstack); static char *get_end_emsg(cstack_T *cstack);
/* /*
* Exception handling terms: * Exception handling terms:
@@ -330,7 +330,7 @@ free_global_msglist(void)
* has returned (see do_one_cmd()). * has returned (see do_one_cmd()).
*/ */
void void
do_errthrow(struct condstack *cstack, char_u *cmdname) do_errthrow(cstack_T *cstack, char_u *cmdname)
{ {
/* /*
* Ensure that all commands in nested function calls and sourced files * Ensure that all commands in nested function calls and sourced files
@@ -365,7 +365,7 @@ do_errthrow(struct condstack *cstack, char_u *cmdname)
* FALSE otherwise. * FALSE otherwise.
*/ */
int int
do_intthrow(struct condstack *cstack) do_intthrow(cstack_T *cstack)
{ {
/* /*
* If no interrupt occurred or no try conditional is active and no exception * If no interrupt occurred or no try conditional is active and no exception
@@ -892,7 +892,7 @@ ex_if(exarg_T *eap)
int error; int error;
int skip; int skip;
int result; int result;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) if (cstack->cs_idx == CSTACK_LEN - 1)
eap->errmsg = N_("E579: :if nesting too deep"); eap->errmsg = N_("E579: :if nesting too deep");
@@ -960,7 +960,7 @@ ex_else(exarg_T *eap)
int error; int error;
int skip; int skip;
int result; int result;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
/* /*
* Don't do something after an error, interrupt, or throw, or when there is * Don't do something after an error, interrupt, or throw, or when there is
@@ -1051,7 +1051,7 @@ ex_while(exarg_T *eap)
int error; int error;
int skip; int skip;
int result; int result;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) if (cstack->cs_idx == CSTACK_LEN - 1)
eap->errmsg = N_("E585: :while/:for nesting too deep"); eap->errmsg = N_("E585: :while/:for nesting too deep");
@@ -1148,7 +1148,7 @@ ex_while(exarg_T *eap)
ex_continue(exarg_T *eap) ex_continue(exarg_T *eap)
{ {
int idx; int idx;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
eap->errmsg = N_("E586: :continue without :while or :for"); eap->errmsg = N_("E586: :continue without :while or :for");
@@ -1186,7 +1186,7 @@ ex_continue(exarg_T *eap)
ex_break(exarg_T *eap) ex_break(exarg_T *eap)
{ {
int idx; int idx;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0)
eap->errmsg = N_("E587: :break without :while or :for"); eap->errmsg = N_("E587: :break without :while or :for");
@@ -1211,11 +1211,11 @@ ex_break(exarg_T *eap)
void void
ex_endwhile(exarg_T *eap) ex_endwhile(exarg_T *eap)
{ {
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
int idx; int idx;
char *err; char *err;
int csf; int csf;
int fl; int fl;
if (eap->cmdidx == CMD_endwhile) if (eap->cmdidx == CMD_endwhile)
{ {
@@ -1325,7 +1325,7 @@ ex_throw(exarg_T *eap)
* used for rethrowing an uncaught exception. * used for rethrowing an uncaught exception.
*/ */
void void
do_throw(struct condstack *cstack) do_throw(cstack_T *cstack)
{ {
int idx; int idx;
int inactivate_try = FALSE; int inactivate_try = FALSE;
@@ -1409,7 +1409,7 @@ do_throw(struct condstack *cstack)
ex_try(exarg_T *eap) ex_try(exarg_T *eap)
{ {
int skip; int skip;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) if (cstack->cs_idx == CSTACK_LEN - 1)
eap->errmsg = N_("E601: :try nesting too deep"); eap->errmsg = N_("E601: :try nesting too deep");
@@ -1486,7 +1486,7 @@ ex_catch(exarg_T *eap)
char_u *save_cpo; char_u *save_cpo;
regmatch_T regmatch; regmatch_T regmatch;
int prev_got_int; int prev_got_int;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
char_u *pat; char_u *pat;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
@@ -1644,7 +1644,7 @@ ex_finally(exarg_T *eap)
int idx; int idx;
int skip = FALSE; int skip = FALSE;
int pending = CSTP_NONE; int pending = CSTP_NONE;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
eap->errmsg = N_("E606: :finally without :try"); eap->errmsg = N_("E606: :finally without :try");
@@ -1773,7 +1773,7 @@ ex_endtry(exarg_T *eap)
int rethrow = FALSE; int rethrow = FALSE;
int pending = CSTP_NONE; int pending = CSTP_NONE;
void *rettv = NULL; void *rettv = NULL;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0)
eap->errmsg = N_("E602: :endtry without :try"); eap->errmsg = N_("E602: :endtry without :try");
@@ -2113,7 +2113,7 @@ leave_cleanup(cleanup_T *csp)
*/ */
int int
cleanup_conditionals( cleanup_conditionals(
struct condstack *cstack, cstack_T *cstack,
int searched_cond, int searched_cond,
int inclusive) int inclusive)
{ {
@@ -2235,7 +2235,7 @@ cleanup_conditionals(
* Return an appropriate error message for a missing endwhile/endfor/endif. * Return an appropriate error message for a missing endwhile/endfor/endif.
*/ */
static char * static char *
get_end_emsg(struct condstack *cstack) get_end_emsg(cstack_T *cstack)
{ {
if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE)
return e_endwhile; return e_endwhile;
@@ -2254,7 +2254,7 @@ get_end_emsg(struct condstack *cstack)
*/ */
void void
rewind_conditionals( rewind_conditionals(
struct condstack *cstack, cstack_T *cstack,
int idx, int idx,
int cond_type, int cond_type,
int *cond_level) int *cond_level)

View File

@@ -5,8 +5,8 @@ int should_abort(int retcode);
int aborted_in_try(void); int aborted_in_try(void);
int cause_errthrow(char_u *mesg, int severe, int *ignore); int cause_errthrow(char_u *mesg, int severe, int *ignore);
void free_global_msglist(void); void free_global_msglist(void);
void do_errthrow(struct condstack *cstack, char_u *cmdname); void do_errthrow(cstack_T *cstack, char_u *cmdname);
int do_intthrow(struct condstack *cstack); int do_intthrow(cstack_T *cstack);
char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free); char *get_exception_string(void *value, except_type_T type, char_u *cmdname, int *should_free);
void discard_current_exception(void); void discard_current_exception(void);
void report_make_pending(int pending, void *value); void report_make_pending(int pending, void *value);
@@ -19,15 +19,15 @@ void ex_continue(exarg_T *eap);
void ex_break(exarg_T *eap); void ex_break(exarg_T *eap);
void ex_endwhile(exarg_T *eap); void ex_endwhile(exarg_T *eap);
void ex_throw(exarg_T *eap); void ex_throw(exarg_T *eap);
void do_throw(struct condstack *cstack); void do_throw(cstack_T *cstack);
void ex_try(exarg_T *eap); void ex_try(exarg_T *eap);
void ex_catch(exarg_T *eap); void ex_catch(exarg_T *eap);
void ex_finally(exarg_T *eap); void ex_finally(exarg_T *eap);
void ex_endtry(exarg_T *eap); void ex_endtry(exarg_T *eap);
void enter_cleanup(cleanup_T *csp); void enter_cleanup(cleanup_T *csp);
void leave_cleanup(cleanup_T *csp); void leave_cleanup(cleanup_T *csp);
int cleanup_conditionals(struct condstack *cstack, int searched_cond, int inclusive); int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive);
void rewind_conditionals(struct condstack *cstack, int idx, int cond_type, int *cond_level); void rewind_conditionals(cstack_T *cstack, int idx, int cond_type, int *cond_level);
void ex_endfunction(exarg_T *eap); void ex_endfunction(exarg_T *eap);
int has_loop_cmd(char_u *p); int has_loop_cmd(char_u *p);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -863,8 +863,7 @@ struct eslist_elem
*/ */
#define CSTACK_LEN 50 #define CSTACK_LEN 50
struct condstack typedef struct {
{
short cs_flags[CSTACK_LEN]; // CSF_ flags short cs_flags[CSTACK_LEN]; // CSF_ flags
char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally" char cs_pending[CSTACK_LEN]; // CSTP_: what's pending in ":finally"
union { union {
@@ -878,7 +877,7 @@ struct condstack
int cs_trylevel; // nr of nested ":try"s int cs_trylevel; // nr of nested ":try"s
eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent" eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent"
char cs_lflags; // loop flags: CSL_ flags char cs_lflags; // loop flags: CSL_ flags
}; } cstack_T;
# define cs_rettv cs_pend.csp_rv # define cs_rettv cs_pend.csp_rv
# define cs_exception cs_pend.csp_ex # define cs_exception cs_pend.csp_ex
@@ -912,7 +911,7 @@ struct condstack
# define CSTP_FINISH 32 // ":finish" is pending # define CSTP_FINISH 32 // ":finish" is pending
/* /*
* Flags for the cs_lflags item in struct condstack. * Flags for the cs_lflags item in cstack_T.
*/ */
# define CSL_HAD_LOOP 1 // just found ":while" or ":for" # define CSL_HAD_LOOP 1 // just found ":while" or ":for"
# define CSL_HAD_ENDLOOP 2 // just found ":endwhile" or ":endfor" # define CSL_HAD_ENDLOOP 2 // just found ":endwhile" or ":endfor"

View File

@@ -3234,7 +3234,7 @@ do_return(
void *rettv) void *rettv)
{ {
int idx; int idx;
struct condstack *cstack = eap->cstack; cstack_T *cstack = eap->cstack;
if (reanimate) if (reanimate)
// Undo the return. // Undo the return.

View File

@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
13,
/**/ /**/
12, 12,
/**/ /**/