Mercurial > vim
annotate src/regexp_nfa.c @ 9044:5abf6f38cbbb v7.4.1807
commit https://github.com/vim/vim/commit/d75263c020a5044fa73bc8cd57ce73ca5e23b360
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 30 16:07:23 2016 +0200
patch 7.4.1807
Problem: Test_out_close_cb sometimes fails.
Solution: Always write DETACH to out, not err.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Apr 2016 16:15:05 +0200 |
parents | 42b228c8701b |
children | 3666915cac0b |
rev | line source |
---|---|
4444 | 1 /* vi:set ts=8 sts=4 sw=4: |
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! |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
21 * Do disable all of this when compiling Vim for debugging, undefine DEBUG in |
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 | |
5296 | 32 /* Added to NFA_ANY - NFA_NUPPER_IC to include a NL. */ |
33 #define NFA_ADD_NL 31 | |
34 | |
4444 | 35 enum |
36 { | |
37 NFA_SPLIT = -1024, | |
38 NFA_MATCH, | |
5370 | 39 NFA_EMPTY, /* matches 0-length */ |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
40 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
41 NFA_START_COLL, /* [abc] start */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
42 NFA_END_COLL, /* [abc] end */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
43 NFA_START_NEG_COLL, /* [^abc] start */ |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
44 NFA_END_NEG_COLL, /* [^abc] end (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
45 NFA_RANGE, /* range of the two previous items |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
46 * (postfix only) */ |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
47 NFA_RANGE_MIN, /* low end of a range */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
48 NFA_RANGE_MAX, /* high end of a range */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
49 |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
50 NFA_CONCAT, /* concatenate two previous items (postfix |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
51 * only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
52 NFA_OR, /* \| (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
53 NFA_STAR, /* greedy * (posfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
54 NFA_STAR_NONGREEDY, /* non-greedy * (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
55 NFA_QUEST, /* greedy \? (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
56 NFA_QUEST_NONGREEDY, /* non-greedy \? (postfix only) */ |
4444 | 57 |
58 NFA_BOL, /* ^ Begin line */ | |
59 NFA_EOL, /* $ End line */ | |
60 NFA_BOW, /* \< Begin word */ | |
61 NFA_EOW, /* \> End word */ | |
62 NFA_BOF, /* \%^ Begin file */ | |
63 NFA_EOF, /* \%$ End file */ | |
64 NFA_NEWL, | |
65 NFA_ZSTART, /* Used for \zs */ | |
66 NFA_ZEND, /* Used for \ze */ | |
67 NFA_NOPEN, /* Start of subexpression marked with \%( */ | |
68 NFA_NCLOSE, /* End of subexpr. marked with \%( ... \) */ | |
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, |
4444 | 81 NFA_COMPOSING, /* Next nodes in NFA are part of the |
82 composing multibyte char */ | |
83 NFA_END_COMPOSING, /* End of a composing char in the NFA */ | |
5901 | 84 NFA_ANY_COMPOSING, /* \%C: Any composing characters. */ |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
85 NFA_OPT_CHARS, /* \%[abc] */ |
4444 | 86 |
87 /* The following are used only in the postfix form, not in the NFA */ | |
88 NFA_PREV_ATOM_NO_WIDTH, /* Used for \@= */ | |
89 NFA_PREV_ATOM_NO_WIDTH_NEG, /* Used for \@! */ | |
90 NFA_PREV_ATOM_JUST_BEFORE, /* Used for \@<= */ | |
91 NFA_PREV_ATOM_JUST_BEFORE_NEG, /* Used for \@<! */ | |
92 NFA_PREV_ATOM_LIKE_PATTERN, /* Used for \@> */ | |
93 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
94 NFA_BACKREF1, /* \1 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
95 NFA_BACKREF2, /* \2 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
96 NFA_BACKREF3, /* \3 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
97 NFA_BACKREF4, /* \4 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
98 NFA_BACKREF5, /* \5 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
99 NFA_BACKREF6, /* \6 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
100 NFA_BACKREF7, /* \7 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
101 NFA_BACKREF8, /* \8 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
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 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
104 NFA_ZREF1, /* \z1 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
105 NFA_ZREF2, /* \z2 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
106 NFA_ZREF3, /* \z3 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
107 NFA_ZREF4, /* \z4 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
108 NFA_ZREF5, /* \z5 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
109 NFA_ZREF6, /* \z6 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
110 NFA_ZREF7, /* \z7 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
111 NFA_ZREF8, /* \z8 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
112 NFA_ZREF9, /* \z9 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
113 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
114 NFA_SKIP, /* Skip characters */ |
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 |
162 /* NFA_FIRST_NL */ | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
163 NFA_ANY, /* Match any one character. */ |
4444 | 164 NFA_IDENT, /* Match identifier char */ |
165 NFA_SIDENT, /* Match identifier char but no digit */ | |
166 NFA_KWORD, /* Match keyword char */ | |
167 NFA_SKWORD, /* Match word char but no digit */ | |
168 NFA_FNAME, /* Match file name char */ | |
169 NFA_SFNAME, /* Match file name char but no digit */ | |
170 NFA_PRINT, /* Match printable char */ | |
171 NFA_SPRINT, /* Match printable char but no digit */ | |
172 NFA_WHITE, /* Match whitespace char */ | |
173 NFA_NWHITE, /* Match non-whitespace char */ | |
174 NFA_DIGIT, /* Match digit char */ | |
175 NFA_NDIGIT, /* Match non-digit char */ | |
176 NFA_HEX, /* Match hex char */ | |
177 NFA_NHEX, /* Match non-hex char */ | |
178 NFA_OCTAL, /* Match octal char */ | |
179 NFA_NOCTAL, /* Match non-octal char */ | |
180 NFA_WORD, /* Match word char */ | |
181 NFA_NWORD, /* Match non-word char */ | |
182 NFA_HEAD, /* Match head char */ | |
183 NFA_NHEAD, /* Match non-head char */ | |
184 NFA_ALPHA, /* Match alpha char */ | |
185 NFA_NALPHA, /* Match non-alpha char */ | |
186 NFA_LOWER, /* Match lowercase char */ | |
187 NFA_NLOWER, /* Match non-lowercase char */ | |
188 NFA_UPPER, /* Match uppercase char */ | |
189 NFA_NUPPER, /* Match non-uppercase char */ | |
5296 | 190 NFA_LOWER_IC, /* Match [a-z] */ |
191 NFA_NLOWER_IC, /* Match [^a-z] */ | |
192 NFA_UPPER_IC, /* Match [A-Z] */ | |
193 NFA_NUPPER_IC, /* Match [^A-Z] */ | |
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 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
198 NFA_CURSOR, /* Match cursor pos */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
199 NFA_LNUM, /* Match line number */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
200 NFA_LNUM_GT, /* Match > line number */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
201 NFA_LNUM_LT, /* Match < line number */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
202 NFA_COL, /* Match cursor column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
203 NFA_COL_GT, /* Match > cursor column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
204 NFA_COL_LT, /* Match < cursor column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
205 NFA_VCOL, /* Match cursor virtual column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
206 NFA_VCOL_GT, /* Match > cursor virtual column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
207 NFA_VCOL_LT, /* Match < cursor virtual column */ |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
208 NFA_MARK, /* Match mark */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
209 NFA_MARK_GT, /* Match > mark */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
210 NFA_MARK_LT, /* Match < mark */ |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
211 NFA_VISUAL, /* Match Visual area */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
212 |
4444 | 213 /* Character classes [:alnum:] etc */ |
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, | |
229 NFA_CLASS_ESCAPE | |
230 }; | |
231 | |
232 /* Keep in sync with classchars. */ | |
233 static int nfa_classcodes[] = { | |
234 NFA_ANY, NFA_IDENT, NFA_SIDENT, NFA_KWORD,NFA_SKWORD, | |
235 NFA_FNAME, NFA_SFNAME, NFA_PRINT, NFA_SPRINT, | |
236 NFA_WHITE, NFA_NWHITE, NFA_DIGIT, NFA_NDIGIT, | |
237 NFA_HEX, NFA_NHEX, NFA_OCTAL, NFA_NOCTAL, | |
238 NFA_WORD, NFA_NWORD, NFA_HEAD, NFA_NHEAD, | |
239 NFA_ALPHA, NFA_NALPHA, NFA_LOWER, NFA_NLOWER, | |
240 NFA_UPPER, NFA_NUPPER | |
241 }; | |
242 | |
5511 | 243 static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely"); |
4444 | 244 static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c"); |
5511 | 245 static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %ld"); |
4444 | 246 |
6533 | 247 /* re_flags passed to nfa_regcomp() */ |
248 static int nfa_re_flags; | |
249 | |
4444 | 250 /* NFA regexp \ze operator encountered. */ |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
251 static int nfa_has_zend; |
4444 | 252 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
253 /* NFA regexp \1 .. \9 encountered. */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
254 static int nfa_has_backref; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
255 |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
256 #ifdef FEAT_SYN_HL |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
257 /* NFA regexp has \z( ), set zsubexpr. */ |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
258 static int nfa_has_zsubexpr; |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
259 #endif |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
260 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
261 /* Number of sub expressions actually being used during execution. 1 if only |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
262 * the whole match (subexpr 0) is used. */ |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
263 static int nfa_nsubexpr; |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
264 |
4444 | 265 static int *post_start; /* holds the postfix form of r.e. */ |
266 static int *post_end; | |
267 static int *post_ptr; | |
268 | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
269 static int nstate; /* Number of states in the NFA. Also used when |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
270 * executing. */ |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
271 static int istate; /* Index in the state vector, used in alloc_state() */ |
4444 | 272 |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
273 /* If not NULL match must end at this position */ |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
274 static save_se_T *nfa_endp = NULL; |
4444 | 275 |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
276 /* listid is global, so that it increases on recursive calls to |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
277 * nfa_regmatch(), which means we don't have to clear the lastlist field of |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
278 * all the states. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
279 static int nfa_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
280 static int nfa_alt_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
281 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
282 /* 0 for first call to nfa_regmatch(), 1 for recursive call. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
283 static int nfa_ll_index = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
284 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
285 static int nfa_regcomp_start(char_u *expr, int re_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
286 static int nfa_get_reganch(nfa_state_T *start, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
287 static int nfa_get_regstart(nfa_state_T *start, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
288 static char_u *nfa_get_match_text(nfa_state_T *start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
289 static int realloc_post_list(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
290 static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
291 static int nfa_emit_equi_class(int c); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
292 static int nfa_regatom(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
293 static int nfa_regpiece(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
294 static int nfa_regconcat(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
295 static int nfa_regbranch(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
296 static int nfa_reg(int paren); |
4444 | 297 #ifdef DEBUG |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
298 static void nfa_set_code(int c); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
299 static void nfa_postfix_dump(char_u *expr, int retval); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
300 static void nfa_print_state(FILE *debugf, nfa_state_T *state); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
301 static void nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
302 static void nfa_dump(nfa_regprog_T *prog); |
4444 | 303 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
304 static int *re2post(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
305 static nfa_state_T *alloc_state(int c, nfa_state_T *out, nfa_state_T *out1); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
306 static void st_error(int *postfix, int *end, int *p); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
307 static int nfa_max_width(nfa_state_T *startstate, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
308 static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
309 static void nfa_postprocess(nfa_regprog_T *prog); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
310 static int check_char_class(int class, int c); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
311 static void nfa_save_listids(nfa_regprog_T *prog, int *list); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
312 static void nfa_restore_listids(nfa_regprog_T *prog, int *list); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
313 static int nfa_re_num_cmp(long_u val, int op, long_u pos); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
314 static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
315 static long nfa_regexec_both(char_u *line, colnr_T col, proftime_T *tm); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
316 static regprog_T *nfa_regcomp(char_u *expr, int re_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
317 static void nfa_regfree(regprog_T *prog); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
318 static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
319 static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
320 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
|
321 static int failure_chance(nfa_state_T *state, int depth); |
4444 | 322 |
323 /* helper functions used when doing re2post() ... regatom() parsing */ | |
324 #define EMIT(c) do { \ | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
325 if (post_ptr >= post_end && realloc_post_list() == FAIL) \ |
4444 | 326 return FAIL; \ |
327 *post_ptr++ = c; \ | |
328 } while (0) | |
329 | |
330 /* | |
331 * Initialize internal variables before NFA compilation. | |
332 * Return OK on success, FAIL otherwise. | |
333 */ | |
334 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
335 nfa_regcomp_start( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
336 char_u *expr, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
337 int re_flags) /* see vim_regcomp() */ |
4444 | 338 { |
4458 | 339 size_t postfix_size; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
340 int nstate_max; |
4444 | 341 |
342 nstate = 0; | |
343 istate = 0; | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
344 /* A reasonable estimation for maximum size */ |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
345 nstate_max = (int)(STRLEN(expr) + 1) * 25; |
4444 | 346 |
4454 | 347 /* Some items blow up in size, such as [A-z]. Add more space for that. |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
348 * When it is still not enough realloc_post_list() will be used. */ |
4458 | 349 nstate_max += 1000; |
4454 | 350 |
351 /* Size for postfix representation of expr. */ | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
352 postfix_size = sizeof(int) * nstate_max; |
4454 | 353 |
4444 | 354 post_start = (int *)lalloc(postfix_size, TRUE); |
355 if (post_start == NULL) | |
356 return FAIL; | |
357 post_ptr = post_start; | |
4454 | 358 post_end = post_start + nstate_max; |
4444 | 359 nfa_has_zend = FALSE; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
360 nfa_has_backref = FALSE; |
4444 | 361 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
362 /* shared with BT engine */ |
4444 | 363 regcomp_start(expr, re_flags); |
364 | |
365 return OK; | |
366 } | |
367 | |
368 /* | |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
369 * 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
|
370 * of the line. |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
371 */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
372 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
373 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
|
374 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
375 nfa_state_T *p = start; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
376 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
377 if (depth > 4) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
378 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
379 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
380 while (p != NULL) |
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 switch (p->c) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
383 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
384 case NFA_BOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
385 case NFA_BOF: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
386 return 1; /* yes! */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
387 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
388 case NFA_ZSTART: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
389 case NFA_ZEND: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
390 case NFA_CURSOR: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
391 case NFA_VISUAL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
392 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
393 case NFA_MOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
394 case NFA_MOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
395 case NFA_MOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
396 case NFA_MOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
397 case NFA_MOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
398 case NFA_MOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
399 case NFA_MOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
400 case NFA_MOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
401 case NFA_MOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
402 case NFA_MOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
403 case NFA_NOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
404 #ifdef FEAT_SYN_HL |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
405 case NFA_ZOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
406 case NFA_ZOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
407 case NFA_ZOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
408 case NFA_ZOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
409 case NFA_ZOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
410 case NFA_ZOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
411 case NFA_ZOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
412 case NFA_ZOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
413 case NFA_ZOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
414 case NFA_ZOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
415 #endif |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
416 p = p->out; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
417 break; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
418 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
419 case NFA_SPLIT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
420 return nfa_get_reganch(p->out, depth + 1) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
421 && nfa_get_reganch(p->out1, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
422 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
423 default: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
424 return 0; /* noooo */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
425 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
426 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
427 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
428 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
429 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
430 /* |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
431 * 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
|
432 * at start of the match. |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
433 */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
434 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
435 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
|
436 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
437 nfa_state_T *p = start; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
438 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
439 if (depth > 4) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
440 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
441 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
442 while (p != NULL) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
443 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
444 switch (p->c) |
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 /* all kinds of zero-width matches */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
447 case NFA_BOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
448 case NFA_BOF: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
449 case NFA_BOW: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
450 case NFA_EOW: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
451 case NFA_ZSTART: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
452 case NFA_ZEND: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
453 case NFA_CURSOR: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
454 case NFA_VISUAL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
455 case NFA_LNUM: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
456 case NFA_LNUM_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
457 case NFA_LNUM_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
458 case NFA_COL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
459 case NFA_COL_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
460 case NFA_COL_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
461 case NFA_VCOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
462 case NFA_VCOL_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
463 case NFA_VCOL_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
464 case NFA_MARK: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
465 case NFA_MARK_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
466 case NFA_MARK_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
467 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
468 case NFA_MOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
469 case NFA_MOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
470 case NFA_MOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
471 case NFA_MOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
472 case NFA_MOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
473 case NFA_MOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
474 case NFA_MOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
475 case NFA_MOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
476 case NFA_MOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
477 case NFA_MOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
478 case NFA_NOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
479 #ifdef FEAT_SYN_HL |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
480 case NFA_ZOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
481 case NFA_ZOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
482 case NFA_ZOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
483 case NFA_ZOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
484 case NFA_ZOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
485 case NFA_ZOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
486 case NFA_ZOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
487 case NFA_ZOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
488 case NFA_ZOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
489 case NFA_ZOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
490 #endif |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
491 p = p->out; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
492 break; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
493 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
494 case NFA_SPLIT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
495 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
496 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
|
497 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
|
498 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
499 if (c1 == c2) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
500 return c1; /* yes! */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
501 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
502 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
503 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
504 default: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
505 if (p->c > 0) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
506 return p->c; /* yes! */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
507 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
508 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
509 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
510 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
511 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
512 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
513 /* |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
514 * 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
|
515 * 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
|
516 * regstart. Otherwise return NULL. |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
517 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
518 static char_u * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
519 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
|
520 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
521 nfa_state_T *p = start; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
522 int len = 0; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
523 char_u *ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
524 char_u *s; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
525 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
526 if (p->c != NFA_MOPEN) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
527 return NULL; /* just in case */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
528 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
529 while (p->c > 0) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
530 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
531 len += MB_CHAR2LEN(p->c); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
532 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
533 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
534 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
|
535 return NULL; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
536 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
537 ret = alloc(len); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
538 if (ret != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
539 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
540 p = start->out->out; /* skip first char, it goes into regstart */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
541 s = ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
542 while (p->c > 0) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
543 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
544 #ifdef FEAT_MBYTE |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
545 if (has_mbyte) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
546 s += (*mb_char2bytes)(p->c, s); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
547 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
548 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
549 *s++ = p->c; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
550 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
551 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
552 *s = NUL; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
553 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
554 return ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
555 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
556 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
557 /* |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
558 * Allocate more space for post_start. Called when |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
559 * running above the estimated number of states. |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
560 */ |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
561 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
562 realloc_post_list(void) |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
563 { |
4667
9e7ef781d494
updated for version 7.3.1081
Bram Moolenaar <bram@vim.org>
parents:
4661
diff
changeset
|
564 int nstate_max = (int)(post_end - post_start); |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
565 int new_max = nstate_max + 1000; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
566 int *new_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
567 int *old_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
568 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
569 new_start = (int *)lalloc(new_max * sizeof(int), TRUE); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
570 if (new_start == NULL) |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
571 return FAIL; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
572 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
|
573 old_start = post_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
574 post_start = new_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
575 post_ptr = new_start + (post_ptr - old_start); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
576 post_end = post_start + new_max; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
577 vim_free(old_start); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
578 return OK; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
579 } |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
580 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
581 /* |
4444 | 582 * Search between "start" and "end" and try to recognize a |
583 * character class in expanded form. For example [0-9]. | |
584 * On success, return the id the character class to be emitted. | |
585 * On failure, return 0 (=FAIL) | |
586 * Start points to the first char of the range, while end should point | |
587 * to the closing brace. | |
5296 | 588 * Keep in mind that 'ignorecase' applies at execution time, thus [a-z] may |
589 * need to be interpreted as [a-zA-Z]. | |
4444 | 590 */ |
591 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
592 nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) |
4444 | 593 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
594 # define CLASS_not 0x80 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
595 # define CLASS_af 0x40 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
596 # define CLASS_AF 0x20 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
597 # define CLASS_az 0x10 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
598 # define CLASS_AZ 0x08 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
599 # define CLASS_o7 0x04 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
600 # define CLASS_o9 0x02 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
601 # define CLASS_underscore 0x01 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
602 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
603 int newl = FALSE; |
4444 | 604 char_u *p; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
605 int config = 0; |
4444 | 606 |
607 if (extra_newl == TRUE) | |
608 newl = TRUE; | |
609 | |
610 if (*end != ']') | |
611 return FAIL; | |
612 p = start; | |
613 if (*p == '^') | |
614 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
615 config |= CLASS_not; |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
616 p++; |
4444 | 617 } |
618 | |
619 while (p < end) | |
620 { | |
621 if (p + 2 < end && *(p + 1) == '-') | |
622 { | |
623 switch (*p) | |
624 { | |
625 case '0': | |
626 if (*(p + 2) == '9') | |
627 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
628 config |= CLASS_o9; |
4444 | 629 break; |
630 } | |
631 else | |
632 if (*(p + 2) == '7') | |
633 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
634 config |= CLASS_o7; |
4444 | 635 break; |
636 } | |
637 case 'a': | |
638 if (*(p + 2) == 'z') | |
639 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
640 config |= CLASS_az; |
4444 | 641 break; |
642 } | |
643 else | |
644 if (*(p + 2) == 'f') | |
645 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
646 config |= CLASS_af; |
4444 | 647 break; |
648 } | |
649 case 'A': | |
650 if (*(p + 2) == 'Z') | |
651 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
652 config |= CLASS_AZ; |
4444 | 653 break; |
654 } | |
655 else | |
656 if (*(p + 2) == 'F') | |
657 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
658 config |= CLASS_AF; |
4444 | 659 break; |
660 } | |
661 /* FALLTHROUGH */ | |
662 default: | |
663 return FAIL; | |
664 } | |
665 p += 3; | |
666 } | |
667 else if (p + 1 < end && *p == '\\' && *(p + 1) == 'n') | |
668 { | |
669 newl = TRUE; | |
670 p += 2; | |
671 } | |
672 else if (*p == '_') | |
673 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
674 config |= CLASS_underscore; |
4444 | 675 p ++; |
676 } | |
677 else if (*p == '\n') | |
678 { | |
679 newl = TRUE; | |
680 p ++; | |
681 } | |
682 else | |
683 return FAIL; | |
684 } /* while (p < end) */ | |
685 | |
686 if (p != end) | |
687 return FAIL; | |
688 | |
689 if (newl == TRUE) | |
5296 | 690 extra_newl = NFA_ADD_NL; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
691 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
692 switch (config) |
4444 | 693 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
694 case CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
695 return extra_newl + NFA_DIGIT; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
696 case CLASS_not | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
697 return extra_newl + NFA_NDIGIT; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
698 case CLASS_af | CLASS_AF | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
699 return extra_newl + NFA_HEX; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
700 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
|
701 return extra_newl + NFA_NHEX; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
702 case CLASS_o7: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
703 return extra_newl + NFA_OCTAL; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
704 case CLASS_not | CLASS_o7: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
705 return extra_newl + NFA_NOCTAL; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
706 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
|
707 return extra_newl + NFA_WORD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
708 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
|
709 return extra_newl + NFA_NWORD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
710 case CLASS_az | CLASS_AZ | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
711 return extra_newl + NFA_HEAD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
712 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
|
713 return extra_newl + NFA_NHEAD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
714 case CLASS_az | CLASS_AZ: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
715 return extra_newl + NFA_ALPHA; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
716 case CLASS_not | CLASS_az | CLASS_AZ: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
717 return extra_newl + NFA_NALPHA; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
718 case CLASS_az: |
5296 | 719 return extra_newl + NFA_LOWER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
720 case CLASS_not | CLASS_az: |
5296 | 721 return extra_newl + NFA_NLOWER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
722 case CLASS_AZ: |
5296 | 723 return extra_newl + NFA_UPPER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
724 case CLASS_not | CLASS_AZ: |
5296 | 725 return extra_newl + NFA_NUPPER_IC; |
4444 | 726 } |
727 return FAIL; | |
728 } | |
729 | |
730 /* | |
731 * Produce the bytes for equivalence class "c". | |
732 * Currently only handles latin1, latin9 and utf-8. | |
733 * Emits bytes in postfix notation: 'a,b,NFA_OR,c,NFA_OR' is | |
734 * equivalent to 'a OR b OR c' | |
735 * | |
736 * NOTE! When changing this function, also update reg_equi_class() | |
737 */ | |
738 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
739 nfa_emit_equi_class(int c) |
4444 | 740 { |
5351 | 741 #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); |
742 #ifdef FEAT_MBYTE | |
743 # define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT); | |
744 #else | |
745 # define EMITMBC(c) | |
746 #endif | |
4444 | 747 |
748 #ifdef FEAT_MBYTE | |
749 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0 | |
750 || STRCMP(p_enc, "iso-8859-15") == 0) | |
751 #endif | |
752 { | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
753 #ifdef EBCDIC |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
754 # define A_circumflex 0x62 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
755 # define A_diaeresis 0x63 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
756 # define A_grave 0x64 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
757 # define A_acute 0x65 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
758 # define A_virguilla 0x66 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
759 # define A_ring 0x67 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
760 # define C_cedilla 0x68 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
761 # define E_acute 0x71 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
762 # define E_circumflex 0x72 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
763 # define E_diaeresis 0x73 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
764 # define E_grave 0x74 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
765 # define I_acute 0x75 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
766 # define I_circumflex 0x76 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
767 # define I_diaeresis 0x77 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
768 # define I_grave 0x78 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
769 # define N_virguilla 0x69 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
770 # define O_circumflex 0xeb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
771 # define O_diaeresis 0xec |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
772 # define O_grave 0xed |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
773 # define O_acute 0xee |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
774 # define O_virguilla 0xef |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
775 # define O_slash 0x80 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
776 # define U_circumflex 0xfb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
777 # define U_diaeresis 0xfc |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
778 # define U_grave 0xfd |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
779 # define U_acute 0xfe |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
780 # define Y_acute 0xba |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
781 # define a_grave 0x42 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
782 # define a_acute 0x43 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
783 # define a_circumflex 0x44 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
784 # define a_virguilla 0x45 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
785 # define a_diaeresis 0x46 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
786 # define a_ring 0x47 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
787 # define c_cedilla 0x48 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
788 # define e_grave 0x51 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
789 # define e_acute 0x52 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
790 # define e_circumflex 0x53 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
791 # define e_diaeresis 0x54 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
792 # define i_grave 0x55 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
793 # define i_acute 0x56 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
794 # define i_circumflex 0x57 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
795 # define i_diaeresis 0x58 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
796 # define n_virguilla 0x49 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
797 # define o_grave 0xcb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
798 # define o_acute 0xcc |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
799 # define o_circumflex 0xcd |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
800 # define o_virguilla 0xce |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
801 # define o_diaeresis 0xcf |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
802 # define o_slash 0x70 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
803 # define u_grave 0xdb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
804 # define u_acute 0xdc |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
805 # define u_circumflex 0xdd |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
806 # define u_diaeresis 0xde |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
807 # define y_acute 0x8d |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
808 # define y_diaeresis 0xdf |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
809 #else |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
810 # define A_grave 0xc0 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
811 # define A_acute 0xc1 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
812 # define A_circumflex 0xc2 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
813 # define A_virguilla 0xc3 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
814 # define A_diaeresis 0xc4 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
815 # define A_ring 0xc5 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
816 # define C_cedilla 0xc7 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
817 # define E_grave 0xc8 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
818 # define E_acute 0xc9 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
819 # define E_circumflex 0xca |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
820 # define E_diaeresis 0xcb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
821 # define I_grave 0xcc |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
822 # define I_acute 0xcd |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
823 # define I_circumflex 0xce |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
824 # define I_diaeresis 0xcf |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
825 # define N_virguilla 0xd1 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
826 # define O_grave 0xd2 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
827 # define O_acute 0xd3 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
828 # define O_circumflex 0xd4 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
829 # define O_virguilla 0xd5 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
830 # define O_diaeresis 0xd6 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
831 # define O_slash 0xd8 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
832 # define U_grave 0xd9 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
833 # define U_acute 0xda |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
834 # define U_circumflex 0xdb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
835 # define U_diaeresis 0xdc |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
836 # define Y_acute 0xdd |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
837 # define a_grave 0xe0 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
838 # define a_acute 0xe1 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
839 # define a_circumflex 0xe2 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
840 # define a_virguilla 0xe3 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
841 # define a_diaeresis 0xe4 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
842 # define a_ring 0xe5 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
843 # define c_cedilla 0xe7 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
844 # define e_grave 0xe8 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
845 # define e_acute 0xe9 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
846 # define e_circumflex 0xea |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
847 # define e_diaeresis 0xeb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
848 # define i_grave 0xec |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
849 # define i_acute 0xed |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
850 # define i_circumflex 0xee |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
851 # define i_diaeresis 0xef |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
852 # define n_virguilla 0xf1 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
853 # define o_grave 0xf2 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
854 # define o_acute 0xf3 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
855 # define o_circumflex 0xf4 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
856 # define o_virguilla 0xf5 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
857 # define o_diaeresis 0xf6 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
858 # define o_slash 0xf8 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
859 # define u_grave 0xf9 |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
860 # define u_acute 0xfa |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
861 # define u_circumflex 0xfb |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
862 # define u_diaeresis 0xfc |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
863 # define y_acute 0xfd |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
864 # define y_diaeresis 0xff |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
865 #endif |
4444 | 866 switch (c) |
867 { | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
868 case 'A': case A_grave: case A_acute: case A_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
869 case A_virguilla: case A_diaeresis: case A_ring: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
870 CASEMBC(0x100) CASEMBC(0x102) CASEMBC(0x104) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
871 CASEMBC(0x1cd) CASEMBC(0x1de) CASEMBC(0x1e0) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
872 CASEMBC(0x1ea2) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
873 EMIT2('A'); EMIT2(A_grave); EMIT2(A_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
874 EMIT2(A_circumflex); EMIT2(A_virguilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
875 EMIT2(A_diaeresis); EMIT2(A_ring); |
5351 | 876 EMITMBC(0x100) EMITMBC(0x102) EMITMBC(0x104) |
877 EMITMBC(0x1cd) EMITMBC(0x1de) EMITMBC(0x1e0) | |
878 EMITMBC(0x1ea2) | |
879 return OK; | |
880 | |
881 case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06) | |
882 EMIT2('B'); EMITMBC(0x1e02) EMITMBC(0x1e06) | |
4444 | 883 return OK; |
884 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
885 case 'C': case C_cedilla: CASEMBC(0x106) CASEMBC(0x108) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
886 CASEMBC(0x10a) CASEMBC(0x10c) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
887 EMIT2('C'); EMIT2(C_cedilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
888 EMITMBC(0x106) EMITMBC(0x108) |
5351 | 889 EMITMBC(0x10a) EMITMBC(0x10c) |
890 return OK; | |
891 | |
892 case 'D': CASEMBC(0x10e) CASEMBC(0x110) CASEMBC(0x1e0a) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
893 CASEMBC(0x1e0e) CASEMBC(0x1e10) |
5351 | 894 EMIT2('D'); EMITMBC(0x10e) EMITMBC(0x110) EMITMBC(0x1e0a) |
895 EMITMBC(0x1e0e) EMITMBC(0x1e10) | |
4444 | 896 return OK; |
897 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
898 case 'E': case E_grave: case E_acute: case E_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
899 case E_diaeresis: CASEMBC(0x112) CASEMBC(0x114) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
900 CASEMBC(0x116) CASEMBC(0x118) CASEMBC(0x11a) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
901 CASEMBC(0x1eba) CASEMBC(0x1ebc) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
902 EMIT2('E'); EMIT2(E_grave); EMIT2(E_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
903 EMIT2(E_circumflex); EMIT2(E_diaeresis); |
5351 | 904 EMITMBC(0x112) EMITMBC(0x114) EMITMBC(0x116) |
905 EMITMBC(0x118) EMITMBC(0x11a) EMITMBC(0x1eba) | |
906 EMITMBC(0x1ebc) | |
907 return OK; | |
908 | |
909 case 'F': CASEMBC(0x1e1e) | |
910 EMIT2('F'); EMITMBC(0x1e1e) | |
911 return OK; | |
912 | |
913 case 'G': CASEMBC(0x11c) CASEMBC(0x11e) CASEMBC(0x120) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
914 CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
915 CASEMBC(0x1f4) CASEMBC(0x1e20) |
5351 | 916 EMIT2('G'); EMITMBC(0x11c) EMITMBC(0x11e) EMITMBC(0x120) |
917 EMITMBC(0x122) EMITMBC(0x1e4) EMITMBC(0x1e6) | |
918 EMITMBC(0x1f4) EMITMBC(0x1e20) | |
919 return OK; | |
920 | |
921 case 'H': CASEMBC(0x124) CASEMBC(0x126) CASEMBC(0x1e22) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
922 CASEMBC(0x1e26) CASEMBC(0x1e28) |
5351 | 923 EMIT2('H'); EMITMBC(0x124) EMITMBC(0x126) EMITMBC(0x1e22) |
924 EMITMBC(0x1e26) EMITMBC(0x1e28) | |
4444 | 925 return OK; |
926 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
927 case 'I': case I_grave: case I_acute: case I_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
928 case I_diaeresis: CASEMBC(0x128) CASEMBC(0x12a) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
929 CASEMBC(0x12c) CASEMBC(0x12e) CASEMBC(0x130) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
930 CASEMBC(0x1cf) CASEMBC(0x1ec8) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
931 EMIT2('I'); EMIT2(I_grave); EMIT2(I_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
932 EMIT2(I_circumflex); EMIT2(I_diaeresis); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
933 EMITMBC(0x128) EMITMBC(0x12a) |
5351 | 934 EMITMBC(0x12c) EMITMBC(0x12e) EMITMBC(0x130) |
935 EMITMBC(0x1cf) EMITMBC(0x1ec8) | |
936 return OK; | |
937 | |
938 case 'J': CASEMBC(0x134) | |
939 EMIT2('J'); EMITMBC(0x134) | |
940 return OK; | |
941 | |
942 case 'K': CASEMBC(0x136) CASEMBC(0x1e8) CASEMBC(0x1e30) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
943 CASEMBC(0x1e34) |
5351 | 944 EMIT2('K'); EMITMBC(0x136) EMITMBC(0x1e8) EMITMBC(0x1e30) |
945 EMITMBC(0x1e34) | |
946 return OK; | |
947 | |
948 case 'L': CASEMBC(0x139) CASEMBC(0x13b) CASEMBC(0x13d) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
949 CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a) |
5351 | 950 EMIT2('L'); EMITMBC(0x139) EMITMBC(0x13b) EMITMBC(0x13d) |
951 EMITMBC(0x13f) EMITMBC(0x141) EMITMBC(0x1e3a) | |
952 return OK; | |
953 | |
954 case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40) | |
955 EMIT2('M'); EMITMBC(0x1e3e) EMITMBC(0x1e40) | |
4444 | 956 return OK; |
957 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
958 case 'N': case N_virguilla: CASEMBC(0x143) CASEMBC(0x145) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
959 CASEMBC(0x147) CASEMBC(0x1e44) CASEMBC(0x1e48) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
960 EMIT2('N'); EMIT2(N_virguilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
961 EMITMBC(0x143) EMITMBC(0x145) |
5351 | 962 EMITMBC(0x147) EMITMBC(0x1e44) EMITMBC(0x1e48) |
4444 | 963 return OK; |
964 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
965 case 'O': case O_grave: case O_acute: case O_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
966 case O_virguilla: case O_diaeresis: case O_slash: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
967 CASEMBC(0x14c) CASEMBC(0x14e) CASEMBC(0x150) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
968 CASEMBC(0x1a0) CASEMBC(0x1d1) CASEMBC(0x1ea) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
969 CASEMBC(0x1ec) CASEMBC(0x1ece) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
970 EMIT2('O'); EMIT2(O_grave); EMIT2(O_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
971 EMIT2(O_circumflex); EMIT2(O_virguilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
972 EMIT2(O_diaeresis); EMIT2(O_slash); |
5351 | 973 EMITMBC(0x14c) EMITMBC(0x14e) EMITMBC(0x150) |
974 EMITMBC(0x1a0) EMITMBC(0x1d1) EMITMBC(0x1ea) | |
975 EMITMBC(0x1ec) EMITMBC(0x1ece) | |
976 return OK; | |
977 | |
978 case 'P': case 0x1e54: case 0x1e56: | |
979 EMIT2('P'); EMITMBC(0x1e54) EMITMBC(0x1e56) | |
980 return OK; | |
981 | |
982 case 'R': CASEMBC(0x154) CASEMBC(0x156) CASEMBC(0x158) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
983 CASEMBC(0x1e58) CASEMBC(0x1e5e) |
5351 | 984 EMIT2('R'); EMITMBC(0x154) EMITMBC(0x156) EMITMBC(0x158) |
985 EMITMBC(0x1e58) EMITMBC(0x1e5e) | |
986 return OK; | |
987 | |
988 case 'S': CASEMBC(0x15a) CASEMBC(0x15c) CASEMBC(0x15e) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
989 CASEMBC(0x160) CASEMBC(0x1e60) |
5351 | 990 EMIT2('S'); EMITMBC(0x15a) EMITMBC(0x15c) EMITMBC(0x15e) |
991 EMITMBC(0x160) EMITMBC(0x1e60) | |
992 return OK; | |
993 | |
994 case 'T': CASEMBC(0x162) CASEMBC(0x164) CASEMBC(0x166) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
995 CASEMBC(0x1e6a) CASEMBC(0x1e6e) |
5351 | 996 EMIT2('T'); EMITMBC(0x162) EMITMBC(0x164) EMITMBC(0x166) |
997 EMITMBC(0x1e6a) EMITMBC(0x1e6e) | |
4444 | 998 return OK; |
999 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1000 case 'U': case U_grave: case U_acute: case U_diaeresis: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1001 case U_circumflex: CASEMBC(0x168) CASEMBC(0x16a) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1002 CASEMBC(0x16c) CASEMBC(0x16e) CASEMBC(0x170) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1003 CASEMBC(0x172) CASEMBC(0x1af) CASEMBC(0x1d3) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1004 CASEMBC(0x1ee6) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1005 EMIT2('U'); EMIT2(U_grave); EMIT2(U_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1006 EMIT2(U_diaeresis); EMIT2(U_circumflex); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1007 EMITMBC(0x168) EMITMBC(0x16a) |
5351 | 1008 EMITMBC(0x16c) EMITMBC(0x16e) EMITMBC(0x170) |
1009 EMITMBC(0x172) EMITMBC(0x1af) EMITMBC(0x1d3) | |
1010 EMITMBC(0x1ee6) | |
1011 return OK; | |
1012 | |
1013 case 'V': CASEMBC(0x1e7c) | |
1014 EMIT2('V'); EMITMBC(0x1e7c) | |
1015 return OK; | |
1016 | |
1017 case 'W': CASEMBC(0x174) CASEMBC(0x1e80) CASEMBC(0x1e82) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1018 CASEMBC(0x1e84) CASEMBC(0x1e86) |
5351 | 1019 EMIT2('W'); EMITMBC(0x174) EMITMBC(0x1e80) EMITMBC(0x1e82) |
1020 EMITMBC(0x1e84) EMITMBC(0x1e86) | |
1021 return OK; | |
1022 | |
1023 case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c) | |
1024 EMIT2('X'); EMITMBC(0x1e8a) EMITMBC(0x1e8c) | |
4444 | 1025 return OK; |
1026 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1027 case 'Y': case Y_acute: CASEMBC(0x176) CASEMBC(0x178) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1028 CASEMBC(0x1e8e) CASEMBC(0x1ef2) CASEMBC(0x1ef6) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1029 CASEMBC(0x1ef8) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1030 EMIT2('Y'); EMIT2(Y_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1031 EMITMBC(0x176) EMITMBC(0x178) |
5351 | 1032 EMITMBC(0x1e8e) EMITMBC(0x1ef2) EMITMBC(0x1ef6) |
1033 EMITMBC(0x1ef8) | |
1034 return OK; | |
1035 | |
1036 case 'Z': CASEMBC(0x179) CASEMBC(0x17b) CASEMBC(0x17d) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1037 CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94) |
5351 | 1038 EMIT2('Z'); EMITMBC(0x179) EMITMBC(0x17b) EMITMBC(0x17d) |
1039 EMITMBC(0x1b5) EMITMBC(0x1e90) EMITMBC(0x1e94) | |
4444 | 1040 return OK; |
1041 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1042 case 'a': case a_grave: case a_acute: case a_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1043 case a_virguilla: case a_diaeresis: case a_ring: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1044 CASEMBC(0x101) CASEMBC(0x103) CASEMBC(0x105) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1045 CASEMBC(0x1ce) CASEMBC(0x1df) CASEMBC(0x1e1) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1046 CASEMBC(0x1ea3) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1047 EMIT2('a'); EMIT2(a_grave); EMIT2(a_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1048 EMIT2(a_circumflex); EMIT2(a_virguilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1049 EMIT2(a_diaeresis); EMIT2(a_ring); |
5351 | 1050 EMITMBC(0x101) EMITMBC(0x103) EMITMBC(0x105) |
1051 EMITMBC(0x1ce) EMITMBC(0x1df) EMITMBC(0x1e1) | |
1052 EMITMBC(0x1ea3) | |
1053 return OK; | |
1054 | |
1055 case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07) | |
1056 EMIT2('b'); EMITMBC(0x1e03) EMITMBC(0x1e07) | |
4444 | 1057 return OK; |
1058 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1059 case 'c': case c_cedilla: CASEMBC(0x107) CASEMBC(0x109) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1060 CASEMBC(0x10b) CASEMBC(0x10d) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1061 EMIT2('c'); EMIT2(c_cedilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1062 EMITMBC(0x107) EMITMBC(0x109) |
5351 | 1063 EMITMBC(0x10b) EMITMBC(0x10d) |
1064 return OK; | |
1065 | |
6914 | 1066 case 'd': CASEMBC(0x10f) CASEMBC(0x111) CASEMBC(0x1e0b) |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1067 CASEMBC(0x1e0f) CASEMBC(0x1e11) |
6914 | 1068 EMIT2('d'); EMITMBC(0x10f) EMITMBC(0x111) |
1069 EMITMBC(0x1e0b) EMITMBC(0x1e0f) EMITMBC(0x1e11) | |
4444 | 1070 return OK; |
1071 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1072 case 'e': case e_grave: case e_acute: case e_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1073 case e_diaeresis: CASEMBC(0x113) CASEMBC(0x115) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1074 CASEMBC(0x117) CASEMBC(0x119) CASEMBC(0x11b) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1075 CASEMBC(0x1ebb) CASEMBC(0x1ebd) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1076 EMIT2('e'); EMIT2(e_grave); EMIT2(e_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1077 EMIT2(e_circumflex); EMIT2(e_diaeresis); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1078 EMITMBC(0x113) EMITMBC(0x115) |
5351 | 1079 EMITMBC(0x117) EMITMBC(0x119) EMITMBC(0x11b) |
1080 EMITMBC(0x1ebb) EMITMBC(0x1ebd) | |
1081 return OK; | |
1082 | |
1083 case 'f': CASEMBC(0x1e1f) | |
1084 EMIT2('f'); EMITMBC(0x1e1f) | |
1085 return OK; | |
1086 | |
1087 case 'g': CASEMBC(0x11d) CASEMBC(0x11f) CASEMBC(0x121) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1088 CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1089 CASEMBC(0x1f5) CASEMBC(0x1e21) |
5351 | 1090 EMIT2('g'); EMITMBC(0x11d) EMITMBC(0x11f) EMITMBC(0x121) |
1091 EMITMBC(0x123) EMITMBC(0x1e5) EMITMBC(0x1e7) | |
1092 EMITMBC(0x1f5) EMITMBC(0x1e21) | |
1093 return OK; | |
1094 | |
1095 case 'h': CASEMBC(0x125) CASEMBC(0x127) CASEMBC(0x1e23) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1096 CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96) |
5351 | 1097 EMIT2('h'); EMITMBC(0x125) EMITMBC(0x127) EMITMBC(0x1e23) |
1098 EMITMBC(0x1e27) EMITMBC(0x1e29) EMITMBC(0x1e96) | |
4444 | 1099 return OK; |
1100 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1101 case 'i': case i_grave: case i_acute: case i_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1102 case i_diaeresis: CASEMBC(0x129) CASEMBC(0x12b) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1103 CASEMBC(0x12d) CASEMBC(0x12f) CASEMBC(0x1d0) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1104 CASEMBC(0x1ec9) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1105 EMIT2('i'); EMIT2(i_grave); EMIT2(i_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1106 EMIT2(i_circumflex); EMIT2(i_diaeresis); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1107 EMITMBC(0x129) EMITMBC(0x12b) |
5351 | 1108 EMITMBC(0x12d) EMITMBC(0x12f) EMITMBC(0x1d0) |
1109 EMITMBC(0x1ec9) | |
1110 return OK; | |
1111 | |
1112 case 'j': CASEMBC(0x135) CASEMBC(0x1f0) | |
1113 EMIT2('j'); EMITMBC(0x135) EMITMBC(0x1f0) | |
1114 return OK; | |
1115 | |
1116 case 'k': CASEMBC(0x137) CASEMBC(0x1e9) CASEMBC(0x1e31) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1117 CASEMBC(0x1e35) |
5351 | 1118 EMIT2('k'); EMITMBC(0x137) EMITMBC(0x1e9) EMITMBC(0x1e31) |
1119 EMITMBC(0x1e35) | |
1120 return OK; | |
1121 | |
1122 case 'l': CASEMBC(0x13a) CASEMBC(0x13c) CASEMBC(0x13e) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1123 CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b) |
5351 | 1124 EMIT2('l'); EMITMBC(0x13a) EMITMBC(0x13c) EMITMBC(0x13e) |
1125 EMITMBC(0x140) EMITMBC(0x142) EMITMBC(0x1e3b) | |
1126 return OK; | |
1127 | |
1128 case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41) | |
1129 EMIT2('m'); EMITMBC(0x1e3f) EMITMBC(0x1e41) | |
4444 | 1130 return OK; |
1131 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1132 case 'n': case n_virguilla: CASEMBC(0x144) CASEMBC(0x146) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1133 CASEMBC(0x148) CASEMBC(0x149) CASEMBC(0x1e45) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1134 CASEMBC(0x1e49) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1135 EMIT2('n'); EMIT2(n_virguilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1136 EMITMBC(0x144) EMITMBC(0x146) |
5351 | 1137 EMITMBC(0x148) EMITMBC(0x149) EMITMBC(0x1e45) |
1138 EMITMBC(0x1e49) | |
4444 | 1139 return OK; |
1140 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1141 case 'o': case o_grave: case o_acute: case o_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1142 case o_virguilla: case o_diaeresis: case o_slash: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1143 CASEMBC(0x14d) CASEMBC(0x14f) CASEMBC(0x151) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1144 CASEMBC(0x1a1) CASEMBC(0x1d2) CASEMBC(0x1eb) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1145 CASEMBC(0x1ed) CASEMBC(0x1ecf) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1146 EMIT2('o'); EMIT2(o_grave); EMIT2(o_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1147 EMIT2(o_circumflex); EMIT2(o_virguilla); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1148 EMIT2(o_diaeresis); EMIT2(o_slash); |
5351 | 1149 EMITMBC(0x14d) EMITMBC(0x14f) EMITMBC(0x151) |
1150 EMITMBC(0x1a1) EMITMBC(0x1d2) EMITMBC(0x1eb) | |
1151 EMITMBC(0x1ed) EMITMBC(0x1ecf) | |
1152 return OK; | |
1153 | |
1154 case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57) | |
1155 EMIT2('p'); EMITMBC(0x1e55) EMITMBC(0x1e57) | |
1156 return OK; | |
1157 | |
1158 case 'r': CASEMBC(0x155) CASEMBC(0x157) CASEMBC(0x159) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1159 CASEMBC(0x1e59) CASEMBC(0x1e5f) |
5351 | 1160 EMIT2('r'); EMITMBC(0x155) EMITMBC(0x157) EMITMBC(0x159) |
1161 EMITMBC(0x1e59) EMITMBC(0x1e5f) | |
1162 return OK; | |
1163 | |
1164 case 's': CASEMBC(0x15b) CASEMBC(0x15d) CASEMBC(0x15f) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1165 CASEMBC(0x161) CASEMBC(0x1e61) |
5351 | 1166 EMIT2('s'); EMITMBC(0x15b) EMITMBC(0x15d) EMITMBC(0x15f) |
1167 EMITMBC(0x161) EMITMBC(0x1e61) | |
1168 return OK; | |
1169 | |
1170 case 't': CASEMBC(0x163) CASEMBC(0x165) CASEMBC(0x167) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1171 CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97) |
5351 | 1172 EMIT2('t'); EMITMBC(0x163) EMITMBC(0x165) EMITMBC(0x167) |
1173 EMITMBC(0x1e6b) EMITMBC(0x1e6f) EMITMBC(0x1e97) | |
4444 | 1174 return OK; |
1175 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1176 case 'u': case u_grave: case u_acute: case u_circumflex: |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1177 case u_diaeresis: CASEMBC(0x169) CASEMBC(0x16b) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1178 CASEMBC(0x16d) CASEMBC(0x16f) CASEMBC(0x171) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1179 CASEMBC(0x173) CASEMBC(0x1b0) CASEMBC(0x1d4) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1180 CASEMBC(0x1ee7) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1181 EMIT2('u'); EMIT2(u_grave); EMIT2(u_acute); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1182 EMIT2(u_circumflex); EMIT2(u_diaeresis); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1183 EMITMBC(0x169) EMITMBC(0x16b) |
5351 | 1184 EMITMBC(0x16d) EMITMBC(0x16f) EMITMBC(0x171) |
1185 EMITMBC(0x173) EMITMBC(0x1b0) EMITMBC(0x1d4) | |
1186 EMITMBC(0x1ee7) | |
1187 return OK; | |
1188 | |
1189 case 'v': CASEMBC(0x1e7d) | |
1190 EMIT2('v'); EMITMBC(0x1e7d) | |
1191 return OK; | |
1192 | |
1193 case 'w': CASEMBC(0x175) CASEMBC(0x1e81) CASEMBC(0x1e83) | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1194 CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98) |
5351 | 1195 EMIT2('w'); EMITMBC(0x175) EMITMBC(0x1e81) EMITMBC(0x1e83) |
1196 EMITMBC(0x1e85) EMITMBC(0x1e87) EMITMBC(0x1e98) | |
1197 return OK; | |
1198 | |
1199 case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d) | |
1200 EMIT2('x'); EMITMBC(0x1e8b) EMITMBC(0x1e8d) | |
4444 | 1201 return OK; |
1202 | |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1203 case 'y': case y_acute: case y_diaeresis: CASEMBC(0x177) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1204 CASEMBC(0x1e8f) CASEMBC(0x1e99) CASEMBC(0x1ef3) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1205 CASEMBC(0x1ef7) CASEMBC(0x1ef9) |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1206 EMIT2('y'); EMIT2(y_acute); EMIT2(y_diaeresis); |
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1207 EMITMBC(0x177) |
5351 | 1208 EMITMBC(0x1e8f) EMITMBC(0x1e99) EMITMBC(0x1ef3) |
1209 EMITMBC(0x1ef7) EMITMBC(0x1ef9) | |
4444 | 1210 return OK; |
1211 | |
5351 | 1212 case 'z': CASEMBC(0x17a) CASEMBC(0x17c) CASEMBC(0x17e) |
8841
f196308a2813
commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents:
8021
diff
changeset
|
1213 CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95) |
5351 | 1214 EMIT2('z'); EMITMBC(0x17a) EMITMBC(0x17c) EMITMBC(0x17e) |
1215 EMITMBC(0x1b6) EMITMBC(0x1e91) EMITMBC(0x1e95) | |
1216 return OK; | |
1217 | |
1218 /* default: character itself */ | |
4444 | 1219 } |
1220 } | |
1221 | |
5351 | 1222 EMIT2(c); |
4444 | 1223 return OK; |
1224 #undef EMIT2 | |
5351 | 1225 #undef EMITMBC |
4444 | 1226 } |
1227 | |
1228 /* | |
1229 * Code to parse regular expression. | |
1230 * | |
1231 * We try to reuse parsing functions in regexp.c to | |
1232 * minimize surprise and keep the syntax consistent. | |
1233 */ | |
1234 | |
1235 /* | |
1236 * Parse the lowest level. | |
1237 * | |
1238 * An atom can be one of a long list of items. Many atoms match one character | |
1239 * in the text. It is often an ordinary character or a character class. | |
1240 * Braces can be used to make a pattern into an atom. The "\z(\)" construct | |
1241 * is only for syntax highlighting. | |
1242 * | |
1243 * atom ::= ordinary-atom | |
1244 * or \( pattern \) | |
1245 * or \%( pattern \) | |
1246 * or \z( pattern \) | |
1247 */ | |
1248 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1249 nfa_regatom(void) |
4444 | 1250 { |
1251 int c; | |
1252 int charclass; | |
1253 int equiclass; | |
1254 int collclass; | |
1255 int got_coll_char; | |
1256 char_u *p; | |
1257 char_u *endp; | |
1258 #ifdef FEAT_MBYTE | |
1259 char_u *old_regparse = regparse; | |
1260 #endif | |
1261 int extra = 0; | |
1262 int emit_range; | |
1263 int negated; | |
1264 int result; | |
1265 int startc = -1; | |
1266 int endc = -1; | |
1267 int oldstartc = -1; | |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1268 int save_prev_at_start = prev_at_start; |
4444 | 1269 |
1270 c = getchr(); | |
1271 switch (c) | |
1272 { | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1273 case NUL: |
5511 | 1274 EMSG_RET_FAIL(_(e_nul_found)); |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1275 |
4444 | 1276 case Magic('^'): |
1277 EMIT(NFA_BOL); | |
1278 break; | |
1279 | |
1280 case Magic('$'): | |
1281 EMIT(NFA_EOL); | |
1282 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
1283 had_eol = TRUE; | |
1284 #endif | |
1285 break; | |
1286 | |
1287 case Magic('<'): | |
1288 EMIT(NFA_BOW); | |
1289 break; | |
1290 | |
1291 case Magic('>'): | |
1292 EMIT(NFA_EOW); | |
1293 break; | |
1294 | |
1295 case Magic('_'): | |
1296 c = no_Magic(getchr()); | |
5511 | 1297 if (c == NUL) |
1298 EMSG_RET_FAIL(_(e_nul_found)); | |
1299 | |
4444 | 1300 if (c == '^') /* "\_^" is start-of-line */ |
1301 { | |
1302 EMIT(NFA_BOL); | |
1303 break; | |
1304 } | |
1305 if (c == '$') /* "\_$" is end-of-line */ | |
1306 { | |
1307 EMIT(NFA_EOL); | |
1308 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
1309 had_eol = TRUE; | |
1310 #endif | |
1311 break; | |
1312 } | |
1313 | |
5296 | 1314 extra = NFA_ADD_NL; |
4444 | 1315 |
1316 /* "\_[" is collection plus newline */ | |
1317 if (c == '[') | |
4517
9a2183bd8295
updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents:
4515
diff
changeset
|
1318 goto collection; |
4444 | 1319 |
1320 /* "\_x" is character class plus newline */ | |
1321 /*FALLTHROUGH*/ | |
1322 | |
1323 /* | |
1324 * Character classes. | |
1325 */ | |
1326 case Magic('.'): | |
1327 case Magic('i'): | |
1328 case Magic('I'): | |
1329 case Magic('k'): | |
1330 case Magic('K'): | |
1331 case Magic('f'): | |
1332 case Magic('F'): | |
1333 case Magic('p'): | |
1334 case Magic('P'): | |
1335 case Magic('s'): | |
1336 case Magic('S'): | |
1337 case Magic('d'): | |
1338 case Magic('D'): | |
1339 case Magic('x'): | |
1340 case Magic('X'): | |
1341 case Magic('o'): | |
1342 case Magic('O'): | |
1343 case Magic('w'): | |
1344 case Magic('W'): | |
1345 case Magic('h'): | |
1346 case Magic('H'): | |
1347 case Magic('a'): | |
1348 case Magic('A'): | |
1349 case Magic('l'): | |
1350 case Magic('L'): | |
1351 case Magic('u'): | |
1352 case Magic('U'): | |
1353 p = vim_strchr(classchars, no_Magic(c)); | |
1354 if (p == NULL) | |
1355 { | |
5511 | 1356 if (extra == NFA_ADD_NL) |
1357 { | |
1358 EMSGN(_(e_ill_char_class), c); | |
1359 rc_did_emsg = TRUE; | |
1360 return FAIL; | |
1361 } | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1362 EMSGN("INTERNAL: Unknown character class char: %ld", c); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1363 return FAIL; |
4444 | 1364 } |
1365 #ifdef FEAT_MBYTE | |
1366 /* When '.' is followed by a composing char ignore the dot, so that | |
1367 * the composing char is matched here. */ | |
1368 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr())) | |
1369 { | |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1370 old_regparse = regparse; |
4444 | 1371 c = getchr(); |
1372 goto nfa_do_multibyte; | |
1373 } | |
1374 #endif | |
1375 EMIT(nfa_classcodes[p - classchars]); | |
5296 | 1376 if (extra == NFA_ADD_NL) |
4444 | 1377 { |
1378 EMIT(NFA_NEWL); | |
1379 EMIT(NFA_OR); | |
1380 regflags |= RF_HASNL; | |
1381 } | |
1382 break; | |
1383 | |
1384 case Magic('n'): | |
1385 if (reg_string) | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1386 /* In a string "\n" matches a newline character. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1387 EMIT(NL); |
4444 | 1388 else |
1389 { | |
1390 /* In buffer text "\n" matches the end of a line. */ | |
1391 EMIT(NFA_NEWL); | |
1392 regflags |= RF_HASNL; | |
1393 } | |
1394 break; | |
1395 | |
1396 case Magic('('): | |
1397 if (nfa_reg(REG_PAREN) == FAIL) | |
1398 return FAIL; /* cascaded error */ | |
1399 break; | |
1400 | |
1401 case Magic('|'): | |
1402 case Magic('&'): | |
1403 case Magic(')'): | |
4450 | 1404 EMSGN(_(e_misplaced), no_Magic(c)); |
4444 | 1405 return FAIL; |
1406 | |
1407 case Magic('='): | |
1408 case Magic('?'): | |
1409 case Magic('+'): | |
1410 case Magic('@'): | |
1411 case Magic('*'): | |
1412 case Magic('{'): | |
1413 /* these should follow an atom, not form an atom */ | |
4450 | 1414 EMSGN(_(e_misplaced), no_Magic(c)); |
4444 | 1415 return FAIL; |
1416 | |
4714
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1417 case Magic('~'): |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1418 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1419 char_u *lp; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1420 |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1421 /* Previous substitute pattern. |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1422 * Generated as "\%(pattern\)". */ |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1423 if (reg_prev_sub == NULL) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1424 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1425 EMSG(_(e_nopresub)); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1426 return FAIL; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1427 } |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1428 for (lp = reg_prev_sub; *lp != NUL; mb_cptr_adv(lp)) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1429 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1430 EMIT(PTR2CHAR(lp)); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1431 if (lp != reg_prev_sub) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1432 EMIT(NFA_CONCAT); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1433 } |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1434 EMIT(NFA_NOPEN); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1435 break; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1436 } |
4444 | 1437 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1438 case Magic('1'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1439 case Magic('2'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1440 case Magic('3'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1441 case Magic('4'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1442 case Magic('5'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1443 case Magic('6'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1444 case Magic('7'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1445 case Magic('8'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1446 case Magic('9'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1447 EMIT(NFA_BACKREF1 + (no_Magic(c) - '1')); |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1448 nfa_has_backref = TRUE; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1449 break; |
4444 | 1450 |
1451 case Magic('z'): | |
1452 c = no_Magic(getchr()); | |
1453 switch (c) | |
1454 { | |
1455 case 's': | |
1456 EMIT(NFA_ZSTART); | |
6170 | 1457 if (re_mult_next("\\zs") == FAIL) |
1458 return FAIL; | |
4444 | 1459 break; |
1460 case 'e': | |
1461 EMIT(NFA_ZEND); | |
1462 nfa_has_zend = TRUE; | |
6170 | 1463 if (re_mult_next("\\ze") == FAIL) |
1464 return FAIL; | |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
1465 break; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1466 #ifdef FEAT_SYN_HL |
4444 | 1467 case '1': |
1468 case '2': | |
1469 case '3': | |
1470 case '4': | |
1471 case '5': | |
1472 case '6': | |
1473 case '7': | |
1474 case '8': | |
1475 case '9': | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1476 /* \z1...\z9 */ |
4688
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1477 if (reg_do_extmatch != REX_USE) |
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1478 EMSG_RET_FAIL(_(e_z1_not_allowed)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1479 EMIT(NFA_ZREF1 + (no_Magic(c) - '1')); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1480 /* No need to set nfa_has_backref, the sub-matches don't |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
1481 * change when \z1 .. \z9 matches or not. */ |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1482 re_has_z = REX_USE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1483 break; |
4444 | 1484 case '(': |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1485 /* \z( */ |
4688
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1486 if (reg_do_extmatch != REX_SET) |
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1487 EMSG_RET_FAIL(_(e_z_not_allowed)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1488 if (nfa_reg(REG_ZPAREN) == FAIL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1489 return FAIL; /* cascaded error */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1490 re_has_z = REX_SET; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1491 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1492 #endif |
4444 | 1493 default: |
4450 | 1494 EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"), |
4444 | 1495 no_Magic(c)); |
1496 return FAIL; | |
1497 } | |
1498 break; | |
1499 | |
1500 case Magic('%'): | |
1501 c = no_Magic(getchr()); | |
1502 switch (c) | |
1503 { | |
1504 /* () without a back reference */ | |
1505 case '(': | |
1506 if (nfa_reg(REG_NPAREN) == FAIL) | |
1507 return FAIL; | |
1508 EMIT(NFA_NOPEN); | |
1509 break; | |
1510 | |
1511 case 'd': /* %d123 decimal */ | |
1512 case 'o': /* %o123 octal */ | |
1513 case 'x': /* %xab hex 2 */ | |
1514 case 'u': /* %uabcd hex 4 */ | |
1515 case 'U': /* %U1234abcd hex 8 */ | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1516 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1517 int nr; |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1518 |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1519 switch (c) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1520 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1521 case 'd': nr = getdecchrs(); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1522 case 'o': nr = getoctchrs(); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1523 case 'x': nr = gethexchrs(2); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1524 case 'u': nr = gethexchrs(4); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1525 case 'U': nr = gethexchrs(8); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1526 default: nr = -1; break; |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1527 } |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1528 |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1529 if (nr < 0) |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1530 EMSG2_RET_FAIL( |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1531 _("E678: Invalid character after %s%%[dxouU]"), |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1532 reg_magic == MAGIC_ALL); |
5360 | 1533 /* A NUL is stored in the text as NL */ |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1534 /* TODO: what if a composing character follows? */ |
5360 | 1535 EMIT(nr == 0 ? 0x0a : nr); |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1536 } |
4444 | 1537 break; |
1538 | |
1539 /* Catch \%^ and \%$ regardless of where they appear in the | |
1540 * pattern -- regardless of whether or not it makes sense. */ | |
1541 case '^': | |
1542 EMIT(NFA_BOF); | |
1543 break; | |
1544 | |
1545 case '$': | |
1546 EMIT(NFA_EOF); | |
1547 break; | |
1548 | |
1549 case '#': | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1550 EMIT(NFA_CURSOR); |
4444 | 1551 break; |
1552 | |
1553 case 'V': | |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
1554 EMIT(NFA_VISUAL); |
4444 | 1555 break; |
1556 | |
5901 | 1557 case 'C': |
1558 EMIT(NFA_ANY_COMPOSING); | |
1559 break; | |
1560 | |
4444 | 1561 case '[': |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1562 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1563 int n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1564 |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1565 /* \%[abc] */ |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1566 for (n = 0; (c = peekchr()) != ']'; ++n) |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1567 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1568 if (c == NUL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1569 EMSG2_RET_FAIL(_(e_missing_sb), |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1570 reg_magic == MAGIC_ALL); |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1571 /* recursive call! */ |
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1572 if (nfa_regatom() == FAIL) |
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1573 return FAIL; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1574 } |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1575 getchr(); /* get the ] */ |
4760
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1576 if (n == 0) |
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1577 EMSG2_RET_FAIL(_(e_empty_sb), |
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1578 reg_magic == MAGIC_ALL); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1579 EMIT(NFA_OPT_CHARS); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1580 EMIT(n); |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1581 |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1582 /* Emit as "\%(\%[abc]\)" to be able to handle |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1583 * "\%[abc]*" which would cause the empty string to be |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1584 * matched an unlimited number of times. NFA_NOPEN is |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1585 * added only once at a position, while NFA_SPLIT is |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1586 * added multiple times. This is more efficient than |
6547 | 1587 * not allowing NFA_SPLIT multiple times, it is used |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1588 * a lot. */ |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1589 EMIT(NFA_NOPEN); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1590 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1591 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1592 |
4444 | 1593 default: |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1594 { |
4655
779ca415f8e1
updated for version 7.3.1075
Bram Moolenaar <bram@vim.org>
parents:
4651
diff
changeset
|
1595 int n = 0; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1596 int cmp = c; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1597 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1598 if (c == '<' || c == '>') |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1599 c = getchr(); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1600 while (VIM_ISDIGIT(c)) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1601 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1602 n = n * 10 + (c - '0'); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1603 c = getchr(); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1604 } |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1605 if (c == 'l' || c == 'c' || c == 'v') |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1606 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1607 if (c == 'l') |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1608 { |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1609 /* \%{n}l \%{n}<l \%{n}>l */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1610 EMIT(cmp == '<' ? NFA_LNUM_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1611 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
|
1612 if (save_prev_at_start) |
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1613 at_start = TRUE; |
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1614 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1615 else if (c == 'c') |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1616 /* \%{n}c \%{n}<c \%{n}>c */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1617 EMIT(cmp == '<' ? NFA_COL_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1618 cmp == '>' ? NFA_COL_GT : NFA_COL); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1619 else |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1620 /* \%{n}v \%{n}<v \%{n}>v */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1621 EMIT(cmp == '<' ? NFA_VCOL_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1622 cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1623 EMIT(n); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1624 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1625 } |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1626 else if (c == '\'' && n == 0) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1627 { |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1628 /* \%'m \%<'m \%>'m */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1629 EMIT(cmp == '<' ? NFA_MARK_LT : |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1630 cmp == '>' ? NFA_MARK_GT : NFA_MARK); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1631 EMIT(getchr()); |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1632 break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1633 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1634 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1635 EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"), |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1636 no_Magic(c)); |
4444 | 1637 return FAIL; |
1638 } | |
1639 break; | |
1640 | |
1641 case Magic('['): | |
4517
9a2183bd8295
updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents:
4515
diff
changeset
|
1642 collection: |
4444 | 1643 /* |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1644 * [abc] uses NFA_START_COLL - NFA_END_COLL |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1645 * [^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
|
1646 * 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
|
1647 * NFA_CONCAT to bind them together. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1648 * Besides normal characters there can be: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1649 * - character classes NFA_CLASS_* |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1650 * - ranges, two characters followed by NFA_RANGE. |
4444 | 1651 */ |
1652 | |
1653 p = regparse; | |
1654 endp = skip_anyof(p); | |
1655 if (*endp == ']') | |
1656 { | |
1657 /* | |
1658 * Try to reverse engineer character classes. For example, | |
5296 | 1659 * recognize that [0-9] stands for \d and [A-Za-z_] for \h, |
4444 | 1660 * and perform the necessary substitutions in the NFA. |
1661 */ | |
1662 result = nfa_recognize_char_class(regparse, endp, | |
5296 | 1663 extra == NFA_ADD_NL); |
4444 | 1664 if (result != FAIL) |
1665 { | |
5296 | 1666 if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL) |
4444 | 1667 { |
5296 | 1668 EMIT(result - NFA_ADD_NL); |
4444 | 1669 EMIT(NFA_NEWL); |
1670 EMIT(NFA_OR); | |
1671 } | |
5296 | 1672 else |
1673 EMIT(result); | |
4444 | 1674 regparse = endp; |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1675 mb_ptr_adv(regparse); |
4444 | 1676 return OK; |
1677 } | |
1678 /* | |
1679 * Failed to recognize a character class. Use the simple | |
1680 * version that turns [abc] into 'a' OR 'b' OR 'c' | |
1681 */ | |
1682 startc = endc = oldstartc = -1; | |
1683 negated = FALSE; | |
1684 if (*regparse == '^') /* negated range */ | |
1685 { | |
1686 negated = TRUE; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1687 mb_ptr_adv(regparse); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1688 EMIT(NFA_START_NEG_COLL); |
4444 | 1689 } |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1690 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1691 EMIT(NFA_START_COLL); |
4444 | 1692 if (*regparse == '-') |
1693 { | |
1694 startc = '-'; | |
1695 EMIT(startc); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1696 EMIT(NFA_CONCAT); |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1697 mb_ptr_adv(regparse); |
4444 | 1698 } |
1699 /* Emit the OR branches for each character in the [] */ | |
1700 emit_range = FALSE; | |
1701 while (regparse < endp) | |
1702 { | |
1703 oldstartc = startc; | |
1704 startc = -1; | |
1705 got_coll_char = FALSE; | |
1706 if (*regparse == '[') | |
1707 { | |
1708 /* Check for [: :], [= =], [. .] */ | |
1709 equiclass = collclass = 0; | |
1710 charclass = get_char_class(®parse); | |
1711 if (charclass == CLASS_NONE) | |
1712 { | |
1713 equiclass = get_equi_class(®parse); | |
1714 if (equiclass == 0) | |
1715 collclass = get_coll_element(®parse); | |
1716 } | |
1717 | |
1718 /* Character class like [:alpha:] */ | |
1719 if (charclass != CLASS_NONE) | |
1720 { | |
1721 switch (charclass) | |
1722 { | |
1723 case CLASS_ALNUM: | |
1724 EMIT(NFA_CLASS_ALNUM); | |
1725 break; | |
1726 case CLASS_ALPHA: | |
1727 EMIT(NFA_CLASS_ALPHA); | |
1728 break; | |
1729 case CLASS_BLANK: | |
1730 EMIT(NFA_CLASS_BLANK); | |
1731 break; | |
1732 case CLASS_CNTRL: | |
1733 EMIT(NFA_CLASS_CNTRL); | |
1734 break; | |
1735 case CLASS_DIGIT: | |
1736 EMIT(NFA_CLASS_DIGIT); | |
1737 break; | |
1738 case CLASS_GRAPH: | |
1739 EMIT(NFA_CLASS_GRAPH); | |
1740 break; | |
1741 case CLASS_LOWER: | |
1742 EMIT(NFA_CLASS_LOWER); | |
1743 break; | |
1744 case CLASS_PRINT: | |
1745 EMIT(NFA_CLASS_PRINT); | |
1746 break; | |
1747 case CLASS_PUNCT: | |
1748 EMIT(NFA_CLASS_PUNCT); | |
1749 break; | |
1750 case CLASS_SPACE: | |
1751 EMIT(NFA_CLASS_SPACE); | |
1752 break; | |
1753 case CLASS_UPPER: | |
1754 EMIT(NFA_CLASS_UPPER); | |
1755 break; | |
1756 case CLASS_XDIGIT: | |
1757 EMIT(NFA_CLASS_XDIGIT); | |
1758 break; | |
1759 case CLASS_TAB: | |
1760 EMIT(NFA_CLASS_TAB); | |
1761 break; | |
1762 case CLASS_RETURN: | |
1763 EMIT(NFA_CLASS_RETURN); | |
1764 break; | |
1765 case CLASS_BACKSPACE: | |
1766 EMIT(NFA_CLASS_BACKSPACE); | |
1767 break; | |
1768 case CLASS_ESCAPE: | |
1769 EMIT(NFA_CLASS_ESCAPE); | |
1770 break; | |
1771 } | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1772 EMIT(NFA_CONCAT); |
4444 | 1773 continue; |
1774 } | |
1775 /* Try equivalence class [=a=] and the like */ | |
1776 if (equiclass != 0) | |
1777 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1778 result = nfa_emit_equi_class(equiclass); |
4444 | 1779 if (result == FAIL) |
1780 { | |
1781 /* should never happen */ | |
1782 EMSG_RET_FAIL(_("E868: Error building NFA with equivalence class!")); | |
1783 } | |
1784 continue; | |
1785 } | |
1786 /* Try collating class like [. .] */ | |
1787 if (collclass != 0) | |
1788 { | |
1789 startc = collclass; /* allow [.a.]-x as a range */ | |
1790 /* Will emit the proper atom at the end of the | |
1791 * while loop. */ | |
1792 } | |
1793 } | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1794 /* Try a range like 'a-x' or '\t-z'. Also allows '-' as a |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1795 * start character. */ |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1796 if (*regparse == '-' && oldstartc != -1) |
4444 | 1797 { |
1798 emit_range = TRUE; | |
1799 startc = oldstartc; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1800 mb_ptr_adv(regparse); |
4444 | 1801 continue; /* reading the end of the range */ |
1802 } | |
1803 | |
1804 /* Now handle simple and escaped characters. | |
1805 * Only "\]", "\^", "\]" and "\\" are special in Vi. Vim | |
1806 * accepts "\t", "\e", etc., but only when the 'l' flag in | |
1807 * 'cpoptions' is not included. | |
1808 * Posix doesn't recognize backslash at all. | |
1809 */ | |
1810 if (*regparse == '\\' | |
4744
a62695305e03
updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents:
4742
diff
changeset
|
1811 && !reg_cpo_bsl |
4444 | 1812 && regparse + 1 <= endp |
1813 && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL | |
4744
a62695305e03
updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents:
4742
diff
changeset
|
1814 || (!reg_cpo_lit |
4444 | 1815 && vim_strchr(REGEXP_ABBR, regparse[1]) |
1816 != NULL) | |
1817 ) | |
1818 ) | |
1819 { | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1820 mb_ptr_adv(regparse); |
4444 | 1821 |
4507
9dbbddb2ed10
updated for version 7.3.1001
Bram Moolenaar <bram@vim.org>
parents:
4503
diff
changeset
|
1822 if (*regparse == 'n') |
4444 | 1823 startc = reg_string ? NL : NFA_NEWL; |
1824 else | |
1825 if (*regparse == 'd' | |
1826 || *regparse == 'o' | |
1827 || *regparse == 'x' | |
1828 || *regparse == 'u' | |
1829 || *regparse == 'U' | |
1830 ) | |
1831 { | |
1832 /* TODO(RE) This needs more testing */ | |
1833 startc = coll_get_char(); | |
1834 got_coll_char = TRUE; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1835 mb_ptr_back(old_regparse, regparse); |
4444 | 1836 } |
1837 else | |
1838 { | |
1839 /* \r,\t,\e,\b */ | |
1840 startc = backslash_trans(*regparse); | |
1841 } | |
1842 } | |
1843 | |
1844 /* Normal printable char */ | |
1845 if (startc == -1) | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1846 startc = PTR2CHAR(regparse); |
4444 | 1847 |
1848 /* Previous char was '-', so this char is end of range. */ | |
1849 if (emit_range) | |
1850 { | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1851 endc = startc; |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1852 startc = oldstartc; |
4444 | 1853 if (startc > endc) |
1854 EMSG_RET_FAIL(_(e_invrange)); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1855 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1856 if (endc > startc + 2) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1857 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1858 /* Emit a range instead of the sequence of |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1859 * individual characters. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1860 if (startc == 0) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1861 /* \x00 is translated to \x0a, start at \x01. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1862 EMIT(1); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1863 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1864 --post_ptr; /* remove NFA_CONCAT */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1865 EMIT(endc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1866 EMIT(NFA_RANGE); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1867 EMIT(NFA_CONCAT); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1868 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1869 else |
4444 | 1870 #ifdef FEAT_MBYTE |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1871 if (has_mbyte && ((*mb_char2len)(startc) > 1 |
4444 | 1872 || (*mb_char2len)(endc) > 1)) |
1873 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1874 /* Emit the characters in the range. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1875 * "startc" was already emitted, so skip it. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1876 * */ |
4444 | 1877 for (c = startc + 1; c <= endc; c++) |
1878 { | |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1879 EMIT(c); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1880 EMIT(NFA_CONCAT); |
4444 | 1881 } |
1882 } | |
1883 else | |
1884 #endif | |
1885 { | |
1886 #ifdef EBCDIC | |
1887 int alpha_only = FALSE; | |
1888 | |
1889 /* for alphabetical range skip the gaps | |
1890 * 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'. */ | |
1891 if (isalpha(startc) && isalpha(endc)) | |
1892 alpha_only = TRUE; | |
1893 #endif | |
1894 /* Emit the range. "startc" was already emitted, so | |
1895 * skip it. */ | |
1896 for (c = startc + 1; c <= endc; c++) | |
1897 #ifdef EBCDIC | |
1898 if (!alpha_only || isalpha(startc)) | |
1899 #endif | |
1900 { | |
1901 EMIT(c); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1902 EMIT(NFA_CONCAT); |
4444 | 1903 } |
1904 } | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1905 emit_range = FALSE; |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1906 startc = -1; |
4444 | 1907 } |
1908 else | |
1909 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1910 /* This char (startc) is not part of a range. Just |
4444 | 1911 * emit it. |
1912 * Normally, simply emit startc. But if we get char | |
1913 * code=0 from a collating char, then replace it with | |
1914 * 0x0a. | |
1915 * This is needed to completely mimic the behaviour of | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1916 * the backtracking engine. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1917 if (startc == NFA_NEWL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1918 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1919 /* Line break can't be matched as part of the |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1920 * collection, add an OR below. But not for negated |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1921 * range. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1922 if (!negated) |
5296 | 1923 extra = NFA_ADD_NL; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1924 } |
4444 | 1925 else |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1926 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1927 if (got_coll_char == TRUE && startc == 0) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1928 EMIT(0x0a); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1929 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1930 EMIT(startc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1931 EMIT(NFA_CONCAT); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1932 } |
4444 | 1933 } |
1934 | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1935 mb_ptr_adv(regparse); |
4444 | 1936 } /* while (p < endp) */ |
1937 | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1938 mb_ptr_back(old_regparse, regparse); |
4444 | 1939 if (*regparse == '-') /* if last, '-' is just a char */ |
1940 { | |
1941 EMIT('-'); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1942 EMIT(NFA_CONCAT); |
4444 | 1943 } |
1944 | |
1945 /* skip the trailing ] */ | |
1946 regparse = endp; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1947 mb_ptr_adv(regparse); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1948 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1949 /* Mark end of the collection. */ |
4444 | 1950 if (negated == TRUE) |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1951 EMIT(NFA_END_NEG_COLL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1952 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1953 EMIT(NFA_END_COLL); |
4615
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1954 |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1955 /* \_[] also matches \n but it's not negated */ |
5296 | 1956 if (extra == NFA_ADD_NL) |
4615
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1957 { |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1958 EMIT(reg_string ? NL : NFA_NEWL); |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1959 EMIT(NFA_OR); |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1960 } |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1961 |
4444 | 1962 return OK; |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1963 } /* if exists closing ] */ |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1964 |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1965 if (reg_strict) |
4444 | 1966 EMSG_RET_FAIL(_(e_missingbracket)); |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1967 /* FALLTHROUGH */ |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1968 |
4444 | 1969 default: |
1970 { | |
1971 #ifdef FEAT_MBYTE | |
1972 int plen; | |
1973 | |
1974 nfa_do_multibyte: | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1975 /* plen is length of current char with composing chars */ |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1976 if (enc_utf8 && ((*mb_char2len)(c) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1977 != (plen = (*mb_ptr2len)(old_regparse)) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1978 || utf_iscomposing(c))) |
4444 | 1979 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1980 int i = 0; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1981 |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1982 /* A base character plus composing characters, or just one |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1983 * or more composing characters. |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1984 * This requires creating a separate atom as if enclosing |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1985 * the characters in (), where NFA_COMPOSING is the ( and |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1986 * NFA_END_COMPOSING is the ). Note that right now we are |
4444 | 1987 * building the postfix form, not the NFA itself; |
1988 * a composing char could be: a, b, c, NFA_COMPOSING | |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1989 * where 'b' and 'c' are chars with codes > 256. */ |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1990 for (;;) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1991 { |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1992 EMIT(c); |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1993 if (i > 0) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1994 EMIT(NFA_CONCAT); |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1995 if ((i += utf_char2len(c)) >= plen) |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1996 break; |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1997 c = utf_ptr2char(old_regparse + i); |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1998 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1999 EMIT(NFA_COMPOSING); |
4444 | 2000 regparse = old_regparse + plen; |
2001 } | |
2002 else | |
2003 #endif | |
2004 { | |
2005 c = no_Magic(c); | |
2006 EMIT(c); | |
2007 } | |
2008 return OK; | |
2009 } | |
2010 } | |
2011 | |
2012 return OK; | |
2013 } | |
2014 | |
2015 /* | |
2016 * Parse something followed by possible [*+=]. | |
2017 * | |
2018 * A piece is an atom, possibly followed by a multi, an indication of how many | |
2019 * times the atom can be matched. Example: "a*" matches any sequence of "a" | |
2020 * characters: "", "a", "aa", etc. | |
2021 * | |
2022 * piece ::= atom | |
2023 * or atom multi | |
2024 */ | |
2025 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2026 nfa_regpiece(void) |
4444 | 2027 { |
2028 int i; | |
2029 int op; | |
2030 int ret; | |
2031 long minval, maxval; | |
2032 int greedy = TRUE; /* Braces are prefixed with '-' ? */ | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2033 parse_state_T old_state; |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2034 parse_state_T new_state; |
4444 | 2035 int c2; |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2036 int old_post_pos; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2037 int my_post_start; |
4444 | 2038 int quest; |
2039 | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2040 /* Save the current parse state, so that we can use it if <atom>{m,n} is |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2041 * next. */ |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2042 save_parse_state(&old_state); |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2043 |
4444 | 2044 /* 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
|
2045 my_post_start = (int)(post_ptr - post_start); |
4444 | 2046 |
2047 ret = nfa_regatom(); | |
2048 if (ret == FAIL) | |
2049 return FAIL; /* cascaded error */ | |
2050 | |
2051 op = peekchr(); | |
2052 if (re_multi_type(op) == NOT_MULTI) | |
2053 return OK; | |
2054 | |
2055 skipchr(); | |
2056 switch (op) | |
2057 { | |
2058 case Magic('*'): | |
2059 EMIT(NFA_STAR); | |
2060 break; | |
2061 | |
2062 case Magic('+'): | |
2063 /* | |
2064 * Trick: Normally, (a*)\+ would match the whole input "aaa". The | |
2065 * first and only submatch would be "aaa". But the backtracking | |
2066 * engine interprets the plus as "try matching one more time", and | |
2067 * a* matches a second time at the end of the input, the empty | |
2068 * string. | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2069 * The submatch will be the empty string. |
4444 | 2070 * |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2071 * 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
|
2072 * <atom>+ with <atom><atom>* |
4444 | 2073 */ |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2074 restore_parse_state(&old_state); |
4444 | 2075 curchr = -1; |
2076 if (nfa_regatom() == FAIL) | |
2077 return FAIL; | |
2078 EMIT(NFA_STAR); | |
2079 EMIT(NFA_CONCAT); | |
2080 skipchr(); /* skip the \+ */ | |
2081 break; | |
2082 | |
2083 case Magic('@'): | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2084 c2 = getdecchrs(); |
4444 | 2085 op = no_Magic(getchr()); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2086 i = 0; |
4444 | 2087 switch(op) |
2088 { | |
2089 case '=': | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2090 /* \@= */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2091 i = NFA_PREV_ATOM_NO_WIDTH; |
4444 | 2092 break; |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
2093 case '!': |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2094 /* \@! */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2095 i = NFA_PREV_ATOM_NO_WIDTH_NEG; |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
2096 break; |
4444 | 2097 case '<': |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2098 op = no_Magic(getchr()); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2099 if (op == '=') |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2100 /* \@<= */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2101 i = NFA_PREV_ATOM_JUST_BEFORE; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2102 else if (op == '!') |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2103 /* \@<! */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2104 i = NFA_PREV_ATOM_JUST_BEFORE_NEG; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2105 break; |
4444 | 2106 case '>': |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2107 /* \@> */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2108 i = NFA_PREV_ATOM_LIKE_PATTERN; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2109 break; |
4444 | 2110 } |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2111 if (i == 0) |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2112 { |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2113 EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2114 return FAIL; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2115 } |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2116 EMIT(i); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2117 if (i == NFA_PREV_ATOM_JUST_BEFORE |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2118 || i == NFA_PREV_ATOM_JUST_BEFORE_NEG) |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2119 EMIT(c2); |
4444 | 2120 break; |
2121 | |
2122 case Magic('?'): | |
2123 case Magic('='): | |
2124 EMIT(NFA_QUEST); | |
2125 break; | |
2126 | |
2127 case Magic('{'): | |
2128 /* a{2,5} will expand to 'aaa?a?a?' | |
2129 * a{-1,3} will expand to 'aa??a??', where ?? is the nongreedy | |
2130 * version of '?' | |
2131 * \v(ab){2,3} will expand to '(ab)(ab)(ab)?', where all the | |
2132 * parenthesis have the same id | |
2133 */ | |
2134 | |
2135 greedy = TRUE; | |
2136 c2 = peekchr(); | |
2137 if (c2 == '-' || c2 == Magic('-')) | |
2138 { | |
2139 skipchr(); | |
2140 greedy = FALSE; | |
2141 } | |
2142 if (!read_limits(&minval, &maxval)) | |
2143 EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits")); | |
4762
47906f888725
updated for version 7.3.1128
Bram Moolenaar <bram@vim.org>
parents:
4760
diff
changeset
|
2144 |
4444 | 2145 /* <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to |
2146 * <atom>* */ | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2147 if (minval == 0 && maxval == MAX_LIMIT) |
4444 | 2148 { |
6533 | 2149 if (greedy) /* { { (match the braces) */ |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2150 /* \{}, \{0,} */ |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2151 EMIT(NFA_STAR); |
6533 | 2152 else /* { { (match the braces) */ |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2153 /* \{-}, \{-0,} */ |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2154 EMIT(NFA_STAR_NONGREEDY); |
4444 | 2155 break; |
2156 } | |
2157 | |
2158 /* Special case: x{0} or x{-0} */ | |
2159 if (maxval == 0) | |
2160 { | |
2161 /* 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
|
2162 post_ptr = post_start + my_post_start; |
5370 | 2163 /* NFA_EMPTY is 0-length and works everywhere */ |
2164 EMIT(NFA_EMPTY); | |
4444 | 2165 return OK; |
2166 } | |
2167 | |
6533 | 2168 /* The engine is very inefficient (uses too many states) when the |
6594 | 2169 * maximum is much larger than the minimum and when the maximum is |
2170 * large. Bail out if we can use the other engine. */ | |
2171 if ((nfa_re_flags & RE_AUTO) | |
2172 && (maxval > minval + 200 || maxval > 500)) | |
6533 | 2173 return FAIL; |
2174 | |
4444 | 2175 /* Ignore previous call to nfa_regatom() */ |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2176 post_ptr = post_start + my_post_start; |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2177 /* Save parse state after the repeated atom and the \{} */ |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2178 save_parse_state(&new_state); |
4444 | 2179 |
2180 quest = (greedy == TRUE? NFA_QUEST : NFA_QUEST_NONGREEDY); | |
2181 for (i = 0; i < maxval; i++) | |
2182 { | |
2183 /* Goto beginning of the repeated atom */ | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2184 restore_parse_state(&old_state); |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2185 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2186 if (nfa_regatom() == FAIL) |
2187 return FAIL; | |
2188 /* after "minval" times, atoms are optional */ | |
2189 if (i + 1 > minval) | |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2190 { |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2191 if (maxval == MAX_LIMIT) |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2192 { |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2193 if (greedy) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2194 EMIT(NFA_STAR); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2195 else |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2196 EMIT(NFA_STAR_NONGREEDY); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2197 } |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2198 else |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2199 EMIT(quest); |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2200 } |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2201 if (old_post_pos != my_post_start) |
4444 | 2202 EMIT(NFA_CONCAT); |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2203 if (i + 1 > minval && maxval == MAX_LIMIT) |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2204 break; |
4444 | 2205 } |
2206 | |
2207 /* 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
|
2208 restore_parse_state(&new_state); |
4444 | 2209 curchr = -1; |
2210 | |
2211 break; | |
2212 | |
2213 | |
2214 default: | |
2215 break; | |
2216 } /* end switch */ | |
2217 | |
2218 if (re_multi_type(peekchr()) != NOT_MULTI) | |
2219 /* Can't have a multi follow a multi. */ | |
2220 EMSG_RET_FAIL(_("E871: (NFA regexp) Can't have a multi follow a multi !")); | |
2221 | |
2222 return OK; | |
2223 } | |
2224 | |
2225 /* | |
2226 * Parse one or more pieces, concatenated. It matches a match for the | |
2227 * first piece, followed by a match for the second piece, etc. Example: | |
2228 * "f[0-9]b", first matches "f", then a digit and then "b". | |
2229 * | |
2230 * concat ::= piece | |
2231 * or piece piece | |
2232 * or piece piece piece | |
2233 * etc. | |
2234 */ | |
2235 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2236 nfa_regconcat(void) |
4444 | 2237 { |
2238 int cont = TRUE; | |
2239 int first = TRUE; | |
2240 | |
2241 while (cont) | |
2242 { | |
2243 switch (peekchr()) | |
2244 { | |
2245 case NUL: | |
2246 case Magic('|'): | |
2247 case Magic('&'): | |
2248 case Magic(')'): | |
2249 cont = FALSE; | |
2250 break; | |
2251 | |
2252 case Magic('Z'): | |
2253 #ifdef FEAT_MBYTE | |
2254 regflags |= RF_ICOMBINE; | |
2255 #endif | |
2256 skipchr_keepstart(); | |
2257 break; | |
2258 case Magic('c'): | |
2259 regflags |= RF_ICASE; | |
2260 skipchr_keepstart(); | |
2261 break; | |
2262 case Magic('C'): | |
2263 regflags |= RF_NOICASE; | |
2264 skipchr_keepstart(); | |
2265 break; | |
2266 case Magic('v'): | |
2267 reg_magic = MAGIC_ALL; | |
2268 skipchr_keepstart(); | |
2269 curchr = -1; | |
2270 break; | |
2271 case Magic('m'): | |
2272 reg_magic = MAGIC_ON; | |
2273 skipchr_keepstart(); | |
2274 curchr = -1; | |
2275 break; | |
2276 case Magic('M'): | |
2277 reg_magic = MAGIC_OFF; | |
2278 skipchr_keepstart(); | |
2279 curchr = -1; | |
2280 break; | |
2281 case Magic('V'): | |
2282 reg_magic = MAGIC_NONE; | |
2283 skipchr_keepstart(); | |
2284 curchr = -1; | |
2285 break; | |
2286 | |
2287 default: | |
2288 if (nfa_regpiece() == FAIL) | |
2289 return FAIL; | |
2290 if (first == FALSE) | |
2291 EMIT(NFA_CONCAT); | |
2292 else | |
2293 first = FALSE; | |
2294 break; | |
2295 } | |
2296 } | |
2297 | |
2298 return OK; | |
2299 } | |
2300 | |
2301 /* | |
2302 * Parse a branch, one or more concats, separated by "\&". It matches the | |
2303 * last concat, but only if all the preceding concats also match at the same | |
2304 * position. Examples: | |
2305 * "foobeep\&..." matches "foo" in "foobeep". | |
2306 * ".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob" | |
2307 * | |
2308 * branch ::= concat | |
2309 * or concat \& concat | |
2310 * or concat \& concat \& concat | |
2311 * etc. | |
2312 */ | |
2313 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2314 nfa_regbranch(void) |
4444 | 2315 { |
2316 int ch; | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2317 int old_post_pos; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2318 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2319 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2320 |
2321 /* First branch, possibly the only one */ | |
2322 if (nfa_regconcat() == FAIL) | |
2323 return FAIL; | |
2324 | |
2325 ch = peekchr(); | |
2326 /* Try next concats */ | |
2327 while (ch == Magic('&')) | |
2328 { | |
2329 skipchr(); | |
2330 EMIT(NFA_NOPEN); | |
2331 EMIT(NFA_PREV_ATOM_NO_WIDTH); | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2332 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2333 if (nfa_regconcat() == FAIL) |
2334 return FAIL; | |
5370 | 2335 /* 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
|
2336 if (old_post_pos == (int)(post_ptr - post_start)) |
5370 | 2337 EMIT(NFA_EMPTY); |
4444 | 2338 EMIT(NFA_CONCAT); |
2339 ch = peekchr(); | |
2340 } | |
2341 | |
5370 | 2342 /* 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
|
2343 if (old_post_pos == (int)(post_ptr - post_start)) |
5370 | 2344 EMIT(NFA_EMPTY); |
4444 | 2345 |
2346 return OK; | |
2347 } | |
2348 | |
2349 /* | |
2350 * Parse a pattern, one or more branches, separated by "\|". It matches | |
2351 * anything that matches one of the branches. Example: "foo\|beep" matches | |
2352 * "foo" and matches "beep". If more than one branch matches, the first one | |
2353 * is used. | |
2354 * | |
2355 * pattern ::= branch | |
2356 * or branch \| branch | |
2357 * or branch \| branch \| branch | |
2358 * etc. | |
2359 */ | |
2360 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2361 nfa_reg( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2362 int paren) /* REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN */ |
4444 | 2363 { |
2364 int parno = 0; | |
2365 | |
2366 if (paren == REG_PAREN) | |
2367 { | |
2368 if (regnpar >= NSUBEXP) /* Too many `(' */ | |
2369 EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('")); | |
2370 parno = regnpar++; | |
2371 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2372 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2373 else if (paren == REG_ZPAREN) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2374 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2375 /* Make a ZOPEN node. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2376 if (regnzpar >= NSUBEXP) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2377 EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z(")); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2378 parno = regnzpar++; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2379 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2380 #endif |
4444 | 2381 |
2382 if (nfa_regbranch() == FAIL) | |
2383 return FAIL; /* cascaded error */ | |
2384 | |
2385 while (peekchr() == Magic('|')) | |
2386 { | |
2387 skipchr(); | |
2388 if (nfa_regbranch() == FAIL) | |
2389 return FAIL; /* cascaded error */ | |
2390 EMIT(NFA_OR); | |
2391 } | |
2392 | |
2393 /* Check for proper termination. */ | |
2394 if (paren != REG_NOPAREN && getchr() != Magic(')')) | |
2395 { | |
2396 if (paren == REG_NPAREN) | |
2397 EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL); | |
2398 else | |
2399 EMSG2_RET_FAIL(_(e_unmatchedp), reg_magic == MAGIC_ALL); | |
2400 } | |
2401 else if (paren == REG_NOPAREN && peekchr() != NUL) | |
2402 { | |
2403 if (peekchr() == Magic(')')) | |
2404 EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL); | |
2405 else | |
2406 EMSG_RET_FAIL(_("E873: (NFA regexp) proper termination error")); | |
2407 } | |
2408 /* | |
2409 * Here we set the flag allowing back references to this set of | |
2410 * parentheses. | |
2411 */ | |
2412 if (paren == REG_PAREN) | |
2413 { | |
2414 had_endbrace[parno] = TRUE; /* have seen the close paren */ | |
2415 EMIT(NFA_MOPEN + parno); | |
2416 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2417 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2418 else if (paren == REG_ZPAREN) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2419 EMIT(NFA_ZOPEN + parno); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2420 #endif |
4444 | 2421 |
2422 return OK; | |
2423 } | |
2424 | |
2425 #ifdef DEBUG | |
2426 static char_u code[50]; | |
2427 | |
2428 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2429 nfa_set_code(int c) |
4444 | 2430 { |
2431 int addnl = FALSE; | |
2432 | |
2433 if (c >= NFA_FIRST_NL && c <= NFA_LAST_NL) | |
2434 { | |
2435 addnl = TRUE; | |
5296 | 2436 c -= NFA_ADD_NL; |
4444 | 2437 } |
2438 | |
2439 STRCPY(code, ""); | |
2440 switch (c) | |
2441 { | |
2442 case NFA_MATCH: STRCPY(code, "NFA_MATCH "); break; | |
2443 case NFA_SPLIT: STRCPY(code, "NFA_SPLIT "); break; | |
2444 case NFA_CONCAT: STRCPY(code, "NFA_CONCAT "); break; | |
2445 case NFA_NEWL: STRCPY(code, "NFA_NEWL "); break; | |
2446 case NFA_ZSTART: STRCPY(code, "NFA_ZSTART"); break; | |
2447 case NFA_ZEND: STRCPY(code, "NFA_ZEND"); break; | |
2448 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2449 case NFA_BACKREF1: STRCPY(code, "NFA_BACKREF1"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2450 case NFA_BACKREF2: STRCPY(code, "NFA_BACKREF2"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2451 case NFA_BACKREF3: STRCPY(code, "NFA_BACKREF3"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2452 case NFA_BACKREF4: STRCPY(code, "NFA_BACKREF4"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2453 case NFA_BACKREF5: STRCPY(code, "NFA_BACKREF5"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2454 case NFA_BACKREF6: STRCPY(code, "NFA_BACKREF6"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2455 case NFA_BACKREF7: STRCPY(code, "NFA_BACKREF7"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2456 case NFA_BACKREF8: STRCPY(code, "NFA_BACKREF8"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2457 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
|
2458 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2459 case NFA_ZREF1: STRCPY(code, "NFA_ZREF1"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2460 case NFA_ZREF2: STRCPY(code, "NFA_ZREF2"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2461 case NFA_ZREF3: STRCPY(code, "NFA_ZREF3"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2462 case NFA_ZREF4: STRCPY(code, "NFA_ZREF4"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2463 case NFA_ZREF5: STRCPY(code, "NFA_ZREF5"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2464 case NFA_ZREF6: STRCPY(code, "NFA_ZREF6"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2465 case NFA_ZREF7: STRCPY(code, "NFA_ZREF7"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2466 case NFA_ZREF8: STRCPY(code, "NFA_ZREF8"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2467 case NFA_ZREF9: STRCPY(code, "NFA_ZREF9"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2468 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2469 case NFA_SKIP: STRCPY(code, "NFA_SKIP"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2470 |
4444 | 2471 case NFA_PREV_ATOM_NO_WIDTH: |
2472 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
|
2473 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
2474 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
|
2475 case NFA_PREV_ATOM_JUST_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2476 STRCPY(code, "NFA_PREV_ATOM_JUST_BEFORE"); break; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2477 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2478 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
|
2479 case NFA_PREV_ATOM_LIKE_PATTERN: |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2480 STRCPY(code, "NFA_PREV_ATOM_LIKE_PATTERN"); break; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2481 |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
2482 case NFA_NOPEN: STRCPY(code, "NFA_NOPEN"); break; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
2483 case NFA_NCLOSE: STRCPY(code, "NFA_NCLOSE"); break; |
4444 | 2484 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
|
2485 case NFA_START_INVISIBLE_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2486 STRCPY(code, "NFA_START_INVISIBLE_FIRST"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2487 case NFA_START_INVISIBLE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2488 STRCPY(code, "NFA_START_INVISIBLE_NEG"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2489 case NFA_START_INVISIBLE_NEG_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2490 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
|
2491 case NFA_START_INVISIBLE_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2492 STRCPY(code, "NFA_START_INVISIBLE_BEFORE"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2493 case NFA_START_INVISIBLE_BEFORE_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2494 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
|
2495 case NFA_START_INVISIBLE_BEFORE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2496 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
|
2497 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2498 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
|
2499 case NFA_START_PATTERN: STRCPY(code, "NFA_START_PATTERN"); break; |
4444 | 2500 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
|
2501 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
|
2502 case NFA_END_PATTERN: STRCPY(code, "NFA_END_PATTERN"); break; |
4444 | 2503 |
2504 case NFA_COMPOSING: STRCPY(code, "NFA_COMPOSING"); break; | |
2505 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
|
2506 case NFA_OPT_CHARS: STRCPY(code, "NFA_OPT_CHARS"); break; |
4444 | 2507 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2508 case NFA_MOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2509 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2510 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2511 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2512 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2513 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2514 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2515 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2516 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2517 case NFA_MOPEN9: |
4444 | 2518 STRCPY(code, "NFA_MOPEN(x)"); |
2519 code[10] = c - NFA_MOPEN + '0'; | |
2520 break; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2521 case NFA_MCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2522 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2523 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2524 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2525 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2526 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2527 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2528 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2529 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2530 case NFA_MCLOSE9: |
4444 | 2531 STRCPY(code, "NFA_MCLOSE(x)"); |
2532 code[11] = c - NFA_MCLOSE + '0'; | |
2533 break; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2534 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2535 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2536 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2537 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2538 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2539 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2540 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2541 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2542 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2543 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2544 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2545 STRCPY(code, "NFA_ZOPEN(x)"); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2546 code[10] = c - NFA_ZOPEN + '0'; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2547 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2548 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2549 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2550 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2551 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2552 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2553 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2554 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2555 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2556 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2557 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2558 STRCPY(code, "NFA_ZCLOSE(x)"); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2559 code[11] = c - NFA_ZCLOSE + '0'; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2560 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2561 #endif |
4444 | 2562 case NFA_EOL: STRCPY(code, "NFA_EOL "); break; |
2563 case NFA_BOL: STRCPY(code, "NFA_BOL "); break; | |
2564 case NFA_EOW: STRCPY(code, "NFA_EOW "); break; | |
2565 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
|
2566 case NFA_EOF: STRCPY(code, "NFA_EOF "); break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
2567 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
|
2568 case NFA_LNUM: STRCPY(code, "NFA_LNUM "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2569 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
|
2570 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
|
2571 case NFA_COL: STRCPY(code, "NFA_COL "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2572 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
|
2573 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
|
2574 case NFA_VCOL: STRCPY(code, "NFA_VCOL "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2575 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
|
2576 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
|
2577 case NFA_MARK: STRCPY(code, "NFA_MARK "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2578 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
|
2579 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
|
2580 case NFA_CURSOR: STRCPY(code, "NFA_CURSOR "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2581 case NFA_VISUAL: STRCPY(code, "NFA_VISUAL "); break; |
5901 | 2582 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
|
2583 |
4444 | 2584 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
|
2585 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
|
2586 case NFA_QUEST: STRCPY(code, "NFA_QUEST"); break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2587 case NFA_QUEST_NONGREEDY: STRCPY(code, "NFA_QUEST_NON_GREEDY"); break; |
5370 | 2588 case NFA_EMPTY: STRCPY(code, "NFA_EMPTY"); break; |
4444 | 2589 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
|
2590 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2591 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
|
2592 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
|
2593 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
|
2594 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
|
2595 case NFA_RANGE: STRCPY(code, "NFA_RANGE"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2596 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
|
2597 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
|
2598 |
4444 | 2599 case NFA_CLASS_ALNUM: STRCPY(code, "NFA_CLASS_ALNUM"); break; |
2600 case NFA_CLASS_ALPHA: STRCPY(code, "NFA_CLASS_ALPHA"); break; | |
2601 case NFA_CLASS_BLANK: STRCPY(code, "NFA_CLASS_BLANK"); break; | |
2602 case NFA_CLASS_CNTRL: STRCPY(code, "NFA_CLASS_CNTRL"); break; | |
2603 case NFA_CLASS_DIGIT: STRCPY(code, "NFA_CLASS_DIGIT"); break; | |
2604 case NFA_CLASS_GRAPH: STRCPY(code, "NFA_CLASS_GRAPH"); break; | |
2605 case NFA_CLASS_LOWER: STRCPY(code, "NFA_CLASS_LOWER"); break; | |
2606 case NFA_CLASS_PRINT: STRCPY(code, "NFA_CLASS_PRINT"); break; | |
2607 case NFA_CLASS_PUNCT: STRCPY(code, "NFA_CLASS_PUNCT"); break; | |
2608 case NFA_CLASS_SPACE: STRCPY(code, "NFA_CLASS_SPACE"); break; | |
2609 case NFA_CLASS_UPPER: STRCPY(code, "NFA_CLASS_UPPER"); break; | |
2610 case NFA_CLASS_XDIGIT: STRCPY(code, "NFA_CLASS_XDIGIT"); break; | |
2611 case NFA_CLASS_TAB: STRCPY(code, "NFA_CLASS_TAB"); break; | |
2612 case NFA_CLASS_RETURN: STRCPY(code, "NFA_CLASS_RETURN"); break; | |
2613 case NFA_CLASS_BACKSPACE: STRCPY(code, "NFA_CLASS_BACKSPACE"); break; | |
2614 case NFA_CLASS_ESCAPE: STRCPY(code, "NFA_CLASS_ESCAPE"); break; | |
2615 | |
2616 case NFA_ANY: STRCPY(code, "NFA_ANY"); break; | |
2617 case NFA_IDENT: STRCPY(code, "NFA_IDENT"); break; | |
2618 case NFA_SIDENT:STRCPY(code, "NFA_SIDENT"); break; | |
2619 case NFA_KWORD: STRCPY(code, "NFA_KWORD"); break; | |
2620 case NFA_SKWORD:STRCPY(code, "NFA_SKWORD"); break; | |
2621 case NFA_FNAME: STRCPY(code, "NFA_FNAME"); break; | |
2622 case NFA_SFNAME:STRCPY(code, "NFA_SFNAME"); break; | |
2623 case NFA_PRINT: STRCPY(code, "NFA_PRINT"); break; | |
2624 case NFA_SPRINT:STRCPY(code, "NFA_SPRINT"); break; | |
2625 case NFA_WHITE: STRCPY(code, "NFA_WHITE"); break; | |
2626 case NFA_NWHITE:STRCPY(code, "NFA_NWHITE"); break; | |
2627 case NFA_DIGIT: STRCPY(code, "NFA_DIGIT"); break; | |
2628 case NFA_NDIGIT:STRCPY(code, "NFA_NDIGIT"); break; | |
2629 case NFA_HEX: STRCPY(code, "NFA_HEX"); break; | |
2630 case NFA_NHEX: STRCPY(code, "NFA_NHEX"); break; | |
2631 case NFA_OCTAL: STRCPY(code, "NFA_OCTAL"); break; | |
2632 case NFA_NOCTAL:STRCPY(code, "NFA_NOCTAL"); break; | |
2633 case NFA_WORD: STRCPY(code, "NFA_WORD"); break; | |
2634 case NFA_NWORD: STRCPY(code, "NFA_NWORD"); break; | |
2635 case NFA_HEAD: STRCPY(code, "NFA_HEAD"); break; | |
2636 case NFA_NHEAD: STRCPY(code, "NFA_NHEAD"); break; | |
2637 case NFA_ALPHA: STRCPY(code, "NFA_ALPHA"); break; | |
2638 case NFA_NALPHA:STRCPY(code, "NFA_NALPHA"); break; | |
2639 case NFA_LOWER: STRCPY(code, "NFA_LOWER"); break; | |
2640 case NFA_NLOWER:STRCPY(code, "NFA_NLOWER"); break; | |
2641 case NFA_UPPER: STRCPY(code, "NFA_UPPER"); break; | |
2642 case NFA_NUPPER:STRCPY(code, "NFA_NUPPER"); break; | |
5296 | 2643 case NFA_LOWER_IC: STRCPY(code, "NFA_LOWER_IC"); break; |
2644 case NFA_NLOWER_IC: STRCPY(code, "NFA_NLOWER_IC"); break; | |
2645 case NFA_UPPER_IC: STRCPY(code, "NFA_UPPER_IC"); break; | |
2646 case NFA_NUPPER_IC: STRCPY(code, "NFA_NUPPER_IC"); break; | |
4444 | 2647 |
2648 default: | |
2649 STRCPY(code, "CHAR(x)"); | |
2650 code[5] = c; | |
2651 } | |
2652 | |
2653 if (addnl == TRUE) | |
2654 STRCAT(code, " + NEWLINE "); | |
2655 | |
2656 } | |
2657 | |
2658 #ifdef ENABLE_LOG | |
2659 static FILE *log_fd; | |
2660 | |
2661 /* | |
2662 * Print the postfix notation of the current regexp. | |
2663 */ | |
2664 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2665 nfa_postfix_dump(char_u *expr, int retval) |
4444 | 2666 { |
2667 int *p; | |
2668 FILE *f; | |
2669 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2670 f = fopen(NFA_REGEXP_DUMP_LOG, "a"); |
4444 | 2671 if (f != NULL) |
2672 { | |
2673 fprintf(f, "\n-------------------------\n"); | |
2674 if (retval == FAIL) | |
2675 fprintf(f, ">>> NFA engine failed ... \n"); | |
2676 else if (retval == OK) | |
2677 fprintf(f, ">>> NFA engine succeeded !\n"); | |
2678 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
|
2679 for (p = post_start; *p && p < post_ptr; p++) |
4444 | 2680 { |
2681 nfa_set_code(*p); | |
2682 fprintf(f, "%s, ", code); | |
2683 } | |
2684 fprintf(f, "\"\nPostfix notation (int): "); | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2685 for (p = post_start; *p && p < post_ptr; p++) |
4444 | 2686 fprintf(f, "%d ", *p); |
2687 fprintf(f, "\n\n"); | |
2688 fclose(f); | |
2689 } | |
2690 } | |
2691 | |
2692 /* | |
2693 * Print the NFA starting with a root node "state". | |
2694 */ | |
2695 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2696 nfa_print_state(FILE *debugf, nfa_state_T *state) |
4444 | 2697 { |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2698 garray_T indent; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2699 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2700 ga_init2(&indent, 1, 64); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2701 ga_append(&indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2702 nfa_print_state2(debugf, state, &indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2703 ga_clear(&indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2704 } |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2705 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2706 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2707 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
|
2708 { |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2709 char_u *p; |
4444 | 2710 |
2711 if (state == NULL) | |
2712 return; | |
2713 | |
2714 fprintf(debugf, "(%2d)", abs(state->id)); | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2715 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2716 /* Output indent */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2717 p = (char_u *)indent->ga_data; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2718 if (indent->ga_len >= 3) |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2719 { |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2720 int last = indent->ga_len - 3; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2721 char_u save[2]; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2722 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2723 STRNCPY(save, &p[last], 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2724 STRNCPY(&p[last], "+-", 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2725 fprintf(debugf, " %s", p); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2726 STRNCPY(&p[last], save, 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2727 } |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2728 else |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2729 fprintf(debugf, " %s", p); |
4444 | 2730 |
2731 nfa_set_code(state->c); | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2732 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
|
2733 code, |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2734 state->c, |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2735 abs(state->id), |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2736 state->val); |
4444 | 2737 if (state->id < 0) |
2738 return; | |
2739 | |
2740 state->id = abs(state->id) * -1; | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2741 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2742 /* grow indent for state->out */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2743 indent->ga_len -= 1; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2744 if (state->out1) |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2745 ga_concat(indent, (char_u *)"| "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2746 else |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2747 ga_concat(indent, (char_u *)" "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2748 ga_append(indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2749 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2750 nfa_print_state2(debugf, state->out, indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2751 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2752 /* replace last part of indent for state->out1 */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2753 indent->ga_len -= 3; |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2754 ga_concat(indent, (char_u *)" "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2755 ga_append(indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2756 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2757 nfa_print_state2(debugf, state->out1, indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2758 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2759 /* shrink indent */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2760 indent->ga_len -= 3; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2761 ga_append(indent, '\0'); |
4444 | 2762 } |
2763 | |
2764 /* | |
2765 * Print the NFA state machine. | |
2766 */ | |
2767 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2768 nfa_dump(nfa_regprog_T *prog) |
4444 | 2769 { |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2770 FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a"); |
4444 | 2771 |
2772 if (debugf != NULL) | |
2773 { | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2774 nfa_print_state(debugf, prog->start); |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
2775 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2776 if (prog->reganch) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2777 fprintf(debugf, "reganch: %d\n", prog->reganch); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2778 if (prog->regstart != NUL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2779 fprintf(debugf, "regstart: %c (decimal: %d)\n", |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2780 prog->regstart, prog->regstart); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2781 if (prog->match_text != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2782 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
|
2783 |
4444 | 2784 fclose(debugf); |
2785 } | |
2786 } | |
2787 #endif /* ENABLE_LOG */ | |
2788 #endif /* DEBUG */ | |
2789 | |
2790 /* | |
2791 * Parse r.e. @expr and convert it into postfix form. | |
2792 * Return the postfix string on success, NULL otherwise. | |
2793 */ | |
2794 static int * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2795 re2post(void) |
4444 | 2796 { |
2797 if (nfa_reg(REG_NOPAREN) == FAIL) | |
2798 return NULL; | |
2799 EMIT(NFA_MOPEN); | |
2800 return post_start; | |
2801 } | |
2802 | |
2803 /* NB. Some of the code below is inspired by Russ's. */ | |
2804 | |
2805 /* | |
2806 * Represents an NFA state plus zero or one or two arrows exiting. | |
2807 * if c == MATCH, no arrows out; matching state. | |
2808 * If c == SPLIT, unlabeled arrows to out and out1 (if != NULL). | |
2809 * If c < 256, labeled arrow with character c to out. | |
2810 */ | |
2811 | |
2812 static nfa_state_T *state_ptr; /* points to nfa_prog->state */ | |
2813 | |
2814 /* | |
2815 * Allocate and initialize nfa_state_T. | |
2816 */ | |
2817 static nfa_state_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2818 alloc_state(int c, nfa_state_T *out, nfa_state_T *out1) |
4444 | 2819 { |
2820 nfa_state_T *s; | |
2821 | |
2822 if (istate >= nstate) | |
2823 return NULL; | |
2824 | |
2825 s = &state_ptr[istate++]; | |
2826 | |
2827 s->c = c; | |
2828 s->out = out; | |
2829 s->out1 = out1; | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2830 s->val = 0; |
4444 | 2831 |
2832 s->id = istate; | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
2833 s->lastlist[0] = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
2834 s->lastlist[1] = 0; |
4444 | 2835 |
2836 return s; | |
2837 } | |
2838 | |
2839 /* | |
2840 * A partially built NFA without the matching state filled in. | |
2841 * Frag_T.start points at the start state. | |
2842 * Frag_T.out is a list of places that need to be set to the | |
2843 * next state for this fragment. | |
2844 */ | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2845 |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2846 /* Since the out pointers in the list are always |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2847 * uninitialized, we use the pointers themselves |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2848 * as storage for the Ptrlists. */ |
4444 | 2849 typedef union Ptrlist Ptrlist; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2850 union Ptrlist |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2851 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2852 Ptrlist *next; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2853 nfa_state_T *s; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2854 }; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2855 |
4444 | 2856 struct Frag |
2857 { | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2858 nfa_state_T *start; |
4444 | 2859 Ptrlist *out; |
2860 }; | |
2861 typedef struct Frag Frag_T; | |
2862 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2863 static Frag_T frag(nfa_state_T *start, Ptrlist *out); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2864 static Ptrlist *list1(nfa_state_T **outp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2865 static void patch(Ptrlist *l, nfa_state_T *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2866 static Ptrlist *append(Ptrlist *l1, Ptrlist *l2); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2867 static void st_push(Frag_T s, Frag_T **p, Frag_T *stack_end); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2868 static Frag_T st_pop(Frag_T **p, Frag_T *stack); |
4444 | 2869 |
2870 /* | |
4456 | 2871 * Initialize a Frag_T struct and return it. |
4444 | 2872 */ |
2873 static Frag_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2874 frag(nfa_state_T *start, Ptrlist *out) |
4444 | 2875 { |
4456 | 2876 Frag_T n; |
2877 | |
2878 n.start = start; | |
2879 n.out = out; | |
4444 | 2880 return n; |
2881 } | |
2882 | |
2883 /* | |
2884 * Create singleton list containing just outp. | |
2885 */ | |
2886 static Ptrlist * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2887 list1( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2888 nfa_state_T **outp) |
4444 | 2889 { |
2890 Ptrlist *l; | |
2891 | |
2892 l = (Ptrlist *)outp; | |
2893 l->next = NULL; | |
2894 return l; | |
2895 } | |
2896 | |
2897 /* | |
2898 * Patch the list of states at out to point to start. | |
2899 */ | |
2900 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2901 patch(Ptrlist *l, nfa_state_T *s) |
4444 | 2902 { |
2903 Ptrlist *next; | |
2904 | |
2905 for (; l; l = next) | |
2906 { | |
2907 next = l->next; | |
2908 l->s = s; | |
2909 } | |
2910 } | |
2911 | |
2912 | |
2913 /* | |
2914 * Join the two lists l1 and l2, returning the combination. | |
2915 */ | |
2916 static Ptrlist * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2917 append(Ptrlist *l1, Ptrlist *l2) |
4444 | 2918 { |
2919 Ptrlist *oldl1; | |
2920 | |
2921 oldl1 = l1; | |
2922 while (l1->next) | |
2923 l1 = l1->next; | |
2924 l1->next = l2; | |
2925 return oldl1; | |
2926 } | |
2927 | |
2928 /* | |
2929 * Stack used for transforming postfix form into NFA. | |
2930 */ | |
2931 static Frag_T empty; | |
2932 | |
2933 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2934 st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED) |
4444 | 2935 { |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2936 #ifdef NFA_REGEXP_ERROR_LOG |
4444 | 2937 FILE *df; |
2938 int *p2; | |
2939 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2940 df = fopen(NFA_REGEXP_ERROR_LOG, "a"); |
4444 | 2941 if (df) |
2942 { | |
2943 fprintf(df, "Error popping the stack!\n"); | |
2944 #ifdef DEBUG | |
2945 fprintf(df, "Current regexp is \"%s\"\n", nfa_regengine.expr); | |
2946 #endif | |
2947 fprintf(df, "Postfix form is: "); | |
2948 #ifdef DEBUG | |
2949 for (p2 = postfix; p2 < end; p2++) | |
2950 { | |
2951 nfa_set_code(*p2); | |
2952 fprintf(df, "%s, ", code); | |
2953 } | |
2954 nfa_set_code(*p); | |
2955 fprintf(df, "\nCurrent position is: "); | |
2956 for (p2 = postfix; p2 <= p; p2 ++) | |
2957 { | |
2958 nfa_set_code(*p2); | |
2959 fprintf(df, "%s, ", code); | |
2960 } | |
2961 #else | |
2962 for (p2 = postfix; p2 < end; p2++) | |
2963 { | |
2964 fprintf(df, "%d, ", *p2); | |
2965 } | |
2966 fprintf(df, "\nCurrent position is: "); | |
2967 for (p2 = postfix; p2 <= p; p2 ++) | |
2968 { | |
2969 fprintf(df, "%d, ", *p2); | |
2970 } | |
2971 #endif | |
2972 fprintf(df, "\n--------------------------\n"); | |
2973 fclose(df); | |
2974 } | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2975 #endif |
4444 | 2976 EMSG(_("E874: (NFA) Could not pop the stack !")); |
2977 } | |
2978 | |
2979 /* | |
2980 * Push an item onto the stack. | |
2981 */ | |
2982 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2983 st_push(Frag_T s, Frag_T **p, Frag_T *stack_end) |
4444 | 2984 { |
2985 Frag_T *stackp = *p; | |
2986 | |
2987 if (stackp >= stack_end) | |
2988 return; | |
2989 *stackp = s; | |
2990 *p = *p + 1; | |
2991 } | |
2992 | |
2993 /* | |
2994 * Pop an item from the stack. | |
2995 */ | |
2996 static Frag_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2997 st_pop(Frag_T **p, Frag_T *stack) |
4444 | 2998 { |
2999 Frag_T *stackp; | |
3000 | |
3001 *p = *p - 1; | |
3002 stackp = *p; | |
3003 if (stackp < stack) | |
3004 return empty; | |
3005 return **p; | |
3006 } | |
3007 | |
3008 /* | |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3009 * 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
|
3010 * When unknown or unlimited return -1. |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3011 */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3012 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3013 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
|
3014 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3015 int l, r; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3016 nfa_state_T *state = startstate; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3017 int len = 0; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3018 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3019 /* detect looping in a NFA_SPLIT */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3020 if (depth > 4) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3021 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3022 |
4958
0a379dea13c9
updated for version 7.3.1224
Bram Moolenaar <bram@vim.org>
parents:
4944
diff
changeset
|
3023 while (state != NULL) |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3024 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3025 switch (state->c) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3026 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3027 case NFA_END_INVISIBLE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3028 case NFA_END_INVISIBLE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3029 /* the end, return what we have */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3030 return len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3031 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3032 case NFA_SPLIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3033 /* two alternatives, use the maximum */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3034 l = nfa_max_width(state->out, depth + 1); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3035 r = nfa_max_width(state->out1, depth + 1); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3036 if (l < 0 || r < 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3037 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3038 return len + (l > r ? l : r); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3039 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3040 case NFA_ANY: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3041 case NFA_START_COLL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3042 case NFA_START_NEG_COLL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3043 /* matches some character, including composing chars */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3044 #ifdef FEAT_MBYTE |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3045 if (enc_utf8) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3046 len += MB_MAXBYTES; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3047 else if (has_mbyte) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3048 len += 2; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3049 else |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3050 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3051 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3052 if (state->c != NFA_ANY) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3053 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3054 /* skip over the characters */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3055 state = state->out1->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3056 continue; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3057 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3058 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3059 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3060 case NFA_DIGIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3061 case NFA_WHITE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3062 case NFA_HEX: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3063 case NFA_OCTAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3064 /* ascii */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3065 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3066 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3067 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3068 case NFA_IDENT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3069 case NFA_SIDENT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3070 case NFA_KWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3071 case NFA_SKWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3072 case NFA_FNAME: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3073 case NFA_SFNAME: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3074 case NFA_PRINT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3075 case NFA_SPRINT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3076 case NFA_NWHITE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3077 case NFA_NDIGIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3078 case NFA_NHEX: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3079 case NFA_NOCTAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3080 case NFA_WORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3081 case NFA_NWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3082 case NFA_HEAD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3083 case NFA_NHEAD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3084 case NFA_ALPHA: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3085 case NFA_NALPHA: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3086 case NFA_LOWER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3087 case NFA_NLOWER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3088 case NFA_UPPER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3089 case NFA_NUPPER: |
5296 | 3090 case NFA_LOWER_IC: |
3091 case NFA_NLOWER_IC: | |
3092 case NFA_UPPER_IC: | |
3093 case NFA_NUPPER_IC: | |
5901 | 3094 case NFA_ANY_COMPOSING: |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3095 /* possibly non-ascii */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3096 #ifdef FEAT_MBYTE |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3097 if (has_mbyte) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3098 len += 3; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3099 else |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3100 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3101 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3102 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3103 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3104 case NFA_START_INVISIBLE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3105 case NFA_START_INVISIBLE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3106 case NFA_START_INVISIBLE_BEFORE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3107 case NFA_START_INVISIBLE_BEFORE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3108 /* zero-width, out1 points to the END state */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3109 state = state->out1->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3110 continue; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3111 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3112 case NFA_BACKREF1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3113 case NFA_BACKREF2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3114 case NFA_BACKREF3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3115 case NFA_BACKREF4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3116 case NFA_BACKREF5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3117 case NFA_BACKREF6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3118 case NFA_BACKREF7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3119 case NFA_BACKREF8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3120 case NFA_BACKREF9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3121 #ifdef FEAT_SYN_HL |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3122 case NFA_ZREF1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3123 case NFA_ZREF2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3124 case NFA_ZREF3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3125 case NFA_ZREF4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3126 case NFA_ZREF5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3127 case NFA_ZREF6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3128 case NFA_ZREF7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3129 case NFA_ZREF8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3130 case NFA_ZREF9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3131 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3132 case NFA_NEWL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3133 case NFA_SKIP: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3134 /* unknown width */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3135 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3136 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3137 case NFA_BOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3138 case NFA_EOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3139 case NFA_BOF: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3140 case NFA_EOF: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3141 case NFA_BOW: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3142 case NFA_EOW: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3143 case NFA_MOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3144 case NFA_MOPEN1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3145 case NFA_MOPEN2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3146 case NFA_MOPEN3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3147 case NFA_MOPEN4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3148 case NFA_MOPEN5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3149 case NFA_MOPEN6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3150 case NFA_MOPEN7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3151 case NFA_MOPEN8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3152 case NFA_MOPEN9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3153 #ifdef FEAT_SYN_HL |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3154 case NFA_ZOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3155 case NFA_ZOPEN1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3156 case NFA_ZOPEN2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3157 case NFA_ZOPEN3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3158 case NFA_ZOPEN4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3159 case NFA_ZOPEN5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3160 case NFA_ZOPEN6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3161 case NFA_ZOPEN7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3162 case NFA_ZOPEN8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3163 case NFA_ZOPEN9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3164 case NFA_ZCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3165 case NFA_ZCLOSE1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3166 case NFA_ZCLOSE2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3167 case NFA_ZCLOSE3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3168 case NFA_ZCLOSE4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3169 case NFA_ZCLOSE5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3170 case NFA_ZCLOSE6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3171 case NFA_ZCLOSE7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3172 case NFA_ZCLOSE8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3173 case NFA_ZCLOSE9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3174 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3175 case NFA_MCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3176 case NFA_MCLOSE1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3177 case NFA_MCLOSE2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3178 case NFA_MCLOSE3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3179 case NFA_MCLOSE4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3180 case NFA_MCLOSE5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3181 case NFA_MCLOSE6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3182 case NFA_MCLOSE7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3183 case NFA_MCLOSE8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3184 case NFA_MCLOSE9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3185 case NFA_NOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3186 case NFA_NCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3187 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3188 case NFA_LNUM_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3189 case NFA_LNUM_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3190 case NFA_COL_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3191 case NFA_COL_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3192 case NFA_VCOL_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3193 case NFA_VCOL_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3194 case NFA_MARK_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3195 case NFA_MARK_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3196 case NFA_VISUAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3197 case NFA_LNUM: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3198 case NFA_CURSOR: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3199 case NFA_COL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3200 case NFA_VCOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3201 case NFA_MARK: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3202 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3203 case NFA_ZSTART: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3204 case NFA_ZEND: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3205 case NFA_OPT_CHARS: |
5370 | 3206 case NFA_EMPTY: |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3207 case NFA_START_PATTERN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3208 case NFA_END_PATTERN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3209 case NFA_COMPOSING: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3210 case NFA_END_COMPOSING: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3211 /* zero-width */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3212 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3213 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3214 default: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3215 if (state->c < 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3216 /* don't know what this is */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3217 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3218 /* normal character */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3219 len += MB_CHAR2LEN(state->c); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3220 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3221 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3222 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3223 /* normal way to continue */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3224 state = state->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3225 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3226 |
4958
0a379dea13c9
updated for version 7.3.1224
Bram Moolenaar <bram@vim.org>
parents:
4944
diff
changeset
|
3227 /* unrecognized, "cannot happen" */ |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3228 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3229 } |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
3230 |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3231 /* |
4444 | 3232 * Convert a postfix form into its equivalent NFA. |
3233 * Return the NFA start state on success, NULL otherwise. | |
3234 */ | |
3235 static nfa_state_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3236 post2nfa(int *postfix, int *end, int nfa_calc_size) |
4444 | 3237 { |
3238 int *p; | |
3239 int mopen; | |
3240 int mclose; | |
3241 Frag_T *stack = NULL; | |
3242 Frag_T *stackp = NULL; | |
3243 Frag_T *stack_end = NULL; | |
3244 Frag_T e1; | |
3245 Frag_T e2; | |
3246 Frag_T e; | |
3247 nfa_state_T *s; | |
3248 nfa_state_T *s1; | |
3249 nfa_state_T *matchstate; | |
4484 | 3250 nfa_state_T *ret = NULL; |
4444 | 3251 |
3252 if (postfix == NULL) | |
3253 return NULL; | |
3254 | |
4456 | 3255 #define PUSH(s) st_push((s), &stackp, stack_end) |
4444 | 3256 #define POP() st_pop(&stackp, stack); \ |
3257 if (stackp < stack) \ | |
3258 { \ | |
3259 st_error(postfix, end, p); \ | |
6747 | 3260 vim_free(stack); \ |
4444 | 3261 return NULL; \ |
3262 } | |
3263 | |
3264 if (nfa_calc_size == FALSE) | |
3265 { | |
3266 /* Allocate space for the stack. Max states on the stack : nstate */ | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3267 stack = (Frag_T *)lalloc((nstate + 1) * sizeof(Frag_T), TRUE); |
4444 | 3268 stackp = stack; |
4462 | 3269 stack_end = stack + (nstate + 1); |
4444 | 3270 } |
3271 | |
3272 for (p = postfix; p < end; ++p) | |
3273 { | |
3274 switch (*p) | |
3275 { | |
3276 case NFA_CONCAT: | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3277 /* Concatenation. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3278 * Pay attention: this operator does not exist in the r.e. itself |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3279 * (it is implicit, really). It is added when r.e. is translated |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3280 * to postfix form in re2post(). */ |
4444 | 3281 if (nfa_calc_size == TRUE) |
3282 { | |
4458 | 3283 /* nstate += 0; */ |
4444 | 3284 break; |
3285 } | |
3286 e2 = POP(); | |
3287 e1 = POP(); | |
3288 patch(e1.out, e2.start); | |
3289 PUSH(frag(e1.start, e2.out)); | |
3290 break; | |
3291 | |
3292 case NFA_OR: | |
3293 /* Alternation */ | |
3294 if (nfa_calc_size == TRUE) | |
3295 { | |
4458 | 3296 nstate++; |
4444 | 3297 break; |
3298 } | |
3299 e2 = POP(); | |
3300 e1 = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3301 s = alloc_state(NFA_SPLIT, e1.start, e2.start); |
4444 | 3302 if (s == NULL) |
4484 | 3303 goto theend; |
4444 | 3304 PUSH(frag(s, append(e1.out, e2.out))); |
3305 break; | |
3306 | |
3307 case NFA_STAR: | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3308 /* Zero or more, prefer more */ |
4444 | 3309 if (nfa_calc_size == TRUE) |
3310 { | |
4458 | 3311 nstate++; |
4444 | 3312 break; |
3313 } | |
3314 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3315 s = alloc_state(NFA_SPLIT, e.start, NULL); |
4444 | 3316 if (s == NULL) |
4484 | 3317 goto theend; |
4444 | 3318 patch(e.out, s); |
3319 PUSH(frag(s, list1(&s->out1))); | |
3320 break; | |
3321 | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3322 case NFA_STAR_NONGREEDY: |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3323 /* Zero or more, prefer zero */ |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3324 if (nfa_calc_size == TRUE) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3325 { |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3326 nstate++; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3327 break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3328 } |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3329 e = POP(); |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3330 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
|
3331 if (s == NULL) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3332 goto theend; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3333 patch(e.out, s); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3334 PUSH(frag(s, list1(&s->out))); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3335 break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3336 |
4444 | 3337 case NFA_QUEST: |
3338 /* one or zero atoms=> greedy match */ | |
3339 if (nfa_calc_size == TRUE) | |
3340 { | |
4458 | 3341 nstate++; |
4444 | 3342 break; |
3343 } | |
3344 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3345 s = alloc_state(NFA_SPLIT, e.start, NULL); |
4444 | 3346 if (s == NULL) |
4484 | 3347 goto theend; |
4444 | 3348 PUSH(frag(s, append(e.out, list1(&s->out1)))); |
3349 break; | |
3350 | |
3351 case NFA_QUEST_NONGREEDY: | |
3352 /* zero or one atoms => non-greedy match */ | |
3353 if (nfa_calc_size == TRUE) | |
3354 { | |
4458 | 3355 nstate++; |
4444 | 3356 break; |
3357 } | |
3358 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3359 s = alloc_state(NFA_SPLIT, NULL, e.start); |
4444 | 3360 if (s == NULL) |
4484 | 3361 goto theend; |
4444 | 3362 PUSH(frag(s, append(e.out, list1(&s->out)))); |
3363 break; | |
3364 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3365 case NFA_END_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3366 case NFA_END_NEG_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3367 /* On the stack is the sequence starting with NFA_START_COLL or |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3368 * NFA_START_NEG_COLL and all possible characters. Patch it to |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3369 * add the output to the start. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3370 if (nfa_calc_size == TRUE) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3371 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3372 nstate++; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3373 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3374 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3375 e = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3376 s = alloc_state(NFA_END_COLL, NULL, NULL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3377 if (s == NULL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3378 goto theend; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3379 patch(e.out, s); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3380 e.start->out1 = s; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3381 PUSH(frag(e.start, list1(&s->out))); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3382 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3383 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3384 case NFA_RANGE: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3385 /* Before this are two characters, the low and high end of a |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3386 * range. Turn them into two states with MIN and MAX. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3387 if (nfa_calc_size == TRUE) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3388 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3389 /* nstate += 0; */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3390 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3391 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3392 e2 = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3393 e1 = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3394 e2.start->val = e2.start->c; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3395 e2.start->c = NFA_RANGE_MAX; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3396 e1.start->val = e1.start->c; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3397 e1.start->c = NFA_RANGE_MIN; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3398 patch(e1.out, e2.start); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3399 PUSH(frag(e1.start, e2.out)); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3400 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3401 |
5370 | 3402 case NFA_EMPTY: |
3403 /* 0-length, used in a repetition with max/min count of 0 */ | |
4444 | 3404 if (nfa_calc_size == TRUE) |
3405 { | |
4458 | 3406 nstate++; |
4444 | 3407 break; |
3408 } | |
5370 | 3409 s = alloc_state(NFA_EMPTY, NULL, NULL); |
4444 | 3410 if (s == NULL) |
4484 | 3411 goto theend; |
4444 | 3412 PUSH(frag(s, list1(&s->out))); |
3413 break; | |
3414 | |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3415 case NFA_OPT_CHARS: |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3416 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3417 int n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3418 |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3419 /* \%[abc] implemented as: |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3420 * NFA_SPLIT |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3421 * +-CHAR(a) |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3422 * | +-NFA_SPLIT |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3423 * | +-CHAR(b) |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3424 * | | +-NFA_SPLIT |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3425 * | | +-CHAR(c) |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3426 * | | | +-next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3427 * | | +- next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3428 * | +- next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3429 * +- next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3430 */ |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3431 n = *++p; /* get number of characters */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3432 if (nfa_calc_size == TRUE) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3433 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3434 nstate += n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3435 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3436 } |
4758
b25a1b2e3175
updated for version 7.3.1126
Bram Moolenaar <bram@vim.org>
parents:
4756
diff
changeset
|
3437 s = NULL; /* avoid compiler warning */ |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3438 e1.out = NULL; /* stores list with out1's */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3439 s1 = NULL; /* previous NFA_SPLIT to connect to */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3440 while (n-- > 0) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3441 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3442 e = POP(); /* get character */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3443 s = alloc_state(NFA_SPLIT, e.start, NULL); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3444 if (s == NULL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3445 goto theend; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3446 if (e1.out == NULL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3447 e1 = e; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3448 patch(e.out, s1); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3449 append(e1.out, list1(&s->out1)); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3450 s1 = s; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3451 } |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3452 PUSH(frag(s, e1.out)); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3453 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3454 } |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3455 |
4444 | 3456 case NFA_PREV_ATOM_NO_WIDTH: |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
3457 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3458 case NFA_PREV_ATOM_JUST_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3459 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3460 case NFA_PREV_ATOM_LIKE_PATTERN: |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3461 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3462 int before = (*p == NFA_PREV_ATOM_JUST_BEFORE |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3463 || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3464 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
|
3465 int start_state; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3466 int end_state; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3467 int n = 0; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3468 nfa_state_T *zend; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3469 nfa_state_T *skip; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3470 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3471 switch (*p) |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3472 { |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3473 case NFA_PREV_ATOM_NO_WIDTH: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3474 start_state = NFA_START_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3475 end_state = NFA_END_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3476 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3477 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3478 start_state = NFA_START_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3479 end_state = NFA_END_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3480 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3481 case NFA_PREV_ATOM_JUST_BEFORE: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3482 start_state = NFA_START_INVISIBLE_BEFORE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3483 end_state = NFA_END_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3484 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3485 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3486 start_state = NFA_START_INVISIBLE_BEFORE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3487 end_state = NFA_END_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3488 break; |
4819
8c4324e6f477
updated for version 7.3.1156
Bram Moolenaar <bram@vim.org>
parents:
4815
diff
changeset
|
3489 default: /* NFA_PREV_ATOM_LIKE_PATTERN: */ |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3490 start_state = NFA_START_PATTERN; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3491 end_state = NFA_END_PATTERN; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3492 break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3493 } |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3494 |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3495 if (before) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3496 n = *++p; /* get the count */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3497 |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
3498 /* The \@= operator: match the preceding atom with zero width. |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
3499 * The \@! operator: no match for the preceding atom. |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3500 * The \@<= operator: match for the preceding atom. |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3501 * The \@<! operator: no match for the preceding atom. |
4444 | 3502 * Surrounds the preceding atom with START_INVISIBLE and |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
3503 * END_INVISIBLE, similarly to MOPEN. */ |
4444 | 3504 |
3505 if (nfa_calc_size == TRUE) | |
3506 { | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3507 nstate += pattern ? 4 : 2; |
4444 | 3508 break; |
3509 } | |
3510 e = POP(); | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3511 s1 = alloc_state(end_state, NULL, NULL); |
4444 | 3512 if (s1 == NULL) |
4484 | 3513 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3514 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3515 s = alloc_state(start_state, e.start, s1); |
4444 | 3516 if (s == NULL) |
4484 | 3517 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3518 if (pattern) |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3519 { |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3520 /* NFA_ZEND -> NFA_END_PATTERN -> NFA_SKIP -> what follows. */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3521 skip = alloc_state(NFA_SKIP, NULL, NULL); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3522 zend = alloc_state(NFA_ZEND, s1, NULL); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3523 s1->out= skip; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3524 patch(e.out, zend); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3525 PUSH(frag(s, list1(&skip->out))); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3526 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3527 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3528 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3529 patch(e.out, s1); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3530 PUSH(frag(s, list1(&s1->out))); |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3531 if (before) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3532 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3533 if (n <= 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3534 /* See if we can guess the maximum width, it avoids a |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3535 * lot of pointless tries. */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3536 n = nfa_max_width(e.start, 0); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3537 s->val = n; /* store the count */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3538 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3539 } |
4444 | 3540 break; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3541 } |
4444 | 3542 |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3543 #ifdef FEAT_MBYTE |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3544 case NFA_COMPOSING: /* char with composing char */ |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3545 #if 0 |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3546 /* TODO */ |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3547 if (regflags & RF_ICOMBINE) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3548 { |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
3549 /* use the base character only */ |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3550 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3551 #endif |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3552 /* FALLTHROUGH */ |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3553 #endif |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3554 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3555 case NFA_MOPEN: /* \( \) Submatch */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3556 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3557 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3558 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3559 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3560 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3561 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3562 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3563 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3564 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3565 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3566 case NFA_ZOPEN: /* \z( \) Submatch */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3567 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3568 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3569 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3570 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3571 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3572 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3573 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3574 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3575 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3576 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3577 case NFA_NOPEN: /* \%( \) "Invisible Submatch" */ |
4444 | 3578 if (nfa_calc_size == TRUE) |
3579 { | |
3580 nstate += 2; | |
3581 break; | |
3582 } | |
3583 | |
3584 mopen = *p; | |
3585 switch (*p) | |
3586 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3587 case NFA_NOPEN: mclose = NFA_NCLOSE; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3588 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3589 case NFA_ZOPEN: mclose = NFA_ZCLOSE; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3590 case NFA_ZOPEN1: mclose = NFA_ZCLOSE1; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3591 case NFA_ZOPEN2: mclose = NFA_ZCLOSE2; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3592 case NFA_ZOPEN3: mclose = NFA_ZCLOSE3; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3593 case NFA_ZOPEN4: mclose = NFA_ZCLOSE4; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3594 case NFA_ZOPEN5: mclose = NFA_ZCLOSE5; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3595 case NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3596 case NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3597 case NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3598 case NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3599 #endif |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3600 #ifdef FEAT_MBYTE |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3601 case NFA_COMPOSING: mclose = NFA_END_COMPOSING; break; |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3602 #endif |
4444 | 3603 default: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3604 /* NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9 */ |
4444 | 3605 mclose = *p + NSUBEXP; |
3606 break; | |
3607 } | |
3608 | |
3609 /* Allow "NFA_MOPEN" as a valid postfix representation for | |
3610 * the empty regexp "". In this case, the NFA will be | |
3611 * NFA_MOPEN -> NFA_MCLOSE. Note that this also allows | |
3612 * empty groups of parenthesis, and empty mbyte chars */ | |
3613 if (stackp == stack) | |
3614 { | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3615 s = alloc_state(mopen, NULL, NULL); |
4444 | 3616 if (s == NULL) |
4484 | 3617 goto theend; |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3618 s1 = alloc_state(mclose, NULL, NULL); |
4444 | 3619 if (s1 == NULL) |
4484 | 3620 goto theend; |
4444 | 3621 patch(list1(&s->out), s1); |
3622 PUSH(frag(s, list1(&s1->out))); | |
3623 break; | |
3624 } | |
3625 | |
3626 /* At least one node was emitted before NFA_MOPEN, so | |
3627 * at least one node will be between NFA_MOPEN and NFA_MCLOSE */ | |
3628 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3629 s = alloc_state(mopen, e.start, NULL); /* `(' */ |
4444 | 3630 if (s == NULL) |
4484 | 3631 goto theend; |
4444 | 3632 |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3633 s1 = alloc_state(mclose, NULL, NULL); /* `)' */ |
4444 | 3634 if (s1 == NULL) |
4484 | 3635 goto theend; |
4444 | 3636 patch(e.out, s1); |
3637 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3638 #ifdef FEAT_MBYTE |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3639 if (mopen == NFA_COMPOSING) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3640 /* COMPOSING->out1 = END_COMPOSING */ |
4444 | 3641 patch(list1(&s->out1), s1); |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3642 #endif |
4444 | 3643 |
3644 PUSH(frag(s, list1(&s1->out))); | |
3645 break; | |
3646 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3647 case NFA_BACKREF1: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3648 case NFA_BACKREF2: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3649 case NFA_BACKREF3: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3650 case NFA_BACKREF4: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3651 case NFA_BACKREF5: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3652 case NFA_BACKREF6: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3653 case NFA_BACKREF7: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3654 case NFA_BACKREF8: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3655 case NFA_BACKREF9: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3656 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3657 case NFA_ZREF1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3658 case NFA_ZREF2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3659 case NFA_ZREF3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3660 case NFA_ZREF4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3661 case NFA_ZREF5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3662 case NFA_ZREF6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3663 case NFA_ZREF7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3664 case NFA_ZREF8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3665 case NFA_ZREF9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3666 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3667 if (nfa_calc_size == TRUE) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3668 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3669 nstate += 2; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3670 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3671 } |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3672 s = alloc_state(*p, NULL, NULL); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3673 if (s == NULL) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3674 goto theend; |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3675 s1 = alloc_state(NFA_SKIP, NULL, NULL); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3676 if (s1 == NULL) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3677 goto theend; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3678 patch(list1(&s->out), s1); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3679 PUSH(frag(s, list1(&s1->out))); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3680 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3681 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3682 case NFA_LNUM: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3683 case NFA_LNUM_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3684 case NFA_LNUM_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3685 case NFA_VCOL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3686 case NFA_VCOL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3687 case NFA_VCOL_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3688 case NFA_COL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3689 case NFA_COL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3690 case NFA_COL_LT: |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3691 case NFA_MARK: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3692 case NFA_MARK_GT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3693 case NFA_MARK_LT: |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3694 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3695 int n = *++p; /* lnum, col or mark name */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3696 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3697 if (nfa_calc_size == TRUE) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3698 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3699 nstate += 1; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3700 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3701 } |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3702 s = alloc_state(p[-1], NULL, NULL); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3703 if (s == NULL) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3704 goto theend; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3705 s->val = n; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3706 PUSH(frag(s, list1(&s->out))); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3707 break; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3708 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3709 |
4444 | 3710 case NFA_ZSTART: |
3711 case NFA_ZEND: | |
3712 default: | |
3713 /* Operands */ | |
3714 if (nfa_calc_size == TRUE) | |
3715 { | |
4458 | 3716 nstate++; |
4444 | 3717 break; |
3718 } | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3719 s = alloc_state(*p, NULL, NULL); |
4444 | 3720 if (s == NULL) |
4484 | 3721 goto theend; |
4444 | 3722 PUSH(frag(s, list1(&s->out))); |
3723 break; | |
3724 | |
3725 } /* switch(*p) */ | |
3726 | |
3727 } /* for(p = postfix; *p; ++p) */ | |
3728 | |
3729 if (nfa_calc_size == TRUE) | |
3730 { | |
4458 | 3731 nstate++; |
4484 | 3732 goto theend; /* Return value when counting size is ignored anyway */ |
4444 | 3733 } |
3734 | |
3735 e = POP(); | |
3736 if (stackp != stack) | |
6747 | 3737 { |
3738 vim_free(stack); | |
4444 | 3739 EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA), too many states left on stack")); |
6747 | 3740 } |
4444 | 3741 |
3742 if (istate >= nstate) | |
6747 | 3743 { |
3744 vim_free(stack); | |
4444 | 3745 EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA ")); |
6747 | 3746 } |
4444 | 3747 |
3748 matchstate = &state_ptr[istate++]; /* the match state */ | |
3749 matchstate->c = NFA_MATCH; | |
3750 matchstate->out = matchstate->out1 = NULL; | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3751 matchstate->id = 0; |
4444 | 3752 |
3753 patch(e.out, matchstate); | |
4484 | 3754 ret = e.start; |
3755 | |
3756 theend: | |
3757 vim_free(stack); | |
3758 return ret; | |
4444 | 3759 |
3760 #undef POP1 | |
3761 #undef PUSH1 | |
3762 #undef POP2 | |
3763 #undef PUSH2 | |
3764 #undef POP | |
3765 #undef PUSH | |
3766 } | |
3767 | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3768 /* |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3769 * 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
|
3770 */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3771 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3772 nfa_postprocess(nfa_regprog_T *prog) |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3773 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3774 int i; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3775 int c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3776 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3777 for (i = 0; i < prog->nstate; ++i) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3778 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3779 c = prog->state[i].c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3780 if (c == NFA_START_INVISIBLE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3781 || c == NFA_START_INVISIBLE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3782 || c == NFA_START_INVISIBLE_BEFORE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3783 || c == NFA_START_INVISIBLE_BEFORE_NEG) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3784 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3785 int directly; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3786 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3787 /* Do it directly when what follows is possibly the end of the |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3788 * match. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3789 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
|
3790 directly = TRUE; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3791 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3792 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3793 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
|
3794 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
|
3795 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3796 /* Postpone when the invisible match is expensive or has a |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3797 * lower chance of failing. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3798 if (c == NFA_START_INVISIBLE_BEFORE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3799 || c == NFA_START_INVISIBLE_BEFORE_NEG) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3800 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3801 /* "before" matches are very expensive when |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3802 * unbounded, always prefer what follows then, |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3803 * unless what follows will always match. |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3804 * Otherwise strongly prefer what follows. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3805 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
|
3806 directly = FALSE; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3807 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3808 directly = ch_follows * 10 < ch_invisible; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3809 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3810 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3811 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3812 /* normal invisible, first do the one with the |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3813 * highest failure chance */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3814 directly = ch_follows < ch_invisible; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3815 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3816 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3817 if (directly) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3818 /* switch to the _FIRST state */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3819 ++prog->state[i].c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3820 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3821 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3822 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3823 |
4444 | 3824 /**************************************************************** |
3825 * NFA execution code. | |
3826 ****************************************************************/ | |
3827 | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3828 typedef struct |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3829 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3830 int in_use; /* number of subexpr with useful info */ |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3831 |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3832 /* 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
|
3833 union |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3834 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3835 struct multipos |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3836 { |
6547 | 3837 linenr_T start_lnum; |
3838 linenr_T end_lnum; | |
3839 colnr_T start_col; | |
3840 colnr_T end_col; | |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3841 } multi[NSUBEXP]; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3842 struct linepos |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3843 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3844 char_u *start; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3845 char_u *end; |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3846 } line[NSUBEXP]; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3847 } list; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3848 } regsub_T; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3849 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3850 typedef struct |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3851 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3852 regsub_T norm; /* \( .. \) matches */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3853 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3854 regsub_T synt; /* \z( .. \) matches */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3855 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3856 } regsubs_T; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3857 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3858 /* nfa_pim_T stores a Postponed Invisible Match. */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3859 typedef struct nfa_pim_S nfa_pim_T; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3860 struct nfa_pim_S |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3861 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3862 int result; /* NFA_PIM_*, see below */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3863 nfa_state_T *state; /* the invisible match start state */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3864 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
|
3865 union |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3866 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3867 lpos_T pos; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3868 char_u *ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3869 } end; /* where the match must end */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3870 }; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3871 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3872 /* Values for done in nfa_pim_T. */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3873 #define NFA_PIM_UNUSED 0 /* pim not used */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3874 #define NFA_PIM_TODO 1 /* pim not done yet */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3875 #define NFA_PIM_MATCH 2 /* pim executed, matches */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3876 #define NFA_PIM_NOMATCH 3 /* pim executed, no match */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3877 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3878 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3879 /* 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
|
3880 typedef struct |
4444 | 3881 { |
3882 nfa_state_T *state; | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3883 int count; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3884 nfa_pim_T pim; /* if pim.result != NFA_PIM_UNUSED: postponed |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3885 * invisible match */ |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3886 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
|
3887 } nfa_thread_T; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3888 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3889 /* nfa_list_T contains the alternative NFA execution states. */ |
4444 | 3890 typedef struct |
3891 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3892 nfa_thread_T *t; /* allocated array of states */ |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3893 int n; /* nr of states currently in "t" */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3894 int len; /* max nr of states in "t" */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3895 int id; /* ID of the list */ |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
3896 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
|
3897 } nfa_list_T; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3898 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3899 #ifdef ENABLE_LOG |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3900 static void log_subsexpr(regsubs_T *subs); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3901 static void log_subexpr(regsub_T *sub); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3902 static char *pim_info(nfa_pim_T *pim); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3903 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3904 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3905 log_subsexpr(regsubs_T *subs) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3906 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3907 log_subexpr(&subs->norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3908 # ifdef FEAT_SYN_HL |
4770
b20dbf3a5370
updated for version 7.3.1132
Bram Moolenaar <bram@vim.org>
parents:
4768
diff
changeset
|
3909 if (nfa_has_zsubexpr) |
b20dbf3a5370
updated for version 7.3.1132
Bram Moolenaar <bram@vim.org>
parents:
4768
diff
changeset
|
3910 log_subexpr(&subs->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3911 # endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3912 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3913 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3914 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3915 log_subexpr(regsub_T *sub) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3916 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3917 int j; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3918 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3919 for (j = 0; j < sub->in_use; j++) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3920 if (REG_MULTI) |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3921 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
|
3922 j, |
6547 | 3923 sub->list.multi[j].start_col, |
3924 (int)sub->list.multi[j].start_lnum, | |
3925 sub->list.multi[j].end_col, | |
3926 (int)sub->list.multi[j].end_lnum); | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3927 else |
4746
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3928 { |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3929 char *s = (char *)sub->list.line[j].start; |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3930 char *e = (char *)sub->list.line[j].end; |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3931 |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3932 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
|
3933 j, |
4746
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3934 s == NULL ? "NULL" : s, |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3935 e == NULL ? "NULL" : e); |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3936 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3937 } |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3938 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3939 static char * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3940 pim_info(nfa_pim_T *pim) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3941 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3942 static char buf[30]; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3943 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3944 if (pim == NULL || pim->result == NFA_PIM_UNUSED) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3945 buf[0] = NUL; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3946 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3947 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3948 sprintf(buf, " PIM col %d", REG_MULTI ? (int)pim->end.pos.col |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3949 : (int)(pim->end.ptr - reginput)); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3950 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3951 return buf; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3952 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3953 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3954 #endif |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3955 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3956 /* Used during execution: whether a match has been found. */ |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3957 static int nfa_match; |
6573 | 3958 #ifdef FEAT_RELTIME |
3959 static proftime_T *nfa_time_limit; | |
3960 static int nfa_time_count; | |
3961 #endif | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3962 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3963 static void copy_pim(nfa_pim_T *to, nfa_pim_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3964 static void clear_sub(regsub_T *sub); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3965 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
|
3966 static void copy_sub_off(regsub_T *to, regsub_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3967 static void copy_ze_off(regsub_T *to, regsub_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3968 static int sub_equal(regsub_T *sub1, regsub_T *sub2); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3969 static int match_backref(regsub_T *sub, int subidx, int *bytelen); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3970 static int has_state_with_pos(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3971 static int pim_equal(nfa_pim_T *one, nfa_pim_T *two); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3972 static int state_in_list(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3973 static regsubs_T *addstate(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs_arg, nfa_pim_T *pim, int off); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3974 static void addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int *ip); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3975 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3976 /* |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3977 * 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
|
3978 */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3979 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3980 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
|
3981 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3982 to->result = from->result; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3983 to->state = from->state; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3984 copy_sub(&to->subs.norm, &from->subs.norm); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3985 #ifdef FEAT_SYN_HL |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3986 if (nfa_has_zsubexpr) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3987 copy_sub(&to->subs.synt, &from->subs.synt); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3988 #endif |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3989 to->end = from->end; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3990 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3991 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3992 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3993 clear_sub(regsub_T *sub) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3994 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3995 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3996 /* Use 0xff to set lnum to -1 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3997 vim_memset(sub->list.multi, 0xff, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3998 sizeof(struct multipos) * nfa_nsubexpr); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3999 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4000 vim_memset(sub->list.line, 0, sizeof(struct linepos) * nfa_nsubexpr); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4001 sub->in_use = 0; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4002 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4003 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4004 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4005 * Copy the submatches from "from" to "to". |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4006 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4007 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4008 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
|
4009 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4010 to->in_use = from->in_use; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4011 if (from->in_use > 0) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4012 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4013 /* Copy the match start and end positions. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4014 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4015 mch_memmove(&to->list.multi[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4016 &from->list.multi[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4017 sizeof(struct multipos) * from->in_use); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4018 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4019 mch_memmove(&to->list.line[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4020 &from->list.line[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4021 sizeof(struct linepos) * from->in_use); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4022 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4023 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4024 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4025 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4026 * Like copy_sub() but exclude the main match. |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4027 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4028 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4029 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
|
4030 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4031 if (to->in_use < from->in_use) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4032 to->in_use = from->in_use; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4033 if (from->in_use > 1) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4034 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4035 /* Copy the match start and end positions. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4036 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4037 mch_memmove(&to->list.multi[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4038 &from->list.multi[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4039 sizeof(struct multipos) * (from->in_use - 1)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4040 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4041 mch_memmove(&to->list.line[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4042 &from->list.line[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4043 sizeof(struct linepos) * (from->in_use - 1)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4044 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4045 } |
4444 | 4046 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4047 /* |
5372 | 4048 * Like copy_sub() but only do the end of the main match if \ze is present. |
4049 */ | |
4050 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4051 copy_ze_off(regsub_T *to, regsub_T *from) |
5372 | 4052 { |
4053 if (nfa_has_zend) | |
4054 { | |
4055 if (REG_MULTI) | |
4056 { | |
6547 | 4057 if (from->list.multi[0].end_lnum >= 0) |
4058 { | |
4059 to->list.multi[0].end_lnum = from->list.multi[0].end_lnum; | |
4060 to->list.multi[0].end_col = from->list.multi[0].end_col; | |
4061 } | |
5372 | 4062 } |
4063 else | |
4064 { | |
4065 if (from->list.line[0].end != NULL) | |
4066 to->list.line[0].end = from->list.line[0].end; | |
4067 } | |
4068 } | |
4069 } | |
4070 | |
4071 /* | |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4072 * Return TRUE if "sub1" and "sub2" have the same start positions. |
5893 | 4073 * 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
|
4074 */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4075 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4076 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
|
4077 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4078 int i; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4079 int todo; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4080 linenr_T s1; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4081 linenr_T s2; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4082 char_u *sp1; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4083 char_u *sp2; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4084 |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4085 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
|
4086 if (REG_MULTI) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4087 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4088 for (i = 0; i < todo; ++i) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4089 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4090 if (i < sub1->in_use) |
6547 | 4091 s1 = sub1->list.multi[i].start_lnum; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4092 else |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4093 s1 = -1; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4094 if (i < sub2->in_use) |
6547 | 4095 s2 = sub2->list.multi[i].start_lnum; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4096 else |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4097 s2 = -1; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4098 if (s1 != s2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4099 return FALSE; |
6547 | 4100 if (s1 != -1 && sub1->list.multi[i].start_col |
4101 != sub2->list.multi[i].start_col) | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4102 return FALSE; |
5893 | 4103 |
4104 if (nfa_has_backref) | |
4105 { | |
4106 if (i < sub1->in_use) | |
6547 | 4107 s1 = sub1->list.multi[i].end_lnum; |
5893 | 4108 else |
4109 s1 = -1; | |
4110 if (i < sub2->in_use) | |
6547 | 4111 s2 = sub2->list.multi[i].end_lnum; |
5893 | 4112 else |
4113 s2 = -1; | |
4114 if (s1 != s2) | |
4115 return FALSE; | |
6547 | 4116 if (s1 != -1 && sub1->list.multi[i].end_col |
4117 != sub2->list.multi[i].end_col) | |
5893 | 4118 return FALSE; |
4119 } | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4120 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4121 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4122 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4123 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4124 for (i = 0; i < todo; ++i) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4125 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4126 if (i < sub1->in_use) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4127 sp1 = sub1->list.line[i].start; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4128 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4129 sp1 = NULL; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4130 if (i < sub2->in_use) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4131 sp2 = sub2->list.line[i].start; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4132 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4133 sp2 = NULL; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4134 if (sp1 != sp2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4135 return FALSE; |
5893 | 4136 if (nfa_has_backref) |
4137 { | |
4138 if (i < sub1->in_use) | |
4139 sp1 = sub1->list.line[i].end; | |
4140 else | |
4141 sp1 = NULL; | |
4142 if (i < sub2->in_use) | |
4143 sp2 = sub2->list.line[i].end; | |
4144 else | |
4145 sp2 = NULL; | |
4146 if (sp1 != sp2) | |
4147 return FALSE; | |
4148 } | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4149 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4150 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4151 |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4152 return TRUE; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4153 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4154 |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4155 #ifdef ENABLE_LOG |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4156 static void |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4157 report_state(char *action, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4158 regsub_T *sub, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4159 nfa_state_T *state, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4160 int lid, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4161 nfa_pim_T *pim) |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4162 { |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4163 int col; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4164 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4165 if (sub->in_use <= 0) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4166 col = -1; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4167 else if (REG_MULTI) |
6547 | 4168 col = sub->list.multi[0].start_col; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4169 else |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4170 col = (int)(sub->list.line[0].start - regline); |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4171 nfa_set_code(state->c); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4172 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
|
4173 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
|
4174 pim_info(pim)); |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4175 } |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4176 #endif |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4177 |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4178 /* |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4179 * 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
|
4180 * positions as "subs". |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4181 */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4182 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4183 has_state_with_pos( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4184 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4185 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4186 regsubs_T *subs, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4187 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
|
4188 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4189 nfa_thread_T *thread; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4190 int i; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4191 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4192 for (i = 0; i < l->n; ++i) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4193 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4194 thread = &l->t[i]; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4195 if (thread->state->id == state->id |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4196 && sub_equal(&thread->subs.norm, &subs->norm) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4197 #ifdef FEAT_SYN_HL |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4198 && (!nfa_has_zsubexpr |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4199 || sub_equal(&thread->subs.synt, &subs->synt)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4200 #endif |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4201 && pim_equal(&thread->pim, pim)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4202 return TRUE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4203 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4204 return FALSE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4205 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4206 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4207 /* |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4208 * 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
|
4209 * set. |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4210 */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4211 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4212 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
|
4213 { |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4214 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
|
4215 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
|
4216 |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4217 if (one_unused) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4218 /* one is unused: equal when two is also unused */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4219 return two_unused; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4220 if (two_unused) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4221 /* one is used and two is not: not equal */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4222 return FALSE; |
5298 | 4223 /* compare the state id */ |
4224 if (one->state->id != two->state->id) | |
4225 return FALSE; | |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4226 /* compare the position */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4227 if (REG_MULTI) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4228 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
|
4229 && one->end.pos.col == two->end.pos.col; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4230 return one->end.ptr == two->end.ptr; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4231 } |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4232 |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4233 /* |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4234 * 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
|
4235 */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4236 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4237 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
|
4238 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4239 nfa_state_T *state = startstate; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4240 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4241 /* avoid too much recursion */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4242 if (depth > 10) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4243 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4244 |
5184
c6dd0c545e5c
updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents:
5074
diff
changeset
|
4245 while (state != NULL) |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4246 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4247 switch (state->c) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4248 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4249 case NFA_MATCH: |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4250 case NFA_MCLOSE: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4251 case NFA_END_INVISIBLE: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4252 case NFA_END_INVISIBLE_NEG: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4253 case NFA_END_PATTERN: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4254 return TRUE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4255 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4256 case NFA_SPLIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4257 return match_follows(state->out, depth + 1) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4258 || match_follows(state->out1, depth + 1); |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4259 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4260 case NFA_START_INVISIBLE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4261 case NFA_START_INVISIBLE_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4262 case NFA_START_INVISIBLE_BEFORE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4263 case NFA_START_INVISIBLE_BEFORE_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4264 case NFA_START_INVISIBLE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4265 case NFA_START_INVISIBLE_NEG_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4266 case NFA_START_INVISIBLE_BEFORE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4267 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4268 case NFA_COMPOSING: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4269 /* skip ahead to next state */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4270 state = state->out1->out; |
5184
c6dd0c545e5c
updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents:
5074
diff
changeset
|
4271 continue; |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4272 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4273 case NFA_ANY: |
5901 | 4274 case NFA_ANY_COMPOSING: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4275 case NFA_IDENT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4276 case NFA_SIDENT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4277 case NFA_KWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4278 case NFA_SKWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4279 case NFA_FNAME: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4280 case NFA_SFNAME: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4281 case NFA_PRINT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4282 case NFA_SPRINT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4283 case NFA_WHITE: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4284 case NFA_NWHITE: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4285 case NFA_DIGIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4286 case NFA_NDIGIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4287 case NFA_HEX: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4288 case NFA_NHEX: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4289 case NFA_OCTAL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4290 case NFA_NOCTAL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4291 case NFA_WORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4292 case NFA_NWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4293 case NFA_HEAD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4294 case NFA_NHEAD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4295 case NFA_ALPHA: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4296 case NFA_NALPHA: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4297 case NFA_LOWER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4298 case NFA_NLOWER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4299 case NFA_UPPER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4300 case NFA_NUPPER: |
5296 | 4301 case NFA_LOWER_IC: |
4302 case NFA_NLOWER_IC: | |
4303 case NFA_UPPER_IC: | |
4304 case NFA_NUPPER_IC: | |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4305 case NFA_START_COLL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4306 case NFA_START_NEG_COLL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4307 case NFA_NEWL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4308 /* state will advance input */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4309 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4310 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4311 default: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4312 if (state->c > 0) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4313 /* state will advance input */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4314 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4315 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4316 /* Others: zero-width or possibly zero-width, might still find |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4317 * a match at the same position, keep looking. */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4318 break; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4319 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4320 state = state->out; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4321 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4322 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4323 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4324 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4325 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4326 /* |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4327 * 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
|
4328 */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4329 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4330 state_in_list( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4331 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4332 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4333 regsubs_T *subs) /* pointers to subexpressions */ |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4334 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4335 if (state->lastlist[nfa_ll_index] == l->id) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4336 { |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4337 if (!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
|
4338 return TRUE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4339 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4340 return FALSE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4341 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4342 |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4343 /* |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4344 * 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
|
4345 * Returns "subs_arg", possibly copied into temp_subs. |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4346 */ |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4347 static regsubs_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4348 addstate( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4349 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4350 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4351 regsubs_T *subs_arg, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4352 nfa_pim_T *pim, /* postponed look-behind match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4353 int off) /* byte offset, when -1 go to next line */ |
4444 | 4354 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4355 int subidx; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4356 nfa_thread_T *thread; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4357 lpos_T save_lpos; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4358 int save_in_use; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4359 char_u *save_ptr; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4360 int i; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4361 regsub_T *sub; |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4362 regsubs_T *subs = subs_arg; |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4363 static regsubs_T temp_subs; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4364 #ifdef ENABLE_LOG |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4365 int did_print = FALSE; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4366 #endif |
4444 | 4367 |
4368 switch (state->c) | |
4369 { | |
4370 case NFA_NCLOSE: | |
4371 case NFA_MCLOSE: | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4372 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4373 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4374 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4375 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4376 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4377 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4378 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4379 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4380 case NFA_MCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4381 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4382 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4383 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4384 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4385 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4386 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4387 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4388 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4389 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4390 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4391 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4392 #endif |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4393 case NFA_MOPEN: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
4394 case NFA_ZEND: |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4395 case NFA_SPLIT: |
5370 | 4396 case NFA_EMPTY: |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4397 /* These nodes are not added themselves but their "out" and/or |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4398 * "out1" may be added below. */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4399 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4400 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4401 case NFA_BOL: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4402 case NFA_BOF: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4403 /* "^" won't match past end-of-line, don't bother trying. |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4404 * Except when at the end of the line, or when we are going to the |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4405 * next line for a look-behind match. */ |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4406 if (reginput > regline |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4407 && *reginput != NUL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4408 && (nfa_endp == NULL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4409 || !REG_MULTI |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4410 || reglnum == nfa_endp->se_u.pos.lnum)) |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4411 goto skip_add; |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4412 /* FALLTHROUGH */ |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4413 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4414 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4415 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4416 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4417 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4418 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4419 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4420 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4421 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4422 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4423 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4424 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4425 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4426 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4427 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4428 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4429 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4430 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4431 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4432 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4433 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4434 #endif |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4435 case NFA_NOPEN: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
4436 case NFA_ZSTART: |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4437 /* These nodes need to be added so that we can bail out when it |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4438 * was added to this list before at the same position to avoid an |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4439 * endless loop for "\(\)*" */ |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
4440 |
4444 | 4441 default: |
5502 | 4442 if (state->lastlist[nfa_ll_index] == l->id && state->c != NFA_SKIP) |
4444 | 4443 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4444 /* This state is already in the list, don't add it again, |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4445 * unless it is an MOPEN that is used for a backreference or |
5895 | 4446 * when there is a PIM. For NFA_MATCH check the position, |
4447 * lower position is preferred. */ | |
4448 if (!nfa_has_backref && pim == NULL && !l->has_pim | |
4449 && state->c != NFA_MATCH) | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4450 { |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4451 skip_add: |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4452 #ifdef ENABLE_LOG |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4453 nfa_set_code(state->c); |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4454 fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s\n", |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4455 abs(state->id), l->id, state->c, code); |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4456 #endif |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4457 return subs; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4458 } |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4459 |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4460 /* Do not add the state again when it exists with the same |
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4461 * positions. */ |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4462 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
|
4463 goto skip_add; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4464 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4465 |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4466 /* When there are backreferences or PIMs the number of states may |
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4467 * be (a lot) bigger than anticipated. */ |
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4468 if (l->n == l->len) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4469 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4470 int newlen = l->len * 3 / 2 + 50; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4471 |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4472 if (subs != &temp_subs) |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4473 { |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4474 /* "subs" may point into the current array, need to make a |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4475 * copy before it becomes invalid. */ |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4476 copy_sub(&temp_subs.norm, &subs->norm); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4477 #ifdef FEAT_SYN_HL |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4478 if (nfa_has_zsubexpr) |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4479 copy_sub(&temp_subs.synt, &subs->synt); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4480 #endif |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4481 subs = &temp_subs; |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4482 } |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4483 |
6594 | 4484 /* TODO: check for vim_realloc() returning NULL. */ |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4485 l->t = vim_realloc(l->t, newlen * sizeof(nfa_thread_T)); |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4486 l->len = newlen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4487 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4488 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4489 /* add the state to the list */ |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4490 state->lastlist[nfa_ll_index] = l->id; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4491 thread = &l->t[l->n++]; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4492 thread->state = state; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4493 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4494 thread->pim.result = NFA_PIM_UNUSED; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4495 else |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4496 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4497 copy_pim(&thread->pim, pim); |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4498 l->has_pim = TRUE; |
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4499 } |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4500 copy_sub(&thread->subs.norm, &subs->norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4501 #ifdef FEAT_SYN_HL |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4502 if (nfa_has_zsubexpr) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4503 copy_sub(&thread->subs.synt, &subs->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4504 #endif |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4505 #ifdef ENABLE_LOG |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4506 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
|
4507 did_print = TRUE; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4508 #endif |
4444 | 4509 } |
4510 | |
4511 #ifdef ENABLE_LOG | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4512 if (!did_print) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4513 report_state("Processing", &subs->norm, state, l->id, pim); |
4444 | 4514 #endif |
4515 switch (state->c) | |
4516 { | |
4517 case NFA_MATCH: | |
4518 break; | |
4519 | |
4520 case NFA_SPLIT: | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4521 /* order matters here */ |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4522 subs = addstate(l, state->out, subs, pim, off); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4523 subs = addstate(l, state->out1, subs, pim, off); |
4444 | 4524 break; |
4525 | |
5370 | 4526 case NFA_EMPTY: |
4444 | 4527 case NFA_NOPEN: |
4528 case NFA_NCLOSE: | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4529 subs = addstate(l, state->out, subs, pim, off); |
4444 | 4530 break; |
4531 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4532 case NFA_MOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4533 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4534 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4535 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4536 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4537 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4538 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4539 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4540 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4541 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4542 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4543 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4544 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4545 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4546 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4547 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4548 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4549 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4550 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4551 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4552 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4553 #endif |
4444 | 4554 case NFA_ZSTART: |
4555 if (state->c == NFA_ZSTART) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4556 { |
4444 | 4557 subidx = 0; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4558 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4559 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4560 #ifdef FEAT_SYN_HL |
5300 | 4561 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
|
4562 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4563 subidx = state->c - NFA_ZOPEN; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4564 sub = &subs->synt; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4565 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4566 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4567 else |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4568 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4569 subidx = state->c - NFA_MOPEN; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4570 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4571 } |
4444 | 4572 |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4573 /* avoid compiler warnings */ |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4574 save_ptr = NULL; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4575 save_lpos.lnum = 0; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4576 save_lpos.col = 0; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4577 |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4578 /* Set the position (with "off" added) in the subexpression. Save |
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4579 * and restore it when it was in use. Otherwise fill any gap. */ |
4444 | 4580 if (REG_MULTI) |
4581 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4582 if (subidx < sub->in_use) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4583 { |
6547 | 4584 save_lpos.lnum = sub->list.multi[subidx].start_lnum; |
4585 save_lpos.col = sub->list.multi[subidx].start_col; | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4586 save_in_use = -1; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4587 } |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4588 else |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4589 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4590 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4591 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
|
4592 { |
6547 | 4593 sub->list.multi[i].start_lnum = -1; |
4594 sub->list.multi[i].end_lnum = -1; | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4595 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4596 sub->in_use = subidx + 1; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4597 } |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4598 if (off == -1) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4599 { |
6547 | 4600 sub->list.multi[subidx].start_lnum = reglnum + 1; |
4601 sub->list.multi[subidx].start_col = 0; | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4602 } |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4603 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4604 { |
6547 | 4605 sub->list.multi[subidx].start_lnum = reglnum; |
4606 sub->list.multi[subidx].start_col = | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4607 (colnr_T)(reginput - regline + off); |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4608 } |
7152
cbdc02d71a18
commit https://github.com/vim/vim/commit/c2b717ebd6719e722dcb5f10e4c74033a53ff7c7
Christian Brabandt <cb@256bit.org>
parents:
6914
diff
changeset
|
4609 sub->list.multi[subidx].end_lnum = -1; |
4444 | 4610 } |
4611 else | |
4612 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4613 if (subidx < sub->in_use) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4614 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4615 save_ptr = sub->list.line[subidx].start; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4616 save_in_use = -1; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4617 } |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4618 else |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4619 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4620 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4621 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
|
4622 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4623 sub->list.line[i].start = NULL; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4624 sub->list.line[i].end = NULL; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4625 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4626 sub->in_use = subidx + 1; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4627 } |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4628 sub->list.line[subidx].start = reginput + off; |
4444 | 4629 } |
4630 | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4631 subs = addstate(l, state->out, subs, pim, off); |
5300 | 4632 /* "subs" may have changed, need to set "sub" again */ |
4633 #ifdef FEAT_SYN_HL | |
4634 if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) | |
4635 sub = &subs->synt; | |
4636 else | |
4637 #endif | |
4638 sub = &subs->norm; | |
4444 | 4639 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4640 if (save_in_use == -1) |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4641 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4642 if (REG_MULTI) |
6547 | 4643 { |
4644 sub->list.multi[subidx].start_lnum = save_lpos.lnum; | |
4645 sub->list.multi[subidx].start_col = save_lpos.col; | |
4646 } | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4647 else |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4648 sub->list.line[subidx].start = save_ptr; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4649 } |
4444 | 4650 else |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4651 sub->in_use = save_in_use; |
4444 | 4652 break; |
4653 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4654 case NFA_MCLOSE: |
5336 | 4655 if (nfa_has_zend && (REG_MULTI |
6547 | 4656 ? subs->norm.list.multi[0].end_lnum >= 0 |
5336 | 4657 : subs->norm.list.line[0].end != NULL)) |
4444 | 4658 { |
5336 | 4659 /* Do not overwrite the position set by \ze. */ |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4660 subs = addstate(l, state->out, subs, pim, off); |
4444 | 4661 break; |
4662 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4663 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4664 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4665 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4666 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4667 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4668 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4669 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4670 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4671 case NFA_MCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4672 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4673 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4674 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4675 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4676 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4677 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4678 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4679 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4680 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4681 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4682 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4683 #endif |
4444 | 4684 case NFA_ZEND: |
4685 if (state->c == NFA_ZEND) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4686 { |
4444 | 4687 subidx = 0; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4688 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4689 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4690 #ifdef FEAT_SYN_HL |
5300 | 4691 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
|
4692 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4693 subidx = state->c - NFA_ZCLOSE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4694 sub = &subs->synt; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4695 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4696 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4697 else |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4698 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4699 subidx = state->c - NFA_MCLOSE; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4700 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4701 } |
4444 | 4702 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4703 /* We don't fill in gaps here, there must have been an MOPEN that |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4704 * has done that. */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4705 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4706 if (sub->in_use <= subidx) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4707 sub->in_use = subidx + 1; |
4444 | 4708 if (REG_MULTI) |
4709 { | |
6547 | 4710 save_lpos.lnum = sub->list.multi[subidx].end_lnum; |
4711 save_lpos.col = sub->list.multi[subidx].end_col; | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4712 if (off == -1) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4713 { |
6547 | 4714 sub->list.multi[subidx].end_lnum = reglnum + 1; |
4715 sub->list.multi[subidx].end_col = 0; | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4716 } |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4717 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4718 { |
6547 | 4719 sub->list.multi[subidx].end_lnum = reglnum; |
4720 sub->list.multi[subidx].end_col = | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4721 (colnr_T)(reginput - regline + off); |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4722 } |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4723 /* avoid compiler warnings */ |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4724 save_ptr = NULL; |
4444 | 4725 } |
4726 else | |
4727 { | |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4728 save_ptr = sub->list.line[subidx].end; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4729 sub->list.line[subidx].end = reginput + off; |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4730 /* avoid compiler warnings */ |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4731 save_lpos.lnum = 0; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4732 save_lpos.col = 0; |
4444 | 4733 } |
4734 | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4735 subs = addstate(l, state->out, subs, pim, off); |
5300 | 4736 /* "subs" may have changed, need to set "sub" again */ |
4737 #ifdef FEAT_SYN_HL | |
4738 if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) | |
4739 sub = &subs->synt; | |
4740 else | |
4741 #endif | |
4742 sub = &subs->norm; | |
4444 | 4743 |
4744 if (REG_MULTI) | |
6547 | 4745 { |
4746 sub->list.multi[subidx].end_lnum = save_lpos.lnum; | |
4747 sub->list.multi[subidx].end_col = save_lpos.col; | |
4748 } | |
4444 | 4749 else |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4750 sub->list.line[subidx].end = save_ptr; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4751 sub->in_use = save_in_use; |
4444 | 4752 break; |
4753 } | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4754 return subs; |
4444 | 4755 } |
4756 | |
4757 /* | |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4758 * 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
|
4759 * 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
|
4760 * 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
|
4761 * matters for alternatives. |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4762 */ |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4763 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4764 addstate_here( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4765 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4766 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4767 regsubs_T *subs, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4768 nfa_pim_T *pim, /* postponed look-behind match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4769 int *ip) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4770 { |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4771 int tlen = l->n; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4772 int count; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4773 int listidx = *ip; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4774 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4775 /* first add the state(s) at the end, so that we know how many there are */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4776 addstate(l, state, subs, pim, 0); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4777 |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4778 /* 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
|
4779 if (listidx + 1 == tlen) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4780 return; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4781 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4782 /* re-order to put the new state at the current position */ |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4783 count = l->n - tlen; |
4924
6ae32a64e153
updated for version 7.3.1207
Bram Moolenaar <bram@vim.org>
parents:
4897
diff
changeset
|
4784 if (count == 0) |
6ae32a64e153
updated for version 7.3.1207
Bram Moolenaar <bram@vim.org>
parents:
4897
diff
changeset
|
4785 return; /* no state got added */ |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4786 if (count == 1) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4787 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4788 /* overwrite the current state */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4789 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
|
4790 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4791 else if (count > 1) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4792 { |
5058
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4793 if (l->n + count - 1 >= l->len) |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4794 { |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4795 /* not enough space to move the new states, reallocate the list |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4796 * and move the states to the right position */ |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4797 nfa_thread_T *newl; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4798 |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4799 l->len = l->len * 3 / 2 + 50; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4800 newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4801 if (newl == NULL) |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4802 return; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4803 mch_memmove(&(newl[0]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4804 &(l->t[0]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4805 sizeof(nfa_thread_T) * listidx); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4806 mch_memmove(&(newl[listidx]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4807 &(l->t[l->n - count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4808 sizeof(nfa_thread_T) * count); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4809 mch_memmove(&(newl[listidx + count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4810 &(l->t[listidx + 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4811 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
|
4812 vim_free(l->t); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4813 l->t = newl; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4814 } |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4815 else |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4816 { |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4817 /* make space for new states, then move them from the |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4818 * end to the current position */ |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4819 mch_memmove(&(l->t[listidx + count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4820 &(l->t[listidx + 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4821 sizeof(nfa_thread_T) * (l->n - listidx - 1)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4822 mch_memmove(&(l->t[listidx]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4823 &(l->t[l->n - 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4824 sizeof(nfa_thread_T) * count); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4825 } |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4826 } |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4827 --l->n; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4828 *ip = listidx - 1; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4829 } |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4830 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4831 /* |
4444 | 4832 * Check character class "class" against current character c. |
4833 */ | |
4834 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4835 check_char_class(int class, int c) |
4444 | 4836 { |
4837 switch (class) | |
4838 { | |
4839 case NFA_CLASS_ALNUM: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
4840 if (c >= 1 && c < 128 && isalnum(c)) |
4444 | 4841 return OK; |
4842 break; | |
4843 case NFA_CLASS_ALPHA: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
4844 if (c >= 1 && c < 128 && isalpha(c)) |
4444 | 4845 return OK; |
4846 break; | |
4847 case NFA_CLASS_BLANK: | |
4848 if (c == ' ' || c == '\t') | |
4849 return OK; | |
4850 break; | |
4851 case NFA_CLASS_CNTRL: | |
4464 | 4852 if (c >= 1 && c <= 255 && iscntrl(c)) |
4444 | 4853 return OK; |
4854 break; | |
4855 case NFA_CLASS_DIGIT: | |
4856 if (VIM_ISDIGIT(c)) | |
4857 return OK; | |
4858 break; | |
4859 case NFA_CLASS_GRAPH: | |
4464 | 4860 if (c >= 1 && c <= 255 && isgraph(c)) |
4444 | 4861 return OK; |
4862 break; | |
4863 case NFA_CLASS_LOWER: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
4864 if (MB_ISLOWER(c) && c != 170 && c != 186) |
4444 | 4865 return OK; |
4866 break; | |
4867 case NFA_CLASS_PRINT: | |
4868 if (vim_isprintc(c)) | |
4869 return OK; | |
4870 break; | |
4871 case NFA_CLASS_PUNCT: | |
9015
42b228c8701b
commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents:
8989
diff
changeset
|
4872 if (c >= 1 && c < 128 && ispunct(c)) |
4444 | 4873 return OK; |
4874 break; | |
4875 case NFA_CLASS_SPACE: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
4876 if ((c >= 9 && c <= 13) || (c == ' ')) |
4444 | 4877 return OK; |
4878 break; | |
4879 case NFA_CLASS_UPPER: | |
4880 if (MB_ISUPPER(c)) | |
4881 return OK; | |
4882 break; | |
4883 case NFA_CLASS_XDIGIT: | |
4884 if (vim_isxdigit(c)) | |
4885 return OK; | |
4886 break; | |
4887 case NFA_CLASS_TAB: | |
4888 if (c == '\t') | |
4889 return OK; | |
4890 break; | |
4891 case NFA_CLASS_RETURN: | |
4892 if (c == '\r') | |
4893 return OK; | |
4894 break; | |
4895 case NFA_CLASS_BACKSPACE: | |
4896 if (c == '\b') | |
4897 return OK; | |
4898 break; | |
4899 case NFA_CLASS_ESCAPE: | |
4900 if (c == '\033') | |
4901 return OK; | |
4902 break; | |
4903 | |
4904 default: | |
4905 /* should not be here :P */ | |
5511 | 4906 EMSGN(_(e_ill_char_class), class); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
4907 return FAIL; |
4444 | 4908 } |
4909 return FAIL; | |
4910 } | |
4911 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4912 /* |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4913 * Check for a match with subexpression "subidx". |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4914 * Return TRUE if it matches. |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4915 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4916 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4917 match_backref( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4918 regsub_T *sub, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4919 int subidx, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4920 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
|
4921 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4922 int len; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4923 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4924 if (sub->in_use <= subidx) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4925 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4926 retempty: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4927 /* backref was not set, match an empty string */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4928 *bytelen = 0; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4929 return TRUE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4930 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4931 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4932 if (REG_MULTI) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4933 { |
6547 | 4934 if (sub->list.multi[subidx].start_lnum < 0 |
4935 || sub->list.multi[subidx].end_lnum < 0) | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4936 goto retempty; |
6547 | 4937 if (sub->list.multi[subidx].start_lnum == reglnum |
4938 && sub->list.multi[subidx].end_lnum == reglnum) | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4939 { |
6547 | 4940 len = sub->list.multi[subidx].end_col |
4941 - sub->list.multi[subidx].start_col; | |
4942 if (cstrncmp(regline + sub->list.multi[subidx].start_col, | |
4891
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4943 reginput, &len) == 0) |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4944 { |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4945 *bytelen = len; |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4946 return TRUE; |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4947 } |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4948 } |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4949 else |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4950 { |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4951 if (match_with_backref( |
6547 | 4952 sub->list.multi[subidx].start_lnum, |
4953 sub->list.multi[subidx].start_col, | |
4954 sub->list.multi[subidx].end_lnum, | |
4955 sub->list.multi[subidx].end_col, | |
4891
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4956 bytelen) == RA_MATCH) |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4957 return TRUE; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4958 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4959 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4960 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4961 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4962 if (sub->list.line[subidx].start == NULL |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4963 || sub->list.line[subidx].end == NULL) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4964 goto retempty; |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4965 len = (int)(sub->list.line[subidx].end - sub->list.line[subidx].start); |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4966 if (cstrncmp(sub->list.line[subidx].start, reginput, &len) == 0) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4967 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4968 *bytelen = len; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4969 return TRUE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4970 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4971 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4972 return FALSE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4973 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4974 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4975 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4976 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
4977 static int match_zref(int subidx, int *bytelen); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4978 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4979 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4980 * Check for a match with \z subexpression "subidx". |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4981 * Return TRUE if it matches. |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4982 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4983 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4984 match_zref( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4985 int subidx, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4986 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
|
4987 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4988 int len; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4989 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4990 cleanup_zsubexpr(); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4991 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
|
4992 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4993 /* backref was not set, match an empty string */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4994 *bytelen = 0; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4995 return TRUE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4996 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4997 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4998 len = (int)STRLEN(re_extmatch_in->matches[subidx]); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4999 if (cstrncmp(re_extmatch_in->matches[subidx], reginput, &len) == 0) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5000 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5001 *bytelen = len; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5002 return TRUE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5003 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5004 return FALSE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5005 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5006 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5007 |
4444 | 5008 /* |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5009 * 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
|
5010 * Also reset the IDs to zero. |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5011 * Only used for the recursive value lastlist[1]. |
4444 | 5012 */ |
5013 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5014 nfa_save_listids(nfa_regprog_T *prog, int *list) |
4444 | 5015 { |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5016 int i; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5017 nfa_state_T *p; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5018 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5019 /* Order in the list is reverse, it's a bit faster that way. */ |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5020 p = &prog->state[0]; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5021 for (i = prog->nstate; --i >= 0; ) |
4444 | 5022 { |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5023 list[i] = p->lastlist[1]; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5024 p->lastlist[1] = 0; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5025 ++p; |
4444 | 5026 } |
5027 } | |
5028 | |
5029 /* | |
5030 * Restore list IDs from "list" to all NFA states. | |
5031 */ | |
5032 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5033 nfa_restore_listids(nfa_regprog_T *prog, int *list) |
4444 | 5034 { |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5035 int i; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5036 nfa_state_T *p; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5037 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5038 p = &prog->state[0]; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5039 for (i = prog->nstate; --i >= 0; ) |
4444 | 5040 { |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5041 p->lastlist[1] = list[i]; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5042 ++p; |
4444 | 5043 } |
5044 } | |
5045 | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5046 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5047 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
|
5048 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5049 if (op == 1) return pos > val; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5050 if (op == 2) return pos < val; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5051 return val == pos; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5052 } |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
5053 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5054 static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T *prog, regsubs_T *submatch, regsubs_T *m, int **listids); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5055 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
|
5056 |
4444 | 5057 /* |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5058 * Recursively call nfa_regmatch() |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5059 * "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
|
5060 * position). |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5061 */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5062 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5063 recursive_regmatch( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5064 nfa_state_T *state, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5065 nfa_pim_T *pim, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5066 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5067 regsubs_T *submatch, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5068 regsubs_T *m, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5069 int **listids) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5070 { |
4887
dc78a26f6f64
updated for version 7.3.1189
Bram Moolenaar <bram@vim.org>
parents:
4879
diff
changeset
|
5071 int save_reginput_col = (int)(reginput - regline); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5072 int save_reglnum = reglnum; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5073 int save_nfa_match = nfa_match; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5074 int save_nfa_listid = nfa_listid; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5075 save_se_T *save_nfa_endp = nfa_endp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5076 save_se_T endpos; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5077 save_se_T *endposp = NULL; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5078 int result; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5079 int need_restore = FALSE; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5080 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5081 if (pim != NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5082 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5083 /* start at the position where the postponed match was */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5084 if (REG_MULTI) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5085 reginput = regline + pim->end.pos.col; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5086 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5087 reginput = pim->end.ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5088 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5089 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5090 if (state->c == NFA_START_INVISIBLE_BEFORE |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5091 || state->c == NFA_START_INVISIBLE_BEFORE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5092 || state->c == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5093 || 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
|
5094 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5095 /* The recursive match must end at the current position. When "pim" is |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5096 * not NULL it specifies the current position. */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5097 endposp = &endpos; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5098 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5099 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5100 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5101 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5102 endpos.se_u.pos.col = (int)(reginput - regline); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5103 endpos.se_u.pos.lnum = reglnum; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5104 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5105 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5106 endpos.se_u.pos = pim->end.pos; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5107 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5108 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5109 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5110 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5111 endpos.se_u.ptr = reginput; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5112 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5113 endpos.se_u.ptr = pim->end.ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5114 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5115 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5116 /* Go back the specified number of bytes, or as far as the |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5117 * start of the previous line, to try matching "\@<=" or |
5188
fa76be660fa9
updated for version 7.4a.020
Bram Moolenaar <bram@vim.org>
parents:
5184
diff
changeset
|
5118 * not matching "\@<!". This is very inefficient, limit the number of |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
5119 * bytes if possible. */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5120 if (state->val <= 0) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5121 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5122 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5123 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5124 regline = reg_getline(--reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5125 if (regline == NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5126 /* can't go before the first line */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5127 regline = reg_getline(++reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5128 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5129 reginput = regline; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5130 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5131 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5132 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5133 if (REG_MULTI && (int)(reginput - regline) < state->val) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5134 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5135 /* Not enough bytes in this line, go to end of |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5136 * previous line. */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5137 regline = reg_getline(--reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5138 if (regline == NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5139 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5140 /* can't go before the first line */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5141 regline = reg_getline(++reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5142 reginput = regline; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5143 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5144 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5145 reginput = regline + STRLEN(regline); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5146 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5147 if ((int)(reginput - regline) >= state->val) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5148 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5149 reginput -= state->val; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5150 #ifdef FEAT_MBYTE |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5151 if (has_mbyte) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5152 reginput -= mb_head_off(regline, reginput); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5153 #endif |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5154 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5155 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5156 reginput = regline; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5157 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5158 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5159 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5160 #ifdef ENABLE_LOG |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5161 if (log_fd != stderr) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5162 fclose(log_fd); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5163 log_fd = NULL; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5164 #endif |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5165 /* Have to clear the lastlist field of the NFA nodes, so that |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5166 * nfa_regmatch() and addstate() can run properly after recursion. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5167 if (nfa_ll_index == 1) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5168 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5169 /* Already calling nfa_regmatch() recursively. Save the lastlist[1] |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5170 * values and clear them. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5171 if (*listids == NULL) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5172 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5173 *listids = (int *)lalloc(sizeof(int) * nstate, TRUE); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5174 if (*listids == NULL) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5175 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5176 EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!")); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5177 return 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5178 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5179 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5180 nfa_save_listids(prog, *listids); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5181 need_restore = TRUE; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5182 /* any value of nfa_listid will do */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5183 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5184 else |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5185 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5186 /* First recursive nfa_regmatch() call, switch to the second lastlist |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5187 * entry. Make sure nfa_listid is different from a previous recursive |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5188 * call, because some states may still have this ID. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5189 ++nfa_ll_index; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5190 if (nfa_listid <= nfa_alt_listid) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5191 nfa_listid = nfa_alt_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5192 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5193 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5194 /* Call nfa_regmatch() to check if the current concat matches at this |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5195 * 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
|
5196 nfa_endp = endposp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5197 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
|
5198 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5199 if (need_restore) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5200 nfa_restore_listids(prog, *listids); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5201 else |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5202 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5203 --nfa_ll_index; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5204 nfa_alt_listid = nfa_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5205 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5206 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5207 /* restore position in input text */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5208 reglnum = save_reglnum; |
4877
9e36c6b1ebf4
updated for version 7.3.1184
Bram Moolenaar <bram@vim.org>
parents:
4845
diff
changeset
|
5209 if (REG_MULTI) |
9e36c6b1ebf4
updated for version 7.3.1184
Bram Moolenaar <bram@vim.org>
parents:
4845
diff
changeset
|
5210 regline = reg_getline(reglnum); |
4887
dc78a26f6f64
updated for version 7.3.1189
Bram Moolenaar <bram@vim.org>
parents:
4879
diff
changeset
|
5211 reginput = regline + save_reginput_col; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5212 nfa_match = save_nfa_match; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5213 nfa_endp = save_nfa_endp; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5214 nfa_listid = save_nfa_listid; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5215 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5216 #ifdef ENABLE_LOG |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5217 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5218 if (log_fd != NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5219 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5220 fprintf(log_fd, "****************************\n"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5221 fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5222 fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5223 fprintf(log_fd, "****************************\n"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5224 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5225 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5226 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5227 EMSG(_("Could not open temporary log file for writing, displaying on stderr ... ")); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5228 log_fd = stderr; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5229 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5230 #endif |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5231 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5232 return result; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5233 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5234 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5235 static int skip_to_start(int c, colnr_T *colp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5236 static long find_match_text(colnr_T startcol, int regstart, char_u *match_text); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5237 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5238 /* |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5239 * 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
|
5240 * empty match: 0 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5241 * NFA_ANY: 1 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5242 * specific character: 99 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5243 */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5244 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5245 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
|
5246 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5247 int c = state->c; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5248 int l, r; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5249 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5250 /* detect looping */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5251 if (depth > 4) |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5252 return 1; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5253 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5254 switch (c) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5255 { |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5256 case NFA_SPLIT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5257 if (state->out->c == NFA_SPLIT || state->out1->c == NFA_SPLIT) |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5258 /* avoid recursive stuff */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5259 return 1; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5260 /* two alternatives, use the lowest failure chance */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5261 l = failure_chance(state->out, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5262 r = failure_chance(state->out1, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5263 return l < r ? l : r; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5264 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5265 case NFA_ANY: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5266 /* matches anything, unlikely to fail */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5267 return 1; |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5268 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5269 case NFA_MATCH: |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5270 case NFA_MCLOSE: |
5901 | 5271 case NFA_ANY_COMPOSING: |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5272 /* empty match works always */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5273 return 0; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5274 |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5275 case NFA_START_INVISIBLE: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5276 case NFA_START_INVISIBLE_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5277 case NFA_START_INVISIBLE_NEG: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5278 case NFA_START_INVISIBLE_NEG_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5279 case NFA_START_INVISIBLE_BEFORE: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5280 case NFA_START_INVISIBLE_BEFORE_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5281 case NFA_START_INVISIBLE_BEFORE_NEG: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5282 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5283 case NFA_START_PATTERN: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5284 /* recursive regmatch is expensive, use low failure chance */ |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5285 return 5; |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5286 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5287 case NFA_BOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5288 case NFA_EOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5289 case NFA_BOF: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5290 case NFA_EOF: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5291 case NFA_NEWL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5292 return 99; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5293 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5294 case NFA_BOW: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5295 case NFA_EOW: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5296 return 90; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5297 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5298 case NFA_MOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5299 case NFA_MOPEN1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5300 case NFA_MOPEN2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5301 case NFA_MOPEN3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5302 case NFA_MOPEN4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5303 case NFA_MOPEN5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5304 case NFA_MOPEN6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5305 case NFA_MOPEN7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5306 case NFA_MOPEN8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5307 case NFA_MOPEN9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5308 #ifdef FEAT_SYN_HL |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5309 case NFA_ZOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5310 case NFA_ZOPEN1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5311 case NFA_ZOPEN2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5312 case NFA_ZOPEN3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5313 case NFA_ZOPEN4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5314 case NFA_ZOPEN5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5315 case NFA_ZOPEN6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5316 case NFA_ZOPEN7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5317 case NFA_ZOPEN8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5318 case NFA_ZOPEN9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5319 case NFA_ZCLOSE: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5320 case NFA_ZCLOSE1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5321 case NFA_ZCLOSE2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5322 case NFA_ZCLOSE3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5323 case NFA_ZCLOSE4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5324 case NFA_ZCLOSE5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5325 case NFA_ZCLOSE6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5326 case NFA_ZCLOSE7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5327 case NFA_ZCLOSE8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5328 case NFA_ZCLOSE9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5329 #endif |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5330 case NFA_NOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5331 case NFA_MCLOSE1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5332 case NFA_MCLOSE2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5333 case NFA_MCLOSE3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5334 case NFA_MCLOSE4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5335 case NFA_MCLOSE5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5336 case NFA_MCLOSE6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5337 case NFA_MCLOSE7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5338 case NFA_MCLOSE8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5339 case NFA_MCLOSE9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5340 case NFA_NCLOSE: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5341 return failure_chance(state->out, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5342 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5343 case NFA_BACKREF1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5344 case NFA_BACKREF2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5345 case NFA_BACKREF3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5346 case NFA_BACKREF4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5347 case NFA_BACKREF5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5348 case NFA_BACKREF6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5349 case NFA_BACKREF7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5350 case NFA_BACKREF8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5351 case NFA_BACKREF9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5352 #ifdef FEAT_SYN_HL |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5353 case NFA_ZREF1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5354 case NFA_ZREF2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5355 case NFA_ZREF3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5356 case NFA_ZREF4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5357 case NFA_ZREF5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5358 case NFA_ZREF6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5359 case NFA_ZREF7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5360 case NFA_ZREF8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5361 case NFA_ZREF9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5362 #endif |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5363 /* backreferences don't match in many places */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5364 return 94; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5365 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5366 case NFA_LNUM_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5367 case NFA_LNUM_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5368 case NFA_COL_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5369 case NFA_COL_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5370 case NFA_VCOL_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5371 case NFA_VCOL_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5372 case NFA_MARK_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5373 case NFA_MARK_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5374 case NFA_VISUAL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5375 /* before/after positions don't match very often */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5376 return 85; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5377 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5378 case NFA_LNUM: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5379 return 90; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5380 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5381 case NFA_CURSOR: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5382 case NFA_COL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5383 case NFA_VCOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5384 case NFA_MARK: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5385 /* specific positions rarely match */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5386 return 98; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5387 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5388 case NFA_COMPOSING: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5389 return 95; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5390 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5391 default: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5392 if (c > 0) |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5393 /* character match fails often */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5394 return 95; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5395 } |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5396 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5397 /* something else, includes character classes */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5398 return 50; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5399 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5400 |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5401 /* |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5402 * 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
|
5403 */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5404 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5405 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
|
5406 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5407 char_u *s; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5408 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5409 /* Used often, do some work to avoid call overhead. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5410 if (!ireg_ic |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5411 #ifdef FEAT_MBYTE |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5412 && !has_mbyte |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5413 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5414 ) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5415 s = vim_strbyte(regline + *colp, c); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5416 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5417 s = cstrchr(regline + *colp, c); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5418 if (s == NULL) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5419 return FAIL; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5420 *colp = (int)(s - regline); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5421 return OK; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5422 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5423 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5424 /* |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5425 * Check for a match with match_text. |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
5426 * 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
|
5427 * 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
|
5428 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5429 static long |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5430 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
|
5431 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5432 colnr_T col = startcol; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5433 int c1, c2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5434 int len1, len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5435 int match; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5436 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5437 for (;;) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5438 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5439 match = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5440 len2 = MB_CHAR2LEN(regstart); /* skip regstart */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5441 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
|
5442 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5443 c1 = PTR2CHAR(match_text + len1); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5444 c2 = PTR2CHAR(regline + col + len2); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5445 if (c1 != c2 && (!ireg_ic || MB_TOLOWER(c1) != MB_TOLOWER(c2))) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5446 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5447 match = FALSE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5448 break; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5449 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5450 len2 += MB_CHAR2LEN(c2); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5451 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5452 if (match |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5453 #ifdef FEAT_MBYTE |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5454 /* check that no composing char follows */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5455 && !(enc_utf8 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5456 && utf_iscomposing(PTR2CHAR(regline + col + len2))) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5457 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5458 ) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5459 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5460 cleanup_subexpr(); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5461 if (REG_MULTI) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5462 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5463 reg_startpos[0].lnum = reglnum; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5464 reg_startpos[0].col = col; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5465 reg_endpos[0].lnum = reglnum; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5466 reg_endpos[0].col = col + len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5467 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5468 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5469 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5470 reg_startp[0] = regline + col; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5471 reg_endp[0] = regline + col + len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5472 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5473 return 1L; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5474 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5475 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5476 /* Try finding regstart after the current match. */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5477 col += MB_CHAR2LEN(regstart); /* skip regstart */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5478 if (skip_to_start(regstart, &col) == FAIL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5479 break; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5480 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5481 return 0L; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5482 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5483 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5484 /* |
4444 | 5485 * Main matching routine. |
5486 * | |
5487 * Run NFA to determine whether it matches reginput. | |
5488 * | |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
5489 * 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
|
5490 * |
4444 | 5491 * Return TRUE if there is a match, FALSE otherwise. |
5372 | 5492 * When there is a match "submatch" contains the positions. |
4444 | 5493 * Note: Caller must ensure that: start != NULL. |
5494 */ | |
5495 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5496 nfa_regmatch( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5497 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5498 nfa_state_T *start, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5499 regsubs_T *submatch, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5500 regsubs_T *m) |
4444 | 5501 { |
5502 int result; | |
6545 | 5503 size_t size = 0; |
4444 | 5504 int flag = 0; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5505 int go_to_nextline = FALSE; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5506 nfa_thread_T *t; |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5507 nfa_list_T list[2]; |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5508 int listidx; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5509 nfa_list_T *thislist; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5510 nfa_list_T *nextlist; |
4444 | 5511 int *listids = NULL; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5512 nfa_state_T *add_state; |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5513 int add_here; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5514 int add_count; |
4819
8c4324e6f477
updated for version 7.3.1156
Bram Moolenaar <bram@vim.org>
parents:
4815
diff
changeset
|
5515 int add_off = 0; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5516 int toplevel = start->c == NFA_MOPEN; |
4460 | 5517 #ifdef NFA_REGEXP_DEBUG_LOG |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5518 FILE *debug; |
4444 | 5519 #endif |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5520 |
5310 | 5521 /* Some patterns may take a long time to match, especially when using |
5522 * recursive_regmatch(). Allow interrupting them with CTRL-C. */ | |
5523 fast_breakcheck(); | |
5524 if (got_int) | |
5525 return FALSE; | |
6573 | 5526 #ifdef FEAT_RELTIME |
5527 if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit)) | |
5528 return FALSE; | |
5529 #endif | |
5310 | 5530 |
8989
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5531 #ifdef NFA_REGEXP_DEBUG_LOG |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5532 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
|
5533 if (debug == NULL) |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5534 { |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5535 EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG); |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5536 return FALSE; |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5537 } |
e600e696c0a1
commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents:
8841
diff
changeset
|
5538 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
5539 nfa_match = FALSE; |
4444 | 5540 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
5541 /* Allocate memory for the lists of nodes. */ |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5542 size = (nstate + 1) * sizeof(nfa_thread_T); |
6547 | 5543 |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5544 list[0].t = (nfa_thread_T *)lalloc(size, TRUE); |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
5545 list[0].len = nstate + 1; |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5546 list[1].t = (nfa_thread_T *)lalloc(size, TRUE); |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
5547 list[1].len = nstate + 1; |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5548 if (list[0].t == NULL || list[1].t == NULL) |
4444 | 5549 goto theend; |
5550 | |
5551 #ifdef ENABLE_LOG | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5552 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 5553 if (log_fd != NULL) |
5554 { | |
5555 fprintf(log_fd, "**********************************\n"); | |
5556 nfa_set_code(start->c); | |
5557 fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n", | |
5558 abs(start->id), code); | |
5559 fprintf(log_fd, "**********************************\n"); | |
5560 } | |
5561 else | |
5562 { | |
5563 EMSG(_("Could not open temporary log file for writing, displaying on stderr ... ")); | |
5564 log_fd = stderr; | |
5565 } | |
5566 #endif | |
5567 | |
5568 thislist = &list[0]; | |
5569 thislist->n = 0; | |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5570 thislist->has_pim = FALSE; |
4444 | 5571 nextlist = &list[1]; |
5572 nextlist->n = 0; | |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5573 nextlist->has_pim = FALSE; |
4444 | 5574 #ifdef ENABLE_LOG |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5575 fprintf(log_fd, "(---) STARTSTATE first\n"); |
4444 | 5576 #endif |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5577 thislist->id = nfa_listid + 1; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5578 |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5579 /* Inline optimized code for addstate(thislist, start, m, 0) if we know |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5580 * it's the first MOPEN. */ |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5581 if (toplevel) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5582 { |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5583 if (REG_MULTI) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5584 { |
6547 | 5585 m->norm.list.multi[0].start_lnum = reglnum; |
5586 m->norm.list.multi[0].start_col = (colnr_T)(reginput - regline); | |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5587 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5588 else |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5589 m->norm.list.line[0].start = reginput; |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5590 m->norm.in_use = 1; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5591 addstate(thislist, start->out, m, NULL, 0); |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5592 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5593 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5594 addstate(thislist, start, m, NULL, 0); |
4444 | 5595 |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5596 #define ADD_STATE_IF_MATCH(state) \ |
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5597 if (result) { \ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5598 add_state = state->out; \ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5599 add_off = clen; \ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5600 } |
4444 | 5601 |
5602 /* | |
5603 * Run for each character. | |
5604 */ | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5605 for (;;) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5606 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5607 int curc; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5608 int clen; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5609 |
4444 | 5610 #ifdef FEAT_MBYTE |
5611 if (has_mbyte) | |
5612 { | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5613 curc = (*mb_ptr2char)(reginput); |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5614 clen = (*mb_ptr2len)(reginput); |
4444 | 5615 } |
5616 else | |
5617 #endif | |
5618 { | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5619 curc = *reginput; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5620 clen = 1; |
4444 | 5621 } |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5622 if (curc == NUL) |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5623 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5624 clen = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5625 go_to_nextline = FALSE; |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5626 } |
4444 | 5627 |
5628 /* swap lists */ | |
5629 thislist = &list[flag]; | |
5630 nextlist = &list[flag ^= 1]; | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5631 nextlist->n = 0; /* clear nextlist */ |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5632 nextlist->has_pim = FALSE; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5633 ++nfa_listid; |
6328 | 5634 if (prog->re_engine == AUTOMATIC_ENGINE && nfa_listid >= NFA_MAX_STATES) |
5635 { | |
5636 /* too many states, retry with old engine */ | |
5637 nfa_match = NFA_TOO_EXPENSIVE; | |
5638 goto theend; | |
5639 } | |
5640 | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5641 thislist->id = nfa_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5642 nextlist->id = nfa_listid + 1; |
4444 | 5643 |
5644 #ifdef ENABLE_LOG | |
5645 fprintf(log_fd, "------------------------------------------\n"); | |
5646 fprintf(log_fd, ">>> Reginput is \"%s\"\n", reginput); | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5647 fprintf(log_fd, ">>> Advanced one character ... Current char is %c (code %d) \n", curc, (int)curc); |
4444 | 5648 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
|
5649 { |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5650 int i; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5651 |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5652 for (i = 0; i < thislist->n; i++) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5653 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
|
5654 } |
4444 | 5655 fprintf(log_fd, "\n"); |
5656 #endif | |
5657 | |
4460 | 5658 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 5659 fprintf(debug, "\n-------------------\n"); |
5660 #endif | |
4480 | 5661 /* |
5662 * If the state lists are empty we can stop. | |
5663 */ | |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5664 if (thislist->n == 0) |
4480 | 5665 break; |
4444 | 5666 |
5667 /* compute nextlist */ | |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5668 for (listidx = 0; listidx < thislist->n; ++listidx) |
4444 | 5669 { |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5670 t = &thislist->t[listidx]; |
4444 | 5671 |
4460 | 5672 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 5673 nfa_set_code(t->state->c); |
5674 fprintf(debug, "%s, ", code); | |
5675 #endif | |
5676 #ifdef ENABLE_LOG | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5677 { |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5678 int col; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5679 |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
5680 if (t->subs.norm.in_use <= 0) |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5681 col = -1; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5682 else if (REG_MULTI) |
6547 | 5683 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
|
5684 else |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
5685 col = (int)(t->subs.norm.list.line[0].start - regline); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5686 nfa_set_code(t->state->c); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5687 fprintf(log_fd, "(%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
|
5688 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
|
5689 pim_info(&t->pim)); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5690 } |
4444 | 5691 #endif |
5692 | |
5693 /* | |
5694 * Handle the possible codes of the current state. | |
5695 * The most important is NFA_MATCH. | |
5696 */ | |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5697 add_state = NULL; |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5698 add_here = FALSE; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5699 add_count = 0; |
4444 | 5700 switch (t->state->c) |
5701 { | |
5702 case NFA_MATCH: | |
4567
96c1a7850097
updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents:
4565
diff
changeset
|
5703 { |
5901 | 5704 #ifdef FEAT_MBYTE |
5705 /* If the match ends before a composing characters and | |
5706 * ireg_icombine is not set, that is not really a match. */ | |
5707 if (enc_utf8 && !ireg_icombine && utf_iscomposing(curc)) | |
5708 break; | |
5709 #endif | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
5710 nfa_match = TRUE; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5711 copy_sub(&submatch->norm, &t->subs.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5712 #ifdef FEAT_SYN_HL |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5713 if (nfa_has_zsubexpr) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5714 copy_sub(&submatch->synt, &t->subs.synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5715 #endif |
4444 | 5716 #ifdef ENABLE_LOG |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5717 log_subsexpr(&t->subs); |
4444 | 5718 #endif |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5719 /* Found the left-most longest match, do not look at any other |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5720 * states at this position. When the list of states is going |
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5721 * to be empty quit without advancing, so that "reginput" is |
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5722 * correct. */ |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5723 if (nextlist->n == 0) |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5724 clen = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5725 goto nextchar; |
4567
96c1a7850097
updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents:
4565
diff
changeset
|
5726 } |
4444 | 5727 |
5728 case NFA_END_INVISIBLE: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5729 case NFA_END_INVISIBLE_NEG: |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5730 case NFA_END_PATTERN: |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5731 /* |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5732 * 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
|
5733 * NFA_START_INVISIBLE_BEFORE node. |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5734 * They surround a zero-width group, used with "\@=", "\&", |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5735 * "\@!", "\@<=" and "\@<!". |
4444 | 5736 * If we got here, it means that the current "invisible" group |
5737 * 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
|
5738 * 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
|
5739 * in the position in "nfa_endp". |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5740 * 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
|
5741 */ |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5742 #ifdef ENABLE_LOG |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5743 if (nfa_endp != NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5744 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5745 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5746 fprintf(log_fd, "Current lnum: %d, endp lnum: %d; current col: %d, endp col: %d\n", |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5747 (int)reglnum, |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5748 (int)nfa_endp->se_u.pos.lnum, |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5749 (int)(reginput - regline), |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5750 nfa_endp->se_u.pos.col); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5751 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5752 fprintf(log_fd, "Current col: %d, endp col: %d\n", |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5753 (int)(reginput - regline), |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5754 (int)(nfa_endp->se_u.ptr - reginput)); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5755 } |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5756 #endif |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5757 /* If "nfa_endp" is set it's only a match if it ends at |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5758 * "nfa_endp" */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5759 if (nfa_endp != NULL && (REG_MULTI |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5760 ? (reglnum != nfa_endp->se_u.pos.lnum |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5761 || (int)(reginput - regline) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5762 != nfa_endp->se_u.pos.col) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5763 : reginput != nfa_endp->se_u.ptr)) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5764 break; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5765 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5766 /* do not set submatches for \@! */ |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5767 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
|
5768 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5769 copy_sub(&m->norm, &t->subs.norm); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5770 #ifdef FEAT_SYN_HL |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5771 if (nfa_has_zsubexpr) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5772 copy_sub(&m->synt, &t->subs.synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5773 #endif |
4444 | 5774 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5775 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5776 fprintf(log_fd, "Match found:\n"); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5777 log_subsexpr(m); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5778 #endif |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5779 nfa_match = TRUE; |
5334 | 5780 /* See comment above at "goto nextchar". */ |
5781 if (nextlist->n == 0) | |
5782 clen = 0; | |
5783 goto nextchar; | |
4444 | 5784 |
5785 case NFA_START_INVISIBLE: | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5786 case NFA_START_INVISIBLE_FIRST: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5787 case NFA_START_INVISIBLE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5788 case NFA_START_INVISIBLE_NEG_FIRST: |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5789 case NFA_START_INVISIBLE_BEFORE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5790 case NFA_START_INVISIBLE_BEFORE_FIRST: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5791 case NFA_START_INVISIBLE_BEFORE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5792 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
4444 | 5793 { |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5794 #ifdef ENABLE_LOG |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5795 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
|
5796 failure_chance(t->state->out, 0), |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5797 failure_chance(t->state->out1->out, 0)); |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5798 #endif |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5799 /* Do it directly if there already is a PIM or when |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5800 * nfa_postprocess() detected it will work better. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5801 if (t->pim.result != NFA_PIM_UNUSED |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5802 || t->state->c == NFA_START_INVISIBLE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5803 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5804 || t->state->c == NFA_START_INVISIBLE_BEFORE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5805 || 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
|
5806 { |
5029
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
5807 int in_use = m->norm.in_use; |
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
5808 |
5370 | 5809 /* Copy submatch info for the recursive call, opposite |
5810 * of what happens on success below. */ | |
4997
8a7d3a73adab
updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents:
4958
diff
changeset
|
5811 copy_sub_off(&m->norm, &t->subs.norm); |
5370 | 5812 #ifdef FEAT_SYN_HL |
5813 if (nfa_has_zsubexpr) | |
5814 copy_sub_off(&m->synt, &t->subs.synt); | |
5815 #endif | |
4997
8a7d3a73adab
updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents:
4958
diff
changeset
|
5816 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5817 /* |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5818 * First try matching the invisible match, then what |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5819 * follows. |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5820 */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5821 result = recursive_regmatch(t->state, NULL, prog, |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5822 submatch, m, &listids); |
6328 | 5823 if (result == NFA_TOO_EXPENSIVE) |
5824 { | |
5825 nfa_match = result; | |
5826 goto theend; | |
5827 } | |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5828 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5829 /* for \@! and \@<! it is a match when the result is |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5830 * FALSE */ |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5831 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
|
5832 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5833 || t->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5834 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5835 || t->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5836 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5837 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5838 /* Copy submatch info from the recursive call */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5839 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
|
5840 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5841 if (nfa_has_zsubexpr) |
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5842 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
|
5843 #endif |
5372 | 5844 /* If the pattern has \ze and it matched in the |
5845 * sub pattern, use it. */ | |
5846 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
|
5847 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5848 /* t->state->out1 is the corresponding |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5849 * END_INVISIBLE node; Add its out to the current |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5850 * list (zero-width match). */ |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5851 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5852 add_state = t->state->out1->out; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5853 } |
5029
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
5854 m->norm.in_use = in_use; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5855 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5856 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5857 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5858 nfa_pim_T pim; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5859 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5860 /* |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5861 * 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
|
5862 * 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
|
5863 * 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
|
5864 * about the invisible match. |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5865 */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5866 pim.state = t->state; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5867 pim.result = NFA_PIM_TODO; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5868 pim.subs.norm.in_use = 0; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5869 #ifdef FEAT_SYN_HL |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5870 pim.subs.synt.in_use = 0; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5871 #endif |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5872 if (REG_MULTI) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5873 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5874 pim.end.pos.col = (int)(reginput - regline); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5875 pim.end.pos.lnum = reglnum; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5876 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5877 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5878 pim.end.ptr = reginput; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5879 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5880 /* t->state->out1 is the corresponding END_INVISIBLE |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5881 * node; Add its out to the current list (zero-width |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5882 * match). */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5883 addstate_here(thislist, t->state->out1->out, &t->subs, |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5884 &pim, &listidx); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5885 } |
4444 | 5886 } |
5887 break; | |
5888 | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5889 case NFA_START_PATTERN: |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5890 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5891 nfa_state_T *skip = NULL; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5892 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5893 int skip_lid = 0; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5894 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5895 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5896 /* There is no point in trying to match the pattern if the |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5897 * output state is not going to be added to the list. */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5898 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
|
5899 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5900 skip = t->state->out1->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5901 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5902 skip_lid = nextlist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5903 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5904 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5905 else if (state_in_list(nextlist, |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5906 t->state->out1->out->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5907 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5908 skip = t->state->out1->out->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5909 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5910 skip_lid = nextlist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5911 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5912 } |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5913 else if (state_in_list(thislist, |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5914 t->state->out1->out->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5915 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5916 skip = t->state->out1->out->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5917 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5918 skip_lid = thislist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5919 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5920 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5921 if (skip != NULL) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5922 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5923 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5924 nfa_set_code(skip->c); |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5925 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
|
5926 abs(skip->id), skip_lid, skip->c, code); |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5927 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5928 break; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5929 } |
5370 | 5930 /* Copy submatch info to the recursive call, opposite of what |
5931 * happens afterwards. */ | |
5932 copy_sub_off(&m->norm, &t->subs.norm); | |
5933 #ifdef FEAT_SYN_HL | |
5934 if (nfa_has_zsubexpr) | |
5935 copy_sub_off(&m->synt, &t->subs.synt); | |
5936 #endif | |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5937 |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5938 /* First try matching the pattern. */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5939 result = recursive_regmatch(t->state, NULL, prog, |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5940 submatch, m, &listids); |
6328 | 5941 if (result == NFA_TOO_EXPENSIVE) |
5942 { | |
5943 nfa_match = result; | |
5944 goto theend; | |
5945 } | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5946 if (result) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5947 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5948 int bytelen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5949 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5950 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5951 fprintf(log_fd, "NFA_START_PATTERN matches:\n"); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5952 log_subsexpr(m); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5953 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5954 /* Copy submatch info from the recursive call */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5955 copy_sub_off(&t->subs.norm, &m->norm); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5956 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5957 if (nfa_has_zsubexpr) |
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5958 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
|
5959 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5960 /* Now we need to skip over the matched text and then |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5961 * continue with what follows. */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5962 if (REG_MULTI) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5963 /* TODO: multi-line match */ |
6547 | 5964 bytelen = m->norm.list.multi[0].end_col |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5965 - (int)(reginput - regline); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5966 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5967 bytelen = (int)(m->norm.list.line[0].end - reginput); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5968 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5969 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5970 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
|
5971 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5972 if (bytelen == 0) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5973 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5974 /* empty match, output of corresponding |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5975 * NFA_END_PATTERN/NFA_SKIP to be used at current |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5976 * position */ |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5977 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5978 add_state = t->state->out1->out->out; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5979 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5980 else if (bytelen <= clen) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5981 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5982 /* match current character, output of corresponding |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5983 * NFA_END_PATTERN to be used at next position. */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5984 add_state = t->state->out1->out->out; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5985 add_off = clen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5986 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5987 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5988 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5989 /* skip over the matched characters, set character |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5990 * count in NFA_SKIP */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5991 add_state = t->state->out1->out; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5992 add_off = bytelen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5993 add_count = bytelen - clen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5994 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5995 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5996 break; |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5997 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5998 |
4444 | 5999 case NFA_BOL: |
6000 if (reginput == regline) | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6001 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6002 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6003 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6004 } |
4444 | 6005 break; |
6006 | |
6007 case NFA_EOL: | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6008 if (curc == NUL) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6009 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6010 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6011 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6012 } |
4444 | 6013 break; |
6014 | |
6015 case NFA_BOW: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6016 result = TRUE; |
4444 | 6017 |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6018 if (curc == NUL) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6019 result = FALSE; |
4444 | 6020 #ifdef FEAT_MBYTE |
6021 else if (has_mbyte) | |
6022 { | |
6023 int this_class; | |
6024 | |
6025 /* Get class of current and previous char (if it exists). */ | |
4503 | 6026 this_class = mb_get_class_buf(reginput, reg_buf); |
4444 | 6027 if (this_class <= 1) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6028 result = FALSE; |
4444 | 6029 else if (reg_prev_class() == this_class) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6030 result = FALSE; |
4444 | 6031 } |
6032 #endif | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6033 else if (!vim_iswordc_buf(curc, reg_buf) |
4503 | 6034 || (reginput > regline |
6035 && vim_iswordc_buf(reginput[-1], reg_buf))) | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6036 result = FALSE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6037 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6038 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6039 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6040 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6041 } |
4444 | 6042 break; |
6043 | |
6044 case NFA_EOW: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6045 result = TRUE; |
4444 | 6046 if (reginput == regline) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6047 result = FALSE; |
4444 | 6048 #ifdef FEAT_MBYTE |
6049 else if (has_mbyte) | |
6050 { | |
6051 int this_class, prev_class; | |
6052 | |
6053 /* Get class of current and previous char (if it exists). */ | |
4503 | 6054 this_class = mb_get_class_buf(reginput, reg_buf); |
4444 | 6055 prev_class = reg_prev_class(); |
6056 if (this_class == prev_class | |
6057 || prev_class == 0 || prev_class == 1) | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6058 result = FALSE; |
4444 | 6059 } |
6060 #endif | |
4503 | 6061 else if (!vim_iswordc_buf(reginput[-1], reg_buf) |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6062 || (reginput[0] != NUL |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6063 && vim_iswordc_buf(curc, reg_buf))) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6064 result = FALSE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6065 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6066 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6067 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6068 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6069 } |
4444 | 6070 break; |
6071 | |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6072 case NFA_BOF: |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6073 if (reglnum == 0 && reginput == regline |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6074 && (!REG_MULTI || reg_firstlnum == 1)) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6075 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6076 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6077 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6078 } |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6079 break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6080 |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6081 case NFA_EOF: |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6082 if (reglnum == reg_maxline && curc == NUL) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6083 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6084 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6085 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6086 } |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6087 break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
6088 |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6089 #ifdef FEAT_MBYTE |
4444 | 6090 case NFA_COMPOSING: |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6091 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6092 int mc = curc; |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6093 int len = 0; |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6094 nfa_state_T *end; |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6095 nfa_state_T *sta; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6096 int cchars[MAX_MCO]; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6097 int ccount = 0; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6098 int j; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6099 |
4444 | 6100 sta = t->state->out; |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6101 len = 0; |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6102 if (utf_iscomposing(sta->c)) |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6103 { |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6104 /* Only match composing character(s), ignore base |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6105 * character. Used for ".{composing}" and "{composing}" |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6106 * (no preceding character). */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6107 len += mb_char2len(mc); |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6108 } |
4551
f0c37f5cf4ea
updated for version 7.3.1023
Bram Moolenaar <bram@vim.org>
parents:
4549
diff
changeset
|
6109 if (ireg_icombine && len == 0) |
4444 | 6110 { |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6111 /* If \Z was present, then ignore composing characters. |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
6112 * When ignoring the base character this always matches. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6113 if (len == 0 && sta->c != curc) |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6114 result = FAIL; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6115 else |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6116 result = OK; |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6117 while (sta->c != NFA_END_COMPOSING) |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6118 sta = sta->out; |
4444 | 6119 } |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6120 |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6121 /* Check base character matches first, unless ignored. */ |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6122 else if (len > 0 || mc == sta->c) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6123 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6124 if (len == 0) |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6125 { |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6126 len += mb_char2len(mc); |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6127 sta = sta->out; |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
6128 } |
4444 | 6129 |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6130 /* We don't care about the order of composing characters. |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6131 * Get them into cchars[] first. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6132 while (len < clen) |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6133 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6134 mc = mb_ptr2char(reginput + len); |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6135 cchars[ccount++] = mc; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6136 len += mb_char2len(mc); |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6137 if (ccount == MAX_MCO) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6138 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6139 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6140 |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6141 /* Check that each composing char in the pattern matches a |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6142 * composing char in the text. We do not check if all |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6143 * composing chars are matched. */ |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6144 result = OK; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6145 while (sta->c != NFA_END_COMPOSING) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6146 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6147 for (j = 0; j < ccount; ++j) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6148 if (cchars[j] == sta->c) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6149 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6150 if (j == ccount) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6151 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6152 result = FAIL; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6153 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6154 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6155 sta = sta->out; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6156 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6157 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6158 else |
4525
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4517
diff
changeset
|
6159 result = FAIL; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6160 |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6161 end = t->state->out1; /* NFA_END_COMPOSING */ |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6162 ADD_STATE_IF_MATCH(end); |
4444 | 6163 break; |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6164 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6165 #endif |
4444 | 6166 |
6167 case NFA_NEWL: | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6168 if (curc == NUL && !reg_line_lbr && REG_MULTI |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6169 && reglnum <= reg_maxline) |
4444 | 6170 { |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6171 go_to_nextline = TRUE; |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6172 /* Pass -1 for the offset, which means taking the position |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6173 * at the start of the next line. */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6174 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6175 add_off = -1; |
4444 | 6176 } |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6177 else if (curc == '\n' && reg_line_lbr) |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6178 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6179 /* 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
|
6180 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6181 add_off = 1; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6182 } |
4444 | 6183 break; |
6184 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6185 case NFA_START_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6186 case NFA_START_NEG_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6187 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6188 /* What follows is a list of characters, until NFA_END_COLL. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6189 * One of them must match or none of them must match. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6190 nfa_state_T *state; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6191 int result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6192 int c1, c2; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6193 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6194 /* Never match EOL. If it's part of the collection it is added |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6195 * as a separate state with an OR. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6196 if (curc == NUL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6197 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6198 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6199 state = t->state->out; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6200 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
|
6201 for (;;) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6202 { |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6203 if (state->c == NFA_END_COLL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6204 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6205 result = !result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6206 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6207 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6208 if (state->c == NFA_RANGE_MIN) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6209 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6210 c1 = state->val; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6211 state = state->out; /* advance to NFA_RANGE_MAX */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6212 c2 = state->val; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6213 #ifdef ENABLE_LOG |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6214 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
|
6215 curc, c1, c2); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6216 #endif |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6217 if (curc >= c1 && curc <= c2) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6218 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6219 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6220 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6221 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6222 if (ireg_ic) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6223 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6224 int curc_low = MB_TOLOWER(curc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6225 int done = FALSE; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6226 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6227 for ( ; c1 <= c2; ++c1) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6228 if (MB_TOLOWER(c1) == curc_low) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6229 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6230 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6231 done = TRUE; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6232 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6233 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6234 if (done) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6235 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6236 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6237 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6238 else if (state->c < 0 ? check_char_class(state->c, curc) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6239 : (curc == state->c |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6240 || (ireg_ic && MB_TOLOWER(curc) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6241 == MB_TOLOWER(state->c)))) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6242 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6243 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6244 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6245 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6246 state = state->out; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6247 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6248 if (result) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6249 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6250 /* next state is in out of the NFA_END_COLL, out1 of |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6251 * START points to the END state */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6252 add_state = t->state->out1->out; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6253 add_off = clen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6254 } |
4444 | 6255 break; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6256 } |
4444 | 6257 |
6258 case NFA_ANY: | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6259 /* 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
|
6260 if (curc > 0) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6261 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6262 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6263 add_off = clen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6264 } |
4444 | 6265 break; |
6266 | |
5901 | 6267 case NFA_ANY_COMPOSING: |
6268 /* On a composing character skip over it. Otherwise do | |
6269 * nothing. Always matches. */ | |
6270 #ifdef FEAT_MBYTE | |
6271 if (enc_utf8 && utf_iscomposing(curc)) | |
6272 { | |
6273 add_off = clen; | |
6274 } | |
6275 else | |
6276 #endif | |
6277 { | |
6278 add_here = TRUE; | |
6279 add_off = 0; | |
6280 } | |
6281 add_state = t->state->out; | |
6282 break; | |
6283 | |
4444 | 6284 /* |
6285 * Character classes like \a for alpha, \d for digit etc. | |
6286 */ | |
6287 case NFA_IDENT: /* \i */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6288 result = vim_isIDc(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6289 ADD_STATE_IF_MATCH(t->state); |
4444 | 6290 break; |
6291 | |
6292 case NFA_SIDENT: /* \I */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6293 result = !VIM_ISDIGIT(curc) && vim_isIDc(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6294 ADD_STATE_IF_MATCH(t->state); |
4444 | 6295 break; |
6296 | |
6297 case NFA_KWORD: /* \k */ | |
4503 | 6298 result = vim_iswordp_buf(reginput, reg_buf); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6299 ADD_STATE_IF_MATCH(t->state); |
4444 | 6300 break; |
6301 | |
6302 case NFA_SKWORD: /* \K */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6303 result = !VIM_ISDIGIT(curc) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6304 && vim_iswordp_buf(reginput, reg_buf); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6305 ADD_STATE_IF_MATCH(t->state); |
4444 | 6306 break; |
6307 | |
6308 case NFA_FNAME: /* \f */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6309 result = vim_isfilec(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6310 ADD_STATE_IF_MATCH(t->state); |
4444 | 6311 break; |
6312 | |
6313 case NFA_SFNAME: /* \F */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6314 result = !VIM_ISDIGIT(curc) && vim_isfilec(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6315 ADD_STATE_IF_MATCH(t->state); |
4444 | 6316 break; |
6317 | |
6318 case NFA_PRINT: /* \p */ | |
5221
9982ec574beb
updated for version 7.4a.036
Bram Moolenaar <bram@vim.org>
parents:
5212
diff
changeset
|
6319 result = vim_isprintc(PTR2CHAR(reginput)); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6320 ADD_STATE_IF_MATCH(t->state); |
4444 | 6321 break; |
6322 | |
6323 case NFA_SPRINT: /* \P */ | |
5221
9982ec574beb
updated for version 7.4a.036
Bram Moolenaar <bram@vim.org>
parents:
5212
diff
changeset
|
6324 result = !VIM_ISDIGIT(curc) && vim_isprintc(PTR2CHAR(reginput)); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6325 ADD_STATE_IF_MATCH(t->state); |
4444 | 6326 break; |
6327 | |
6328 case NFA_WHITE: /* \s */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6329 result = vim_iswhite(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6330 ADD_STATE_IF_MATCH(t->state); |
4444 | 6331 break; |
6332 | |
6333 case NFA_NWHITE: /* \S */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6334 result = curc != NUL && !vim_iswhite(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6335 ADD_STATE_IF_MATCH(t->state); |
4444 | 6336 break; |
6337 | |
6338 case NFA_DIGIT: /* \d */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6339 result = ri_digit(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6340 ADD_STATE_IF_MATCH(t->state); |
4444 | 6341 break; |
6342 | |
6343 case NFA_NDIGIT: /* \D */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6344 result = curc != NUL && !ri_digit(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6345 ADD_STATE_IF_MATCH(t->state); |
4444 | 6346 break; |
6347 | |
6348 case NFA_HEX: /* \x */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6349 result = ri_hex(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6350 ADD_STATE_IF_MATCH(t->state); |
4444 | 6351 break; |
6352 | |
6353 case NFA_NHEX: /* \X */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6354 result = curc != NUL && !ri_hex(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6355 ADD_STATE_IF_MATCH(t->state); |
4444 | 6356 break; |
6357 | |
6358 case NFA_OCTAL: /* \o */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6359 result = ri_octal(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6360 ADD_STATE_IF_MATCH(t->state); |
4444 | 6361 break; |
6362 | |
6363 case NFA_NOCTAL: /* \O */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6364 result = curc != NUL && !ri_octal(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6365 ADD_STATE_IF_MATCH(t->state); |
4444 | 6366 break; |
6367 | |
6368 case NFA_WORD: /* \w */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6369 result = ri_word(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6370 ADD_STATE_IF_MATCH(t->state); |
4444 | 6371 break; |
6372 | |
6373 case NFA_NWORD: /* \W */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6374 result = curc != NUL && !ri_word(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6375 ADD_STATE_IF_MATCH(t->state); |
4444 | 6376 break; |
6377 | |
6378 case NFA_HEAD: /* \h */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6379 result = ri_head(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6380 ADD_STATE_IF_MATCH(t->state); |
4444 | 6381 break; |
6382 | |
6383 case NFA_NHEAD: /* \H */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6384 result = curc != NUL && !ri_head(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6385 ADD_STATE_IF_MATCH(t->state); |
4444 | 6386 break; |
6387 | |
6388 case NFA_ALPHA: /* \a */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6389 result = ri_alpha(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6390 ADD_STATE_IF_MATCH(t->state); |
4444 | 6391 break; |
6392 | |
6393 case NFA_NALPHA: /* \A */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6394 result = curc != NUL && !ri_alpha(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6395 ADD_STATE_IF_MATCH(t->state); |
4444 | 6396 break; |
6397 | |
6398 case NFA_LOWER: /* \l */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6399 result = ri_lower(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6400 ADD_STATE_IF_MATCH(t->state); |
4444 | 6401 break; |
6402 | |
6403 case NFA_NLOWER: /* \L */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6404 result = curc != NUL && !ri_lower(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6405 ADD_STATE_IF_MATCH(t->state); |
4444 | 6406 break; |
6407 | |
6408 case NFA_UPPER: /* \u */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6409 result = ri_upper(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6410 ADD_STATE_IF_MATCH(t->state); |
4444 | 6411 break; |
6412 | |
6413 case NFA_NUPPER: /* \U */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6414 result = curc != NUL && !ri_upper(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6415 ADD_STATE_IF_MATCH(t->state); |
4444 | 6416 break; |
6417 | |
5296 | 6418 case NFA_LOWER_IC: /* [a-z] */ |
6419 result = ri_lower(curc) || (ireg_ic && ri_upper(curc)); | |
6420 ADD_STATE_IF_MATCH(t->state); | |
6421 break; | |
6422 | |
6423 case NFA_NLOWER_IC: /* [^a-z] */ | |
6424 result = curc != NUL | |
6425 && !(ri_lower(curc) || (ireg_ic && ri_upper(curc))); | |
6426 ADD_STATE_IF_MATCH(t->state); | |
6427 break; | |
6428 | |
6429 case NFA_UPPER_IC: /* [A-Z] */ | |
6430 result = ri_upper(curc) || (ireg_ic && ri_lower(curc)); | |
6431 ADD_STATE_IF_MATCH(t->state); | |
6432 break; | |
6433 | |
6434 case NFA_NUPPER_IC: /* ^[A-Z] */ | |
6435 result = curc != NUL | |
6436 && !(ri_upper(curc) || (ireg_ic && ri_lower(curc))); | |
6437 ADD_STATE_IF_MATCH(t->state); | |
6438 break; | |
6439 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6440 case NFA_BACKREF1: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6441 case NFA_BACKREF2: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6442 case NFA_BACKREF3: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6443 case NFA_BACKREF4: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6444 case NFA_BACKREF5: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6445 case NFA_BACKREF6: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6446 case NFA_BACKREF7: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6447 case NFA_BACKREF8: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6448 case NFA_BACKREF9: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6449 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6450 case NFA_ZREF1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6451 case NFA_ZREF2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6452 case NFA_ZREF3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6453 case NFA_ZREF4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6454 case NFA_ZREF5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6455 case NFA_ZREF6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6456 case NFA_ZREF7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6457 case NFA_ZREF8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6458 case NFA_ZREF9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6459 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6460 /* \1 .. \9 \z1 .. \z9 */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6461 { |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6462 int subidx; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6463 int bytelen; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6464 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6465 if (t->state->c <= NFA_BACKREF9) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6466 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6467 subidx = t->state->c - NFA_BACKREF1 + 1; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6468 result = match_backref(&t->subs.norm, subidx, &bytelen); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6469 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6470 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6471 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6472 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6473 subidx = t->state->c - NFA_ZREF1 + 1; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6474 result = match_zref(subidx, &bytelen); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6475 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6476 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6477 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6478 if (result) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6479 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6480 if (bytelen == 0) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6481 { |
4692
08fbb1ce1bc5
updated for version 7.3.1093
Bram Moolenaar <bram@vim.org>
parents:
4690
diff
changeset
|
6482 /* empty match always works, output of NFA_SKIP to be |
08fbb1ce1bc5
updated for version 7.3.1093
Bram Moolenaar <bram@vim.org>
parents:
4690
diff
changeset
|
6483 * used next */ |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6484 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6485 add_state = t->state->out->out; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6486 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6487 else if (bytelen <= clen) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6488 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6489 /* match current character, jump ahead to out of |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6490 * NFA_SKIP */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6491 add_state = t->state->out->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6492 add_off = clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6493 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6494 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6495 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
6496 /* skip over the matched characters, set character |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6497 * count in NFA_SKIP */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6498 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6499 add_off = bytelen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6500 add_count = bytelen - clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6501 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6502 } |
4482 | 6503 break; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6504 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6505 case NFA_SKIP: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
6506 /* character of previous matching \1 .. \9 or \@> */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6507 if (t->count - clen <= 0) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6508 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6509 /* end of match, go to what follows */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6510 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6511 add_off = clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6512 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6513 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6514 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6515 /* add state again with decremented count */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6516 add_state = t->state; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6517 add_off = 0; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6518 add_count = t->count - clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6519 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6520 break; |
4482 | 6521 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6522 case NFA_LNUM: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6523 case NFA_LNUM_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6524 case NFA_LNUM_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6525 result = (REG_MULTI && |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6526 nfa_re_num_cmp(t->state->val, t->state->c - NFA_LNUM, |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6527 (long_u)(reglnum + reg_firstlnum))); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6528 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6529 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6530 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6531 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6532 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6533 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6534 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6535 case NFA_COL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6536 case NFA_COL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6537 case NFA_COL_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6538 result = nfa_re_num_cmp(t->state->val, t->state->c - NFA_COL, |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6539 (long_u)(reginput - regline) + 1); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6540 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6541 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6542 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6543 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6544 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6545 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6546 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6547 case NFA_VCOL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6548 case NFA_VCOL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6549 case NFA_VCOL_LT: |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6550 { |
6499 | 6551 int op = t->state->c - NFA_VCOL; |
6552 colnr_T col = (colnr_T)(reginput - regline); | |
6510 | 6553 win_T *wp = reg_win == NULL ? curwin : reg_win; |
6499 | 6554 |
6555 /* Bail out quickly when there can't be a match, avoid the | |
6556 * overhead of win_linetabsize() on long lines. */ | |
6653 | 6557 if (op != 1 && col > t->state->val |
6558 #ifdef FEAT_MBYTE | |
6559 * (has_mbyte ? MB_MAXBYTES : 1) | |
6560 #endif | |
6561 ) | |
6499 | 6562 break; |
6510 | 6563 result = FALSE; |
6564 if (op == 1 && col - 1 > t->state->val && col > 100) | |
6565 { | |
6566 int ts = wp->w_buffer->b_p_ts; | |
6567 | |
6568 /* Guess that a character won't use more columns than | |
6569 * 'tabstop', with a minimum of 4. */ | |
6570 if (ts < 4) | |
6571 ts = 4; | |
6572 result = col > t->state->val * ts; | |
6573 } | |
6574 if (!result) | |
6575 result = nfa_re_num_cmp(t->state->val, op, | |
6576 (long_u)win_linetabsize(wp, regline, col) + 1); | |
6499 | 6577 if (result) |
6578 { | |
6579 add_here = TRUE; | |
6580 add_state = t->state->out; | |
6581 } | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6582 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6583 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6584 |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6585 case NFA_MARK: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6586 case NFA_MARK_GT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6587 case NFA_MARK_LT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6588 { |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6589 pos_T *pos = getmark_buf(reg_buf, t->state->val, FALSE); |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6590 |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6591 /* Compare the mark position to the match position. */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6592 result = (pos != NULL /* mark doesn't exist */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6593 && pos->lnum > 0 /* mark isn't set in reg_buf */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6594 && (pos->lnum == reglnum + reg_firstlnum |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6595 ? (pos->col == (colnr_T)(reginput - regline) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6596 ? t->state->c == NFA_MARK |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6597 : (pos->col < (colnr_T)(reginput - regline) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6598 ? t->state->c == NFA_MARK_GT |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6599 : t->state->c == NFA_MARK_LT)) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6600 : (pos->lnum < reglnum + reg_firstlnum |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6601 ? t->state->c == NFA_MARK_GT |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6602 : t->state->c == NFA_MARK_LT))); |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6603 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6604 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6605 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6606 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6607 } |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6608 break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6609 } |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6610 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6611 case NFA_CURSOR: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6612 result = (reg_win != NULL |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6613 && (reglnum + reg_firstlnum == reg_win->w_cursor.lnum) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6614 && ((colnr_T)(reginput - regline) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6615 == reg_win->w_cursor.col)); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6616 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6617 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6618 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6619 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6620 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6621 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6622 |
4756
96f3348f9f11
updated for version 7.3.1125
Bram Moolenaar <bram@vim.org>
parents:
4750
diff
changeset
|
6623 case NFA_VISUAL: |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6624 result = reg_match_visual(); |
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6625 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6626 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6627 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6628 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6629 } |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6630 break; |
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6631 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6632 case NFA_MOPEN1: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6633 case NFA_MOPEN2: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6634 case NFA_MOPEN3: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6635 case NFA_MOPEN4: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6636 case NFA_MOPEN5: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6637 case NFA_MOPEN6: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6638 case NFA_MOPEN7: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6639 case NFA_MOPEN8: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6640 case NFA_MOPEN9: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6641 #ifdef FEAT_SYN_HL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6642 case NFA_ZOPEN: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6643 case NFA_ZOPEN1: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6644 case NFA_ZOPEN2: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6645 case NFA_ZOPEN3: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6646 case NFA_ZOPEN4: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6647 case NFA_ZOPEN5: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6648 case NFA_ZOPEN6: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6649 case NFA_ZOPEN7: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6650 case NFA_ZOPEN8: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6651 case NFA_ZOPEN9: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6652 #endif |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6653 case NFA_NOPEN: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6654 case NFA_ZSTART: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6655 /* These states are only added to be able to bail out when |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6656 * they are added again, nothing is to be done. */ |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6657 break; |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6658 |
4444 | 6659 default: /* regular character */ |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6660 { |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6661 int c = t->state->c; |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6662 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6663 #ifdef DEBUG |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6664 if (c < 0) |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6665 EMSGN("INTERNAL: Negative state char: %ld", c); |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6666 #endif |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6667 result = (c == curc); |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6668 |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6669 if (!result && ireg_ic) |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6670 result = MB_TOLOWER(c) == MB_TOLOWER(curc); |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6671 #ifdef FEAT_MBYTE |
5901 | 6672 /* If ireg_icombine is not set only skip over the character |
6673 * itself. When it is set skip over composing characters. */ | |
6674 if (result && enc_utf8 && !ireg_icombine) | |
6787 | 6675 clen = utf_ptr2len(reginput); |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6676 #endif |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6677 ADD_STATE_IF_MATCH(t->state); |
4444 | 6678 break; |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6679 } |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6680 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6681 } /* switch (t->state->c) */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6682 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6683 if (add_state != NULL) |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6684 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6685 nfa_pim_T *pim; |
5401 | 6686 nfa_pim_T pim_copy; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6687 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6688 if (t->pim.result == NFA_PIM_UNUSED) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6689 pim = NULL; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6690 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6691 pim = &t->pim; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6692 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6693 /* Handle the postponed invisible match if the match might end |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6694 * without advancing and before the end of the line. */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6695 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
|
6696 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6697 if (pim->result == NFA_PIM_TODO) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6698 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6699 #ifdef ENABLE_LOG |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6700 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6701 fprintf(log_fd, "==================================\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6702 fprintf(log_fd, "Postponed recursive nfa_regmatch()\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6703 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6704 #endif |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6705 result = recursive_regmatch(pim->state, pim, |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6706 prog, submatch, m, &listids); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6707 pim->result = result ? NFA_PIM_MATCH : NFA_PIM_NOMATCH; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6708 /* for \@! and \@<! it is a match when the result is |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6709 * FALSE */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6710 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
|
6711 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6712 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6713 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6714 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6715 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6716 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6717 /* Copy submatch info from the recursive call */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6718 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
|
6719 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
6720 if (nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6721 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
|
6722 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6723 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6724 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6725 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6726 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6727 result = (pim->result == NFA_PIM_MATCH); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6728 #ifdef ENABLE_LOG |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6729 fprintf(log_fd, "\n"); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6730 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
|
6731 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
|
6732 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6733 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6734 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6735 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6736 /* 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
|
6737 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
|
6738 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6739 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6740 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6741 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6742 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6743 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6744 /* Copy submatch info from the recursive call */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6745 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
|
6746 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
6747 if (nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6748 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
|
6749 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6750 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6751 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6752 /* look-behind match failed, don't add the state */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6753 continue; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6754 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6755 /* Postponed invisible match was handled, don't add it to |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6756 * following states. */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6757 pim = NULL; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6758 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6759 |
5401 | 6760 /* If "pim" points into l->t it will become invalid when |
6761 * adding the state causes the list to be reallocated. Make a | |
6762 * local copy to avoid that. */ | |
6763 if (pim == &t->pim) | |
6764 { | |
6765 copy_pim(&pim_copy, pim); | |
6766 pim = &pim_copy; | |
6767 } | |
6768 | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6769 if (add_here) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6770 addstate_here(thislist, add_state, &t->subs, pim, &listidx); |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6771 else |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6772 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6773 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
|
6774 if (add_count > 0) |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6775 nextlist->t[nextlist->n - 1].count = add_count; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6776 } |
4444 | 6777 } |
6778 | |
6779 } /* for (thislist = thislist; thislist->state; thislist++) */ | |
6780 | |
4557
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6781 /* Look for the start of a match in the current position by adding the |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6782 * start state to the list of states. |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6783 * The first found match is the leftmost one, thus the order of states |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6784 * matters! |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6785 * Do not add the start state in recursive calls of nfa_regmatch(), |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6786 * because recursive calls should only start in the first position. |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6787 * Unless "nfa_endp" is not NULL, then we match the end position. |
4557
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6788 * 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
|
6789 if (nfa_match == FALSE |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6790 && ((toplevel |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6791 && reglnum == 0 |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6792 && clen != 0 |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6793 && (ireg_maxcol == 0 |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6794 || (colnr_T)(reginput - regline) < ireg_maxcol)) |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6795 || (nfa_endp != NULL |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6796 && (REG_MULTI |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6797 ? (reglnum < nfa_endp->se_u.pos.lnum |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6798 || (reglnum == nfa_endp->se_u.pos.lnum |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6799 && (int)(reginput - regline) |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6800 < nfa_endp->se_u.pos.col)) |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6801 : reginput < nfa_endp->se_u.ptr)))) |
4444 | 6802 { |
6803 #ifdef ENABLE_LOG | |
6804 fprintf(log_fd, "(---) STARTSTATE\n"); | |
6805 #endif | |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6806 /* Inline optimized code for addstate() if we know the state is |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6807 * the first MOPEN. */ |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6808 if (toplevel) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6809 { |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6810 int add = TRUE; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6811 int c; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6812 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6813 if (prog->regstart != NUL && clen != 0) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6814 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6815 if (nextlist->n == 0) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6816 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6817 colnr_T col = (colnr_T)(reginput - regline) + clen; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6818 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6819 /* Nextlist is empty, we can skip ahead to the |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6820 * character that must appear at the start. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6821 if (skip_to_start(prog->regstart, &col) == FAIL) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6822 break; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6823 #ifdef ENABLE_LOG |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6824 fprintf(log_fd, " Skipping ahead %d bytes to regstart\n", |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6825 col - ((colnr_T)(reginput - regline) + clen)); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6826 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6827 reginput = regline + col - clen; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6828 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6829 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6830 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6831 /* Checking if the required start character matches is |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6832 * cheaper than adding a state that won't match. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6833 c = PTR2CHAR(reginput + clen); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6834 if (c != prog->regstart && (!ireg_ic || MB_TOLOWER(c) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6835 != MB_TOLOWER(prog->regstart))) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6836 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6837 #ifdef ENABLE_LOG |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6838 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
|
6839 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6840 add = FALSE; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6841 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6842 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6843 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6844 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6845 if (add) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6846 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6847 if (REG_MULTI) |
6547 | 6848 m->norm.list.multi[0].start_col = |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6849 (colnr_T)(reginput - regline) + clen; |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6850 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6851 m->norm.list.line[0].start = reginput + clen; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6852 addstate(nextlist, start->out, m, NULL, clen); |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6853 } |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6854 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6855 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6856 addstate(nextlist, start, m, NULL, clen); |
4444 | 6857 } |
6858 | |
6859 #ifdef ENABLE_LOG | |
6860 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
|
6861 { |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6862 int i; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6863 |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6864 for (i = 0; i < thislist->n; i++) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6865 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
|
6866 } |
4444 | 6867 fprintf(log_fd, "\n"); |
6868 #endif | |
6869 | |
6870 nextchar: | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6871 /* Advance to the next character, or advance to the next line, or |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6872 * finish. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6873 if (clen != 0) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6874 reginput += clen; |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6875 else if (go_to_nextline || (nfa_endp != NULL && REG_MULTI |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6876 && reglnum < nfa_endp->se_u.pos.lnum)) |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6877 reg_nextline(); |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6878 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6879 break; |
6499 | 6880 |
6881 /* Allow interrupting with CTRL-C. */ | |
6573 | 6882 line_breakcheck(); |
6499 | 6883 if (got_int) |
6884 break; | |
6573 | 6885 #ifdef FEAT_RELTIME |
6886 /* Check for timeout once in a twenty times to avoid overhead. */ | |
6887 if (nfa_time_limit != NULL && ++nfa_time_count == 20) | |
6888 { | |
6889 nfa_time_count = 0; | |
6890 if (profile_passed_limit(nfa_time_limit)) | |
6891 break; | |
6892 } | |
6893 #endif | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6894 } |
4444 | 6895 |
6896 #ifdef ENABLE_LOG | |
6897 if (log_fd != stderr) | |
6898 fclose(log_fd); | |
6899 log_fd = NULL; | |
6900 #endif | |
6901 | |
6902 theend: | |
6903 /* Free memory */ | |
6904 vim_free(list[0].t); | |
6905 vim_free(list[1].t); | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
6906 vim_free(listids); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6907 #undef ADD_STATE_IF_MATCH |
4460 | 6908 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 6909 fclose(debug); |
6910 #endif | |
6911 | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
6912 return nfa_match; |
4444 | 6913 } |
6914 | |
6915 /* | |
6916 * Try match of "prog" with at regline["col"]. | |
6392 | 6917 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 6918 */ |
6919 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6920 nfa_regtry( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6921 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6922 colnr_T col, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6923 proftime_T *tm UNUSED) /* timeout limit or NULL */ |
4444 | 6924 { |
6925 int i; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6926 regsubs_T subs, m; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6927 nfa_state_T *start = prog->start; |
6328 | 6928 int result; |
4444 | 6929 #ifdef ENABLE_LOG |
6930 FILE *f; | |
6931 #endif | |
6932 | |
6933 reginput = regline + col; | |
6573 | 6934 #ifdef FEAT_RELTIME |
6935 nfa_time_limit = tm; | |
6936 nfa_time_count = 0; | |
6937 #endif | |
4444 | 6938 |
6939 #ifdef ENABLE_LOG | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6940 f = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 6941 if (f != NULL) |
6942 { | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6943 fprintf(f, "\n\n\t=======================================================\n"); |
4444 | 6944 #ifdef DEBUG |
6945 fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr); | |
6946 #endif | |
6947 fprintf(f, "\tInput text is \"%s\" \n", reginput); | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6948 fprintf(f, "\t=======================================================\n\n"); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
6949 nfa_print_state(f, start); |
4444 | 6950 fprintf(f, "\n\n"); |
6951 fclose(f); | |
6952 } | |
6953 else | |
6954 EMSG(_("Could not open temporary log file for writing ")); | |
6955 #endif | |
6956 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6957 clear_sub(&subs.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6958 clear_sub(&m.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6959 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6960 clear_sub(&subs.synt); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6961 clear_sub(&m.synt); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6962 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6963 |
6328 | 6964 result = nfa_regmatch(prog, start, &subs, &m); |
6965 if (result == FALSE) | |
4444 | 6966 return 0; |
6328 | 6967 else if (result == NFA_TOO_EXPENSIVE) |
6968 return result; | |
4444 | 6969 |
6970 cleanup_subexpr(); | |
6971 if (REG_MULTI) | |
6972 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6973 for (i = 0; i < subs.norm.in_use; i++) |
4444 | 6974 { |
6547 | 6975 reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum; |
6976 reg_startpos[i].col = subs.norm.list.multi[i].start_col; | |
6977 | |
6978 reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum; | |
6979 reg_endpos[i].col = subs.norm.list.multi[i].end_col; | |
4444 | 6980 } |
6981 | |
6982 if (reg_startpos[0].lnum < 0) | |
6983 { | |
6984 reg_startpos[0].lnum = 0; | |
6985 reg_startpos[0].col = col; | |
6986 } | |
6987 if (reg_endpos[0].lnum < 0) | |
6988 { | |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
6989 /* pattern has a \ze but it didn't match, use current end */ |
4444 | 6990 reg_endpos[0].lnum = reglnum; |
6991 reg_endpos[0].col = (int)(reginput - regline); | |
6992 } | |
6993 else | |
6994 /* Use line number of "\ze". */ | |
6995 reglnum = reg_endpos[0].lnum; | |
6996 } | |
6997 else | |
6998 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6999 for (i = 0; i < subs.norm.in_use; i++) |
4444 | 7000 { |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7001 reg_startp[i] = subs.norm.list.line[i].start; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7002 reg_endp[i] = subs.norm.list.line[i].end; |
4444 | 7003 } |
7004 | |
7005 if (reg_startp[0] == NULL) | |
7006 reg_startp[0] = regline + col; | |
7007 if (reg_endp[0] == NULL) | |
7008 reg_endp[0] = reginput; | |
7009 } | |
7010 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7011 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7012 /* Package any found \z(...\) matches for export. Default is none. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7013 unref_extmatch(re_extmatch_out); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7014 re_extmatch_out = NULL; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7015 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7016 if (prog->reghasz == REX_SET) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7017 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7018 cleanup_zsubexpr(); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7019 re_extmatch_out = make_extmatch(); |
7258
7245d8635ac7
commit https://github.com/vim/vim/commit/5ad075c0735d3d8b97708d17c22de8facb15f997
Christian Brabandt <cb@256bit.org>
parents:
7152
diff
changeset
|
7020 /* Loop over \z1, \z2, etc. There is no \z0. */ |
7245d8635ac7
commit https://github.com/vim/vim/commit/5ad075c0735d3d8b97708d17c22de8facb15f997
Christian Brabandt <cb@256bit.org>
parents:
7152
diff
changeset
|
7021 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
|
7022 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7023 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7024 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7025 struct multipos *mpos = &subs.synt.list.multi[i]; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7026 |
5820 | 7027 /* Only accept single line matches that are valid. */ |
6547 | 7028 if (mpos->start_lnum >= 0 |
7029 && mpos->start_lnum == mpos->end_lnum | |
7030 && mpos->end_col >= mpos->start_col) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7031 re_extmatch_out->matches[i] = |
6547 | 7032 vim_strnsave(reg_getline(mpos->start_lnum) |
7033 + mpos->start_col, | |
7034 mpos->end_col - mpos->start_col); | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7035 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7036 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7037 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7038 struct linepos *lpos = &subs.synt.list.line[i]; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7039 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7040 if (lpos->start != NULL && lpos->end != NULL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7041 re_extmatch_out->matches[i] = |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7042 vim_strnsave(lpos->start, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7043 (int)(lpos->end - lpos->start)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7044 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7045 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7046 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7047 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7048 |
4444 | 7049 return 1 + reglnum; |
7050 } | |
7051 | |
7052 /* | |
7053 * Match a regexp against a string ("line" points to the string) or multiple | |
7054 * lines ("line" is NULL, use reg_getline()). | |
7055 * | |
6392 | 7056 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 7057 */ |
7058 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7059 nfa_regexec_both( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7060 char_u *line, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7061 colnr_T startcol, /* column to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7062 proftime_T *tm) /* timeout limit or NULL */ |
4444 | 7063 { |
7064 nfa_regprog_T *prog; | |
7065 long retval = 0L; | |
7066 int i; | |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7067 colnr_T col = startcol; |
4444 | 7068 |
7069 if (REG_MULTI) | |
7070 { | |
7071 prog = (nfa_regprog_T *)reg_mmatch->regprog; | |
7072 line = reg_getline((linenr_T)0); /* relative to the cursor */ | |
7073 reg_startpos = reg_mmatch->startpos; | |
7074 reg_endpos = reg_mmatch->endpos; | |
7075 } | |
7076 else | |
7077 { | |
7078 prog = (nfa_regprog_T *)reg_match->regprog; | |
7079 reg_startp = reg_match->startp; | |
7080 reg_endp = reg_match->endp; | |
7081 } | |
7082 | |
7083 /* Be paranoid... */ | |
7084 if (prog == NULL || line == NULL) | |
7085 { | |
7086 EMSG(_(e_null)); | |
7087 goto theend; | |
7088 } | |
7089 | |
7090 /* If pattern contains "\c" or "\C": overrule value of ireg_ic */ | |
7091 if (prog->regflags & RF_ICASE) | |
7092 ireg_ic = TRUE; | |
7093 else if (prog->regflags & RF_NOICASE) | |
7094 ireg_ic = FALSE; | |
7095 | |
7096 #ifdef FEAT_MBYTE | |
7097 /* If pattern contains "\Z" overrule value of ireg_icombine */ | |
7098 if (prog->regflags & RF_ICOMBINE) | |
7099 ireg_icombine = TRUE; | |
7100 #endif | |
7101 | |
7102 regline = line; | |
7103 reglnum = 0; /* relative to line */ | |
7104 | |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
7105 nfa_has_zend = prog->has_zend; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
7106 nfa_has_backref = prog->has_backref; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
7107 nfa_nsubexpr = prog->nsubexp; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7108 nfa_listid = 1; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7109 nfa_alt_listid = 2; |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7110 nfa_regengine.expr = prog->pattern; |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
7111 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7112 if (prog->reganch && col > 0) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7113 return 0L; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7114 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7115 need_clear_subexpr = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7116 #ifdef FEAT_SYN_HL |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7117 /* Clear the external match subpointers if necessary. */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7118 if (prog->reghasz == REX_SET) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7119 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7120 nfa_has_zsubexpr = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7121 need_clear_zsubexpr = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7122 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7123 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7124 nfa_has_zsubexpr = FALSE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7125 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7126 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7127 if (prog->regstart != NUL) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7128 { |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7129 /* Skip ahead until a character we know the match must start with. |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7130 * When there is none there is no match. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
7131 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
|
7132 return 0L; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7133 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7134 /* If match_text is set it contains the full text that must match. |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7135 * Nothing else to try. Doesn't handle combining chars well. */ |
4811
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
7136 if (prog->match_text != NULL |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
7137 #ifdef FEAT_MBYTE |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
7138 && !ireg_icombine |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
7139 #endif |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
7140 ) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7141 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
|
7142 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7143 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7144 /* If the start column is past the maximum column: no need to try. */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7145 if (ireg_maxcol > 0 && col >= ireg_maxcol) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7146 goto theend; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7147 |
4444 | 7148 nstate = prog->nstate; |
7149 for (i = 0; i < nstate; ++i) | |
7150 { | |
7151 prog->state[i].id = i; | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7152 prog->state[i].lastlist[0] = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7153 prog->state[i].lastlist[1] = 0; |
4444 | 7154 } |
7155 | |
6573 | 7156 retval = nfa_regtry(prog, col, tm); |
4444 | 7157 |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7158 nfa_regengine.expr = NULL; |
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7159 |
4444 | 7160 theend: |
7161 return retval; | |
7162 } | |
7163 | |
7164 /* | |
7165 * Compile a regular expression into internal code for the NFA matcher. | |
7166 * Returns the program in allocated space. Returns NULL for an error. | |
7167 */ | |
7168 static regprog_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7169 nfa_regcomp(char_u *expr, int re_flags) |
4444 | 7170 { |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7171 nfa_regprog_T *prog = NULL; |
4458 | 7172 size_t prog_size; |
4444 | 7173 int *postfix; |
7174 | |
7175 if (expr == NULL) | |
7176 return NULL; | |
7177 | |
7178 nfa_regengine.expr = expr; | |
6533 | 7179 nfa_re_flags = re_flags; |
4444 | 7180 |
7181 init_class_tab(); | |
7182 | |
7183 if (nfa_regcomp_start(expr, re_flags) == FAIL) | |
7184 return NULL; | |
7185 | |
7186 /* Build postfix form of the regexp. Needed to build the NFA | |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7187 * (and count its size). */ |
4444 | 7188 postfix = re2post(); |
7189 if (postfix == NULL) | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7190 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7191 /* TODO: only give this error for debugging? */ |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7192 if (post_ptr >= post_end) |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7193 EMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start); |
4444 | 7194 goto fail; /* Cascaded (syntax?) error */ |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7195 } |
4444 | 7196 |
7197 /* | |
7198 * In order to build the NFA, we parse the input regexp twice: | |
7199 * 1. first pass to count size (so we can allocate space) | |
7200 * 2. second to emit code | |
7201 */ | |
7202 #ifdef ENABLE_LOG | |
7203 { | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
7204 FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 7205 |
7206 if (f != NULL) | |
7207 { | |
7208 fprintf(f, "\n*****************************\n\n\n\n\tCompiling regexp \"%s\" ... hold on !\n", expr); | |
7209 fclose(f); | |
7210 } | |
7211 } | |
7212 #endif | |
7213 | |
7214 /* | |
7215 * PASS 1 | |
7216 * Count number of NFA states in "nstate". Do not build the NFA. | |
7217 */ | |
7218 post2nfa(postfix, post_ptr, TRUE); | |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7219 |
4837
05b8436873d4
updated for version 7.3.1165
Bram Moolenaar <bram@vim.org>
parents:
4821
diff
changeset
|
7220 /* allocate the regprog with space for the compiled regexp */ |
05b8436873d4
updated for version 7.3.1165
Bram Moolenaar <bram@vim.org>
parents:
4821
diff
changeset
|
7221 prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1); |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7222 prog = (nfa_regprog_T *)lalloc(prog_size, TRUE); |
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7223 if (prog == NULL) |
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7224 goto fail; |
4444 | 7225 state_ptr = prog->state; |
7226 | |
7227 /* | |
7228 * PASS 2 | |
7229 * Build the NFA | |
7230 */ | |
7231 prog->start = post2nfa(postfix, post_ptr, FALSE); | |
7232 if (prog->start == NULL) | |
7233 goto fail; | |
7234 | |
7235 prog->regflags = regflags; | |
7236 prog->engine = &nfa_regengine; | |
7237 prog->nstate = nstate; | |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
7238 prog->has_zend = nfa_has_zend; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
7239 prog->has_backref = nfa_has_backref; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
7240 prog->nsubexp = regnpar; |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7241 |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
7242 nfa_postprocess(prog); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
7243 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7244 prog->reganch = nfa_get_reganch(prog->start, 0); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7245 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
|
7246 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
|
7247 |
4444 | 7248 #ifdef ENABLE_LOG |
7249 nfa_postfix_dump(expr, OK); | |
7250 nfa_dump(prog); | |
7251 #endif | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7252 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7253 /* Remember whether this pattern has any \z specials in it. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7254 prog->reghasz = re_has_z; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7255 #endif |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7256 prog->pattern = vim_strsave(expr); |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7257 nfa_regengine.expr = NULL; |
4444 | 7258 |
7259 out: | |
7260 vim_free(post_start); | |
7261 post_start = post_ptr = post_end = NULL; | |
7262 state_ptr = NULL; | |
7263 return (regprog_T *)prog; | |
7264 | |
7265 fail: | |
7266 vim_free(prog); | |
7267 prog = NULL; | |
7268 #ifdef ENABLE_LOG | |
7269 nfa_postfix_dump(expr, FAIL); | |
7270 #endif | |
7271 nfa_regengine.expr = NULL; | |
7272 goto out; | |
7273 } | |
7274 | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7275 /* |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7276 * 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
|
7277 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7278 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7279 nfa_regfree(regprog_T *prog) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7280 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7281 if (prog != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7282 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7283 vim_free(((nfa_regprog_T *)prog)->match_text); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7284 vim_free(((nfa_regprog_T *)prog)->pattern); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7285 vim_free(prog); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7286 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7287 } |
4444 | 7288 |
7289 /* | |
7290 * Match a regexp against a string. | |
7291 * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp(). | |
7292 * Uses curbuf for line count and 'iskeyword'. | |
5838 | 7293 * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break. |
4444 | 7294 * |
6392 | 7295 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 7296 */ |
7297 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7298 nfa_regexec_nl( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7299 regmatch_T *rmp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7300 char_u *line, /* string to match against */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7301 colnr_T col, /* column to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7302 int line_lbr) |
4444 | 7303 { |
7304 reg_match = rmp; | |
7305 reg_mmatch = NULL; | |
7306 reg_maxline = 0; | |
5838 | 7307 reg_line_lbr = line_lbr; |
4444 | 7308 reg_buf = curbuf; |
7309 reg_win = NULL; | |
7310 ireg_ic = rmp->rm_ic; | |
7311 #ifdef FEAT_MBYTE | |
7312 ireg_icombine = FALSE; | |
7313 #endif | |
7314 ireg_maxcol = 0; | |
6573 | 7315 return nfa_regexec_both(line, col, NULL); |
4444 | 7316 } |
7317 | |
7318 | |
7319 /* | |
7320 * Match a regexp against multiple lines. | |
7321 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). | |
7322 * Uses curbuf for line count and 'iskeyword'. | |
7323 * | |
6392 | 7324 * Return <= 0 if there is no match. Return number of lines contained in the |
4444 | 7325 * match otherwise. |
7326 * | |
7327 * Note: the body is the same as bt_regexec() except for nfa_regexec_both() | |
7328 * | |
7329 * ! Also NOTE : match may actually be in another line. e.g.: | |
7330 * when r.e. is \nc, cursor is at 'a' and the text buffer looks like | |
7331 * | |
7332 * +-------------------------+ | |
7333 * |a | | |
7334 * |b | | |
7335 * |c | | |
7336 * | | | |
7337 * +-------------------------+ | |
7338 * | |
7339 * then nfa_regexec_multi() returns 3. while the original | |
7340 * vim_regexec_multi() returns 0 and a second call at line 2 will return 2. | |
7341 * | |
7342 * FIXME if this behavior is not compatible. | |
7343 */ | |
7344 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7345 nfa_regexec_multi( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7346 regmmatch_T *rmp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7347 win_T *win, /* window in which to search or NULL */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7348 buf_T *buf, /* buffer in which to search */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7349 linenr_T lnum, /* nr of line to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7350 colnr_T col, /* column to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7351 proftime_T *tm) /* timeout limit or NULL */ |
4444 | 7352 { |
7353 reg_match = NULL; | |
7354 reg_mmatch = rmp; | |
7355 reg_buf = buf; | |
7356 reg_win = win; | |
7357 reg_firstlnum = lnum; | |
7358 reg_maxline = reg_buf->b_ml.ml_line_count - lnum; | |
7359 reg_line_lbr = FALSE; | |
7360 ireg_ic = rmp->rmm_ic; | |
7361 #ifdef FEAT_MBYTE | |
7362 ireg_icombine = FALSE; | |
7363 #endif | |
7364 ireg_maxcol = rmp->rmm_maxcol; | |
7365 | |
6573 | 7366 return nfa_regexec_both(NULL, col, tm); |
4444 | 7367 } |
7368 | |
7369 #ifdef DEBUG | |
7370 # undef ENABLE_LOG | |
7371 #endif |