From 055409764ca5f7978d4c399d2c440af0ce971c4f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 30 Jan 2016 20:31:25 +0100 Subject: patch 7.4.1213 Problem: Using old style function declarations. Solution: Change to new style function declarations. (script by Hirohito Higashi) --- src/regexp_nfa.c | 304 +++++++++++++++++++++---------------------------------- 1 file changed, 113 insertions(+), 191 deletions(-) (limited to 'src/regexp_nfa.c') diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index cbb3d308b..8bcf3bc41 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -332,9 +332,9 @@ static int failure_chance(nfa_state_T *state, int depth); * Return OK on success, FAIL otherwise. */ static int -nfa_regcomp_start(expr, re_flags) - char_u *expr; - int re_flags; /* see vim_regcomp() */ +nfa_regcomp_start( + char_u *expr, + int re_flags) /* see vim_regcomp() */ { size_t postfix_size; int nstate_max; @@ -370,9 +370,7 @@ nfa_regcomp_start(expr, re_flags) * of the line. */ static int -nfa_get_reganch(start, depth) - nfa_state_T *start; - int depth; +nfa_get_reganch(nfa_state_T *start, int depth) { nfa_state_T *p = start; @@ -434,9 +432,7 @@ nfa_get_reganch(start, depth) * at start of the match. */ static int -nfa_get_regstart(start, depth) - nfa_state_T *start; - int depth; +nfa_get_regstart(nfa_state_T *start, int depth) { nfa_state_T *p = start; @@ -520,8 +516,7 @@ nfa_get_regstart(start, depth) * regstart. Otherwise return NULL. */ static char_u * -nfa_get_match_text(start) - nfa_state_T *start; +nfa_get_match_text(nfa_state_T *start) { nfa_state_T *p = start; int len = 0; @@ -564,7 +559,7 @@ nfa_get_match_text(start) * running above the estimated number of states. */ static int -realloc_post_list() +realloc_post_list(void) { int nstate_max = (int)(post_end - post_start); int new_max = nstate_max + 1000; @@ -594,10 +589,7 @@ realloc_post_list() * need to be interpreted as [a-zA-Z]. */ static int -nfa_recognize_char_class(start, end, extra_newl) - char_u *start; - char_u *end; - int extra_newl; +nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) { # define CLASS_not 0x80 # define CLASS_af 0x40 @@ -744,8 +736,7 @@ nfa_recognize_char_class(start, end, extra_newl) * NOTE! When changing this function, also update reg_equi_class() */ static int -nfa_emit_equi_class(c) - int c; +nfa_emit_equi_class(int c) { #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); #ifdef FEAT_MBYTE @@ -1118,7 +1109,7 @@ nfa_emit_equi_class(c) * or \z( pattern \) */ static int -nfa_regatom() +nfa_regatom(void) { int c; int charclass; @@ -1890,7 +1881,7 @@ nfa_do_multibyte: * or atom multi */ static int -nfa_regpiece() +nfa_regpiece(void) { int i; int op; @@ -2100,7 +2091,7 @@ nfa_regpiece() * etc. */ static int -nfa_regconcat() +nfa_regconcat(void) { int cont = TRUE; int first = TRUE; @@ -2178,7 +2169,7 @@ nfa_regconcat() * etc. */ static int -nfa_regbranch() +nfa_regbranch(void) { int ch; int old_post_pos; @@ -2225,8 +2216,8 @@ nfa_regbranch() * etc. */ static int -nfa_reg(paren) - int paren; /* REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN */ +nfa_reg( + int paren) /* REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN */ { int parno = 0; @@ -2293,8 +2284,7 @@ nfa_reg(paren) static char_u code[50]; static void -nfa_set_code(c) - int c; +nfa_set_code(int c) { int addnl = FALSE; @@ -2530,9 +2520,7 @@ static FILE *log_fd; * Print the postfix notation of the current regexp. */ static void -nfa_postfix_dump(expr, retval) - char_u *expr; - int retval; +nfa_postfix_dump(char_u *expr, int retval) { int *p; FILE *f; @@ -2563,9 +2551,7 @@ nfa_postfix_dump(expr, retval) * Print the NFA starting with a root node "state". */ static void -nfa_print_state(debugf, state) - FILE *debugf; - nfa_state_T *state; +nfa_print_state(FILE *debugf, nfa_state_T *state) { garray_T indent; @@ -2576,10 +2562,7 @@ nfa_print_state(debugf, state) } static void -nfa_print_state2(debugf, state, indent) - FILE *debugf; - nfa_state_T *state; - garray_T *indent; +nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent) { char_u *p; @@ -2640,8 +2623,7 @@ nfa_print_state2(debugf, state, indent) * Print the NFA state machine. */ static void -nfa_dump(prog) - nfa_regprog_T *prog; +nfa_dump(nfa_regprog_T *prog) { FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a"); @@ -2668,7 +2650,7 @@ nfa_dump(prog) * Return the postfix string on success, NULL otherwise. */ static int * -re2post() +re2post(void) { if (nfa_reg(REG_NOPAREN) == FAIL) return NULL; @@ -2691,10 +2673,7 @@ static nfa_state_T *state_ptr; /* points to nfa_prog->state */ * Allocate and initialize nfa_state_T. */ static nfa_state_T * -alloc_state(c, out, out1) - int c; - nfa_state_T *out; - nfa_state_T *out1; +alloc_state(int c, nfa_state_T *out, nfa_state_T *out1) { nfa_state_T *s; @@ -2750,9 +2729,7 @@ static Frag_T st_pop(Frag_T **p, Frag_T *stack); * Initialize a Frag_T struct and return it. */ static Frag_T -frag(start, out) - nfa_state_T *start; - Ptrlist *out; +frag(nfa_state_T *start, Ptrlist *out) { Frag_T n; @@ -2765,8 +2742,8 @@ frag(start, out) * Create singleton list containing just outp. */ static Ptrlist * -list1(outp) - nfa_state_T **outp; +list1( + nfa_state_T **outp) { Ptrlist *l; @@ -2779,9 +2756,7 @@ list1(outp) * Patch the list of states at out to point to start. */ static void -patch(l, s) - Ptrlist *l; - nfa_state_T *s; +patch(Ptrlist *l, nfa_state_T *s) { Ptrlist *next; @@ -2797,9 +2772,7 @@ patch(l, s) * Join the two lists l1 and l2, returning the combination. */ static Ptrlist * -append(l1, l2) - Ptrlist *l1; - Ptrlist *l2; +append(Ptrlist *l1, Ptrlist *l2) { Ptrlist *oldl1; @@ -2816,10 +2789,7 @@ append(l1, l2) static Frag_T empty; static void -st_error(postfix, end, p) - int *postfix UNUSED; - int *end UNUSED; - int *p UNUSED; +st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED) { #ifdef NFA_REGEXP_ERROR_LOG FILE *df; @@ -2868,10 +2838,7 @@ st_error(postfix, end, p) * Push an item onto the stack. */ static void -st_push(s, p, stack_end) - Frag_T s; - Frag_T **p; - Frag_T *stack_end; +st_push(Frag_T s, Frag_T **p, Frag_T *stack_end) { Frag_T *stackp = *p; @@ -2885,9 +2852,7 @@ st_push(s, p, stack_end) * Pop an item from the stack. */ static Frag_T -st_pop(p, stack) - Frag_T **p; - Frag_T *stack; +st_pop(Frag_T **p, Frag_T *stack) { Frag_T *stackp; @@ -2903,9 +2868,7 @@ st_pop(p, stack) * When unknown or unlimited return -1. */ static int -nfa_max_width(startstate, depth) - nfa_state_T *startstate; - int depth; +nfa_max_width(nfa_state_T *startstate, int depth) { int l, r; nfa_state_T *state = startstate; @@ -3128,10 +3091,7 @@ nfa_max_width(startstate, depth) * Return the NFA start state on success, NULL otherwise. */ static nfa_state_T * -post2nfa(postfix, end, nfa_calc_size) - int *postfix; - int *end; - int nfa_calc_size; +post2nfa(int *postfix, int *end, int nfa_calc_size) { int *p; int mopen; @@ -3667,8 +3627,7 @@ theend: * After building the NFA program, inspect it to add optimization hints. */ static void -nfa_postprocess(prog) - nfa_regprog_T *prog; +nfa_postprocess(nfa_regprog_T *prog) { int i; int c; @@ -3801,8 +3760,7 @@ static void log_subexpr(regsub_T *sub); static char *pim_info(nfa_pim_T *pim); static void -log_subsexpr(subs) - regsubs_T *subs; +log_subsexpr(regsubs_T *subs) { log_subexpr(&subs->norm); # ifdef FEAT_SYN_HL @@ -3812,8 +3770,7 @@ log_subsexpr(subs) } static void -log_subexpr(sub) - regsub_T *sub; +log_subexpr(regsub_T *sub) { int j; @@ -3838,8 +3795,7 @@ log_subexpr(sub) } static char * -pim_info(pim) - nfa_pim_T *pim; +pim_info(nfa_pim_T *pim) { static char buf[30]; @@ -3879,9 +3835,7 @@ static void addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nf * Copy postponed invisible match info from "from" to "to". */ static void -copy_pim(to, from) - nfa_pim_T *to; - nfa_pim_T *from; +copy_pim(nfa_pim_T *to, nfa_pim_T *from) { to->result = from->result; to->state = from->state; @@ -3894,8 +3848,7 @@ copy_pim(to, from) } static void -clear_sub(sub) - regsub_T *sub; +clear_sub(regsub_T *sub) { if (REG_MULTI) /* Use 0xff to set lnum to -1 */ @@ -3910,9 +3863,7 @@ clear_sub(sub) * Copy the submatches from "from" to "to". */ static void -copy_sub(to, from) - regsub_T *to; - regsub_T *from; +copy_sub(regsub_T *to, regsub_T *from) { to->in_use = from->in_use; if (from->in_use > 0) @@ -3933,9 +3884,7 @@ copy_sub(to, from) * Like copy_sub() but exclude the main match. */ static void -copy_sub_off(to, from) - regsub_T *to; - regsub_T *from; +copy_sub_off(regsub_T *to, regsub_T *from) { if (to->in_use < from->in_use) to->in_use = from->in_use; @@ -3957,9 +3906,7 @@ copy_sub_off(to, from) * Like copy_sub() but only do the end of the main match if \ze is present. */ static void -copy_ze_off(to, from) - regsub_T *to; - regsub_T *from; +copy_ze_off(regsub_T *to, regsub_T *from) { if (nfa_has_zend) { @@ -3984,9 +3931,7 @@ copy_ze_off(to, from) * When using back-references also check the end position. */ static int -sub_equal(sub1, sub2) - regsub_T *sub1; - regsub_T *sub2; +sub_equal(regsub_T *sub1, regsub_T *sub2) { int i; int todo; @@ -4093,11 +4038,11 @@ report_state(char *action, * positions as "subs". */ static int -has_state_with_pos(l, state, subs, pim) - nfa_list_T *l; /* runtime state list */ - nfa_state_T *state; /* state to update */ - regsubs_T *subs; /* pointers to subexpressions */ - nfa_pim_T *pim; /* postponed match or NULL */ +has_state_with_pos( + nfa_list_T *l, /* runtime state list */ + nfa_state_T *state, /* state to update */ + regsubs_T *subs, /* pointers to subexpressions */ + nfa_pim_T *pim) /* postponed match or NULL */ { nfa_thread_T *thread; int i; @@ -4122,9 +4067,7 @@ has_state_with_pos(l, state, subs, pim) * set. */ static int -pim_equal(one, two) - nfa_pim_T *one; - nfa_pim_T *two; +pim_equal(nfa_pim_T *one, nfa_pim_T *two) { int one_unused = (one == NULL || one->result == NFA_PIM_UNUSED); int two_unused = (two == NULL || two->result == NFA_PIM_UNUSED); @@ -4149,9 +4092,7 @@ pim_equal(one, two) * Return TRUE if "state" leads to a NFA_MATCH without advancing the input. */ static int -match_follows(startstate, depth) - nfa_state_T *startstate; - int depth; +match_follows(nfa_state_T *startstate, int depth) { nfa_state_T *state = startstate; @@ -4244,10 +4185,10 @@ match_follows(startstate, depth) * Return TRUE if "state" is already in list "l". */ static int -state_in_list(l, state, subs) - nfa_list_T *l; /* runtime state list */ - nfa_state_T *state; /* state to update */ - regsubs_T *subs; /* pointers to subexpressions */ +state_in_list( + nfa_list_T *l, /* runtime state list */ + nfa_state_T *state, /* state to update */ + regsubs_T *subs) /* pointers to subexpressions */ { if (state->lastlist[nfa_ll_index] == l->id) { @@ -4262,12 +4203,12 @@ state_in_list(l, state, subs) * Returns "subs_arg", possibly copied into temp_subs. */ static regsubs_T * -addstate(l, state, subs_arg, pim, off) - nfa_list_T *l; /* runtime state list */ - nfa_state_T *state; /* state to update */ - regsubs_T *subs_arg; /* pointers to subexpressions */ - nfa_pim_T *pim; /* postponed look-behind match */ - int off; /* byte offset, when -1 go to next line */ +addstate( + nfa_list_T *l, /* runtime state list */ + nfa_state_T *state, /* state to update */ + regsubs_T *subs_arg, /* pointers to subexpressions */ + nfa_pim_T *pim, /* postponed look-behind match */ + int off) /* byte offset, when -1 go to next line */ { int subidx; nfa_thread_T *thread; @@ -4678,12 +4619,12 @@ skip_add: * matters for alternatives. */ static void -addstate_here(l, state, subs, pim, ip) - nfa_list_T *l; /* runtime state list */ - nfa_state_T *state; /* state to update */ - regsubs_T *subs; /* pointers to subexpressions */ - nfa_pim_T *pim; /* postponed look-behind match */ - int *ip; +addstate_here( + nfa_list_T *l, /* runtime state list */ + nfa_state_T *state, /* state to update */ + regsubs_T *subs, /* pointers to subexpressions */ + nfa_pim_T *pim, /* postponed look-behind match */ + int *ip) { int tlen = l->n; int count; @@ -4749,9 +4690,7 @@ addstate_here(l, state, subs, pim, ip) * Check character class "class" against current character c. */ static int -check_char_class(class, c) - int class; - int c; +check_char_class(int class, int c) { switch (class) { @@ -4833,10 +4772,10 @@ check_char_class(class, c) * Return TRUE if it matches. */ static int -match_backref(sub, subidx, bytelen) - regsub_T *sub; /* pointers to subexpressions */ - int subidx; - int *bytelen; /* out: length of match in bytes */ +match_backref( + regsub_T *sub, /* pointers to subexpressions */ + int subidx, + int *bytelen) /* out: length of match in bytes */ { int len; @@ -4900,9 +4839,9 @@ static int match_zref(int subidx, int *bytelen); * Return TRUE if it matches. */ static int -match_zref(subidx, bytelen) - int subidx; - int *bytelen; /* out: length of match in bytes */ +match_zref( + int subidx, + int *bytelen) /* out: length of match in bytes */ { int len; @@ -4930,9 +4869,7 @@ match_zref(subidx, bytelen) * Only used for the recursive value lastlist[1]. */ static void -nfa_save_listids(prog, list) - nfa_regprog_T *prog; - int *list; +nfa_save_listids(nfa_regprog_T *prog, int *list) { int i; nfa_state_T *p; @@ -4951,9 +4888,7 @@ nfa_save_listids(prog, list) * Restore list IDs from "list" to all NFA states. */ static void -nfa_restore_listids(prog, list) - nfa_regprog_T *prog; - int *list; +nfa_restore_listids(nfa_regprog_T *prog, int *list) { int i; nfa_state_T *p; @@ -4967,10 +4902,7 @@ nfa_restore_listids(prog, list) } static int -nfa_re_num_cmp(val, op, pos) - long_u val; - int op; - long_u pos; +nfa_re_num_cmp(long_u val, int op, long_u pos) { if (op == 1) return pos > val; if (op == 2) return pos < val; @@ -4986,13 +4918,13 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm * position). */ static int -recursive_regmatch(state, pim, prog, submatch, m, listids) - nfa_state_T *state; - nfa_pim_T *pim; - nfa_regprog_T *prog; - regsubs_T *submatch; - regsubs_T *m; - int **listids; +recursive_regmatch( + nfa_state_T *state, + nfa_pim_T *pim, + nfa_regprog_T *prog, + regsubs_T *submatch, + regsubs_T *m, + int **listids) { int save_reginput_col = (int)(reginput - regline); int save_reglnum = reglnum; @@ -5168,9 +5100,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text); * specific character: 99 */ static int -failure_chance(state, depth) - nfa_state_T *state; - int depth; +failure_chance(nfa_state_T *state, int depth) { int c = state->c; int l, r; @@ -5330,9 +5260,7 @@ failure_chance(state, depth) * Skip until the char "c" we know a match must start with. */ static int -skip_to_start(c, colp) - int c; - colnr_T *colp; +skip_to_start(int c, colnr_T *colp) { char_u *s; @@ -5357,10 +5285,7 @@ skip_to_start(c, colp) * Returns zero for no match, 1 for a match. */ static long -find_match_text(startcol, regstart, match_text) - colnr_T startcol; - int regstart; - char_u *match_text; +find_match_text(colnr_T startcol, int regstart, char_u *match_text) { colnr_T col = startcol; int c1, c2; @@ -5426,11 +5351,11 @@ find_match_text(startcol, regstart, match_text) * Note: Caller must ensure that: start != NULL. */ static int -nfa_regmatch(prog, start, submatch, m) - nfa_regprog_T *prog; - nfa_state_T *start; - regsubs_T *submatch; - regsubs_T *m; +nfa_regmatch( + nfa_regprog_T *prog, + nfa_state_T *start, + regsubs_T *submatch, + regsubs_T *m) { int result; size_t size = 0; @@ -6847,10 +6772,10 @@ theend: * Returns <= 0 for failure, number of lines contained in the match otherwise. */ static long -nfa_regtry(prog, col, tm) - nfa_regprog_T *prog; - colnr_T col; - proftime_T *tm UNUSED; /* timeout limit or NULL */ +nfa_regtry( + nfa_regprog_T *prog, + colnr_T col, + proftime_T *tm UNUSED) /* timeout limit or NULL */ { int i; regsubs_T subs, m; @@ -6986,10 +6911,10 @@ nfa_regtry(prog, col, tm) * Returns <= 0 for failure, number of lines contained in the match otherwise. */ static long -nfa_regexec_both(line, startcol, tm) - char_u *line; - colnr_T startcol; /* column to start looking for match */ - proftime_T *tm; /* timeout limit or NULL */ +nfa_regexec_both( + char_u *line, + colnr_T startcol, /* column to start looking for match */ + proftime_T *tm) /* timeout limit or NULL */ { nfa_regprog_T *prog; long retval = 0L; @@ -7096,9 +7021,7 @@ theend: * Returns the program in allocated space. Returns NULL for an error. */ static regprog_T * -nfa_regcomp(expr, re_flags) - char_u *expr; - int re_flags; +nfa_regcomp(char_u *expr, int re_flags) { nfa_regprog_T *prog = NULL; size_t prog_size; @@ -7208,8 +7131,7 @@ fail: * Free a compiled regexp program, returned by nfa_regcomp(). */ static void -nfa_regfree(prog) - regprog_T *prog; +nfa_regfree(regprog_T *prog) { if (prog != NULL) { @@ -7228,11 +7150,11 @@ nfa_regfree(prog) * Returns <= 0 for failure, number of lines contained in the match otherwise. */ static int -nfa_regexec_nl(rmp, line, col, line_lbr) - regmatch_T *rmp; - char_u *line; /* string to match against */ - colnr_T col; /* column to start looking for match */ - int line_lbr; +nfa_regexec_nl( + regmatch_T *rmp, + char_u *line, /* string to match against */ + colnr_T col, /* column to start looking for match */ + int line_lbr) { reg_match = rmp; reg_mmatch = NULL; @@ -7275,13 +7197,13 @@ nfa_regexec_nl(rmp, line, col, line_lbr) * FIXME if this behavior is not compatible. */ static long -nfa_regexec_multi(rmp, win, buf, lnum, col, tm) - regmmatch_T *rmp; - win_T *win; /* window in which to search or NULL */ - buf_T *buf; /* buffer in which to search */ - linenr_T lnum; /* nr of line to start looking for match */ - colnr_T col; /* column to start looking for match */ - proftime_T *tm; /* timeout limit or NULL */ +nfa_regexec_multi( + regmmatch_T *rmp, + win_T *win, /* window in which to search or NULL */ + buf_T *buf, /* buffer in which to search */ + linenr_T lnum, /* nr of line to start looking for match */ + colnr_T col, /* column to start looking for match */ + proftime_T *tm) /* timeout limit or NULL */ { reg_match = NULL; reg_mmatch = rmp; -- cgit v1.2.1