1 | #ifndef DEFINE_FUNC_ATTRIBUTES |
2 | # define DEFINE_FUNC_ATTRIBUTES |
3 | #endif |
4 | #include "nvim/func_attr.h" |
5 | #undef DEFINE_FUNC_ATTRIBUTES |
6 | static void nfa_regcomp_start(char_u *expr, int re_flags ); |
7 | static int nfa_get_reganch(nfa_state_T *start, int depth); |
8 | static int nfa_get_regstart(nfa_state_T *start, int depth); |
9 | static char_u *nfa_get_match_text(nfa_state_T *start); |
10 | static void realloc_post_list(void); |
11 | static int nfa_recognize_char_class(char_u *start, char_u *end, int ); |
12 | static void nfa_emit_equi_class(int c); |
13 | static int nfa_regatom(void); |
14 | static int nfa_regpiece(void); |
15 | static int nfa_regconcat(void); |
16 | static int nfa_regbranch(void); |
17 | static int nfa_reg(int paren ); |
18 | static int *re2post(void); |
19 | static nfa_state_T *alloc_state(int c, nfa_state_T *out, nfa_state_T *out1); |
20 | static Frag_T frag(nfa_state_T *start, Ptrlist *out); |
21 | static Ptrlist *list1(nfa_state_T **outp); |
22 | static void patch(Ptrlist *l, nfa_state_T *s); |
23 | static Ptrlist *append(Ptrlist *l1, Ptrlist *l2); |
24 | static void st_error(int *postfix, int *end, int *p); |
25 | static void st_push(Frag_T s, Frag_T **p, Frag_T *stack_end); |
26 | static Frag_T st_pop(Frag_T **p, Frag_T *stack); |
27 | static int nfa_max_width(nfa_state_T *startstate, int depth); |
28 | static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size); |
29 | static void nfa_postprocess(nfa_regprog_T *prog); |
30 | static void copy_pim(nfa_pim_T *to, nfa_pim_T *from); |
31 | static void clear_sub(regsub_T *sub); |
32 | static void copy_sub(regsub_T *to, regsub_T *from); |
33 | static void copy_sub_off(regsub_T *to, regsub_T *from); |
34 | static void copy_ze_off(regsub_T *to, regsub_T *from); |
35 | static int sub_equal(regsub_T *sub1, regsub_T *sub2); |
36 | static int has_state_with_pos(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim ); |
37 | static int pim_equal(nfa_pim_T *one, nfa_pim_T *two); |
38 | static int match_follows(nfa_state_T *startstate, int depth); |
39 | static int state_in_list(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs ); |
40 | static regsubs_T *addstate(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs_arg, nfa_pim_T *pim, int off_arg) FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_WARN_UNUSED_RESULT; |
41 | static regsubs_T *addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int *ip ) FUNC_ATTR_NONNULL_ARG(1, 2, 5) FUNC_ATTR_WARN_UNUSED_RESULT; |
42 | static int check_char_class(int class, int c); |
43 | static int match_backref(regsub_T *sub, int subidx, int *bytelen ); |
44 | static int match_zref(int subidx, int *bytelen ); |
45 | static void nfa_save_listids(nfa_regprog_T *prog, int *list); |
46 | static void nfa_restore_listids(nfa_regprog_T *prog, int *list); |
47 | static _Bool nfa_re_num_cmp(uintmax_t val, int op, uintmax_t pos); |
48 | static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T *prog, regsubs_T *submatch, regsubs_T *m, int **listids, int *listids_len); |
49 | static int failure_chance(nfa_state_T *state, int depth); |
50 | static int skip_to_start(int c, colnr_T *colp); |
51 | static long find_match_text(colnr_T startcol, int regstart, char_u *match_text); |
52 | static int nfa_did_time_out(void); |
53 | static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *submatch, regsubs_T *m); |
54 | static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm, int *timed_out); |
55 | static long nfa_regexec_both(char_u *line, colnr_T startcol, proftime_T *tm, int *timed_out); |
56 | static regprog_T *nfa_regcomp(char_u *expr, int re_flags); |
57 | static void nfa_regfree(regprog_T *prog); |
58 | static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, _Bool line_lbr ); |
59 | static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm, int *timed_out); |
60 | #include "nvim/func_attr.h" |
61 | |