Mercurial > vim
annotate src/regexp_nfa.c @ 29221:6e82fb24a351
Added tag v8.2.5129 for changeset d6f8b784d0f6d3017a26750e15d7ce971d312f87
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Jun 2022 15:45:03 +0200 |
parents | 0af5fe160e4e |
children | c7aa0c46acd5 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9371
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
4444 | 2 * |
3 * NFA regular expression implementation. | |
4 * | |
5 * This file is included in "regexp.c". | |
6 */ | |
7 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
8 /* |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
9 * Logging of NFA engine. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
10 * |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
11 * The NFA engine can write four log files: |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
12 * - Error log: Contains NFA engine's fatal errors. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
13 * - Dump log: Contains compiled NFA state machine's information. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
14 * - Run log: Contains information of matching procedure. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
15 * - Debug log: Contains detailed information of matching procedure. Can be |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
16 * disabled by undefining NFA_REGEXP_DEBUG_LOG. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
17 * The first one can also be used without debug mode. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
18 * The last three are enabled when compiled as debug mode and individually |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
19 * disabled by commenting them out. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
20 * The log files can get quite big! |
26592
9f445e07f766
patch 8.2.3825: various comments could be improved
Bram Moolenaar <Bram@vim.org>
parents:
26436
diff
changeset
|
21 * To disable all of this when compiling Vim for debugging, undefine DEBUG in |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
22 * regexp.c |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
23 */ |
4444 | 24 #ifdef DEBUG |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
25 # define NFA_REGEXP_ERROR_LOG "nfa_regexp_error.log" |
4444 | 26 # define ENABLE_LOG |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
27 # define NFA_REGEXP_DUMP_LOG "nfa_regexp_dump.log" |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
28 # define NFA_REGEXP_RUN_LOG "nfa_regexp_run.log" |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
29 # define NFA_REGEXP_DEBUG_LOG "nfa_regexp_debug.log" |
4444 | 30 #endif |
31 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
32 // Added to NFA_ANY - NFA_NUPPER_IC to include a NL. |
5296 | 33 #define NFA_ADD_NL 31 |
34 | |
4444 | 35 enum |
36 { | |
37 NFA_SPLIT = -1024, | |
38 NFA_MATCH, | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
39 NFA_EMPTY, // matches 0-length |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
40 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
41 NFA_START_COLL, // [abc] start |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
42 NFA_END_COLL, // [abc] end |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
43 NFA_START_NEG_COLL, // [^abc] start |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
44 NFA_END_NEG_COLL, // [^abc] end (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
45 NFA_RANGE, // range of the two previous items |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
46 // (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
47 NFA_RANGE_MIN, // low end of a range |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
48 NFA_RANGE_MAX, // high end of a range |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
49 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
50 NFA_CONCAT, // concatenate two previous items (postfix |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
51 // only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
52 NFA_OR, // \| (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
53 NFA_STAR, // greedy * (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
54 NFA_STAR_NONGREEDY, // non-greedy * (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
55 NFA_QUEST, // greedy \? (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
56 NFA_QUEST_NONGREEDY, // non-greedy \? (postfix only) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
57 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
58 NFA_BOL, // ^ Begin line |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
59 NFA_EOL, // $ End line |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
60 NFA_BOW, // \< Begin word |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
61 NFA_EOW, // \> End word |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
62 NFA_BOF, // \%^ Begin file |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
63 NFA_EOF, // \%$ End file |
4444 | 64 NFA_NEWL, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
65 NFA_ZSTART, // Used for \zs |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
66 NFA_ZEND, // Used for \ze |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
67 NFA_NOPEN, // Start of subexpression marked with \%( |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
68 NFA_NCLOSE, // End of subexpr. marked with \%( ... \) |
4444 | 69 NFA_START_INVISIBLE, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
70 NFA_START_INVISIBLE_FIRST, |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
71 NFA_START_INVISIBLE_NEG, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
72 NFA_START_INVISIBLE_NEG_FIRST, |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
73 NFA_START_INVISIBLE_BEFORE, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
74 NFA_START_INVISIBLE_BEFORE_FIRST, |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
75 NFA_START_INVISIBLE_BEFORE_NEG, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
76 NFA_START_INVISIBLE_BEFORE_NEG_FIRST, |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
77 NFA_START_PATTERN, |
4444 | 78 NFA_END_INVISIBLE, |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
79 NFA_END_INVISIBLE_NEG, |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
80 NFA_END_PATTERN, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
81 NFA_COMPOSING, // Next nodes in NFA are part of the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
82 // composing multibyte char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
83 NFA_END_COMPOSING, // End of a composing char in the NFA |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
84 NFA_ANY_COMPOSING, // \%C: Any composing characters. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
85 NFA_OPT_CHARS, // \%[abc] |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
86 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
87 // The following are used only in the postfix form, not in the NFA |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
88 NFA_PREV_ATOM_NO_WIDTH, // Used for \@= |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
89 NFA_PREV_ATOM_NO_WIDTH_NEG, // Used for \@! |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
90 NFA_PREV_ATOM_JUST_BEFORE, // Used for \@<= |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
91 NFA_PREV_ATOM_JUST_BEFORE_NEG, // Used for \@<! |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
92 NFA_PREV_ATOM_LIKE_PATTERN, // Used for \@> |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
93 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
94 NFA_BACKREF1, // \1 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
95 NFA_BACKREF2, // \2 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
96 NFA_BACKREF3, // \3 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
97 NFA_BACKREF4, // \4 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
98 NFA_BACKREF5, // \5 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
99 NFA_BACKREF6, // \6 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
100 NFA_BACKREF7, // \7 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
101 NFA_BACKREF8, // \8 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
102 NFA_BACKREF9, // \9 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
103 #ifdef FEAT_SYN_HL |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
104 NFA_ZREF1, // \z1 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
105 NFA_ZREF2, // \z2 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
106 NFA_ZREF3, // \z3 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
107 NFA_ZREF4, // \z4 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
108 NFA_ZREF5, // \z5 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
109 NFA_ZREF6, // \z6 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
110 NFA_ZREF7, // \z7 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
111 NFA_ZREF8, // \z8 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
112 NFA_ZREF9, // \z9 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
113 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
114 NFA_SKIP, // Skip characters |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
115 |
4444 | 116 NFA_MOPEN, |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
117 NFA_MOPEN1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
118 NFA_MOPEN2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
119 NFA_MOPEN3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
120 NFA_MOPEN4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
121 NFA_MOPEN5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
122 NFA_MOPEN6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
123 NFA_MOPEN7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
124 NFA_MOPEN8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
125 NFA_MOPEN9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
126 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
127 NFA_MCLOSE, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
128 NFA_MCLOSE1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
129 NFA_MCLOSE2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
130 NFA_MCLOSE3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
131 NFA_MCLOSE4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
132 NFA_MCLOSE5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
133 NFA_MCLOSE6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
134 NFA_MCLOSE7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
135 NFA_MCLOSE8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
136 NFA_MCLOSE9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
137 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
138 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
139 NFA_ZOPEN, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
140 NFA_ZOPEN1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
141 NFA_ZOPEN2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
142 NFA_ZOPEN3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
143 NFA_ZOPEN4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
144 NFA_ZOPEN5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
145 NFA_ZOPEN6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
146 NFA_ZOPEN7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
147 NFA_ZOPEN8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
148 NFA_ZOPEN9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
149 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
150 NFA_ZCLOSE, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
151 NFA_ZCLOSE1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
152 NFA_ZCLOSE2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
153 NFA_ZCLOSE3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
154 NFA_ZCLOSE4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
155 NFA_ZCLOSE5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
156 NFA_ZCLOSE6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
157 NFA_ZCLOSE7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
158 NFA_ZCLOSE8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
159 NFA_ZCLOSE9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
160 #endif |
4444 | 161 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
162 // NFA_FIRST_NL |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
163 NFA_ANY, // Match any one character. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
164 NFA_IDENT, // Match identifier char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
165 NFA_SIDENT, // Match identifier char but no digit |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
166 NFA_KWORD, // Match keyword char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
167 NFA_SKWORD, // Match word char but no digit |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
168 NFA_FNAME, // Match file name char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
169 NFA_SFNAME, // Match file name char but no digit |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
170 NFA_PRINT, // Match printable char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
171 NFA_SPRINT, // Match printable char but no digit |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
172 NFA_WHITE, // Match whitespace char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
173 NFA_NWHITE, // Match non-whitespace char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
174 NFA_DIGIT, // Match digit char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
175 NFA_NDIGIT, // Match non-digit char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
176 NFA_HEX, // Match hex char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
177 NFA_NHEX, // Match non-hex char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
178 NFA_OCTAL, // Match octal char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
179 NFA_NOCTAL, // Match non-octal char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
180 NFA_WORD, // Match word char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
181 NFA_NWORD, // Match non-word char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
182 NFA_HEAD, // Match head char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
183 NFA_NHEAD, // Match non-head char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
184 NFA_ALPHA, // Match alpha char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
185 NFA_NALPHA, // Match non-alpha char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
186 NFA_LOWER, // Match lowercase char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
187 NFA_NLOWER, // Match non-lowercase char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
188 NFA_UPPER, // Match uppercase char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
189 NFA_NUPPER, // Match non-uppercase char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
190 NFA_LOWER_IC, // Match [a-z] |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
191 NFA_NLOWER_IC, // Match [^a-z] |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
192 NFA_UPPER_IC, // Match [A-Z] |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
193 NFA_NUPPER_IC, // Match [^A-Z] |
5296 | 194 |
195 NFA_FIRST_NL = NFA_ANY + NFA_ADD_NL, | |
196 NFA_LAST_NL = NFA_NUPPER_IC + NFA_ADD_NL, | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
197 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
198 NFA_CURSOR, // Match cursor pos |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
199 NFA_LNUM, // Match line number |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
200 NFA_LNUM_GT, // Match > line number |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
201 NFA_LNUM_LT, // Match < line number |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
202 NFA_COL, // Match cursor column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
203 NFA_COL_GT, // Match > cursor column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
204 NFA_COL_LT, // Match < cursor column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
205 NFA_VCOL, // Match cursor virtual column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
206 NFA_VCOL_GT, // Match > cursor virtual column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
207 NFA_VCOL_LT, // Match < cursor virtual column |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
208 NFA_MARK, // Match mark |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
209 NFA_MARK_GT, // Match > mark |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
210 NFA_MARK_LT, // Match < mark |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
211 NFA_VISUAL, // Match Visual area |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
212 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
213 // Character classes [:alnum:] etc |
4444 | 214 NFA_CLASS_ALNUM, |
215 NFA_CLASS_ALPHA, | |
216 NFA_CLASS_BLANK, | |
217 NFA_CLASS_CNTRL, | |
218 NFA_CLASS_DIGIT, | |
219 NFA_CLASS_GRAPH, | |
220 NFA_CLASS_LOWER, | |
221 NFA_CLASS_PRINT, | |
222 NFA_CLASS_PUNCT, | |
223 NFA_CLASS_SPACE, | |
224 NFA_CLASS_UPPER, | |
225 NFA_CLASS_XDIGIT, | |
226 NFA_CLASS_TAB, | |
227 NFA_CLASS_RETURN, | |
228 NFA_CLASS_BACKSPACE, | |
15709
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
229 NFA_CLASS_ESCAPE, |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
230 NFA_CLASS_IDENT, |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
231 NFA_CLASS_KEYWORD, |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
232 NFA_CLASS_FNAME |
4444 | 233 }; |
234 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
235 // Keep in sync with classchars. |
4444 | 236 static int nfa_classcodes[] = { |
237 NFA_ANY, NFA_IDENT, NFA_SIDENT, NFA_KWORD,NFA_SKWORD, | |
238 NFA_FNAME, NFA_SFNAME, NFA_PRINT, NFA_SPRINT, | |
239 NFA_WHITE, NFA_NWHITE, NFA_DIGIT, NFA_NDIGIT, | |
240 NFA_HEX, NFA_NHEX, NFA_OCTAL, NFA_NOCTAL, | |
241 NFA_WORD, NFA_NWORD, NFA_HEAD, NFA_NHEAD, | |
242 NFA_ALPHA, NFA_NALPHA, NFA_LOWER, NFA_NLOWER, | |
243 NFA_UPPER, NFA_NUPPER | |
244 }; | |
245 | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
246 // Variables only used in nfa_regcomp() and descendants. |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
247 static int nfa_re_flags; // re_flags passed to nfa_regcomp() |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
248 static int *post_start; // holds the postfix form of r.e. |
4444 | 249 static int *post_end; |
250 static int *post_ptr; | |
23471
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
251 |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
252 // Set when the pattern should use the NFA engine. |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
253 // E.g. [[:upper:]] only allows 8bit characters for BT engine, |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
254 // while NFA engine handles multibyte characters correctly. |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
255 static int wants_nfa; |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
256 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
257 static int nstate; // Number of states in the NFA. |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
258 static int istate; // Index in the state vector, used in alloc_state() |
4444 | 259 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
260 // If not NULL match must end at this position |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
261 static save_se_T *nfa_endp = NULL; |
4444 | 262 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
263 // 0 for first call to nfa_regmatch(), 1 for recursive call. |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
264 static int nfa_ll_index = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
265 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
266 static int realloc_post_list(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
267 static int nfa_reg(int paren); |
4444 | 268 #ifdef DEBUG |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
269 static void nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent); |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
270 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
271 static int match_follows(nfa_state_T *startstate, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
272 static int failure_chance(nfa_state_T *state, int depth); |
4444 | 273 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
274 // helper functions used when doing re2post() ... regatom() parsing |
4444 | 275 #define EMIT(c) do { \ |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
276 if (post_ptr >= post_end && realloc_post_list() == FAIL) \ |
4444 | 277 return FAIL; \ |
278 *post_ptr++ = c; \ | |
279 } while (0) | |
280 | |
281 /* | |
282 * Initialize internal variables before NFA compilation. | |
283 * Return OK on success, FAIL otherwise. | |
284 */ | |
285 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
286 nfa_regcomp_start( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
287 char_u *expr, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
288 int re_flags) // see vim_regcomp() |
4444 | 289 { |
4458 | 290 size_t postfix_size; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
291 int nstate_max; |
4444 | 292 |
293 nstate = 0; | |
294 istate = 0; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
295 // A reasonable estimation for maximum size |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
296 nstate_max = (int)(STRLEN(expr) + 1) * 25; |
4444 | 297 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
298 // Some items blow up in size, such as [A-z]. Add more space for that. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
299 // When it is still not enough realloc_post_list() will be used. |
4458 | 300 nstate_max += 1000; |
4454 | 301 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
302 // Size for postfix representation of expr. |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
303 postfix_size = sizeof(int) * nstate_max; |
4454 | 304 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
305 post_start = alloc(postfix_size); |
4444 | 306 if (post_start == NULL) |
307 return FAIL; | |
308 post_ptr = post_start; | |
4454 | 309 post_end = post_start + nstate_max; |
23471
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
310 wants_nfa = FALSE; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
311 rex.nfa_has_zend = FALSE; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
312 rex.nfa_has_backref = FALSE; |
4444 | 313 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
314 // shared with BT engine |
4444 | 315 regcomp_start(expr, re_flags); |
316 | |
317 return OK; | |
318 } | |
319 | |
320 /* | |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
321 * Figure out if the NFA state list starts with an anchor, must match at start |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
322 * of the line. |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
323 */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
324 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
325 nfa_get_reganch(nfa_state_T *start, int depth) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
326 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
327 nfa_state_T *p = start; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
328 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
329 if (depth > 4) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
330 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
331 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
332 while (p != NULL) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
333 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
334 switch (p->c) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
335 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
336 case NFA_BOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
337 case NFA_BOF: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
338 return 1; // yes! |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
339 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
340 case NFA_ZSTART: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
341 case NFA_ZEND: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
342 case NFA_CURSOR: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
343 case NFA_VISUAL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
344 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
345 case NFA_MOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
346 case NFA_MOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
347 case NFA_MOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
348 case NFA_MOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
349 case NFA_MOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
350 case NFA_MOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
351 case NFA_MOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
352 case NFA_MOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
353 case NFA_MOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
354 case NFA_MOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
355 case NFA_NOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
356 #ifdef FEAT_SYN_HL |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
357 case NFA_ZOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
358 case NFA_ZOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
359 case NFA_ZOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
360 case NFA_ZOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
361 case NFA_ZOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
362 case NFA_ZOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
363 case NFA_ZOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
364 case NFA_ZOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
365 case NFA_ZOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
366 case NFA_ZOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
367 #endif |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
368 p = p->out; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
369 break; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
370 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
371 case NFA_SPLIT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
372 return nfa_get_reganch(p->out, depth + 1) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
373 && nfa_get_reganch(p->out1, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
374 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
375 default: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
376 return 0; // noooo |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
377 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
378 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
379 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
380 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
381 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
382 /* |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
383 * Figure out if the NFA state list starts with a character which must match |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
384 * at start of the match. |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
385 */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
386 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
387 nfa_get_regstart(nfa_state_T *start, int depth) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
388 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
389 nfa_state_T *p = start; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
390 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
391 if (depth > 4) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
392 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
393 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
394 while (p != NULL) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
395 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
396 switch (p->c) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
397 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
398 // all kinds of zero-width matches |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
399 case NFA_BOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
400 case NFA_BOF: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
401 case NFA_BOW: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
402 case NFA_EOW: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
403 case NFA_ZSTART: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
404 case NFA_ZEND: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
405 case NFA_CURSOR: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
406 case NFA_VISUAL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
407 case NFA_LNUM: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
408 case NFA_LNUM_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
409 case NFA_LNUM_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
410 case NFA_COL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
411 case NFA_COL_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
412 case NFA_COL_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
413 case NFA_VCOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
414 case NFA_VCOL_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
415 case NFA_VCOL_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
416 case NFA_MARK: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
417 case NFA_MARK_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
418 case NFA_MARK_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
419 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
420 case NFA_MOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
421 case NFA_MOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
422 case NFA_MOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
423 case NFA_MOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
424 case NFA_MOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
425 case NFA_MOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
426 case NFA_MOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
427 case NFA_MOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
428 case NFA_MOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
429 case NFA_MOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
430 case NFA_NOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
431 #ifdef FEAT_SYN_HL |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
432 case NFA_ZOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
433 case NFA_ZOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
434 case NFA_ZOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
435 case NFA_ZOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
436 case NFA_ZOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
437 case NFA_ZOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
438 case NFA_ZOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
439 case NFA_ZOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
440 case NFA_ZOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
441 case NFA_ZOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
442 #endif |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
443 p = p->out; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
444 break; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
445 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
446 case NFA_SPLIT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
447 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
448 int c1 = nfa_get_regstart(p->out, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
449 int c2 = nfa_get_regstart(p->out1, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
450 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
451 if (c1 == c2) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
452 return c1; // yes! |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
453 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
454 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
455 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
456 default: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
457 if (p->c > 0) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
458 return p->c; // yes! |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
459 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
460 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
461 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
462 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
463 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
464 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
465 /* |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
466 * Figure out if the NFA state list contains just literal text and nothing |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
467 * else. If so return a string in allocated memory with what must match after |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
468 * regstart. Otherwise return NULL. |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
469 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
470 static char_u * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
471 nfa_get_match_text(nfa_state_T *start) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
472 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
473 nfa_state_T *p = start; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
474 int len = 0; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
475 char_u *ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
476 char_u *s; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
477 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
478 if (p->c != NFA_MOPEN) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
479 return NULL; // just in case |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
480 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
481 while (p->c > 0) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
482 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
483 len += MB_CHAR2LEN(p->c); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
484 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
485 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
486 if (p->c != NFA_MCLOSE || p->out->c != NFA_MATCH) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
487 return NULL; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
488 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
489 ret = alloc(len); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
490 if (ret != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
491 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
492 p = start->out->out; // skip first char, it goes into regstart |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
493 s = ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
494 while (p->c > 0) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
495 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
496 if (has_mbyte) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
497 s += (*mb_char2bytes)(p->c, s); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
498 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
499 *s++ = p->c; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
500 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
501 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
502 *s = NUL; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
503 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
504 return ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
505 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
506 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
507 /* |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
508 * Allocate more space for post_start. Called when |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
509 * running above the estimated number of states. |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
510 */ |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
511 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
512 realloc_post_list(void) |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
513 { |
4667
9e7ef781d494
updated for version 7.3.1081
Bram Moolenaar <bram@vim.org>
parents:
4661
diff
changeset
|
514 int nstate_max = (int)(post_end - post_start); |
15904
fec4416adb80
patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents:
15876
diff
changeset
|
515 int new_max; |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
516 int *new_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
517 int *old_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
518 |
15904
fec4416adb80
patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents:
15876
diff
changeset
|
519 // For weird patterns the number of states can be very high. Increasing by |
fec4416adb80
patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents:
15876
diff
changeset
|
520 // 50% seems a reasonable compromise between memory use and speed. |
fec4416adb80
patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents:
15876
diff
changeset
|
521 new_max = nstate_max * 3 / 2; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
522 new_start = ALLOC_MULT(int, new_max); |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
523 if (new_start == NULL) |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
524 return FAIL; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
525 mch_memmove(new_start, post_start, nstate_max * sizeof(int)); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
526 old_start = post_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
527 post_start = new_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
528 post_ptr = new_start + (post_ptr - old_start); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
529 post_end = post_start + new_max; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
530 vim_free(old_start); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
531 return OK; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
532 } |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
533 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
534 /* |
4444 | 535 * Search between "start" and "end" and try to recognize a |
536 * character class in expanded form. For example [0-9]. | |
537 * On success, return the id the character class to be emitted. | |
538 * On failure, return 0 (=FAIL) | |
539 * Start points to the first char of the range, while end should point | |
540 * to the closing brace. | |
5296 | 541 * Keep in mind that 'ignorecase' applies at execution time, thus [a-z] may |
542 * need to be interpreted as [a-zA-Z]. | |
4444 | 543 */ |
544 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
545 nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) |
4444 | 546 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
547 # define CLASS_not 0x80 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
548 # define CLASS_af 0x40 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
549 # define CLASS_AF 0x20 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
550 # define CLASS_az 0x10 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
551 # define CLASS_AZ 0x08 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
552 # define CLASS_o7 0x04 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
553 # define CLASS_o9 0x02 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
554 # define CLASS_underscore 0x01 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
555 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
556 int newl = FALSE; |
4444 | 557 char_u *p; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
558 int config = 0; |
4444 | 559 |
560 if (extra_newl == TRUE) | |
561 newl = TRUE; | |
562 | |
563 if (*end != ']') | |
564 return FAIL; | |
565 p = start; | |
566 if (*p == '^') | |
567 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
568 config |= CLASS_not; |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
569 p++; |
4444 | 570 } |
571 | |
572 while (p < end) | |
573 { | |
574 if (p + 2 < end && *(p + 1) == '-') | |
575 { | |
576 switch (*p) | |
577 { | |
578 case '0': | |
579 if (*(p + 2) == '9') | |
580 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
581 config |= CLASS_o9; |
4444 | 582 break; |
583 } | |
584 if (*(p + 2) == '7') | |
585 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
586 config |= CLASS_o7; |
4444 | 587 break; |
588 } | |
11469
0ade9dd85156
patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents:
11269
diff
changeset
|
589 return FAIL; |
0ade9dd85156
patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents:
11269
diff
changeset
|
590 |
4444 | 591 case 'a': |
592 if (*(p + 2) == 'z') | |
593 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
594 config |= CLASS_az; |
4444 | 595 break; |
596 } | |
597 if (*(p + 2) == 'f') | |
598 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
599 config |= CLASS_af; |
4444 | 600 break; |
601 } | |
11469
0ade9dd85156
patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents:
11269
diff
changeset
|
602 return FAIL; |
0ade9dd85156
patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents:
11269
diff
changeset
|
603 |
4444 | 604 case 'A': |
605 if (*(p + 2) == 'Z') | |
606 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
607 config |= CLASS_AZ; |
4444 | 608 break; |
609 } | |
610 if (*(p + 2) == 'F') | |
611 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
612 config |= CLASS_AF; |
4444 | 613 break; |
614 } | |
11469
0ade9dd85156
patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents:
11269
diff
changeset
|
615 return FAIL; |
0ade9dd85156
patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents:
11269
diff
changeset
|
616 |
4444 | 617 default: |
618 return FAIL; | |
619 } | |
620 p += 3; | |
621 } | |
622 else if (p + 1 < end && *p == '\\' && *(p + 1) == 'n') | |
623 { | |
624 newl = TRUE; | |
625 p += 2; | |
626 } | |
627 else if (*p == '_') | |
628 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
629 config |= CLASS_underscore; |
4444 | 630 p ++; |
631 } | |
632 else if (*p == '\n') | |
633 { | |
634 newl = TRUE; | |
635 p ++; | |
636 } | |
637 else | |
638 return FAIL; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
639 } // while (p < end) |
4444 | 640 |
641 if (p != end) | |
642 return FAIL; | |
643 | |
644 if (newl == TRUE) | |
5296 | 645 extra_newl = NFA_ADD_NL; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
646 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
647 switch (config) |
4444 | 648 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
649 case CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
650 return extra_newl + NFA_DIGIT; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
651 case CLASS_not | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
652 return extra_newl + NFA_NDIGIT; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
653 case CLASS_af | CLASS_AF | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
654 return extra_newl + NFA_HEX; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
655 case CLASS_not | CLASS_af | CLASS_AF | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
656 return extra_newl + NFA_NHEX; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
657 case CLASS_o7: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
658 return extra_newl + NFA_OCTAL; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
659 case CLASS_not | CLASS_o7: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
660 return extra_newl + NFA_NOCTAL; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
661 case CLASS_az | CLASS_AZ | CLASS_o9 | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
662 return extra_newl + NFA_WORD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
663 case CLASS_not | CLASS_az | CLASS_AZ | CLASS_o9 | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
664 return extra_newl + NFA_NWORD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
665 case CLASS_az | CLASS_AZ | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
666 return extra_newl + NFA_HEAD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
667 case CLASS_not | CLASS_az | CLASS_AZ | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
668 return extra_newl + NFA_NHEAD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
669 case CLASS_az | CLASS_AZ: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
670 return extra_newl + NFA_ALPHA; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
671 case CLASS_not | CLASS_az | CLASS_AZ: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
672 return extra_newl + NFA_NALPHA; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
673 case CLASS_az: |
5296 | 674 return extra_newl + NFA_LOWER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
675 case CLASS_not | CLASS_az: |
5296 | 676 return extra_newl + NFA_NLOWER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
677 case CLASS_AZ: |
5296 | 678 return extra_newl + NFA_UPPER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
679 case CLASS_not | CLASS_AZ: |
5296 | 680 return extra_newl + NFA_NUPPER_IC; |
4444 | 681 } |
682 return FAIL; | |
683 } | |
684 | |
685 /* | |
686 * Produce the bytes for equivalence class "c". | |
687 * Currently only handles latin1, latin9 and utf-8. | |
688 * Emits bytes in postfix notation: 'a,b,NFA_OR,c,NFA_OR' is | |
689 * equivalent to 'a OR b OR c' | |
690 * | |
691 * NOTE! When changing this function, also update reg_equi_class() | |
692 */ | |
693 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
694 nfa_emit_equi_class(int c) |
4444 | 695 { |
5351 | 696 #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
697 |
4444 | 698 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0 |
699 || STRCMP(p_enc, "iso-8859-15") == 0) | |
700 { | |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
701 #define A_grave 0xc0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
702 #define A_acute 0xc1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
703 #define A_circumflex 0xc2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
704 #define A_virguilla 0xc3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
705 #define A_diaeresis 0xc4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
706 #define A_ring 0xc5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
707 #define C_cedilla 0xc7 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
708 #define E_grave 0xc8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
709 #define E_acute 0xc9 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
710 #define E_circumflex 0xca |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
711 #define E_diaeresis 0xcb |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
712 #define I_grave 0xcc |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
713 #define I_acute 0xcd |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
714 #define I_circumflex 0xce |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
715 #define I_diaeresis 0xcf |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
716 #define N_virguilla 0xd1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
717 #define O_grave 0xd2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
718 #define O_acute 0xd3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
719 #define O_circumflex 0xd4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
720 #define O_virguilla 0xd5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
721 #define O_diaeresis 0xd6 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
722 #define O_slash 0xd8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
723 #define U_grave 0xd9 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
724 #define U_acute 0xda |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
725 #define U_circumflex 0xdb |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
726 #define U_diaeresis 0xdc |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
727 #define Y_acute 0xdd |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
728 #define a_grave 0xe0 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
729 #define a_acute 0xe1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
730 #define a_circumflex 0xe2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
731 #define a_virguilla 0xe3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
732 #define a_diaeresis 0xe4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
733 #define a_ring 0xe5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
734 #define c_cedilla 0xe7 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
735 #define e_grave 0xe8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
736 #define e_acute 0xe9 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
737 #define e_circumflex 0xea |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
738 #define e_diaeresis 0xeb |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
739 #define i_grave 0xec |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
740 #define i_acute 0xed |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
741 #define i_circumflex 0xee |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
742 #define i_diaeresis 0xef |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
743 #define n_virguilla 0xf1 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
744 #define o_grave 0xf2 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
745 #define o_acute 0xf3 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
746 #define o_circumflex 0xf4 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
747 #define o_virguilla 0xf5 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
748 #define o_diaeresis 0xf6 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
749 #define o_slash 0xf8 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
750 #define u_grave 0xf9 |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
751 #define u_acute 0xfa |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
752 #define u_circumflex 0xfb |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
753 #define u_diaeresis 0xfc |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
754 #define y_acute 0xfd |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
755 #define y_diaeresis 0xff |
4444 | 756 switch (c) |
757 { | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
758 case 'A': case A_grave: case A_acute: case A_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
759 case A_virguilla: case A_diaeresis: case A_ring: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
760 case 0x100: case 0x102: case 0x104: case 0x1cd: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
761 case 0x1de: case 0x1e0: case 0x1fa: case 0x200: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
762 case 0x202: case 0x226: case 0x23a: case 0x1e00: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
763 case 0x1ea0: case 0x1ea2: case 0x1ea4: case 0x1ea6: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
764 case 0x1ea8: case 0x1eaa: case 0x1eac: case 0x1eae: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
765 case 0x1eb0: case 0x1eb2: case 0x1eb4: case 0x1eb6: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
766 EMIT2('A') EMIT2(A_grave) EMIT2(A_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
767 EMIT2(A_circumflex) EMIT2(A_virguilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
768 EMIT2(A_diaeresis) EMIT2(A_ring) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
769 EMIT2(0x100) EMIT2(0x102) EMIT2(0x104) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
770 EMIT2(0x1cd) EMIT2(0x1de) EMIT2(0x1e0) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
771 EMIT2(0x1fa) EMIT2(0x200) EMIT2(0x202) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
772 EMIT2(0x226) EMIT2(0x23a) EMIT2(0x1e00) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
773 EMIT2(0x1ea0) EMIT2(0x1ea2) EMIT2(0x1ea4) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
774 EMIT2(0x1ea6) EMIT2(0x1ea8) EMIT2(0x1eaa) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
775 EMIT2(0x1eac) EMIT2(0x1eae) EMIT2(0x1eb0) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
776 EMIT2(0x1eb2) EMIT2(0x1eb6) EMIT2(0x1eb4) |
5351 | 777 return OK; |
778 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
779 case 'B': case 0x181: case 0x243: case 0x1e02: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
780 case 0x1e04: case 0x1e06: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
781 EMIT2('B') |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
782 EMIT2(0x181) EMIT2(0x243) EMIT2(0x1e02) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
783 EMIT2(0x1e04) EMIT2(0x1e06) |
4444 | 784 return OK; |
785 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
786 case 'C': case C_cedilla: case 0x106: case 0x108: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
787 case 0x10a: case 0x10c: case 0x187: case 0x23b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
788 case 0x1e08: case 0xa792: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
789 EMIT2('C') EMIT2(C_cedilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
790 EMIT2(0x106) EMIT2(0x108) EMIT2(0x10a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
791 EMIT2(0x10c) EMIT2(0x187) EMIT2(0x23b) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
792 EMIT2(0x1e08) EMIT2(0xa792) |
5351 | 793 return OK; |
794 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
795 case 'D': case 0x10e: case 0x110: case 0x18a: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
796 case 0x1e0a: case 0x1e0c: case 0x1e0e: case 0x1e10: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
797 case 0x1e12: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
798 EMIT2('D') EMIT2(0x10e) EMIT2(0x110) EMIT2(0x18a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
799 EMIT2(0x1e0a) EMIT2(0x1e0c) EMIT2(0x1e0e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
800 EMIT2(0x1e10) EMIT2(0x1e12) |
4444 | 801 return OK; |
802 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
803 case 'E': case E_grave: case E_acute: case E_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
804 case E_diaeresis: case 0x112: case 0x114: case 0x116: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
805 case 0x118: case 0x11a: case 0x204: case 0x206: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
806 case 0x228: case 0x246: case 0x1e14: case 0x1e16: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
807 case 0x1e18: case 0x1e1a: case 0x1e1c: case 0x1eb8: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
808 case 0x1eba: case 0x1ebc: case 0x1ebe: case 0x1ec0: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
809 case 0x1ec2: case 0x1ec4: case 0x1ec6: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
810 EMIT2('E') EMIT2(E_grave) EMIT2(E_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
811 EMIT2(E_circumflex) EMIT2(E_diaeresis) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
812 EMIT2(0x112) EMIT2(0x114) EMIT2(0x116) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
813 EMIT2(0x118) EMIT2(0x11a) EMIT2(0x204) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
814 EMIT2(0x206) EMIT2(0x228) EMIT2(0x246) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
815 EMIT2(0x1e14) EMIT2(0x1e16) EMIT2(0x1e18) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
816 EMIT2(0x1e1a) EMIT2(0x1e1c) EMIT2(0x1eb8) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
817 EMIT2(0x1eba) EMIT2(0x1ebc) EMIT2(0x1ebe) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
818 EMIT2(0x1ec0) EMIT2(0x1ec2) EMIT2(0x1ec4) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
819 EMIT2(0x1ec6) |
5351 | 820 return OK; |
821 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
822 case 'F': case 0x191: case 0x1e1e: case 0xa798: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
823 EMIT2('F') EMIT2(0x191) EMIT2(0x1e1e) EMIT2(0xa798) |
5351 | 824 return OK; |
825 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
826 case 'G': case 0x11c: case 0x11e: case 0x120: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
827 case 0x122: case 0x193: case 0x1e4: case 0x1e6: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
828 case 0x1f4: case 0x1e20: case 0xa7a0: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
829 EMIT2('G') EMIT2(0x11c) EMIT2(0x11e) EMIT2(0x120) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
830 EMIT2(0x122) EMIT2(0x193) EMIT2(0x1e4) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
831 EMIT2(0x1e6) EMIT2(0x1f4) EMIT2(0x1e20) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
832 EMIT2(0xa7a0) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
833 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
834 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
835 case 'H': case 0x124: case 0x126: case 0x21e: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
836 case 0x1e22: case 0x1e24: case 0x1e26: case 0x1e28: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
837 case 0x1e2a: case 0x2c67: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
838 EMIT2('H') EMIT2(0x124) EMIT2(0x126) EMIT2(0x21e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
839 EMIT2(0x1e22) EMIT2(0x1e24) EMIT2(0x1e26) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
840 EMIT2(0x1e28) EMIT2(0x1e2a) EMIT2(0x2c67) |
4444 | 841 return OK; |
842 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
843 case 'I': case I_grave: case I_acute: case I_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
844 case I_diaeresis: case 0x128: case 0x12a: case 0x12c: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
845 case 0x12e: case 0x130: case 0x197: case 0x1cf: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
846 case 0x208: case 0x20a: case 0x1e2c: case 0x1e2e: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
847 case 0x1ec8: case 0x1eca: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
848 EMIT2('I') EMIT2(I_grave) EMIT2(I_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
849 EMIT2(I_circumflex) EMIT2(I_diaeresis) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
850 EMIT2(0x128) EMIT2(0x12a) EMIT2(0x12c) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
851 EMIT2(0x12e) EMIT2(0x130) EMIT2(0x197) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
852 EMIT2(0x1cf) EMIT2(0x208) EMIT2(0x20a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
853 EMIT2(0x1e2c) EMIT2(0x1e2e) EMIT2(0x1ec8) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
854 EMIT2(0x1eca) |
5351 | 855 return OK; |
856 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
857 case 'J': case 0x134: case 0x248: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
858 EMIT2('J') EMIT2(0x134) EMIT2(0x248) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
859 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
860 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
861 case 'K': case 0x136: case 0x198: case 0x1e8: case 0x1e30: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
862 case 0x1e32: case 0x1e34: case 0x2c69: case 0xa740: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
863 EMIT2('K') EMIT2(0x136) EMIT2(0x198) EMIT2(0x1e8) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
864 EMIT2(0x1e30) EMIT2(0x1e32) EMIT2(0x1e34) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
865 EMIT2(0x2c69) EMIT2(0xa740) |
5351 | 866 return OK; |
867 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
868 case 'L': case 0x139: case 0x13b: case 0x13d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
869 case 0x13f: case 0x141: case 0x23d: case 0x1e36: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
870 case 0x1e38: case 0x1e3a: case 0x1e3c: case 0x2c60: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
871 EMIT2('L') EMIT2(0x139) EMIT2(0x13b) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
872 EMIT2(0x13d) EMIT2(0x13f) EMIT2(0x141) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
873 EMIT2(0x23d) EMIT2(0x1e36) EMIT2(0x1e38) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
874 EMIT2(0x1e3a) EMIT2(0x1e3c) EMIT2(0x2c60) |
5351 | 875 return OK; |
876 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
877 case 'M': case 0x1e3e: case 0x1e40: case 0x1e42: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
878 EMIT2('M') EMIT2(0x1e3e) EMIT2(0x1e40) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
879 EMIT2(0x1e42) |
4444 | 880 return OK; |
881 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
882 case 'N': case N_virguilla: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
883 case 0x143: case 0x145: case 0x147: case 0x1f8: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
884 case 0x1e44: case 0x1e46: case 0x1e48: case 0x1e4a: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
885 case 0xa7a4: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
886 EMIT2('N') EMIT2(N_virguilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
887 EMIT2(0x143) EMIT2(0x145) EMIT2(0x147) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
888 EMIT2(0x1f8) EMIT2(0x1e44) EMIT2(0x1e46) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
889 EMIT2(0x1e48) EMIT2(0x1e4a) EMIT2(0xa7a4) |
4444 | 890 return OK; |
891 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
892 case 'O': case O_grave: case O_acute: case O_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
893 case O_virguilla: case O_diaeresis: case O_slash: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
894 case 0x14c: case 0x14e: case 0x150: case 0x19f: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
895 case 0x1a0: case 0x1d1: case 0x1ea: case 0x1ec: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
896 case 0x1fe: case 0x20c: case 0x20e: case 0x22a: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
897 case 0x22c: case 0x22e: case 0x230: case 0x1e4c: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
898 case 0x1e4e: case 0x1e50: case 0x1e52: case 0x1ecc: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
899 case 0x1ece: case 0x1ed0: case 0x1ed2: case 0x1ed4: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
900 case 0x1ed6: case 0x1ed8: case 0x1eda: case 0x1edc: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
901 case 0x1ede: case 0x1ee0: case 0x1ee2: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
902 EMIT2('O') EMIT2(O_grave) EMIT2(O_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
903 EMIT2(O_circumflex) EMIT2(O_virguilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
904 EMIT2(O_diaeresis) EMIT2(O_slash) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
905 EMIT2(0x14c) EMIT2(0x14e) EMIT2(0x150) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
906 EMIT2(0x19f) EMIT2(0x1a0) EMIT2(0x1d1) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
907 EMIT2(0x1ea) EMIT2(0x1ec) EMIT2(0x1fe) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
908 EMIT2(0x20c) EMIT2(0x20e) EMIT2(0x22a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
909 EMIT2(0x22c) EMIT2(0x22e) EMIT2(0x230) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
910 EMIT2(0x1e4c) EMIT2(0x1e4e) EMIT2(0x1e50) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
911 EMIT2(0x1e52) EMIT2(0x1ecc) EMIT2(0x1ece) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
912 EMIT2(0x1ed0) EMIT2(0x1ed2) EMIT2(0x1ed4) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
913 EMIT2(0x1ed6) EMIT2(0x1ed8) EMIT2(0x1eda) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
914 EMIT2(0x1edc) EMIT2(0x1ede) EMIT2(0x1ee0) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
915 EMIT2(0x1ee2) |
5351 | 916 return OK; |
917 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
918 case 'P': case 0x1a4: case 0x1e54: case 0x1e56: case 0x2c63: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
919 EMIT2('P') EMIT2(0x1a4) EMIT2(0x1e54) EMIT2(0x1e56) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
920 EMIT2(0x2c63) |
5351 | 921 return OK; |
922 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
923 case 'Q': case 0x24a: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
924 EMIT2('Q') EMIT2(0x24a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
925 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
926 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
927 case 'R': case 0x154: case 0x156: case 0x158: case 0x210: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
928 case 0x212: case 0x24c: case 0x1e58: case 0x1e5a: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
929 case 0x1e5c: case 0x1e5e: case 0x2c64: case 0xa7a6: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
930 EMIT2('R') EMIT2(0x154) EMIT2(0x156) EMIT2(0x158) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
931 EMIT2(0x210) EMIT2(0x212) EMIT2(0x24c) EMIT2(0x1e58) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
932 EMIT2(0x1e5a) EMIT2(0x1e5c) EMIT2(0x1e5e) EMIT2(0x2c64) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
933 EMIT2(0xa7a6) |
5351 | 934 return OK; |
935 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
936 case 'S': case 0x15a: case 0x15c: case 0x15e: case 0x160: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
937 case 0x218: case 0x1e60: case 0x1e62: case 0x1e64: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
938 case 0x1e66: case 0x1e68: case 0x2c7e: case 0xa7a8: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
939 EMIT2('S') EMIT2(0x15a) EMIT2(0x15c) EMIT2(0x15e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
940 EMIT2(0x160) EMIT2(0x218) EMIT2(0x1e60) EMIT2(0x1e62) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
941 EMIT2(0x1e64) EMIT2(0x1e66) EMIT2(0x1e68) EMIT2(0x2c7e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
942 EMIT2(0xa7a8) |
5351 | 943 return OK; |
944 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
945 case 'T': case 0x162: case 0x164: case 0x166: case 0x1ac: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
946 case 0x1ae: case 0x21a: case 0x23e: case 0x1e6a: case 0x1e6c: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
947 case 0x1e6e: case 0x1e70: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
948 EMIT2('T') EMIT2(0x162) EMIT2(0x164) EMIT2(0x166) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
949 EMIT2(0x1ac) EMIT2(0x1ae) EMIT2(0x23e) EMIT2(0x21a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
950 EMIT2(0x1e6a) EMIT2(0x1e6c) EMIT2(0x1e6e) EMIT2(0x1e70) |
4444 | 951 return OK; |
952 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
953 case 'U': case U_grave: case U_acute: case U_diaeresis: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
954 case U_circumflex: case 0x168: case 0x16a: case 0x16c: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
955 case 0x16e: case 0x170: case 0x172: case 0x1af: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
956 case 0x1d3: case 0x1d5: case 0x1d7: case 0x1d9: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
957 case 0x1db: case 0x214: case 0x216: case 0x244: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
958 case 0x1e72: case 0x1e74: case 0x1e76: case 0x1e78: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
959 case 0x1e7a: case 0x1ee4: case 0x1ee6: case 0x1ee8: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
960 case 0x1eea: case 0x1eec: case 0x1eee: case 0x1ef0: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
961 EMIT2('U') EMIT2(U_grave) EMIT2(U_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
962 EMIT2(U_diaeresis) EMIT2(U_circumflex) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
963 EMIT2(0x168) EMIT2(0x16a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
964 EMIT2(0x16c) EMIT2(0x16e) EMIT2(0x170) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
965 EMIT2(0x172) EMIT2(0x1af) EMIT2(0x1d3) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
966 EMIT2(0x1d5) EMIT2(0x1d7) EMIT2(0x1d9) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
967 EMIT2(0x1db) EMIT2(0x214) EMIT2(0x216) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
968 EMIT2(0x244) EMIT2(0x1e72) EMIT2(0x1e74) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
969 EMIT2(0x1e76) EMIT2(0x1e78) EMIT2(0x1e7a) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
970 EMIT2(0x1ee4) EMIT2(0x1ee6) EMIT2(0x1ee8) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
971 EMIT2(0x1eea) EMIT2(0x1eec) EMIT2(0x1eee) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
972 EMIT2(0x1ef0) |
5351 | 973 return OK; |
974 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
975 case 'V': case 0x1b2: case 0x1e7c: case 0x1e7e: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
976 EMIT2('V') EMIT2(0x1b2) EMIT2(0x1e7c) EMIT2(0x1e7e) |
5351 | 977 return OK; |
978 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
979 case 'W': case 0x174: case 0x1e80: case 0x1e82: case 0x1e84: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
980 case 0x1e86: case 0x1e88: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
981 EMIT2('W') EMIT2(0x174) EMIT2(0x1e80) EMIT2(0x1e82) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
982 EMIT2(0x1e84) EMIT2(0x1e86) EMIT2(0x1e88) |
4444 | 983 return OK; |
984 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
985 case 'X': case 0x1e8a: case 0x1e8c: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
986 EMIT2('X') EMIT2(0x1e8a) EMIT2(0x1e8c) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
987 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
988 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
989 case 'Y': case Y_acute: case 0x176: case 0x178: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
990 case 0x1b3: case 0x232: case 0x24e: case 0x1e8e: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
991 case 0x1ef2: case 0x1ef4: case 0x1ef6: case 0x1ef8: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
992 EMIT2('Y') EMIT2(Y_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
993 EMIT2(0x176) EMIT2(0x178) EMIT2(0x1b3) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
994 EMIT2(0x232) EMIT2(0x24e) EMIT2(0x1e8e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
995 EMIT2(0x1ef2) EMIT2(0x1ef4) EMIT2(0x1ef6) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
996 EMIT2(0x1ef8) |
5351 | 997 return OK; |
998 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
999 case 'Z': case 0x179: case 0x17b: case 0x17d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1000 case 0x1b5: case 0x1e90: case 0x1e92: case 0x1e94: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1001 case 0x2c6b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1002 EMIT2('Z') EMIT2(0x179) EMIT2(0x17b) EMIT2(0x17d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1003 EMIT2(0x1b5) EMIT2(0x1e90) EMIT2(0x1e92) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1004 EMIT2(0x1e94) EMIT2(0x2c6b) |
4444 | 1005 return OK; |
1006 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1007 case 'a': case a_grave: case a_acute: case a_circumflex: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1008 case a_virguilla: case a_diaeresis: case a_ring: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1009 case 0x101: case 0x103: case 0x105: case 0x1ce: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1010 case 0x1df: case 0x1e1: case 0x1fb: case 0x201: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1011 case 0x203: case 0x227: case 0x1d8f: case 0x1e01: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1012 case 0x1e9a: case 0x1ea1: case 0x1ea3: case 0x1ea5: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1013 case 0x1ea7: case 0x1ea9: case 0x1eab: case 0x1ead: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1014 case 0x1eaf: case 0x1eb1: case 0x1eb3: case 0x1eb5: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1015 case 0x1eb7: case 0x2c65: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1016 EMIT2('a') EMIT2(a_grave) EMIT2(a_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1017 EMIT2(a_circumflex) EMIT2(a_virguilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1018 EMIT2(a_diaeresis) EMIT2(a_ring) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1019 EMIT2(0x101) EMIT2(0x103) EMIT2(0x105) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1020 EMIT2(0x1ce) EMIT2(0x1df) EMIT2(0x1e1) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1021 EMIT2(0x1fb) EMIT2(0x201) EMIT2(0x203) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1022 EMIT2(0x227) EMIT2(0x1d8f) EMIT2(0x1e01) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1023 EMIT2(0x1e9a) EMIT2(0x1ea1) EMIT2(0x1ea3) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1024 EMIT2(0x1ea5) EMIT2(0x1ea7) EMIT2(0x1ea9) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1025 EMIT2(0x1eab) EMIT2(0x1ead) EMIT2(0x1eaf) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1026 EMIT2(0x1eb1) EMIT2(0x1eb3) EMIT2(0x1eb5) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1027 EMIT2(0x1eb7) EMIT2(0x2c65) |
5351 | 1028 return OK; |
1029 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1030 case 'b': case 0x180: case 0x253: case 0x1d6c: case 0x1d80: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1031 case 0x1e03: case 0x1e05: case 0x1e07: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1032 EMIT2('b') EMIT2(0x180) EMIT2(0x253) EMIT2(0x1d6c) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1033 EMIT2(0x1d80) EMIT2(0x1e03) EMIT2(0x1e05) EMIT2(0x1e07) |
4444 | 1034 return OK; |
1035 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1036 case 'c': case c_cedilla: case 0x107: case 0x109: case 0x10b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1037 case 0x10d: case 0x188: case 0x23c: case 0x1e09: case 0xa793: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1038 case 0xa794: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1039 EMIT2('c') EMIT2(c_cedilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1040 EMIT2(0x107) EMIT2(0x109) EMIT2(0x10b) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1041 EMIT2(0x10d) EMIT2(0x188) EMIT2(0x23c) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1042 EMIT2(0x1e09) EMIT2(0xa793) EMIT2(0xa794) |
5351 | 1043 return OK; |
1044 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1045 case 'd': case 0x10f: case 0x111: case 0x257: case 0x1d6d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1046 case 0x1d81: case 0x1d91: case 0x1e0b: case 0x1e0d: case 0x1e0f: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1047 case 0x1e11: case 0x1e13: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1048 EMIT2('d') EMIT2(0x10f) EMIT2(0x111) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1049 EMIT2(0x257) EMIT2(0x1d6d) EMIT2(0x1d81) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1050 EMIT2(0x1d91) EMIT2(0x1e0b) EMIT2(0x1e0d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1051 EMIT2(0x1e0f) EMIT2(0x1e11) EMIT2(0x1e13) |
4444 | 1052 return OK; |
1053 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1054 case 'e': case e_grave: case e_acute: case e_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1055 case e_diaeresis: case 0x113: case 0x115: case 0x117: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1056 case 0x119: case 0x11b: case 0x205: case 0x207: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1057 case 0x229: case 0x247: case 0x1d92: case 0x1e15: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1058 case 0x1e17: case 0x1e19: case 0x1e1b: case 0x1e1d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1059 case 0x1eb9: case 0x1ebb: case 0x1ebd: case 0x1ebf: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1060 case 0x1ec1: case 0x1ec3: case 0x1ec5: case 0x1ec7: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1061 EMIT2('e') EMIT2(e_grave) EMIT2(e_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1062 EMIT2(e_circumflex) EMIT2(e_diaeresis) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1063 EMIT2(0x113) EMIT2(0x115) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1064 EMIT2(0x117) EMIT2(0x119) EMIT2(0x11b) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1065 EMIT2(0x205) EMIT2(0x207) EMIT2(0x229) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1066 EMIT2(0x247) EMIT2(0x1d92) EMIT2(0x1e15) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1067 EMIT2(0x1e17) EMIT2(0x1e19) EMIT2(0x1e1b) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1068 EMIT2(0x1e1d) EMIT2(0x1eb9) EMIT2(0x1ebb) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1069 EMIT2(0x1ebd) EMIT2(0x1ebf) EMIT2(0x1ec1) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1070 EMIT2(0x1ec3) EMIT2(0x1ec5) EMIT2(0x1ec7) |
5351 | 1071 return OK; |
1072 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1073 case 'f': case 0x192: case 0x1d6e: case 0x1d82: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1074 case 0x1e1f: case 0xa799: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1075 EMIT2('f') EMIT2(0x192) EMIT2(0x1d6e) EMIT2(0x1d82) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1076 EMIT2(0x1e1f) EMIT2(0xa799) |
5351 | 1077 return OK; |
1078 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1079 case 'g': case 0x11d: case 0x11f: case 0x121: case 0x123: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1080 case 0x1e5: case 0x1e7: case 0x1f5: case 0x260: case 0x1d83: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1081 case 0x1e21: case 0xa7a1: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1082 EMIT2('g') EMIT2(0x11d) EMIT2(0x11f) EMIT2(0x121) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1083 EMIT2(0x123) EMIT2(0x1e5) EMIT2(0x1e7) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1084 EMIT2(0x1f5) EMIT2(0x260) EMIT2(0x1d83) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1085 EMIT2(0x1e21) EMIT2(0xa7a1) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1086 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1087 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1088 case 'h': case 0x125: case 0x127: case 0x21f: case 0x1e23: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1089 case 0x1e25: case 0x1e27: case 0x1e29: case 0x1e2b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1090 case 0x1e96: case 0x2c68: case 0xa795: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1091 EMIT2('h') EMIT2(0x125) EMIT2(0x127) EMIT2(0x21f) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1092 EMIT2(0x1e23) EMIT2(0x1e25) EMIT2(0x1e27) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1093 EMIT2(0x1e29) EMIT2(0x1e2b) EMIT2(0x1e96) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1094 EMIT2(0x2c68) EMIT2(0xa795) |
4444 | 1095 return OK; |
1096 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1097 case 'i': case i_grave: case i_acute: case i_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1098 case i_diaeresis: case 0x129: case 0x12b: case 0x12d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1099 case 0x12f: case 0x1d0: case 0x209: case 0x20b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1100 case 0x268: case 0x1d96: case 0x1e2d: case 0x1e2f: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1101 case 0x1ec9: case 0x1ecb: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1102 EMIT2('i') EMIT2(i_grave) EMIT2(i_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1103 EMIT2(i_circumflex) EMIT2(i_diaeresis) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1104 EMIT2(0x129) EMIT2(0x12b) EMIT2(0x12d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1105 EMIT2(0x12f) EMIT2(0x1d0) EMIT2(0x209) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1106 EMIT2(0x20b) EMIT2(0x268) EMIT2(0x1d96) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1107 EMIT2(0x1e2d) EMIT2(0x1e2f) EMIT2(0x1ec9) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1108 EMIT2(0x1ecb) EMIT2(0x1ecb) |
5351 | 1109 return OK; |
1110 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1111 case 'j': case 0x135: case 0x1f0: case 0x249: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1112 EMIT2('j') EMIT2(0x135) EMIT2(0x1f0) EMIT2(0x249) |
5351 | 1113 return OK; |
1114 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1115 case 'k': case 0x137: case 0x199: case 0x1e9: case 0x1d84: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1116 case 0x1e31: case 0x1e33: case 0x1e35: case 0x2c6a: case 0xa741: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1117 EMIT2('k') EMIT2(0x137) EMIT2(0x199) EMIT2(0x1e9) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1118 EMIT2(0x1d84) EMIT2(0x1e31) EMIT2(0x1e33) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1119 EMIT2(0x1e35) EMIT2(0x2c6a) EMIT2(0xa741) |
5351 | 1120 return OK; |
1121 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1122 case 'l': case 0x13a: case 0x13c: case 0x13e: case 0x140: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1123 case 0x142: case 0x19a: case 0x1e37: case 0x1e39: case 0x1e3b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1124 case 0x1e3d: case 0x2c61: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1125 EMIT2('l') EMIT2(0x13a) EMIT2(0x13c) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1126 EMIT2(0x13e) EMIT2(0x140) EMIT2(0x142) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1127 EMIT2(0x19a) EMIT2(0x1e37) EMIT2(0x1e39) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1128 EMIT2(0x1e3b) EMIT2(0x1e3d) EMIT2(0x2c61) |
4444 | 1129 return OK; |
1130 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1131 case 'm': case 0x1d6f: case 0x1e3f: case 0x1e41: case 0x1e43: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1132 EMIT2('m') EMIT2(0x1d6f) EMIT2(0x1e3f) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1133 EMIT2(0x1e41) EMIT2(0x1e43) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1134 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1135 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1136 case 'n': case n_virguilla: case 0x144: case 0x146: case 0x148: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1137 case 0x149: case 0x1f9: case 0x1d70: case 0x1d87: case 0x1e45: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1138 case 0x1e47: case 0x1e49: case 0x1e4b: case 0xa7a5: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1139 EMIT2('n') EMIT2(n_virguilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1140 EMIT2(0x144) EMIT2(0x146) EMIT2(0x148) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1141 EMIT2(0x149) EMIT2(0x1f9) EMIT2(0x1d70) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1142 EMIT2(0x1d87) EMIT2(0x1e45) EMIT2(0x1e47) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1143 EMIT2(0x1e49) EMIT2(0x1e4b) EMIT2(0xa7a5) |
4444 | 1144 return OK; |
1145 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1146 case 'o': case o_grave: case o_acute: case o_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1147 case o_virguilla: case o_diaeresis: case o_slash: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1148 case 0x14d: case 0x14f: case 0x151: case 0x1a1: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1149 case 0x1d2: case 0x1eb: case 0x1ed: case 0x1ff: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1150 case 0x20d: case 0x20f: case 0x22b: case 0x22d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1151 case 0x22f: case 0x231: case 0x275: case 0x1e4d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1152 case 0x1e4f: case 0x1e51: case 0x1e53: case 0x1ecd: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1153 case 0x1ecf: case 0x1ed1: case 0x1ed3: case 0x1ed5: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1154 case 0x1ed7: case 0x1ed9: case 0x1edb: case 0x1edd: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1155 case 0x1edf: case 0x1ee1: case 0x1ee3: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1156 EMIT2('o') EMIT2(o_grave) EMIT2(o_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1157 EMIT2(o_circumflex) EMIT2(o_virguilla) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1158 EMIT2(o_diaeresis) EMIT2(o_slash) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1159 EMIT2(0x14d) EMIT2(0x14f) EMIT2(0x151) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1160 EMIT2(0x1a1) EMIT2(0x1d2) EMIT2(0x1eb) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1161 EMIT2(0x1ed) EMIT2(0x1ff) EMIT2(0x20d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1162 EMIT2(0x20f) EMIT2(0x22b) EMIT2(0x22d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1163 EMIT2(0x22f) EMIT2(0x231) EMIT2(0x275) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1164 EMIT2(0x1e4d) EMIT2(0x1e4f) EMIT2(0x1e51) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1165 EMIT2(0x1e53) EMIT2(0x1ecd) EMIT2(0x1ecf) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1166 EMIT2(0x1ed1) EMIT2(0x1ed3) EMIT2(0x1ed5) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1167 EMIT2(0x1ed7) EMIT2(0x1ed9) EMIT2(0x1edb) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1168 EMIT2(0x1edd) EMIT2(0x1edf) EMIT2(0x1ee1) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1169 EMIT2(0x1ee3) |
5351 | 1170 return OK; |
1171 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1172 case 'p': case 0x1a5: case 0x1d71: case 0x1d7d: case 0x1d88: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1173 case 0x1e55: case 0x1e57: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1174 EMIT2('p') EMIT2(0x1a5) EMIT2(0x1d71) EMIT2(0x1d7d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1175 EMIT2(0x1d88) EMIT2(0x1e55) EMIT2(0x1e57) |
5351 | 1176 return OK; |
1177 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1178 case 'q': case 0x24b: case 0x2a0: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1179 EMIT2('q') EMIT2(0x24b) EMIT2(0x2a0) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1180 return OK; |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1181 |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1182 case 'r': case 0x155: case 0x157: case 0x159: case 0x211: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1183 case 0x213: case 0x24d: case 0x27d: case 0x1d72: case 0x1d73: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1184 case 0x1d89: case 0x1e59: case 0x1e5b: case 0x1e5d: case 0x1e5f: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1185 case 0xa7a7: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1186 EMIT2('r') EMIT2(0x155) EMIT2(0x157) EMIT2(0x159) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1187 EMIT2(0x211) EMIT2(0x213) EMIT2(0x24d) EMIT2(0x27d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1188 EMIT2(0x1d72) EMIT2(0x1d73) EMIT2(0x1d89) EMIT2(0x1e59) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1189 EMIT2(0x1e5b) EMIT2(0x1e5d) EMIT2(0x1e5f) EMIT2(0xa7a7) |
5351 | 1190 return OK; |
1191 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1192 case 's': case 0x15b: case 0x15d: case 0x15f: case 0x161: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1193 case 0x219: case 0x23f: case 0x1d74: case 0x1d8a: case 0x1e61: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1194 case 0x1e63: case 0x1e65: case 0x1e67: case 0x1e69: case 0xa7a9: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1195 EMIT2('s') EMIT2(0x15b) EMIT2(0x15d) EMIT2(0x15f) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1196 EMIT2(0x161) EMIT2(0x219) EMIT2(0x23f) EMIT2(0x1d74) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1197 EMIT2(0x1d8a) EMIT2(0x1e61) EMIT2(0x1e63) EMIT2(0x1e65) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1198 EMIT2(0x1e67) EMIT2(0x1e69) EMIT2(0xa7a9) |
5351 | 1199 return OK; |
1200 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1201 case 't': case 0x163: case 0x165: case 0x167: case 0x1ab: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1202 case 0x1ad: case 0x21b: case 0x288: case 0x1d75: case 0x1e6b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1203 case 0x1e6d: case 0x1e6f: case 0x1e71: case 0x1e97: case 0x2c66: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1204 EMIT2('t') EMIT2(0x163) EMIT2(0x165) EMIT2(0x167) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1205 EMIT2(0x1ab) EMIT2(0x1ad) EMIT2(0x21b) EMIT2(0x288) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1206 EMIT2(0x1d75) EMIT2(0x1e6b) EMIT2(0x1e6d) EMIT2(0x1e6f) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1207 EMIT2(0x1e71) EMIT2(0x1e97) EMIT2(0x2c66) |
4444 | 1208 return OK; |
1209 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1210 case 'u': case u_grave: case u_acute: case u_circumflex: |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1211 case u_diaeresis: case 0x169: case 0x16b: case 0x16d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1212 case 0x16f: case 0x171: case 0x173: case 0x1b0: case 0x1d4: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1213 case 0x1d6: case 0x1d8: case 0x1da: case 0x1dc: case 0x215: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1214 case 0x217: case 0x289: case 0x1d7e: case 0x1d99: case 0x1e73: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1215 case 0x1e75: case 0x1e77: case 0x1e79: case 0x1e7b: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1216 case 0x1ee5: case 0x1ee7: case 0x1ee9: case 0x1eeb: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1217 case 0x1eed: case 0x1eef: case 0x1ef1: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1218 EMIT2('u') EMIT2(u_grave) EMIT2(u_acute) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1219 EMIT2(u_circumflex) EMIT2(u_diaeresis) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1220 EMIT2(0x169) EMIT2(0x16b) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1221 EMIT2(0x16d) EMIT2(0x16f) EMIT2(0x171) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1222 EMIT2(0x173) EMIT2(0x1d6) EMIT2(0x1d8) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1223 EMIT2(0x215) EMIT2(0x217) EMIT2(0x1b0) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1224 EMIT2(0x1d4) EMIT2(0x1da) EMIT2(0x1dc) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1225 EMIT2(0x289) EMIT2(0x1e73) EMIT2(0x1d7e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1226 EMIT2(0x1d99) EMIT2(0x1e75) EMIT2(0x1e77) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1227 EMIT2(0x1e79) EMIT2(0x1e7b) EMIT2(0x1ee5) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1228 EMIT2(0x1ee7) EMIT2(0x1ee9) EMIT2(0x1eeb) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1229 EMIT2(0x1eed) EMIT2(0x1eef) EMIT2(0x1ef1) |
5351 | 1230 return OK; |
1231 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1232 case 'v': case 0x28b: case 0x1d8c: case 0x1e7d: case 0x1e7f: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1233 EMIT2('v') EMIT2(0x28b) EMIT2(0x1d8c) EMIT2(0x1e7d) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1234 EMIT2(0x1e7f) |
5351 | 1235 return OK; |
1236 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1237 case 'w': case 0x175: case 0x1e81: case 0x1e83: case 0x1e85: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1238 case 0x1e87: case 0x1e89: case 0x1e98: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1239 EMIT2('w') EMIT2(0x175) EMIT2(0x1e81) EMIT2(0x1e83) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1240 EMIT2(0x1e85) EMIT2(0x1e87) EMIT2(0x1e89) EMIT2(0x1e98) |
5351 | 1241 return OK; |
1242 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1243 case 'x': case 0x1e8b: case 0x1e8d: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1244 EMIT2('x') EMIT2(0x1e8b) EMIT2(0x1e8d) |
4444 | 1245 return OK; |
1246 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1247 case 'y': case y_acute: case y_diaeresis: case 0x177: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1248 case 0x1b4: case 0x233: case 0x24f: case 0x1e8f: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1249 case 0x1e99: case 0x1ef3: case 0x1ef5: case 0x1ef7: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1250 case 0x1ef9: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1251 EMIT2('y') EMIT2(y_acute) EMIT2(y_diaeresis) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1252 EMIT2(0x177) EMIT2(0x1b4) EMIT2(0x233) EMIT2(0x24f) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1253 EMIT2(0x1e8f) EMIT2(0x1e99) EMIT2(0x1ef3) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1254 EMIT2(0x1ef5) EMIT2(0x1ef7) EMIT2(0x1ef9) |
4444 | 1255 return OK; |
1256 | |
24351
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1257 case 'z': case 0x17a: case 0x17c: case 0x17e: case 0x1b6: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1258 case 0x1d76: case 0x1d8e: case 0x1e91: case 0x1e93: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1259 case 0x1e95: case 0x2c6c: |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1260 EMIT2('z') EMIT2(0x17a) EMIT2(0x17c) EMIT2(0x17e) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1261 EMIT2(0x1b6) EMIT2(0x1d76) EMIT2(0x1d8e) EMIT2(0x1e91) |
585695c70392
patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents:
23471
diff
changeset
|
1262 EMIT2(0x1e93) EMIT2(0x1e95) EMIT2(0x2c6c) |
5351 | 1263 return OK; |
1264 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1265 // default: character itself |
4444 | 1266 } |
1267 } | |
1268 | |
5351 | 1269 EMIT2(c); |
4444 | 1270 return OK; |
1271 #undef EMIT2 | |
1272 } | |
1273 | |
1274 /* | |
1275 * Code to parse regular expression. | |
1276 * | |
1277 * We try to reuse parsing functions in regexp.c to | |
1278 * minimize surprise and keep the syntax consistent. | |
1279 */ | |
1280 | |
1281 /* | |
1282 * Parse the lowest level. | |
1283 * | |
1284 * An atom can be one of a long list of items. Many atoms match one character | |
1285 * in the text. It is often an ordinary character or a character class. | |
1286 * Braces can be used to make a pattern into an atom. The "\z(\)" construct | |
1287 * is only for syntax highlighting. | |
1288 * | |
1289 * atom ::= ordinary-atom | |
1290 * or \( pattern \) | |
1291 * or \%( pattern \) | |
1292 * or \z( pattern \) | |
1293 */ | |
1294 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1295 nfa_regatom(void) |
4444 | 1296 { |
1297 int c; | |
1298 int charclass; | |
1299 int equiclass; | |
1300 int collclass; | |
1301 int got_coll_char; | |
1302 char_u *p; | |
1303 char_u *endp; | |
1304 char_u *old_regparse = regparse; | |
1305 int extra = 0; | |
1306 int emit_range; | |
1307 int negated; | |
1308 int result; | |
1309 int startc = -1; | |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1310 int save_prev_at_start = prev_at_start; |
4444 | 1311 |
1312 c = getchr(); | |
1313 switch (c) | |
1314 { | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1315 case NUL: |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1316 EMSG_RET_FAIL(_(e_nfa_regexp_end_encountered_prematurely)); |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1317 |
4444 | 1318 case Magic('^'): |
1319 EMIT(NFA_BOL); | |
1320 break; | |
1321 | |
1322 case Magic('$'): | |
1323 EMIT(NFA_EOL); | |
1324 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
1325 had_eol = TRUE; | |
1326 #endif | |
1327 break; | |
1328 | |
1329 case Magic('<'): | |
1330 EMIT(NFA_BOW); | |
1331 break; | |
1332 | |
1333 case Magic('>'): | |
1334 EMIT(NFA_EOW); | |
1335 break; | |
1336 | |
1337 case Magic('_'): | |
1338 c = no_Magic(getchr()); | |
5511 | 1339 if (c == NUL) |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1340 EMSG_RET_FAIL(_(e_nfa_regexp_end_encountered_prematurely)); |
5511 | 1341 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1342 if (c == '^') // "\_^" is start-of-line |
4444 | 1343 { |
1344 EMIT(NFA_BOL); | |
1345 break; | |
1346 } | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1347 if (c == '$') // "\_$" is end-of-line |
4444 | 1348 { |
1349 EMIT(NFA_EOL); | |
1350 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
1351 had_eol = TRUE; | |
1352 #endif | |
1353 break; | |
1354 } | |
1355 | |
5296 | 1356 extra = NFA_ADD_NL; |
4444 | 1357 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1358 // "\_[" is collection plus newline |
4444 | 1359 if (c == '[') |
4517
9a2183bd8295
updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents:
4515
diff
changeset
|
1360 goto collection; |
4444 | 1361 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1362 // "\_x" is character class plus newline |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1363 // FALLTHROUGH |
4444 | 1364 |
1365 /* | |
1366 * Character classes. | |
1367 */ | |
1368 case Magic('.'): | |
1369 case Magic('i'): | |
1370 case Magic('I'): | |
1371 case Magic('k'): | |
1372 case Magic('K'): | |
1373 case Magic('f'): | |
1374 case Magic('F'): | |
1375 case Magic('p'): | |
1376 case Magic('P'): | |
1377 case Magic('s'): | |
1378 case Magic('S'): | |
1379 case Magic('d'): | |
1380 case Magic('D'): | |
1381 case Magic('x'): | |
1382 case Magic('X'): | |
1383 case Magic('o'): | |
1384 case Magic('O'): | |
1385 case Magic('w'): | |
1386 case Magic('W'): | |
1387 case Magic('h'): | |
1388 case Magic('H'): | |
1389 case Magic('a'): | |
1390 case Magic('A'): | |
1391 case Magic('l'): | |
1392 case Magic('L'): | |
1393 case Magic('u'): | |
1394 case Magic('U'): | |
1395 p = vim_strchr(classchars, no_Magic(c)); | |
1396 if (p == NULL) | |
1397 { | |
5511 | 1398 if (extra == NFA_ADD_NL) |
1399 { | |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1400 semsg(_(e_nfa_regexp_invalid_character_class_nr), c); |
5511 | 1401 rc_did_emsg = TRUE; |
1402 return FAIL; | |
1403 } | |
15490
98c35d312987
patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
1404 siemsg("INTERNAL: Unknown character class char: %d", c); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1405 return FAIL; |
4444 | 1406 } |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
1407 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1408 // When '.' is followed by a composing char ignore the dot, so that |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1409 // the composing char is matched here. |
4444 | 1410 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr())) |
1411 { | |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1412 old_regparse = regparse; |
4444 | 1413 c = getchr(); |
1414 goto nfa_do_multibyte; | |
1415 } | |
1416 EMIT(nfa_classcodes[p - classchars]); | |
5296 | 1417 if (extra == NFA_ADD_NL) |
4444 | 1418 { |
1419 EMIT(NFA_NEWL); | |
1420 EMIT(NFA_OR); | |
1421 regflags |= RF_HASNL; | |
1422 } | |
1423 break; | |
1424 | |
1425 case Magic('n'): | |
1426 if (reg_string) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1427 // In a string "\n" matches a newline character. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1428 EMIT(NL); |
4444 | 1429 else |
1430 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1431 // In buffer text "\n" matches the end of a line. |
4444 | 1432 EMIT(NFA_NEWL); |
1433 regflags |= RF_HASNL; | |
1434 } | |
1435 break; | |
1436 | |
1437 case Magic('('): | |
1438 if (nfa_reg(REG_PAREN) == FAIL) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1439 return FAIL; // cascaded error |
4444 | 1440 break; |
1441 | |
1442 case Magic('|'): | |
1443 case Magic('&'): | |
1444 case Magic(')'): | |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1445 semsg(_(e_nfa_regexp_misplaced_chr), no_Magic(c)); |
4444 | 1446 return FAIL; |
1447 | |
1448 case Magic('='): | |
1449 case Magic('?'): | |
1450 case Magic('+'): | |
1451 case Magic('@'): | |
1452 case Magic('*'): | |
1453 case Magic('{'): | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1454 // these should follow an atom, not form an atom |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1455 semsg(_(e_nfa_regexp_misplaced_chr), no_Magic(c)); |
4444 | 1456 return FAIL; |
1457 | |
4714
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1458 case Magic('~'): |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1459 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1460 char_u *lp; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1461 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1462 // Previous substitute pattern. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1463 // Generated as "\%(pattern\)". |
4714
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1464 if (reg_prev_sub == NULL) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1465 { |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25178
diff
changeset
|
1466 emsg(_(e_no_previous_substitute_regular_expression)); |
4714
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1467 return FAIL; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1468 } |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1469 for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) |
4714
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1470 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1471 EMIT(PTR2CHAR(lp)); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1472 if (lp != reg_prev_sub) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1473 EMIT(NFA_CONCAT); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1474 } |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1475 EMIT(NFA_NOPEN); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1476 break; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1477 } |
4444 | 1478 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1479 case Magic('1'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1480 case Magic('2'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1481 case Magic('3'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1482 case Magic('4'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1483 case Magic('5'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1484 case Magic('6'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1485 case Magic('7'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1486 case Magic('8'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1487 case Magic('9'): |
11525
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1488 { |
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1489 int refnum = no_Magic(c) - '1'; |
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1490 |
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1491 if (!seen_endbrace(refnum + 1)) |
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1492 return FAIL; |
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1493 EMIT(NFA_BACKREF1 + refnum); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
1494 rex.nfa_has_backref = TRUE; |
11525
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11521
diff
changeset
|
1495 } |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1496 break; |
4444 | 1497 |
1498 case Magic('z'): | |
1499 c = no_Magic(getchr()); | |
1500 switch (c) | |
1501 { | |
1502 case 's': | |
1503 EMIT(NFA_ZSTART); | |
6170 | 1504 if (re_mult_next("\\zs") == FAIL) |
1505 return FAIL; | |
4444 | 1506 break; |
1507 case 'e': | |
1508 EMIT(NFA_ZEND); | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
1509 rex.nfa_has_zend = TRUE; |
6170 | 1510 if (re_mult_next("\\ze") == FAIL) |
1511 return FAIL; | |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
1512 break; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1513 #ifdef FEAT_SYN_HL |
4444 | 1514 case '1': |
1515 case '2': | |
1516 case '3': | |
1517 case '4': | |
1518 case '5': | |
1519 case '6': | |
1520 case '7': | |
1521 case '8': | |
1522 case '9': | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1523 // \z1...\z9 |
14161
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
14159
diff
changeset
|
1524 if ((reg_do_extmatch & REX_USE) == 0) |
26436
ef0c07cbf53f
patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26161
diff
changeset
|
1525 EMSG_RET_FAIL(_(e_z1_z9_not_allowed_here)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1526 EMIT(NFA_ZREF1 + (no_Magic(c) - '1')); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1527 // No need to set rex.nfa_has_backref, the sub-matches don't |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1528 // change when \z1 .. \z9 matches or not. |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1529 re_has_z = REX_USE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1530 break; |
4444 | 1531 case '(': |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1532 // \z( |
14161
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
14159
diff
changeset
|
1533 if ((reg_do_extmatch & REX_SET) == 0) |
26436
ef0c07cbf53f
patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26161
diff
changeset
|
1534 EMSG_RET_FAIL(_(e_z_not_allowed_here)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1535 if (nfa_reg(REG_ZPAREN) == FAIL) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1536 return FAIL; // cascaded error |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1537 re_has_z = REX_SET; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1538 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1539 #endif |
4444 | 1540 default: |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
1541 semsg(_(e_nfa_regexp_unknown_operator_z_chr), no_Magic(c)); |
4444 | 1542 return FAIL; |
1543 } | |
1544 break; | |
1545 | |
1546 case Magic('%'): | |
1547 c = no_Magic(getchr()); | |
1548 switch (c) | |
1549 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1550 // () without a back reference |
4444 | 1551 case '(': |
1552 if (nfa_reg(REG_NPAREN) == FAIL) | |
1553 return FAIL; | |
1554 EMIT(NFA_NOPEN); | |
1555 break; | |
1556 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1557 case 'd': // %d123 decimal |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1558 case 'o': // %o123 octal |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1559 case 'x': // %xab hex 2 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1560 case 'u': // %uabcd hex 4 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1561 case 'U': // %U1234abcd hex 8 |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1562 { |
12752
09c856605191
patch 8.0.1254: undefined left shift in gethexchrs()
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
1563 long nr; |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1564 |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1565 switch (c) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1566 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1567 case 'd': nr = getdecchrs(); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1568 case 'o': nr = getoctchrs(); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1569 case 'x': nr = gethexchrs(2); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1570 case 'u': nr = gethexchrs(4); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1571 case 'U': nr = gethexchrs(8); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1572 default: nr = -1; break; |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1573 } |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1574 |
15924
98d315176d48
patch 8.1.0968: crash when using search pattern %Ufffffc23
Bram Moolenaar <Bram@vim.org>
parents:
15904
diff
changeset
|
1575 if (nr < 0 || nr > INT_MAX) |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
1576 EMSG2_RET_FAIL(_(e_invalid_character_after_str_2), |
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26883
diff
changeset
|
1577 reg_magic == MAGIC_ALL); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1578 // A NUL is stored in the text as NL |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1579 // TODO: what if a composing character follows? |
5360 | 1580 EMIT(nr == 0 ? 0x0a : nr); |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1581 } |
4444 | 1582 break; |
1583 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1584 // Catch \%^ and \%$ regardless of where they appear in the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1585 // pattern -- regardless of whether or not it makes sense. |
4444 | 1586 case '^': |
1587 EMIT(NFA_BOF); | |
1588 break; | |
1589 | |
1590 case '$': | |
1591 EMIT(NFA_EOF); | |
1592 break; | |
1593 | |
1594 case '#': | |
28911
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1595 if (regparse[0] == '=' && regparse[1] >= 48 |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1596 && regparse[1] <= 50) |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1597 { |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1598 // misplaced \%#=1 |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1599 semsg(_(e_atom_engine_must_be_at_start_of_pattern), |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1600 regparse[1]); |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1601 return FAIL; |
e25196adb7c1
patch 8.2.4978: no error if engine selection atom is not at the start
Bram Moolenaar <Bram@vim.org>
parents:
28335
diff
changeset
|
1602 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1603 EMIT(NFA_CURSOR); |
4444 | 1604 break; |
1605 | |
1606 case 'V': | |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
1607 EMIT(NFA_VISUAL); |
4444 | 1608 break; |
1609 | |
5901 | 1610 case 'C': |
1611 EMIT(NFA_ANY_COMPOSING); | |
1612 break; | |
1613 | |
4444 | 1614 case '[': |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1615 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1616 int n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1617 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1618 // \%[abc] |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1619 for (n = 0; (c = peekchr()) != ']'; ++n) |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1620 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1621 if (c == NUL) |
26436
ef0c07cbf53f
patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26161
diff
changeset
|
1622 EMSG2_RET_FAIL(_(e_missing_sb_after_str), |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1623 reg_magic == MAGIC_ALL); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1624 // recursive call! |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1625 if (nfa_regatom() == FAIL) |
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1626 return FAIL; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1627 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1628 getchr(); // get the ] |
4760
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1629 if (n == 0) |
26436
ef0c07cbf53f
patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26161
diff
changeset
|
1630 EMSG2_RET_FAIL(_(e_empty_str_brackets), |
4760
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1631 reg_magic == MAGIC_ALL); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1632 EMIT(NFA_OPT_CHARS); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1633 EMIT(n); |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1634 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1635 // Emit as "\%(\%[abc]\)" to be able to handle |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1636 // "\%[abc]*" which would cause the empty string to be |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1637 // matched an unlimited number of times. NFA_NOPEN is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1638 // added only once at a position, while NFA_SPLIT is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1639 // added multiple times. This is more efficient than |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1640 // not allowing NFA_SPLIT multiple times, it is used |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1641 // a lot. |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1642 EMIT(NFA_NOPEN); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1643 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1644 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1645 |
4444 | 1646 default: |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1647 { |
20677
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1648 long_u n = 0; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1649 int cmp = c; |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1650 int cur = FALSE; |
28335
786707ef91de
patch 8.2.4693: new regexp does not accept pattern "%>0v"
Bram Moolenaar <Bram@vim.org>
parents:
28325
diff
changeset
|
1651 int got_digit = FALSE; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1652 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1653 if (c == '<' || c == '>') |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1654 c = getchr(); |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1655 if (no_Magic(c) == '.') |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1656 { |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1657 cur = TRUE; |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1658 c = getchr(); |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1659 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1660 while (VIM_ISDIGIT(c)) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1661 { |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1662 long_u tmp; |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1663 |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1664 if (cur) |
28135
3ccd55c472b8
patch 8.2.4592: search continues after giving E1204
Bram Moolenaar <Bram@vim.org>
parents:
28043
diff
changeset
|
1665 { |
28325
a3a760ee765f
patch 8.2.4688: new regexp engine does not give an error for "%v"
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1666 semsg(_(e_regexp_number_after_dot_pos_search_chr), |
28135
3ccd55c472b8
patch 8.2.4592: search continues after giving E1204
Bram Moolenaar <Bram@vim.org>
parents:
28043
diff
changeset
|
1667 no_Magic(c)); |
3ccd55c472b8
patch 8.2.4592: search continues after giving E1204
Bram Moolenaar <Bram@vim.org>
parents:
28043
diff
changeset
|
1668 return FAIL; |
3ccd55c472b8
patch 8.2.4592: search continues after giving E1204
Bram Moolenaar <Bram@vim.org>
parents:
28043
diff
changeset
|
1669 } |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1670 tmp = n * 10 + (c - '0'); |
20677
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1671 |
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1672 if (tmp < n) |
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1673 { |
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1674 // overflow. |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1675 emsg(_(e_percent_value_too_large)); |
20677
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1676 return FAIL; |
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1677 } |
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1678 n = tmp; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1679 c = getchr(); |
28335
786707ef91de
patch 8.2.4693: new regexp does not accept pattern "%>0v"
Bram Moolenaar <Bram@vim.org>
parents:
28325
diff
changeset
|
1680 got_digit = TRUE; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1681 } |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1682 if (c == 'l' || c == 'c' || c == 'v') |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1683 { |
20677
ab0dc036f586
patch 8.2.0892: ubsan warns for undefined behavior
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
1684 long_u limit = INT_MAX; |
15802
f043c8931585
patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents:
15800
diff
changeset
|
1685 |
28335
786707ef91de
patch 8.2.4693: new regexp does not accept pattern "%>0v"
Bram Moolenaar <Bram@vim.org>
parents:
28325
diff
changeset
|
1686 if (!cur && !got_digit) |
28325
a3a760ee765f
patch 8.2.4688: new regexp engine does not give an error for "%v"
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1687 { |
a3a760ee765f
patch 8.2.4688: new regexp engine does not give an error for "%v"
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1688 semsg(_(e_nfa_regexp_missing_value_in_chr), |
a3a760ee765f
patch 8.2.4688: new regexp engine does not give an error for "%v"
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1689 no_Magic(c)); |
a3a760ee765f
patch 8.2.4688: new regexp engine does not give an error for "%v"
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1690 return FAIL; |
a3a760ee765f
patch 8.2.4688: new regexp engine does not give an error for "%v"
Bram Moolenaar <Bram@vim.org>
parents:
28247
diff
changeset
|
1691 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1692 if (c == 'l') |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1693 { |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1694 if (cur) |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1695 n = curwin->w_cursor.lnum; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1696 // \%{n}l \%{n}<l \%{n}>l |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1697 EMIT(cmp == '<' ? NFA_LNUM_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1698 cmp == '>' ? NFA_LNUM_GT : NFA_LNUM); |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1699 if (save_prev_at_start) |
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1700 at_start = TRUE; |
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1701 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1702 else if (c == 'c') |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1703 { |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1704 if (cur) |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1705 { |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1706 n = curwin->w_cursor.col; |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1707 n++; |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1708 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1709 // \%{n}c \%{n}<c \%{n}>c |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1710 EMIT(cmp == '<' ? NFA_COL_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1711 cmp == '>' ? NFA_COL_GT : NFA_COL); |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1712 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1713 else |
15802
f043c8931585
patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents:
15800
diff
changeset
|
1714 { |
25147
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1715 if (cur) |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1716 { |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1717 colnr_T vcol = 0; |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1718 |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1719 getvvcol(curwin, &curwin->w_cursor, |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1720 NULL, NULL, &vcol); |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1721 n = ++vcol; |
10b269321459
patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents:
24693
diff
changeset
|
1722 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1723 // \%{n}v \%{n}<v \%{n}>v |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1724 EMIT(cmp == '<' ? NFA_VCOL_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1725 cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); |
15802
f043c8931585
patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents:
15800
diff
changeset
|
1726 limit = INT_MAX / MB_MAXBYTES; |
f043c8931585
patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents:
15800
diff
changeset
|
1727 } |
f043c8931585
patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents:
15800
diff
changeset
|
1728 if (n >= limit) |
13192
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
1729 { |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1730 emsg(_(e_percent_value_too_large)); |
13192
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
1731 return FAIL; |
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
1732 } |
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
1733 EMIT((int)n); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1734 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1735 } |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1736 else if (c == '\'' && n == 0) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1737 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1738 // \%'m \%<'m \%>'m |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1739 EMIT(cmp == '<' ? NFA_MARK_LT : |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1740 cmp == '>' ? NFA_MARK_GT : NFA_MARK); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1741 EMIT(getchr()); |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1742 break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1743 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1744 } |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
1745 semsg(_(e_nfa_regexp_unknown_operator_percent_chr), no_Magic(c)); |
4444 | 1746 return FAIL; |
1747 } | |
1748 break; | |
1749 | |
1750 case Magic('['): | |
4517
9a2183bd8295
updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents:
4515
diff
changeset
|
1751 collection: |
4444 | 1752 /* |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1753 * [abc] uses NFA_START_COLL - NFA_END_COLL |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1754 * [^abc] uses NFA_START_NEG_COLL - NFA_END_NEG_COLL |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1755 * Each character is produced as a regular state, using |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1756 * NFA_CONCAT to bind them together. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1757 * Besides normal characters there can be: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1758 * - character classes NFA_CLASS_* |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1759 * - ranges, two characters followed by NFA_RANGE. |
4444 | 1760 */ |
1761 | |
1762 p = regparse; | |
1763 endp = skip_anyof(p); | |
1764 if (*endp == ']') | |
1765 { | |
1766 /* | |
1767 * Try to reverse engineer character classes. For example, | |
5296 | 1768 * recognize that [0-9] stands for \d and [A-Za-z_] for \h, |
4444 | 1769 * and perform the necessary substitutions in the NFA. |
1770 */ | |
1771 result = nfa_recognize_char_class(regparse, endp, | |
5296 | 1772 extra == NFA_ADD_NL); |
4444 | 1773 if (result != FAIL) |
1774 { | |
5296 | 1775 if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL) |
4444 | 1776 { |
5296 | 1777 EMIT(result - NFA_ADD_NL); |
4444 | 1778 EMIT(NFA_NEWL); |
1779 EMIT(NFA_OR); | |
1780 } | |
5296 | 1781 else |
1782 EMIT(result); | |
4444 | 1783 regparse = endp; |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1784 MB_PTR_ADV(regparse); |
4444 | 1785 return OK; |
1786 } | |
1787 /* | |
1788 * Failed to recognize a character class. Use the simple | |
1789 * version that turns [abc] into 'a' OR 'b' OR 'c' | |
1790 */ | |
25178
0797c8ce343d
patch 8.2.3125: variables are set but not used
Bram Moolenaar <Bram@vim.org>
parents:
25147
diff
changeset
|
1791 startc = -1; |
4444 | 1792 negated = FALSE; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1793 if (*regparse == '^') // negated range |
4444 | 1794 { |
1795 negated = TRUE; | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1796 MB_PTR_ADV(regparse); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1797 EMIT(NFA_START_NEG_COLL); |
4444 | 1798 } |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1799 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1800 EMIT(NFA_START_COLL); |
4444 | 1801 if (*regparse == '-') |
1802 { | |
1803 startc = '-'; | |
1804 EMIT(startc); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1805 EMIT(NFA_CONCAT); |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1806 MB_PTR_ADV(regparse); |
4444 | 1807 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1808 // Emit the OR branches for each character in the [] |
4444 | 1809 emit_range = FALSE; |
1810 while (regparse < endp) | |
1811 { | |
25178
0797c8ce343d
patch 8.2.3125: variables are set but not used
Bram Moolenaar <Bram@vim.org>
parents:
25147
diff
changeset
|
1812 int oldstartc = startc; |
0797c8ce343d
patch 8.2.3125: variables are set but not used
Bram Moolenaar <Bram@vim.org>
parents:
25147
diff
changeset
|
1813 |
4444 | 1814 startc = -1; |
1815 got_coll_char = FALSE; | |
1816 if (*regparse == '[') | |
1817 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1818 // Check for [: :], [= =], [. .] |
4444 | 1819 equiclass = collclass = 0; |
1820 charclass = get_char_class(®parse); | |
1821 if (charclass == CLASS_NONE) | |
1822 { | |
1823 equiclass = get_equi_class(®parse); | |
1824 if (equiclass == 0) | |
1825 collclass = get_coll_element(®parse); | |
1826 } | |
1827 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1828 // Character class like [:alpha:] |
4444 | 1829 if (charclass != CLASS_NONE) |
1830 { | |
1831 switch (charclass) | |
1832 { | |
1833 case CLASS_ALNUM: | |
1834 EMIT(NFA_CLASS_ALNUM); | |
1835 break; | |
1836 case CLASS_ALPHA: | |
1837 EMIT(NFA_CLASS_ALPHA); | |
1838 break; | |
1839 case CLASS_BLANK: | |
1840 EMIT(NFA_CLASS_BLANK); | |
1841 break; | |
1842 case CLASS_CNTRL: | |
1843 EMIT(NFA_CLASS_CNTRL); | |
1844 break; | |
1845 case CLASS_DIGIT: | |
1846 EMIT(NFA_CLASS_DIGIT); | |
1847 break; | |
1848 case CLASS_GRAPH: | |
1849 EMIT(NFA_CLASS_GRAPH); | |
1850 break; | |
1851 case CLASS_LOWER: | |
23471
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
1852 wants_nfa = TRUE; |
4444 | 1853 EMIT(NFA_CLASS_LOWER); |
1854 break; | |
1855 case CLASS_PRINT: | |
1856 EMIT(NFA_CLASS_PRINT); | |
1857 break; | |
1858 case CLASS_PUNCT: | |
1859 EMIT(NFA_CLASS_PUNCT); | |
1860 break; | |
1861 case CLASS_SPACE: | |
1862 EMIT(NFA_CLASS_SPACE); | |
1863 break; | |
1864 case CLASS_UPPER: | |
23471
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
1865 wants_nfa = TRUE; |
4444 | 1866 EMIT(NFA_CLASS_UPPER); |
1867 break; | |
1868 case CLASS_XDIGIT: | |
1869 EMIT(NFA_CLASS_XDIGIT); | |
1870 break; | |
1871 case CLASS_TAB: | |
1872 EMIT(NFA_CLASS_TAB); | |
1873 break; | |
1874 case CLASS_RETURN: | |
1875 EMIT(NFA_CLASS_RETURN); | |
1876 break; | |
1877 case CLASS_BACKSPACE: | |
1878 EMIT(NFA_CLASS_BACKSPACE); | |
1879 break; | |
1880 case CLASS_ESCAPE: | |
1881 EMIT(NFA_CLASS_ESCAPE); | |
1882 break; | |
15709
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1883 case CLASS_IDENT: |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1884 EMIT(NFA_CLASS_IDENT); |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1885 break; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1886 case CLASS_KEYWORD: |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1887 EMIT(NFA_CLASS_KEYWORD); |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1888 break; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1889 case CLASS_FNAME: |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1890 EMIT(NFA_CLASS_FNAME); |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
1891 break; |
4444 | 1892 } |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1893 EMIT(NFA_CONCAT); |
4444 | 1894 continue; |
1895 } | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1896 // Try equivalence class [=a=] and the like |
4444 | 1897 if (equiclass != 0) |
1898 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1899 result = nfa_emit_equi_class(equiclass); |
4444 | 1900 if (result == FAIL) |
1901 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1902 // should never happen |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
1903 EMSG_RET_FAIL(_(e_error_building_nfa_with_equivalence_class)); |
4444 | 1904 } |
1905 continue; | |
1906 } | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1907 // Try collating class like [. .] |
4444 | 1908 if (collclass != 0) |
1909 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1910 startc = collclass; // allow [.a.]-x as a range |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1911 // Will emit the proper atom at the end of the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1912 // while loop. |
4444 | 1913 } |
1914 } | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1915 // Try a range like 'a-x' or '\t-z'. Also allows '-' as a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1916 // start character. |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1917 if (*regparse == '-' && oldstartc != -1) |
4444 | 1918 { |
1919 emit_range = TRUE; | |
1920 startc = oldstartc; | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1921 MB_PTR_ADV(regparse); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1922 continue; // reading the end of the range |
4444 | 1923 } |
1924 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1925 // Now handle simple and escaped characters. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1926 // Only "\]", "\^", "\]" and "\\" are special in Vi. Vim |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1927 // accepts "\t", "\e", etc., but only when the 'l' flag in |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1928 // 'cpoptions' is not included. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1929 // Posix doesn't recognize backslash at all. |
4444 | 1930 if (*regparse == '\\' |
4744
a62695305e03
updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents:
4742
diff
changeset
|
1931 && !reg_cpo_bsl |
4444 | 1932 && regparse + 1 <= endp |
1933 && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL | |
4744
a62695305e03
updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents:
4742
diff
changeset
|
1934 || (!reg_cpo_lit |
4444 | 1935 && vim_strchr(REGEXP_ABBR, regparse[1]) |
1936 != NULL) | |
1937 ) | |
1938 ) | |
1939 { | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1940 MB_PTR_ADV(regparse); |
4444 | 1941 |
4507
9dbbddb2ed10
updated for version 7.3.1001
Bram Moolenaar <bram@vim.org>
parents:
4503
diff
changeset
|
1942 if (*regparse == 'n') |
15876
0c49755f460e
patch 8.1.0945: internal error when using pattern with NL in the range
Bram Moolenaar <Bram@vim.org>
parents:
15824
diff
changeset
|
1943 startc = (reg_string || emit_range |
0c49755f460e
patch 8.1.0945: internal error when using pattern with NL in the range
Bram Moolenaar <Bram@vim.org>
parents:
15824
diff
changeset
|
1944 || regparse[1] == '-') ? NL : NFA_NEWL; |
16162
cd5c83115ec6
patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents:
15935
diff
changeset
|
1945 else if (*regparse == 'd' |
4444 | 1946 || *regparse == 'o' |
1947 || *regparse == 'x' | |
1948 || *regparse == 'u' | |
1949 || *regparse == 'U' | |
1950 ) | |
1951 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1952 // TODO(RE) This needs more testing |
4444 | 1953 startc = coll_get_char(); |
1954 got_coll_char = TRUE; | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
1955 MB_PTR_BACK(old_regparse, regparse); |
4444 | 1956 } |
1957 else | |
1958 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1959 // \r,\t,\e,\b |
4444 | 1960 startc = backslash_trans(*regparse); |
1961 } | |
1962 } | |
1963 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1964 // Normal printable char |
4444 | 1965 if (startc == -1) |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1966 startc = PTR2CHAR(regparse); |
4444 | 1967 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1968 // Previous char was '-', so this char is end of range. |
4444 | 1969 if (emit_range) |
1970 { | |
25178
0797c8ce343d
patch 8.2.3125: variables are set but not used
Bram Moolenaar <Bram@vim.org>
parents:
25147
diff
changeset
|
1971 int endc = startc; |
0797c8ce343d
patch 8.2.3125: variables are set but not used
Bram Moolenaar <Bram@vim.org>
parents:
25147
diff
changeset
|
1972 |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1973 startc = oldstartc; |
4444 | 1974 if (startc > endc) |
26958
d92e0d85923f
patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
1975 EMSG_RET_FAIL(_(e_reverse_range_in_character_class)); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1976 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1977 if (endc > startc + 2) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1978 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1979 // Emit a range instead of the sequence of |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1980 // individual characters. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1981 if (startc == 0) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1982 // \x00 is translated to \x0a, start at \x01. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1983 EMIT(1); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1984 else |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1985 --post_ptr; // remove NFA_CONCAT |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1986 EMIT(endc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1987 EMIT(NFA_RANGE); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1988 EMIT(NFA_CONCAT); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1989 } |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
1990 else if (has_mbyte && ((*mb_char2len)(startc) > 1 |
4444 | 1991 || (*mb_char2len)(endc) > 1)) |
1992 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1993 // Emit the characters in the range. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1994 // "startc" was already emitted, so skip it. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
1995 // |
4444 | 1996 for (c = startc + 1; c <= endc; c++) |
1997 { | |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1998 EMIT(c); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1999 EMIT(NFA_CONCAT); |
4444 | 2000 } |
2001 } | |
2002 else | |
2003 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2004 // Emit the range. "startc" was already emitted, so |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2005 // skip it. |
4444 | 2006 for (c = startc + 1; c <= endc; c++) |
27490
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
2007 { |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
2008 EMIT(c); |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
2009 EMIT(NFA_CONCAT); |
fb4c30606b4a
patch 8.2.4273: the EBCDIC support is outdated
Bram Moolenaar <Bram@vim.org>
parents:
27000
diff
changeset
|
2010 } |
4444 | 2011 } |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
2012 emit_range = FALSE; |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
2013 startc = -1; |
4444 | 2014 } |
2015 else | |
2016 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2017 // This char (startc) is not part of a range. Just |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2018 // emit it. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2019 // Normally, simply emit startc. But if we get char |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2020 // code=0 from a collating char, then replace it with |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2021 // 0x0a. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2022 // This is needed to completely mimic the behaviour of |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2023 // the backtracking engine. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2024 if (startc == NFA_NEWL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2025 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2026 // Line break can't be matched as part of the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2027 // collection, add an OR below. But not for negated |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2028 // range. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2029 if (!negated) |
5296 | 2030 extra = NFA_ADD_NL; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2031 } |
4444 | 2032 else |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2033 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2034 if (got_coll_char == TRUE && startc == 0) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2035 EMIT(0x0a); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2036 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2037 EMIT(startc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2038 EMIT(NFA_CONCAT); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2039 } |
4444 | 2040 } |
2041 | |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
2042 MB_PTR_ADV(regparse); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2043 } // while (p < endp) |
4444 | 2044 |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
2045 MB_PTR_BACK(old_regparse, regparse); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2046 if (*regparse == '-') // if last, '-' is just a char |
4444 | 2047 { |
2048 EMIT('-'); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2049 EMIT(NFA_CONCAT); |
4444 | 2050 } |
2051 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2052 // skip the trailing ] |
4444 | 2053 regparse = endp; |
11127
506f5d8b7d8b
patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
10551
diff
changeset
|
2054 MB_PTR_ADV(regparse); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2055 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2056 // Mark end of the collection. |
4444 | 2057 if (negated == TRUE) |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2058 EMIT(NFA_END_NEG_COLL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2059 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2060 EMIT(NFA_END_COLL); |
4615
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
2061 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2062 // \_[] also matches \n but it's not negated |
5296 | 2063 if (extra == NFA_ADD_NL) |
4615
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
2064 { |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
2065 EMIT(reg_string ? NL : NFA_NEWL); |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
2066 EMIT(NFA_OR); |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
2067 } |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
2068 |
4444 | 2069 return OK; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2070 } // if exists closing ] |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
2071 |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
2072 if (reg_strict) |
26958
d92e0d85923f
patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
2073 EMSG_RET_FAIL(_(e_missing_rsb_after_str_lsb)); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2074 // FALLTHROUGH |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
2075 |
4444 | 2076 default: |
2077 { | |
2078 int plen; | |
2079 | |
2080 nfa_do_multibyte: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2081 // plen is length of current char with composing chars |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
2082 if (enc_utf8 && ((*mb_char2len)(c) |
11269
121d29004998
patch 8.0.0520: using a function pointer while the function is known
Christian Brabandt <cb@256bit.org>
parents:
11267
diff
changeset
|
2083 != (plen = utfc_ptr2len(old_regparse)) |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
2084 || utf_iscomposing(c))) |
4444 | 2085 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
2086 int i = 0; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
2087 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2088 // A base character plus composing characters, or just one |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2089 // or more composing characters. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2090 // This requires creating a separate atom as if enclosing |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2091 // the characters in (), where NFA_COMPOSING is the ( and |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2092 // NFA_END_COMPOSING is the ). Note that right now we are |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2093 // building the postfix form, not the NFA itself; |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2094 // a composing char could be: a, b, c, NFA_COMPOSING |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2095 // where 'b' and 'c' are chars with codes > 256. |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2096 for (;;) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2097 { |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2098 EMIT(c); |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2099 if (i > 0) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2100 EMIT(NFA_CONCAT); |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
2101 if ((i += utf_char2len(c)) >= plen) |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2102 break; |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2103 c = utf_ptr2char(old_regparse + i); |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2104 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
2105 EMIT(NFA_COMPOSING); |
4444 | 2106 regparse = old_regparse + plen; |
2107 } | |
2108 else | |
2109 { | |
2110 c = no_Magic(c); | |
2111 EMIT(c); | |
2112 } | |
2113 return OK; | |
2114 } | |
2115 } | |
2116 | |
2117 return OK; | |
2118 } | |
2119 | |
2120 /* | |
2121 * Parse something followed by possible [*+=]. | |
2122 * | |
2123 * A piece is an atom, possibly followed by a multi, an indication of how many | |
2124 * times the atom can be matched. Example: "a*" matches any sequence of "a" | |
2125 * characters: "", "a", "aa", etc. | |
2126 * | |
2127 * piece ::= atom | |
2128 * or atom multi | |
2129 */ | |
2130 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2131 nfa_regpiece(void) |
4444 | 2132 { |
2133 int i; | |
2134 int op; | |
2135 int ret; | |
2136 long minval, maxval; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2137 int greedy = TRUE; // Braces are prefixed with '-' ? |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2138 parse_state_T old_state; |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2139 parse_state_T new_state; |
12752
09c856605191
patch 8.0.1254: undefined left shift in gethexchrs()
Christian Brabandt <cb@256bit.org>
parents:
12674
diff
changeset
|
2140 long c2; |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2141 int old_post_pos; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2142 int my_post_start; |
4444 | 2143 int quest; |
2144 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2145 // Save the current parse state, so that we can use it if <atom>{m,n} is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2146 // next. |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2147 save_parse_state(&old_state); |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2148 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2149 // store current pos in the postfix form, for \{m,n} involving 0s |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2150 my_post_start = (int)(post_ptr - post_start); |
4444 | 2151 |
2152 ret = nfa_regatom(); | |
2153 if (ret == FAIL) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2154 return FAIL; // cascaded error |
4444 | 2155 |
2156 op = peekchr(); | |
2157 if (re_multi_type(op) == NOT_MULTI) | |
2158 return OK; | |
2159 | |
2160 skipchr(); | |
2161 switch (op) | |
2162 { | |
2163 case Magic('*'): | |
2164 EMIT(NFA_STAR); | |
2165 break; | |
2166 | |
2167 case Magic('+'): | |
2168 /* | |
2169 * Trick: Normally, (a*)\+ would match the whole input "aaa". The | |
2170 * first and only submatch would be "aaa". But the backtracking | |
2171 * engine interprets the plus as "try matching one more time", and | |
2172 * a* matches a second time at the end of the input, the empty | |
2173 * string. | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2174 * The submatch will be the empty string. |
4444 | 2175 * |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2176 * In order to be consistent with the old engine, we replace |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2177 * <atom>+ with <atom><atom>* |
4444 | 2178 */ |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2179 restore_parse_state(&old_state); |
4444 | 2180 curchr = -1; |
2181 if (nfa_regatom() == FAIL) | |
2182 return FAIL; | |
2183 EMIT(NFA_STAR); | |
2184 EMIT(NFA_CONCAT); | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2185 skipchr(); // skip the \+ |
4444 | 2186 break; |
2187 | |
2188 case Magic('@'): | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2189 c2 = getdecchrs(); |
4444 | 2190 op = no_Magic(getchr()); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2191 i = 0; |
4444 | 2192 switch(op) |
2193 { | |
2194 case '=': | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2195 // \@= |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2196 i = NFA_PREV_ATOM_NO_WIDTH; |
4444 | 2197 break; |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
2198 case '!': |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2199 // \@! |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2200 i = NFA_PREV_ATOM_NO_WIDTH_NEG; |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
2201 break; |
4444 | 2202 case '<': |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2203 op = no_Magic(getchr()); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2204 if (op == '=') |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2205 // \@<= |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2206 i = NFA_PREV_ATOM_JUST_BEFORE; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2207 else if (op == '!') |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2208 // \@<! |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2209 i = NFA_PREV_ATOM_JUST_BEFORE_NEG; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2210 break; |
4444 | 2211 case '>': |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2212 // \@> |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2213 i = NFA_PREV_ATOM_LIKE_PATTERN; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2214 break; |
4444 | 2215 } |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2216 if (i == 0) |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2217 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
2218 semsg(_(e_nfa_regexp_unknown_operator_at_chr), op); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2219 return FAIL; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2220 } |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2221 EMIT(i); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2222 if (i == NFA_PREV_ATOM_JUST_BEFORE |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2223 || i == NFA_PREV_ATOM_JUST_BEFORE_NEG) |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2224 EMIT(c2); |
4444 | 2225 break; |
2226 | |
2227 case Magic('?'): | |
2228 case Magic('='): | |
2229 EMIT(NFA_QUEST); | |
2230 break; | |
2231 | |
2232 case Magic('{'): | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2233 // a{2,5} will expand to 'aaa?a?a?' |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2234 // a{-1,3} will expand to 'aa??a??', where ?? is the nongreedy |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2235 // version of '?' |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2236 // \v(ab){2,3} will expand to '(ab)(ab)(ab)?', where all the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2237 // parenthesis have the same id |
4444 | 2238 |
2239 greedy = TRUE; | |
2240 c2 = peekchr(); | |
2241 if (c2 == '-' || c2 == Magic('-')) | |
2242 { | |
2243 skipchr(); | |
2244 greedy = FALSE; | |
2245 } | |
2246 if (!read_limits(&minval, &maxval)) | |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
2247 EMSG_RET_FAIL(_(e_nfa_regexp_error_reading_repetition_limits)); |
4762
47906f888725
updated for version 7.3.1128
Bram Moolenaar <bram@vim.org>
parents:
4760
diff
changeset
|
2248 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2249 // <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2250 // <atom>* |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2251 if (minval == 0 && maxval == MAX_LIMIT) |
4444 | 2252 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2253 if (greedy) // { { (match the braces) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2254 // \{}, \{0,} |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2255 EMIT(NFA_STAR); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2256 else // { { (match the braces) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2257 // \{-}, \{-0,} |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2258 EMIT(NFA_STAR_NONGREEDY); |
4444 | 2259 break; |
2260 } | |
2261 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2262 // Special case: x{0} or x{-0} |
4444 | 2263 if (maxval == 0) |
2264 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2265 // Ignore result of previous call to nfa_regatom() |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2266 post_ptr = post_start + my_post_start; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2267 // NFA_EMPTY is 0-length and works everywhere |
5370 | 2268 EMIT(NFA_EMPTY); |
4444 | 2269 return OK; |
2270 } | |
2271 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2272 // The engine is very inefficient (uses too many states) when the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2273 // maximum is much larger than the minimum and when the maximum is |
23471
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2274 // large. However, when maxval is MAX_LIMIT, it is okay, as this |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2275 // will emit NFA_STAR. |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2276 // Bail out if we can use the other engine, but only, when the |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2277 // pattern does not need the NFA engine like (e.g. [[:upper:]]\{2,\} |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
2278 // does not work with characters > 8 bit with the BT engine) |
6594 | 2279 if ((nfa_re_flags & RE_AUTO) |
23471
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2280 && (maxval > 500 || maxval > minval + 200) |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2281 && (maxval != MAX_LIMIT && minval < 200) |
a7cdfc8e4b6e
patch 8.2.2278: falling back to old regexp engine can some patterns
Bram Moolenaar <Bram@vim.org>
parents:
23270
diff
changeset
|
2282 && !wants_nfa) |
6533 | 2283 return FAIL; |
2284 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2285 // Ignore previous call to nfa_regatom() |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2286 post_ptr = post_start + my_post_start; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2287 // Save parse state after the repeated atom and the \{} |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2288 save_parse_state(&new_state); |
4444 | 2289 |
2290 quest = (greedy == TRUE? NFA_QUEST : NFA_QUEST_NONGREEDY); | |
2291 for (i = 0; i < maxval; i++) | |
2292 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2293 // Goto beginning of the repeated atom |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2294 restore_parse_state(&old_state); |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2295 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2296 if (nfa_regatom() == FAIL) |
2297 return FAIL; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2298 // after "minval" times, atoms are optional |
4444 | 2299 if (i + 1 > minval) |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2300 { |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2301 if (maxval == MAX_LIMIT) |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2302 { |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2303 if (greedy) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2304 EMIT(NFA_STAR); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2305 else |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2306 EMIT(NFA_STAR_NONGREEDY); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2307 } |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2308 else |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2309 EMIT(quest); |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2310 } |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2311 if (old_post_pos != my_post_start) |
4444 | 2312 EMIT(NFA_CONCAT); |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2313 if (i + 1 > minval && maxval == MAX_LIMIT) |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2314 break; |
4444 | 2315 } |
2316 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2317 // Go to just after the repeated atom and the \{} |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2318 restore_parse_state(&new_state); |
4444 | 2319 curchr = -1; |
2320 | |
2321 break; | |
2322 | |
2323 | |
2324 default: | |
2325 break; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2326 } // end switch |
4444 | 2327 |
2328 if (re_multi_type(peekchr()) != NOT_MULTI) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2329 // Can't have a multi follow a multi. |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
2330 EMSG_RET_FAIL(_(e_nfa_regexp_cant_have_multi_follow_multi)); |
4444 | 2331 |
2332 return OK; | |
2333 } | |
2334 | |
2335 /* | |
2336 * Parse one or more pieces, concatenated. It matches a match for the | |
2337 * first piece, followed by a match for the second piece, etc. Example: | |
2338 * "f[0-9]b", first matches "f", then a digit and then "b". | |
2339 * | |
2340 * concat ::= piece | |
2341 * or piece piece | |
2342 * or piece piece piece | |
2343 * etc. | |
2344 */ | |
2345 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2346 nfa_regconcat(void) |
4444 | 2347 { |
2348 int cont = TRUE; | |
2349 int first = TRUE; | |
2350 | |
2351 while (cont) | |
2352 { | |
2353 switch (peekchr()) | |
2354 { | |
2355 case NUL: | |
2356 case Magic('|'): | |
2357 case Magic('&'): | |
2358 case Magic(')'): | |
2359 cont = FALSE; | |
2360 break; | |
2361 | |
2362 case Magic('Z'): | |
2363 regflags |= RF_ICOMBINE; | |
2364 skipchr_keepstart(); | |
2365 break; | |
2366 case Magic('c'): | |
2367 regflags |= RF_ICASE; | |
2368 skipchr_keepstart(); | |
2369 break; | |
2370 case Magic('C'): | |
2371 regflags |= RF_NOICASE; | |
2372 skipchr_keepstart(); | |
2373 break; | |
2374 case Magic('v'): | |
2375 reg_magic = MAGIC_ALL; | |
2376 skipchr_keepstart(); | |
2377 curchr = -1; | |
2378 break; | |
2379 case Magic('m'): | |
2380 reg_magic = MAGIC_ON; | |
2381 skipchr_keepstart(); | |
2382 curchr = -1; | |
2383 break; | |
2384 case Magic('M'): | |
2385 reg_magic = MAGIC_OFF; | |
2386 skipchr_keepstart(); | |
2387 curchr = -1; | |
2388 break; | |
2389 case Magic('V'): | |
2390 reg_magic = MAGIC_NONE; | |
2391 skipchr_keepstart(); | |
2392 curchr = -1; | |
2393 break; | |
2394 | |
2395 default: | |
2396 if (nfa_regpiece() == FAIL) | |
2397 return FAIL; | |
2398 if (first == FALSE) | |
2399 EMIT(NFA_CONCAT); | |
2400 else | |
2401 first = FALSE; | |
2402 break; | |
2403 } | |
2404 } | |
2405 | |
2406 return OK; | |
2407 } | |
2408 | |
2409 /* | |
2410 * Parse a branch, one or more concats, separated by "\&". It matches the | |
2411 * last concat, but only if all the preceding concats also match at the same | |
2412 * position. Examples: | |
2413 * "foobeep\&..." matches "foo" in "foobeep". | |
2414 * ".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob" | |
2415 * | |
2416 * branch ::= concat | |
2417 * or concat \& concat | |
2418 * or concat \& concat \& concat | |
2419 * etc. | |
2420 */ | |
2421 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2422 nfa_regbranch(void) |
4444 | 2423 { |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2424 int old_post_pos; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2425 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2426 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2427 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2428 // First branch, possibly the only one |
4444 | 2429 if (nfa_regconcat() == FAIL) |
2430 return FAIL; | |
2431 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2432 // Try next concats |
13043
307f2622826f
patch 8.0.1397: pattern with & following nothing gives an error
Christian Brabandt <cb@256bit.org>
parents:
12752
diff
changeset
|
2433 while (peekchr() == Magic('&')) |
4444 | 2434 { |
2435 skipchr(); | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2436 // if concat is empty do emit a node |
13043
307f2622826f
patch 8.0.1397: pattern with & following nothing gives an error
Christian Brabandt <cb@256bit.org>
parents:
12752
diff
changeset
|
2437 if (old_post_pos == (int)(post_ptr - post_start)) |
307f2622826f
patch 8.0.1397: pattern with & following nothing gives an error
Christian Brabandt <cb@256bit.org>
parents:
12752
diff
changeset
|
2438 EMIT(NFA_EMPTY); |
4444 | 2439 EMIT(NFA_NOPEN); |
2440 EMIT(NFA_PREV_ATOM_NO_WIDTH); | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2441 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2442 if (nfa_regconcat() == FAIL) |
2443 return FAIL; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2444 // if concat is empty do emit a node |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2445 if (old_post_pos == (int)(post_ptr - post_start)) |
5370 | 2446 EMIT(NFA_EMPTY); |
4444 | 2447 EMIT(NFA_CONCAT); |
2448 } | |
2449 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2450 // if a branch is empty, emit one node for it |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2451 if (old_post_pos == (int)(post_ptr - post_start)) |
5370 | 2452 EMIT(NFA_EMPTY); |
4444 | 2453 |
2454 return OK; | |
2455 } | |
2456 | |
2457 /* | |
2458 * Parse a pattern, one or more branches, separated by "\|". It matches | |
2459 * anything that matches one of the branches. Example: "foo\|beep" matches | |
2460 * "foo" and matches "beep". If more than one branch matches, the first one | |
2461 * is used. | |
2462 * | |
2463 * pattern ::= branch | |
2464 * or branch \| branch | |
2465 * or branch \| branch \| branch | |
2466 * etc. | |
2467 */ | |
2468 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2469 nfa_reg( |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2470 int paren) // REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN |
4444 | 2471 { |
2472 int parno = 0; | |
2473 | |
2474 if (paren == REG_PAREN) | |
2475 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2476 if (regnpar >= NSUBEXP) // Too many `(' |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
2477 EMSG_RET_FAIL(_(e_nfa_regexp_too_many_parens)); |
4444 | 2478 parno = regnpar++; |
2479 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2480 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2481 else if (paren == REG_ZPAREN) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2482 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2483 // Make a ZOPEN node. |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2484 if (regnzpar >= NSUBEXP) |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
2485 EMSG_RET_FAIL(_(e_nfa_regexp_too_many_z)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2486 parno = regnzpar++; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2487 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2488 #endif |
4444 | 2489 |
2490 if (nfa_regbranch() == FAIL) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2491 return FAIL; // cascaded error |
4444 | 2492 |
2493 while (peekchr() == Magic('|')) | |
2494 { | |
2495 skipchr(); | |
2496 if (nfa_regbranch() == FAIL) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2497 return FAIL; // cascaded error |
4444 | 2498 EMIT(NFA_OR); |
2499 } | |
2500 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2501 // Check for proper termination. |
4444 | 2502 if (paren != REG_NOPAREN && getchr() != Magic(')')) |
2503 { | |
2504 if (paren == REG_NPAREN) | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2505 EMSG2_RET_FAIL(_(e_unmatched_str_percent_open), |
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2506 reg_magic == MAGIC_ALL); |
4444 | 2507 else |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2508 EMSG2_RET_FAIL(_(e_unmatched_str_open), reg_magic == MAGIC_ALL); |
4444 | 2509 } |
2510 else if (paren == REG_NOPAREN && peekchr() != NUL) | |
2511 { | |
2512 if (peekchr() == Magic(')')) | |
25320
1e6da8364a02
patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
2513 EMSG2_RET_FAIL(_(e_unmatched_str_close), reg_magic == MAGIC_ALL); |
4444 | 2514 else |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
2515 EMSG_RET_FAIL(_(e_nfa_regexp_proper_termination_error)); |
4444 | 2516 } |
2517 /* | |
2518 * Here we set the flag allowing back references to this set of | |
2519 * parentheses. | |
2520 */ | |
2521 if (paren == REG_PAREN) | |
2522 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2523 had_endbrace[parno] = TRUE; // have seen the close paren |
4444 | 2524 EMIT(NFA_MOPEN + parno); |
2525 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2526 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2527 else if (paren == REG_ZPAREN) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2528 EMIT(NFA_ZOPEN + parno); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2529 #endif |
4444 | 2530 |
2531 return OK; | |
2532 } | |
2533 | |
2534 #ifdef DEBUG | |
2535 static char_u code[50]; | |
2536 | |
2537 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2538 nfa_set_code(int c) |
4444 | 2539 { |
2540 int addnl = FALSE; | |
2541 | |
2542 if (c >= NFA_FIRST_NL && c <= NFA_LAST_NL) | |
2543 { | |
2544 addnl = TRUE; | |
5296 | 2545 c -= NFA_ADD_NL; |
4444 | 2546 } |
2547 | |
2548 STRCPY(code, ""); | |
2549 switch (c) | |
2550 { | |
2551 case NFA_MATCH: STRCPY(code, "NFA_MATCH "); break; | |
2552 case NFA_SPLIT: STRCPY(code, "NFA_SPLIT "); break; | |
2553 case NFA_CONCAT: STRCPY(code, "NFA_CONCAT "); break; | |
2554 case NFA_NEWL: STRCPY(code, "NFA_NEWL "); break; | |
2555 case NFA_ZSTART: STRCPY(code, "NFA_ZSTART"); break; | |
2556 case NFA_ZEND: STRCPY(code, "NFA_ZEND"); break; | |
2557 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2558 case NFA_BACKREF1: STRCPY(code, "NFA_BACKREF1"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2559 case NFA_BACKREF2: STRCPY(code, "NFA_BACKREF2"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2560 case NFA_BACKREF3: STRCPY(code, "NFA_BACKREF3"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2561 case NFA_BACKREF4: STRCPY(code, "NFA_BACKREF4"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2562 case NFA_BACKREF5: STRCPY(code, "NFA_BACKREF5"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2563 case NFA_BACKREF6: STRCPY(code, "NFA_BACKREF6"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2564 case NFA_BACKREF7: STRCPY(code, "NFA_BACKREF7"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2565 case NFA_BACKREF8: STRCPY(code, "NFA_BACKREF8"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2566 case NFA_BACKREF9: STRCPY(code, "NFA_BACKREF9"); break; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2567 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2568 case NFA_ZREF1: STRCPY(code, "NFA_ZREF1"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2569 case NFA_ZREF2: STRCPY(code, "NFA_ZREF2"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2570 case NFA_ZREF3: STRCPY(code, "NFA_ZREF3"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2571 case NFA_ZREF4: STRCPY(code, "NFA_ZREF4"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2572 case NFA_ZREF5: STRCPY(code, "NFA_ZREF5"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2573 case NFA_ZREF6: STRCPY(code, "NFA_ZREF6"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2574 case NFA_ZREF7: STRCPY(code, "NFA_ZREF7"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2575 case NFA_ZREF8: STRCPY(code, "NFA_ZREF8"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2576 case NFA_ZREF9: STRCPY(code, "NFA_ZREF9"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2577 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2578 case NFA_SKIP: STRCPY(code, "NFA_SKIP"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2579 |
4444 | 2580 case NFA_PREV_ATOM_NO_WIDTH: |
2581 STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH"); break; | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
2582 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
2583 STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH_NEG"); break; |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2584 case NFA_PREV_ATOM_JUST_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2585 STRCPY(code, "NFA_PREV_ATOM_JUST_BEFORE"); break; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2586 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2587 STRCPY(code, "NFA_PREV_ATOM_JUST_BEFORE_NEG"); break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2588 case NFA_PREV_ATOM_LIKE_PATTERN: |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2589 STRCPY(code, "NFA_PREV_ATOM_LIKE_PATTERN"); break; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2590 |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
2591 case NFA_NOPEN: STRCPY(code, "NFA_NOPEN"); break; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
2592 case NFA_NCLOSE: STRCPY(code, "NFA_NCLOSE"); break; |
4444 | 2593 case NFA_START_INVISIBLE: STRCPY(code, "NFA_START_INVISIBLE"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2594 case NFA_START_INVISIBLE_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2595 STRCPY(code, "NFA_START_INVISIBLE_FIRST"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2596 case NFA_START_INVISIBLE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2597 STRCPY(code, "NFA_START_INVISIBLE_NEG"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2598 case NFA_START_INVISIBLE_NEG_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2599 STRCPY(code, "NFA_START_INVISIBLE_NEG_FIRST"); break; |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2600 case NFA_START_INVISIBLE_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2601 STRCPY(code, "NFA_START_INVISIBLE_BEFORE"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2602 case NFA_START_INVISIBLE_BEFORE_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2603 STRCPY(code, "NFA_START_INVISIBLE_BEFORE_FIRST"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2604 case NFA_START_INVISIBLE_BEFORE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2605 STRCPY(code, "NFA_START_INVISIBLE_BEFORE_NEG"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2606 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2607 STRCPY(code, "NFA_START_INVISIBLE_BEFORE_NEG_FIRST"); break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2608 case NFA_START_PATTERN: STRCPY(code, "NFA_START_PATTERN"); break; |
4444 | 2609 case NFA_END_INVISIBLE: STRCPY(code, "NFA_END_INVISIBLE"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2610 case NFA_END_INVISIBLE_NEG: STRCPY(code, "NFA_END_INVISIBLE_NEG"); break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2611 case NFA_END_PATTERN: STRCPY(code, "NFA_END_PATTERN"); break; |
4444 | 2612 |
2613 case NFA_COMPOSING: STRCPY(code, "NFA_COMPOSING"); break; | |
2614 case NFA_END_COMPOSING: STRCPY(code, "NFA_END_COMPOSING"); break; | |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
2615 case NFA_OPT_CHARS: STRCPY(code, "NFA_OPT_CHARS"); break; |
4444 | 2616 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2617 case NFA_MOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2618 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2619 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2620 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2621 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2622 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2623 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2624 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2625 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2626 case NFA_MOPEN9: |
4444 | 2627 STRCPY(code, "NFA_MOPEN(x)"); |
2628 code[10] = c - NFA_MOPEN + '0'; | |
2629 break; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2630 case NFA_MCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2631 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2632 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2633 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2634 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2635 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2636 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2637 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2638 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2639 case NFA_MCLOSE9: |
4444 | 2640 STRCPY(code, "NFA_MCLOSE(x)"); |
2641 code[11] = c - NFA_MCLOSE + '0'; | |
2642 break; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2643 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2644 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2645 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2646 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2647 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2648 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2649 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2650 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2651 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2652 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2653 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2654 STRCPY(code, "NFA_ZOPEN(x)"); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2655 code[10] = c - NFA_ZOPEN + '0'; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2656 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2657 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2658 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2659 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2660 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2661 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2662 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2663 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2664 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2665 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2666 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2667 STRCPY(code, "NFA_ZCLOSE(x)"); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2668 code[11] = c - NFA_ZCLOSE + '0'; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2669 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2670 #endif |
4444 | 2671 case NFA_EOL: STRCPY(code, "NFA_EOL "); break; |
2672 case NFA_BOL: STRCPY(code, "NFA_BOL "); break; | |
2673 case NFA_EOW: STRCPY(code, "NFA_EOW "); break; | |
2674 case NFA_BOW: STRCPY(code, "NFA_BOW "); break; | |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
2675 case NFA_EOF: STRCPY(code, "NFA_EOF "); break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
2676 case NFA_BOF: STRCPY(code, "NFA_BOF "); break; |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2677 case NFA_LNUM: STRCPY(code, "NFA_LNUM "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2678 case NFA_LNUM_GT: STRCPY(code, "NFA_LNUM_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2679 case NFA_LNUM_LT: STRCPY(code, "NFA_LNUM_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2680 case NFA_COL: STRCPY(code, "NFA_COL "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2681 case NFA_COL_GT: STRCPY(code, "NFA_COL_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2682 case NFA_COL_LT: STRCPY(code, "NFA_COL_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2683 case NFA_VCOL: STRCPY(code, "NFA_VCOL "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2684 case NFA_VCOL_GT: STRCPY(code, "NFA_VCOL_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2685 case NFA_VCOL_LT: STRCPY(code, "NFA_VCOL_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2686 case NFA_MARK: STRCPY(code, "NFA_MARK "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2687 case NFA_MARK_GT: STRCPY(code, "NFA_MARK_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2688 case NFA_MARK_LT: STRCPY(code, "NFA_MARK_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2689 case NFA_CURSOR: STRCPY(code, "NFA_CURSOR "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2690 case NFA_VISUAL: STRCPY(code, "NFA_VISUAL "); break; |
5901 | 2691 case NFA_ANY_COMPOSING: STRCPY(code, "NFA_ANY_COMPOSING "); break; |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2692 |
4444 | 2693 case NFA_STAR: STRCPY(code, "NFA_STAR "); break; |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2694 case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2695 case NFA_QUEST: STRCPY(code, "NFA_QUEST"); break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2696 case NFA_QUEST_NONGREEDY: STRCPY(code, "NFA_QUEST_NON_GREEDY"); break; |
5370 | 2697 case NFA_EMPTY: STRCPY(code, "NFA_EMPTY"); break; |
4444 | 2698 case NFA_OR: STRCPY(code, "NFA_OR"); break; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2699 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2700 case NFA_START_COLL: STRCPY(code, "NFA_START_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2701 case NFA_END_COLL: STRCPY(code, "NFA_END_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2702 case NFA_START_NEG_COLL: STRCPY(code, "NFA_START_NEG_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2703 case NFA_END_NEG_COLL: STRCPY(code, "NFA_END_NEG_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2704 case NFA_RANGE: STRCPY(code, "NFA_RANGE"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2705 case NFA_RANGE_MIN: STRCPY(code, "NFA_RANGE_MIN"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2706 case NFA_RANGE_MAX: STRCPY(code, "NFA_RANGE_MAX"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2707 |
4444 | 2708 case NFA_CLASS_ALNUM: STRCPY(code, "NFA_CLASS_ALNUM"); break; |
2709 case NFA_CLASS_ALPHA: STRCPY(code, "NFA_CLASS_ALPHA"); break; | |
2710 case NFA_CLASS_BLANK: STRCPY(code, "NFA_CLASS_BLANK"); break; | |
2711 case NFA_CLASS_CNTRL: STRCPY(code, "NFA_CLASS_CNTRL"); break; | |
2712 case NFA_CLASS_DIGIT: STRCPY(code, "NFA_CLASS_DIGIT"); break; | |
2713 case NFA_CLASS_GRAPH: STRCPY(code, "NFA_CLASS_GRAPH"); break; | |
2714 case NFA_CLASS_LOWER: STRCPY(code, "NFA_CLASS_LOWER"); break; | |
2715 case NFA_CLASS_PRINT: STRCPY(code, "NFA_CLASS_PRINT"); break; | |
2716 case NFA_CLASS_PUNCT: STRCPY(code, "NFA_CLASS_PUNCT"); break; | |
2717 case NFA_CLASS_SPACE: STRCPY(code, "NFA_CLASS_SPACE"); break; | |
2718 case NFA_CLASS_UPPER: STRCPY(code, "NFA_CLASS_UPPER"); break; | |
2719 case NFA_CLASS_XDIGIT: STRCPY(code, "NFA_CLASS_XDIGIT"); break; | |
2720 case NFA_CLASS_TAB: STRCPY(code, "NFA_CLASS_TAB"); break; | |
2721 case NFA_CLASS_RETURN: STRCPY(code, "NFA_CLASS_RETURN"); break; | |
2722 case NFA_CLASS_BACKSPACE: STRCPY(code, "NFA_CLASS_BACKSPACE"); break; | |
2723 case NFA_CLASS_ESCAPE: STRCPY(code, "NFA_CLASS_ESCAPE"); break; | |
15709
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
2724 case NFA_CLASS_IDENT: STRCPY(code, "NFA_CLASS_IDENT"); break; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
2725 case NFA_CLASS_KEYWORD: STRCPY(code, "NFA_CLASS_KEYWORD"); break; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
2726 case NFA_CLASS_FNAME: STRCPY(code, "NFA_CLASS_FNAME"); break; |
4444 | 2727 |
2728 case NFA_ANY: STRCPY(code, "NFA_ANY"); break; | |
2729 case NFA_IDENT: STRCPY(code, "NFA_IDENT"); break; | |
2730 case NFA_SIDENT:STRCPY(code, "NFA_SIDENT"); break; | |
2731 case NFA_KWORD: STRCPY(code, "NFA_KWORD"); break; | |
2732 case NFA_SKWORD:STRCPY(code, "NFA_SKWORD"); break; | |
2733 case NFA_FNAME: STRCPY(code, "NFA_FNAME"); break; | |
2734 case NFA_SFNAME:STRCPY(code, "NFA_SFNAME"); break; | |
2735 case NFA_PRINT: STRCPY(code, "NFA_PRINT"); break; | |
2736 case NFA_SPRINT:STRCPY(code, "NFA_SPRINT"); break; | |
2737 case NFA_WHITE: STRCPY(code, "NFA_WHITE"); break; | |
2738 case NFA_NWHITE:STRCPY(code, "NFA_NWHITE"); break; | |
2739 case NFA_DIGIT: STRCPY(code, "NFA_DIGIT"); break; | |
2740 case NFA_NDIGIT:STRCPY(code, "NFA_NDIGIT"); break; | |
2741 case NFA_HEX: STRCPY(code, "NFA_HEX"); break; | |
2742 case NFA_NHEX: STRCPY(code, "NFA_NHEX"); break; | |
2743 case NFA_OCTAL: STRCPY(code, "NFA_OCTAL"); break; | |
2744 case NFA_NOCTAL:STRCPY(code, "NFA_NOCTAL"); break; | |
2745 case NFA_WORD: STRCPY(code, "NFA_WORD"); break; | |
2746 case NFA_NWORD: STRCPY(code, "NFA_NWORD"); break; | |
2747 case NFA_HEAD: STRCPY(code, "NFA_HEAD"); break; | |
2748 case NFA_NHEAD: STRCPY(code, "NFA_NHEAD"); break; | |
2749 case NFA_ALPHA: STRCPY(code, "NFA_ALPHA"); break; | |
2750 case NFA_NALPHA:STRCPY(code, "NFA_NALPHA"); break; | |
2751 case NFA_LOWER: STRCPY(code, "NFA_LOWER"); break; | |
2752 case NFA_NLOWER:STRCPY(code, "NFA_NLOWER"); break; | |
2753 case NFA_UPPER: STRCPY(code, "NFA_UPPER"); break; | |
2754 case NFA_NUPPER:STRCPY(code, "NFA_NUPPER"); break; | |
5296 | 2755 case NFA_LOWER_IC: STRCPY(code, "NFA_LOWER_IC"); break; |
2756 case NFA_NLOWER_IC: STRCPY(code, "NFA_NLOWER_IC"); break; | |
2757 case NFA_UPPER_IC: STRCPY(code, "NFA_UPPER_IC"); break; | |
2758 case NFA_NUPPER_IC: STRCPY(code, "NFA_NUPPER_IC"); break; | |
4444 | 2759 |
2760 default: | |
2761 STRCPY(code, "CHAR(x)"); | |
2762 code[5] = c; | |
2763 } | |
2764 | |
2765 if (addnl == TRUE) | |
2766 STRCAT(code, " + NEWLINE "); | |
2767 | |
2768 } | |
2769 | |
2770 #ifdef ENABLE_LOG | |
2771 static FILE *log_fd; | |
14145
1cf832945469
patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents:
14121
diff
changeset
|
2772 static char_u e_log_open_failed[] = N_("Could not open temporary log file for writing, displaying on stderr... "); |
4444 | 2773 |
2774 /* | |
2775 * Print the postfix notation of the current regexp. | |
2776 */ | |
2777 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2778 nfa_postfix_dump(char_u *expr, int retval) |
4444 | 2779 { |
2780 int *p; | |
2781 FILE *f; | |
2782 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2783 f = fopen(NFA_REGEXP_DUMP_LOG, "a"); |
4444 | 2784 if (f != NULL) |
2785 { | |
2786 fprintf(f, "\n-------------------------\n"); | |
2787 if (retval == FAIL) | |
14145
1cf832945469
patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents:
14121
diff
changeset
|
2788 fprintf(f, ">>> NFA engine failed... \n"); |
4444 | 2789 else if (retval == OK) |
2790 fprintf(f, ">>> NFA engine succeeded !\n"); | |
2791 fprintf(f, "Regexp: \"%s\"\nPostfix notation (char): \"", expr); | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2792 for (p = post_start; *p && p < post_ptr; p++) |
4444 | 2793 { |
2794 nfa_set_code(*p); | |
2795 fprintf(f, "%s, ", code); | |
2796 } | |
2797 fprintf(f, "\"\nPostfix notation (int): "); | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2798 for (p = post_start; *p && p < post_ptr; p++) |
4444 | 2799 fprintf(f, "%d ", *p); |
2800 fprintf(f, "\n\n"); | |
2801 fclose(f); | |
2802 } | |
2803 } | |
2804 | |
2805 /* | |
2806 * Print the NFA starting with a root node "state". | |
2807 */ | |
2808 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2809 nfa_print_state(FILE *debugf, nfa_state_T *state) |
4444 | 2810 { |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2811 garray_T indent; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2812 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2813 ga_init2(&indent, 1, 64); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2814 ga_append(&indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2815 nfa_print_state2(debugf, state, &indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2816 ga_clear(&indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2817 } |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2818 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2819 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2820 nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent) |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2821 { |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2822 char_u *p; |
4444 | 2823 |
2824 if (state == NULL) | |
2825 return; | |
2826 | |
2827 fprintf(debugf, "(%2d)", abs(state->id)); | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2828 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2829 // Output indent |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2830 p = (char_u *)indent->ga_data; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2831 if (indent->ga_len >= 3) |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2832 { |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2833 int last = indent->ga_len - 3; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2834 char_u save[2]; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2835 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2836 STRNCPY(save, &p[last], 2); |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
2837 memcpy(&p[last], "+-", 2); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2838 fprintf(debugf, " %s", p); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2839 STRNCPY(&p[last], save, 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2840 } |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2841 else |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2842 fprintf(debugf, " %s", p); |
4444 | 2843 |
2844 nfa_set_code(state->c); | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2845 fprintf(debugf, "%s (%d) (id=%d) val=%d\n", |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2846 code, |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2847 state->c, |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2848 abs(state->id), |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2849 state->val); |
4444 | 2850 if (state->id < 0) |
2851 return; | |
2852 | |
2853 state->id = abs(state->id) * -1; | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2854 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2855 // grow indent for state->out |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2856 indent->ga_len -= 1; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2857 if (state->out1) |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2858 ga_concat(indent, (char_u *)"| "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2859 else |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2860 ga_concat(indent, (char_u *)" "); |
26652
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26592
diff
changeset
|
2861 ga_append(indent, NUL); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2862 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2863 nfa_print_state2(debugf, state->out, indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2864 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2865 // replace last part of indent for state->out1 |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2866 indent->ga_len -= 3; |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2867 ga_concat(indent, (char_u *)" "); |
26652
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26592
diff
changeset
|
2868 ga_append(indent, NUL); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2869 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2870 nfa_print_state2(debugf, state->out1, indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2871 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2872 // shrink indent |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2873 indent->ga_len -= 3; |
26652
a3f38923c037
patch 8.2.3855: illegal memory access when displaying a blob
Bram Moolenaar <Bram@vim.org>
parents:
26592
diff
changeset
|
2874 ga_append(indent, NUL); |
4444 | 2875 } |
2876 | |
2877 /* | |
2878 * Print the NFA state machine. | |
2879 */ | |
2880 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2881 nfa_dump(nfa_regprog_T *prog) |
4444 | 2882 { |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2883 FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a"); |
4444 | 2884 |
2885 if (debugf != NULL) | |
2886 { | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2887 nfa_print_state(debugf, prog->start); |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
2888 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2889 if (prog->reganch) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2890 fprintf(debugf, "reganch: %d\n", prog->reganch); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2891 if (prog->regstart != NUL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2892 fprintf(debugf, "regstart: %c (decimal: %d)\n", |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2893 prog->regstart, prog->regstart); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2894 if (prog->match_text != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2895 fprintf(debugf, "match_text: \"%s\"\n", prog->match_text); |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
2896 |
4444 | 2897 fclose(debugf); |
2898 } | |
2899 } | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2900 #endif // ENABLE_LOG |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2901 #endif // DEBUG |
4444 | 2902 |
2903 /* | |
2904 * Parse r.e. @expr and convert it into postfix form. | |
2905 * Return the postfix string on success, NULL otherwise. | |
2906 */ | |
2907 static int * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2908 re2post(void) |
4444 | 2909 { |
2910 if (nfa_reg(REG_NOPAREN) == FAIL) | |
2911 return NULL; | |
2912 EMIT(NFA_MOPEN); | |
2913 return post_start; | |
2914 } | |
2915 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2916 // NB. Some of the code below is inspired by Russ's. |
4444 | 2917 |
2918 /* | |
2919 * Represents an NFA state plus zero or one or two arrows exiting. | |
2920 * if c == MATCH, no arrows out; matching state. | |
2921 * If c == SPLIT, unlabeled arrows to out and out1 (if != NULL). | |
2922 * If c < 256, labeled arrow with character c to out. | |
2923 */ | |
2924 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2925 static nfa_state_T *state_ptr; // points to nfa_prog->state |
4444 | 2926 |
2927 /* | |
2928 * Allocate and initialize nfa_state_T. | |
2929 */ | |
2930 static nfa_state_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2931 alloc_state(int c, nfa_state_T *out, nfa_state_T *out1) |
4444 | 2932 { |
2933 nfa_state_T *s; | |
2934 | |
2935 if (istate >= nstate) | |
2936 return NULL; | |
2937 | |
2938 s = &state_ptr[istate++]; | |
2939 | |
2940 s->c = c; | |
2941 s->out = out; | |
2942 s->out1 = out1; | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2943 s->val = 0; |
4444 | 2944 |
2945 s->id = istate; | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
2946 s->lastlist[0] = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
2947 s->lastlist[1] = 0; |
4444 | 2948 |
2949 return s; | |
2950 } | |
2951 | |
2952 /* | |
2953 * A partially built NFA without the matching state filled in. | |
2954 * Frag_T.start points at the start state. | |
2955 * Frag_T.out is a list of places that need to be set to the | |
2956 * next state for this fragment. | |
2957 */ | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2958 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2959 // Since the out pointers in the list are always |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2960 // uninitialized, we use the pointers themselves |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
2961 // as storage for the Ptrlists. |
4444 | 2962 typedef union Ptrlist Ptrlist; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2963 union Ptrlist |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2964 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2965 Ptrlist *next; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2966 nfa_state_T *s; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2967 }; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2968 |
4444 | 2969 struct Frag |
2970 { | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2971 nfa_state_T *start; |
4444 | 2972 Ptrlist *out; |
2973 }; | |
2974 typedef struct Frag Frag_T; | |
2975 | |
2976 /* | |
4456 | 2977 * Initialize a Frag_T struct and return it. |
4444 | 2978 */ |
2979 static Frag_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2980 frag(nfa_state_T *start, Ptrlist *out) |
4444 | 2981 { |
4456 | 2982 Frag_T n; |
2983 | |
2984 n.start = start; | |
2985 n.out = out; | |
4444 | 2986 return n; |
2987 } | |
2988 | |
2989 /* | |
2990 * Create singleton list containing just outp. | |
2991 */ | |
2992 static Ptrlist * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2993 list1( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2994 nfa_state_T **outp) |
4444 | 2995 { |
2996 Ptrlist *l; | |
2997 | |
2998 l = (Ptrlist *)outp; | |
2999 l->next = NULL; | |
3000 return l; | |
3001 } | |
3002 | |
3003 /* | |
3004 * Patch the list of states at out to point to start. | |
3005 */ | |
3006 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3007 patch(Ptrlist *l, nfa_state_T *s) |
4444 | 3008 { |
3009 Ptrlist *next; | |
3010 | |
3011 for (; l; l = next) | |
3012 { | |
3013 next = l->next; | |
3014 l->s = s; | |
3015 } | |
3016 } | |
3017 | |
3018 | |
3019 /* | |
3020 * Join the two lists l1 and l2, returning the combination. | |
3021 */ | |
3022 static Ptrlist * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3023 append(Ptrlist *l1, Ptrlist *l2) |
4444 | 3024 { |
3025 Ptrlist *oldl1; | |
3026 | |
3027 oldl1 = l1; | |
3028 while (l1->next) | |
3029 l1 = l1->next; | |
3030 l1->next = l2; | |
3031 return oldl1; | |
3032 } | |
3033 | |
3034 /* | |
3035 * Stack used for transforming postfix form into NFA. | |
3036 */ | |
3037 static Frag_T empty; | |
3038 | |
3039 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3040 st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED) |
4444 | 3041 { |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3042 #ifdef NFA_REGEXP_ERROR_LOG |
4444 | 3043 FILE *df; |
3044 int *p2; | |
3045 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3046 df = fopen(NFA_REGEXP_ERROR_LOG, "a"); |
4444 | 3047 if (df) |
3048 { | |
3049 fprintf(df, "Error popping the stack!\n"); | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
3050 # ifdef DEBUG |
4444 | 3051 fprintf(df, "Current regexp is \"%s\"\n", nfa_regengine.expr); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
3052 # endif |
4444 | 3053 fprintf(df, "Postfix form is: "); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
3054 # ifdef DEBUG |
4444 | 3055 for (p2 = postfix; p2 < end; p2++) |
3056 { | |
3057 nfa_set_code(*p2); | |
3058 fprintf(df, "%s, ", code); | |
3059 } | |
3060 nfa_set_code(*p); | |
3061 fprintf(df, "\nCurrent position is: "); | |
3062 for (p2 = postfix; p2 <= p; p2 ++) | |
3063 { | |
3064 nfa_set_code(*p2); | |
3065 fprintf(df, "%s, ", code); | |
3066 } | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
3067 # else |
4444 | 3068 for (p2 = postfix; p2 < end; p2++) |
3069 fprintf(df, "%d, ", *p2); | |
3070 fprintf(df, "\nCurrent position is: "); | |
3071 for (p2 = postfix; p2 <= p; p2 ++) | |
3072 fprintf(df, "%d, ", *p2); | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
3073 # endif |
4444 | 3074 fprintf(df, "\n--------------------------\n"); |
3075 fclose(df); | |
3076 } | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3077 #endif |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
3078 emsg(_(e_nfa_regexp_could_not_pop_stack)); |
4444 | 3079 } |
3080 | |
3081 /* | |
3082 * Push an item onto the stack. | |
3083 */ | |
3084 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3085 st_push(Frag_T s, Frag_T **p, Frag_T *stack_end) |
4444 | 3086 { |
3087 Frag_T *stackp = *p; | |
3088 | |
3089 if (stackp >= stack_end) | |
3090 return; | |
3091 *stackp = s; | |
3092 *p = *p + 1; | |
3093 } | |
3094 | |
3095 /* | |
3096 * Pop an item from the stack. | |
3097 */ | |
3098 static Frag_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3099 st_pop(Frag_T **p, Frag_T *stack) |
4444 | 3100 { |
3101 Frag_T *stackp; | |
3102 | |
3103 *p = *p - 1; | |
3104 stackp = *p; | |
3105 if (stackp < stack) | |
3106 return empty; | |
3107 return **p; | |
3108 } | |
3109 | |
3110 /* | |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3111 * Estimate the maximum byte length of anything matching "state". |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3112 * When unknown or unlimited return -1. |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3113 */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3114 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3115 nfa_max_width(nfa_state_T *startstate, int depth) |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3116 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3117 int l, r; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3118 nfa_state_T *state = startstate; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3119 int len = 0; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3120 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3121 // detect looping in a NFA_SPLIT |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3122 if (depth > 4) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3123 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3124 |
4958
0a379dea13c9
updated for version 7.3.1224
Bram Moolenaar <bram@vim.org>
parents:
4944
diff
changeset
|
3125 while (state != NULL) |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3126 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3127 switch (state->c) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3128 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3129 case NFA_END_INVISIBLE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3130 case NFA_END_INVISIBLE_NEG: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3131 // the end, return what we have |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3132 return len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3133 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3134 case NFA_SPLIT: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3135 // two alternatives, use the maximum |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3136 l = nfa_max_width(state->out, depth + 1); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3137 r = nfa_max_width(state->out1, depth + 1); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3138 if (l < 0 || r < 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3139 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3140 return len + (l > r ? l : r); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3141 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3142 case NFA_ANY: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3143 case NFA_START_COLL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3144 case NFA_START_NEG_COLL: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3145 // matches some character, including composing chars |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3146 if (enc_utf8) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3147 len += MB_MAXBYTES; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3148 else if (has_mbyte) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3149 len += 2; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3150 else |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3151 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3152 if (state->c != NFA_ANY) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3153 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3154 // skip over the characters |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3155 state = state->out1->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3156 continue; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3157 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3158 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3159 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3160 case NFA_DIGIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3161 case NFA_WHITE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3162 case NFA_HEX: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3163 case NFA_OCTAL: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3164 // ascii |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3165 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3166 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3167 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3168 case NFA_IDENT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3169 case NFA_SIDENT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3170 case NFA_KWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3171 case NFA_SKWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3172 case NFA_FNAME: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3173 case NFA_SFNAME: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3174 case NFA_PRINT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3175 case NFA_SPRINT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3176 case NFA_NWHITE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3177 case NFA_NDIGIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3178 case NFA_NHEX: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3179 case NFA_NOCTAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3180 case NFA_WORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3181 case NFA_NWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3182 case NFA_HEAD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3183 case NFA_NHEAD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3184 case NFA_ALPHA: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3185 case NFA_NALPHA: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3186 case NFA_LOWER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3187 case NFA_NLOWER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3188 case NFA_UPPER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3189 case NFA_NUPPER: |
5296 | 3190 case NFA_LOWER_IC: |
3191 case NFA_NLOWER_IC: | |
3192 case NFA_UPPER_IC: | |
3193 case NFA_NUPPER_IC: | |
5901 | 3194 case NFA_ANY_COMPOSING: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3195 // possibly non-ascii |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3196 if (has_mbyte) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3197 len += 3; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3198 else |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3199 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3200 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3201 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3202 case NFA_START_INVISIBLE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3203 case NFA_START_INVISIBLE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3204 case NFA_START_INVISIBLE_BEFORE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3205 case NFA_START_INVISIBLE_BEFORE_NEG: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3206 // zero-width, out1 points to the END state |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3207 state = state->out1->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3208 continue; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3209 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3210 case NFA_BACKREF1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3211 case NFA_BACKREF2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3212 case NFA_BACKREF3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3213 case NFA_BACKREF4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3214 case NFA_BACKREF5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3215 case NFA_BACKREF6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3216 case NFA_BACKREF7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3217 case NFA_BACKREF8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3218 case NFA_BACKREF9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3219 #ifdef FEAT_SYN_HL |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3220 case NFA_ZREF1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3221 case NFA_ZREF2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3222 case NFA_ZREF3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3223 case NFA_ZREF4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3224 case NFA_ZREF5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3225 case NFA_ZREF6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3226 case NFA_ZREF7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3227 case NFA_ZREF8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3228 case NFA_ZREF9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3229 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3230 case NFA_NEWL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3231 case NFA_SKIP: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3232 // unknown width |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3233 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3234 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3235 case NFA_BOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3236 case NFA_EOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3237 case NFA_BOF: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3238 case NFA_EOF: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3239 case NFA_BOW: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3240 case NFA_EOW: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3241 case NFA_MOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3242 case NFA_MOPEN1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3243 case NFA_MOPEN2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3244 case NFA_MOPEN3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3245 case NFA_MOPEN4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3246 case NFA_MOPEN5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3247 case NFA_MOPEN6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3248 case NFA_MOPEN7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3249 case NFA_MOPEN8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3250 case NFA_MOPEN9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3251 #ifdef FEAT_SYN_HL |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3252 case NFA_ZOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3253 case NFA_ZOPEN1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3254 case NFA_ZOPEN2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3255 case NFA_ZOPEN3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3256 case NFA_ZOPEN4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3257 case NFA_ZOPEN5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3258 case NFA_ZOPEN6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3259 case NFA_ZOPEN7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3260 case NFA_ZOPEN8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3261 case NFA_ZOPEN9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3262 case NFA_ZCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3263 case NFA_ZCLOSE1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3264 case NFA_ZCLOSE2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3265 case NFA_ZCLOSE3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3266 case NFA_ZCLOSE4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3267 case NFA_ZCLOSE5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3268 case NFA_ZCLOSE6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3269 case NFA_ZCLOSE7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3270 case NFA_ZCLOSE8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3271 case NFA_ZCLOSE9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3272 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3273 case NFA_MCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3274 case NFA_MCLOSE1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3275 case NFA_MCLOSE2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3276 case NFA_MCLOSE3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3277 case NFA_MCLOSE4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3278 case NFA_MCLOSE5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3279 case NFA_MCLOSE6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3280 case NFA_MCLOSE7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3281 case NFA_MCLOSE8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3282 case NFA_MCLOSE9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3283 case NFA_NOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3284 case NFA_NCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3285 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3286 case NFA_LNUM_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3287 case NFA_LNUM_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3288 case NFA_COL_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3289 case NFA_COL_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3290 case NFA_VCOL_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3291 case NFA_VCOL_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3292 case NFA_MARK_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3293 case NFA_MARK_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3294 case NFA_VISUAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3295 case NFA_LNUM: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3296 case NFA_CURSOR: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3297 case NFA_COL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3298 case NFA_VCOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3299 case NFA_MARK: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3300 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3301 case NFA_ZSTART: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3302 case NFA_ZEND: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3303 case NFA_OPT_CHARS: |
5370 | 3304 case NFA_EMPTY: |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3305 case NFA_START_PATTERN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3306 case NFA_END_PATTERN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3307 case NFA_COMPOSING: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3308 case NFA_END_COMPOSING: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3309 // zero-width |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3310 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3311 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3312 default: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3313 if (state->c < 0) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3314 // don't know what this is |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3315 return -1; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3316 // normal character |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3317 len += MB_CHAR2LEN(state->c); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3318 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3319 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3320 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3321 // normal way to continue |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3322 state = state->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3323 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3324 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3325 // unrecognized, "cannot happen" |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3326 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3327 } |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
3328 |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3329 /* |
4444 | 3330 * Convert a postfix form into its equivalent NFA. |
3331 * Return the NFA start state on success, NULL otherwise. | |
3332 */ | |
3333 static nfa_state_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3334 post2nfa(int *postfix, int *end, int nfa_calc_size) |
4444 | 3335 { |
3336 int *p; | |
3337 int mopen; | |
3338 int mclose; | |
3339 Frag_T *stack = NULL; | |
3340 Frag_T *stackp = NULL; | |
3341 Frag_T *stack_end = NULL; | |
3342 Frag_T e1; | |
3343 Frag_T e2; | |
3344 Frag_T e; | |
3345 nfa_state_T *s; | |
3346 nfa_state_T *s1; | |
3347 nfa_state_T *matchstate; | |
4484 | 3348 nfa_state_T *ret = NULL; |
4444 | 3349 |
3350 if (postfix == NULL) | |
3351 return NULL; | |
3352 | |
4456 | 3353 #define PUSH(s) st_push((s), &stackp, stack_end) |
4444 | 3354 #define POP() st_pop(&stackp, stack); \ |
3355 if (stackp < stack) \ | |
3356 { \ | |
3357 st_error(postfix, end, p); \ | |
6747 | 3358 vim_free(stack); \ |
4444 | 3359 return NULL; \ |
3360 } | |
3361 | |
3362 if (nfa_calc_size == FALSE) | |
3363 { | |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
16825
diff
changeset
|
3364 // Allocate space for the stack. Max states on the stack: "nstate". |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
3365 stack = ALLOC_MULT(Frag_T, nstate + 1); |
15265
a7d02a56b5d5
patch 8.1.0641: no check for out-of-memory when converting regexp
Bram Moolenaar <Bram@vim.org>
parents:
14354
diff
changeset
|
3366 if (stack == NULL) |
a7d02a56b5d5
patch 8.1.0641: no check for out-of-memory when converting regexp
Bram Moolenaar <Bram@vim.org>
parents:
14354
diff
changeset
|
3367 return NULL; |
4444 | 3368 stackp = stack; |
4462 | 3369 stack_end = stack + (nstate + 1); |
4444 | 3370 } |
3371 | |
3372 for (p = postfix; p < end; ++p) | |
3373 { | |
3374 switch (*p) | |
3375 { | |
3376 case NFA_CONCAT: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3377 // Concatenation. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3378 // Pay attention: this operator does not exist in the r.e. itself |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3379 // (it is implicit, really). It is added when r.e. is translated |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3380 // to postfix form in re2post(). |
4444 | 3381 if (nfa_calc_size == TRUE) |
3382 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3383 // nstate += 0; |
4444 | 3384 break; |
3385 } | |
3386 e2 = POP(); | |
3387 e1 = POP(); | |
3388 patch(e1.out, e2.start); | |
3389 PUSH(frag(e1.start, e2.out)); | |
3390 break; | |
3391 | |
3392 case NFA_OR: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3393 // Alternation |
4444 | 3394 if (nfa_calc_size == TRUE) |
3395 { | |
4458 | 3396 nstate++; |
4444 | 3397 break; |
3398 } | |
3399 e2 = POP(); | |
3400 e1 = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3401 s = alloc_state(NFA_SPLIT, e1.start, e2.start); |
4444 | 3402 if (s == NULL) |
4484 | 3403 goto theend; |
4444 | 3404 PUSH(frag(s, append(e1.out, e2.out))); |
3405 break; | |
3406 | |
3407 case NFA_STAR: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3408 // Zero or more, prefer more |
4444 | 3409 if (nfa_calc_size == TRUE) |
3410 { | |
4458 | 3411 nstate++; |
4444 | 3412 break; |
3413 } | |
3414 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3415 s = alloc_state(NFA_SPLIT, e.start, NULL); |
4444 | 3416 if (s == NULL) |
4484 | 3417 goto theend; |
4444 | 3418 patch(e.out, s); |
3419 PUSH(frag(s, list1(&s->out1))); | |
3420 break; | |
3421 | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3422 case NFA_STAR_NONGREEDY: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3423 // Zero or more, prefer zero |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3424 if (nfa_calc_size == TRUE) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3425 { |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3426 nstate++; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3427 break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3428 } |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3429 e = POP(); |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3430 s = alloc_state(NFA_SPLIT, NULL, e.start); |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3431 if (s == NULL) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3432 goto theend; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3433 patch(e.out, s); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3434 PUSH(frag(s, list1(&s->out))); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3435 break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3436 |
4444 | 3437 case NFA_QUEST: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3438 // one or zero atoms=> greedy match |
4444 | 3439 if (nfa_calc_size == TRUE) |
3440 { | |
4458 | 3441 nstate++; |
4444 | 3442 break; |
3443 } | |
3444 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3445 s = alloc_state(NFA_SPLIT, e.start, NULL); |
4444 | 3446 if (s == NULL) |
4484 | 3447 goto theend; |
4444 | 3448 PUSH(frag(s, append(e.out, list1(&s->out1)))); |
3449 break; | |
3450 | |
3451 case NFA_QUEST_NONGREEDY: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3452 // zero or one atoms => non-greedy match |
4444 | 3453 if (nfa_calc_size == TRUE) |
3454 { | |
4458 | 3455 nstate++; |
4444 | 3456 break; |
3457 } | |
3458 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3459 s = alloc_state(NFA_SPLIT, NULL, e.start); |
4444 | 3460 if (s == NULL) |
4484 | 3461 goto theend; |
4444 | 3462 PUSH(frag(s, append(e.out, list1(&s->out)))); |
3463 break; | |
3464 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3465 case NFA_END_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3466 case NFA_END_NEG_COLL: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3467 // On the stack is the sequence starting with NFA_START_COLL or |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3468 // NFA_START_NEG_COLL and all possible characters. Patch it to |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3469 // add the output to the start. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3470 if (nfa_calc_size == TRUE) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3471 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3472 nstate++; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3473 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3474 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3475 e = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3476 s = alloc_state(NFA_END_COLL, NULL, NULL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3477 if (s == NULL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3478 goto theend; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3479 patch(e.out, s); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3480 e.start->out1 = s; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3481 PUSH(frag(e.start, list1(&s->out))); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3482 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3483 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3484 case NFA_RANGE: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3485 // Before this are two characters, the low and high end of a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3486 // range. Turn them into two states with MIN and MAX. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3487 if (nfa_calc_size == TRUE) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3488 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3489 // nstate += 0; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3490 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3491 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3492 e2 = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3493 e1 = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3494 e2.start->val = e2.start->c; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3495 e2.start->c = NFA_RANGE_MAX; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3496 e1.start->val = e1.start->c; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3497 e1.start->c = NFA_RANGE_MIN; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3498 patch(e1.out, e2.start); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3499 PUSH(frag(e1.start, e2.out)); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3500 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3501 |
5370 | 3502 case NFA_EMPTY: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3503 // 0-length, used in a repetition with max/min count of 0 |
4444 | 3504 if (nfa_calc_size == TRUE) |
3505 { | |
4458 | 3506 nstate++; |
4444 | 3507 break; |
3508 } | |
5370 | 3509 s = alloc_state(NFA_EMPTY, NULL, NULL); |
4444 | 3510 if (s == NULL) |
4484 | 3511 goto theend; |
4444 | 3512 PUSH(frag(s, list1(&s->out))); |
3513 break; | |
3514 | |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3515 case NFA_OPT_CHARS: |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3516 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3517 int n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3518 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3519 // \%[abc] implemented as: |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3520 // NFA_SPLIT |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3521 // +-CHAR(a) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3522 // | +-NFA_SPLIT |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3523 // | +-CHAR(b) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3524 // | | +-NFA_SPLIT |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3525 // | | +-CHAR(c) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3526 // | | | +-next |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3527 // | | +- next |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3528 // | +- next |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3529 // +- next |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3530 n = *++p; // get number of characters |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3531 if (nfa_calc_size == TRUE) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3532 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3533 nstate += n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3534 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3535 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3536 s = NULL; // avoid compiler warning |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3537 e1.out = NULL; // stores list with out1's |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3538 s1 = NULL; // previous NFA_SPLIT to connect to |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3539 while (n-- > 0) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3540 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3541 e = POP(); // get character |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3542 s = alloc_state(NFA_SPLIT, e.start, NULL); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3543 if (s == NULL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3544 goto theend; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3545 if (e1.out == NULL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3546 e1 = e; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3547 patch(e.out, s1); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3548 append(e1.out, list1(&s->out1)); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3549 s1 = s; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3550 } |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3551 PUSH(frag(s, e1.out)); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3552 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3553 } |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3554 |
4444 | 3555 case NFA_PREV_ATOM_NO_WIDTH: |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
3556 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3557 case NFA_PREV_ATOM_JUST_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3558 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3559 case NFA_PREV_ATOM_LIKE_PATTERN: |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3560 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3561 int before = (*p == NFA_PREV_ATOM_JUST_BEFORE |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3562 || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3563 int pattern = (*p == NFA_PREV_ATOM_LIKE_PATTERN); |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3564 int start_state; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3565 int end_state; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3566 int n = 0; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3567 nfa_state_T *zend; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3568 nfa_state_T *skip; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3569 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3570 switch (*p) |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3571 { |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3572 case NFA_PREV_ATOM_NO_WIDTH: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3573 start_state = NFA_START_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3574 end_state = NFA_END_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3575 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3576 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3577 start_state = NFA_START_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3578 end_state = NFA_END_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3579 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3580 case NFA_PREV_ATOM_JUST_BEFORE: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3581 start_state = NFA_START_INVISIBLE_BEFORE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3582 end_state = NFA_END_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3583 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3584 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3585 start_state = NFA_START_INVISIBLE_BEFORE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3586 end_state = NFA_END_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3587 break; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3588 default: // NFA_PREV_ATOM_LIKE_PATTERN: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3589 start_state = NFA_START_PATTERN; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3590 end_state = NFA_END_PATTERN; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3591 break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3592 } |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3593 |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3594 if (before) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3595 n = *++p; // get the count |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3596 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3597 // The \@= operator: match the preceding atom with zero width. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3598 // The \@! operator: no match for the preceding atom. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3599 // The \@<= operator: match for the preceding atom. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3600 // The \@<! operator: no match for the preceding atom. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3601 // Surrounds the preceding atom with START_INVISIBLE and |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3602 // END_INVISIBLE, similarly to MOPEN. |
4444 | 3603 |
3604 if (nfa_calc_size == TRUE) | |
3605 { | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3606 nstate += pattern ? 4 : 2; |
4444 | 3607 break; |
3608 } | |
3609 e = POP(); | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3610 s1 = alloc_state(end_state, NULL, NULL); |
4444 | 3611 if (s1 == NULL) |
4484 | 3612 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3613 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3614 s = alloc_state(start_state, e.start, s1); |
4444 | 3615 if (s == NULL) |
4484 | 3616 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3617 if (pattern) |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3618 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3619 // NFA_ZEND -> NFA_END_PATTERN -> NFA_SKIP -> what follows. |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3620 skip = alloc_state(NFA_SKIP, NULL, NULL); |
11896
a941848d8c44
patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
3621 if (skip == NULL) |
a941848d8c44
patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
3622 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3623 zend = alloc_state(NFA_ZEND, s1, NULL); |
11896
a941848d8c44
patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
3624 if (zend == NULL) |
a941848d8c44
patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
3625 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3626 s1->out= skip; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3627 patch(e.out, zend); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3628 PUSH(frag(s, list1(&skip->out))); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3629 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3630 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3631 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3632 patch(e.out, s1); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3633 PUSH(frag(s, list1(&s1->out))); |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3634 if (before) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3635 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3636 if (n <= 0) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3637 // See if we can guess the maximum width, it avoids a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3638 // lot of pointless tries. |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3639 n = nfa_max_width(e.start, 0); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3640 s->val = n; // store the count |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3641 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3642 } |
4444 | 3643 break; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3644 } |
4444 | 3645 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3646 case NFA_COMPOSING: // char with composing char |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3647 #if 0 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3648 // TODO |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3649 if (regflags & RF_ICOMBINE) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3650 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3651 // use the base character only |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3652 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3653 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3654 // FALLTHROUGH |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3655 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3656 case NFA_MOPEN: // \( \) Submatch |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3657 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3658 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3659 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3660 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3661 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3662 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3663 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3664 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3665 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3666 #ifdef FEAT_SYN_HL |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3667 case NFA_ZOPEN: // \z( \) Submatch |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3668 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3669 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3670 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3671 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3672 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3673 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3674 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3675 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3676 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3677 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3678 case NFA_NOPEN: // \%( \) "Invisible Submatch" |
4444 | 3679 if (nfa_calc_size == TRUE) |
3680 { | |
3681 nstate += 2; | |
3682 break; | |
3683 } | |
3684 | |
3685 mopen = *p; | |
3686 switch (*p) | |
3687 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3688 case NFA_NOPEN: mclose = NFA_NCLOSE; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3689 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3690 case NFA_ZOPEN: mclose = NFA_ZCLOSE; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3691 case NFA_ZOPEN1: mclose = NFA_ZCLOSE1; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3692 case NFA_ZOPEN2: mclose = NFA_ZCLOSE2; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3693 case NFA_ZOPEN3: mclose = NFA_ZCLOSE3; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3694 case NFA_ZOPEN4: mclose = NFA_ZCLOSE4; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3695 case NFA_ZOPEN5: mclose = NFA_ZCLOSE5; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3696 case NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3697 case NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3698 case NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3699 case NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3700 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3701 case NFA_COMPOSING: mclose = NFA_END_COMPOSING; break; |
4444 | 3702 default: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3703 // NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9 |
4444 | 3704 mclose = *p + NSUBEXP; |
3705 break; | |
3706 } | |
3707 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3708 // Allow "NFA_MOPEN" as a valid postfix representation for |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3709 // the empty regexp "". In this case, the NFA will be |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3710 // NFA_MOPEN -> NFA_MCLOSE. Note that this also allows |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3711 // empty groups of parenthesis, and empty mbyte chars |
4444 | 3712 if (stackp == stack) |
3713 { | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3714 s = alloc_state(mopen, NULL, NULL); |
4444 | 3715 if (s == NULL) |
4484 | 3716 goto theend; |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3717 s1 = alloc_state(mclose, NULL, NULL); |
4444 | 3718 if (s1 == NULL) |
4484 | 3719 goto theend; |
4444 | 3720 patch(list1(&s->out), s1); |
3721 PUSH(frag(s, list1(&s1->out))); | |
3722 break; | |
3723 } | |
3724 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3725 // At least one node was emitted before NFA_MOPEN, so |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3726 // at least one node will be between NFA_MOPEN and NFA_MCLOSE |
4444 | 3727 e = POP(); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3728 s = alloc_state(mopen, e.start, NULL); // `(' |
4444 | 3729 if (s == NULL) |
4484 | 3730 goto theend; |
4444 | 3731 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3732 s1 = alloc_state(mclose, NULL, NULL); // `)' |
4444 | 3733 if (s1 == NULL) |
4484 | 3734 goto theend; |
4444 | 3735 patch(e.out, s1); |
3736 | |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3737 if (mopen == NFA_COMPOSING) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3738 // COMPOSING->out1 = END_COMPOSING |
4444 | 3739 patch(list1(&s->out1), s1); |
3740 | |
3741 PUSH(frag(s, list1(&s1->out))); | |
3742 break; | |
3743 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3744 case NFA_BACKREF1: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3745 case NFA_BACKREF2: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3746 case NFA_BACKREF3: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3747 case NFA_BACKREF4: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3748 case NFA_BACKREF5: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3749 case NFA_BACKREF6: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3750 case NFA_BACKREF7: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3751 case NFA_BACKREF8: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3752 case NFA_BACKREF9: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3753 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3754 case NFA_ZREF1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3755 case NFA_ZREF2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3756 case NFA_ZREF3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3757 case NFA_ZREF4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3758 case NFA_ZREF5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3759 case NFA_ZREF6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3760 case NFA_ZREF7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3761 case NFA_ZREF8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3762 case NFA_ZREF9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3763 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3764 if (nfa_calc_size == TRUE) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3765 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3766 nstate += 2; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3767 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3768 } |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3769 s = alloc_state(*p, NULL, NULL); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3770 if (s == NULL) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3771 goto theend; |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3772 s1 = alloc_state(NFA_SKIP, NULL, NULL); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3773 if (s1 == NULL) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3774 goto theend; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3775 patch(list1(&s->out), s1); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3776 PUSH(frag(s, list1(&s1->out))); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3777 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3778 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3779 case NFA_LNUM: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3780 case NFA_LNUM_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3781 case NFA_LNUM_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3782 case NFA_VCOL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3783 case NFA_VCOL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3784 case NFA_VCOL_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3785 case NFA_COL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3786 case NFA_COL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3787 case NFA_COL_LT: |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3788 case NFA_MARK: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3789 case NFA_MARK_GT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3790 case NFA_MARK_LT: |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3791 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3792 int n = *++p; // lnum, col or mark name |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3793 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3794 if (nfa_calc_size == TRUE) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3795 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3796 nstate += 1; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3797 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3798 } |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3799 s = alloc_state(p[-1], NULL, NULL); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3800 if (s == NULL) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3801 goto theend; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3802 s->val = n; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3803 PUSH(frag(s, list1(&s->out))); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3804 break; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3805 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3806 |
4444 | 3807 case NFA_ZSTART: |
3808 case NFA_ZEND: | |
3809 default: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3810 // Operands |
4444 | 3811 if (nfa_calc_size == TRUE) |
3812 { | |
4458 | 3813 nstate++; |
4444 | 3814 break; |
3815 } | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3816 s = alloc_state(*p, NULL, NULL); |
4444 | 3817 if (s == NULL) |
4484 | 3818 goto theend; |
4444 | 3819 PUSH(frag(s, list1(&s->out))); |
3820 break; | |
3821 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3822 } // switch(*p) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3823 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3824 } // for(p = postfix; *p; ++p) |
4444 | 3825 |
3826 if (nfa_calc_size == TRUE) | |
3827 { | |
4458 | 3828 nstate++; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3829 goto theend; // Return value when counting size is ignored anyway |
4444 | 3830 } |
3831 | |
3832 e = POP(); | |
3833 if (stackp != stack) | |
6747 | 3834 { |
3835 vim_free(stack); | |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
3836 EMSG_RET_NULL(_(e_nfa_regexp_while_converting_from_postfix_to_nfa_too_many_stats_left_on_stack)); |
6747 | 3837 } |
4444 | 3838 |
3839 if (istate >= nstate) | |
6747 | 3840 { |
3841 vim_free(stack); | |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
3842 EMSG_RET_NULL(_(e_nfa_regexp_not_enough_space_to_store_whole_nfa)); |
6747 | 3843 } |
4444 | 3844 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3845 matchstate = &state_ptr[istate++]; // the match state |
4444 | 3846 matchstate->c = NFA_MATCH; |
3847 matchstate->out = matchstate->out1 = NULL; | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3848 matchstate->id = 0; |
4444 | 3849 |
3850 patch(e.out, matchstate); | |
4484 | 3851 ret = e.start; |
3852 | |
3853 theend: | |
3854 vim_free(stack); | |
3855 return ret; | |
4444 | 3856 |
3857 #undef POP1 | |
3858 #undef PUSH1 | |
3859 #undef POP2 | |
3860 #undef PUSH2 | |
3861 #undef POP | |
3862 #undef PUSH | |
3863 } | |
3864 | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3865 /* |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3866 * After building the NFA program, inspect it to add optimization hints. |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3867 */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3868 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3869 nfa_postprocess(nfa_regprog_T *prog) |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3870 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3871 int i; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3872 int c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3873 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3874 for (i = 0; i < prog->nstate; ++i) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3875 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3876 c = prog->state[i].c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3877 if (c == NFA_START_INVISIBLE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3878 || c == NFA_START_INVISIBLE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3879 || c == NFA_START_INVISIBLE_BEFORE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3880 || c == NFA_START_INVISIBLE_BEFORE_NEG) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3881 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3882 int directly; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3883 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3884 // Do it directly when what follows is possibly the end of the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3885 // match. |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3886 if (match_follows(prog->state[i].out1->out, 0)) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3887 directly = TRUE; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3888 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3889 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3890 int ch_invisible = failure_chance(prog->state[i].out, 0); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3891 int ch_follows = failure_chance(prog->state[i].out1->out, 0); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3892 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3893 // Postpone when the invisible match is expensive or has a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3894 // lower chance of failing. |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3895 if (c == NFA_START_INVISIBLE_BEFORE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3896 || c == NFA_START_INVISIBLE_BEFORE_NEG) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3897 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3898 // "before" matches are very expensive when |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3899 // unbounded, always prefer what follows then, |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3900 // unless what follows will always match. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3901 // Otherwise strongly prefer what follows. |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3902 if (prog->state[i].val <= 0 && ch_follows > 0) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3903 directly = FALSE; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3904 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3905 directly = ch_follows * 10 < ch_invisible; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3906 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3907 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3908 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3909 // normal invisible, first do the one with the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3910 // highest failure chance |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3911 directly = ch_follows < ch_invisible; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3912 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3913 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3914 if (directly) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3915 // switch to the _FIRST state |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3916 ++prog->state[i].c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3917 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3918 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3919 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3920 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3921 ///////////////////////////////////////////////////////////////// |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3922 // NFA execution code. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3923 ///////////////////////////////////////////////////////////////// |
4444 | 3924 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3925 typedef struct |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3926 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3927 int in_use; // number of subexpr with useful info |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3928 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3929 // When REG_MULTI is TRUE list.multi is used, otherwise list.line. |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3930 union |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3931 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3932 struct multipos |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3933 { |
6547 | 3934 linenr_T start_lnum; |
3935 linenr_T end_lnum; | |
3936 colnr_T start_col; | |
3937 colnr_T end_col; | |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3938 } multi[NSUBEXP]; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3939 struct linepos |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3940 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3941 char_u *start; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3942 char_u *end; |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3943 } line[NSUBEXP]; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3944 } list; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3945 } regsub_T; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3946 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3947 typedef struct |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3948 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3949 regsub_T norm; // \( .. \) matches |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3950 #ifdef FEAT_SYN_HL |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3951 regsub_T synt; // \z( .. \) matches |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3952 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3953 } regsubs_T; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3954 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3955 // nfa_pim_T stores a Postponed Invisible Match. |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3956 typedef struct nfa_pim_S nfa_pim_T; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3957 struct nfa_pim_S |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3958 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3959 int result; // NFA_PIM_*, see below |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3960 nfa_state_T *state; // the invisible match start state |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3961 regsubs_T subs; // submatch info, only party used |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3962 union |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3963 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3964 lpos_T pos; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3965 char_u *ptr; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3966 } end; // where the match must end |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3967 }; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3968 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3969 // Values for done in nfa_pim_T. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3970 #define NFA_PIM_UNUSED 0 // pim not used |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3971 #define NFA_PIM_TODO 1 // pim not done yet |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3972 #define NFA_PIM_MATCH 2 // pim executed, matches |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3973 #define NFA_PIM_NOMATCH 3 // pim executed, no match |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3974 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3975 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3976 // nfa_thread_T contains execution information of a NFA state |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3977 typedef struct |
4444 | 3978 { |
3979 nfa_state_T *state; | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3980 int count; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3981 nfa_pim_T pim; // if pim.result != NFA_PIM_UNUSED: postponed |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3982 // invisible match |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3983 regsubs_T subs; // submatch info, only party used |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3984 } nfa_thread_T; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3985 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3986 // nfa_list_T contains the alternative NFA execution states. |
4444 | 3987 typedef struct |
3988 { | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3989 nfa_thread_T *t; // allocated array of states |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3990 int n; // nr of states currently in "t" |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3991 int len; // max nr of states in "t" |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3992 int id; // ID of the list |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
3993 int has_pim; // TRUE when any state has a PIM |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3994 } nfa_list_T; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3995 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3996 #ifdef ENABLE_LOG |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3997 static void log_subexpr(regsub_T *sub); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3998 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3999 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4000 log_subsexpr(regsubs_T *subs) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4001 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4002 log_subexpr(&subs->norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4003 # ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4004 if (rex.nfa_has_zsubexpr) |
4770
b20dbf3a5370
updated for version 7.3.1132
Bram Moolenaar <bram@vim.org>
parents:
4768
diff
changeset
|
4005 log_subexpr(&subs->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4006 # endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4007 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4008 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4009 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4010 log_subexpr(regsub_T *sub) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4011 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4012 int j; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4013 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4014 for (j = 0; j < sub->in_use; j++) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4015 if (REG_MULTI) |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
4016 fprintf(log_fd, "*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\n", |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4017 j, |
6547 | 4018 sub->list.multi[j].start_col, |
4019 (int)sub->list.multi[j].start_lnum, | |
4020 sub->list.multi[j].end_col, | |
4021 (int)sub->list.multi[j].end_lnum); | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4022 else |
4746
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4023 { |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4024 char *s = (char *)sub->list.line[j].start; |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4025 char *e = (char *)sub->list.line[j].end; |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4026 |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
4027 fprintf(log_fd, "*** group %d, start: \"%s\", end: \"%s\"\n", |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4028 j, |
4746
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4029 s == NULL ? "NULL" : s, |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4030 e == NULL ? "NULL" : e); |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
4031 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4032 } |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4033 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4034 static char * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4035 pim_info(nfa_pim_T *pim) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4036 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4037 static char buf[30]; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4038 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4039 if (pim == NULL || pim->result == NFA_PIM_UNUSED) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4040 buf[0] = NUL; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4041 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4042 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4043 sprintf(buf, " PIM col %d", REG_MULTI ? (int)pim->end.pos.col |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4044 : (int)(pim->end.ptr - rex.input)); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4045 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4046 return buf; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4047 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4048 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4049 #endif |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4050 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4051 // Used during execution: whether a match has been found. |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
4052 static int nfa_match; |
6573 | 4053 #ifdef FEAT_RELTIME |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
4054 static int *nfa_timed_out; |
6573 | 4055 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4056 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
4057 static void copy_sub(regsub_T *to, regsub_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
4058 static int pim_equal(nfa_pim_T *one, nfa_pim_T *two); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4059 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4060 /* |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4061 * Copy postponed invisible match info from "from" to "to". |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4062 */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4063 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4064 copy_pim(nfa_pim_T *to, nfa_pim_T *from) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4065 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4066 to->result = from->result; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4067 to->state = from->state; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4068 copy_sub(&to->subs.norm, &from->subs.norm); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4069 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4070 if (rex.nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4071 copy_sub(&to->subs.synt, &from->subs.synt); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4072 #endif |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4073 to->end = from->end; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4074 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4075 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4076 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4077 clear_sub(regsub_T *sub) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4078 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4079 if (REG_MULTI) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4080 // Use 0xff to set lnum to -1 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4081 vim_memset(sub->list.multi, 0xff, |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4082 sizeof(struct multipos) * rex.nfa_nsubexpr); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4083 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4084 vim_memset(sub->list.line, 0, |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4085 sizeof(struct linepos) * rex.nfa_nsubexpr); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4086 sub->in_use = 0; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4087 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4088 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4089 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4090 * Copy the submatches from "from" to "to". |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4091 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4092 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4093 copy_sub(regsub_T *to, regsub_T *from) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4094 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4095 to->in_use = from->in_use; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4096 if (from->in_use > 0) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4097 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4098 // Copy the match start and end positions. |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4099 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4100 mch_memmove(&to->list.multi[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4101 &from->list.multi[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4102 sizeof(struct multipos) * from->in_use); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4103 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4104 mch_memmove(&to->list.line[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4105 &from->list.line[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4106 sizeof(struct linepos) * from->in_use); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4107 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4108 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4109 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4110 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4111 * Like copy_sub() but exclude the main match. |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4112 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4113 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4114 copy_sub_off(regsub_T *to, regsub_T *from) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4115 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4116 if (to->in_use < from->in_use) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4117 to->in_use = from->in_use; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4118 if (from->in_use > 1) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4119 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4120 // Copy the match start and end positions. |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4121 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4122 mch_memmove(&to->list.multi[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4123 &from->list.multi[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4124 sizeof(struct multipos) * (from->in_use - 1)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4125 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4126 mch_memmove(&to->list.line[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4127 &from->list.line[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4128 sizeof(struct linepos) * (from->in_use - 1)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4129 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4130 } |
4444 | 4131 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4132 /* |
5372 | 4133 * Like copy_sub() but only do the end of the main match if \ze is present. |
4134 */ | |
4135 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4136 copy_ze_off(regsub_T *to, regsub_T *from) |
5372 | 4137 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4138 if (rex.nfa_has_zend) |
5372 | 4139 { |
4140 if (REG_MULTI) | |
4141 { | |
6547 | 4142 if (from->list.multi[0].end_lnum >= 0) |
13192
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
4143 { |
6547 | 4144 to->list.multi[0].end_lnum = from->list.multi[0].end_lnum; |
4145 to->list.multi[0].end_col = from->list.multi[0].end_col; | |
13192
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
4146 } |
5372 | 4147 } |
4148 else | |
4149 { | |
4150 if (from->list.line[0].end != NULL) | |
4151 to->list.line[0].end = from->list.line[0].end; | |
4152 } | |
4153 } | |
4154 } | |
4155 | |
4156 /* | |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4157 * Return TRUE if "sub1" and "sub2" have the same start positions. |
5893 | 4158 * When using back-references also check the end position. |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4159 */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4160 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4161 sub_equal(regsub_T *sub1, regsub_T *sub2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4162 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4163 int i; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4164 int todo; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4165 linenr_T s1; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4166 linenr_T s2; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4167 char_u *sp1; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4168 char_u *sp2; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4169 |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4170 todo = sub1->in_use > sub2->in_use ? sub1->in_use : sub2->in_use; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4171 if (REG_MULTI) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4172 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4173 for (i = 0; i < todo; ++i) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4174 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4175 if (i < sub1->in_use) |
6547 | 4176 s1 = sub1->list.multi[i].start_lnum; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4177 else |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4178 s1 = -1; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4179 if (i < sub2->in_use) |
6547 | 4180 s2 = sub2->list.multi[i].start_lnum; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4181 else |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4182 s2 = -1; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4183 if (s1 != s2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4184 return FALSE; |
6547 | 4185 if (s1 != -1 && sub1->list.multi[i].start_col |
4186 != sub2->list.multi[i].start_col) | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4187 return FALSE; |
5893 | 4188 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4189 if (rex.nfa_has_backref) |
5893 | 4190 { |
4191 if (i < sub1->in_use) | |
6547 | 4192 s1 = sub1->list.multi[i].end_lnum; |
5893 | 4193 else |
4194 s1 = -1; | |
4195 if (i < sub2->in_use) | |
6547 | 4196 s2 = sub2->list.multi[i].end_lnum; |
5893 | 4197 else |
4198 s2 = -1; | |
4199 if (s1 != s2) | |
4200 return FALSE; | |
6547 | 4201 if (s1 != -1 && sub1->list.multi[i].end_col |
4202 != sub2->list.multi[i].end_col) | |
5893 | 4203 return FALSE; |
4204 } | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4205 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4206 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4207 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4208 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4209 for (i = 0; i < todo; ++i) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4210 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4211 if (i < sub1->in_use) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4212 sp1 = sub1->list.line[i].start; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4213 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4214 sp1 = NULL; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4215 if (i < sub2->in_use) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4216 sp2 = sub2->list.line[i].start; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4217 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4218 sp2 = NULL; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4219 if (sp1 != sp2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4220 return FALSE; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4221 if (rex.nfa_has_backref) |
5893 | 4222 { |
4223 if (i < sub1->in_use) | |
4224 sp1 = sub1->list.line[i].end; | |
4225 else | |
4226 sp1 = NULL; | |
4227 if (i < sub2->in_use) | |
4228 sp2 = sub2->list.line[i].end; | |
4229 else | |
4230 sp2 = NULL; | |
4231 if (sp1 != sp2) | |
4232 return FALSE; | |
4233 } | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4234 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4235 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4236 |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4237 return TRUE; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4238 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4239 |
29191
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4240 #ifdef FEAT_RELTIME |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4241 /* |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4242 * Check if we are past the time limit, if there is one. |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4243 */ |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4244 static int |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4245 nfa_did_time_out(void) |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4246 { |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4247 if (*timeout_flag) |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4248 { |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4249 if (nfa_timed_out != NULL) |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4250 { |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4251 if (!*nfa_timed_out) |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4252 ch_log(NULL, "NFA regexp timed out"); |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4253 *nfa_timed_out = TRUE; |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4254 } |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4255 return TRUE; |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4256 } |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4257 return FALSE; |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4258 } |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4259 #endif |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4260 |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4261 #ifdef ENABLE_LOG |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4262 static void |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4263 open_debug_log(int result) |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4264 { |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4265 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4266 if (log_fd == NULL) |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4267 { |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4268 emsg(_(e_log_open_failed)); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4269 log_fd = stderr; |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4270 } |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4271 |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4272 fprintf(log_fd, "****************************\n"); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4273 fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n"); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4274 fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : result == MAYBE |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4275 ? "MAYBE" : "FALSE"); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4276 fprintf(log_fd, "****************************\n"); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4277 } |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4278 |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4279 static void |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4280 report_state(char *action, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4281 regsub_T *sub, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4282 nfa_state_T *state, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4283 int lid, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4284 nfa_pim_T *pim) |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4285 { |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4286 int col; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4287 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4288 if (sub->in_use <= 0) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4289 col = -1; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4290 else if (REG_MULTI) |
6547 | 4291 col = sub->list.multi[0].start_col; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4292 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4293 col = (int)(sub->list.line[0].start - rex.line); |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4294 nfa_set_code(state->c); |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4295 if (log_fd == NULL) |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4296 open_debug_log(MAYBE); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
4297 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4298 fprintf(log_fd, "> %s state %d to list %d. char %d: %s (start col %d)%s\n", |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4299 action, abs(state->id), lid, state->c, code, col, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4300 pim_info(pim)); |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4301 } |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4302 #endif |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4303 |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4304 /* |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4305 * Return TRUE if the same state is already in list "l" with the same |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4306 * positions as "subs". |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4307 */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4308 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4309 has_state_with_pos( |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4310 nfa_list_T *l, // runtime state list |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4311 nfa_state_T *state, // state to update |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4312 regsubs_T *subs, // pointers to subexpressions |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4313 nfa_pim_T *pim) // postponed match or NULL |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4314 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4315 nfa_thread_T *thread; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4316 int i; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4317 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4318 for (i = 0; i < l->n; ++i) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4319 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4320 thread = &l->t[i]; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4321 if (thread->state->id == state->id |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4322 && sub_equal(&thread->subs.norm, &subs->norm) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4323 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4324 && (!rex.nfa_has_zsubexpr |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4325 || sub_equal(&thread->subs.synt, &subs->synt)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4326 #endif |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4327 && pim_equal(&thread->pim, pim)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4328 return TRUE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4329 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4330 return FALSE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4331 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4332 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4333 /* |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4334 * Return TRUE if "one" and "two" are equal. That includes when both are not |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4335 * set. |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4336 */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4337 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4338 pim_equal(nfa_pim_T *one, nfa_pim_T *two) |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4339 { |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4340 int one_unused = (one == NULL || one->result == NFA_PIM_UNUSED); |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4341 int two_unused = (two == NULL || two->result == NFA_PIM_UNUSED); |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4342 |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4343 if (one_unused) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4344 // one is unused: equal when two is also unused |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4345 return two_unused; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4346 if (two_unused) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4347 // one is used and two is not: not equal |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4348 return FALSE; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4349 // compare the state id |
5298 | 4350 if (one->state->id != two->state->id) |
4351 return FALSE; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4352 // compare the position |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4353 if (REG_MULTI) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4354 return one->end.pos.lnum == two->end.pos.lnum |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4355 && one->end.pos.col == two->end.pos.col; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4356 return one->end.ptr == two->end.ptr; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4357 } |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4358 |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4359 /* |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4360 * Return TRUE if "state" leads to a NFA_MATCH without advancing the input. |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4361 */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4362 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4363 match_follows(nfa_state_T *startstate, int depth) |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4364 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4365 nfa_state_T *state = startstate; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4366 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4367 // avoid too much recursion |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4368 if (depth > 10) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4369 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4370 |
5184
c6dd0c545e5c
updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents:
5074
diff
changeset
|
4371 while (state != NULL) |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4372 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4373 switch (state->c) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4374 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4375 case NFA_MATCH: |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4376 case NFA_MCLOSE: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4377 case NFA_END_INVISIBLE: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4378 case NFA_END_INVISIBLE_NEG: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4379 case NFA_END_PATTERN: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4380 return TRUE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4381 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4382 case NFA_SPLIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4383 return match_follows(state->out, depth + 1) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4384 || match_follows(state->out1, depth + 1); |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4385 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4386 case NFA_START_INVISIBLE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4387 case NFA_START_INVISIBLE_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4388 case NFA_START_INVISIBLE_BEFORE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4389 case NFA_START_INVISIBLE_BEFORE_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4390 case NFA_START_INVISIBLE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4391 case NFA_START_INVISIBLE_NEG_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4392 case NFA_START_INVISIBLE_BEFORE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4393 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4394 case NFA_COMPOSING: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4395 // skip ahead to next state |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4396 state = state->out1->out; |
5184
c6dd0c545e5c
updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents:
5074
diff
changeset
|
4397 continue; |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4398 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4399 case NFA_ANY: |
5901 | 4400 case NFA_ANY_COMPOSING: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4401 case NFA_IDENT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4402 case NFA_SIDENT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4403 case NFA_KWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4404 case NFA_SKWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4405 case NFA_FNAME: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4406 case NFA_SFNAME: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4407 case NFA_PRINT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4408 case NFA_SPRINT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4409 case NFA_WHITE: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4410 case NFA_NWHITE: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4411 case NFA_DIGIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4412 case NFA_NDIGIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4413 case NFA_HEX: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4414 case NFA_NHEX: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4415 case NFA_OCTAL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4416 case NFA_NOCTAL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4417 case NFA_WORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4418 case NFA_NWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4419 case NFA_HEAD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4420 case NFA_NHEAD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4421 case NFA_ALPHA: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4422 case NFA_NALPHA: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4423 case NFA_LOWER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4424 case NFA_NLOWER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4425 case NFA_UPPER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4426 case NFA_NUPPER: |
5296 | 4427 case NFA_LOWER_IC: |
4428 case NFA_NLOWER_IC: | |
4429 case NFA_UPPER_IC: | |
4430 case NFA_NUPPER_IC: | |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4431 case NFA_START_COLL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4432 case NFA_START_NEG_COLL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4433 case NFA_NEWL: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4434 // state will advance input |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4435 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4436 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4437 default: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4438 if (state->c > 0) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4439 // state will advance input |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4440 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4441 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4442 // Others: zero-width or possibly zero-width, might still find |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4443 // a match at the same position, keep looking. |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4444 break; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4445 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4446 state = state->out; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4447 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4448 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4449 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4450 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4451 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4452 /* |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4453 * Return TRUE if "state" is already in list "l". |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4454 */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4455 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4456 state_in_list( |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4457 nfa_list_T *l, // runtime state list |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4458 nfa_state_T *state, // state to update |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4459 regsubs_T *subs) // pointers to subexpressions |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4460 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4461 if (state->lastlist[nfa_ll_index] == l->id) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4462 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4463 if (!rex.nfa_has_backref || has_state_with_pos(l, state, subs, NULL)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4464 return TRUE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4465 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4466 return FALSE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4467 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4468 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4469 // Offset used for "off" by addstate_here(). |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4470 #define ADDSTATE_HERE_OFFSET 10 |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4471 |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4472 /* |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4473 * Add "state" and possibly what follows to state list ".". |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4474 * Returns "subs_arg", possibly copied into temp_subs. |
29191
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4475 * Returns NULL when recursiveness is too deep or timed out. |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4476 */ |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4477 static regsubs_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4478 addstate( |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4479 nfa_list_T *l, // runtime state list |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4480 nfa_state_T *state, // state to update |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4481 regsubs_T *subs_arg, // pointers to subexpressions |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4482 nfa_pim_T *pim, // postponed look-behind match |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4483 int off_arg) // byte offset, when -1 go to next line |
4444 | 4484 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4485 int subidx; |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4486 int off = off_arg; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4487 int add_here = FALSE; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4488 int listindex = 0; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4489 int k; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4490 int found = FALSE; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4491 nfa_thread_T *thread; |
10168
3c37899baa8d
commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4492 struct multipos save_multipos; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4493 int save_in_use; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4494 char_u *save_ptr; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4495 int i; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4496 regsub_T *sub; |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4497 regsubs_T *subs = subs_arg; |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4498 static regsubs_T temp_subs; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4499 #ifdef ENABLE_LOG |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4500 int did_print = FALSE; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4501 #endif |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4502 static int depth = 0; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4503 |
29191
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4504 #ifdef FEAT_RELTIME |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4505 if (nfa_did_time_out()) |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4506 return NULL; |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4507 #endif |
0af5fe160e4e
patch 8.2.5115: search timeout is overrun with some patterns
Bram Moolenaar <Bram@vim.org>
parents:
29071
diff
changeset
|
4508 |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4509 // This function is called recursively. When the depth is too much we run |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4510 // out of stack and crash, limit recursiveness here. |
15800
483fda269100
patch 8.1.0907: CI tests on AppVeyor are failing
Bram Moolenaar <Bram@vim.org>
parents:
15796
diff
changeset
|
4511 if (++depth >= 5000 || subs == NULL) |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4512 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4513 --depth; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4514 return NULL; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4515 } |
4444 | 4516 |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4517 if (off_arg <= -ADDSTATE_HERE_OFFSET) |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4518 { |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4519 add_here = TRUE; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4520 off = 0; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4521 listindex = -(off_arg + ADDSTATE_HERE_OFFSET); |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4522 } |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4523 |
4444 | 4524 switch (state->c) |
4525 { | |
4526 case NFA_NCLOSE: | |
4527 case NFA_MCLOSE: | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4528 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4529 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4530 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4531 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4532 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4533 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4534 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4535 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4536 case NFA_MCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4537 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4538 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4539 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4540 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4541 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4542 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4543 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4544 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4545 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4546 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4547 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4548 #endif |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4549 case NFA_MOPEN: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
4550 case NFA_ZEND: |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4551 case NFA_SPLIT: |
5370 | 4552 case NFA_EMPTY: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4553 // These nodes are not added themselves but their "out" and/or |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4554 // "out1" may be added below. |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4555 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4556 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4557 case NFA_BOL: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4558 case NFA_BOF: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4559 // "^" won't match past end-of-line, don't bother trying. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4560 // Except when at the end of the line, or when we are going to the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4561 // next line for a look-behind match. |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4562 if (rex.input > rex.line |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4563 && *rex.input != NUL |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4564 && (nfa_endp == NULL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4565 || !REG_MULTI |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4566 || rex.lnum == nfa_endp->se_u.pos.lnum)) |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4567 goto skip_add; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4568 // FALLTHROUGH |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4569 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4570 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4571 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4572 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4573 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4574 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4575 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4576 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4577 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4578 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4579 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4580 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4581 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4582 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4583 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4584 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4585 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4586 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4587 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4588 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4589 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4590 #endif |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4591 case NFA_NOPEN: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
4592 case NFA_ZSTART: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4593 // These nodes need to be added so that we can bail out when it |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4594 // was added to this list before at the same position to avoid an |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4595 // endless loop for "\(\)*" |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
4596 |
4444 | 4597 default: |
5502 | 4598 if (state->lastlist[nfa_ll_index] == l->id && state->c != NFA_SKIP) |
4444 | 4599 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4600 // This state is already in the list, don't add it again, |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4601 // unless it is an MOPEN that is used for a backreference or |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4602 // when there is a PIM. For NFA_MATCH check the position, |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4603 // lower position is preferred. |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4604 if (!rex.nfa_has_backref && pim == NULL && !l->has_pim |
5895 | 4605 && state->c != NFA_MATCH) |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4606 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4607 // When called from addstate_here() do insert before |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4608 // existing states. |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4609 if (add_here) |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4610 { |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4611 for (k = 0; k < l->n && k < listindex; ++k) |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4612 if (l->t[k].state->id == state->id) |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4613 { |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4614 found = TRUE; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4615 break; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4616 } |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4617 } |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4618 if (!add_here || found) |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4619 { |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4620 skip_add: |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4621 #ifdef ENABLE_LOG |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4622 nfa_set_code(state->c); |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4623 fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s pim: %s has_pim: %d found: %d\n", |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4624 abs(state->id), l->id, state->c, code, |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4625 pim == NULL ? "NULL" : "yes", l->has_pim, found); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4626 #endif |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4627 --depth; |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4628 return subs; |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4629 } |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4630 } |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4631 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4632 // Do not add the state again when it exists with the same |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4633 // positions. |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4634 if (has_state_with_pos(l, state, subs, pim)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4635 goto skip_add; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4636 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4637 |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4638 // When there are backreferences or PIMs the number of states may |
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4639 // be (a lot) bigger than anticipated. |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4640 if (l->n == l->len) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4641 { |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4642 int newlen = l->len * 3 / 2 + 50; |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4643 size_t newsize = newlen * sizeof(nfa_thread_T); |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4644 nfa_thread_T *newt; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4645 |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4646 if ((long)(newsize >> 10) >= p_mmp) |
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4647 { |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4648 emsg(_(e_pattern_uses_more_memory_than_maxmempattern)); |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4649 --depth; |
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4650 return NULL; |
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4651 } |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4652 if (subs != &temp_subs) |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4653 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4654 // "subs" may point into the current array, need to make a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4655 // copy before it becomes invalid. |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4656 copy_sub(&temp_subs.norm, &subs->norm); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4657 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4658 if (rex.nfa_has_zsubexpr) |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4659 copy_sub(&temp_subs.synt, &subs->synt); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4660 #endif |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4661 subs = &temp_subs; |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4662 } |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4663 |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4664 newt = vim_realloc(l->t, newsize); |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4665 if (newt == NULL) |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4666 { |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4667 // out of memory |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4668 --depth; |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4669 return NULL; |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4670 } |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4671 l->t = newt; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4672 l->len = newlen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4673 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4674 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4675 // add the state to the list |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4676 state->lastlist[nfa_ll_index] = l->id; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4677 thread = &l->t[l->n++]; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4678 thread->state = state; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4679 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4680 thread->pim.result = NFA_PIM_UNUSED; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4681 else |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4682 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4683 copy_pim(&thread->pim, pim); |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4684 l->has_pim = TRUE; |
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4685 } |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4686 copy_sub(&thread->subs.norm, &subs->norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4687 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4688 if (rex.nfa_has_zsubexpr) |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4689 copy_sub(&thread->subs.synt, &subs->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4690 #endif |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4691 #ifdef ENABLE_LOG |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4692 report_state("Adding", &thread->subs.norm, state, l->id, pim); |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4693 did_print = TRUE; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4694 #endif |
4444 | 4695 } |
4696 | |
4697 #ifdef ENABLE_LOG | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4698 if (!did_print) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4699 report_state("Processing", &subs->norm, state, l->id, pim); |
4444 | 4700 #endif |
4701 switch (state->c) | |
4702 { | |
4703 case NFA_MATCH: | |
4704 break; | |
4705 | |
4706 case NFA_SPLIT: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4707 // order matters here |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4708 subs = addstate(l, state->out, subs, pim, off_arg); |
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4709 subs = addstate(l, state->out1, subs, pim, off_arg); |
4444 | 4710 break; |
4711 | |
5370 | 4712 case NFA_EMPTY: |
4444 | 4713 case NFA_NOPEN: |
4714 case NFA_NCLOSE: | |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4715 subs = addstate(l, state->out, subs, pim, off_arg); |
4444 | 4716 break; |
4717 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4718 case NFA_MOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4719 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4720 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4721 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4722 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4723 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4724 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4725 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4726 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4727 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4728 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4729 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4730 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4731 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4732 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4733 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4734 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4735 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4736 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4737 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4738 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4739 #endif |
4444 | 4740 case NFA_ZSTART: |
4741 if (state->c == NFA_ZSTART) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4742 { |
4444 | 4743 subidx = 0; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4744 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4745 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4746 #ifdef FEAT_SYN_HL |
5300 | 4747 else if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4748 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4749 subidx = state->c - NFA_ZOPEN; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4750 sub = &subs->synt; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4751 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4752 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4753 else |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4754 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4755 subidx = state->c - NFA_MOPEN; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4756 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4757 } |
4444 | 4758 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4759 // avoid compiler warnings |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4760 save_ptr = NULL; |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
4761 CLEAR_FIELD(save_multipos); |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4762 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4763 // Set the position (with "off" added) in the subexpression. Save |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4764 // and restore it when it was in use. Otherwise fill any gap. |
4444 | 4765 if (REG_MULTI) |
4766 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4767 if (subidx < sub->in_use) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4768 { |
10168
3c37899baa8d
commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4769 save_multipos = sub->list.multi[subidx]; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4770 save_in_use = -1; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4771 } |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4772 else |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4773 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4774 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4775 for (i = sub->in_use; i < subidx; ++i) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4776 { |
6547 | 4777 sub->list.multi[i].start_lnum = -1; |
4778 sub->list.multi[i].end_lnum = -1; | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4779 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4780 sub->in_use = subidx + 1; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4781 } |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4782 if (off == -1) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4783 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4784 sub->list.multi[subidx].start_lnum = rex.lnum + 1; |
6547 | 4785 sub->list.multi[subidx].start_col = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4786 } |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4787 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4788 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4789 sub->list.multi[subidx].start_lnum = rex.lnum; |
6547 | 4790 sub->list.multi[subidx].start_col = |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4791 (colnr_T)(rex.input - rex.line + off); |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4792 } |
7152
cbdc02d71a18
commit https://github.com/vim/vim/commit/c2b717ebd6719e722dcb5f10e4c74033a53ff7c7
Christian Brabandt <cb@256bit.org>
parents:
6914
diff
changeset
|
4793 sub->list.multi[subidx].end_lnum = -1; |
4444 | 4794 } |
4795 else | |
4796 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4797 if (subidx < sub->in_use) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4798 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4799 save_ptr = sub->list.line[subidx].start; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4800 save_in_use = -1; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4801 } |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4802 else |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4803 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4804 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4805 for (i = sub->in_use; i < subidx; ++i) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4806 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4807 sub->list.line[i].start = NULL; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4808 sub->list.line[i].end = NULL; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4809 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4810 sub->in_use = subidx + 1; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4811 } |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4812 sub->list.line[subidx].start = rex.input + off; |
4444 | 4813 } |
4814 | |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4815 subs = addstate(l, state->out, subs, pim, off_arg); |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4816 if (subs == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4817 break; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4818 // "subs" may have changed, need to set "sub" again |
5300 | 4819 #ifdef FEAT_SYN_HL |
4820 if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) | |
4821 sub = &subs->synt; | |
4822 else | |
4823 #endif | |
4824 sub = &subs->norm; | |
4444 | 4825 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4826 if (save_in_use == -1) |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4827 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4828 if (REG_MULTI) |
10168
3c37899baa8d
commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4829 sub->list.multi[subidx] = save_multipos; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4830 else |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4831 sub->list.line[subidx].start = save_ptr; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4832 } |
4444 | 4833 else |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4834 sub->in_use = save_in_use; |
4444 | 4835 break; |
4836 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4837 case NFA_MCLOSE: |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4838 if (rex.nfa_has_zend && (REG_MULTI |
6547 | 4839 ? subs->norm.list.multi[0].end_lnum >= 0 |
5336 | 4840 : subs->norm.list.line[0].end != NULL)) |
4444 | 4841 { |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4842 // Do not overwrite the position set by \ze. |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4843 subs = addstate(l, state->out, subs, pim, off_arg); |
4444 | 4844 break; |
4845 } | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4846 // FALLTHROUGH |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4847 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4848 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4849 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4850 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4851 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4852 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4853 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4854 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4855 case NFA_MCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4856 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4857 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4858 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4859 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4860 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4861 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4862 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4863 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4864 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4865 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4866 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4867 #endif |
4444 | 4868 case NFA_ZEND: |
4869 if (state->c == NFA_ZEND) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4870 { |
4444 | 4871 subidx = 0; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4872 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4873 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4874 #ifdef FEAT_SYN_HL |
5300 | 4875 else if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4876 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4877 subidx = state->c - NFA_ZCLOSE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4878 sub = &subs->synt; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4879 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4880 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4881 else |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4882 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4883 subidx = state->c - NFA_MCLOSE; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4884 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4885 } |
4444 | 4886 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4887 // We don't fill in gaps here, there must have been an MOPEN that |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4888 // has done that. |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4889 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4890 if (sub->in_use <= subidx) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4891 sub->in_use = subidx + 1; |
4444 | 4892 if (REG_MULTI) |
4893 { | |
10168
3c37899baa8d
commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4894 save_multipos = sub->list.multi[subidx]; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4895 if (off == -1) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4896 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4897 sub->list.multi[subidx].end_lnum = rex.lnum + 1; |
6547 | 4898 sub->list.multi[subidx].end_col = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4899 } |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4900 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4901 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4902 sub->list.multi[subidx].end_lnum = rex.lnum; |
6547 | 4903 sub->list.multi[subidx].end_col = |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4904 (colnr_T)(rex.input - rex.line + off); |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4905 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4906 // avoid compiler warnings |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4907 save_ptr = NULL; |
4444 | 4908 } |
4909 else | |
4910 { | |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4911 save_ptr = sub->list.line[subidx].end; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
4912 sub->list.line[subidx].end = rex.input + off; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4913 // avoid compiler warnings |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19405
diff
changeset
|
4914 CLEAR_FIELD(save_multipos); |
4444 | 4915 } |
4916 | |
10170
4acacf4081ce
commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents:
10168
diff
changeset
|
4917 subs = addstate(l, state->out, subs, pim, off_arg); |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4918 if (subs == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4919 break; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4920 // "subs" may have changed, need to set "sub" again |
5300 | 4921 #ifdef FEAT_SYN_HL |
4922 if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) | |
4923 sub = &subs->synt; | |
4924 else | |
4925 #endif | |
4926 sub = &subs->norm; | |
4444 | 4927 |
4928 if (REG_MULTI) | |
10168
3c37899baa8d
commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
4929 sub->list.multi[subidx] = save_multipos; |
4444 | 4930 else |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4931 sub->list.line[subidx].end = save_ptr; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4932 sub->in_use = save_in_use; |
4444 | 4933 break; |
4934 } | |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4935 --depth; |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4936 return subs; |
4444 | 4937 } |
4938 | |
4939 /* | |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4940 * Like addstate(), but the new state(s) are put at position "*ip". |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4941 * Used for zero-width matches, next state to use is the added one. |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4942 * This makes sure the order of states to be tried does not change, which |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4943 * matters for alternatives. |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4944 */ |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4945 static regsubs_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4946 addstate_here( |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4947 nfa_list_T *l, // runtime state list |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4948 nfa_state_T *state, // state to update |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4949 regsubs_T *subs, // pointers to subexpressions |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4950 nfa_pim_T *pim, // postponed look-behind match |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4951 int *ip) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4952 { |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4953 int tlen = l->n; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4954 int count; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4955 int listidx = *ip; |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4956 regsubs_T *r; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4957 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4958 // First add the state(s) at the end, so that we know how many there are. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4959 // Pass the listidx as offset (avoids adding another argument to |
26771
fc859aea8cec
patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents:
26652
diff
changeset
|
4960 // addstate()). |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4961 r = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET); |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4962 if (r == NULL) |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4963 return NULL; |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4964 |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4965 // when "*ip" was at the end of the list, nothing to do |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4966 if (listidx + 1 == tlen) |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4967 return r; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4968 |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4969 // re-order to put the new state at the current position |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4970 count = l->n - tlen; |
4924
6ae32a64e153
updated for version 7.3.1207
Bram Moolenaar <bram@vim.org>
parents:
4897
diff
changeset
|
4971 if (count == 0) |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4972 return r; // no state got added |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4973 if (count == 1) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4974 { |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
4975 // overwrite the current state |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4976 l->t[listidx] = l->t[l->n - 1]; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4977 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4978 else if (count > 1) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4979 { |
5058
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4980 if (l->n + count - 1 >= l->len) |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4981 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4982 // not enough space to move the new states, reallocate the list |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
4983 // and move the states to the right position |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4984 int newlen = l->len * 3 / 2 + 50; |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4985 size_t newsize = newlen * sizeof(nfa_thread_T); |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4986 nfa_thread_T *newl; |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4987 |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4988 if ((long)(newsize >> 10) >= p_mmp) |
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4989 { |
26883
7f150a4936f2
patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26771
diff
changeset
|
4990 emsg(_(e_pattern_uses_more_memory_than_maxmempattern)); |
15812
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4991 return NULL; |
3808b583889e
patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents:
15806
diff
changeset
|
4992 } |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
4993 newl = alloc(newsize); |
5058
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4994 if (newl == NULL) |
15806
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4995 return NULL; |
6a4e9d9f1d66
patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents:
15802
diff
changeset
|
4996 l->len = newlen; |
5058
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4997 mch_memmove(&(newl[0]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4998 &(l->t[0]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4999 sizeof(nfa_thread_T) * listidx); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5000 mch_memmove(&(newl[listidx]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5001 &(l->t[l->n - count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5002 sizeof(nfa_thread_T) * count); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5003 mch_memmove(&(newl[listidx + count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5004 &(l->t[listidx + 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5005 sizeof(nfa_thread_T) * (l->n - count - listidx - 1)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5006 vim_free(l->t); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5007 l->t = newl; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5008 } |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5009 else |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5010 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5011 // make space for new states, then move them from the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5012 // end to the current position |
5058
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5013 mch_memmove(&(l->t[listidx + count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5014 &(l->t[listidx + 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5015 sizeof(nfa_thread_T) * (l->n - listidx - 1)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5016 mch_memmove(&(l->t[listidx]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5017 &(l->t[l->n - 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5018 sizeof(nfa_thread_T) * count); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
5019 } |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5020 } |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5021 --l->n; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5022 *ip = listidx - 1; |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5023 |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5024 return r; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5025 } |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5026 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5027 /* |
4444 | 5028 * Check character class "class" against current character c. |
5029 */ | |
5030 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5031 check_char_class(int class, int c) |
4444 | 5032 { |
5033 switch (class) | |
5034 { | |
5035 case NFA_CLASS_ALNUM: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
5036 if (c >= 1 && c < 128 && isalnum(c)) |
4444 | 5037 return OK; |
5038 break; | |
5039 case NFA_CLASS_ALPHA: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
5040 if (c >= 1 && c < 128 && isalpha(c)) |
4444 | 5041 return OK; |
5042 break; | |
5043 case NFA_CLASS_BLANK: | |
5044 if (c == ' ' || c == '\t') | |
5045 return OK; | |
5046 break; | |
5047 case NFA_CLASS_CNTRL: | |
11267
588de97b40e7
patch 8.0.0519: character classes are not well tested
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
5048 if (c >= 1 && c <= 127 && iscntrl(c)) |
4444 | 5049 return OK; |
5050 break; | |
5051 case NFA_CLASS_DIGIT: | |
5052 if (VIM_ISDIGIT(c)) | |
5053 return OK; | |
5054 break; | |
5055 case NFA_CLASS_GRAPH: | |
11267
588de97b40e7
patch 8.0.0519: character classes are not well tested
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
5056 if (c >= 1 && c <= 127 && isgraph(c)) |
4444 | 5057 return OK; |
5058 break; | |
5059 case NFA_CLASS_LOWER: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
5060 if (MB_ISLOWER(c) && c != 170 && c != 186) |
4444 | 5061 return OK; |
5062 break; | |
5063 case NFA_CLASS_PRINT: | |
5064 if (vim_isprintc(c)) | |
5065 return OK; | |
5066 break; | |
5067 case NFA_CLASS_PUNCT: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
5068 if (c >= 1 && c < 128 && ispunct(c)) |
4444 | 5069 return OK; |
5070 break; | |
5071 case NFA_CLASS_SPACE: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5072 if ((c >= 9 && c <= 13) || (c == ' ')) |
4444 | 5073 return OK; |
5074 break; | |
5075 case NFA_CLASS_UPPER: | |
5076 if (MB_ISUPPER(c)) | |
5077 return OK; | |
5078 break; | |
5079 case NFA_CLASS_XDIGIT: | |
5080 if (vim_isxdigit(c)) | |
5081 return OK; | |
5082 break; | |
5083 case NFA_CLASS_TAB: | |
5084 if (c == '\t') | |
5085 return OK; | |
5086 break; | |
5087 case NFA_CLASS_RETURN: | |
5088 if (c == '\r') | |
5089 return OK; | |
5090 break; | |
5091 case NFA_CLASS_BACKSPACE: | |
5092 if (c == '\b') | |
5093 return OK; | |
5094 break; | |
5095 case NFA_CLASS_ESCAPE: | |
5096 if (c == '\033') | |
5097 return OK; | |
5098 break; | |
15709
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5099 case NFA_CLASS_IDENT: |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5100 if (vim_isIDc(c)) |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5101 return OK; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5102 break; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5103 case NFA_CLASS_KEYWORD: |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5104 if (reg_iswordc(c)) |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5105 return OK; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5106 break; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5107 case NFA_CLASS_FNAME: |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5108 if (vim_isfilec(c)) |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5109 return OK; |
2e2f07561f4b
patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents:
15603
diff
changeset
|
5110 break; |
4444 | 5111 |
5112 default: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5113 // should not be here :P |
26962
85866e069c24
patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26958
diff
changeset
|
5114 siemsg(_(e_nfa_regexp_invalid_character_class_nr), class); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
5115 return FAIL; |
4444 | 5116 } |
5117 return FAIL; | |
5118 } | |
5119 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5120 /* |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5121 * Check for a match with subexpression "subidx". |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5122 * Return TRUE if it matches. |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5123 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5124 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5125 match_backref( |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5126 regsub_T *sub, // pointers to subexpressions |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5127 int subidx, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5128 int *bytelen) // out: length of match in bytes |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5129 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5130 int len; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5131 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5132 if (sub->in_use <= subidx) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5133 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5134 retempty: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5135 // backref was not set, match an empty string |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5136 *bytelen = 0; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5137 return TRUE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5138 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5139 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5140 if (REG_MULTI) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5141 { |
6547 | 5142 if (sub->list.multi[subidx].start_lnum < 0 |
5143 || sub->list.multi[subidx].end_lnum < 0) | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5144 goto retempty; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5145 if (sub->list.multi[subidx].start_lnum == rex.lnum |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5146 && sub->list.multi[subidx].end_lnum == rex.lnum) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5147 { |
6547 | 5148 len = sub->list.multi[subidx].end_col |
5149 - sub->list.multi[subidx].start_col; | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5150 if (cstrncmp(rex.line + sub->list.multi[subidx].start_col, |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5151 rex.input, &len) == 0) |
4891
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5152 { |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5153 *bytelen = len; |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5154 return TRUE; |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5155 } |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5156 } |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5157 else |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5158 { |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5159 if (match_with_backref( |
6547 | 5160 sub->list.multi[subidx].start_lnum, |
5161 sub->list.multi[subidx].start_col, | |
5162 sub->list.multi[subidx].end_lnum, | |
5163 sub->list.multi[subidx].end_col, | |
4891
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5164 bytelen) == RA_MATCH) |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
5165 return TRUE; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5166 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5167 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5168 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5169 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
5170 if (sub->list.line[subidx].start == NULL |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
5171 || sub->list.line[subidx].end == NULL) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5172 goto retempty; |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
5173 len = (int)(sub->list.line[subidx].end - sub->list.line[subidx].start); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5174 if (cstrncmp(sub->list.line[subidx].start, rex.input, &len) == 0) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5175 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5176 *bytelen = len; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5177 return TRUE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5178 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5179 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5180 return FALSE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5181 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5182 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5183 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5184 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5185 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5186 * Check for a match with \z subexpression "subidx". |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5187 * Return TRUE if it matches. |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5188 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5189 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5190 match_zref( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5191 int subidx, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5192 int *bytelen) // out: length of match in bytes |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5193 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5194 int len; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5195 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5196 cleanup_zsubexpr(); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5197 if (re_extmatch_in == NULL || re_extmatch_in->matches[subidx] == NULL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5198 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5199 // backref was not set, match an empty string |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5200 *bytelen = 0; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5201 return TRUE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5202 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5203 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5204 len = (int)STRLEN(re_extmatch_in->matches[subidx]); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5205 if (cstrncmp(re_extmatch_in->matches[subidx], rex.input, &len) == 0) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5206 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5207 *bytelen = len; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5208 return TRUE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5209 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5210 return FALSE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5211 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5212 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5213 |
4444 | 5214 /* |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5215 * Save list IDs for all NFA states of "prog" into "list". |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5216 * Also reset the IDs to zero. |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5217 * Only used for the recursive value lastlist[1]. |
4444 | 5218 */ |
5219 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5220 nfa_save_listids(nfa_regprog_T *prog, int *list) |
4444 | 5221 { |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5222 int i; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5223 nfa_state_T *p; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5224 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5225 // Order in the list is reverse, it's a bit faster that way. |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5226 p = &prog->state[0]; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5227 for (i = prog->nstate; --i >= 0; ) |
4444 | 5228 { |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5229 list[i] = p->lastlist[1]; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5230 p->lastlist[1] = 0; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5231 ++p; |
4444 | 5232 } |
5233 } | |
5234 | |
5235 /* | |
5236 * Restore list IDs from "list" to all NFA states. | |
5237 */ | |
5238 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5239 nfa_restore_listids(nfa_regprog_T *prog, int *list) |
4444 | 5240 { |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5241 int i; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5242 nfa_state_T *p; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5243 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5244 p = &prog->state[0]; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5245 for (i = prog->nstate; --i >= 0; ) |
4444 | 5246 { |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5247 p->lastlist[1] = list[i]; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5248 ++p; |
4444 | 5249 } |
5250 } | |
5251 | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5252 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5253 nfa_re_num_cmp(long_u val, int op, long_u pos) |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5254 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5255 if (op == 1) return pos > val; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5256 if (op == 2) return pos < val; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5257 return val == pos; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5258 } |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5259 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5260 static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *submatch, regsubs_T *m); |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
5261 |
4444 | 5262 /* |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5263 * Recursively call nfa_regmatch() |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5264 * "pim" is NULL or contains info about a Postponed Invisible Match (start |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5265 * position). |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5266 */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5267 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5268 recursive_regmatch( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5269 nfa_state_T *state, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5270 nfa_pim_T *pim, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5271 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5272 regsubs_T *submatch, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5273 regsubs_T *m, |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
5274 int **listids, |
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
5275 int *listids_len) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5276 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5277 int save_reginput_col = (int)(rex.input - rex.line); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5278 int save_reglnum = rex.lnum; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5279 int save_nfa_match = nfa_match; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5280 int save_nfa_listid = rex.nfa_listid; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5281 save_se_T *save_nfa_endp = nfa_endp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5282 save_se_T endpos; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5283 save_se_T *endposp = NULL; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5284 int result; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5285 int need_restore = FALSE; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5286 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5287 if (pim != NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5288 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5289 // start at the position where the postponed match was |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5290 if (REG_MULTI) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5291 rex.input = rex.line + pim->end.pos.col; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5292 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5293 rex.input = pim->end.ptr; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5294 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5295 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5296 if (state->c == NFA_START_INVISIBLE_BEFORE |
13192
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
5297 || state->c == NFA_START_INVISIBLE_BEFORE_FIRST |
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
5298 || state->c == NFA_START_INVISIBLE_BEFORE_NEG |
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
5299 || state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5300 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5301 // The recursive match must end at the current position. When "pim" is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5302 // not NULL it specifies the current position. |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5303 endposp = &endpos; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5304 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5305 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5306 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5307 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5308 endpos.se_u.pos.col = (int)(rex.input - rex.line); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5309 endpos.se_u.pos.lnum = rex.lnum; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5310 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5311 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5312 endpos.se_u.pos = pim->end.pos; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5313 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5314 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5315 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5316 if (pim == NULL) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5317 endpos.se_u.ptr = rex.input; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5318 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5319 endpos.se_u.ptr = pim->end.ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5320 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5321 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5322 // Go back the specified number of bytes, or as far as the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5323 // start of the previous line, to try matching "\@<=" or |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5324 // not matching "\@<!". This is very inefficient, limit the number of |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5325 // bytes if possible. |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5326 if (state->val <= 0) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5327 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5328 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5329 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5330 rex.line = reg_getline(--rex.lnum); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5331 if (rex.line == NULL) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5332 // can't go before the first line |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5333 rex.line = reg_getline(++rex.lnum); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5334 } |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5335 rex.input = rex.line; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5336 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5337 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5338 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5339 if (REG_MULTI && (int)(rex.input - rex.line) < state->val) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5340 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5341 // Not enough bytes in this line, go to end of |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5342 // previous line. |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5343 rex.line = reg_getline(--rex.lnum); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5344 if (rex.line == NULL) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5345 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5346 // can't go before the first line |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5347 rex.line = reg_getline(++rex.lnum); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5348 rex.input = rex.line; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5349 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5350 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5351 rex.input = rex.line + STRLEN(rex.line); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5352 } |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5353 if ((int)(rex.input - rex.line) >= state->val) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5354 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5355 rex.input -= state->val; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5356 if (has_mbyte) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5357 rex.input -= mb_head_off(rex.line, rex.input); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5358 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5359 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5360 rex.input = rex.line; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5361 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5362 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5363 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5364 #ifdef ENABLE_LOG |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5365 if (log_fd != stderr) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5366 fclose(log_fd); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5367 log_fd = NULL; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5368 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5369 // Have to clear the lastlist field of the NFA nodes, so that |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5370 // nfa_regmatch() and addstate() can run properly after recursion. |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5371 if (nfa_ll_index == 1) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5372 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5373 // Already calling nfa_regmatch() recursively. Save the lastlist[1] |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5374 // values and clear them. |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5375 if (*listids == NULL || *listids_len < prog->nstate) |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5376 { |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
5377 vim_free(*listids); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
5378 *listids = ALLOC_MULT(int, prog->nstate); |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5379 if (*listids == NULL) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5380 { |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26962
diff
changeset
|
5381 emsg(_(e_nfa_regexp_could_not_allocate_memory_for_branch_traversal)); |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5382 return 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5383 } |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5384 *listids_len = prog->nstate; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5385 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5386 nfa_save_listids(prog, *listids); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5387 need_restore = TRUE; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5388 // any value of rex.nfa_listid will do |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5389 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5390 else |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5391 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5392 // First recursive nfa_regmatch() call, switch to the second lastlist |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5393 // entry. Make sure rex.nfa_listid is different from a previous |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5394 // recursive call, because some states may still have this ID. |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5395 ++nfa_ll_index; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5396 if (rex.nfa_listid <= rex.nfa_alt_listid) |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5397 rex.nfa_listid = rex.nfa_alt_listid; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5398 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5399 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5400 // Call nfa_regmatch() to check if the current concat matches at this |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5401 // position. The concat ends with the node NFA_END_INVISIBLE |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5402 nfa_endp = endposp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5403 result = nfa_regmatch(prog, state->out, submatch, m); |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5404 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5405 if (need_restore) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5406 nfa_restore_listids(prog, *listids); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5407 else |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5408 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5409 --nfa_ll_index; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5410 rex.nfa_alt_listid = rex.nfa_listid; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5411 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5412 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5413 // restore position in input text |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5414 rex.lnum = save_reglnum; |
4877
9e36c6b1ebf4
updated for version 7.3.1184
Bram Moolenaar <bram@vim.org>
parents:
4845
diff
changeset
|
5415 if (REG_MULTI) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5416 rex.line = reg_getline(rex.lnum); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5417 rex.input = rex.line + save_reginput_col; |
9371
3666915cac0b
commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents:
9015
diff
changeset
|
5418 if (result != NFA_TOO_EXPENSIVE) |
3666915cac0b
commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents:
9015
diff
changeset
|
5419 { |
3666915cac0b
commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents:
9015
diff
changeset
|
5420 nfa_match = save_nfa_match; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5421 rex.nfa_listid = save_nfa_listid; |
9371
3666915cac0b
commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents:
9015
diff
changeset
|
5422 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5423 nfa_endp = save_nfa_endp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5424 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5425 #ifdef ENABLE_LOG |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5426 open_debug_log(result); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5427 #endif |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5428 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5429 return result; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5430 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5431 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5432 /* |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5433 * Estimate the chance of a match with "state" failing. |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5434 * empty match: 0 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5435 * NFA_ANY: 1 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5436 * specific character: 99 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5437 */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5438 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5439 failure_chance(nfa_state_T *state, int depth) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5440 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5441 int c = state->c; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5442 int l, r; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5443 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5444 // detect looping |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5445 if (depth > 4) |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5446 return 1; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5447 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5448 switch (c) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5449 { |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5450 case NFA_SPLIT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5451 if (state->out->c == NFA_SPLIT || state->out1->c == NFA_SPLIT) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5452 // avoid recursive stuff |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5453 return 1; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5454 // two alternatives, use the lowest failure chance |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5455 l = failure_chance(state->out, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5456 r = failure_chance(state->out1, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5457 return l < r ? l : r; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5458 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5459 case NFA_ANY: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5460 // matches anything, unlikely to fail |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5461 return 1; |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5462 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5463 case NFA_MATCH: |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5464 case NFA_MCLOSE: |
5901 | 5465 case NFA_ANY_COMPOSING: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5466 // empty match works always |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5467 return 0; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5468 |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5469 case NFA_START_INVISIBLE: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5470 case NFA_START_INVISIBLE_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5471 case NFA_START_INVISIBLE_NEG: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5472 case NFA_START_INVISIBLE_NEG_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5473 case NFA_START_INVISIBLE_BEFORE: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5474 case NFA_START_INVISIBLE_BEFORE_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5475 case NFA_START_INVISIBLE_BEFORE_NEG: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5476 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5477 case NFA_START_PATTERN: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5478 // recursive regmatch is expensive, use low failure chance |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5479 return 5; |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5480 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5481 case NFA_BOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5482 case NFA_EOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5483 case NFA_BOF: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5484 case NFA_EOF: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5485 case NFA_NEWL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5486 return 99; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5487 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5488 case NFA_BOW: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5489 case NFA_EOW: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5490 return 90; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5491 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5492 case NFA_MOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5493 case NFA_MOPEN1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5494 case NFA_MOPEN2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5495 case NFA_MOPEN3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5496 case NFA_MOPEN4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5497 case NFA_MOPEN5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5498 case NFA_MOPEN6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5499 case NFA_MOPEN7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5500 case NFA_MOPEN8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5501 case NFA_MOPEN9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5502 #ifdef FEAT_SYN_HL |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5503 case NFA_ZOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5504 case NFA_ZOPEN1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5505 case NFA_ZOPEN2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5506 case NFA_ZOPEN3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5507 case NFA_ZOPEN4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5508 case NFA_ZOPEN5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5509 case NFA_ZOPEN6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5510 case NFA_ZOPEN7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5511 case NFA_ZOPEN8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5512 case NFA_ZOPEN9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5513 case NFA_ZCLOSE: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5514 case NFA_ZCLOSE1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5515 case NFA_ZCLOSE2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5516 case NFA_ZCLOSE3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5517 case NFA_ZCLOSE4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5518 case NFA_ZCLOSE5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5519 case NFA_ZCLOSE6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5520 case NFA_ZCLOSE7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5521 case NFA_ZCLOSE8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5522 case NFA_ZCLOSE9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5523 #endif |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5524 case NFA_NOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5525 case NFA_MCLOSE1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5526 case NFA_MCLOSE2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5527 case NFA_MCLOSE3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5528 case NFA_MCLOSE4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5529 case NFA_MCLOSE5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5530 case NFA_MCLOSE6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5531 case NFA_MCLOSE7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5532 case NFA_MCLOSE8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5533 case NFA_MCLOSE9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5534 case NFA_NCLOSE: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5535 return failure_chance(state->out, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5536 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5537 case NFA_BACKREF1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5538 case NFA_BACKREF2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5539 case NFA_BACKREF3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5540 case NFA_BACKREF4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5541 case NFA_BACKREF5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5542 case NFA_BACKREF6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5543 case NFA_BACKREF7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5544 case NFA_BACKREF8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5545 case NFA_BACKREF9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5546 #ifdef FEAT_SYN_HL |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5547 case NFA_ZREF1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5548 case NFA_ZREF2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5549 case NFA_ZREF3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5550 case NFA_ZREF4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5551 case NFA_ZREF5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5552 case NFA_ZREF6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5553 case NFA_ZREF7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5554 case NFA_ZREF8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5555 case NFA_ZREF9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5556 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5557 // backreferences don't match in many places |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5558 return 94; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5559 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5560 case NFA_LNUM_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5561 case NFA_LNUM_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5562 case NFA_COL_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5563 case NFA_COL_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5564 case NFA_VCOL_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5565 case NFA_VCOL_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5566 case NFA_MARK_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5567 case NFA_MARK_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5568 case NFA_VISUAL: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5569 // before/after positions don't match very often |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5570 return 85; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5571 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5572 case NFA_LNUM: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5573 return 90; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5574 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5575 case NFA_CURSOR: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5576 case NFA_COL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5577 case NFA_VCOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5578 case NFA_MARK: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5579 // specific positions rarely match |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5580 return 98; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5581 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5582 case NFA_COMPOSING: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5583 return 95; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5584 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5585 default: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5586 if (c > 0) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5587 // character match fails often |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5588 return 95; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5589 } |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5590 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5591 // something else, includes character classes |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5592 return 50; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5593 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5594 |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5595 /* |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5596 * Skip until the char "c" we know a match must start with. |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5597 */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5598 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5599 skip_to_start(int c, colnr_T *colp) |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5600 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5601 char_u *s; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5602 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5603 // Used often, do some work to avoid call overhead. |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
5604 if (!rex.reg_ic && !has_mbyte) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5605 s = vim_strbyte(rex.line + *colp, c); |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5606 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5607 s = cstrchr(rex.line + *colp, c); |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5608 if (s == NULL) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5609 return FAIL; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5610 *colp = (int)(s - rex.line); |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5611 return OK; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5612 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5613 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5614 /* |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5615 * Check for a match with match_text. |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
5616 * Called after skip_to_start() has found regstart. |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5617 * Returns zero for no match, 1 for a match. |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5618 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5619 static long |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5620 find_match_text(colnr_T startcol, int regstart, char_u *match_text) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5621 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5622 colnr_T col = startcol; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5623 int c1, c2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5624 int len1, len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5625 int match; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5626 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5627 for (;;) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5628 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5629 match = TRUE; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5630 len2 = MB_CHAR2LEN(regstart); // skip regstart |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5631 for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1)) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5632 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5633 c1 = PTR2CHAR(match_text + len1); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5634 c2 = PTR2CHAR(rex.line + col + len2); |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
5635 if (c1 != c2 && (!rex.reg_ic || MB_CASEFOLD(c1) != MB_CASEFOLD(c2))) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5636 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5637 match = FALSE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5638 break; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5639 } |
25747
1c999a6e9d92
patch 8.2.3409: reading beyond end of line with invalid utf-8 character
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5640 len2 += enc_utf8 ? utf_ptr2len(rex.line + col + len2) |
1c999a6e9d92
patch 8.2.3409: reading beyond end of line with invalid utf-8 character
Bram Moolenaar <Bram@vim.org>
parents:
25320
diff
changeset
|
5641 : MB_CHAR2LEN(c2); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5642 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5643 if (match |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5644 // check that no composing char follows |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5645 && !(enc_utf8 |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
5646 && utf_iscomposing(PTR2CHAR(rex.line + col + len2)))) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5647 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5648 cleanup_subexpr(); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5649 if (REG_MULTI) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5650 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5651 rex.reg_startpos[0].lnum = rex.lnum; |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
5652 rex.reg_startpos[0].col = col; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5653 rex.reg_endpos[0].lnum = rex.lnum; |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
5654 rex.reg_endpos[0].col = col + len2; |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5655 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5656 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5657 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5658 rex.reg_startp[0] = rex.line + col; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5659 rex.reg_endp[0] = rex.line + col + len2; |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5660 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5661 return 1L; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5662 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5663 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5664 // Try finding regstart after the current match. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5665 col += MB_CHAR2LEN(regstart); // skip regstart |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5666 if (skip_to_start(regstart, &col) == FAIL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5667 break; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5668 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5669 return 0L; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5670 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5671 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5672 /* |
4444 | 5673 * Main matching routine. |
5674 * | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5675 * Run NFA to determine whether it matches rex.input. |
4444 | 5676 * |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
5677 * When "nfa_endp" is not NULL it is a required end-of-match position. |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5678 * |
16491
38a323a6fd18
patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
5679 * Return TRUE if there is a match, FALSE if there is no match, |
38a323a6fd18
patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
5680 * NFA_TOO_EXPENSIVE if we end up with too many states. |
5372 | 5681 * When there is a match "submatch" contains the positions. |
16491
38a323a6fd18
patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
5682 * |
4444 | 5683 * Note: Caller must ensure that: start != NULL. |
5684 */ | |
5685 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5686 nfa_regmatch( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5687 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5688 nfa_state_T *start, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5689 regsubs_T *submatch, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5690 regsubs_T *m) |
4444 | 5691 { |
16491
38a323a6fd18
patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16162
diff
changeset
|
5692 int result = FALSE; |
6545 | 5693 size_t size = 0; |
4444 | 5694 int flag = 0; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5695 int go_to_nextline = FALSE; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5696 nfa_thread_T *t; |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5697 nfa_list_T list[2]; |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5698 int listidx; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5699 nfa_list_T *thislist; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5700 nfa_list_T *nextlist; |
4444 | 5701 int *listids = NULL; |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
5702 int listids_len = 0; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5703 nfa_state_T *add_state; |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5704 int add_here; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5705 int add_count; |
4819
8c4324e6f477
updated for version 7.3.1156
Bram Moolenaar <bram@vim.org>
parents:
4815
diff
changeset
|
5706 int add_off = 0; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5707 int toplevel = start->c == NFA_MOPEN; |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5708 regsubs_T *r; |
4460 | 5709 #ifdef NFA_REGEXP_DEBUG_LOG |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5710 FILE *debug; |
4444 | 5711 #endif |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5712 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5713 // Some patterns may take a long time to match, especially when using |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5714 // recursive_regmatch(). Allow interrupting them with CTRL-C. |
5310 | 5715 fast_breakcheck(); |
5716 if (got_int) | |
5717 return FALSE; | |
6573 | 5718 #ifdef FEAT_RELTIME |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29028
diff
changeset
|
5719 if (nfa_did_time_out()) |
6573 | 5720 return FALSE; |
5721 #endif | |
5310 | 5722 |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5723 #ifdef NFA_REGEXP_DEBUG_LOG |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5724 debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5725 if (debug == NULL) |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5726 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15265
diff
changeset
|
5727 semsg("(NFA) COULD NOT OPEN %s!", NFA_REGEXP_DEBUG_LOG); |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5728 return FALSE; |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5729 } |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5730 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
5731 nfa_match = FALSE; |
4444 | 5732 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5733 // Allocate memory for the lists of nodes. |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5734 size = (prog->nstate + 1) * sizeof(nfa_thread_T); |
6547 | 5735 |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
5736 list[0].t = alloc(size); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5737 list[0].len = prog->nstate + 1; |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
5738 list[1].t = alloc(size); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5739 list[1].len = prog->nstate + 1; |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5740 if (list[0].t == NULL || list[1].t == NULL) |
4444 | 5741 goto theend; |
5742 | |
5743 #ifdef ENABLE_LOG | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5744 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5745 if (log_fd == NULL) |
4444 | 5746 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15265
diff
changeset
|
5747 emsg(_(e_log_open_failed)); |
4444 | 5748 log_fd = stderr; |
5749 } | |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5750 fprintf(log_fd, "**********************************\n"); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5751 nfa_set_code(start->c); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5752 fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n", |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5753 abs(start->id), code); |
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
5754 fprintf(log_fd, "**********************************\n"); |
4444 | 5755 #endif |
5756 | |
5757 thislist = &list[0]; | |
5758 thislist->n = 0; | |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5759 thislist->has_pim = FALSE; |
4444 | 5760 nextlist = &list[1]; |
5761 nextlist->n = 0; | |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5762 nextlist->has_pim = FALSE; |
4444 | 5763 #ifdef ENABLE_LOG |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5764 fprintf(log_fd, "(---) STARTSTATE first\n"); |
4444 | 5765 #endif |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5766 thislist->id = rex.nfa_listid + 1; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5767 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5768 // Inline optimized code for addstate(thislist, start, m, 0) if we know |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5769 // it's the first MOPEN. |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5770 if (toplevel) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5771 { |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5772 if (REG_MULTI) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5773 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5774 m->norm.list.multi[0].start_lnum = rex.lnum; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5775 m->norm.list.multi[0].start_col = (colnr_T)(rex.input - rex.line); |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5776 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5777 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5778 m->norm.list.line[0].start = rex.input; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5779 m->norm.in_use = 1; |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5780 r = addstate(thislist, start->out, m, NULL, 0); |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5781 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5782 else |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5783 r = addstate(thislist, start, m, NULL, 0); |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5784 if (r == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5785 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5786 nfa_match = NFA_TOO_EXPENSIVE; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5787 goto theend; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
5788 } |
4444 | 5789 |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5790 #define ADD_STATE_IF_MATCH(state) \ |
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5791 if (result) { \ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5792 add_state = state->out; \ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5793 add_off = clen; \ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5794 } |
4444 | 5795 |
5796 /* | |
5797 * Run for each character. | |
5798 */ | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5799 for (;;) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5800 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5801 int curc; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5802 int clen; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5803 |
4444 | 5804 if (has_mbyte) |
5805 { | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5806 curc = (*mb_ptr2char)(rex.input); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5807 clen = (*mb_ptr2len)(rex.input); |
4444 | 5808 } |
5809 else | |
5810 { | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5811 curc = *rex.input; |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5812 clen = 1; |
4444 | 5813 } |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5814 if (curc == NUL) |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5815 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5816 clen = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5817 go_to_nextline = FALSE; |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5818 } |
4444 | 5819 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5820 // swap lists |
4444 | 5821 thislist = &list[flag]; |
5822 nextlist = &list[flag ^= 1]; | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5823 nextlist->n = 0; // clear nextlist |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5824 nextlist->has_pim = FALSE; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5825 ++rex.nfa_listid; |
14161
7cac4646c552
patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents:
14159
diff
changeset
|
5826 if (prog->re_engine == AUTOMATIC_ENGINE |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5827 && (rex.nfa_listid >= NFA_MAX_STATES |
14173
4b59671bce9c
patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents:
14163
diff
changeset
|
5828 # ifdef FEAT_EVAL |
4b59671bce9c
patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents:
14163
diff
changeset
|
5829 || nfa_fail_for_testing |
4b59671bce9c
patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents:
14163
diff
changeset
|
5830 # endif |
4b59671bce9c
patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents:
14163
diff
changeset
|
5831 )) |
6328 | 5832 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5833 // too many states, retry with old engine |
6328 | 5834 nfa_match = NFA_TOO_EXPENSIVE; |
5835 goto theend; | |
5836 } | |
5837 | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5838 thislist->id = rex.nfa_listid; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5839 nextlist->id = rex.nfa_listid + 1; |
4444 | 5840 |
5841 #ifdef ENABLE_LOG | |
5842 fprintf(log_fd, "------------------------------------------\n"); | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5843 fprintf(log_fd, ">>> Reginput is \"%s\"\n", rex.input); |
14145
1cf832945469
patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents:
14121
diff
changeset
|
5844 fprintf(log_fd, ">>> Advanced one character... Current char is %c (code %d) \n", curc, (int)curc); |
4444 | 5845 fprintf(log_fd, ">>> Thislist has %d states available: ", thislist->n); |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5846 { |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5847 int i; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5848 |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5849 for (i = 0; i < thislist->n; i++) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5850 fprintf(log_fd, "%d ", abs(thislist->t[i].state->id)); |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5851 } |
4444 | 5852 fprintf(log_fd, "\n"); |
5853 #endif | |
5854 | |
4460 | 5855 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 5856 fprintf(debug, "\n-------------------\n"); |
5857 #endif | |
4480 | 5858 /* |
5859 * If the state lists are empty we can stop. | |
5860 */ | |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5861 if (thislist->n == 0) |
4480 | 5862 break; |
4444 | 5863 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5864 // compute nextlist |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5865 for (listidx = 0; listidx < thislist->n; ++listidx) |
4444 | 5866 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5867 // If the list gets very long there probably is something wrong. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5868 // At least allow interrupting with CTRL-C. |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
5869 fast_breakcheck(); |
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
5870 if (got_int) |
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
5871 break; |
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
5872 #ifdef FEAT_RELTIME |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29028
diff
changeset
|
5873 if (nfa_did_time_out()) |
29028
e0cf900448c1
patch 8.2.5036: using two counters for timeout check in NFA engine
Bram Moolenaar <Bram@vim.org>
parents:
29012
diff
changeset
|
5874 break; |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
5875 #endif |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5876 t = &thislist->t[listidx]; |
4444 | 5877 |
4460 | 5878 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 5879 nfa_set_code(t->state->c); |
5880 fprintf(debug, "%s, ", code); | |
5881 #endif | |
5882 #ifdef ENABLE_LOG | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5883 { |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5884 int col; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5885 |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
5886 if (t->subs.norm.in_use <= 0) |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5887 col = -1; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5888 else if (REG_MULTI) |
6547 | 5889 col = t->subs.norm.list.multi[0].start_col; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5890 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5891 col = (int)(t->subs.norm.list.line[0].start - rex.line); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5892 nfa_set_code(t->state->c); |
14145
1cf832945469
patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents:
14121
diff
changeset
|
5893 fprintf(log_fd, "(%d) char %d %s (start col %d)%s... \n", |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5894 abs(t->state->id), (int)t->state->c, code, col, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5895 pim_info(&t->pim)); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5896 } |
4444 | 5897 #endif |
5898 | |
5899 /* | |
5900 * Handle the possible codes of the current state. | |
5901 * The most important is NFA_MATCH. | |
5902 */ | |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5903 add_state = NULL; |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5904 add_here = FALSE; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5905 add_count = 0; |
4444 | 5906 switch (t->state->c) |
5907 { | |
5908 case NFA_MATCH: | |
4567
96c1a7850097
updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents:
4565
diff
changeset
|
5909 { |
23262
dca9e6b931d3
patch 8.2.2177: pattern "^" does not match if first character is combining
Bram Moolenaar <Bram@vim.org>
parents:
23251
diff
changeset
|
5910 // If the match is not at the start of the line, ends before a |
dca9e6b931d3
patch 8.2.2177: pattern "^" does not match if first character is combining
Bram Moolenaar <Bram@vim.org>
parents:
23251
diff
changeset
|
5911 // composing characters and rex.reg_icombine is not set, that |
dca9e6b931d3
patch 8.2.2177: pattern "^" does not match if first character is combining
Bram Moolenaar <Bram@vim.org>
parents:
23251
diff
changeset
|
5912 // is not really a match. |
dca9e6b931d3
patch 8.2.2177: pattern "^" does not match if first character is combining
Bram Moolenaar <Bram@vim.org>
parents:
23251
diff
changeset
|
5913 if (enc_utf8 && !rex.reg_icombine |
dca9e6b931d3
patch 8.2.2177: pattern "^" does not match if first character is combining
Bram Moolenaar <Bram@vim.org>
parents:
23251
diff
changeset
|
5914 && rex.input != rex.line && utf_iscomposing(curc)) |
5901 | 5915 break; |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
5916 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
5917 nfa_match = TRUE; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5918 copy_sub(&submatch->norm, &t->subs.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5919 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5920 if (rex.nfa_has_zsubexpr) |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5921 copy_sub(&submatch->synt, &t->subs.synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5922 #endif |
4444 | 5923 #ifdef ENABLE_LOG |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5924 log_subsexpr(&t->subs); |
4444 | 5925 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5926 // Found the left-most longest match, do not look at any other |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5927 // states at this position. When the list of states is going |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5928 // to be empty quit without advancing, so that "rex.input" is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5929 // correct. |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5930 if (nextlist->n == 0) |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5931 clen = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5932 goto nextchar; |
4567
96c1a7850097
updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents:
4565
diff
changeset
|
5933 } |
4444 | 5934 |
5935 case NFA_END_INVISIBLE: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5936 case NFA_END_INVISIBLE_NEG: |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5937 case NFA_END_PATTERN: |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5938 /* |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5939 * This is only encountered after a NFA_START_INVISIBLE or |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5940 * NFA_START_INVISIBLE_BEFORE node. |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5941 * They surround a zero-width group, used with "\@=", "\&", |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5942 * "\@!", "\@<=" and "\@<!". |
4444 | 5943 * If we got here, it means that the current "invisible" group |
5944 * finished successfully, so return control to the parent | |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5945 * nfa_regmatch(). For a look-behind match only when it ends |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5946 * in the position in "nfa_endp". |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5947 * Submatches are stored in *m, and used in the parent call. |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5948 */ |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5949 #ifdef ENABLE_LOG |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5950 if (nfa_endp != NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5951 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5952 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5953 fprintf(log_fd, "Current lnum: %d, endp lnum: %d; current col: %d, endp col: %d\n", |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5954 (int)rex.lnum, |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5955 (int)nfa_endp->se_u.pos.lnum, |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5956 (int)(rex.input - rex.line), |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5957 nfa_endp->se_u.pos.col); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5958 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5959 fprintf(log_fd, "Current col: %d, endp col: %d\n", |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5960 (int)(rex.input - rex.line), |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5961 (int)(nfa_endp->se_u.ptr - rex.input)); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5962 } |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5963 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5964 // If "nfa_endp" is set it's only a match if it ends at |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5965 // "nfa_endp" |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5966 if (nfa_endp != NULL && (REG_MULTI |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5967 ? (rex.lnum != nfa_endp->se_u.pos.lnum |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5968 || (int)(rex.input - rex.line) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5969 != nfa_endp->se_u.pos.col) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5970 : rex.input != nfa_endp->se_u.ptr)) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5971 break; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5972 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5973 // do not set submatches for \@! |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5974 if (t->state->c != NFA_END_INVISIBLE_NEG) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5975 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5976 copy_sub(&m->norm, &t->subs.norm); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5977 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
5978 if (rex.nfa_has_zsubexpr) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5979 copy_sub(&m->synt, &t->subs.synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5980 #endif |
4444 | 5981 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5982 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5983 fprintf(log_fd, "Match found:\n"); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5984 log_subsexpr(m); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5985 #endif |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5986 nfa_match = TRUE; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
5987 // See comment above at "goto nextchar". |
5334 | 5988 if (nextlist->n == 0) |
5989 clen = 0; | |
5990 goto nextchar; | |
4444 | 5991 |
5992 case NFA_START_INVISIBLE: | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5993 case NFA_START_INVISIBLE_FIRST: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5994 case NFA_START_INVISIBLE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5995 case NFA_START_INVISIBLE_NEG_FIRST: |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5996 case NFA_START_INVISIBLE_BEFORE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5997 case NFA_START_INVISIBLE_BEFORE_FIRST: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5998 case NFA_START_INVISIBLE_BEFORE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5999 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
4444 | 6000 { |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
6001 #ifdef ENABLE_LOG |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
6002 fprintf(log_fd, "Failure chance invisible: %d, what follows: %d\n", |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
6003 failure_chance(t->state->out, 0), |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
6004 failure_chance(t->state->out1->out, 0)); |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
6005 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6006 // Do it directly if there already is a PIM or when |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6007 // nfa_postprocess() detected it will work better. |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6008 if (t->pim.result != NFA_PIM_UNUSED |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6009 || t->state->c == NFA_START_INVISIBLE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6010 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6011 || t->state->c == NFA_START_INVISIBLE_BEFORE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6012 || t->state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6013 { |
5029
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
6014 int in_use = m->norm.in_use; |
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
6015 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6016 // Copy submatch info for the recursive call, opposite |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6017 // of what happens on success below. |
4997
8a7d3a73adab
updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents:
4958
diff
changeset
|
6018 copy_sub_off(&m->norm, &t->subs.norm); |
5370 | 6019 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6020 if (rex.nfa_has_zsubexpr) |
5370 | 6021 copy_sub_off(&m->synt, &t->subs.synt); |
6022 #endif | |
4997
8a7d3a73adab
updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents:
4958
diff
changeset
|
6023 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6024 /* |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6025 * First try matching the invisible match, then what |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6026 * follows. |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6027 */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6028 result = recursive_regmatch(t->state, NULL, prog, |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
6029 submatch, m, &listids, &listids_len); |
6328 | 6030 if (result == NFA_TOO_EXPENSIVE) |
6031 { | |
6032 nfa_match = result; | |
6033 goto theend; | |
6034 } | |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6035 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6036 // for \@! and \@<! it is a match when the result is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6037 // FALSE |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6038 if (result != (t->state->c == NFA_START_INVISIBLE_NEG |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6039 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6040 || t->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6041 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6042 || t->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6043 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6044 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6045 // Copy submatch info from the recursive call |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6046 copy_sub_off(&t->subs.norm, &m->norm); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6047 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6048 if (rex.nfa_has_zsubexpr) |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
6049 copy_sub_off(&t->subs.synt, &m->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6050 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6051 // If the pattern has \ze and it matched in the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6052 // sub pattern, use it. |
5372 | 6053 copy_ze_off(&t->subs.norm, &m->norm); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
6054 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6055 // t->state->out1 is the corresponding |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6056 // END_INVISIBLE node; Add its out to the current |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6057 // list (zero-width match). |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6058 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6059 add_state = t->state->out1->out; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6060 } |
5029
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
6061 m->norm.in_use = in_use; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6062 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6063 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6064 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6065 nfa_pim_T pim; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6066 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6067 /* |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6068 * First try matching what follows. Only if a match |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6069 * is found verify the invisible match matches. Add a |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6070 * nfa_pim_T to the following states, it contains info |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6071 * about the invisible match. |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6072 */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6073 pim.state = t->state; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6074 pim.result = NFA_PIM_TODO; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6075 pim.subs.norm.in_use = 0; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6076 #ifdef FEAT_SYN_HL |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6077 pim.subs.synt.in_use = 0; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6078 #endif |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6079 if (REG_MULTI) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6080 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6081 pim.end.pos.col = (int)(rex.input - rex.line); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6082 pim.end.pos.lnum = rex.lnum; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6083 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6084 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6085 pim.end.ptr = rex.input; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6086 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6087 // t->state->out1 is the corresponding END_INVISIBLE |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6088 // node; Add its out to the current list (zero-width |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6089 // match). |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6090 if (addstate_here(thislist, t->state->out1->out, |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6091 &t->subs, &pim, &listidx) == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6092 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6093 nfa_match = NFA_TOO_EXPENSIVE; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6094 goto theend; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6095 } |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6096 } |
4444 | 6097 } |
6098 break; | |
6099 | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6100 case NFA_START_PATTERN: |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6101 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6102 nfa_state_T *skip = NULL; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6103 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6104 int skip_lid = 0; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6105 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6106 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6107 // There is no point in trying to match the pattern if the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6108 // output state is not going to be added to the list. |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6109 if (state_in_list(nextlist, t->state->out1->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6110 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6111 skip = t->state->out1->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6112 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6113 skip_lid = nextlist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6114 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6115 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6116 else if (state_in_list(nextlist, |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6117 t->state->out1->out->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6118 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6119 skip = t->state->out1->out->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6120 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6121 skip_lid = nextlist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6122 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6123 } |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
6124 else if (state_in_list(thislist, |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6125 t->state->out1->out->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6126 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6127 skip = t->state->out1->out->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6128 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6129 skip_lid = thislist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6130 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6131 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6132 if (skip != NULL) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6133 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6134 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6135 nfa_set_code(skip->c); |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6136 fprintf(log_fd, "> Not trying to match pattern, output state %d is already in list %d. char %d: %s\n", |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6137 abs(skip->id), skip_lid, skip->c, code); |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6138 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6139 break; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6140 } |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6141 // Copy submatch info to the recursive call, opposite of what |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6142 // happens afterwards. |
5370 | 6143 copy_sub_off(&m->norm, &t->subs.norm); |
6144 #ifdef FEAT_SYN_HL | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6145 if (rex.nfa_has_zsubexpr) |
5370 | 6146 copy_sub_off(&m->synt, &t->subs.synt); |
6147 #endif | |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6148 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6149 // First try matching the pattern. |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6150 result = recursive_regmatch(t->state, NULL, prog, |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
6151 submatch, m, &listids, &listids_len); |
6328 | 6152 if (result == NFA_TOO_EXPENSIVE) |
6153 { | |
6154 nfa_match = result; | |
6155 goto theend; | |
6156 } | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6157 if (result) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6158 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6159 int bytelen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6160 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6161 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6162 fprintf(log_fd, "NFA_START_PATTERN matches:\n"); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6163 log_subsexpr(m); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6164 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6165 // Copy submatch info from the recursive call |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6166 copy_sub_off(&t->subs.norm, &m->norm); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6167 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6168 if (rex.nfa_has_zsubexpr) |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
6169 copy_sub_off(&t->subs.synt, &m->synt); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6170 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6171 // Now we need to skip over the matched text and then |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6172 // continue with what follows. |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6173 if (REG_MULTI) |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6174 // TODO: multi-line match |
6547 | 6175 bytelen = m->norm.list.multi[0].end_col |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6176 - (int)(rex.input - rex.line); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6177 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6178 bytelen = (int)(m->norm.list.line[0].end - rex.input); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6179 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6180 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6181 fprintf(log_fd, "NFA_START_PATTERN length: %d\n", bytelen); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6182 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6183 if (bytelen == 0) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6184 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6185 // empty match, output of corresponding |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6186 // NFA_END_PATTERN/NFA_SKIP to be used at current |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6187 // position |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6188 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6189 add_state = t->state->out1->out->out; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6190 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6191 else if (bytelen <= clen) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6192 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6193 // match current character, output of corresponding |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6194 // NFA_END_PATTERN to be used at next position. |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6195 add_state = t->state->out1->out->out; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6196 add_off = clen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6197 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6198 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6199 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6200 // skip over the matched characters, set character |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6201 // count in NFA_SKIP |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6202 add_state = t->state->out1->out; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6203 add_off = bytelen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6204 add_count = bytelen - clen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6205 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6206 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6207 break; |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
6208 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6209 |
4444 | 6210 case NFA_BOL: |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6211 if (rex.input == rex.line) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6212 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6213 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6214 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6215 } |
4444 | 6216 break; |
6217 | |
6218 case NFA_EOL: | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6219 if (curc == NUL) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6220 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6221 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6222 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6223 } |
4444 | 6224 break; |
6225 | |
6226 case NFA_BOW: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6227 result = TRUE; |
4444 | 6228 |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6229 if (curc == NUL) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6230 result = FALSE; |
4444 | 6231 else if (has_mbyte) |
6232 { | |
6233 int this_class; | |
6234 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6235 // Get class of current and previous char (if it exists). |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6236 this_class = mb_get_class_buf(rex.input, rex.reg_buf); |
4444 | 6237 if (this_class <= 1) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6238 result = FALSE; |
4444 | 6239 else if (reg_prev_class() == this_class) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6240 result = FALSE; |
4444 | 6241 } |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6242 else if (!vim_iswordc_buf(curc, rex.reg_buf) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6243 || (rex.input > rex.line |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6244 && vim_iswordc_buf(rex.input[-1], rex.reg_buf))) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6245 result = FALSE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6246 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6247 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6248 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6249 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6250 } |
4444 | 6251 break; |
6252 | |
6253 case NFA_EOW: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6254 result = TRUE; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6255 if (rex.input == rex.line) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6256 result = FALSE; |
4444 | 6257 else if (has_mbyte) |
6258 { | |
6259 int this_class, prev_class; | |
6260 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6261 // Get class of current and previous char (if it exists). |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6262 this_class = mb_get_class_buf(rex.input, rex.reg_buf); |
4444 | 6263 prev_class = reg_prev_class(); |
6264 if (this_class == prev_class | |
6265 || prev_class == 0 || prev_class == 1) | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6266 result = FALSE; |
4444 | 6267 } |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6268 else if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf) |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6269 || (rex.input[0] != NUL |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6270 && vim_iswordc_buf(curc, rex.reg_buf))) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6271 result = FALSE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6272 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6273 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6274 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6275 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6276 } |
4444 | 6277 break; |
6278 | |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6279 case NFA_BOF: |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6280 if (rex.lnum == 0 && rex.input == rex.line |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6281 && (!REG_MULTI || rex.reg_firstlnum == 1)) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6282 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6283 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6284 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6285 } |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6286 break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6287 |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6288 case NFA_EOF: |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6289 if (rex.lnum == rex.reg_maxline && curc == NUL) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6290 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6291 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6292 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6293 } |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6294 break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6295 |
4444 | 6296 case NFA_COMPOSING: |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6297 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6298 int mc = curc; |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6299 int len = 0; |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6300 nfa_state_T *end; |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6301 nfa_state_T *sta; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6302 int cchars[MAX_MCO]; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6303 int ccount = 0; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6304 int j; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6305 |
4444 | 6306 sta = t->state->out; |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6307 len = 0; |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6308 if (utf_iscomposing(sta->c)) |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6309 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6310 // Only match composing character(s), ignore base |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6311 // character. Used for ".{composing}" and "{composing}" |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6312 // (no preceding character). |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6313 len += mb_char2len(mc); |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6314 } |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6315 if (rex.reg_icombine && len == 0) |
4444 | 6316 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6317 // If \Z was present, then ignore composing characters. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6318 // When ignoring the base character this always matches. |
13208
e96663c35bab
patch 8.0.1478: unnecessary condition
Christian Brabandt <cb@256bit.org>
parents:
13192
diff
changeset
|
6319 if (sta->c != curc) |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6320 result = FAIL; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6321 else |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6322 result = OK; |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6323 while (sta->c != NFA_END_COMPOSING) |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6324 sta = sta->out; |
4444 | 6325 } |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6326 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6327 // Check base character matches first, unless ignored. |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6328 else if (len > 0 || mc == sta->c) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6329 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6330 if (len == 0) |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6331 { |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6332 len += mb_char2len(mc); |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6333 sta = sta->out; |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6334 } |
4444 | 6335 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6336 // We don't care about the order of composing characters. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6337 // Get them into cchars[] first. |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6338 while (len < clen) |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6339 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6340 mc = mb_ptr2char(rex.input + len); |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6341 cchars[ccount++] = mc; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6342 len += mb_char2len(mc); |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6343 if (ccount == MAX_MCO) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6344 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6345 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6346 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6347 // Check that each composing char in the pattern matches a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6348 // composing char in the text. We do not check if all |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6349 // composing chars are matched. |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6350 result = OK; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6351 while (sta->c != NFA_END_COMPOSING) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6352 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6353 for (j = 0; j < ccount; ++j) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6354 if (cchars[j] == sta->c) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6355 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6356 if (j == ccount) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6357 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6358 result = FAIL; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6359 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6360 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6361 sta = sta->out; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6362 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6363 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6364 else |
4525
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4517
diff
changeset
|
6365 result = FAIL; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6366 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6367 end = t->state->out1; // NFA_END_COMPOSING |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6368 ADD_STATE_IF_MATCH(end); |
4444 | 6369 break; |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6370 } |
4444 | 6371 |
6372 case NFA_NEWL: | |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6373 if (curc == NUL && !rex.reg_line_lbr && REG_MULTI |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6374 && rex.lnum <= rex.reg_maxline) |
4444 | 6375 { |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6376 go_to_nextline = TRUE; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6377 // Pass -1 for the offset, which means taking the position |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6378 // at the start of the next line. |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6379 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6380 add_off = -1; |
4444 | 6381 } |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6382 else if (curc == '\n' && rex.reg_line_lbr) |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6383 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6384 // match \n as if it is an ordinary character |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6385 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6386 add_off = 1; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6387 } |
4444 | 6388 break; |
6389 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6390 case NFA_START_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6391 case NFA_START_NEG_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6392 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6393 // What follows is a list of characters, until NFA_END_COLL. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6394 // One of them must match or none of them must match. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6395 nfa_state_T *state; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6396 int result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6397 int c1, c2; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6398 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6399 // Never match EOL. If it's part of the collection it is added |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6400 // as a separate state with an OR. |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6401 if (curc == NUL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6402 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6403 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6404 state = t->state->out; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6405 result_if_matched = (t->state->c == NFA_START_COLL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6406 for (;;) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6407 { |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6408 if (state->c == NFA_END_COLL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6409 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6410 result = !result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6411 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6412 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6413 if (state->c == NFA_RANGE_MIN) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6414 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6415 c1 = state->val; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6416 state = state->out; // advance to NFA_RANGE_MAX |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6417 c2 = state->val; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6418 #ifdef ENABLE_LOG |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6419 fprintf(log_fd, "NFA_RANGE_MIN curc=%d c1=%d c2=%d\n", |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6420 curc, c1, c2); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6421 #endif |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6422 if (curc >= c1 && curc <= c2) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6423 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6424 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6425 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6426 } |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6427 if (rex.reg_ic) |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6428 { |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
6429 int curc_low = MB_CASEFOLD(curc); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6430 int done = FALSE; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6431 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6432 for ( ; c1 <= c2; ++c1) |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
6433 if (MB_CASEFOLD(c1) == curc_low) |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6434 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6435 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6436 done = TRUE; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6437 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6438 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6439 if (done) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6440 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6441 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6442 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6443 else if (state->c < 0 ? check_char_class(state->c, curc) |
13192
9bd4151e5aeb
patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents:
13043
diff
changeset
|
6444 : (curc == state->c |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
6445 || (rex.reg_ic && MB_CASEFOLD(curc) |
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
6446 == MB_CASEFOLD(state->c)))) |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6447 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6448 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6449 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6450 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6451 state = state->out; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6452 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6453 if (result) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6454 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6455 // next state is in out of the NFA_END_COLL, out1 of |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6456 // START points to the END state |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6457 add_state = t->state->out1->out; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6458 add_off = clen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6459 } |
4444 | 6460 break; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6461 } |
4444 | 6462 |
6463 case NFA_ANY: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6464 // Any char except '\0', (end of input) does not match. |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6465 if (curc > 0) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6466 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6467 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6468 add_off = clen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6469 } |
4444 | 6470 break; |
6471 | |
5901 | 6472 case NFA_ANY_COMPOSING: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6473 // On a composing character skip over it. Otherwise do |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6474 // nothing. Always matches. |
5901 | 6475 if (enc_utf8 && utf_iscomposing(curc)) |
6476 { | |
6477 add_off = clen; | |
6478 } | |
6479 else | |
6480 { | |
6481 add_here = TRUE; | |
6482 add_off = 0; | |
6483 } | |
6484 add_state = t->state->out; | |
6485 break; | |
6486 | |
4444 | 6487 /* |
6488 * Character classes like \a for alpha, \d for digit etc. | |
6489 */ | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6490 case NFA_IDENT: // \i |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6491 result = vim_isIDc(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6492 ADD_STATE_IF_MATCH(t->state); |
4444 | 6493 break; |
6494 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6495 case NFA_SIDENT: // \I |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6496 result = !VIM_ISDIGIT(curc) && vim_isIDc(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6497 ADD_STATE_IF_MATCH(t->state); |
4444 | 6498 break; |
6499 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6500 case NFA_KWORD: // \k |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6501 result = vim_iswordp_buf(rex.input, rex.reg_buf); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6502 ADD_STATE_IF_MATCH(t->state); |
4444 | 6503 break; |
6504 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6505 case NFA_SKWORD: // \K |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6506 result = !VIM_ISDIGIT(curc) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6507 && vim_iswordp_buf(rex.input, rex.reg_buf); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6508 ADD_STATE_IF_MATCH(t->state); |
4444 | 6509 break; |
6510 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6511 case NFA_FNAME: // \f |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6512 result = vim_isfilec(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6513 ADD_STATE_IF_MATCH(t->state); |
4444 | 6514 break; |
6515 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6516 case NFA_SFNAME: // \F |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6517 result = !VIM_ISDIGIT(curc) && vim_isfilec(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6518 ADD_STATE_IF_MATCH(t->state); |
4444 | 6519 break; |
6520 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6521 case NFA_PRINT: // \p |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6522 result = vim_isprintc(PTR2CHAR(rex.input)); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6523 ADD_STATE_IF_MATCH(t->state); |
4444 | 6524 break; |
6525 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6526 case NFA_SPRINT: // \P |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6527 result = !VIM_ISDIGIT(curc) && vim_isprintc(PTR2CHAR(rex.input)); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6528 ADD_STATE_IF_MATCH(t->state); |
4444 | 6529 break; |
6530 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6531 case NFA_WHITE: // \s |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
6532 result = VIM_ISWHITE(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6533 ADD_STATE_IF_MATCH(t->state); |
4444 | 6534 break; |
6535 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6536 case NFA_NWHITE: // \S |
11129
f4ea50924c6d
patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents:
11127
diff
changeset
|
6537 result = curc != NUL && !VIM_ISWHITE(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6538 ADD_STATE_IF_MATCH(t->state); |
4444 | 6539 break; |
6540 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6541 case NFA_DIGIT: // \d |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6542 result = ri_digit(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6543 ADD_STATE_IF_MATCH(t->state); |
4444 | 6544 break; |
6545 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6546 case NFA_NDIGIT: // \D |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6547 result = curc != NUL && !ri_digit(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6548 ADD_STATE_IF_MATCH(t->state); |
4444 | 6549 break; |
6550 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6551 case NFA_HEX: // \x |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6552 result = ri_hex(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6553 ADD_STATE_IF_MATCH(t->state); |
4444 | 6554 break; |
6555 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6556 case NFA_NHEX: // \X |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6557 result = curc != NUL && !ri_hex(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6558 ADD_STATE_IF_MATCH(t->state); |
4444 | 6559 break; |
6560 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6561 case NFA_OCTAL: // \o |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6562 result = ri_octal(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6563 ADD_STATE_IF_MATCH(t->state); |
4444 | 6564 break; |
6565 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6566 case NFA_NOCTAL: // \O |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6567 result = curc != NUL && !ri_octal(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6568 ADD_STATE_IF_MATCH(t->state); |
4444 | 6569 break; |
6570 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6571 case NFA_WORD: // \w |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6572 result = ri_word(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6573 ADD_STATE_IF_MATCH(t->state); |
4444 | 6574 break; |
6575 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6576 case NFA_NWORD: // \W |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6577 result = curc != NUL && !ri_word(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6578 ADD_STATE_IF_MATCH(t->state); |
4444 | 6579 break; |
6580 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6581 case NFA_HEAD: // \h |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6582 result = ri_head(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6583 ADD_STATE_IF_MATCH(t->state); |
4444 | 6584 break; |
6585 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6586 case NFA_NHEAD: // \H |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6587 result = curc != NUL && !ri_head(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6588 ADD_STATE_IF_MATCH(t->state); |
4444 | 6589 break; |
6590 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6591 case NFA_ALPHA: // \a |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6592 result = ri_alpha(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6593 ADD_STATE_IF_MATCH(t->state); |
4444 | 6594 break; |
6595 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6596 case NFA_NALPHA: // \A |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6597 result = curc != NUL && !ri_alpha(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6598 ADD_STATE_IF_MATCH(t->state); |
4444 | 6599 break; |
6600 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6601 case NFA_LOWER: // \l |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6602 result = ri_lower(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6603 ADD_STATE_IF_MATCH(t->state); |
4444 | 6604 break; |
6605 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6606 case NFA_NLOWER: // \L |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6607 result = curc != NUL && !ri_lower(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6608 ADD_STATE_IF_MATCH(t->state); |
4444 | 6609 break; |
6610 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6611 case NFA_UPPER: // \u |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6612 result = ri_upper(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6613 ADD_STATE_IF_MATCH(t->state); |
4444 | 6614 break; |
6615 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6616 case NFA_NUPPER: // \U |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6617 result = curc != NUL && !ri_upper(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6618 ADD_STATE_IF_MATCH(t->state); |
4444 | 6619 break; |
6620 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6621 case NFA_LOWER_IC: // [a-z] |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6622 result = ri_lower(curc) || (rex.reg_ic && ri_upper(curc)); |
5296 | 6623 ADD_STATE_IF_MATCH(t->state); |
6624 break; | |
6625 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6626 case NFA_NLOWER_IC: // [^a-z] |
5296 | 6627 result = curc != NUL |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6628 && !(ri_lower(curc) || (rex.reg_ic && ri_upper(curc))); |
5296 | 6629 ADD_STATE_IF_MATCH(t->state); |
6630 break; | |
6631 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6632 case NFA_UPPER_IC: // [A-Z] |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6633 result = ri_upper(curc) || (rex.reg_ic && ri_lower(curc)); |
5296 | 6634 ADD_STATE_IF_MATCH(t->state); |
6635 break; | |
6636 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6637 case NFA_NUPPER_IC: // ^[A-Z] |
5296 | 6638 result = curc != NUL |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6639 && !(ri_upper(curc) || (rex.reg_ic && ri_lower(curc))); |
5296 | 6640 ADD_STATE_IF_MATCH(t->state); |
6641 break; | |
6642 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6643 case NFA_BACKREF1: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6644 case NFA_BACKREF2: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6645 case NFA_BACKREF3: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6646 case NFA_BACKREF4: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6647 case NFA_BACKREF5: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6648 case NFA_BACKREF6: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6649 case NFA_BACKREF7: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6650 case NFA_BACKREF8: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6651 case NFA_BACKREF9: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6652 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6653 case NFA_ZREF1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6654 case NFA_ZREF2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6655 case NFA_ZREF3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6656 case NFA_ZREF4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6657 case NFA_ZREF5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6658 case NFA_ZREF6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6659 case NFA_ZREF7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6660 case NFA_ZREF8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6661 case NFA_ZREF9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6662 #endif |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6663 // \1 .. \9 \z1 .. \z9 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6664 { |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6665 int subidx; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6666 int bytelen; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6667 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6668 if (t->state->c <= NFA_BACKREF9) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6669 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6670 subidx = t->state->c - NFA_BACKREF1 + 1; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6671 result = match_backref(&t->subs.norm, subidx, &bytelen); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6672 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6673 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6674 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6675 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6676 subidx = t->state->c - NFA_ZREF1 + 1; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6677 result = match_zref(subidx, &bytelen); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6678 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6679 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6680 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6681 if (result) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6682 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6683 if (bytelen == 0) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6684 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6685 // empty match always works, output of NFA_SKIP to be |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6686 // used next |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6687 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6688 add_state = t->state->out->out; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6689 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6690 else if (bytelen <= clen) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6691 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6692 // match current character, jump ahead to out of |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6693 // NFA_SKIP |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6694 add_state = t->state->out->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6695 add_off = clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6696 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6697 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6698 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6699 // skip over the matched characters, set character |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6700 // count in NFA_SKIP |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6701 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6702 add_off = bytelen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6703 add_count = bytelen - clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6704 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6705 } |
4482 | 6706 break; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6707 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6708 case NFA_SKIP: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6709 // character of previous matching \1 .. \9 or \@> |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6710 if (t->count - clen <= 0) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6711 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6712 // end of match, go to what follows |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6713 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6714 add_off = clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6715 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6716 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6717 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6718 // add state again with decremented count |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6719 add_state = t->state; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6720 add_off = 0; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6721 add_count = t->count - clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6722 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6723 break; |
4482 | 6724 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6725 case NFA_LNUM: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6726 case NFA_LNUM_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6727 case NFA_LNUM_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6728 result = (REG_MULTI && |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6729 nfa_re_num_cmp(t->state->val, t->state->c - NFA_LNUM, |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6730 (long_u)(rex.lnum + rex.reg_firstlnum))); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6731 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6732 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6733 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6734 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6735 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6736 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6737 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6738 case NFA_COL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6739 case NFA_COL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6740 case NFA_COL_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6741 result = nfa_re_num_cmp(t->state->val, t->state->c - NFA_COL, |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6742 (long_u)(rex.input - rex.line) + 1); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6743 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6744 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6745 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6746 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6747 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6748 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6749 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6750 case NFA_VCOL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6751 case NFA_VCOL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6752 case NFA_VCOL_LT: |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6753 { |
6499 | 6754 int op = t->state->c - NFA_VCOL; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6755 colnr_T col = (colnr_T)(rex.input - rex.line); |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6756 win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; |
6499 | 6757 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6758 // Bail out quickly when there can't be a match, avoid the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6759 // overhead of win_linetabsize() on long lines. |
6653 | 6760 if (op != 1 && col > t->state->val |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
6761 * (has_mbyte ? MB_MAXBYTES : 1)) |
6499 | 6762 break; |
6510 | 6763 result = FALSE; |
6764 if (op == 1 && col - 1 > t->state->val && col > 100) | |
6765 { | |
6766 int ts = wp->w_buffer->b_p_ts; | |
6767 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6768 // Guess that a character won't use more columns than |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6769 // 'tabstop', with a minimum of 4. |
6510 | 6770 if (ts < 4) |
6771 ts = 4; | |
6772 result = col > t->state->val * ts; | |
6773 } | |
6774 if (!result) | |
6775 result = nfa_re_num_cmp(t->state->val, op, | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6776 (long_u)win_linetabsize(wp, rex.line, col) + 1); |
6499 | 6777 if (result) |
6778 { | |
6779 add_here = TRUE; | |
6780 add_state = t->state->out; | |
6781 } | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6782 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6783 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6784 |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6785 case NFA_MARK: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6786 case NFA_MARK_GT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6787 case NFA_MARK_LT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6788 { |
28247
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
28135
diff
changeset
|
6789 pos_T *pos; |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
28135
diff
changeset
|
6790 size_t col = REG_MULTI ? rex.input - rex.line : 0; |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
28135
diff
changeset
|
6791 |
f70015784777
patch 8.2.4649: various formatting problems
Bram Moolenaar <Bram@vim.org>
parents:
28135
diff
changeset
|
6792 pos = getmark_buf(rex.reg_buf, t->state->val, FALSE); |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6793 |
26161
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6794 // Line may have been freed, get it again. |
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6795 if (REG_MULTI) |
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6796 { |
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6797 rex.line = reg_getline(rex.lnum); |
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6798 rex.input = rex.line + col; |
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6799 } |
9835f424bef5
patch 8.2.3612: using freed memory with regexp using a mark
Bram Moolenaar <Bram@vim.org>
parents:
25747
diff
changeset
|
6800 |
24693
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6801 // Compare the mark position to the match position, if the mark |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6802 // exists and mark is set in reg_buf. |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6803 if (pos != NULL && pos->lnum > 0) |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6804 { |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6805 colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6806 && pos->col == MAXCOL |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6807 ? (colnr_T)STRLEN(reg_getline( |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6808 pos->lnum - rex.reg_firstlnum)) |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6809 : pos->col; |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6810 |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6811 result = (pos->lnum == rex.lnum + rex.reg_firstlnum |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6812 ? (pos_col == (colnr_T)(rex.input - rex.line) |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6813 ? t->state->c == NFA_MARK |
24693
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6814 : (pos_col < (colnr_T)(rex.input - rex.line) |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6815 ? t->state->c == NFA_MARK_GT |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6816 : t->state->c == NFA_MARK_LT)) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6817 : (pos->lnum < rex.lnum + rex.reg_firstlnum |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6818 ? t->state->c == NFA_MARK_GT |
24693
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6819 : t->state->c == NFA_MARK_LT)); |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6820 if (result) |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6821 { |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6822 add_here = TRUE; |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6823 add_state = t->state->out; |
97789fcef0cf
patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents:
24580
diff
changeset
|
6824 } |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6825 } |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6826 break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6827 } |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6828 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6829 case NFA_CURSOR: |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6830 result = (rex.reg_win != NULL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6831 && (rex.lnum + rex.reg_firstlnum |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6832 == rex.reg_win->w_cursor.lnum) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6833 && ((colnr_T)(rex.input - rex.line) |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6834 == rex.reg_win->w_cursor.col)); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6835 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6836 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6837 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6838 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6839 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6840 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6841 |
4756
96f3348f9f11
updated for version 7.3.1125
Bram Moolenaar <bram@vim.org>
parents:
4750
diff
changeset
|
6842 case NFA_VISUAL: |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6843 result = reg_match_visual(); |
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6844 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6845 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6846 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6847 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6848 } |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6849 break; |
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6850 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6851 case NFA_MOPEN1: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6852 case NFA_MOPEN2: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6853 case NFA_MOPEN3: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6854 case NFA_MOPEN4: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6855 case NFA_MOPEN5: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6856 case NFA_MOPEN6: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6857 case NFA_MOPEN7: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6858 case NFA_MOPEN8: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6859 case NFA_MOPEN9: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6860 #ifdef FEAT_SYN_HL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6861 case NFA_ZOPEN: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6862 case NFA_ZOPEN1: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6863 case NFA_ZOPEN2: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6864 case NFA_ZOPEN3: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6865 case NFA_ZOPEN4: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6866 case NFA_ZOPEN5: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6867 case NFA_ZOPEN6: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6868 case NFA_ZOPEN7: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6869 case NFA_ZOPEN8: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6870 case NFA_ZOPEN9: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6871 #endif |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6872 case NFA_NOPEN: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6873 case NFA_ZSTART: |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6874 // These states are only added to be able to bail out when |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6875 // they are added again, nothing is to be done. |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6876 break; |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6877 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6878 default: // regular character |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6879 { |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6880 int c = t->state->c; |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6881 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6882 #ifdef DEBUG |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6883 if (c < 0) |
27000
8c0730eca2ce
patch 8.2.4029: debugging NFA regexp my crash, cached indent may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
6884 siemsg("INTERNAL: Negative state char: %ld", (long)c); |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6885 #endif |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6886 result = (c == curc); |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6887 |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6888 if (!result && rex.reg_ic) |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
6889 result = MB_CASEFOLD(c) == MB_CASEFOLD(curc); |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6890 // If rex.reg_icombine is not set only skip over the character |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6891 // itself. When it is set skip over composing characters. |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
6892 if (result && enc_utf8 && !rex.reg_icombine) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6893 clen = utf_ptr2len(rex.input); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6894 ADD_STATE_IF_MATCH(t->state); |
4444 | 6895 break; |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6896 } |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6897 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6898 } // switch (t->state->c) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6899 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6900 if (add_state != NULL) |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6901 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6902 nfa_pim_T *pim; |
5401 | 6903 nfa_pim_T pim_copy; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6904 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6905 if (t->pim.result == NFA_PIM_UNUSED) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6906 pim = NULL; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6907 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6908 pim = &t->pim; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6909 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6910 // Handle the postponed invisible match if the match might end |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6911 // without advancing and before the end of the line. |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6912 if (pim != NULL && (clen == 0 || match_follows(add_state, 0))) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6913 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6914 if (pim->result == NFA_PIM_TODO) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6915 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6916 #ifdef ENABLE_LOG |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6917 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6918 fprintf(log_fd, "==================================\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6919 fprintf(log_fd, "Postponed recursive nfa_regmatch()\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6920 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6921 #endif |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6922 result = recursive_regmatch(pim->state, pim, |
14309
15530de011bc
patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents:
14173
diff
changeset
|
6923 prog, submatch, m, &listids, &listids_len); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6924 pim->result = result ? NFA_PIM_MATCH : NFA_PIM_NOMATCH; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6925 // for \@! and \@<! it is a match when the result is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6926 // FALSE |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6927 if (result != (pim->state->c == NFA_START_INVISIBLE_NEG |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6928 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6929 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6930 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6931 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6932 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6933 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6934 // Copy submatch info from the recursive call |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6935 copy_sub_off(&pim->subs.norm, &m->norm); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6936 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6937 if (rex.nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6938 copy_sub_off(&pim->subs.synt, &m->synt); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6939 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6940 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6941 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6942 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6943 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6944 result = (pim->result == NFA_PIM_MATCH); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6945 #ifdef ENABLE_LOG |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6946 fprintf(log_fd, "\n"); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6947 fprintf(log_fd, "Using previous recursive nfa_regmatch() result, result == %d\n", pim->result); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6948 fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6949 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6950 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6951 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6952 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6953 // for \@! and \@<! it is a match when result is FALSE |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6954 if (result != (pim->state->c == NFA_START_INVISIBLE_NEG |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6955 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6956 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6957 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6958 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6959 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6960 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6961 // Copy submatch info from the recursive call |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6962 copy_sub_off(&t->subs.norm, &pim->subs.norm); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6963 #ifdef FEAT_SYN_HL |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
6964 if (rex.nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6965 copy_sub_off(&t->subs.synt, &pim->subs.synt); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6966 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6967 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6968 else |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6969 // look-behind match failed, don't add the state |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6970 continue; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6971 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6972 // Postponed invisible match was handled, don't add it to |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6973 // following states. |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6974 pim = NULL; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6975 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6976 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6977 // If "pim" points into l->t it will become invalid when |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6978 // adding the state causes the list to be reallocated. Make a |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
6979 // local copy to avoid that. |
5401 | 6980 if (pim == &t->pim) |
6981 { | |
6982 copy_pim(&pim_copy, pim); | |
6983 pim = &pim_copy; | |
6984 } | |
6985 | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6986 if (add_here) |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6987 r = addstate_here(thislist, add_state, &t->subs, |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6988 pim, &listidx); |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6989 else |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6990 { |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6991 r = addstate(nextlist, add_state, &t->subs, pim, add_off); |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6992 if (add_count > 0) |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6993 nextlist->t[nextlist->n - 1].count = add_count; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6994 } |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6995 if (r == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6996 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6997 nfa_match = NFA_TOO_EXPENSIVE; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6998 goto theend; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
6999 } |
4444 | 7000 } |
7001 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7002 } // for (thislist = thislist; thislist->state; thislist++) |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7003 |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7004 // Look for the start of a match in the current position by adding the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7005 // start state to the list of states. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7006 // The first found match is the leftmost one, thus the order of states |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7007 // matters! |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7008 // Do not add the start state in recursive calls of nfa_regmatch(), |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7009 // because recursive calls should only start in the first position. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7010 // Unless "nfa_endp" is not NULL, then we match the end position. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7011 // Also don't start a match past the first line. |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
7012 if (nfa_match == FALSE |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
7013 && ((toplevel |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7014 && rex.lnum == 0 |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
7015 && clen != 0 |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7016 && (rex.reg_maxcol == 0 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7017 || (colnr_T)(rex.input - rex.line) < rex.reg_maxcol)) |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
7018 || (nfa_endp != NULL |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
7019 && (REG_MULTI |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7020 ? (rex.lnum < nfa_endp->se_u.pos.lnum |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7021 || (rex.lnum == nfa_endp->se_u.pos.lnum |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7022 && (int)(rex.input - rex.line) |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
7023 < nfa_endp->se_u.pos.col)) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7024 : rex.input < nfa_endp->se_u.ptr)))) |
4444 | 7025 { |
7026 #ifdef ENABLE_LOG | |
7027 fprintf(log_fd, "(---) STARTSTATE\n"); | |
7028 #endif | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7029 // Inline optimized code for addstate() if we know the state is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7030 // the first MOPEN. |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
7031 if (toplevel) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
7032 { |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7033 int add = TRUE; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7034 int c; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7035 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7036 if (prog->regstart != NUL && clen != 0) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7037 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7038 if (nextlist->n == 0) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7039 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7040 colnr_T col = (colnr_T)(rex.input - rex.line) + clen; |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7041 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7042 // Nextlist is empty, we can skip ahead to the |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7043 // character that must appear at the start. |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7044 if (skip_to_start(prog->regstart, &col) == FAIL) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7045 break; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7046 #ifdef ENABLE_LOG |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7047 fprintf(log_fd, " Skipping ahead %d bytes to regstart\n", |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7048 col - ((colnr_T)(rex.input - rex.line) + clen)); |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7049 #endif |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7050 rex.input = rex.line + col - clen; |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7051 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7052 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7053 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7054 // Checking if the required start character matches is |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7055 // cheaper than adding a state that won't match. |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7056 c = PTR2CHAR(rex.input + clen); |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7057 if (c != prog->regstart && (!rex.reg_ic |
20772
097f5b5c907b
patch 8.2.0938: NFA regexp uses tolower ()to compare ignore-case
Bram Moolenaar <Bram@vim.org>
parents:
20677
diff
changeset
|
7058 || MB_CASEFOLD(c) != MB_CASEFOLD(prog->regstart))) |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7059 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7060 #ifdef ENABLE_LOG |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7061 fprintf(log_fd, " Skipping start state, regstart does not match\n"); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7062 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7063 add = FALSE; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7064 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7065 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7066 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7067 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7068 if (add) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7069 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7070 if (REG_MULTI) |
6547 | 7071 m->norm.list.multi[0].start_col = |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7072 (colnr_T)(rex.input - rex.line) + clen; |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7073 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7074 m->norm.list.line[0].start = rex.input + clen; |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7075 if (addstate(nextlist, start->out, m, NULL, clen) == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7076 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7077 nfa_match = NFA_TOO_EXPENSIVE; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7078 goto theend; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7079 } |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7080 } |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
7081 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
7082 else |
15796
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7083 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7084 if (addstate(nextlist, start, m, NULL, clen) == NULL) |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7085 { |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7086 nfa_match = NFA_TOO_EXPENSIVE; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7087 goto theend; |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7088 } |
481452f6687c
patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
15709
diff
changeset
|
7089 } |
4444 | 7090 } |
7091 | |
7092 #ifdef ENABLE_LOG | |
7093 fprintf(log_fd, ">>> Thislist had %d states available: ", thislist->n); | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7094 { |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7095 int i; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7096 |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7097 for (i = 0; i < thislist->n; i++) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7098 fprintf(log_fd, "%d ", abs(thislist->t[i].state->id)); |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7099 } |
4444 | 7100 fprintf(log_fd, "\n"); |
7101 #endif | |
7102 | |
7103 nextchar: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7104 // Advance to the next character, or advance to the next line, or |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7105 // finish. |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
7106 if (clen != 0) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7107 rex.input += clen; |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
7108 else if (go_to_nextline || (nfa_endp != NULL && REG_MULTI |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7109 && rex.lnum < nfa_endp->se_u.pos.lnum)) |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
7110 reg_nextline(); |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
7111 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
7112 break; |
6499 | 7113 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7114 // Allow interrupting with CTRL-C. |
6573 | 7115 line_breakcheck(); |
6499 | 7116 if (got_int) |
7117 break; | |
6573 | 7118 #ifdef FEAT_RELTIME |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29028
diff
changeset
|
7119 if (nfa_did_time_out()) |
29028
e0cf900448c1
patch 8.2.5036: using two counters for timeout check in NFA engine
Bram Moolenaar <Bram@vim.org>
parents:
29012
diff
changeset
|
7120 break; |
6573 | 7121 #endif |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
7122 } |
4444 | 7123 |
7124 #ifdef ENABLE_LOG | |
7125 if (log_fd != stderr) | |
7126 fclose(log_fd); | |
7127 log_fd = NULL; | |
7128 #endif | |
7129 | |
7130 theend: | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7131 // Free memory |
4444 | 7132 vim_free(list[0].t); |
7133 vim_free(list[1].t); | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
7134 vim_free(listids); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
7135 #undef ADD_STATE_IF_MATCH |
4460 | 7136 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 7137 fclose(debug); |
7138 #endif | |
7139 | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
7140 return nfa_match; |
4444 | 7141 } |
7142 | |
7143 /* | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7144 * Try match of "prog" with at rex.line["col"]. |
6392 | 7145 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 7146 */ |
7147 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7148 nfa_regtry( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7149 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7150 colnr_T col, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7151 int *timed_out UNUSED) // flag set on timeout or NULL |
4444 | 7152 { |
7153 int i; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7154 regsubs_T subs, m; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7155 nfa_state_T *start = prog->start; |
6328 | 7156 int result; |
4444 | 7157 #ifdef ENABLE_LOG |
7158 FILE *f; | |
7159 #endif | |
7160 | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7161 rex.input = rex.line + col; |
6573 | 7162 #ifdef FEAT_RELTIME |
11521
578df034735d
patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents:
11480
diff
changeset
|
7163 nfa_timed_out = timed_out; |
6573 | 7164 #endif |
4444 | 7165 |
7166 #ifdef ENABLE_LOG | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
7167 f = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 7168 if (f != NULL) |
7169 { | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
7170 fprintf(f, "\n\n\t=======================================================\n"); |
4444 | 7171 #ifdef DEBUG |
7172 fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr); | |
7173 #endif | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7174 fprintf(f, "\tInput text is \"%s\" \n", rex.input); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
7175 fprintf(f, "\t=======================================================\n\n"); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
7176 nfa_print_state(f, start); |
4444 | 7177 fprintf(f, "\n\n"); |
7178 fclose(f); | |
7179 } | |
7180 else | |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15265
diff
changeset
|
7181 emsg("Could not open temporary log file for writing"); |
4444 | 7182 #endif |
7183 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7184 clear_sub(&subs.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7185 clear_sub(&m.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7186 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7187 clear_sub(&subs.synt); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7188 clear_sub(&m.synt); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7189 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7190 |
6328 | 7191 result = nfa_regmatch(prog, start, &subs, &m); |
7192 if (result == FALSE) | |
4444 | 7193 return 0; |
6328 | 7194 else if (result == NFA_TOO_EXPENSIVE) |
7195 return result; | |
4444 | 7196 |
7197 cleanup_subexpr(); | |
7198 if (REG_MULTI) | |
7199 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7200 for (i = 0; i < subs.norm.in_use; i++) |
4444 | 7201 { |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7202 rex.reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7203 rex.reg_startpos[i].col = subs.norm.list.multi[i].start_col; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7204 |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7205 rex.reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7206 rex.reg_endpos[i].col = subs.norm.list.multi[i].end_col; |
4444 | 7207 } |
7208 | |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7209 if (rex.reg_startpos[0].lnum < 0) |
4444 | 7210 { |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7211 rex.reg_startpos[0].lnum = 0; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7212 rex.reg_startpos[0].col = col; |
4444 | 7213 } |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7214 if (rex.reg_endpos[0].lnum < 0) |
4444 | 7215 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7216 // pattern has a \ze but it didn't match, use current end |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7217 rex.reg_endpos[0].lnum = rex.lnum; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7218 rex.reg_endpos[0].col = (int)(rex.input - rex.line); |
4444 | 7219 } |
7220 else | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7221 // Use line number of "\ze". |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7222 rex.lnum = rex.reg_endpos[0].lnum; |
4444 | 7223 } |
7224 else | |
7225 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7226 for (i = 0; i < subs.norm.in_use; i++) |
4444 | 7227 { |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7228 rex.reg_startp[i] = subs.norm.list.line[i].start; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7229 rex.reg_endp[i] = subs.norm.list.line[i].end; |
4444 | 7230 } |
7231 | |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7232 if (rex.reg_startp[0] == NULL) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7233 rex.reg_startp[0] = rex.line + col; |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7234 if (rex.reg_endp[0] == NULL) |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7235 rex.reg_endp[0] = rex.input; |
4444 | 7236 } |
7237 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7238 #ifdef FEAT_SYN_HL |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7239 // Package any found \z(...\) matches for export. Default is none. |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7240 unref_extmatch(re_extmatch_out); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7241 re_extmatch_out = NULL; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7242 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7243 if (prog->reghasz == REX_SET) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7244 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7245 cleanup_zsubexpr(); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7246 re_extmatch_out = make_extmatch(); |
18945
c62d63d2b9f0
patch 8.2.0033: crash when make_extmatch() runs out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
7247 if (re_extmatch_out == NULL) |
c62d63d2b9f0
patch 8.2.0033: crash when make_extmatch() runs out of memory
Bram Moolenaar <Bram@vim.org>
parents:
18812
diff
changeset
|
7248 return 0; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7249 // Loop over \z1, \z2, etc. There is no \z0. |
7258
7245d8635ac7
commit https://github.com/vim/vim/commit/5ad075c0735d3d8b97708d17c22de8facb15f997
Christian Brabandt <cb@256bit.org>
parents:
7152
diff
changeset
|
7250 for (i = 1; i < subs.synt.in_use; i++) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7251 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7252 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7253 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7254 struct multipos *mpos = &subs.synt.list.multi[i]; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7255 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7256 // Only accept single line matches that are valid. |
6547 | 7257 if (mpos->start_lnum >= 0 |
7258 && mpos->start_lnum == mpos->end_lnum | |
7259 && mpos->end_col >= mpos->start_col) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7260 re_extmatch_out->matches[i] = |
6547 | 7261 vim_strnsave(reg_getline(mpos->start_lnum) |
7262 + mpos->start_col, | |
7263 mpos->end_col - mpos->start_col); | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7264 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7265 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7266 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7267 struct linepos *lpos = &subs.synt.list.line[i]; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7268 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7269 if (lpos->start != NULL && lpos->end != NULL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7270 re_extmatch_out->matches[i] = |
20830
9064044fd4f6
patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents:
20772
diff
changeset
|
7271 vim_strnsave(lpos->start, lpos->end - lpos->start); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7272 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7273 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7274 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7275 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7276 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7277 return 1 + rex.lnum; |
4444 | 7278 } |
7279 | |
7280 /* | |
7281 * Match a regexp against a string ("line" points to the string) or multiple | |
24580
87ff80c08e4b
patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents:
24351
diff
changeset
|
7282 * lines (if "line" is NULL, use reg_getline()). |
4444 | 7283 * |
6392 | 7284 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 7285 */ |
7286 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7287 nfa_regexec_both( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7288 char_u *line, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7289 colnr_T startcol, // column to start looking for match |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7290 int *timed_out) // flag set on timeout or NULL |
4444 | 7291 { |
7292 nfa_regprog_T *prog; | |
7293 long retval = 0L; | |
7294 int i; | |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7295 colnr_T col = startcol; |
4444 | 7296 |
7297 if (REG_MULTI) | |
7298 { | |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7299 prog = (nfa_regprog_T *)rex.reg_mmatch->regprog; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7300 line = reg_getline((linenr_T)0); // relative to the cursor |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7301 rex.reg_startpos = rex.reg_mmatch->startpos; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7302 rex.reg_endpos = rex.reg_mmatch->endpos; |
4444 | 7303 } |
7304 else | |
7305 { | |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7306 prog = (nfa_regprog_T *)rex.reg_match->regprog; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7307 rex.reg_startp = rex.reg_match->startp; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7308 rex.reg_endp = rex.reg_match->endp; |
4444 | 7309 } |
7310 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7311 // Be paranoid... |
4444 | 7312 if (prog == NULL || line == NULL) |
7313 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25178
diff
changeset
|
7314 iemsg(_(e_null_argument)); |
4444 | 7315 goto theend; |
7316 } | |
7317 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7318 // If pattern contains "\c" or "\C": overrule value of rex.reg_ic |
4444 | 7319 if (prog->regflags & RF_ICASE) |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7320 rex.reg_ic = TRUE; |
4444 | 7321 else if (prog->regflags & RF_NOICASE) |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7322 rex.reg_ic = FALSE; |
4444 | 7323 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7324 // If pattern contains "\Z" overrule value of rex.reg_icombine |
4444 | 7325 if (prog->regflags & RF_ICOMBINE) |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7326 rex.reg_icombine = TRUE; |
4444 | 7327 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7328 rex.line = line; |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7329 rex.lnum = 0; // relative to line |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7330 |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7331 rex.nfa_has_zend = prog->has_zend; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7332 rex.nfa_has_backref = prog->has_backref; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7333 rex.nfa_nsubexpr = prog->nsubexp; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7334 rex.nfa_listid = 1; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7335 rex.nfa_alt_listid = 2; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7336 #ifdef DEBUG |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7337 nfa_regengine.expr = prog->pattern; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7338 #endif |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
7339 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7340 if (prog->reganch && col > 0) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7341 return 0L; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7342 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7343 rex.need_clear_subexpr = TRUE; |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7344 #ifdef FEAT_SYN_HL |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7345 // Clear the external match subpointers if necessary. |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7346 if (prog->reghasz == REX_SET) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7347 { |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7348 rex.nfa_has_zsubexpr = TRUE; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7349 rex.need_clear_zsubexpr = TRUE; |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7350 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7351 else |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7352 { |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7353 rex.nfa_has_zsubexpr = FALSE; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7354 rex.need_clear_zsubexpr = FALSE; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7355 } |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7356 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7357 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7358 if (prog->regstart != NUL) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7359 { |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7360 // Skip ahead until a character we know the match must start with. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7361 // When there is none there is no match. |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7362 if (skip_to_start(prog->regstart, &col) == FAIL) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7363 return 0L; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7364 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7365 // If match_text is set it contains the full text that must match. |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7366 // Nothing else to try. Doesn't handle combining chars well. |
15603
639b8318472c
patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
15490
diff
changeset
|
7367 if (prog->match_text != NULL && !rex.reg_icombine) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7368 return find_match_text(col, prog->regstart, prog->match_text); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7369 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7370 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7371 // If the start column is past the maximum column: no need to try. |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7372 if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7373 goto theend; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7374 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7375 // Set the "nstate" used by nfa_regcomp() to zero to trigger an error when |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7376 // it's accidentally used during execution. |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7377 nstate = 0; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7378 for (i = 0; i < prog->nstate; ++i) |
4444 | 7379 { |
7380 prog->state[i].id = i; | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7381 prog->state[i].lastlist[0] = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7382 prog->state[i].lastlist[1] = 0; |
4444 | 7383 } |
7384 | |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29028
diff
changeset
|
7385 retval = nfa_regtry(prog, col, timed_out); |
4444 | 7386 |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7387 #ifdef DEBUG |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7388 nfa_regengine.expr = NULL; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7389 #endif |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7390 |
4444 | 7391 theend: |
23270
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7392 if (retval > 0) |
23150
90b16a0022e5
patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22167
diff
changeset
|
7393 { |
23270
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7394 // Make sure the end is never before the start. Can happen when \zs and |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7395 // \ze are used. |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7396 if (REG_MULTI) |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7397 { |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7398 lpos_T *start = &rex.reg_mmatch->startpos[0]; |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7399 lpos_T *end = &rex.reg_mmatch->endpos[0]; |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7400 |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7401 if (end->lnum < start->lnum |
23150
90b16a0022e5
patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22167
diff
changeset
|
7402 || (end->lnum == start->lnum && end->col < start->col)) |
23270
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7403 rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7404 } |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7405 else |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7406 { |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7407 if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7408 rex.reg_match->endp[0] = rex.reg_match->startp[0]; |
22d0c25869d8
patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents:
23262
diff
changeset
|
7409 } |
23150
90b16a0022e5
patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22167
diff
changeset
|
7410 } |
90b16a0022e5
patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22167
diff
changeset
|
7411 |
4444 | 7412 return retval; |
7413 } | |
7414 | |
7415 /* | |
7416 * Compile a regular expression into internal code for the NFA matcher. | |
7417 * Returns the program in allocated space. Returns NULL for an error. | |
7418 */ | |
7419 static regprog_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7420 nfa_regcomp(char_u *expr, int re_flags) |
4444 | 7421 { |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7422 nfa_regprog_T *prog = NULL; |
4458 | 7423 size_t prog_size; |
4444 | 7424 int *postfix; |
7425 | |
7426 if (expr == NULL) | |
7427 return NULL; | |
7428 | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7429 #ifdef DEBUG |
4444 | 7430 nfa_regengine.expr = expr; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7431 #endif |
6533 | 7432 nfa_re_flags = re_flags; |
4444 | 7433 |
7434 init_class_tab(); | |
7435 | |
7436 if (nfa_regcomp_start(expr, re_flags) == FAIL) | |
7437 return NULL; | |
7438 | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7439 // Build postfix form of the regexp. Needed to build the NFA |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7440 // (and count its size). |
4444 | 7441 postfix = re2post(); |
7442 if (postfix == NULL) | |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7443 goto fail; // Cascaded (syntax?) error |
4444 | 7444 |
7445 /* | |
7446 * In order to build the NFA, we parse the input regexp twice: | |
7447 * 1. first pass to count size (so we can allocate space) | |
7448 * 2. second to emit code | |
7449 */ | |
7450 #ifdef ENABLE_LOG | |
7451 { | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
7452 FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 7453 |
7454 if (f != NULL) | |
7455 { | |
14145
1cf832945469
patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents:
14121
diff
changeset
|
7456 fprintf(f, "\n*****************************\n\n\n\n\tCompiling regexp \"%s\"... hold on !\n", expr); |
4444 | 7457 fclose(f); |
7458 } | |
7459 } | |
7460 #endif | |
7461 | |
7462 /* | |
7463 * PASS 1 | |
7464 * Count number of NFA states in "nstate". Do not build the NFA. | |
7465 */ | |
7466 post2nfa(postfix, post_ptr, TRUE); | |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7467 |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7468 // allocate the regprog with space for the compiled regexp |
4837
05b8436873d4
updated for version 7.3.1165
Bram Moolenaar <bram@vim.org>
parents:
4821
diff
changeset
|
7469 prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1); |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
7470 prog = alloc(prog_size); |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7471 if (prog == NULL) |
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7472 goto fail; |
4444 | 7473 state_ptr = prog->state; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7474 prog->re_in_use = FALSE; |
4444 | 7475 |
7476 /* | |
7477 * PASS 2 | |
7478 * Build the NFA | |
7479 */ | |
7480 prog->start = post2nfa(postfix, post_ptr, FALSE); | |
7481 if (prog->start == NULL) | |
7482 goto fail; | |
7483 | |
7484 prog->regflags = regflags; | |
7485 prog->engine = &nfa_regengine; | |
7486 prog->nstate = nstate; | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7487 prog->has_zend = rex.nfa_has_zend; |
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7488 prog->has_backref = rex.nfa_has_backref; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
7489 prog->nsubexp = regnpar; |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7490 |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
7491 nfa_postprocess(prog); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
7492 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7493 prog->reganch = nfa_get_reganch(prog->start, 0); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7494 prog->regstart = nfa_get_regstart(prog->start, 0); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7495 prog->match_text = nfa_get_match_text(prog->start); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7496 |
4444 | 7497 #ifdef ENABLE_LOG |
7498 nfa_postfix_dump(expr, OK); | |
7499 nfa_dump(prog); | |
7500 #endif | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7501 #ifdef FEAT_SYN_HL |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7502 // Remember whether this pattern has any \z specials in it. |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7503 prog->reghasz = re_has_z; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7504 #endif |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7505 prog->pattern = vim_strsave(expr); |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7506 #ifdef DEBUG |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7507 nfa_regengine.expr = NULL; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7508 #endif |
4444 | 7509 |
7510 out: | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13208
diff
changeset
|
7511 VIM_CLEAR(post_start); |
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13208
diff
changeset
|
7512 post_ptr = post_end = NULL; |
4444 | 7513 state_ptr = NULL; |
7514 return (regprog_T *)prog; | |
7515 | |
7516 fail: | |
13244
ac42c4b11dbc
patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents:
13208
diff
changeset
|
7517 VIM_CLEAR(prog); |
4444 | 7518 #ifdef ENABLE_LOG |
7519 nfa_postfix_dump(expr, FAIL); | |
7520 #endif | |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7521 #ifdef DEBUG |
4444 | 7522 nfa_regengine.expr = NULL; |
14354
ffd834f893aa
patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents:
14309
diff
changeset
|
7523 #endif |
4444 | 7524 goto out; |
7525 } | |
7526 | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7527 /* |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7528 * Free a compiled regexp program, returned by nfa_regcomp(). |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7529 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7530 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7531 nfa_regfree(regprog_T *prog) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7532 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7533 if (prog != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7534 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7535 vim_free(((nfa_regprog_T *)prog)->match_text); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7536 vim_free(((nfa_regprog_T *)prog)->pattern); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7537 vim_free(prog); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7538 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7539 } |
4444 | 7540 |
7541 /* | |
7542 * Match a regexp against a string. | |
7543 * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp(). | |
7544 * Uses curbuf for line count and 'iskeyword'. | |
5838 | 7545 * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break. |
4444 | 7546 * |
6392 | 7547 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 7548 */ |
7549 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7550 nfa_regexec_nl( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7551 regmatch_T *rmp, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7552 char_u *line, // string to match against |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7553 colnr_T col, // column to start looking for match |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7554 int line_lbr) |
4444 | 7555 { |
10245
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7556 rex.reg_match = rmp; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7557 rex.reg_mmatch = NULL; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7558 rex.reg_maxline = 0; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7559 rex.reg_line_lbr = line_lbr; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7560 rex.reg_buf = curbuf; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7561 rex.reg_win = NULL; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7562 rex.reg_ic = rmp->rm_ic; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7563 rex.reg_icombine = FALSE; |
d76ccdacb41e
commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents:
10170
diff
changeset
|
7564 rex.reg_maxcol = 0; |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29028
diff
changeset
|
7565 return nfa_regexec_both(line, col, NULL); |
4444 | 7566 } |
7567 | |
7568 | |
7569 /* | |
7570 * Match a regexp against multiple lines. | |
7571 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). | |
7572 * Uses curbuf for line count and 'iskeyword'. | |
7573 * | |
6392 | 7574 * Return <= 0 if there is no match. Return number of lines contained in the |
4444 | 7575 * match otherwise. |
7576 * | |
7577 * Note: the body is the same as bt_regexec() except for nfa_regexec_both() | |
7578 * | |
7579 * ! Also NOTE : match may actually be in another line. e.g.: | |
7580 * when r.e. is \nc, cursor is at 'a' and the text buffer looks like | |
7581 * | |
7582 * +-------------------------+ | |
7583 * |a | | |
7584 * |b | | |
7585 * |c | | |
7586 * | | | |
7587 * +-------------------------+ | |
7588 * | |
7589 * then nfa_regexec_multi() returns 3. while the original | |
7590 * vim_regexec_multi() returns 0 and a second call at line 2 will return 2. | |
7591 * | |
7592 * FIXME if this behavior is not compatible. | |
7593 */ | |
7594 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7595 nfa_regexec_multi( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7596 regmmatch_T *rmp, |
18812
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7597 win_T *win, // window in which to search or NULL |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7598 buf_T *buf, // buffer in which to search |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7599 linenr_T lnum, // nr of line to start looking for match |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7600 colnr_T col, // column to start looking for match |
d34ec6fe207d
patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
7601 int *timed_out) // flag set on timeout or NULL |
4444 | 7602 { |
19405
08f4dc2ba716
patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents:
18945
diff
changeset
|
7603 init_regexec_multi(rmp, win, buf, lnum); |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
29028
diff
changeset
|
7604 return nfa_regexec_both(NULL, col, timed_out); |
4444 | 7605 } |
7606 | |
7607 #ifdef DEBUG | |
7608 # undef ENABLE_LOG | |
7609 #endif |