comparison src/regexp_nfa.c @ 7805:0b6c37dd858d v7.4.1199

commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 29 22:47:03 2016 +0100 patch 7.4.1199 Problem: Still using __ARGS. Solution: Remove __ARGS in several files. (script by Hirohito Higashi)
author Christian Brabandt <cb@256bit.org>
date Fri, 29 Jan 2016 23:00:05 +0100
parents 7245d8635ac7
children c079097365f3
comparison
equal deleted inserted replaced
7804:874044d87168 7805:0b6c37dd858d
280 static int nfa_alt_listid; 280 static int nfa_alt_listid;
281 281
282 /* 0 for first call to nfa_regmatch(), 1 for recursive call. */ 282 /* 0 for first call to nfa_regmatch(), 1 for recursive call. */
283 static int nfa_ll_index = 0; 283 static int nfa_ll_index = 0;
284 284
285 static int nfa_regcomp_start __ARGS((char_u *expr, int re_flags)); 285 static int nfa_regcomp_start(char_u *expr, int re_flags);
286 static int nfa_get_reganch __ARGS((nfa_state_T *start, int depth)); 286 static int nfa_get_reganch(nfa_state_T *start, int depth);
287 static int nfa_get_regstart __ARGS((nfa_state_T *start, int depth)); 287 static int nfa_get_regstart(nfa_state_T *start, int depth);
288 static char_u *nfa_get_match_text __ARGS((nfa_state_T *start)); 288 static char_u *nfa_get_match_text(nfa_state_T *start);
289 static int realloc_post_list __ARGS((void)); 289 static int realloc_post_list(void);
290 static int nfa_recognize_char_class __ARGS((char_u *start, char_u *end, int extra_newl)); 290 static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl);
291 static int nfa_emit_equi_class __ARGS((int c)); 291 static int nfa_emit_equi_class(int c);
292 static int nfa_regatom __ARGS((void)); 292 static int nfa_regatom(void);
293 static int nfa_regpiece __ARGS((void)); 293 static int nfa_regpiece(void);
294 static int nfa_regconcat __ARGS((void)); 294 static int nfa_regconcat(void);
295 static int nfa_regbranch __ARGS((void)); 295 static int nfa_regbranch(void);
296 static int nfa_reg __ARGS((int paren)); 296 static int nfa_reg(int paren);
297 #ifdef DEBUG 297 #ifdef DEBUG
298 static void nfa_set_code __ARGS((int c)); 298 static void nfa_set_code(int c);
299 static void nfa_postfix_dump __ARGS((char_u *expr, int retval)); 299 static void nfa_postfix_dump(char_u *expr, int retval);
300 static void nfa_print_state __ARGS((FILE *debugf, nfa_state_T *state)); 300 static void nfa_print_state(FILE *debugf, nfa_state_T *state);
301 static void nfa_print_state2 __ARGS((FILE *debugf, nfa_state_T *state, garray_T *indent)); 301 static void nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent);
302 static void nfa_dump __ARGS((nfa_regprog_T *prog)); 302 static void nfa_dump(nfa_regprog_T *prog);
303 #endif 303 #endif
304 static int *re2post __ARGS((void)); 304 static int *re2post(void);
305 static nfa_state_T *alloc_state __ARGS((int c, nfa_state_T *out, nfa_state_T *out1)); 305 static nfa_state_T *alloc_state(int c, nfa_state_T *out, nfa_state_T *out1);
306 static void st_error __ARGS((int *postfix, int *end, int *p)); 306 static void st_error(int *postfix, int *end, int *p);
307 static int nfa_max_width __ARGS((nfa_state_T *startstate, int depth)); 307 static int nfa_max_width(nfa_state_T *startstate, int depth);
308 static nfa_state_T *post2nfa __ARGS((int *postfix, int *end, int nfa_calc_size)); 308 static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size);
309 static void nfa_postprocess __ARGS((nfa_regprog_T *prog)); 309 static void nfa_postprocess(nfa_regprog_T *prog);
310 static int check_char_class __ARGS((int class, int c)); 310 static int check_char_class(int class, int c);
311 static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list)); 311 static void nfa_save_listids(nfa_regprog_T *prog, int *list);
312 static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list)); 312 static void nfa_restore_listids(nfa_regprog_T *prog, int *list);
313 static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos)); 313 static int nfa_re_num_cmp(long_u val, int op, long_u pos);
314 static long nfa_regtry __ARGS((nfa_regprog_T *prog, colnr_T col, proftime_T *tm)); 314 static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm);
315 static long nfa_regexec_both __ARGS((char_u *line, colnr_T col, proftime_T *tm)); 315 static long nfa_regexec_both(char_u *line, colnr_T col, proftime_T *tm);
316 static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags)); 316 static regprog_T *nfa_regcomp(char_u *expr, int re_flags);
317 static void nfa_regfree __ARGS((regprog_T *prog)); 317 static void nfa_regfree(regprog_T *prog);
318 static int nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr)); 318 static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr);
319 static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm)); 319 static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm);
320 static int match_follows __ARGS((nfa_state_T *startstate, int depth)); 320 static int match_follows(nfa_state_T *startstate, int depth);
321 static int failure_chance __ARGS((nfa_state_T *state, int depth)); 321 static int failure_chance(nfa_state_T *state, int depth);
322 322
323 /* helper functions used when doing re2post() ... regatom() parsing */ 323 /* helper functions used when doing re2post() ... regatom() parsing */
324 #define EMIT(c) do { \ 324 #define EMIT(c) do { \
325 if (post_ptr >= post_end && realloc_post_list() == FAIL) \ 325 if (post_ptr >= post_end && realloc_post_list() == FAIL) \
326 return FAIL; \ 326 return FAIL; \
2737 nfa_state_T *start; 2737 nfa_state_T *start;
2738 Ptrlist *out; 2738 Ptrlist *out;
2739 }; 2739 };
2740 typedef struct Frag Frag_T; 2740 typedef struct Frag Frag_T;
2741 2741
2742 static Frag_T frag __ARGS((nfa_state_T *start, Ptrlist *out)); 2742 static Frag_T frag(nfa_state_T *start, Ptrlist *out);
2743 static Ptrlist *list1 __ARGS((nfa_state_T **outp)); 2743 static Ptrlist *list1(nfa_state_T **outp);
2744 static void patch __ARGS((Ptrlist *l, nfa_state_T *s)); 2744 static void patch(Ptrlist *l, nfa_state_T *s);
2745 static Ptrlist *append __ARGS((Ptrlist *l1, Ptrlist *l2)); 2745 static Ptrlist *append(Ptrlist *l1, Ptrlist *l2);
2746 static void st_push __ARGS((Frag_T s, Frag_T **p, Frag_T *stack_end)); 2746 static void st_push(Frag_T s, Frag_T **p, Frag_T *stack_end);
2747 static Frag_T st_pop __ARGS((Frag_T **p, Frag_T *stack)); 2747 static Frag_T st_pop(Frag_T **p, Frag_T *stack);
2748 2748
2749 /* 2749 /*
2750 * Initialize a Frag_T struct and return it. 2750 * Initialize a Frag_T struct and return it.
2751 */ 2751 */
2752 static Frag_T 2752 static Frag_T
3794 int id; /* ID of the list */ 3794 int id; /* ID of the list */
3795 int has_pim; /* TRUE when any state has a PIM */ 3795 int has_pim; /* TRUE when any state has a PIM */
3796 } nfa_list_T; 3796 } nfa_list_T;
3797 3797
3798 #ifdef ENABLE_LOG 3798 #ifdef ENABLE_LOG
3799 static void log_subsexpr __ARGS((regsubs_T *subs)); 3799 static void log_subsexpr(regsubs_T *subs);
3800 static void log_subexpr __ARGS((regsub_T *sub)); 3800 static void log_subexpr(regsub_T *sub);
3801 static char *pim_info __ARGS((nfa_pim_T *pim)); 3801 static char *pim_info(nfa_pim_T *pim);
3802 3802
3803 static void 3803 static void
3804 log_subsexpr(subs) 3804 log_subsexpr(subs)
3805 regsubs_T *subs; 3805 regsubs_T *subs;
3806 { 3806 {
3860 #ifdef FEAT_RELTIME 3860 #ifdef FEAT_RELTIME
3861 static proftime_T *nfa_time_limit; 3861 static proftime_T *nfa_time_limit;
3862 static int nfa_time_count; 3862 static int nfa_time_count;
3863 #endif 3863 #endif
3864 3864
3865 static void copy_pim __ARGS((nfa_pim_T *to, nfa_pim_T *from)); 3865 static void copy_pim(nfa_pim_T *to, nfa_pim_T *from);
3866 static void clear_sub __ARGS((regsub_T *sub)); 3866 static void clear_sub(regsub_T *sub);
3867 static void copy_sub __ARGS((regsub_T *to, regsub_T *from)); 3867 static void copy_sub(regsub_T *to, regsub_T *from);
3868 static void copy_sub_off __ARGS((regsub_T *to, regsub_T *from)); 3868 static void copy_sub_off(regsub_T *to, regsub_T *from);
3869 static void copy_ze_off __ARGS((regsub_T *to, regsub_T *from)); 3869 static void copy_ze_off(regsub_T *to, regsub_T *from);
3870 static int sub_equal __ARGS((regsub_T *sub1, regsub_T *sub2)); 3870 static int sub_equal(regsub_T *sub1, regsub_T *sub2);
3871 static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen)); 3871 static int match_backref(regsub_T *sub, int subidx, int *bytelen);
3872 static int has_state_with_pos __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim)); 3872 static int has_state_with_pos(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim);
3873 static int pim_equal __ARGS((nfa_pim_T *one, nfa_pim_T *two)); 3873 static int pim_equal(nfa_pim_T *one, nfa_pim_T *two);
3874 static int state_in_list __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs)); 3874 static int state_in_list(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs);
3875 static regsubs_T *addstate __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs_arg, nfa_pim_T *pim, int off)); 3875 static regsubs_T *addstate(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs_arg, nfa_pim_T *pim, int off);
3876 static void addstate_here __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int *ip)); 3876 static void addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int *ip);
3877 3877
3878 /* 3878 /*
3879 * Copy postponed invisible match info from "from" to "to". 3879 * Copy postponed invisible match info from "from" to "to".
3880 */ 3880 */
3881 static void 3881 static void
4891 return FALSE; 4891 return FALSE;
4892 } 4892 }
4893 4893
4894 #ifdef FEAT_SYN_HL 4894 #ifdef FEAT_SYN_HL
4895 4895
4896 static int match_zref __ARGS((int subidx, int *bytelen)); 4896 static int match_zref(int subidx, int *bytelen);
4897 4897
4898 /* 4898 /*
4899 * Check for a match with \z subexpression "subidx". 4899 * Check for a match with \z subexpression "subidx".
4900 * Return TRUE if it matches. 4900 * Return TRUE if it matches.
4901 */ 4901 */
4975 if (op == 1) return pos > val; 4975 if (op == 1) return pos > val;
4976 if (op == 2) return pos < val; 4976 if (op == 2) return pos < val;
4977 return val == pos; 4977 return val == pos;
4978 } 4978 }
4979 4979
4980 static int recursive_regmatch __ARGS((nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T *prog, regsubs_T *submatch, regsubs_T *m, int **listids)); 4980 static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T *prog, regsubs_T *submatch, regsubs_T *m, int **listids);
4981 static int nfa_regmatch __ARGS((nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *submatch, regsubs_T *m)); 4981 static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *submatch, regsubs_T *m);
4982 4982
4983 /* 4983 /*
4984 * Recursively call nfa_regmatch() 4984 * Recursively call nfa_regmatch()
4985 * "pim" is NULL or contains info about a Postponed Invisible Match (start 4985 * "pim" is NULL or contains info about a Postponed Invisible Match (start
4986 * position). 4986 * position).
5156 #endif 5156 #endif
5157 5157
5158 return result; 5158 return result;
5159 } 5159 }
5160 5160
5161 static int skip_to_start __ARGS((int c, colnr_T *colp)); 5161 static int skip_to_start(int c, colnr_T *colp);
5162 static long find_match_text __ARGS((colnr_T startcol, int regstart, char_u *match_text)); 5162 static long find_match_text(colnr_T startcol, int regstart, char_u *match_text);
5163 5163
5164 /* 5164 /*
5165 * Estimate the chance of a match with "state" failing. 5165 * Estimate the chance of a match with "state" failing.
5166 * empty match: 0 5166 * empty match: 0
5167 * NFA_ANY: 1 5167 * NFA_ANY: 1