summaryrefslogtreecommitdiff
path: root/src/regexp.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-11-05 14:27:36 +0100
committerBram Moolenaar <Bram@vim.org>2014-11-05 14:27:36 +0100
commitfda3729a064d6466cec6ac83dd1bfcc437ea4cc9 (patch)
tree7642145192f29ec2050ac8e9cc890ddc353615af /src/regexp.h
parent4f7e821f26019c14f4470deb0867c919548d5cd5 (diff)
downloadvim-git-fda3729a064d6466cec6ac83dd1bfcc437ea4cc9.tar.gz
updated for version 7.4.497v7.4.497
Problem: With some regexp patterns the NFA engine uses many states and becomes very slow. To the user it looks like Vim freezes. Solution: When the number of states reaches a limit fall back to the old engine. (Christian Brabandt)
Diffstat (limited to 'src/regexp.h')
-rw-r--r--src/regexp.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/regexp.h b/src/regexp.h
index cd619daf4..6617cd237 100644
--- a/src/regexp.h
+++ b/src/regexp.h
@@ -27,6 +27,18 @@
*/
#define NFA_MAX_BRACES 20
+/*
+ * In the NFA engine: how many states are allowed
+ */
+#define NFA_MAX_STATES 100000
+#define NFA_TOO_EXPENSIVE -1
+
+/* Which regexp engine to use? Needed for vim_regcomp().
+ * Must match with 'regexpengine'. */
+#define AUTOMATIC_ENGINE 0
+#define BACKTRACKING_ENGINE 1
+#define NFA_ENGINE 2
+
typedef struct regengine regengine_T;
/*
@@ -38,6 +50,8 @@ typedef struct regprog
{
regengine_T *engine;
unsigned regflags;
+ unsigned re_engine; /* automatic, backtracking or nfa engine */
+ unsigned re_flags; /* second argument for vim_regcomp() */
} regprog_T;
/*
@@ -47,9 +61,11 @@ typedef struct regprog
*/
typedef struct
{
- /* These two members implement regprog_T */
+ /* These four members implement regprog_T */
regengine_T *engine;
unsigned regflags;
+ unsigned re_engine;
+ unsigned re_flags; /* second argument for vim_regcomp() */
int regstart;
char_u reganch;
@@ -81,9 +97,11 @@ struct nfa_state
*/
typedef struct
{
- /* These two members implement regprog_T */
+ /* These three members implement regprog_T */
regengine_T *engine;
unsigned regflags;
+ unsigned re_engine;
+ unsigned re_flags; /* second argument for vim_regcomp() */
nfa_state_T *start; /* points into state[] */
@@ -96,9 +114,7 @@ typedef struct
#ifdef FEAT_SYN_HL
int reghasz;
#endif
-#ifdef DEBUG
char_u *pattern;
-#endif
int nsubexp; /* number of () */
int nstate;
nfa_state_T state[1]; /* actually longer.. */
@@ -151,9 +167,7 @@ struct regengine
void (*regfree)(regprog_T *);
int (*regexec_nl)(regmatch_T*, char_u*, colnr_T, int);
long (*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
-#ifdef DEBUG
char_u *expr;
-#endif
};
#endif /* _REGEXP_H */