annotate src/regexp_nfa.c @ 19253:a8d2d3c8f0b3 v8.2.0185

patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines Commit: https://github.com/vim/vim/commit/a259d8d30bc289764925fc42db1dbe774f0bb3f8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 31 20:10:50 2020 +0100 patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines Problem: Vim9 script: cannot use "if has()" to skip lines. Solution: Evaluate constant expression at runtime.
author Bram Moolenaar <Bram@vim.org>
date Fri, 31 Jan 2020 20:15:05 +0100
parents c62d63d2b9f0
children 08f4dc2ba716
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9371
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 * NFA regular expression implementation.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5 * This file is included in "regexp.c".
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
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
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
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
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
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
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
32 // Added to NFA_ANY - NFA_NUPPER_IC to include a NL.
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
33 #define NFA_ADD_NL 31
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
34
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 enum
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 NFA_SPLIT = -1024,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 NFA_MATCH,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
39 NFA_EMPTY, // matches 0-length
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
40
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
41 NFA_START_COLL, // [abc] start
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
42 NFA_END_COLL, // [abc] end
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
43 NFA_START_NEG_COLL, // [^abc] start
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
44 NFA_END_NEG_COLL, // [^abc] end (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
45 NFA_RANGE, // range of the two previous items
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
46 // (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
47 NFA_RANGE_MIN, // low end of a range
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
48 NFA_RANGE_MAX, // high end of a range
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
49
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
50 NFA_CONCAT, // concatenate two previous items (postfix
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
51 // only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
52 NFA_OR, // \| (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
53 NFA_STAR, // greedy * (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
54 NFA_STAR_NONGREEDY, // non-greedy * (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
55 NFA_QUEST, // greedy \? (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
56 NFA_QUEST_NONGREEDY, // non-greedy \? (postfix only)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
57
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
58 NFA_BOL, // ^ Begin line
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
59 NFA_EOL, // $ End line
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
60 NFA_BOW, // \< Begin word
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
61 NFA_EOW, // \> End word
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
62 NFA_BOF, // \%^ Begin file
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
63 NFA_EOF, // \%$ End file
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 NFA_NEWL,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
65 NFA_ZSTART, // Used for \zs
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
66 NFA_ZEND, // Used for \ze
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
67 NFA_NOPEN, // Start of subexpression marked with \%(
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
68 NFA_NCLOSE, // End of subexpr. marked with \%( ... \)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
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
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
78 NFA_END_INVISIBLE,
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
79 NFA_END_INVISIBLE_NEG,
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
80 NFA_END_PATTERN,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
81 NFA_COMPOSING, // Next nodes in NFA are part of the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
82 // composing multibyte char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
83 NFA_END_COMPOSING, // End of a composing char in the NFA
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
84 NFA_ANY_COMPOSING, // \%C: Any composing characters.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
85 NFA_OPT_CHARS, // \%[abc]
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
86
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
87 // The following are used only in the postfix form, not in the NFA
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
88 NFA_PREV_ATOM_NO_WIDTH, // Used for \@=
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
89 NFA_PREV_ATOM_NO_WIDTH_NEG, // Used for \@!
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
90 NFA_PREV_ATOM_JUST_BEFORE, // Used for \@<=
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
91 NFA_PREV_ATOM_JUST_BEFORE_NEG, // Used for \@<!
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
92 NFA_PREV_ATOM_LIKE_PATTERN, // Used for \@>
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
93
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
94 NFA_BACKREF1, // \1
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
95 NFA_BACKREF2, // \2
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
96 NFA_BACKREF3, // \3
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
97 NFA_BACKREF4, // \4
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
98 NFA_BACKREF5, // \5
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
99 NFA_BACKREF6, // \6
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
100 NFA_BACKREF7, // \7
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
101 NFA_BACKREF8, // \8
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
102 NFA_BACKREF9, // \9
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
103 #ifdef FEAT_SYN_HL
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
104 NFA_ZREF1, // \z1
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
105 NFA_ZREF2, // \z2
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
106 NFA_ZREF3, // \z3
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
107 NFA_ZREF4, // \z4
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
108 NFA_ZREF5, // \z5
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
109 NFA_ZREF6, // \z6
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
110 NFA_ZREF7, // \z7
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
111 NFA_ZREF8, // \z8
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
112 NFA_ZREF9, // \z9
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
113 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
114 NFA_SKIP, // Skip characters
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
115
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
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
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
161
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
162 // NFA_FIRST_NL
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
163 NFA_ANY, // Match any one character.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
164 NFA_IDENT, // Match identifier char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
165 NFA_SIDENT, // Match identifier char but no digit
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
166 NFA_KWORD, // Match keyword char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
167 NFA_SKWORD, // Match word char but no digit
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
168 NFA_FNAME, // Match file name char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
169 NFA_SFNAME, // Match file name char but no digit
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
170 NFA_PRINT, // Match printable char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
171 NFA_SPRINT, // Match printable char but no digit
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
172 NFA_WHITE, // Match whitespace char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
173 NFA_NWHITE, // Match non-whitespace char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
174 NFA_DIGIT, // Match digit char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
175 NFA_NDIGIT, // Match non-digit char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
176 NFA_HEX, // Match hex char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
177 NFA_NHEX, // Match non-hex char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
178 NFA_OCTAL, // Match octal char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
179 NFA_NOCTAL, // Match non-octal char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
180 NFA_WORD, // Match word char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
181 NFA_NWORD, // Match non-word char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
182 NFA_HEAD, // Match head char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
183 NFA_NHEAD, // Match non-head char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
184 NFA_ALPHA, // Match alpha char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
185 NFA_NALPHA, // Match non-alpha char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
186 NFA_LOWER, // Match lowercase char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
187 NFA_NLOWER, // Match non-lowercase char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
188 NFA_UPPER, // Match uppercase char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
189 NFA_NUPPER, // Match non-uppercase char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
190 NFA_LOWER_IC, // Match [a-z]
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
191 NFA_NLOWER_IC, // Match [^a-z]
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
192 NFA_UPPER_IC, // Match [A-Z]
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
193 NFA_NUPPER_IC, // Match [^A-Z]
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
194
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
195 NFA_FIRST_NL = NFA_ANY + NFA_ADD_NL,
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
196 NFA_LAST_NL = NFA_NUPPER_IC + NFA_ADD_NL,
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
197
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
198 NFA_CURSOR, // Match cursor pos
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
199 NFA_LNUM, // Match line number
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
200 NFA_LNUM_GT, // Match > line number
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
201 NFA_LNUM_LT, // Match < line number
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
202 NFA_COL, // Match cursor column
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
203 NFA_COL_GT, // Match > cursor column
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
204 NFA_COL_LT, // Match < cursor column
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
205 NFA_VCOL, // Match cursor virtual column
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
206 NFA_VCOL_GT, // Match > cursor virtual column
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
207 NFA_VCOL_LT, // Match < cursor virtual column
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
208 NFA_MARK, // Match mark
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
209 NFA_MARK_GT, // Match > mark
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
210 NFA_MARK_LT, // Match < mark
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
211 NFA_VISUAL, // Match Visual area
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
212
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
213 // Character classes [:alnum:] etc
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
214 NFA_CLASS_ALNUM,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
215 NFA_CLASS_ALPHA,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
216 NFA_CLASS_BLANK,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
217 NFA_CLASS_CNTRL,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
218 NFA_CLASS_DIGIT,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
219 NFA_CLASS_GRAPH,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
220 NFA_CLASS_LOWER,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
221 NFA_CLASS_PRINT,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
222 NFA_CLASS_PUNCT,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
223 NFA_CLASS_SPACE,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
224 NFA_CLASS_UPPER,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
225 NFA_CLASS_XDIGIT,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
226 NFA_CLASS_TAB,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
227 NFA_CLASS_RETURN,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
228 NFA_CLASS_BACKSPACE,
15709
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
229 NFA_CLASS_ESCAPE,
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
230 NFA_CLASS_IDENT,
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
231 NFA_CLASS_KEYWORD,
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
232 NFA_CLASS_FNAME
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
233 };
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
234
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
235 // Keep in sync with classchars.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
236 static int nfa_classcodes[] = {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
237 NFA_ANY, NFA_IDENT, NFA_SIDENT, NFA_KWORD,NFA_SKWORD,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
238 NFA_FNAME, NFA_SFNAME, NFA_PRINT, NFA_SPRINT,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
239 NFA_WHITE, NFA_NWHITE, NFA_DIGIT, NFA_NDIGIT,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
240 NFA_HEX, NFA_NHEX, NFA_OCTAL, NFA_NOCTAL,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
241 NFA_WORD, NFA_NWORD, NFA_HEAD, NFA_NHEAD,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
242 NFA_ALPHA, NFA_NALPHA, NFA_LOWER, NFA_NLOWER,
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
243 NFA_UPPER, NFA_NUPPER
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
244 };
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
245
5511
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
246 static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
247 static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
15876
0c49755f460e patch 8.1.0945: internal error when using pattern with NL in the range
Bram Moolenaar <Bram@vim.org>
parents: 15824
diff changeset
248 static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
249
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
250 // Variables only used in nfa_regcomp() and descendants.
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
251 static int nfa_re_flags; // re_flags passed to nfa_regcomp()
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
252 static int *post_start; // holds the postfix form of r.e.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
253 static int *post_end;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
254 static int *post_ptr;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
255 static int nstate; // Number of states in the NFA.
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
256 static int istate; // Index in the state vector, used in alloc_state()
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
257
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
258 // If not NULL match must end at this position
4694
efc4fb311d5d updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents: 4692
diff changeset
259 static save_se_T *nfa_endp = NULL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
260
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
261 // 0 for first call to nfa_regmatch(), 1 for recursive call.
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
262 static int nfa_ll_index = 0;
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
263
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
264 static int realloc_post_list(void);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
265 static int nfa_reg(int paren);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
266 #ifdef DEBUG
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
267 static void nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent);
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
268 #endif
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
269 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
270 static int failure_chance(nfa_state_T *state, int depth);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
271
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
272 // helper functions used when doing re2post() ... regatom() parsing
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
273 #define EMIT(c) do { \
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
274 if (post_ptr >= post_end && realloc_post_list() == FAIL) \
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
275 return FAIL; \
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
276 *post_ptr++ = c; \
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
277 } while (0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
278
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
279 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
280 * Initialize internal variables before NFA compilation.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
281 * Return OK on success, FAIL otherwise.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
282 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
283 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
284 nfa_regcomp_start(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
285 char_u *expr,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
286 int re_flags) // see vim_regcomp()
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
287 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
288 size_t postfix_size;
4555
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
289 int nstate_max;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
290
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
291 nstate = 0;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
292 istate = 0;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
293 // A reasonable estimation for maximum size
4673
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
294 nstate_max = (int)(STRLEN(expr) + 1) * 25;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
295
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
296 // Some items blow up in size, such as [A-z]. Add more space for that.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
297 // When it is still not enough realloc_post_list() will be used.
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
298 nstate_max += 1000;
4454
44b89b025cdf updated for version 7.3.975
Bram Moolenaar <bram@vim.org>
parents: 4450
diff changeset
299
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
300 // Size for postfix representation of expr.
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
301 postfix_size = sizeof(int) * nstate_max;
4454
44b89b025cdf updated for version 7.3.975
Bram Moolenaar <bram@vim.org>
parents: 4450
diff changeset
302
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
303 post_start = alloc(postfix_size);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
304 if (post_start == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
305 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
306 post_ptr = post_start;
4454
44b89b025cdf updated for version 7.3.975
Bram Moolenaar <bram@vim.org>
parents: 4450
diff changeset
307 post_end = post_start + nstate_max;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
308 rex.nfa_has_zend = FALSE;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
309 rex.nfa_has_backref = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
310
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
311 // shared with BT engine
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
312 regcomp_start(expr, re_flags);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
313
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
314 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
315 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
316
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
317 /*
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
318 * 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
319 * of the line.
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
320 */
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
321 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
322 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
323 {
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
324 nfa_state_T *p = start;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
325
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
326 if (depth > 4)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
327 return 0;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
328
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
329 while (p != NULL)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
330 {
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
331 switch (p->c)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
332 {
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
333 case NFA_BOL:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
334 case NFA_BOF:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
335 return 1; // yes!
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
336
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
337 case NFA_ZSTART:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
338 case NFA_ZEND:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
339 case NFA_CURSOR:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
340 case NFA_VISUAL:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
341
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
342 case NFA_MOPEN:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
343 case NFA_MOPEN1:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
344 case NFA_MOPEN2:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
345 case NFA_MOPEN3:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
346 case NFA_MOPEN4:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
347 case NFA_MOPEN5:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
348 case NFA_MOPEN6:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
349 case NFA_MOPEN7:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
350 case NFA_MOPEN8:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
351 case NFA_MOPEN9:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
352 case NFA_NOPEN:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
353 #ifdef FEAT_SYN_HL
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
354 case NFA_ZOPEN:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
355 case NFA_ZOPEN1:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
356 case NFA_ZOPEN2:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
357 case NFA_ZOPEN3:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
358 case NFA_ZOPEN4:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
359 case NFA_ZOPEN5:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
360 case NFA_ZOPEN6:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
361 case NFA_ZOPEN7:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
362 case NFA_ZOPEN8:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
363 case NFA_ZOPEN9:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
364 #endif
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
365 p = p->out;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
366 break;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
367
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
368 case NFA_SPLIT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
369 return nfa_get_reganch(p->out, depth + 1)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
370 && nfa_get_reganch(p->out1, depth + 1);
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 default:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
373 return 0; // noooo
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 }
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
376 return 0;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
377 }
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
378
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
379 /*
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
380 * 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
381 * at start of the match.
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
382 */
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
383 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
384 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
385 {
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
386 nfa_state_T *p = start;
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 if (depth > 4)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
389 return 0;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
390
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
391 while (p != NULL)
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 switch (p->c)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
394 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
395 // all kinds of zero-width matches
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
396 case NFA_BOL:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
397 case NFA_BOF:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
398 case NFA_BOW:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
399 case NFA_EOW:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
400 case NFA_ZSTART:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
401 case NFA_ZEND:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
402 case NFA_CURSOR:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
403 case NFA_VISUAL:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
404 case NFA_LNUM:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
405 case NFA_LNUM_GT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
406 case NFA_LNUM_LT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
407 case NFA_COL:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
408 case NFA_COL_GT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
409 case NFA_COL_LT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
410 case NFA_VCOL:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
411 case NFA_VCOL_GT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
412 case NFA_VCOL_LT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
413 case NFA_MARK:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
414 case NFA_MARK_GT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
415 case NFA_MARK_LT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
416
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
417 case NFA_MOPEN:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
418 case NFA_MOPEN1:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
419 case NFA_MOPEN2:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
420 case NFA_MOPEN3:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
421 case NFA_MOPEN4:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
422 case NFA_MOPEN5:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
423 case NFA_MOPEN6:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
424 case NFA_MOPEN7:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
425 case NFA_MOPEN8:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
426 case NFA_MOPEN9:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
427 case NFA_NOPEN:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
428 #ifdef FEAT_SYN_HL
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
429 case NFA_ZOPEN:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
430 case NFA_ZOPEN1:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
431 case NFA_ZOPEN2:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
432 case NFA_ZOPEN3:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
433 case NFA_ZOPEN4:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
434 case NFA_ZOPEN5:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
435 case NFA_ZOPEN6:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
436 case NFA_ZOPEN7:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
437 case NFA_ZOPEN8:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
438 case NFA_ZOPEN9:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
439 #endif
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
440 p = p->out;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
441 break;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
442
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
443 case NFA_SPLIT:
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
444 {
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
445 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
446 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
447
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
448 if (c1 == c2)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
449 return c1; // yes!
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
450 return 0;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
451 }
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
452
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
453 default:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
454 if (p->c > 0)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
455 return p->c; // yes!
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
456 return 0;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
457 }
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
458 }
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
459 return 0;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
460 }
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
461
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
462 /*
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
463 * 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
464 * 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
465 * regstart. Otherwise return NULL.
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
466 */
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
467 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
468 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
469 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
470 nfa_state_T *p = start;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
471 int len = 0;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
472 char_u *ret;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
473 char_u *s;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
474
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
475 if (p->c != NFA_MOPEN)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
476 return NULL; // just in case
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
477 p = p->out;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
478 while (p->c > 0)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
479 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
480 len += MB_CHAR2LEN(p->c);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
481 p = p->out;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
482 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
483 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
484 return NULL;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
485
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
486 ret = alloc(len);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
487 if (ret != NULL)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
488 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
489 p = start->out->out; // skip first char, it goes into regstart
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
490 s = ret;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
491 while (p->c > 0)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
492 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
493 if (has_mbyte)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
494 s += (*mb_char2bytes)(p->c, s);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
495 else
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
496 *s++ = p->c;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
497 p = p->out;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
498 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
499 *s = NUL;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
500 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
501 return ret;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
502 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
503
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
504 /*
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
505 * Allocate more space for post_start. Called when
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
506 * running above the estimated number of states.
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
507 */
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
508 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
509 realloc_post_list(void)
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
510 {
4667
9e7ef781d494 updated for version 7.3.1081
Bram Moolenaar <bram@vim.org>
parents: 4661
diff changeset
511 int nstate_max = (int)(post_end - post_start);
15904
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15876
diff changeset
512 int new_max;
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
513 int *new_start;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
514 int *old_start;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
515
15904
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15876
diff changeset
516 // For weird patterns the number of states can be very high. Increasing by
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15876
diff changeset
517 // 50% seems a reasonable compromise between memory use and speed.
fec4416adb80 patch 8.1.0958: compiling weird regexp pattern is very slow
Bram Moolenaar <Bram@vim.org>
parents: 15876
diff changeset
518 new_max = nstate_max * 3 / 2;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
519 new_start = ALLOC_MULT(int, new_max);
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
520 if (new_start == NULL)
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
521 return FAIL;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
522 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
523 old_start = post_start;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
524 post_start = new_start;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
525 post_ptr = new_start + (post_ptr - old_start);
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
526 post_end = post_start + new_max;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
527 vim_free(old_start);
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
528 return OK;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
529 }
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
530
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
531 /*
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
532 * Search between "start" and "end" and try to recognize a
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
533 * character class in expanded form. For example [0-9].
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
534 * On success, return the id the character class to be emitted.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
535 * On failure, return 0 (=FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
536 * Start points to the first char of the range, while end should point
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
537 * to the closing brace.
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
538 * Keep in mind that 'ignorecase' applies at execution time, thus [a-z] may
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
539 * need to be interpreted as [a-zA-Z].
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
540 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
541 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
542 nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
543 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
544 # define CLASS_not 0x80
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
545 # define CLASS_af 0x40
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
546 # define CLASS_AF 0x20
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
547 # define CLASS_az 0x10
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
548 # define CLASS_AZ 0x08
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
549 # define CLASS_o7 0x04
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
550 # define CLASS_o9 0x02
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
551 # define CLASS_underscore 0x01
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
552
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
553 int newl = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
554 char_u *p;
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
555 int config = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
556
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
557 if (extra_newl == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
558 newl = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
559
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
560 if (*end != ']')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
561 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
562 p = start;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
563 if (*p == '^')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
564 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
565 config |= CLASS_not;
4720
bd6bef0bd0fb updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents: 4718
diff changeset
566 p++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
567 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
568
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
569 while (p < end)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
570 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
571 if (p + 2 < end && *(p + 1) == '-')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
572 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
573 switch (*p)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
574 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
575 case '0':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
576 if (*(p + 2) == '9')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
577 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
578 config |= CLASS_o9;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
579 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
580 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
581 if (*(p + 2) == '7')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
582 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
583 config |= CLASS_o7;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
584 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
585 }
11469
0ade9dd85156 patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents: 11269
diff changeset
586 return FAIL;
0ade9dd85156 patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents: 11269
diff changeset
587
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
588 case 'a':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
589 if (*(p + 2) == 'z')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
590 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
591 config |= CLASS_az;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
592 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
593 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
594 if (*(p + 2) == 'f')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
595 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
596 config |= CLASS_af;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
597 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
598 }
11469
0ade9dd85156 patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents: 11269
diff changeset
599 return FAIL;
0ade9dd85156 patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents: 11269
diff changeset
600
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
601 case 'A':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
602 if (*(p + 2) == 'Z')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
603 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
604 config |= CLASS_AZ;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
605 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
606 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
607 if (*(p + 2) == 'F')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
608 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
609 config |= CLASS_AF;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
610 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
611 }
11469
0ade9dd85156 patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents: 11269
diff changeset
612 return FAIL;
0ade9dd85156 patch 8.0.0618: NFA regex engine handles [0-z] incorrectly
Christian Brabandt <cb@256bit.org>
parents: 11269
diff changeset
613
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
614 default:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
615 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
616 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
617 p += 3;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
618 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
619 else if (p + 1 < end && *p == '\\' && *(p + 1) == 'n')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
620 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
621 newl = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
622 p += 2;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
623 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
624 else if (*p == '_')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
625 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
626 config |= CLASS_underscore;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
627 p ++;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
628 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
629 else if (*p == '\n')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
630 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
631 newl = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
632 p ++;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
633 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
634 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
635 return FAIL;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
636 } // while (p < end)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
637
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
638 if (p != end)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
639 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
640
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
641 if (newl == TRUE)
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
642 extra_newl = NFA_ADD_NL;
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
643
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
644 switch (config)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
645 {
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
646 case CLASS_o9:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
647 return extra_newl + NFA_DIGIT;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
648 case CLASS_not | CLASS_o9:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
649 return extra_newl + NFA_NDIGIT;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
650 case CLASS_af | CLASS_AF | CLASS_o9:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
651 return extra_newl + NFA_HEX;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
652 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
653 return extra_newl + NFA_NHEX;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
654 case CLASS_o7:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
655 return extra_newl + NFA_OCTAL;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
656 case CLASS_not | CLASS_o7:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
657 return extra_newl + NFA_NOCTAL;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
658 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
659 return extra_newl + NFA_WORD;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
660 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
661 return extra_newl + NFA_NWORD;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
662 case CLASS_az | CLASS_AZ | CLASS_underscore:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
663 return extra_newl + NFA_HEAD;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
664 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
665 return extra_newl + NFA_NHEAD;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
666 case CLASS_az | CLASS_AZ:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
667 return extra_newl + NFA_ALPHA;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
668 case CLASS_not | CLASS_az | CLASS_AZ:
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
669 return extra_newl + NFA_NALPHA;
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
670 case CLASS_az:
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
671 return extra_newl + NFA_LOWER_IC;
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
672 case CLASS_not | CLASS_az:
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
673 return extra_newl + NFA_NLOWER_IC;
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
674 case CLASS_AZ:
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
675 return extra_newl + NFA_UPPER_IC;
4728
43de4ebbe7ad updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents: 4726
diff changeset
676 case CLASS_not | CLASS_AZ:
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
677 return extra_newl + NFA_NUPPER_IC;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
678 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
679 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
680 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
681
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
682 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
683 * Produce the bytes for equivalence class "c".
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
684 * Currently only handles latin1, latin9 and utf-8.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
685 * Emits bytes in postfix notation: 'a,b,NFA_OR,c,NFA_OR' is
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
686 * equivalent to 'a OR b OR c'
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
687 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
688 * NOTE! When changing this function, also update reg_equi_class()
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
689 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
690 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
691 nfa_emit_equi_class(int c)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
692 {
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
693 #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT);
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
694 #define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT);
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
695
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
696 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
697 || STRCMP(p_enc, "iso-8859-15") == 0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
698 {
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
699 #ifdef EBCDIC
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
700 # define A_circumflex 0x62
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
701 # define A_diaeresis 0x63
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
702 # define A_grave 0x64
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
703 # define A_acute 0x65
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
704 # define A_virguilla 0x66
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
705 # define A_ring 0x67
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
706 # define C_cedilla 0x68
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
707 # define E_acute 0x71
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
708 # define E_circumflex 0x72
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
709 # define E_diaeresis 0x73
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
710 # define E_grave 0x74
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
711 # define I_acute 0x75
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
712 # define I_circumflex 0x76
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
713 # define I_diaeresis 0x77
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
714 # define I_grave 0x78
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
715 # define N_virguilla 0x69
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
716 # define O_circumflex 0xeb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
717 # define O_diaeresis 0xec
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
718 # define O_grave 0xed
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
719 # define O_acute 0xee
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
720 # define O_virguilla 0xef
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
721 # define O_slash 0x80
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
722 # define U_circumflex 0xfb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
723 # define U_diaeresis 0xfc
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
724 # define U_grave 0xfd
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
725 # define U_acute 0xfe
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
726 # define Y_acute 0xba
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
727 # define a_grave 0x42
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
728 # define a_acute 0x43
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
729 # define a_circumflex 0x44
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
730 # define a_virguilla 0x45
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
731 # define a_diaeresis 0x46
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
732 # define a_ring 0x47
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
733 # define c_cedilla 0x48
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
734 # define e_grave 0x51
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
735 # define e_acute 0x52
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
736 # define e_circumflex 0x53
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
737 # define e_diaeresis 0x54
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
738 # define i_grave 0x55
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
739 # define i_acute 0x56
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
740 # define i_circumflex 0x57
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
741 # define i_diaeresis 0x58
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
742 # define n_virguilla 0x49
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
743 # define o_grave 0xcb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
744 # define o_acute 0xcc
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
745 # define o_circumflex 0xcd
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
746 # define o_virguilla 0xce
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
747 # define o_diaeresis 0xcf
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
748 # define o_slash 0x70
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
749 # define u_grave 0xdb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
750 # define u_acute 0xdc
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
751 # define u_circumflex 0xdd
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
752 # define u_diaeresis 0xde
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
753 # define y_acute 0x8d
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
754 # define y_diaeresis 0xdf
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
755 #else
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
756 # define A_grave 0xc0
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
757 # define A_acute 0xc1
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
758 # define A_circumflex 0xc2
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
759 # define A_virguilla 0xc3
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
760 # define A_diaeresis 0xc4
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
761 # define A_ring 0xc5
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
762 # define C_cedilla 0xc7
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
763 # define E_grave 0xc8
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
764 # define E_acute 0xc9
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
765 # define E_circumflex 0xca
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
766 # define E_diaeresis 0xcb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
767 # define I_grave 0xcc
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
768 # define I_acute 0xcd
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
769 # define I_circumflex 0xce
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
770 # define I_diaeresis 0xcf
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
771 # define N_virguilla 0xd1
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
772 # define O_grave 0xd2
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
773 # define O_acute 0xd3
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
774 # define O_circumflex 0xd4
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
775 # define O_virguilla 0xd5
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
776 # define O_diaeresis 0xd6
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
777 # define O_slash 0xd8
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
778 # define U_grave 0xd9
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
779 # define U_acute 0xda
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
780 # define U_circumflex 0xdb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
781 # define U_diaeresis 0xdc
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
782 # define Y_acute 0xdd
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
783 # define a_grave 0xe0
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
784 # define a_acute 0xe1
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
785 # define a_circumflex 0xe2
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
786 # define a_virguilla 0xe3
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
787 # define a_diaeresis 0xe4
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
788 # define a_ring 0xe5
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
789 # define c_cedilla 0xe7
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
790 # define e_grave 0xe8
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
791 # define e_acute 0xe9
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
792 # define e_circumflex 0xea
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
793 # define e_diaeresis 0xeb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
794 # define i_grave 0xec
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
795 # define i_acute 0xed
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
796 # define i_circumflex 0xee
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
797 # define i_diaeresis 0xef
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
798 # define n_virguilla 0xf1
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
799 # define o_grave 0xf2
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
800 # define o_acute 0xf3
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
801 # define o_circumflex 0xf4
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
802 # define o_virguilla 0xf5
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
803 # define o_diaeresis 0xf6
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
804 # define o_slash 0xf8
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
805 # define u_grave 0xf9
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
806 # define u_acute 0xfa
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
807 # define u_circumflex 0xfb
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
808 # define u_diaeresis 0xfc
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
809 # define y_acute 0xfd
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
810 # define y_diaeresis 0xff
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
811 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
812 switch (c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
813 {
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
814 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
815 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
816 CASEMBC(0x100) CASEMBC(0x102) CASEMBC(0x104)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
817 CASEMBC(0x1cd) CASEMBC(0x1de) CASEMBC(0x1e0)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
818 CASEMBC(0x1ea2)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
819 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
820 EMIT2(A_circumflex); EMIT2(A_virguilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
821 EMIT2(A_diaeresis); EMIT2(A_ring);
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
822 EMITMBC(0x100) EMITMBC(0x102) EMITMBC(0x104)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
823 EMITMBC(0x1cd) EMITMBC(0x1de) EMITMBC(0x1e0)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
824 EMITMBC(0x1ea2)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
825 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
826
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
827 case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
828 EMIT2('B'); EMITMBC(0x1e02) EMITMBC(0x1e06)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
829 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
830
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
831 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
832 CASEMBC(0x10a) CASEMBC(0x10c)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
833 EMIT2('C'); EMIT2(C_cedilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
834 EMITMBC(0x106) EMITMBC(0x108)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
835 EMITMBC(0x10a) EMITMBC(0x10c)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
836 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
837
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
838 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
839 CASEMBC(0x1e0e) CASEMBC(0x1e10)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
840 EMIT2('D'); EMITMBC(0x10e) EMITMBC(0x110) EMITMBC(0x1e0a)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
841 EMITMBC(0x1e0e) EMITMBC(0x1e10)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
842 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
843
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
844 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
845 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
846 CASEMBC(0x116) CASEMBC(0x118) CASEMBC(0x11a)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
847 CASEMBC(0x1eba) CASEMBC(0x1ebc)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
848 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
849 EMIT2(E_circumflex); EMIT2(E_diaeresis);
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
850 EMITMBC(0x112) EMITMBC(0x114) EMITMBC(0x116)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
851 EMITMBC(0x118) EMITMBC(0x11a) EMITMBC(0x1eba)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
852 EMITMBC(0x1ebc)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
853 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
854
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
855 case 'F': CASEMBC(0x1e1e)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
856 EMIT2('F'); EMITMBC(0x1e1e)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
857 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
858
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
859 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
860 CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
861 CASEMBC(0x1f4) CASEMBC(0x1e20)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
862 EMIT2('G'); EMITMBC(0x11c) EMITMBC(0x11e) EMITMBC(0x120)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
863 EMITMBC(0x122) EMITMBC(0x1e4) EMITMBC(0x1e6)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
864 EMITMBC(0x1f4) EMITMBC(0x1e20)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
865 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
866
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
867 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
868 CASEMBC(0x1e26) CASEMBC(0x1e28)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
869 EMIT2('H'); EMITMBC(0x124) EMITMBC(0x126) EMITMBC(0x1e22)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
870 EMITMBC(0x1e26) EMITMBC(0x1e28)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
871 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
872
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
873 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
874 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
875 CASEMBC(0x12c) CASEMBC(0x12e) CASEMBC(0x130)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
876 CASEMBC(0x1cf) CASEMBC(0x1ec8)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
877 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
878 EMIT2(I_circumflex); EMIT2(I_diaeresis);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
879 EMITMBC(0x128) EMITMBC(0x12a)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
880 EMITMBC(0x12c) EMITMBC(0x12e) EMITMBC(0x130)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
881 EMITMBC(0x1cf) EMITMBC(0x1ec8)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
882 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
883
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
884 case 'J': CASEMBC(0x134)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
885 EMIT2('J'); EMITMBC(0x134)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
886 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
887
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
888 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
889 CASEMBC(0x1e34)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
890 EMIT2('K'); EMITMBC(0x136) EMITMBC(0x1e8) EMITMBC(0x1e30)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
891 EMITMBC(0x1e34)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
892 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
893
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
894 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
895 CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
896 EMIT2('L'); EMITMBC(0x139) EMITMBC(0x13b) EMITMBC(0x13d)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
897 EMITMBC(0x13f) EMITMBC(0x141) EMITMBC(0x1e3a)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
898 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
899
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
900 case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
901 EMIT2('M'); EMITMBC(0x1e3e) EMITMBC(0x1e40)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
902 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
903
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
904 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
905 CASEMBC(0x147) CASEMBC(0x1e44) CASEMBC(0x1e48)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
906 EMIT2('N'); EMIT2(N_virguilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
907 EMITMBC(0x143) EMITMBC(0x145)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
908 EMITMBC(0x147) EMITMBC(0x1e44) EMITMBC(0x1e48)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
909 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
910
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
911 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
912 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
913 CASEMBC(0x14c) CASEMBC(0x14e) CASEMBC(0x150)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
914 CASEMBC(0x1a0) CASEMBC(0x1d1) CASEMBC(0x1ea)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
915 CASEMBC(0x1ec) CASEMBC(0x1ece)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
916 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
917 EMIT2(O_circumflex); EMIT2(O_virguilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
918 EMIT2(O_diaeresis); EMIT2(O_slash);
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
919 EMITMBC(0x14c) EMITMBC(0x14e) EMITMBC(0x150)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
920 EMITMBC(0x1a0) EMITMBC(0x1d1) EMITMBC(0x1ea)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
921 EMITMBC(0x1ec) EMITMBC(0x1ece)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
922 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
923
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
924 case 'P': case 0x1e54: case 0x1e56:
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
925 EMIT2('P'); EMITMBC(0x1e54) EMITMBC(0x1e56)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
926 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
927
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
928 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
929 CASEMBC(0x1e58) CASEMBC(0x1e5e)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
930 EMIT2('R'); EMITMBC(0x154) EMITMBC(0x156) EMITMBC(0x158)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
931 EMITMBC(0x1e58) EMITMBC(0x1e5e)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
932 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
933
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
934 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
935 CASEMBC(0x160) CASEMBC(0x1e60)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
936 EMIT2('S'); EMITMBC(0x15a) EMITMBC(0x15c) EMITMBC(0x15e)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
937 EMITMBC(0x160) EMITMBC(0x1e60)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
938 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
939
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
940 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
941 CASEMBC(0x1e6a) CASEMBC(0x1e6e)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
942 EMIT2('T'); EMITMBC(0x162) EMITMBC(0x164) EMITMBC(0x166)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
943 EMITMBC(0x1e6a) EMITMBC(0x1e6e)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
944 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
945
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
946 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
947 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
948 CASEMBC(0x16c) CASEMBC(0x16e) CASEMBC(0x170)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
949 CASEMBC(0x172) CASEMBC(0x1af) CASEMBC(0x1d3)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
950 CASEMBC(0x1ee6)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
951 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
952 EMIT2(U_diaeresis); EMIT2(U_circumflex);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
953 EMITMBC(0x168) EMITMBC(0x16a)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
954 EMITMBC(0x16c) EMITMBC(0x16e) EMITMBC(0x170)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
955 EMITMBC(0x172) EMITMBC(0x1af) EMITMBC(0x1d3)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
956 EMITMBC(0x1ee6)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
957 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
958
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
959 case 'V': CASEMBC(0x1e7c)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
960 EMIT2('V'); EMITMBC(0x1e7c)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
961 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
962
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
963 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
964 CASEMBC(0x1e84) CASEMBC(0x1e86)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
965 EMIT2('W'); EMITMBC(0x174) EMITMBC(0x1e80) EMITMBC(0x1e82)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
966 EMITMBC(0x1e84) EMITMBC(0x1e86)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
967 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
968
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
969 case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
970 EMIT2('X'); EMITMBC(0x1e8a) EMITMBC(0x1e8c)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
971 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
972
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
973 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
974 CASEMBC(0x1e8e) CASEMBC(0x1ef2) CASEMBC(0x1ef6)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
975 CASEMBC(0x1ef8)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
976 EMIT2('Y'); EMIT2(Y_acute);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
977 EMITMBC(0x176) EMITMBC(0x178)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
978 EMITMBC(0x1e8e) EMITMBC(0x1ef2) EMITMBC(0x1ef6)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
979 EMITMBC(0x1ef8)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
980 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
981
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
982 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
983 CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
984 EMIT2('Z'); EMITMBC(0x179) EMITMBC(0x17b) EMITMBC(0x17d)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
985 EMITMBC(0x1b5) EMITMBC(0x1e90) EMITMBC(0x1e94)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
986 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
987
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
988 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
989 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
990 CASEMBC(0x101) CASEMBC(0x103) CASEMBC(0x105)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
991 CASEMBC(0x1ce) CASEMBC(0x1df) CASEMBC(0x1e1)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
992 CASEMBC(0x1ea3)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
993 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
994 EMIT2(a_circumflex); EMIT2(a_virguilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
995 EMIT2(a_diaeresis); EMIT2(a_ring);
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
996 EMITMBC(0x101) EMITMBC(0x103) EMITMBC(0x105)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
997 EMITMBC(0x1ce) EMITMBC(0x1df) EMITMBC(0x1e1)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
998 EMITMBC(0x1ea3)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
999 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1000
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1001 case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1002 EMIT2('b'); EMITMBC(0x1e03) EMITMBC(0x1e07)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1003 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1004
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1005 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
1006 CASEMBC(0x10b) CASEMBC(0x10d)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1007 EMIT2('c'); EMIT2(c_cedilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1008 EMITMBC(0x107) EMITMBC(0x109)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1009 EMITMBC(0x10b) EMITMBC(0x10d)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1010 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1011
6914
94b179585851 patch 7.4.776
Bram Moolenaar <bram@vim.org>
parents: 6787
diff changeset
1012 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
1013 CASEMBC(0x1e0f) CASEMBC(0x1e11)
6914
94b179585851 patch 7.4.776
Bram Moolenaar <bram@vim.org>
parents: 6787
diff changeset
1014 EMIT2('d'); EMITMBC(0x10f) EMITMBC(0x111)
94b179585851 patch 7.4.776
Bram Moolenaar <bram@vim.org>
parents: 6787
diff changeset
1015 EMITMBC(0x1e0b) EMITMBC(0x1e0f) EMITMBC(0x1e11)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1016 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1017
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1018 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
1019 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
1020 CASEMBC(0x117) CASEMBC(0x119) CASEMBC(0x11b)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1021 CASEMBC(0x1ebb) CASEMBC(0x1ebd)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1022 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
1023 EMIT2(e_circumflex); EMIT2(e_diaeresis);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1024 EMITMBC(0x113) EMITMBC(0x115)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1025 EMITMBC(0x117) EMITMBC(0x119) EMITMBC(0x11b)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1026 EMITMBC(0x1ebb) EMITMBC(0x1ebd)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1027 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1028
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1029 case 'f': CASEMBC(0x1e1f)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1030 EMIT2('f'); EMITMBC(0x1e1f)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1031 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1032
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1033 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
1034 CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1035 CASEMBC(0x1f5) CASEMBC(0x1e21)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1036 EMIT2('g'); EMITMBC(0x11d) EMITMBC(0x11f) EMITMBC(0x121)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1037 EMITMBC(0x123) EMITMBC(0x1e5) EMITMBC(0x1e7)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1038 EMITMBC(0x1f5) EMITMBC(0x1e21)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1039 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1040
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1041 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
1042 CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1043 EMIT2('h'); EMITMBC(0x125) EMITMBC(0x127) EMITMBC(0x1e23)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1044 EMITMBC(0x1e27) EMITMBC(0x1e29) EMITMBC(0x1e96)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1045 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1046
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1047 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
1048 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
1049 CASEMBC(0x12d) CASEMBC(0x12f) CASEMBC(0x1d0)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1050 CASEMBC(0x1ec9)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1051 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
1052 EMIT2(i_circumflex); EMIT2(i_diaeresis);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1053 EMITMBC(0x129) EMITMBC(0x12b)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1054 EMITMBC(0x12d) EMITMBC(0x12f) EMITMBC(0x1d0)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1055 EMITMBC(0x1ec9)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1056 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1057
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1058 case 'j': CASEMBC(0x135) CASEMBC(0x1f0)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1059 EMIT2('j'); EMITMBC(0x135) EMITMBC(0x1f0)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1060 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1061
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1062 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
1063 CASEMBC(0x1e35)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1064 EMIT2('k'); EMITMBC(0x137) EMITMBC(0x1e9) EMITMBC(0x1e31)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1065 EMITMBC(0x1e35)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1066 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1067
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1068 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
1069 CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1070 EMIT2('l'); EMITMBC(0x13a) EMITMBC(0x13c) EMITMBC(0x13e)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1071 EMITMBC(0x140) EMITMBC(0x142) EMITMBC(0x1e3b)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1072 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1073
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1074 case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1075 EMIT2('m'); EMITMBC(0x1e3f) EMITMBC(0x1e41)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1076 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1077
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1078 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
1079 CASEMBC(0x148) CASEMBC(0x149) CASEMBC(0x1e45)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1080 CASEMBC(0x1e49)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1081 EMIT2('n'); EMIT2(n_virguilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1082 EMITMBC(0x144) EMITMBC(0x146)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1083 EMITMBC(0x148) EMITMBC(0x149) EMITMBC(0x1e45)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1084 EMITMBC(0x1e49)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1085 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1086
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1087 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
1088 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
1089 CASEMBC(0x14d) CASEMBC(0x14f) CASEMBC(0x151)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1090 CASEMBC(0x1a1) CASEMBC(0x1d2) CASEMBC(0x1eb)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1091 CASEMBC(0x1ed) CASEMBC(0x1ecf)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1092 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
1093 EMIT2(o_circumflex); EMIT2(o_virguilla);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1094 EMIT2(o_diaeresis); EMIT2(o_slash);
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1095 EMITMBC(0x14d) EMITMBC(0x14f) EMITMBC(0x151)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1096 EMITMBC(0x1a1) EMITMBC(0x1d2) EMITMBC(0x1eb)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1097 EMITMBC(0x1ed) EMITMBC(0x1ecf)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1098 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1099
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1100 case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1101 EMIT2('p'); EMITMBC(0x1e55) EMITMBC(0x1e57)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1102 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1103
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1104 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
1105 CASEMBC(0x1e59) CASEMBC(0x1e5f)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1106 EMIT2('r'); EMITMBC(0x155) EMITMBC(0x157) EMITMBC(0x159)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1107 EMITMBC(0x1e59) EMITMBC(0x1e5f)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1108 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1109
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1110 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
1111 CASEMBC(0x161) CASEMBC(0x1e61)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1112 EMIT2('s'); EMITMBC(0x15b) EMITMBC(0x15d) EMITMBC(0x15f)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1113 EMITMBC(0x161) EMITMBC(0x1e61)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1114 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1115
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1116 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
1117 CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1118 EMIT2('t'); EMITMBC(0x163) EMITMBC(0x165) EMITMBC(0x167)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1119 EMITMBC(0x1e6b) EMITMBC(0x1e6f) EMITMBC(0x1e97)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1120 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1121
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1122 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
1123 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
1124 CASEMBC(0x16d) CASEMBC(0x16f) CASEMBC(0x171)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1125 CASEMBC(0x173) CASEMBC(0x1b0) CASEMBC(0x1d4)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1126 CASEMBC(0x1ee7)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1127 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
1128 EMIT2(u_circumflex); EMIT2(u_diaeresis);
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1129 EMITMBC(0x169) EMITMBC(0x16b)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1130 EMITMBC(0x16d) EMITMBC(0x16f) EMITMBC(0x171)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1131 EMITMBC(0x173) EMITMBC(0x1b0) EMITMBC(0x1d4)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1132 EMITMBC(0x1ee7)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1133 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1134
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1135 case 'v': CASEMBC(0x1e7d)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1136 EMIT2('v'); EMITMBC(0x1e7d)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1137 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1138
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1139 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
1140 CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1141 EMIT2('w'); EMITMBC(0x175) EMITMBC(0x1e81) EMITMBC(0x1e83)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1142 EMITMBC(0x1e85) EMITMBC(0x1e87) EMITMBC(0x1e98)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1143 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1144
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1145 case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1146 EMIT2('x'); EMITMBC(0x1e8b) EMITMBC(0x1e8d)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1147 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1148
8841
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1149 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
1150 CASEMBC(0x1e8f) CASEMBC(0x1e99) CASEMBC(0x1ef3)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1151 CASEMBC(0x1ef7) CASEMBC(0x1ef9)
f196308a2813 commit https://github.com/vim/vim/commit/2a6fa564a3b5061c14ff63b8b0f12801df0b0ac2
Christian Brabandt <cb@256bit.org>
parents: 8021
diff changeset
1152 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
1153 EMITMBC(0x177)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1154 EMITMBC(0x1e8f) EMITMBC(0x1e99) EMITMBC(0x1ef3)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1155 EMITMBC(0x1ef7) EMITMBC(0x1ef9)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1156 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1157
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1158 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
1159 CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95)
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1160 EMIT2('z'); EMITMBC(0x17a) EMITMBC(0x17c) EMITMBC(0x17e)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1161 EMITMBC(0x1b6) EMITMBC(0x1e91) EMITMBC(0x1e95)
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1162 return OK;
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1163
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1164 // default: character itself
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1165 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1166 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1167
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1168 EMIT2(c);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1169 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1170 #undef EMIT2
5351
923738744a60 updated for version 7.4.028
Bram Moolenaar <bram@vim.org>
parents: 5336
diff changeset
1171 #undef EMITMBC
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1172 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1173
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1174 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1175 * Code to parse regular expression.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1176 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1177 * We try to reuse parsing functions in regexp.c to
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1178 * minimize surprise and keep the syntax consistent.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1179 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1180
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1181 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1182 * Parse the lowest level.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1183 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1184 * An atom can be one of a long list of items. Many atoms match one character
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1185 * in the text. It is often an ordinary character or a character class.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1186 * Braces can be used to make a pattern into an atom. The "\z(\)" construct
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1187 * is only for syntax highlighting.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1188 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1189 * atom ::= ordinary-atom
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1190 * or \( pattern \)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1191 * or \%( pattern \)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1192 * or \z( pattern \)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1193 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1194 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1195 nfa_regatom(void)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1196 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1197 int c;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1198 int charclass;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1199 int equiclass;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1200 int collclass;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1201 int got_coll_char;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1202 char_u *p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1203 char_u *endp;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1204 char_u *old_regparse = regparse;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1205 int extra = 0;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1206 int emit_range;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1207 int negated;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1208 int result;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1209 int startc = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1210 int endc = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1211 int oldstartc = -1;
8021
b6b4f354df23 commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
1212 int save_prev_at_start = prev_at_start;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1213
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1214 c = getchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1215 switch (c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1216 {
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1217 case NUL:
5511
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1218 EMSG_RET_FAIL(_(e_nul_found));
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1219
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1220 case Magic('^'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1221 EMIT(NFA_BOL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1222 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1223
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1224 case Magic('$'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1225 EMIT(NFA_EOL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1226 #if defined(FEAT_SYN_HL) || defined(PROTO)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1227 had_eol = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1228 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1229 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1230
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1231 case Magic('<'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1232 EMIT(NFA_BOW);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1233 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1234
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1235 case Magic('>'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1236 EMIT(NFA_EOW);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1237 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1238
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1239 case Magic('_'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1240 c = no_Magic(getchr());
5511
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1241 if (c == NUL)
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1242 EMSG_RET_FAIL(_(e_nul_found));
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1243
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1244 if (c == '^') // "\_^" is start-of-line
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1245 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1246 EMIT(NFA_BOL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1247 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1248 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1249 if (c == '$') // "\_$" is end-of-line
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1250 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1251 EMIT(NFA_EOL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1252 #if defined(FEAT_SYN_HL) || defined(PROTO)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1253 had_eol = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1254 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1255 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1256 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1257
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1258 extra = NFA_ADD_NL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1259
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1260 // "\_[" is collection plus newline
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1261 if (c == '[')
4517
9a2183bd8295 updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents: 4515
diff changeset
1262 goto collection;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1263
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1264 // "\_x" is character class plus newline
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1265 // FALLTHROUGH
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1266
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1267 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1268 * Character classes.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1269 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1270 case Magic('.'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1271 case Magic('i'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1272 case Magic('I'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1273 case Magic('k'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1274 case Magic('K'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1275 case Magic('f'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1276 case Magic('F'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1277 case Magic('p'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1278 case Magic('P'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1279 case Magic('s'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1280 case Magic('S'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1281 case Magic('d'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1282 case Magic('D'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1283 case Magic('x'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1284 case Magic('X'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1285 case Magic('o'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1286 case Magic('O'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1287 case Magic('w'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1288 case Magic('W'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1289 case Magic('h'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1290 case Magic('H'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1291 case Magic('a'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1292 case Magic('A'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1293 case Magic('l'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1294 case Magic('L'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1295 case Magic('u'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1296 case Magic('U'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1297 p = vim_strchr(classchars, no_Magic(c));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1298 if (p == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1299 {
5511
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1300 if (extra == NFA_ADD_NL)
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1301 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1302 semsg(_(e_ill_char_class), c);
5511
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1303 rc_did_emsg = TRUE;
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1304 return FAIL;
dd7d1a86b311 updated for version 7.4.104
Bram Moolenaar <bram@vim.org>
parents: 5502
diff changeset
1305 }
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1306 siemsg("INTERNAL: Unknown character class char: %d", c);
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
1307 return FAIL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1308 }
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
1309
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1310 // When '.' is followed by a composing char ignore the dot, so that
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1311 // the composing char is matched here.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1312 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr()))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1313 {
4535
45f97c349537 updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents: 4533
diff changeset
1314 old_regparse = regparse;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1315 c = getchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1316 goto nfa_do_multibyte;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1317 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1318 EMIT(nfa_classcodes[p - classchars]);
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1319 if (extra == NFA_ADD_NL)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1320 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1321 EMIT(NFA_NEWL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1322 EMIT(NFA_OR);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1323 regflags |= RF_HASNL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1324 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1325 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1326
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1327 case Magic('n'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1328 if (reg_string)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1329 // In a string "\n" matches a newline character.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1330 EMIT(NL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1331 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1332 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1333 // In buffer text "\n" matches the end of a line.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1334 EMIT(NFA_NEWL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1335 regflags |= RF_HASNL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1336 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1337 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1338
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1339 case Magic('('):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1340 if (nfa_reg(REG_PAREN) == FAIL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1341 return FAIL; // cascaded error
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1342 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1343
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1344 case Magic('|'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1345 case Magic('&'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1346 case Magic(')'):
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1347 semsg(_(e_misplaced), no_Magic(c));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1348 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1349
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1350 case Magic('='):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1351 case Magic('?'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1352 case Magic('+'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1353 case Magic('@'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1354 case Magic('*'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1355 case Magic('{'):
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1356 // these should follow an atom, not form an atom
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1357 semsg(_(e_misplaced), no_Magic(c));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1358 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1359
4714
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1360 case Magic('~'):
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1361 {
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1362 char_u *lp;
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1363
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1364 // Previous substitute pattern.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1365 // Generated as "\%(pattern\)".
4714
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1366 if (reg_prev_sub == NULL)
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1367 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1368 emsg(_(e_nopresub));
4714
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1369 return FAIL;
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1370 }
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1371 for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp))
4714
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1372 {
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1373 EMIT(PTR2CHAR(lp));
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1374 if (lp != reg_prev_sub)
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1375 EMIT(NFA_CONCAT);
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1376 }
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1377 EMIT(NFA_NOPEN);
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1378 break;
fc4d7f02ea3a updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents: 4712
diff changeset
1379 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1380
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1381 case Magic('1'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1382 case Magic('2'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1383 case Magic('3'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1384 case Magic('4'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1385 case Magic('5'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1386 case Magic('6'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1387 case Magic('7'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1388 case Magic('8'):
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1389 case Magic('9'):
11525
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1390 {
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1391 int refnum = no_Magic(c) - '1';
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1392
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1393 if (!seen_endbrace(refnum + 1))
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1394 return FAIL;
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1395 EMIT(NFA_BACKREF1 + refnum);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
1396 rex.nfa_has_backref = TRUE;
11525
14b6b79d685b patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
1397 }
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
1398 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1399
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1400 case Magic('z'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1401 c = no_Magic(getchr());
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1402 switch (c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1403 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1404 case 's':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1405 EMIT(NFA_ZSTART);
6170
3ee39fe2df7d updated for version 7.4.421
Bram Moolenaar <bram@vim.org>
parents: 5901
diff changeset
1406 if (re_mult_next("\\zs") == FAIL)
3ee39fe2df7d updated for version 7.4.421
Bram Moolenaar <bram@vim.org>
parents: 5901
diff changeset
1407 return FAIL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1408 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1409 case 'e':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1410 EMIT(NFA_ZEND);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
1411 rex.nfa_has_zend = TRUE;
6170
3ee39fe2df7d updated for version 7.4.421
Bram Moolenaar <bram@vim.org>
parents: 5901
diff changeset
1412 if (re_mult_next("\\ze") == FAIL)
3ee39fe2df7d updated for version 7.4.421
Bram Moolenaar <bram@vim.org>
parents: 5901
diff changeset
1413 return FAIL;
4569
f262fb02889d updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents: 4567
diff changeset
1414 break;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1415 #ifdef FEAT_SYN_HL
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1416 case '1':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1417 case '2':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1418 case '3':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1419 case '4':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1420 case '5':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1421 case '6':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1422 case '7':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1423 case '8':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1424 case '9':
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1425 // \z1...\z9
14161
7cac4646c552 patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents: 14159
diff changeset
1426 if ((reg_do_extmatch & REX_USE) == 0)
4688
371cc0c44097 updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents: 4686
diff changeset
1427 EMSG_RET_FAIL(_(e_z1_not_allowed));
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1428 EMIT(NFA_ZREF1 + (no_Magic(c) - '1'));
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1429 // No need to set rex.nfa_has_backref, the sub-matches don't
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1430 // change when \z1 .. \z9 matches or not.
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1431 re_has_z = REX_USE;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1432 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1433 case '(':
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1434 // \z(
14161
7cac4646c552 patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents: 14159
diff changeset
1435 if ((reg_do_extmatch & REX_SET) == 0)
4688
371cc0c44097 updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents: 4686
diff changeset
1436 EMSG_RET_FAIL(_(e_z_not_allowed));
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1437 if (nfa_reg(REG_ZPAREN) == FAIL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1438 return FAIL; // cascaded error
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1439 re_has_z = REX_SET;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1440 break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
1441 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1442 default:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1443 semsg(_("E867: (NFA) Unknown operator '\\z%c'"),
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1444 no_Magic(c));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1445 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1446 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1447 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1448
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1449 case Magic('%'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1450 c = no_Magic(getchr());
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1451 switch (c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1452 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1453 // () without a back reference
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1454 case '(':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1455 if (nfa_reg(REG_NPAREN) == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1456 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1457 EMIT(NFA_NOPEN);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1458 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1459
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1460 case 'd': // %d123 decimal
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1461 case 'o': // %o123 octal
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1462 case 'x': // %xab hex 2
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1463 case 'u': // %uabcd hex 4
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1464 case 'U': // %U1234abcd hex 8
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1465 {
12752
09c856605191 patch 8.0.1254: undefined left shift in gethexchrs()
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
1466 long nr;
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1467
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1468 switch (c)
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1469 {
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1470 case 'd': nr = getdecchrs(); break;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1471 case 'o': nr = getoctchrs(); break;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1472 case 'x': nr = gethexchrs(2); break;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1473 case 'u': nr = gethexchrs(4); break;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1474 case 'U': nr = gethexchrs(8); break;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1475 default: nr = -1; break;
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1476 }
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1477
15924
98d315176d48 patch 8.1.0968: crash when using search pattern %Ufffffc23
Bram Moolenaar <Bram@vim.org>
parents: 15904
diff changeset
1478 if (nr < 0 || nr > INT_MAX)
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1479 EMSG2_RET_FAIL(
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1480 _("E678: Invalid character after %s%%[dxouU]"),
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1481 reg_magic == MAGIC_ALL);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1482 // A NUL is stored in the text as NL
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1483 // TODO: what if a composing character follows?
5360
71e92a1cb37d updated for version 7.4.032
Bram Moolenaar <bram@vim.org>
parents: 5351
diff changeset
1484 EMIT(nr == 0 ? 0x0a : nr);
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1485 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1486 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1487
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1488 // Catch \%^ and \%$ regardless of where they appear in the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1489 // pattern -- regardless of whether or not it makes sense.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1490 case '^':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1491 EMIT(NFA_BOF);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1492 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1493
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1494 case '$':
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1495 EMIT(NFA_EOF);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1496 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1497
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1498 case '#':
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1499 EMIT(NFA_CURSOR);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1500 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1501
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1502 case 'V':
4730
749e2b2755d5 updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents: 4728
diff changeset
1503 EMIT(NFA_VISUAL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1504 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1505
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
1506 case 'C':
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
1507 EMIT(NFA_ANY_COMPOSING);
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
1508 break;
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
1509
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1510 case '[':
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1511 {
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1512 int n;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1513
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1514 // \%[abc]
4944
613651492c19 updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents: 4938
diff changeset
1515 for (n = 0; (c = peekchr()) != ']'; ++n)
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1516 {
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1517 if (c == NUL)
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1518 EMSG2_RET_FAIL(_(e_missing_sb),
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1519 reg_magic == MAGIC_ALL);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1520 // recursive call!
4944
613651492c19 updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents: 4938
diff changeset
1521 if (nfa_regatom() == FAIL)
613651492c19 updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents: 4938
diff changeset
1522 return FAIL;
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1523 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1524 getchr(); // get the ]
4760
532a9855bd30 updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents: 4758
diff changeset
1525 if (n == 0)
532a9855bd30 updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents: 4758
diff changeset
1526 EMSG2_RET_FAIL(_(e_empty_sb),
532a9855bd30 updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents: 4758
diff changeset
1527 reg_magic == MAGIC_ALL);
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1528 EMIT(NFA_OPT_CHARS);
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1529 EMIT(n);
5255
3c6e2b89875f updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents: 5253
diff changeset
1530
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1531 // Emit as "\%(\%[abc]\)" to be able to handle
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1532 // "\%[abc]*" which would cause the empty string to be
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1533 // matched an unlimited number of times. NFA_NOPEN is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1534 // added only once at a position, while NFA_SPLIT is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1535 // added multiple times. This is more efficient than
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1536 // not allowing NFA_SPLIT multiple times, it is used
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1537 // a lot.
5255
3c6e2b89875f updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents: 5253
diff changeset
1538 EMIT(NFA_NOPEN);
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1539 break;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1540 }
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
1541
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1542 default:
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1543 {
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
1544 long n = 0;
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1545 int cmp = c;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1546
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1547 if (c == '<' || c == '>')
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1548 c = getchr();
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1549 while (VIM_ISDIGIT(c))
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1550 {
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1551 n = n * 10 + (c - '0');
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1552 c = getchr();
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1553 }
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1554 if (c == 'l' || c == 'c' || c == 'v')
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1555 {
15802
f043c8931585 patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents: 15800
diff changeset
1556 int limit = INT_MAX;
f043c8931585 patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents: 15800
diff changeset
1557
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1558 if (c == 'l')
8021
b6b4f354df23 commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
1559 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1560 // \%{n}l \%{n}<l \%{n}>l
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1561 EMIT(cmp == '<' ? NFA_LNUM_LT :
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1562 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
1563 if (save_prev_at_start)
b6b4f354df23 commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
1564 at_start = TRUE;
b6b4f354df23 commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
1565 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1566 else if (c == 'c')
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1567 // \%{n}c \%{n}<c \%{n}>c
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1568 EMIT(cmp == '<' ? NFA_COL_LT :
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1569 cmp == '>' ? NFA_COL_GT : NFA_COL);
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1570 else
15802
f043c8931585 patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents: 15800
diff changeset
1571 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1572 // \%{n}v \%{n}<v \%{n}>v
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1573 EMIT(cmp == '<' ? NFA_VCOL_LT :
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1574 cmp == '>' ? NFA_VCOL_GT : NFA_VCOL);
15802
f043c8931585 patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents: 15800
diff changeset
1575 limit = INT_MAX / MB_MAXBYTES;
f043c8931585 patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents: 15800
diff changeset
1576 }
f043c8931585 patch 8.1.0908: can't handle large value for %{nr}v in regexp
Bram Moolenaar <Bram@vim.org>
parents: 15800
diff changeset
1577 if (n >= limit)
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
1578 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1579 emsg(_("E951: \\% value too large"));
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
1580 return FAIL;
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
1581 }
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
1582 EMIT((int)n);
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1583 break;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1584 }
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1585 else if (c == '\'' && n == 0)
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1586 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1587 // \%'m \%<'m \%>'m
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1588 EMIT(cmp == '<' ? NFA_MARK_LT :
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1589 cmp == '>' ? NFA_MARK_GT : NFA_MARK);
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
1590 EMIT(getchr());
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1591 break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
1592 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
1593 }
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
1594 semsg(_("E867: (NFA) Unknown operator '\\%%%c'"),
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
1595 no_Magic(c));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1596 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1597 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1598 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1599
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1600 case Magic('['):
4517
9a2183bd8295 updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents: 4515
diff changeset
1601 collection:
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1602 /*
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1603 * [abc] uses NFA_START_COLL - NFA_END_COLL
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1604 * [^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
1605 * 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
1606 * NFA_CONCAT to bind them together.
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1607 * Besides normal characters there can be:
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1608 * - character classes NFA_CLASS_*
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1609 * - ranges, two characters followed by NFA_RANGE.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1610 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1611
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1612 p = regparse;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1613 endp = skip_anyof(p);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1614 if (*endp == ']')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1615 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1616 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1617 * Try to reverse engineer character classes. For example,
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1618 * recognize that [0-9] stands for \d and [A-Za-z_] for \h,
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1619 * and perform the necessary substitutions in the NFA.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1620 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1621 result = nfa_recognize_char_class(regparse, endp,
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1622 extra == NFA_ADD_NL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1623 if (result != FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1624 {
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1625 if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1626 {
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1627 EMIT(result - NFA_ADD_NL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1628 EMIT(NFA_NEWL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1629 EMIT(NFA_OR);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1630 }
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1631 else
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1632 EMIT(result);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1633 regparse = endp;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1634 MB_PTR_ADV(regparse);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1635 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1636 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1637 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1638 * Failed to recognize a character class. Use the simple
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1639 * version that turns [abc] into 'a' OR 'b' OR 'c'
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1640 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1641 startc = endc = oldstartc = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1642 negated = FALSE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1643 if (*regparse == '^') // negated range
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1644 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1645 negated = TRUE;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1646 MB_PTR_ADV(regparse);
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1647 EMIT(NFA_START_NEG_COLL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1648 }
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1649 else
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1650 EMIT(NFA_START_COLL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1651 if (*regparse == '-')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1652 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1653 startc = '-';
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1654 EMIT(startc);
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1655 EMIT(NFA_CONCAT);
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1656 MB_PTR_ADV(regparse);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1657 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1658 // Emit the OR branches for each character in the []
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1659 emit_range = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1660 while (regparse < endp)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1661 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1662 oldstartc = startc;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1663 startc = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1664 got_coll_char = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1665 if (*regparse == '[')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1666 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1667 // Check for [: :], [= =], [. .]
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1668 equiclass = collclass = 0;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1669 charclass = get_char_class(&regparse);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1670 if (charclass == CLASS_NONE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1671 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1672 equiclass = get_equi_class(&regparse);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1673 if (equiclass == 0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1674 collclass = get_coll_element(&regparse);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1675 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1676
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1677 // Character class like [:alpha:]
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1678 if (charclass != CLASS_NONE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1679 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1680 switch (charclass)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1681 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1682 case CLASS_ALNUM:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1683 EMIT(NFA_CLASS_ALNUM);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1684 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1685 case CLASS_ALPHA:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1686 EMIT(NFA_CLASS_ALPHA);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1687 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1688 case CLASS_BLANK:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1689 EMIT(NFA_CLASS_BLANK);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1690 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1691 case CLASS_CNTRL:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1692 EMIT(NFA_CLASS_CNTRL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1693 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1694 case CLASS_DIGIT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1695 EMIT(NFA_CLASS_DIGIT);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1696 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1697 case CLASS_GRAPH:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1698 EMIT(NFA_CLASS_GRAPH);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1699 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1700 case CLASS_LOWER:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1701 EMIT(NFA_CLASS_LOWER);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1702 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1703 case CLASS_PRINT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1704 EMIT(NFA_CLASS_PRINT);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1705 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1706 case CLASS_PUNCT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1707 EMIT(NFA_CLASS_PUNCT);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1708 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1709 case CLASS_SPACE:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1710 EMIT(NFA_CLASS_SPACE);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1711 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1712 case CLASS_UPPER:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1713 EMIT(NFA_CLASS_UPPER);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1714 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1715 case CLASS_XDIGIT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1716 EMIT(NFA_CLASS_XDIGIT);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1717 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1718 case CLASS_TAB:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1719 EMIT(NFA_CLASS_TAB);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1720 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1721 case CLASS_RETURN:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1722 EMIT(NFA_CLASS_RETURN);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1723 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1724 case CLASS_BACKSPACE:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1725 EMIT(NFA_CLASS_BACKSPACE);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1726 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1727 case CLASS_ESCAPE:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1728 EMIT(NFA_CLASS_ESCAPE);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1729 break;
15709
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1730 case CLASS_IDENT:
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1731 EMIT(NFA_CLASS_IDENT);
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1732 break;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1733 case CLASS_KEYWORD:
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1734 EMIT(NFA_CLASS_KEYWORD);
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1735 break;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1736 case CLASS_FNAME:
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1737 EMIT(NFA_CLASS_FNAME);
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
1738 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1739 }
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1740 EMIT(NFA_CONCAT);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1741 continue;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1742 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1743 // Try equivalence class [=a=] and the like
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1744 if (equiclass != 0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1745 {
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1746 result = nfa_emit_equi_class(equiclass);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1747 if (result == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1748 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1749 // should never happen
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1750 EMSG_RET_FAIL(_("E868: Error building NFA with equivalence class!"));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1751 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1752 continue;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1753 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1754 // Try collating class like [. .]
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1755 if (collclass != 0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1756 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1757 startc = collclass; // allow [.a.]-x as a range
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1758 // Will emit the proper atom at the end of the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1759 // while loop.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1760 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1761 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1762 // Try a range like 'a-x' or '\t-z'. Also allows '-' as a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1763 // start character.
4677
c1622ff9ed8d updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents: 4675
diff changeset
1764 if (*regparse == '-' && oldstartc != -1)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1765 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1766 emit_range = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1767 startc = oldstartc;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1768 MB_PTR_ADV(regparse);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1769 continue; // reading the end of the range
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1770 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1771
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1772 // Now handle simple and escaped characters.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1773 // Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1774 // accepts "\t", "\e", etc., but only when the 'l' flag in
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1775 // 'cpoptions' is not included.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1776 // Posix doesn't recognize backslash at all.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1777 if (*regparse == '\\'
4744
a62695305e03 updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents: 4742
diff changeset
1778 && !reg_cpo_bsl
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1779 && regparse + 1 <= endp
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1780 && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
4744
a62695305e03 updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents: 4742
diff changeset
1781 || (!reg_cpo_lit
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1782 && vim_strchr(REGEXP_ABBR, regparse[1])
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1783 != NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1784 )
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1785 )
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1786 {
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1787 MB_PTR_ADV(regparse);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1788
4507
9dbbddb2ed10 updated for version 7.3.1001
Bram Moolenaar <bram@vim.org>
parents: 4503
diff changeset
1789 if (*regparse == 'n')
15876
0c49755f460e patch 8.1.0945: internal error when using pattern with NL in the range
Bram Moolenaar <Bram@vim.org>
parents: 15824
diff changeset
1790 startc = (reg_string || emit_range
0c49755f460e patch 8.1.0945: internal error when using pattern with NL in the range
Bram Moolenaar <Bram@vim.org>
parents: 15824
diff changeset
1791 || regparse[1] == '-') ? NL : NFA_NEWL;
16162
cd5c83115ec6 patch 8.1.1086: too many curly braces
Bram Moolenaar <Bram@vim.org>
parents: 15935
diff changeset
1792 else if (*regparse == 'd'
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1793 || *regparse == 'o'
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1794 || *regparse == 'x'
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1795 || *regparse == 'u'
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1796 || *regparse == 'U'
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1797 )
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1798 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1799 // TODO(RE) This needs more testing
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1800 startc = coll_get_char();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1801 got_coll_char = TRUE;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1802 MB_PTR_BACK(old_regparse, regparse);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1803 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1804 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1805 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1806 // \r,\t,\e,\b
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1807 startc = backslash_trans(*regparse);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1808 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1809 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1810
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1811 // Normal printable char
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1812 if (startc == -1)
4677
c1622ff9ed8d updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents: 4675
diff changeset
1813 startc = PTR2CHAR(regparse);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1814
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1815 // Previous char was '-', so this char is end of range.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1816 if (emit_range)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1817 {
4677
c1622ff9ed8d updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents: 4675
diff changeset
1818 endc = startc;
c1622ff9ed8d updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents: 4675
diff changeset
1819 startc = oldstartc;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1820 if (startc > endc)
11480
99ce30ac4226 patch 8.0.0623: error for invalid regexp is not very informative
Christian Brabandt <cb@256bit.org>
parents: 11469
diff changeset
1821 EMSG_RET_FAIL(_(e_reverse_range));
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1822
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1823 if (endc > startc + 2)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1824 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1825 // Emit a range instead of the sequence of
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1826 // individual characters.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1827 if (startc == 0)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1828 // \x00 is translated to \x0a, start at \x01.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1829 EMIT(1);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1830 else
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1831 --post_ptr; // remove NFA_CONCAT
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1832 EMIT(endc);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1833 EMIT(NFA_RANGE);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1834 EMIT(NFA_CONCAT);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1835 }
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
1836 else if (has_mbyte && ((*mb_char2len)(startc) > 1
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1837 || (*mb_char2len)(endc) > 1))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1838 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1839 // Emit the characters in the range.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1840 // "startc" was already emitted, so skip it.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1841 //
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1842 for (c = startc + 1; c <= endc; c++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1843 {
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1844 EMIT(c);
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1845 EMIT(NFA_CONCAT);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1846 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1847 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1848 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1849 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1850 #ifdef EBCDIC
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1851 int alpha_only = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1852
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1853 // for alphabetical range skip the gaps
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1854 // 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1855 if (isalpha(startc) && isalpha(endc))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1856 alpha_only = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1857 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1858 // Emit the range. "startc" was already emitted, so
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1859 // skip it.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1860 for (c = startc + 1; c <= endc; c++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1861 #ifdef EBCDIC
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1862 if (!alpha_only || isalpha(startc))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1863 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1864 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1865 EMIT(c);
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1866 EMIT(NFA_CONCAT);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1867 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1868 }
4677
c1622ff9ed8d updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents: 4675
diff changeset
1869 emit_range = FALSE;
c1622ff9ed8d updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents: 4675
diff changeset
1870 startc = -1;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1871 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1872 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1873 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1874 // This char (startc) is not part of a range. Just
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1875 // emit it.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1876 // Normally, simply emit startc. But if we get char
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1877 // code=0 from a collating char, then replace it with
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1878 // 0x0a.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1879 // This is needed to completely mimic the behaviour of
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1880 // the backtracking engine.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1881 if (startc == NFA_NEWL)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1882 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1883 // Line break can't be matched as part of the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1884 // collection, add an OR below. But not for negated
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1885 // range.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1886 if (!negated)
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1887 extra = NFA_ADD_NL;
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1888 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1889 else
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1890 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1891 if (got_coll_char == TRUE && startc == 0)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1892 EMIT(0x0a);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1893 else
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1894 EMIT(startc);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1895 EMIT(NFA_CONCAT);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1896 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1897 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1898
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1899 MB_PTR_ADV(regparse);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1900 } // while (p < endp)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1901
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1902 MB_PTR_BACK(old_regparse, regparse);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1903 if (*regparse == '-') // if last, '-' is just a char
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1904 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1905 EMIT('-');
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1906 EMIT(NFA_CONCAT);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1907 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1908
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1909 // skip the trailing ]
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1910 regparse = endp;
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10551
diff changeset
1911 MB_PTR_ADV(regparse);
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1912
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1913 // Mark end of the collection.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1914 if (negated == TRUE)
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1915 EMIT(NFA_END_NEG_COLL);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1916 else
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
1917 EMIT(NFA_END_COLL);
4615
5679b8ddd8cc updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents: 4583
diff changeset
1918
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1919 // \_[] also matches \n but it's not negated
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
1920 if (extra == NFA_ADD_NL)
4615
5679b8ddd8cc updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents: 4583
diff changeset
1921 {
5679b8ddd8cc updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents: 4583
diff changeset
1922 EMIT(reg_string ? NL : NFA_NEWL);
5679b8ddd8cc updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents: 4583
diff changeset
1923 EMIT(NFA_OR);
5679b8ddd8cc updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents: 4583
diff changeset
1924 }
5679b8ddd8cc updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents: 4583
diff changeset
1925
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1926 return OK;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1927 } // if exists closing ]
4529
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
1928
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
1929 if (reg_strict)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1930 EMSG_RET_FAIL(_(e_missingbracket));
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1931 // FALLTHROUGH
4529
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
1932
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1933 default:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1934 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1935 int plen;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1936
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1937 nfa_do_multibyte:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1938 // plen is length of current char with composing chars
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1939 if (enc_utf8 && ((*mb_char2len)(c)
11269
121d29004998 patch 8.0.0520: using a function pointer while the function is known
Christian Brabandt <cb@256bit.org>
parents: 11267
diff changeset
1940 != (plen = utfc_ptr2len(old_regparse))
4543
08ac46980953 updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents: 4541
diff changeset
1941 || utf_iscomposing(c)))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1942 {
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1943 int i = 0;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
1944
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1945 // A base character plus composing characters, or just one
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1946 // or more composing characters.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1947 // This requires creating a separate atom as if enclosing
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1948 // the characters in (), where NFA_COMPOSING is the ( and
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1949 // NFA_END_COMPOSING is the ). Note that right now we are
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1950 // building the postfix form, not the NFA itself;
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1951 // a composing char could be: a, b, c, NFA_COMPOSING
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1952 // where 'b' and 'c' are chars with codes > 256.
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1953 for (;;)
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1954 {
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1955 EMIT(c);
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1956 if (i > 0)
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1957 EMIT(NFA_CONCAT);
4529
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
1958 if ((i += utf_char2len(c)) >= plen)
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1959 break;
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1960 c = utf_ptr2char(old_regparse + i);
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1961 }
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
1962 EMIT(NFA_COMPOSING);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1963 regparse = old_regparse + plen;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1964 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1965 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1966 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1967 c = no_Magic(c);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1968 EMIT(c);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1969 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1970 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1971 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1972 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1973
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1974 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1975 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1976
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1977 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1978 * Parse something followed by possible [*+=].
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1979 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1980 * A piece is an atom, possibly followed by a multi, an indication of how many
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1981 * times the atom can be matched. Example: "a*" matches any sequence of "a"
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1982 * characters: "", "a", "aa", etc.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1983 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1984 * piece ::= atom
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1985 * or atom multi
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1986 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1987 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1988 nfa_regpiece(void)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1989 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1990 int i;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1991 int op;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1992 int ret;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1993 long minval, maxval;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
1994 int greedy = TRUE; // Braces are prefixed with '-' ?
4679
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
1995 parse_state_T old_state;
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
1996 parse_state_T new_state;
12752
09c856605191 patch 8.0.1254: undefined left shift in gethexchrs()
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
1997 long c2;
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
1998 int old_post_pos;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
1999 int my_post_start;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2000 int quest;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2001
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2002 // Save the current parse state, so that we can use it if <atom>{m,n} is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2003 // next.
4679
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
2004 save_parse_state(&old_state);
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
2005
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2006 // 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
2007 my_post_start = (int)(post_ptr - post_start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2008
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2009 ret = nfa_regatom();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2010 if (ret == FAIL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2011 return FAIL; // cascaded error
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2012
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2013 op = peekchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2014 if (re_multi_type(op) == NOT_MULTI)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2015 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2016
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2017 skipchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2018 switch (op)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2019 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2020 case Magic('*'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2021 EMIT(NFA_STAR);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2022 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2023
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2024 case Magic('+'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2025 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2026 * Trick: Normally, (a*)\+ would match the whole input "aaa". The
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2027 * first and only submatch would be "aaa". But the backtracking
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2028 * engine interprets the plus as "try matching one more time", and
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2029 * a* matches a second time at the end of the input, the empty
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2030 * string.
5255
3c6e2b89875f updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents: 5253
diff changeset
2031 * The submatch will be the empty string.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2032 *
4673
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2033 * 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
2034 * <atom>+ with <atom><atom>*
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2035 */
4679
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
2036 restore_parse_state(&old_state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2037 curchr = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2038 if (nfa_regatom() == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2039 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2040 EMIT(NFA_STAR);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2041 EMIT(NFA_CONCAT);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2042 skipchr(); // skip the \+
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2043 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2044
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2045 case Magic('@'):
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2046 c2 = getdecchrs();
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2047 op = no_Magic(getchr());
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2048 i = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2049 switch(op)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2050 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2051 case '=':
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2052 // \@=
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2053 i = NFA_PREV_ATOM_NO_WIDTH;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2054 break;
4661
0dce3d812e7a updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents: 4657
diff changeset
2055 case '!':
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2056 // \@!
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2057 i = NFA_PREV_ATOM_NO_WIDTH_NEG;
4661
0dce3d812e7a updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents: 4657
diff changeset
2058 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2059 case '<':
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2060 op = no_Magic(getchr());
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2061 if (op == '=')
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2062 // \@<=
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2063 i = NFA_PREV_ATOM_JUST_BEFORE;
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2064 else if (op == '!')
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2065 // \@<!
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2066 i = NFA_PREV_ATOM_JUST_BEFORE_NEG;
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2067 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2068 case '>':
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2069 // \@>
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
2070 i = NFA_PREV_ATOM_LIKE_PATTERN;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
2071 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2072 }
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2073 if (i == 0)
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2074 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
2075 semsg(_("E869: (NFA) Unknown operator '\\@%c'"), op);
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2076 return FAIL;
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2077 }
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2078 EMIT(i);
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2079 if (i == NFA_PREV_ATOM_JUST_BEFORE
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2080 || i == NFA_PREV_ATOM_JUST_BEFORE_NEG)
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2081 EMIT(c2);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2082 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2083
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2084 case Magic('?'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2085 case Magic('='):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2086 EMIT(NFA_QUEST);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2087 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2088
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2089 case Magic('{'):
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2090 // a{2,5} will expand to 'aaa?a?a?'
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2091 // a{-1,3} will expand to 'aa??a??', where ?? is the nongreedy
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2092 // version of '?'
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2093 // \v(ab){2,3} will expand to '(ab)(ab)(ab)?', where all the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2094 // parenthesis have the same id
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2095
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2096 greedy = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2097 c2 = peekchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2098 if (c2 == '-' || c2 == Magic('-'))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2099 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2100 skipchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2101 greedy = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2102 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2103 if (!read_limits(&minval, &maxval))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2104 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
2105
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2106 // <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2107 // <atom>*
4675
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2108 if (minval == 0 && maxval == MAX_LIMIT)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2109 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2110 if (greedy) // { { (match the braces)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2111 // \{}, \{0,}
4675
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2112 EMIT(NFA_STAR);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2113 else // { { (match the braces)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2114 // \{-}, \{-0,}
4675
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2115 EMIT(NFA_STAR_NONGREEDY);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2116 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2117 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2118
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2119 // Special case: x{0} or x{-0}
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2120 if (maxval == 0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2121 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2122 // 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
2123 post_ptr = post_start + my_post_start;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2124 // NFA_EMPTY is 0-length and works everywhere
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
2125 EMIT(NFA_EMPTY);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2126 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2127 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2128
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2129 // The engine is very inefficient (uses too many states) when the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2130 // maximum is much larger than the minimum and when the maximum is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2131 // large. Bail out if we can use the other engine.
6594
3cca9b0cc1a0 updated for version 7.4.623
Bram Moolenaar <bram@vim.org>
parents: 6592
diff changeset
2132 if ((nfa_re_flags & RE_AUTO)
10551
c3cc8b2aab6a patch 8.0.0165: ubsan warns for integer overflow
Christian Brabandt <cb@256bit.org>
parents: 10540
diff changeset
2133 && (maxval > 500 || maxval > minval + 200))
6533
bdc8e71633e4 updated for version 7.4.593
Bram Moolenaar <bram@vim.org>
parents: 6510
diff changeset
2134 return FAIL;
bdc8e71633e4 updated for version 7.4.593
Bram Moolenaar <bram@vim.org>
parents: 6510
diff changeset
2135
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2136 // Ignore previous call to nfa_regatom()
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2137 post_ptr = post_start + my_post_start;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2138 // Save parse state after the repeated atom and the \{}
4679
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
2139 save_parse_state(&new_state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2140
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2141 quest = (greedy == TRUE? NFA_QUEST : NFA_QUEST_NONGREEDY);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2142 for (i = 0; i < maxval; i++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2143 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2144 // Goto beginning of the repeated atom
4679
4d92b873acef updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents: 4677
diff changeset
2145 restore_parse_state(&old_state);
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2146 old_post_pos = (int)(post_ptr - post_start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2147 if (nfa_regatom() == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2148 return FAIL;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2149 // after "minval" times, atoms are optional
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2150 if (i + 1 > minval)
4673
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2151 {
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2152 if (maxval == MAX_LIMIT)
4675
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2153 {
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2154 if (greedy)
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2155 EMIT(NFA_STAR);
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2156 else
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2157 EMIT(NFA_STAR_NONGREEDY);
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2158 }
4673
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2159 else
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2160 EMIT(quest);
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2161 }
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2162 if (old_post_pos != my_post_start)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2163 EMIT(NFA_CONCAT);
4673
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2164 if (i + 1 > minval && maxval == MAX_LIMIT)
05d57d7c2d55 updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents: 4671
diff changeset
2165 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2166 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2167
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2168 // 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
2169 restore_parse_state(&new_state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2170 curchr = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2171
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2172 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2173
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2174
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2175 default:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2176 break;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2177 } // end switch
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2178
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2179 if (re_multi_type(peekchr()) != NOT_MULTI)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2180 // Can't have a multi follow a multi.
14163
99a96be12254 patch 8.1.0099: exclamation mark in error message not needed
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
2181 EMSG_RET_FAIL(_("E871: (NFA regexp) Can't have a multi follow a multi"));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2182
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2183 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2184 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2185
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2186 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2187 * Parse one or more pieces, concatenated. It matches a match for the
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2188 * first piece, followed by a match for the second piece, etc. Example:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2189 * "f[0-9]b", first matches "f", then a digit and then "b".
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2190 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2191 * concat ::= piece
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2192 * or piece piece
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2193 * or piece piece piece
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2194 * etc.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2195 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2196 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2197 nfa_regconcat(void)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2198 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2199 int cont = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2200 int first = TRUE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2201
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2202 while (cont)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2203 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2204 switch (peekchr())
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2205 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2206 case NUL:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2207 case Magic('|'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2208 case Magic('&'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2209 case Magic(')'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2210 cont = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2211 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2212
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2213 case Magic('Z'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2214 regflags |= RF_ICOMBINE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2215 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2216 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2217 case Magic('c'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2218 regflags |= RF_ICASE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2219 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2220 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2221 case Magic('C'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2222 regflags |= RF_NOICASE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2223 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2224 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2225 case Magic('v'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2226 reg_magic = MAGIC_ALL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2227 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2228 curchr = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2229 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2230 case Magic('m'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2231 reg_magic = MAGIC_ON;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2232 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2233 curchr = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2234 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2235 case Magic('M'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2236 reg_magic = MAGIC_OFF;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2237 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2238 curchr = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2239 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2240 case Magic('V'):
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2241 reg_magic = MAGIC_NONE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2242 skipchr_keepstart();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2243 curchr = -1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2244 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2245
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2246 default:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2247 if (nfa_regpiece() == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2248 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2249 if (first == FALSE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2250 EMIT(NFA_CONCAT);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2251 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2252 first = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2253 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2254 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2255 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2256
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2257 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2258 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2259
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2260 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2261 * Parse a branch, one or more concats, separated by "\&". It matches the
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2262 * last concat, but only if all the preceding concats also match at the same
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2263 * position. Examples:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2264 * "foobeep\&..." matches "foo" in "foobeep".
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2265 * ".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob"
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2266 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2267 * branch ::= concat
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2268 * or concat \& concat
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2269 * or concat \& concat \& concat
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2270 * etc.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2271 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2272 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2273 nfa_regbranch(void)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2274 {
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2275 int old_post_pos;
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2276
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2277 old_post_pos = (int)(post_ptr - post_start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2278
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2279 // First branch, possibly the only one
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2280 if (nfa_regconcat() == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2281 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2282
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2283 // Try next concats
13043
307f2622826f patch 8.0.1397: pattern with & following nothing gives an error
Christian Brabandt <cb@256bit.org>
parents: 12752
diff changeset
2284 while (peekchr() == Magic('&'))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2285 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2286 skipchr();
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2287 // if concat is empty do emit a node
13043
307f2622826f patch 8.0.1397: pattern with & following nothing gives an error
Christian Brabandt <cb@256bit.org>
parents: 12752
diff changeset
2288 if (old_post_pos == (int)(post_ptr - post_start))
307f2622826f patch 8.0.1397: pattern with & following nothing gives an error
Christian Brabandt <cb@256bit.org>
parents: 12752
diff changeset
2289 EMIT(NFA_EMPTY);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2290 EMIT(NFA_NOPEN);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2291 EMIT(NFA_PREV_ATOM_NO_WIDTH);
4651
f10f63aaec5c updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents: 4649
diff changeset
2292 old_post_pos = (int)(post_ptr - post_start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2293 if (nfa_regconcat() == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2294 return FAIL;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2295 // 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
2296 if (old_post_pos == (int)(post_ptr - post_start))
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
2297 EMIT(NFA_EMPTY);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2298 EMIT(NFA_CONCAT);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2299 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2300
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2301 // 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
2302 if (old_post_pos == (int)(post_ptr - post_start))
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
2303 EMIT(NFA_EMPTY);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2304
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2305 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2306 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2307
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2308 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2309 * Parse a pattern, one or more branches, separated by "\|". It matches
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2310 * anything that matches one of the branches. Example: "foo\|beep" matches
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2311 * "foo" and matches "beep". If more than one branch matches, the first one
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2312 * is used.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2313 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2314 * pattern ::= branch
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2315 * or branch \| branch
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2316 * or branch \| branch \| branch
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2317 * etc.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2318 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2319 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2320 nfa_reg(
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2321 int paren) // REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2322 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2323 int parno = 0;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2324
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2325 if (paren == REG_PAREN)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2326 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2327 if (regnpar >= NSUBEXP) // Too many `('
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2328 EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('"));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2329 parno = regnpar++;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2330 }
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2331 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2332 else if (paren == REG_ZPAREN)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2333 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2334 // Make a ZOPEN node.
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2335 if (regnzpar >= NSUBEXP)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2336 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
2337 parno = regnzpar++;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2338 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2339 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2340
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2341 if (nfa_regbranch() == FAIL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2342 return FAIL; // cascaded error
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2343
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2344 while (peekchr() == Magic('|'))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2345 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2346 skipchr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2347 if (nfa_regbranch() == FAIL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2348 return FAIL; // cascaded error
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2349 EMIT(NFA_OR);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2350 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2351
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2352 // Check for proper termination.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2353 if (paren != REG_NOPAREN && getchr() != Magic(')'))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2354 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2355 if (paren == REG_NPAREN)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2356 EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2357 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2358 EMSG2_RET_FAIL(_(e_unmatchedp), reg_magic == MAGIC_ALL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2359 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2360 else if (paren == REG_NOPAREN && peekchr() != NUL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2361 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2362 if (peekchr() == Magic(')'))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2363 EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2364 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2365 EMSG_RET_FAIL(_("E873: (NFA regexp) proper termination error"));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2366 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2367 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2368 * Here we set the flag allowing back references to this set of
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2369 * parentheses.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2370 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2371 if (paren == REG_PAREN)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2372 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2373 had_endbrace[parno] = TRUE; // have seen the close paren
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2374 EMIT(NFA_MOPEN + parno);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2375 }
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2376 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2377 else if (paren == REG_ZPAREN)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2378 EMIT(NFA_ZOPEN + parno);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2379 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2380
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2381 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2382 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2383
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2384 #ifdef DEBUG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2385 static char_u code[50];
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2386
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2387 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2388 nfa_set_code(int c)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2389 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2390 int addnl = FALSE;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2391
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2392 if (c >= NFA_FIRST_NL && c <= NFA_LAST_NL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2393 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2394 addnl = TRUE;
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
2395 c -= NFA_ADD_NL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2396 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2397
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2398 STRCPY(code, "");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2399 switch (c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2400 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2401 case NFA_MATCH: STRCPY(code, "NFA_MATCH "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2402 case NFA_SPLIT: STRCPY(code, "NFA_SPLIT "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2403 case NFA_CONCAT: STRCPY(code, "NFA_CONCAT "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2404 case NFA_NEWL: STRCPY(code, "NFA_NEWL "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2405 case NFA_ZSTART: STRCPY(code, "NFA_ZSTART"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2406 case NFA_ZEND: STRCPY(code, "NFA_ZEND"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2407
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2408 case NFA_BACKREF1: STRCPY(code, "NFA_BACKREF1"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2409 case NFA_BACKREF2: STRCPY(code, "NFA_BACKREF2"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2410 case NFA_BACKREF3: STRCPY(code, "NFA_BACKREF3"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2411 case NFA_BACKREF4: STRCPY(code, "NFA_BACKREF4"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2412 case NFA_BACKREF5: STRCPY(code, "NFA_BACKREF5"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2413 case NFA_BACKREF6: STRCPY(code, "NFA_BACKREF6"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2414 case NFA_BACKREF7: STRCPY(code, "NFA_BACKREF7"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2415 case NFA_BACKREF8: STRCPY(code, "NFA_BACKREF8"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2416 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
2417 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2418 case NFA_ZREF1: STRCPY(code, "NFA_ZREF1"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2419 case NFA_ZREF2: STRCPY(code, "NFA_ZREF2"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2420 case NFA_ZREF3: STRCPY(code, "NFA_ZREF3"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2421 case NFA_ZREF4: STRCPY(code, "NFA_ZREF4"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2422 case NFA_ZREF5: STRCPY(code, "NFA_ZREF5"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2423 case NFA_ZREF6: STRCPY(code, "NFA_ZREF6"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2424 case NFA_ZREF7: STRCPY(code, "NFA_ZREF7"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2425 case NFA_ZREF8: STRCPY(code, "NFA_ZREF8"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2426 case NFA_ZREF9: STRCPY(code, "NFA_ZREF9"); break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2427 #endif
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2428 case NFA_SKIP: STRCPY(code, "NFA_SKIP"); break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
2429
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2430 case NFA_PREV_ATOM_NO_WIDTH:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2431 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
2432 case NFA_PREV_ATOM_NO_WIDTH_NEG:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
2433 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
2434 case NFA_PREV_ATOM_JUST_BEFORE:
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2435 STRCPY(code, "NFA_PREV_ATOM_JUST_BEFORE"); break;
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2436 case NFA_PREV_ATOM_JUST_BEFORE_NEG:
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2437 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
2438 case NFA_PREV_ATOM_LIKE_PATTERN:
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
2439 STRCPY(code, "NFA_PREV_ATOM_LIKE_PATTERN"); break;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
2440
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
2441 case NFA_NOPEN: STRCPY(code, "NFA_NOPEN"); break;
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
2442 case NFA_NCLOSE: STRCPY(code, "NFA_NCLOSE"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2443 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
2444 case NFA_START_INVISIBLE_FIRST:
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
2445 STRCPY(code, "NFA_START_INVISIBLE_FIRST"); break;
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
2446 case NFA_START_INVISIBLE_NEG:
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
2447 STRCPY(code, "NFA_START_INVISIBLE_NEG"); break;
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
2448 case NFA_START_INVISIBLE_NEG_FIRST:
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
2449 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
2450 case NFA_START_INVISIBLE_BEFORE:
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
2451 STRCPY(code, "NFA_START_INVISIBLE_BEFORE"); break;
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
2452 case NFA_START_INVISIBLE_BEFORE_FIRST:
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
2453 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
2454 case NFA_START_INVISIBLE_BEFORE_NEG:
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
2455 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
2456 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST:
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
2457 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
2458 case NFA_START_PATTERN: STRCPY(code, "NFA_START_PATTERN"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2459 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
2460 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
2461 case NFA_END_PATTERN: STRCPY(code, "NFA_END_PATTERN"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2462
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2463 case NFA_COMPOSING: STRCPY(code, "NFA_COMPOSING"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2464 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
2465 case NFA_OPT_CHARS: STRCPY(code, "NFA_OPT_CHARS"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2466
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2467 case NFA_MOPEN:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2468 case NFA_MOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2469 case NFA_MOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2470 case NFA_MOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2471 case NFA_MOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2472 case NFA_MOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2473 case NFA_MOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2474 case NFA_MOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2475 case NFA_MOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2476 case NFA_MOPEN9:
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2477 STRCPY(code, "NFA_MOPEN(x)");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2478 code[10] = c - NFA_MOPEN + '0';
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2479 break;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2480 case NFA_MCLOSE:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2481 case NFA_MCLOSE1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2482 case NFA_MCLOSE2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2483 case NFA_MCLOSE3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2484 case NFA_MCLOSE4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2485 case NFA_MCLOSE5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2486 case NFA_MCLOSE6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2487 case NFA_MCLOSE7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2488 case NFA_MCLOSE8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2489 case NFA_MCLOSE9:
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2490 STRCPY(code, "NFA_MCLOSE(x)");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2491 code[11] = c - NFA_MCLOSE + '0';
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2492 break;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2493 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2494 case NFA_ZOPEN:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2495 case NFA_ZOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2496 case NFA_ZOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2497 case NFA_ZOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2498 case NFA_ZOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2499 case NFA_ZOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2500 case NFA_ZOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2501 case NFA_ZOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2502 case NFA_ZOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2503 case NFA_ZOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2504 STRCPY(code, "NFA_ZOPEN(x)");
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2505 code[10] = c - NFA_ZOPEN + '0';
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2506 break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2507 case NFA_ZCLOSE:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2508 case NFA_ZCLOSE1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2509 case NFA_ZCLOSE2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2510 case NFA_ZCLOSE3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2511 case NFA_ZCLOSE4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2512 case NFA_ZCLOSE5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2513 case NFA_ZCLOSE6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2514 case NFA_ZCLOSE7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2515 case NFA_ZCLOSE8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2516 case NFA_ZCLOSE9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2517 STRCPY(code, "NFA_ZCLOSE(x)");
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2518 code[11] = c - NFA_ZCLOSE + '0';
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2519 break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
2520 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2521 case NFA_EOL: STRCPY(code, "NFA_EOL "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2522 case NFA_BOL: STRCPY(code, "NFA_BOL "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2523 case NFA_EOW: STRCPY(code, "NFA_EOW "); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2524 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
2525 case NFA_EOF: STRCPY(code, "NFA_EOF "); break;
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
2526 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
2527 case NFA_LNUM: STRCPY(code, "NFA_LNUM "); break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
2528 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
2529 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
2530 case NFA_COL: STRCPY(code, "NFA_COL "); break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
2531 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
2532 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
2533 case NFA_VCOL: STRCPY(code, "NFA_VCOL "); break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
2534 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
2535 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
2536 case NFA_MARK: STRCPY(code, "NFA_MARK "); break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
2537 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
2538 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
2539 case NFA_CURSOR: STRCPY(code, "NFA_CURSOR "); break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
2540 case NFA_VISUAL: STRCPY(code, "NFA_VISUAL "); break;
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
2541 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
2542
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2543 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
2544 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
2545 case NFA_QUEST: STRCPY(code, "NFA_QUEST"); break;
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
2546 case NFA_QUEST_NONGREEDY: STRCPY(code, "NFA_QUEST_NON_GREEDY"); break;
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
2547 case NFA_EMPTY: STRCPY(code, "NFA_EMPTY"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2548 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
2549
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
2550 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
2551 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
2552 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
2553 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
2554 case NFA_RANGE: STRCPY(code, "NFA_RANGE"); break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
2555 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
2556 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
2557
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2558 case NFA_CLASS_ALNUM: STRCPY(code, "NFA_CLASS_ALNUM"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2559 case NFA_CLASS_ALPHA: STRCPY(code, "NFA_CLASS_ALPHA"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2560 case NFA_CLASS_BLANK: STRCPY(code, "NFA_CLASS_BLANK"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2561 case NFA_CLASS_CNTRL: STRCPY(code, "NFA_CLASS_CNTRL"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2562 case NFA_CLASS_DIGIT: STRCPY(code, "NFA_CLASS_DIGIT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2563 case NFA_CLASS_GRAPH: STRCPY(code, "NFA_CLASS_GRAPH"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2564 case NFA_CLASS_LOWER: STRCPY(code, "NFA_CLASS_LOWER"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2565 case NFA_CLASS_PRINT: STRCPY(code, "NFA_CLASS_PRINT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2566 case NFA_CLASS_PUNCT: STRCPY(code, "NFA_CLASS_PUNCT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2567 case NFA_CLASS_SPACE: STRCPY(code, "NFA_CLASS_SPACE"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2568 case NFA_CLASS_UPPER: STRCPY(code, "NFA_CLASS_UPPER"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2569 case NFA_CLASS_XDIGIT: STRCPY(code, "NFA_CLASS_XDIGIT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2570 case NFA_CLASS_TAB: STRCPY(code, "NFA_CLASS_TAB"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2571 case NFA_CLASS_RETURN: STRCPY(code, "NFA_CLASS_RETURN"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2572 case NFA_CLASS_BACKSPACE: STRCPY(code, "NFA_CLASS_BACKSPACE"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2573 case NFA_CLASS_ESCAPE: STRCPY(code, "NFA_CLASS_ESCAPE"); break;
15709
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
2574 case NFA_CLASS_IDENT: STRCPY(code, "NFA_CLASS_IDENT"); break;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
2575 case NFA_CLASS_KEYWORD: STRCPY(code, "NFA_CLASS_KEYWORD"); break;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
2576 case NFA_CLASS_FNAME: STRCPY(code, "NFA_CLASS_FNAME"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2577
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2578 case NFA_ANY: STRCPY(code, "NFA_ANY"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2579 case NFA_IDENT: STRCPY(code, "NFA_IDENT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2580 case NFA_SIDENT:STRCPY(code, "NFA_SIDENT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2581 case NFA_KWORD: STRCPY(code, "NFA_KWORD"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2582 case NFA_SKWORD:STRCPY(code, "NFA_SKWORD"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2583 case NFA_FNAME: STRCPY(code, "NFA_FNAME"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2584 case NFA_SFNAME:STRCPY(code, "NFA_SFNAME"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2585 case NFA_PRINT: STRCPY(code, "NFA_PRINT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2586 case NFA_SPRINT:STRCPY(code, "NFA_SPRINT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2587 case NFA_WHITE: STRCPY(code, "NFA_WHITE"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2588 case NFA_NWHITE:STRCPY(code, "NFA_NWHITE"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2589 case NFA_DIGIT: STRCPY(code, "NFA_DIGIT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2590 case NFA_NDIGIT:STRCPY(code, "NFA_NDIGIT"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2591 case NFA_HEX: STRCPY(code, "NFA_HEX"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2592 case NFA_NHEX: STRCPY(code, "NFA_NHEX"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2593 case NFA_OCTAL: STRCPY(code, "NFA_OCTAL"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2594 case NFA_NOCTAL:STRCPY(code, "NFA_NOCTAL"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2595 case NFA_WORD: STRCPY(code, "NFA_WORD"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2596 case NFA_NWORD: STRCPY(code, "NFA_NWORD"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2597 case NFA_HEAD: STRCPY(code, "NFA_HEAD"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2598 case NFA_NHEAD: STRCPY(code, "NFA_NHEAD"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2599 case NFA_ALPHA: STRCPY(code, "NFA_ALPHA"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2600 case NFA_NALPHA:STRCPY(code, "NFA_NALPHA"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2601 case NFA_LOWER: STRCPY(code, "NFA_LOWER"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2602 case NFA_NLOWER:STRCPY(code, "NFA_NLOWER"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2603 case NFA_UPPER: STRCPY(code, "NFA_UPPER"); break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2604 case NFA_NUPPER:STRCPY(code, "NFA_NUPPER"); break;
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
2605 case NFA_LOWER_IC: STRCPY(code, "NFA_LOWER_IC"); break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
2606 case NFA_NLOWER_IC: STRCPY(code, "NFA_NLOWER_IC"); break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
2607 case NFA_UPPER_IC: STRCPY(code, "NFA_UPPER_IC"); break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
2608 case NFA_NUPPER_IC: STRCPY(code, "NFA_NUPPER_IC"); break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2609
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2610 default:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2611 STRCPY(code, "CHAR(x)");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2612 code[5] = c;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2613 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2614
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2615 if (addnl == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2616 STRCAT(code, " + NEWLINE ");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2617
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2618 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2619
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2620 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2621 static FILE *log_fd;
14145
1cf832945469 patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents: 14121
diff changeset
2622 static char_u e_log_open_failed[] = N_("Could not open temporary log file for writing, displaying on stderr... ");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2623
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2624 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2625 * Print the postfix notation of the current regexp.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2626 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2627 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2628 nfa_postfix_dump(char_u *expr, int retval)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2629 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2630 int *p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2631 FILE *f;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2632
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
2633 f = fopen(NFA_REGEXP_DUMP_LOG, "a");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2634 if (f != NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2635 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2636 fprintf(f, "\n-------------------------\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2637 if (retval == FAIL)
14145
1cf832945469 patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents: 14121
diff changeset
2638 fprintf(f, ">>> NFA engine failed... \n");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2639 else if (retval == OK)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2640 fprintf(f, ">>> NFA engine succeeded !\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2641 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
2642 for (p = post_start; *p && p < post_ptr; p++)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2643 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2644 nfa_set_code(*p);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2645 fprintf(f, "%s, ", code);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2646 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2647 fprintf(f, "\"\nPostfix notation (int): ");
5255
3c6e2b89875f updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents: 5253
diff changeset
2648 for (p = post_start; *p && p < post_ptr; p++)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2649 fprintf(f, "%d ", *p);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2650 fprintf(f, "\n\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2651 fclose(f);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2652 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2653 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2654
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2655 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2656 * Print the NFA starting with a root node "state".
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2657 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2658 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2659 nfa_print_state(FILE *debugf, nfa_state_T *state)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2660 {
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2661 garray_T indent;
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2662
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2663 ga_init2(&indent, 1, 64);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2664 ga_append(&indent, '\0');
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2665 nfa_print_state2(debugf, state, &indent);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2666 ga_clear(&indent);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2667 }
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2668
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2669 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2670 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
2671 {
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2672 char_u *p;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2673
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2674 if (state == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2675 return;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2676
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2677 fprintf(debugf, "(%2d)", abs(state->id));
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2678
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2679 // Output indent
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2680 p = (char_u *)indent->ga_data;
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2681 if (indent->ga_len >= 3)
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2682 {
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2683 int last = indent->ga_len - 3;
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2684 char_u save[2];
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2685
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2686 STRNCPY(save, &p[last], 2);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2687 STRNCPY(&p[last], "+-", 2);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2688 fprintf(debugf, " %s", p);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2689 STRNCPY(&p[last], save, 2);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2690 }
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2691 else
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2692 fprintf(debugf, " %s", p);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2693
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2694 nfa_set_code(state->c);
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
2695 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
2696 code,
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
2697 state->c,
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
2698 abs(state->id),
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
2699 state->val);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2700 if (state->id < 0)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2701 return;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2702
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2703 state->id = abs(state->id) * -1;
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2704
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2705 // grow indent for state->out
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2706 indent->ga_len -= 1;
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2707 if (state->out1)
4537
5cc98a5898cf updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents: 4535
diff changeset
2708 ga_concat(indent, (char_u *)"| ");
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2709 else
4537
5cc98a5898cf updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents: 4535
diff changeset
2710 ga_concat(indent, (char_u *)" ");
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2711 ga_append(indent, '\0');
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2712
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2713 nfa_print_state2(debugf, state->out, indent);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2714
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2715 // replace last part of indent for state->out1
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2716 indent->ga_len -= 3;
4537
5cc98a5898cf updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents: 4535
diff changeset
2717 ga_concat(indent, (char_u *)" ");
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2718 ga_append(indent, '\0');
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 nfa_print_state2(debugf, state->out1, indent);
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2721
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2722 // shrink indent
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2723 indent->ga_len -= 3;
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2724 ga_append(indent, '\0');
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2725 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2726
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2727 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2728 * Print the NFA state machine.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2729 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2730 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2731 nfa_dump(nfa_regprog_T *prog)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2732 {
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
2733 FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2734
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2735 if (debugf != NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2736 {
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
2737 nfa_print_state(debugf, prog->start);
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
2738
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2739 if (prog->reganch)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2740 fprintf(debugf, "reganch: %d\n", prog->reganch);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2741 if (prog->regstart != NUL)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2742 fprintf(debugf, "regstart: %c (decimal: %d)\n",
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2743 prog->regstart, prog->regstart);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2744 if (prog->match_text != NULL)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
2745 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
2746
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2747 fclose(debugf);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2748 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2749 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2750 #endif // ENABLE_LOG
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2751 #endif // DEBUG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2752
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2753 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2754 * Parse r.e. @expr and convert it into postfix form.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2755 * Return the postfix string on success, NULL otherwise.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2756 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2757 static int *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2758 re2post(void)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2759 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2760 if (nfa_reg(REG_NOPAREN) == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2761 return NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2762 EMIT(NFA_MOPEN);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2763 return post_start;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2764 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2765
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2766 // NB. Some of the code below is inspired by Russ's.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2767
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2768 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2769 * Represents an NFA state plus zero or one or two arrows exiting.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2770 * if c == MATCH, no arrows out; matching state.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2771 * If c == SPLIT, unlabeled arrows to out and out1 (if != NULL).
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2772 * If c < 256, labeled arrow with character c to out.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2773 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2774
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2775 static nfa_state_T *state_ptr; // points to nfa_prog->state
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2776
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2777 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2778 * Allocate and initialize nfa_state_T.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2779 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2780 static nfa_state_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2781 alloc_state(int c, nfa_state_T *out, nfa_state_T *out1)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2782 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2783 nfa_state_T *s;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2784
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2785 if (istate >= nstate)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2786 return NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2787
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2788 s = &state_ptr[istate++];
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2789
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2790 s->c = c;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2791 s->out = out;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2792 s->out1 = out1;
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
2793 s->val = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2794
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2795 s->id = istate;
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
2796 s->lastlist[0] = 0;
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
2797 s->lastlist[1] = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2798
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2799 return s;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2800 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2801
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2802 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2803 * A partially built NFA without the matching state filled in.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2804 * Frag_T.start points at the start state.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2805 * Frag_T.out is a list of places that need to be set to the
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2806 * next state for this fragment.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2807 */
4555
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2808
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2809 // Since the out pointers in the list are always
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2810 // uninitialized, we use the pointers themselves
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2811 // as storage for the Ptrlists.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2812 typedef union Ptrlist Ptrlist;
4555
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2813 union Ptrlist
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2814 {
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2815 Ptrlist *next;
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2816 nfa_state_T *s;
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2817 };
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2818
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2819 struct Frag
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2820 {
4555
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
2821 nfa_state_T *start;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2822 Ptrlist *out;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2823 };
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2824 typedef struct Frag Frag_T;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2825
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2826 /*
4456
015a8fabf900 updated for version 7.3.976
Bram Moolenaar <bram@vim.org>
parents: 4454
diff changeset
2827 * Initialize a Frag_T struct and return it.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2828 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2829 static Frag_T
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2830 frag(nfa_state_T *start, Ptrlist *out)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2831 {
4456
015a8fabf900 updated for version 7.3.976
Bram Moolenaar <bram@vim.org>
parents: 4454
diff changeset
2832 Frag_T n;
015a8fabf900 updated for version 7.3.976
Bram Moolenaar <bram@vim.org>
parents: 4454
diff changeset
2833
015a8fabf900 updated for version 7.3.976
Bram Moolenaar <bram@vim.org>
parents: 4454
diff changeset
2834 n.start = start;
015a8fabf900 updated for version 7.3.976
Bram Moolenaar <bram@vim.org>
parents: 4454
diff changeset
2835 n.out = out;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2836 return n;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2837 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2838
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2839 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2840 * Create singleton list containing just outp.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2841 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2842 static Ptrlist *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2843 list1(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2844 nfa_state_T **outp)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2845 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2846 Ptrlist *l;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2847
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2848 l = (Ptrlist *)outp;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2849 l->next = NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2850 return l;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2851 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2852
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2853 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2854 * Patch the list of states at out to point to start.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2855 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2856 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2857 patch(Ptrlist *l, nfa_state_T *s)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2858 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2859 Ptrlist *next;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2860
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2861 for (; l; l = next)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2862 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2863 next = l->next;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2864 l->s = s;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2865 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2866 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2867
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2868
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2869 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2870 * Join the two lists l1 and l2, returning the combination.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2871 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2872 static Ptrlist *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2873 append(Ptrlist *l1, Ptrlist *l2)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2874 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2875 Ptrlist *oldl1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2876
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2877 oldl1 = l1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2878 while (l1->next)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2879 l1 = l1->next;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2880 l1->next = l2;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2881 return oldl1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2882 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2883
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2884 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2885 * Stack used for transforming postfix form into NFA.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2886 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2887 static Frag_T empty;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2888
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2889 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2890 st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2891 {
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
2892 #ifdef NFA_REGEXP_ERROR_LOG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2893 FILE *df;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2894 int *p2;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2895
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
2896 df = fopen(NFA_REGEXP_ERROR_LOG, "a");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2897 if (df)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2898 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2899 fprintf(df, "Error popping the stack!\n");
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
2900 # ifdef DEBUG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2901 fprintf(df, "Current regexp is \"%s\"\n", nfa_regengine.expr);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
2902 # endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2903 fprintf(df, "Postfix form is: ");
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
2904 # ifdef DEBUG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2905 for (p2 = postfix; p2 < end; p2++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2906 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2907 nfa_set_code(*p2);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2908 fprintf(df, "%s, ", code);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2909 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2910 nfa_set_code(*p);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2911 fprintf(df, "\nCurrent position is: ");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2912 for (p2 = postfix; p2 <= p; p2 ++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2913 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2914 nfa_set_code(*p2);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2915 fprintf(df, "%s, ", code);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2916 }
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
2917 # else
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2918 for (p2 = postfix; p2 < end; p2++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2919 fprintf(df, "%d, ", *p2);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2920 fprintf(df, "\nCurrent position is: ");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2921 for (p2 = postfix; p2 <= p; p2 ++)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2922 fprintf(df, "%d, ", *p2);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
2923 # endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2924 fprintf(df, "\n--------------------------\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2925 fclose(df);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2926 }
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
2927 #endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
2928 emsg(_("E874: (NFA) Could not pop the stack!"));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2929 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2930
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2931 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2932 * Push an item onto the stack.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2933 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2934 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2935 st_push(Frag_T s, Frag_T **p, Frag_T *stack_end)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2936 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2937 Frag_T *stackp = *p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2938
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2939 if (stackp >= stack_end)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2940 return;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2941 *stackp = s;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2942 *p = *p + 1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2943 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2944
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2945 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2946 * Pop an item from the stack.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2947 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2948 static Frag_T
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2949 st_pop(Frag_T **p, Frag_T *stack)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2950 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2951 Frag_T *stackp;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2952
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2953 *p = *p - 1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2954 stackp = *p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2955 if (stackp < stack)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2956 return empty;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2957 return **p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2958 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2959
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2960 /*
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2961 * 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
2962 * When unknown or unlimited return -1.
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2963 */
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2964 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2965 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
2966 {
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2967 int l, r;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2968 nfa_state_T *state = startstate;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2969 int len = 0;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2970
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2971 // detect looping in a NFA_SPLIT
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2972 if (depth > 4)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2973 return -1;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2974
4958
0a379dea13c9 updated for version 7.3.1224
Bram Moolenaar <bram@vim.org>
parents: 4944
diff changeset
2975 while (state != NULL)
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2976 {
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2977 switch (state->c)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2978 {
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2979 case NFA_END_INVISIBLE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2980 case NFA_END_INVISIBLE_NEG:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2981 // the end, return what we have
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2982 return len;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2983
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2984 case NFA_SPLIT:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2985 // two alternatives, use the maximum
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2986 l = nfa_max_width(state->out, depth + 1);
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2987 r = nfa_max_width(state->out1, depth + 1);
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2988 if (l < 0 || r < 0)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2989 return -1;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2990 return len + (l > r ? l : r);
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2991
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2992 case NFA_ANY:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2993 case NFA_START_COLL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2994 case NFA_START_NEG_COLL:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
2995 // matches some character, including composing chars
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2996 if (enc_utf8)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2997 len += MB_MAXBYTES;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2998 else if (has_mbyte)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
2999 len += 2;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3000 else
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3001 ++len;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3002 if (state->c != NFA_ANY)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3003 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3004 // skip over the characters
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3005 state = state->out1->out;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3006 continue;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3007 }
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3008 break;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3009
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3010 case NFA_DIGIT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3011 case NFA_WHITE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3012 case NFA_HEX:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3013 case NFA_OCTAL:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3014 // ascii
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3015 ++len;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3016 break;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3017
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3018 case NFA_IDENT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3019 case NFA_SIDENT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3020 case NFA_KWORD:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3021 case NFA_SKWORD:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3022 case NFA_FNAME:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3023 case NFA_SFNAME:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3024 case NFA_PRINT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3025 case NFA_SPRINT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3026 case NFA_NWHITE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3027 case NFA_NDIGIT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3028 case NFA_NHEX:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3029 case NFA_NOCTAL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3030 case NFA_WORD:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3031 case NFA_NWORD:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3032 case NFA_HEAD:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3033 case NFA_NHEAD:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3034 case NFA_ALPHA:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3035 case NFA_NALPHA:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3036 case NFA_LOWER:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3037 case NFA_NLOWER:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3038 case NFA_UPPER:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3039 case NFA_NUPPER:
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
3040 case NFA_LOWER_IC:
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
3041 case NFA_NLOWER_IC:
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
3042 case NFA_UPPER_IC:
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
3043 case NFA_NUPPER_IC:
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
3044 case NFA_ANY_COMPOSING:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3045 // possibly non-ascii
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3046 if (has_mbyte)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3047 len += 3;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3048 else
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3049 ++len;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3050 break;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3051
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3052 case NFA_START_INVISIBLE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3053 case NFA_START_INVISIBLE_NEG:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3054 case NFA_START_INVISIBLE_BEFORE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3055 case NFA_START_INVISIBLE_BEFORE_NEG:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3056 // zero-width, out1 points to the END state
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3057 state = state->out1->out;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3058 continue;
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_BACKREF1:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3061 case NFA_BACKREF2:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3062 case NFA_BACKREF3:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3063 case NFA_BACKREF4:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3064 case NFA_BACKREF5:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3065 case NFA_BACKREF6:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3066 case NFA_BACKREF7:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3067 case NFA_BACKREF8:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3068 case NFA_BACKREF9:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3069 #ifdef FEAT_SYN_HL
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3070 case NFA_ZREF1:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3071 case NFA_ZREF2:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3072 case NFA_ZREF3:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3073 case NFA_ZREF4:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3074 case NFA_ZREF5:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3075 case NFA_ZREF6:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3076 case NFA_ZREF7:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3077 case NFA_ZREF8:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3078 case NFA_ZREF9:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3079 #endif
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3080 case NFA_NEWL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3081 case NFA_SKIP:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3082 // unknown width
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3083 return -1;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3084
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3085 case NFA_BOL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3086 case NFA_EOL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3087 case NFA_BOF:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3088 case NFA_EOF:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3089 case NFA_BOW:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3090 case NFA_EOW:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3091 case NFA_MOPEN:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3092 case NFA_MOPEN1:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3093 case NFA_MOPEN2:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3094 case NFA_MOPEN3:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3095 case NFA_MOPEN4:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3096 case NFA_MOPEN5:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3097 case NFA_MOPEN6:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3098 case NFA_MOPEN7:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3099 case NFA_MOPEN8:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3100 case NFA_MOPEN9:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3101 #ifdef FEAT_SYN_HL
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3102 case NFA_ZOPEN:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3103 case NFA_ZOPEN1:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3104 case NFA_ZOPEN2:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3105 case NFA_ZOPEN3:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3106 case NFA_ZOPEN4:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3107 case NFA_ZOPEN5:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3108 case NFA_ZOPEN6:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3109 case NFA_ZOPEN7:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3110 case NFA_ZOPEN8:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3111 case NFA_ZOPEN9:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3112 case NFA_ZCLOSE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3113 case NFA_ZCLOSE1:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3114 case NFA_ZCLOSE2:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3115 case NFA_ZCLOSE3:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3116 case NFA_ZCLOSE4:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3117 case NFA_ZCLOSE5:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3118 case NFA_ZCLOSE6:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3119 case NFA_ZCLOSE7:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3120 case NFA_ZCLOSE8:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3121 case NFA_ZCLOSE9:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3122 #endif
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3123 case NFA_MCLOSE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3124 case NFA_MCLOSE1:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3125 case NFA_MCLOSE2:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3126 case NFA_MCLOSE3:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3127 case NFA_MCLOSE4:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3128 case NFA_MCLOSE5:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3129 case NFA_MCLOSE6:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3130 case NFA_MCLOSE7:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3131 case NFA_MCLOSE8:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3132 case NFA_MCLOSE9:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3133 case NFA_NOPEN:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3134 case NFA_NCLOSE:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3135
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3136 case NFA_LNUM_GT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3137 case NFA_LNUM_LT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3138 case NFA_COL_GT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3139 case NFA_COL_LT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3140 case NFA_VCOL_GT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3141 case NFA_VCOL_LT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3142 case NFA_MARK_GT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3143 case NFA_MARK_LT:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3144 case NFA_VISUAL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3145 case NFA_LNUM:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3146 case NFA_CURSOR:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3147 case NFA_COL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3148 case NFA_VCOL:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3149 case NFA_MARK:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3150
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3151 case NFA_ZSTART:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3152 case NFA_ZEND:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3153 case NFA_OPT_CHARS:
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
3154 case NFA_EMPTY:
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3155 case NFA_START_PATTERN:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3156 case NFA_END_PATTERN:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3157 case NFA_COMPOSING:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3158 case NFA_END_COMPOSING:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3159 // zero-width
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3160 break;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3161
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3162 default:
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3163 if (state->c < 0)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3164 // don't know what this is
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3165 return -1;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3166 // normal character
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3167 len += MB_CHAR2LEN(state->c);
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3168 break;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3169 }
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3170
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3171 // normal way to continue
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3172 state = state->out;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3173 }
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3174
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3175 // unrecognized, "cannot happen"
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3176 return -1;
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3177 }
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
3178
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3179 /*
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3180 * Convert a postfix form into its equivalent NFA.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3181 * Return the NFA start state on success, NULL otherwise.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3182 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3183 static nfa_state_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3184 post2nfa(int *postfix, int *end, int nfa_calc_size)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3185 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3186 int *p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3187 int mopen;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3188 int mclose;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3189 Frag_T *stack = NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3190 Frag_T *stackp = NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3191 Frag_T *stack_end = NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3192 Frag_T e1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3193 Frag_T e2;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3194 Frag_T e;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3195 nfa_state_T *s;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3196 nfa_state_T *s1;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3197 nfa_state_T *matchstate;
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3198 nfa_state_T *ret = NULL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3199
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3200 if (postfix == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3201 return NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3202
4456
015a8fabf900 updated for version 7.3.976
Bram Moolenaar <bram@vim.org>
parents: 4454
diff changeset
3203 #define PUSH(s) st_push((s), &stackp, stack_end)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3204 #define POP() st_pop(&stackp, stack); \
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3205 if (stackp < stack) \
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3206 { \
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3207 st_error(postfix, end, p); \
6747
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3208 vim_free(stack); \
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3209 return NULL; \
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3210 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3211
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3212 if (nfa_calc_size == FALSE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3213 {
18498
9e6d5a4abb1c patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
3214 // Allocate space for the stack. Max states on the stack: "nstate".
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
3215 stack = ALLOC_MULT(Frag_T, nstate + 1);
15265
a7d02a56b5d5 patch 8.1.0641: no check for out-of-memory when converting regexp
Bram Moolenaar <Bram@vim.org>
parents: 14354
diff changeset
3216 if (stack == NULL)
a7d02a56b5d5 patch 8.1.0641: no check for out-of-memory when converting regexp
Bram Moolenaar <Bram@vim.org>
parents: 14354
diff changeset
3217 return NULL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3218 stackp = stack;
4462
a63361b90979 updated for version 7.3.979
Bram Moolenaar <bram@vim.org>
parents: 4460
diff changeset
3219 stack_end = stack + (nstate + 1);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3220 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3221
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3222 for (p = postfix; p < end; ++p)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3223 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3224 switch (*p)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3225 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3226 case NFA_CONCAT:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3227 // Concatenation.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3228 // Pay attention: this operator does not exist in the r.e. itself
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3229 // (it is implicit, really). It is added when r.e. is translated
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3230 // to postfix form in re2post().
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3231 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3232 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3233 // nstate += 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3234 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3235 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3236 e2 = POP();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3237 e1 = POP();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3238 patch(e1.out, e2.start);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3239 PUSH(frag(e1.start, e2.out));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3240 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3241
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3242 case NFA_OR:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3243 // Alternation
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3244 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3245 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3246 nstate++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3247 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3248 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3249 e2 = POP();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3250 e1 = POP();
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3251 s = alloc_state(NFA_SPLIT, e1.start, e2.start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3252 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3253 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3254 PUSH(frag(s, append(e1.out, e2.out)));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3255 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3256
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3257 case NFA_STAR:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3258 // Zero or more, prefer more
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3259 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3260 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3261 nstate++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3262 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3263 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3264 e = POP();
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3265 s = alloc_state(NFA_SPLIT, e.start, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3266 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3267 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3268 patch(e.out, s);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3269 PUSH(frag(s, list1(&s->out1)));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3270 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3271
4675
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3272 case NFA_STAR_NONGREEDY:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3273 // Zero or more, prefer zero
4675
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3274 if (nfa_calc_size == TRUE)
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3275 {
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3276 nstate++;
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3277 break;
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3278 }
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3279 e = POP();
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3280 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
3281 if (s == NULL)
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3282 goto theend;
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3283 patch(e.out, s);
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3284 PUSH(frag(s, list1(&s->out)));
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3285 break;
811a4c9b51d8 updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents: 4673
diff changeset
3286
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3287 case NFA_QUEST:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3288 // one or zero atoms=> greedy match
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3289 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3290 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3291 nstate++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3292 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3293 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3294 e = POP();
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3295 s = alloc_state(NFA_SPLIT, e.start, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3296 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3297 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3298 PUSH(frag(s, append(e.out, list1(&s->out1))));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3299 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3300
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3301 case NFA_QUEST_NONGREEDY:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3302 // zero or one atoms => non-greedy match
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3303 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3304 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3305 nstate++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3306 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3307 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3308 e = POP();
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3309 s = alloc_state(NFA_SPLIT, NULL, e.start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3310 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3311 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3312 PUSH(frag(s, append(e.out, list1(&s->out))));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3313 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3314
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3315 case NFA_END_COLL:
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3316 case NFA_END_NEG_COLL:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3317 // On the stack is the sequence starting with NFA_START_COLL or
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3318 // NFA_START_NEG_COLL and all possible characters. Patch it to
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3319 // add the output to the start.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3320 if (nfa_calc_size == TRUE)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3321 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3322 nstate++;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3323 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3324 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3325 e = POP();
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3326 s = alloc_state(NFA_END_COLL, NULL, NULL);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3327 if (s == NULL)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3328 goto theend;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3329 patch(e.out, s);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3330 e.start->out1 = s;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3331 PUSH(frag(e.start, list1(&s->out)));
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3332 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3333
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3334 case NFA_RANGE:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3335 // Before this are two characters, the low and high end of a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3336 // range. Turn them into two states with MIN and MAX.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3337 if (nfa_calc_size == TRUE)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3338 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3339 // nstate += 0;
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3340 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3341 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3342 e2 = POP();
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3343 e1 = POP();
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3344 e2.start->val = e2.start->c;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3345 e2.start->c = NFA_RANGE_MAX;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3346 e1.start->val = e1.start->c;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3347 e1.start->c = NFA_RANGE_MIN;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3348 patch(e1.out, e2.start);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3349 PUSH(frag(e1.start, e2.out));
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3350 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3351
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
3352 case NFA_EMPTY:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3353 // 0-length, used in a repetition with max/min count of 0
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3354 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3355 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3356 nstate++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3357 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3358 }
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
3359 s = alloc_state(NFA_EMPTY, NULL, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3360 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3361 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3362 PUSH(frag(s, list1(&s->out)));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3363 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3364
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3365 case NFA_OPT_CHARS:
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3366 {
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3367 int n;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3368
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3369 // \%[abc] implemented as:
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3370 // NFA_SPLIT
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3371 // +-CHAR(a)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3372 // | +-NFA_SPLIT
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3373 // | +-CHAR(b)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3374 // | | +-NFA_SPLIT
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3375 // | | +-CHAR(c)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3376 // | | | +-next
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3377 // | | +- next
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3378 // | +- next
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3379 // +- next
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3380 n = *++p; // get number of characters
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3381 if (nfa_calc_size == TRUE)
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3382 {
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3383 nstate += n;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3384 break;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3385 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3386 s = NULL; // avoid compiler warning
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3387 e1.out = NULL; // stores list with out1's
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3388 s1 = NULL; // previous NFA_SPLIT to connect to
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3389 while (n-- > 0)
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3390 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3391 e = POP(); // get character
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3392 s = alloc_state(NFA_SPLIT, e.start, NULL);
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3393 if (s == NULL)
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3394 goto theend;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3395 if (e1.out == NULL)
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3396 e1 = e;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3397 patch(e.out, s1);
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3398 append(e1.out, list1(&s->out1));
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3399 s1 = s;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3400 }
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3401 PUSH(frag(s, e1.out));
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3402 break;
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3403 }
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3404
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3405 case NFA_PREV_ATOM_NO_WIDTH:
4661
0dce3d812e7a updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents: 4657
diff changeset
3406 case NFA_PREV_ATOM_NO_WIDTH_NEG:
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
3407 case NFA_PREV_ATOM_JUST_BEFORE:
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
3408 case NFA_PREV_ATOM_JUST_BEFORE_NEG:
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3409 case NFA_PREV_ATOM_LIKE_PATTERN:
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3410 {
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3411 int before = (*p == NFA_PREV_ATOM_JUST_BEFORE
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3412 || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG);
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3413 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
3414 int start_state;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3415 int end_state;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3416 int n = 0;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3417 nfa_state_T *zend;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3418 nfa_state_T *skip;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3419
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3420 switch (*p)
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3421 {
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3422 case NFA_PREV_ATOM_NO_WIDTH:
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3423 start_state = NFA_START_INVISIBLE;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3424 end_state = NFA_END_INVISIBLE;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3425 break;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3426 case NFA_PREV_ATOM_NO_WIDTH_NEG:
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3427 start_state = NFA_START_INVISIBLE_NEG;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3428 end_state = NFA_END_INVISIBLE_NEG;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3429 break;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3430 case NFA_PREV_ATOM_JUST_BEFORE:
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3431 start_state = NFA_START_INVISIBLE_BEFORE;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3432 end_state = NFA_END_INVISIBLE;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3433 break;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3434 case NFA_PREV_ATOM_JUST_BEFORE_NEG:
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3435 start_state = NFA_START_INVISIBLE_BEFORE_NEG;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3436 end_state = NFA_END_INVISIBLE_NEG;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3437 break;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3438 default: // NFA_PREV_ATOM_LIKE_PATTERN:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3439 start_state = NFA_START_PATTERN;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3440 end_state = NFA_END_PATTERN;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
3441 break;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3442 }
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3443
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3444 if (before)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3445 n = *++p; // get the count
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3446
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3447 // The \@= operator: match the preceding atom with zero width.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3448 // The \@! operator: no match for the preceding atom.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3449 // The \@<= operator: match for the preceding atom.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3450 // The \@<! operator: no match for the preceding atom.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3451 // Surrounds the preceding atom with START_INVISIBLE and
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3452 // END_INVISIBLE, similarly to MOPEN.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3453
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3454 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3455 {
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3456 nstate += pattern ? 4 : 2;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3457 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3458 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3459 e = POP();
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3460 s1 = alloc_state(end_state, NULL, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3461 if (s1 == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3462 goto theend;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3463
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3464 s = alloc_state(start_state, e.start, s1);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3465 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3466 goto theend;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3467 if (pattern)
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
3468 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3469 // NFA_ZEND -> NFA_END_PATTERN -> NFA_SKIP -> what follows.
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3470 skip = alloc_state(NFA_SKIP, NULL, NULL);
11896
a941848d8c44 patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents: 11525
diff changeset
3471 if (skip == NULL)
a941848d8c44 patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents: 11525
diff changeset
3472 goto theend;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3473 zend = alloc_state(NFA_ZEND, s1, NULL);
11896
a941848d8c44 patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents: 11525
diff changeset
3474 if (zend == NULL)
a941848d8c44 patch 8.0.0828: Coverity: may dereference NULL pointer
Christian Brabandt <cb@256bit.org>
parents: 11525
diff changeset
3475 goto theend;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3476 s1->out= skip;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3477 patch(e.out, zend);
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3478 PUSH(frag(s, list1(&skip->out)));
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
3479 }
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3480 else
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3481 {
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3482 patch(e.out, s1);
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3483 PUSH(frag(s, list1(&s1->out)));
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3484 if (before)
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3485 {
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3486 if (n <= 0)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3487 // See if we can guess the maximum width, it avoids a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3488 // lot of pointless tries.
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3489 n = nfa_max_width(e.start, 0);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3490 s->val = n; // store the count
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3491 }
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3492 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3493 break;
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3494 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3495
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3496 case NFA_COMPOSING: // char with composing char
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
3497 #if 0
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3498 // TODO
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
3499 if (regflags & RF_ICOMBINE)
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
3500 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3501 // use the base character only
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
3502 }
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
3503 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3504 // FALLTHROUGH
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3505
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3506 case NFA_MOPEN: // \( \) Submatch
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3507 case NFA_MOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3508 case NFA_MOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3509 case NFA_MOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3510 case NFA_MOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3511 case NFA_MOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3512 case NFA_MOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3513 case NFA_MOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3514 case NFA_MOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3515 case NFA_MOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3516 #ifdef FEAT_SYN_HL
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3517 case NFA_ZOPEN: // \z( \) Submatch
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3518 case NFA_ZOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3519 case NFA_ZOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3520 case NFA_ZOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3521 case NFA_ZOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3522 case NFA_ZOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3523 case NFA_ZOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3524 case NFA_ZOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3525 case NFA_ZOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3526 case NFA_ZOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3527 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3528 case NFA_NOPEN: // \%( \) "Invisible Submatch"
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3529 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3530 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3531 nstate += 2;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3532 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3533 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3534
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3535 mopen = *p;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3536 switch (*p)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3537 {
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3538 case NFA_NOPEN: mclose = NFA_NCLOSE; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3539 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3540 case NFA_ZOPEN: mclose = NFA_ZCLOSE; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3541 case NFA_ZOPEN1: mclose = NFA_ZCLOSE1; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3542 case NFA_ZOPEN2: mclose = NFA_ZCLOSE2; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3543 case NFA_ZOPEN3: mclose = NFA_ZCLOSE3; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3544 case NFA_ZOPEN4: mclose = NFA_ZCLOSE4; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3545 case NFA_ZOPEN5: mclose = NFA_ZCLOSE5; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3546 case NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3547 case NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3548 case NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3549 case NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3550 #endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3551 case NFA_COMPOSING: mclose = NFA_END_COMPOSING; break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3552 default:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3553 // NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3554 mclose = *p + NSUBEXP;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3555 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3556 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3557
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3558 // Allow "NFA_MOPEN" as a valid postfix representation for
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3559 // the empty regexp "". In this case, the NFA will be
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3560 // NFA_MOPEN -> NFA_MCLOSE. Note that this also allows
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3561 // empty groups of parenthesis, and empty mbyte chars
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3562 if (stackp == stack)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3563 {
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3564 s = alloc_state(mopen, NULL, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3565 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3566 goto theend;
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3567 s1 = alloc_state(mclose, NULL, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3568 if (s1 == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3569 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3570 patch(list1(&s->out), s1);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3571 PUSH(frag(s, list1(&s1->out)));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3572 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3573 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3574
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3575 // At least one node was emitted before NFA_MOPEN, so
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3576 // at least one node will be between NFA_MOPEN and NFA_MCLOSE
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3577 e = POP();
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3578 s = alloc_state(mopen, e.start, NULL); // `('
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3579 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3580 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3581
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3582 s1 = alloc_state(mclose, NULL, NULL); // `)'
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3583 if (s1 == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3584 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3585 patch(e.out, s1);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3586
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
3587 if (mopen == NFA_COMPOSING)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3588 // COMPOSING->out1 = END_COMPOSING
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3589 patch(list1(&s->out1), s1);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3590
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3591 PUSH(frag(s, list1(&s1->out)));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3592 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3593
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3594 case NFA_BACKREF1:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3595 case NFA_BACKREF2:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3596 case NFA_BACKREF3:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3597 case NFA_BACKREF4:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3598 case NFA_BACKREF5:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3599 case NFA_BACKREF6:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3600 case NFA_BACKREF7:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3601 case NFA_BACKREF8:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3602 case NFA_BACKREF9:
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3603 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3604 case NFA_ZREF1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3605 case NFA_ZREF2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3606 case NFA_ZREF3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3607 case NFA_ZREF4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3608 case NFA_ZREF5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3609 case NFA_ZREF6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3610 case NFA_ZREF7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3611 case NFA_ZREF8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3612 case NFA_ZREF9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3613 #endif
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3614 if (nfa_calc_size == TRUE)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3615 {
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3616 nstate += 2;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3617 break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3618 }
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3619 s = alloc_state(*p, NULL, NULL);
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3620 if (s == NULL)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3621 goto theend;
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3622 s1 = alloc_state(NFA_SKIP, NULL, NULL);
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3623 if (s1 == NULL)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3624 goto theend;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3625 patch(list1(&s->out), s1);
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3626 PUSH(frag(s, list1(&s1->out)));
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3627 break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3628
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3629 case NFA_LNUM:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3630 case NFA_LNUM_GT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3631 case NFA_LNUM_LT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3632 case NFA_VCOL:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3633 case NFA_VCOL_GT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3634 case NFA_VCOL_LT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3635 case NFA_COL:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3636 case NFA_COL_GT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3637 case NFA_COL_LT:
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
3638 case NFA_MARK:
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
3639 case NFA_MARK_GT:
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
3640 case NFA_MARK_LT:
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3641 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3642 int n = *++p; // lnum, col or mark name
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3643
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3644 if (nfa_calc_size == TRUE)
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3645 {
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3646 nstate += 1;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3647 break;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3648 }
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3649 s = alloc_state(p[-1], NULL, NULL);
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3650 if (s == NULL)
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3651 goto theend;
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3652 s->val = n;
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3653 PUSH(frag(s, list1(&s->out)));
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3654 break;
4740
97560c16ca99 updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents: 4738
diff changeset
3655 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
3656
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3657 case NFA_ZSTART:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3658 case NFA_ZEND:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3659 default:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3660 // Operands
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3661 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3662 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3663 nstate++;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3664 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3665 }
4696
ed4e689bbea1 updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents: 4694
diff changeset
3666 s = alloc_state(*p, NULL, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3667 if (s == NULL)
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3668 goto theend;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3669 PUSH(frag(s, list1(&s->out)));
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3670 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3671
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3672 } // switch(*p)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3673
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3674 } // for(p = postfix; *p; ++p)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3675
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3676 if (nfa_calc_size == TRUE)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3677 {
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
3678 nstate++;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3679 goto theend; // Return value when counting size is ignored anyway
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3680 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3681
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3682 e = POP();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3683 if (stackp != stack)
6747
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3684 {
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3685 vim_free(stack);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3686 EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA), too many states left on stack"));
6747
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3687 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3688
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3689 if (istate >= nstate)
6747
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3690 {
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3691 vim_free(stack);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3692 EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA "));
6747
4c4c8a53347b patch 7.4.696
Bram Moolenaar <bram@vim.org>
parents: 6653
diff changeset
3693 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3694
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3695 matchstate = &state_ptr[istate++]; // the match state
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3696 matchstate->c = NFA_MATCH;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3697 matchstate->out = matchstate->out1 = NULL;
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
3698 matchstate->id = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3699
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3700 patch(e.out, matchstate);
4484
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3701 ret = e.start;
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3702
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3703 theend:
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3704 vim_free(stack);
9a1d78f82826 updated for version 7.3.990
Bram Moolenaar <bram@vim.org>
parents: 4482
diff changeset
3705 return ret;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3706
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3707 #undef POP1
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3708 #undef PUSH1
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3709 #undef POP2
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3710 #undef PUSH2
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3711 #undef POP
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3712 #undef PUSH
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3713 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3714
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3715 /*
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3716 * 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
3717 */
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3718 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3719 nfa_postprocess(nfa_regprog_T *prog)
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3720 {
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3721 int i;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3722 int c;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3723
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3724 for (i = 0; i < prog->nstate; ++i)
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3725 {
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3726 c = prog->state[i].c;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3727 if (c == NFA_START_INVISIBLE
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3728 || c == NFA_START_INVISIBLE_NEG
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3729 || c == NFA_START_INVISIBLE_BEFORE
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3730 || c == NFA_START_INVISIBLE_BEFORE_NEG)
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3731 {
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3732 int directly;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3733
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3734 // Do it directly when what follows is possibly the end of the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3735 // match.
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3736 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
3737 directly = TRUE;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3738 else
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3739 {
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3740 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
3741 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
3742
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3743 // Postpone when the invisible match is expensive or has a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3744 // lower chance of failing.
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3745 if (c == NFA_START_INVISIBLE_BEFORE
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3746 || c == NFA_START_INVISIBLE_BEFORE_NEG)
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3747 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3748 // "before" matches are very expensive when
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3749 // unbounded, always prefer what follows then,
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3750 // unless what follows will always match.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3751 // Otherwise strongly prefer what follows.
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3752 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
3753 directly = FALSE;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3754 else
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3755 directly = ch_follows * 10 < ch_invisible;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3756 }
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3757 else
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3758 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3759 // normal invisible, first do the one with the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3760 // highest failure chance
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3761 directly = ch_follows < ch_invisible;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3762 }
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3763 }
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3764 if (directly)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3765 // switch to the _FIRST state
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3766 ++prog->state[i].c;
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3767 }
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 }
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
3770
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3771 /////////////////////////////////////////////////////////////////
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3772 // NFA execution code.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3773 /////////////////////////////////////////////////////////////////
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3774
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3775 typedef struct
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3776 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3777 int in_use; // number of subexpr with useful info
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3778
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3779 // 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
3780 union
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3781 {
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3782 struct multipos
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3783 {
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3784 linenr_T start_lnum;
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3785 linenr_T end_lnum;
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3786 colnr_T start_col;
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3787 colnr_T end_col;
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
3788 } multi[NSUBEXP];
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3789 struct linepos
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3790 {
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3791 char_u *start;
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3792 char_u *end;
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
3793 } line[NSUBEXP];
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
3794 } list;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3795 } regsub_T;
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
3796
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3797 typedef struct
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3798 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3799 regsub_T norm; // \( .. \) matches
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3800 #ifdef FEAT_SYN_HL
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3801 regsub_T synt; // \z( .. \) matches
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3802 #endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3803 } regsubs_T;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3804
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3805 // nfa_pim_T stores a Postponed Invisible Match.
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
3806 typedef struct nfa_pim_S nfa_pim_T;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
3807 struct nfa_pim_S
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
3808 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3809 int result; // NFA_PIM_*, see below
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3810 nfa_state_T *state; // the invisible match start state
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3811 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
3812 union
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3813 {
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3814 lpos_T pos;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3815 char_u *ptr;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3816 } end; // where the match must end
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
3817 };
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
3818
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3819 // Values for done in nfa_pim_T.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3820 #define NFA_PIM_UNUSED 0 // pim not used
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3821 #define NFA_PIM_TODO 1 // pim not done yet
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3822 #define NFA_PIM_MATCH 2 // pim executed, matches
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3823 #define NFA_PIM_NOMATCH 3 // pim executed, no match
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3824
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3825
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3826 // 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
3827 typedef struct
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3828 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3829 nfa_state_T *state;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3830 int count;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3831 nfa_pim_T pim; // if pim.result != NFA_PIM_UNUSED: postponed
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3832 // invisible match
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3833 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
3834 } nfa_thread_T;
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
3835
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3836 // nfa_list_T contains the alternative NFA execution states.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3837 typedef struct
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3838 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3839 nfa_thread_T *t; // allocated array of states
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3840 int n; // nr of states currently in "t"
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3841 int len; // max nr of states in "t"
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3842 int id; // ID of the list
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3843 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
3844 } nfa_list_T;
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
3845
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3846 #ifdef ENABLE_LOG
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
3847 static void log_subexpr(regsub_T *sub);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3848
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3849 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3850 log_subsexpr(regsubs_T *subs)
4686
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 log_subexpr(&subs->norm);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3853 # ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3854 if (rex.nfa_has_zsubexpr)
4770
b20dbf3a5370 updated for version 7.3.1132
Bram Moolenaar <bram@vim.org>
parents: 4768
diff changeset
3855 log_subexpr(&subs->synt);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3856 # endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3857 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3858
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3859 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3860 log_subexpr(regsub_T *sub)
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3861 {
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3862 int j;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3863
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3864 for (j = 0; j < sub->in_use; j++)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3865 if (REG_MULTI)
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3866 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
3867 j,
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3868 sub->list.multi[j].start_col,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3869 (int)sub->list.multi[j].start_lnum,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3870 sub->list.multi[j].end_col,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3871 (int)sub->list.multi[j].end_lnum);
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3872 else
4746
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3873 {
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3874 char *s = (char *)sub->list.line[j].start;
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3875 char *e = (char *)sub->list.line[j].end;
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3876
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
3877 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
3878 j,
4746
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3879 s == NULL ? "NULL" : s,
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3880 e == NULL ? "NULL" : e);
d1376091d18b updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents: 4744
diff changeset
3881 }
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3882 }
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3883
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3884 static char *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3885 pim_info(nfa_pim_T *pim)
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3886 {
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3887 static char buf[30];
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3888
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3889 if (pim == NULL || pim->result == NFA_PIM_UNUSED)
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3890 buf[0] = NUL;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3891 else
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3892 {
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3893 sprintf(buf, " PIM col %d", REG_MULTI ? (int)pim->end.pos.col
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3894 : (int)(pim->end.ptr - rex.input));
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3895 }
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3896 return buf;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3897 }
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3898
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3899 #endif
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
3900
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3901 // Used during execution: whether a match has been found.
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
3902 static int nfa_match;
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
3903 #ifdef FEAT_RELTIME
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
3904 static proftime_T *nfa_time_limit;
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
3905 static int *nfa_timed_out;
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
3906 static int nfa_time_count;
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
3907 #endif
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
3908
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
3909 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
3910 static int pim_equal(nfa_pim_T *one, nfa_pim_T *two);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3911
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3912 /*
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3913 * 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
3914 */
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3915 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3916 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
3917 {
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3918 to->result = from->result;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3919 to->state = from->state;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3920 copy_sub(&to->subs.norm, &from->subs.norm);
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3921 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3922 if (rex.nfa_has_zsubexpr)
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3923 copy_sub(&to->subs.synt, &from->subs.synt);
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3924 #endif
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3925 to->end = from->end;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3926 }
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
3927
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3928 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3929 clear_sub(regsub_T *sub)
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3930 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3931 if (REG_MULTI)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3932 // Use 0xff to set lnum to -1
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3933 vim_memset(sub->list.multi, 0xff,
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3934 sizeof(struct multipos) * rex.nfa_nsubexpr);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3935 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3936 vim_memset(sub->list.line, 0,
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3937 sizeof(struct linepos) * rex.nfa_nsubexpr);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3938 sub->in_use = 0;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3939 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3940
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3941 /*
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3942 * Copy the submatches from "from" to "to".
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3943 */
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3944 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3945 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
3946 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3947 to->in_use = from->in_use;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3948 if (from->in_use > 0)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3949 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3950 // Copy the match start and end positions.
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3951 if (REG_MULTI)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3952 mch_memmove(&to->list.multi[0],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3953 &from->list.multi[0],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3954 sizeof(struct multipos) * from->in_use);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3955 else
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3956 mch_memmove(&to->list.line[0],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3957 &from->list.line[0],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3958 sizeof(struct linepos) * from->in_use);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3959 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3960 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3961
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3962 /*
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3963 * Like copy_sub() but exclude the main match.
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3964 */
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3965 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3966 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
3967 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3968 if (to->in_use < from->in_use)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3969 to->in_use = from->in_use;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3970 if (from->in_use > 1)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3971 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
3972 // Copy the match start and end positions.
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3973 if (REG_MULTI)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3974 mch_memmove(&to->list.multi[1],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3975 &from->list.multi[1],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3976 sizeof(struct multipos) * (from->in_use - 1));
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3977 else
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3978 mch_memmove(&to->list.line[1],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3979 &from->list.line[1],
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3980 sizeof(struct linepos) * (from->in_use - 1));
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3981 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
3982 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3983
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
3984 /*
5372
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3985 * Like copy_sub() but only do the end of the main match if \ze is present.
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3986 */
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3987 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
3988 copy_ze_off(regsub_T *to, regsub_T *from)
5372
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3989 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
3990 if (rex.nfa_has_zend)
5372
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3991 {
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3992 if (REG_MULTI)
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3993 {
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3994 if (from->list.multi[0].end_lnum >= 0)
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
3995 {
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3996 to->list.multi[0].end_lnum = from->list.multi[0].end_lnum;
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
3997 to->list.multi[0].end_col = from->list.multi[0].end_col;
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
3998 }
5372
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
3999 }
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4000 else
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4001 {
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4002 if (from->list.line[0].end != NULL)
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4003 to->list.line[0].end = from->list.line[0].end;
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4004 }
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4005 }
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4006 }
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4007
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
4008 /*
4893
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4009 * Return TRUE if "sub1" and "sub2" have the same start positions.
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4010 * 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
4011 */
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4012 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4013 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
4014 {
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4015 int i;
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4016 int todo;
4893
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4017 linenr_T s1;
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4018 linenr_T s2;
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4019 char_u *sp1;
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4020 char_u *sp2;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4021
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4022 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
4023 if (REG_MULTI)
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4024 {
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4025 for (i = 0; i < todo; ++i)
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4026 {
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4027 if (i < sub1->in_use)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4028 s1 = sub1->list.multi[i].start_lnum;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4029 else
5006
f451d60ab8ec updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents: 4997
diff changeset
4030 s1 = -1;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4031 if (i < sub2->in_use)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4032 s2 = sub2->list.multi[i].start_lnum;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4033 else
5006
f451d60ab8ec updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents: 4997
diff changeset
4034 s2 = -1;
4893
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4035 if (s1 != s2)
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4036 return FALSE;
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4037 if (s1 != -1 && sub1->list.multi[i].start_col
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4038 != sub2->list.multi[i].start_col)
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4039 return FALSE;
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4040
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4041 if (rex.nfa_has_backref)
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4042 {
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4043 if (i < sub1->in_use)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4044 s1 = sub1->list.multi[i].end_lnum;
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4045 else
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4046 s1 = -1;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4047 if (i < sub2->in_use)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4048 s2 = sub2->list.multi[i].end_lnum;
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4049 else
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4050 s2 = -1;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4051 if (s1 != s2)
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4052 return FALSE;
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4053 if (s1 != -1 && sub1->list.multi[i].end_col
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4054 != sub2->list.multi[i].end_col)
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4055 return FALSE;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4056 }
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4057 }
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4058 }
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4059 else
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4060 {
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4061 for (i = 0; i < todo; ++i)
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4062 {
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4063 if (i < sub1->in_use)
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4064 sp1 = sub1->list.line[i].start;
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4065 else
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4066 sp1 = NULL;
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4067 if (i < sub2->in_use)
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4068 sp2 = sub2->list.line[i].start;
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4069 else
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4070 sp2 = NULL;
4893
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4071 if (sp1 != sp2)
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4072 return FALSE;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4073 if (rex.nfa_has_backref)
5893
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4074 {
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4075 if (i < sub1->in_use)
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4076 sp1 = sub1->list.line[i].end;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4077 else
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4078 sp1 = NULL;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4079 if (i < sub2->in_use)
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4080 sp2 = sub2->list.line[i].end;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4081 else
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4082 sp2 = NULL;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4083 if (sp1 != sp2)
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4084 return FALSE;
99374096a76b updated for version 7.4.289
Bram Moolenaar <bram@vim.org>
parents: 5838
diff changeset
4085 }
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4086 }
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
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4089 return TRUE;
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4090 }
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4091
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4092 #ifdef ENABLE_LOG
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4093 static void
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4094 report_state(char *action,
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4095 regsub_T *sub,
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4096 nfa_state_T *state,
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4097 int lid,
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4098 nfa_pim_T *pim)
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4099 {
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4100 int col;
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4101
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4102 if (sub->in_use <= 0)
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4103 col = -1;
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4104 else if (REG_MULTI)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4105 col = sub->list.multi[0].start_col;
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4106 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4107 col = (int)(sub->list.line[0].start - rex.line);
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4108 nfa_set_code(state->c);
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4109 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
4110 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
4111 pim_info(pim));
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4112 }
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4113 #endif
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4114
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4115 /*
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4116 * 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
4117 * positions as "subs".
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4118 */
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4119 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4120 has_state_with_pos(
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4121 nfa_list_T *l, // runtime state list
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4122 nfa_state_T *state, // state to update
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4123 regsubs_T *subs, // pointers to subexpressions
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4124 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
4125 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4126 nfa_thread_T *thread;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4127 int i;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4128
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4129 for (i = 0; i < l->n; ++i)
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4130 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4131 thread = &l->t[i];
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4132 if (thread->state->id == state->id
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4133 && sub_equal(&thread->subs.norm, &subs->norm)
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4134 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4135 && (!rex.nfa_has_zsubexpr
4893
07b9c48a30e9 updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents: 4891
diff changeset
4136 || sub_equal(&thread->subs.synt, &subs->synt))
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4137 #endif
5212
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4138 && pim_equal(&thread->pim, pim))
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4139 return TRUE;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4140 }
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4141 return FALSE;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4142 }
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4143
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4144 /*
5212
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4145 * 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
4146 * set.
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4147 */
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4148 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4149 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
4150 {
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4151 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
4152 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
4153
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4154 if (one_unused)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4155 // one is unused: equal when two is also unused
5212
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4156 return two_unused;
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4157 if (two_unused)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4158 // one is used and two is not: not equal
5212
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4159 return FALSE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4160 // compare the state id
5298
e29f11399cce updated for version 7.4.002
Bram Moolenaar <bram@vim.org>
parents: 5296
diff changeset
4161 if (one->state->id != two->state->id)
e29f11399cce updated for version 7.4.002
Bram Moolenaar <bram@vim.org>
parents: 5296
diff changeset
4162 return FALSE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4163 // compare the position
5212
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4164 if (REG_MULTI)
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4165 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
4166 && one->end.pos.col == two->end.pos.col;
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4167 return one->end.ptr == two->end.ptr;
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4168 }
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4169
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4170 /*
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4171 * 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
4172 */
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4173 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4174 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
4175 {
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4176 nfa_state_T *state = startstate;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4177
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4178 // avoid too much recursion
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4179 if (depth > 10)
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4180 return FALSE;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4181
5184
c6dd0c545e5c updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents: 5074
diff changeset
4182 while (state != NULL)
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4183 {
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4184 switch (state->c)
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4185 {
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4186 case NFA_MATCH:
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4187 case NFA_MCLOSE:
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4188 case NFA_END_INVISIBLE:
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4189 case NFA_END_INVISIBLE_NEG:
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4190 case NFA_END_PATTERN:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4191 return TRUE;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4192
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4193 case NFA_SPLIT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4194 return match_follows(state->out, depth + 1)
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4195 || match_follows(state->out1, depth + 1);
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4196
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4197 case NFA_START_INVISIBLE:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
4198 case NFA_START_INVISIBLE_FIRST:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4199 case NFA_START_INVISIBLE_BEFORE:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
4200 case NFA_START_INVISIBLE_BEFORE_FIRST:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4201 case NFA_START_INVISIBLE_NEG:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
4202 case NFA_START_INVISIBLE_NEG_FIRST:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4203 case NFA_START_INVISIBLE_BEFORE_NEG:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
4204 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4205 case NFA_COMPOSING:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4206 // skip ahead to next state
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4207 state = state->out1->out;
5184
c6dd0c545e5c updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents: 5074
diff changeset
4208 continue;
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4209
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4210 case NFA_ANY:
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
4211 case NFA_ANY_COMPOSING:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4212 case NFA_IDENT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4213 case NFA_SIDENT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4214 case NFA_KWORD:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4215 case NFA_SKWORD:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4216 case NFA_FNAME:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4217 case NFA_SFNAME:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4218 case NFA_PRINT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4219 case NFA_SPRINT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4220 case NFA_WHITE:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4221 case NFA_NWHITE:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4222 case NFA_DIGIT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4223 case NFA_NDIGIT:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4224 case NFA_HEX:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4225 case NFA_NHEX:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4226 case NFA_OCTAL:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4227 case NFA_NOCTAL:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4228 case NFA_WORD:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4229 case NFA_NWORD:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4230 case NFA_HEAD:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4231 case NFA_NHEAD:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4232 case NFA_ALPHA:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4233 case NFA_NALPHA:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4234 case NFA_LOWER:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4235 case NFA_NLOWER:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4236 case NFA_UPPER:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4237 case NFA_NUPPER:
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
4238 case NFA_LOWER_IC:
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
4239 case NFA_NLOWER_IC:
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
4240 case NFA_UPPER_IC:
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
4241 case NFA_NUPPER_IC:
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4242 case NFA_START_COLL:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4243 case NFA_START_NEG_COLL:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4244 case NFA_NEWL:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4245 // state will advance input
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4246 return FALSE;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4247
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4248 default:
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4249 if (state->c > 0)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4250 // state will advance input
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4251 return FALSE;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4252
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4253 // Others: zero-width or possibly zero-width, might still find
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4254 // a match at the same position, keep looking.
4809
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4255 break;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4256 }
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4257 state = state->out;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4258 }
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4259 return FALSE;
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4260 }
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4261
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4262
4d7e3df04256 updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents: 4807
diff changeset
4263 /*
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4264 * 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
4265 */
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4266 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4267 state_in_list(
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4268 nfa_list_T *l, // runtime state list
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4269 nfa_state_T *state, // state to update
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4270 regsubs_T *subs) // pointers to subexpressions
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4271 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4272 if (state->lastlist[nfa_ll_index] == l->id)
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4273 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4274 if (!rex.nfa_has_backref || has_state_with_pos(l, state, subs, NULL))
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4275 return TRUE;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4276 }
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4277 return FALSE;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4278 }
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
4279
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4280 // Offset used for "off" by addstate_here().
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4281 #define ADDSTATE_HERE_OFFSET 10
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4282
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4283 /*
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4284 * 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
4285 * Returns "subs_arg", possibly copied into temp_subs.
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4286 * Returns NULL when recursiveness is too deep.
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4287 */
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4288 static regsubs_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4289 addstate(
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4290 nfa_list_T *l, // runtime state list
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4291 nfa_state_T *state, // state to update
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4292 regsubs_T *subs_arg, // pointers to subexpressions
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4293 nfa_pim_T *pim, // postponed look-behind match
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4294 int off_arg) // byte offset, when -1 go to next line
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4295 {
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
4296 int subidx;
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4297 int off = off_arg;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4298 int add_here = FALSE;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4299 int listindex = 0;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4300 int k;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4301 int found = FALSE;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4302 nfa_thread_T *thread;
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4303 struct multipos save_multipos;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4304 int save_in_use;
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
4305 char_u *save_ptr;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4306 int i;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4307 regsub_T *sub;
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4308 regsubs_T *subs = subs_arg;
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4309 static regsubs_T temp_subs;
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4310 #ifdef ENABLE_LOG
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4311 int did_print = FALSE;
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4312 #endif
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4313 static int depth = 0;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4314
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4315 // This function is called recursively. When the depth is too much we run
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4316 // out of stack and crash, limit recursiveness here.
15800
483fda269100 patch 8.1.0907: CI tests on AppVeyor are failing
Bram Moolenaar <Bram@vim.org>
parents: 15796
diff changeset
4317 if (++depth >= 5000 || subs == NULL)
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4318 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4319 --depth;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4320 return NULL;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4321 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4322
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4323 if (off_arg <= -ADDSTATE_HERE_OFFSET)
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4324 {
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4325 add_here = TRUE;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4326 off = 0;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4327 listindex = -(off_arg + ADDSTATE_HERE_OFFSET);
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4328 }
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4329
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4330 switch (state->c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4331 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4332 case NFA_NCLOSE:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4333 case NFA_MCLOSE:
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4334 case NFA_MCLOSE1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4335 case NFA_MCLOSE2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4336 case NFA_MCLOSE3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4337 case NFA_MCLOSE4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4338 case NFA_MCLOSE5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4339 case NFA_MCLOSE6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4340 case NFA_MCLOSE7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4341 case NFA_MCLOSE8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4342 case NFA_MCLOSE9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4343 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4344 case NFA_ZCLOSE:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4345 case NFA_ZCLOSE1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4346 case NFA_ZCLOSE2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4347 case NFA_ZCLOSE3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4348 case NFA_ZCLOSE4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4349 case NFA_ZCLOSE5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4350 case NFA_ZCLOSE6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4351 case NFA_ZCLOSE7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4352 case NFA_ZCLOSE8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4353 case NFA_ZCLOSE9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4354 #endif
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4355 case NFA_MOPEN:
4748
4b9503f0c7d3 updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents: 4746
diff changeset
4356 case NFA_ZEND:
4815
6419ee8098c8 updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents: 4813
diff changeset
4357 case NFA_SPLIT:
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
4358 case NFA_EMPTY:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4359 // These nodes are not added themselves but their "out" and/or
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4360 // "out1" may be added below.
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4361 break;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4362
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4363 case NFA_BOL:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4364 case NFA_BOF:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4365 // "^" won't match past end-of-line, don't bother trying.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4366 // Except when at the end of the line, or when we are going to the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4367 // next line for a look-behind match.
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4368 if (rex.input > rex.line
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4369 && *rex.input != NUL
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4370 && (nfa_endp == NULL
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4371 || !REG_MULTI
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4372 || rex.lnum == nfa_endp->se_u.pos.lnum))
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4373 goto skip_add;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4374 // FALLTHROUGH
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4375
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4376 case NFA_MOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4377 case NFA_MOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4378 case NFA_MOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4379 case NFA_MOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4380 case NFA_MOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4381 case NFA_MOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4382 case NFA_MOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4383 case NFA_MOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4384 case NFA_MOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4385 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4386 case NFA_ZOPEN:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4387 case NFA_ZOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4388 case NFA_ZOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4389 case NFA_ZOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4390 case NFA_ZOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4391 case NFA_ZOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4392 case NFA_ZOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4393 case NFA_ZOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4394 case NFA_ZOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4395 case NFA_ZOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4396 #endif
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
4397 case NFA_NOPEN:
4748
4b9503f0c7d3 updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents: 4746
diff changeset
4398 case NFA_ZSTART:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4399 // These nodes need to be added so that we can bail out when it
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4400 // was added to this list before at the same position to avoid an
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4401 // endless loop for "\(\)*"
4694
efc4fb311d5d updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents: 4692
diff changeset
4402
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4403 default:
5502
5ad60cd88339 updated for version 7.4.100
Bram Moolenaar <bram@vim.org>
parents: 5401
diff changeset
4404 if (state->lastlist[nfa_ll_index] == l->id && state->c != NFA_SKIP)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4405 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4406 // This state is already in the list, don't add it again,
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4407 // unless it is an MOPEN that is used for a backreference or
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4408 // when there is a PIM. For NFA_MATCH check the position,
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4409 // lower position is preferred.
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4410 if (!rex.nfa_has_backref && pim == NULL && !l->has_pim
5895
b871734bf54e updated for version 7.4.290
Bram Moolenaar <bram@vim.org>
parents: 5893
diff changeset
4411 && state->c != NFA_MATCH)
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4412 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4413 // When called from addstate_here() do insert before
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4414 // existing states.
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4415 if (add_here)
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4416 {
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4417 for (k = 0; k < l->n && k < listindex; ++k)
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4418 if (l->t[k].state->id == state->id)
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4419 {
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4420 found = TRUE;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4421 break;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4422 }
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4423 }
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4424 if (!add_here || found)
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4425 {
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4426 skip_add:
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4427 #ifdef ENABLE_LOG
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4428 nfa_set_code(state->c);
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4429 fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s pim: %s has_pim: %d found: %d\n",
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4430 abs(state->id), l->id, state->c, code,
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4431 pim == NULL ? "NULL" : "yes", l->has_pim, found);
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4432 #endif
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4433 --depth;
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4434 return subs;
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4435 }
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4436 }
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4437
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4438 // Do not add the state again when it exists with the same
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4439 // positions.
5212
2741b46e96bf updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents: 5210
diff changeset
4440 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
4441 goto skip_add;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4442 }
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4443
15812
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4444 // When there are backreferences or PIMs the number of states may
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4445 // be (a lot) bigger than anticipated.
5006
f451d60ab8ec updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents: 4997
diff changeset
4446 if (l->n == l->len)
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4447 {
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4448 int newlen = l->len * 3 / 2 + 50;
15812
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4449 size_t newsize = newlen * sizeof(nfa_thread_T);
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4450 nfa_thread_T *newt;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4451
15812
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4452 if ((long)(newsize >> 10) >= p_mmp)
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4453 {
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4454 emsg(_(e_maxmempat));
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4455 --depth;
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4456 return NULL;
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4457 }
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4458 if (subs != &temp_subs)
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4459 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4460 // "subs" may point into the current array, need to make a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4461 // copy before it becomes invalid.
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4462 copy_sub(&temp_subs.norm, &subs->norm);
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4463 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4464 if (rex.nfa_has_zsubexpr)
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4465 copy_sub(&temp_subs.synt, &subs->synt);
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4466 #endif
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4467 subs = &temp_subs;
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4468 }
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4469
15812
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4470 newt = vim_realloc(l->t, newsize);
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4471 if (newt == NULL)
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4472 {
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4473 // out of memory
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4474 --depth;
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4475 return NULL;
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4476 }
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4477 l->t = newt;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4478 l->len = newlen;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4479 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4480
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4481 // add the state to the list
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
4482 state->lastlist[nfa_ll_index] = l->id;
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4483 thread = &l->t[l->n++];
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4484 thread->state = state;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4485 if (pim == NULL)
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4486 thread->pim.result = NFA_PIM_UNUSED;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4487 else
5227
a08fa2919f2b updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents: 5221
diff changeset
4488 {
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4489 copy_pim(&thread->pim, pim);
5227
a08fa2919f2b updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents: 5221
diff changeset
4490 l->has_pim = TRUE;
a08fa2919f2b updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents: 5221
diff changeset
4491 }
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4492 copy_sub(&thread->subs.norm, &subs->norm);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4493 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4494 if (rex.nfa_has_zsubexpr)
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
4495 copy_sub(&thread->subs.synt, &subs->synt);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4496 #endif
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4497 #ifdef ENABLE_LOG
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4498 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
4499 did_print = TRUE;
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4500 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4501 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4502
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4503 #ifdef ENABLE_LOG
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
4504 if (!did_print)
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
4505 report_state("Processing", &subs->norm, state, l->id, pim);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4506 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4507 switch (state->c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4508 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4509 case NFA_MATCH:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4510 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4511
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4512 case NFA_SPLIT:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4513 // order matters here
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4514 subs = addstate(l, state->out, subs, pim, off_arg);
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4515 subs = addstate(l, state->out1, subs, pim, off_arg);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4516 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4517
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
4518 case NFA_EMPTY:
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4519 case NFA_NOPEN:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4520 case NFA_NCLOSE:
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4521 subs = addstate(l, state->out, subs, pim, off_arg);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4522 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4523
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4524 case NFA_MOPEN:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4525 case NFA_MOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4526 case NFA_MOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4527 case NFA_MOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4528 case NFA_MOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4529 case NFA_MOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4530 case NFA_MOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4531 case NFA_MOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4532 case NFA_MOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4533 case NFA_MOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4534 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4535 case NFA_ZOPEN:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4536 case NFA_ZOPEN1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4537 case NFA_ZOPEN2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4538 case NFA_ZOPEN3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4539 case NFA_ZOPEN4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4540 case NFA_ZOPEN5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4541 case NFA_ZOPEN6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4542 case NFA_ZOPEN7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4543 case NFA_ZOPEN8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4544 case NFA_ZOPEN9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4545 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4546 case NFA_ZSTART:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4547 if (state->c == NFA_ZSTART)
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4548 {
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4549 subidx = 0;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4550 sub = &subs->norm;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4551 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4552 #ifdef FEAT_SYN_HL
5300
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4553 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
4554 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4555 subidx = state->c - NFA_ZOPEN;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4556 sub = &subs->synt;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4557 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4558 #endif
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
4559 else
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4560 {
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
4561 subidx = state->c - NFA_MOPEN;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4562 sub = &subs->norm;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4563 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4564
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4565 // avoid compiler warnings
5210
839ebe7c1b2f updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents: 5188
diff changeset
4566 save_ptr = NULL;
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4567 vim_memset(&save_multipos, 0, sizeof(save_multipos));
5210
839ebe7c1b2f updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents: 5188
diff changeset
4568
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4569 // Set the position (with "off" added) in the subexpression. Save
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4570 // and restore it when it was in use. Otherwise fill any gap.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4571 if (REG_MULTI)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4572 {
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4573 if (subidx < sub->in_use)
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4574 {
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4575 save_multipos = sub->list.multi[subidx];
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4576 save_in_use = -1;
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4577 }
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4578 else
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4579 {
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4580 save_in_use = sub->in_use;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4581 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
4582 {
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4583 sub->list.multi[i].start_lnum = -1;
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4584 sub->list.multi[i].end_lnum = -1;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4585 }
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4586 sub->in_use = subidx + 1;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4587 }
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4588 if (off == -1)
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4589 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4590 sub->list.multi[subidx].start_lnum = rex.lnum + 1;
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4591 sub->list.multi[subidx].start_col = 0;
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4592 }
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4593 else
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4594 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4595 sub->list.multi[subidx].start_lnum = rex.lnum;
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4596 sub->list.multi[subidx].start_col =
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4597 (colnr_T)(rex.input - rex.line + off);
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4598 }
7152
cbdc02d71a18 commit https://github.com/vim/vim/commit/c2b717ebd6719e722dcb5f10e4c74033a53ff7c7
Christian Brabandt <cb@256bit.org>
parents: 6914
diff changeset
4599 sub->list.multi[subidx].end_lnum = -1;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4600 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4601 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4602 {
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4603 if (subidx < sub->in_use)
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4604 {
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4605 save_ptr = sub->list.line[subidx].start;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4606 save_in_use = -1;
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4607 }
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4608 else
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4609 {
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4610 save_in_use = sub->in_use;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4611 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
4612 {
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4613 sub->list.line[i].start = NULL;
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4614 sub->list.line[i].end = NULL;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4615 }
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4616 sub->in_use = subidx + 1;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4617 }
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4618 sub->list.line[subidx].start = rex.input + off;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4619 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4620
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4621 subs = addstate(l, state->out, subs, pim, off_arg);
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4622 if (subs == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4623 break;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4624 // "subs" may have changed, need to set "sub" again
5300
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4625 #ifdef FEAT_SYN_HL
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4626 if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9)
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4627 sub = &subs->synt;
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4628 else
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4629 #endif
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4630 sub = &subs->norm;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4631
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4632 if (save_in_use == -1)
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4633 {
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4634 if (REG_MULTI)
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4635 sub->list.multi[subidx] = save_multipos;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4636 else
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4637 sub->list.line[subidx].start = save_ptr;
4563
e7016af0cbf9 updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents: 4561
diff changeset
4638 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4639 else
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4640 sub->in_use = save_in_use;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4641 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4642
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4643 case NFA_MCLOSE:
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4644 if (rex.nfa_has_zend && (REG_MULTI
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4645 ? subs->norm.list.multi[0].end_lnum >= 0
5336
c514693882b9 updated for version 7.4.021
Bram Moolenaar <bram@vim.org>
parents: 5334
diff changeset
4646 : subs->norm.list.line[0].end != NULL))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4647 {
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4648 // Do not overwrite the position set by \ze.
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4649 subs = addstate(l, state->out, subs, pim, off_arg);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4650 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4651 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4652 // FALLTHROUGH
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4653 case NFA_MCLOSE1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4654 case NFA_MCLOSE2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4655 case NFA_MCLOSE3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4656 case NFA_MCLOSE4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4657 case NFA_MCLOSE5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4658 case NFA_MCLOSE6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4659 case NFA_MCLOSE7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4660 case NFA_MCLOSE8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4661 case NFA_MCLOSE9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4662 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4663 case NFA_ZCLOSE:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4664 case NFA_ZCLOSE1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4665 case NFA_ZCLOSE2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4666 case NFA_ZCLOSE3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4667 case NFA_ZCLOSE4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4668 case NFA_ZCLOSE5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4669 case NFA_ZCLOSE6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4670 case NFA_ZCLOSE7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4671 case NFA_ZCLOSE8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4672 case NFA_ZCLOSE9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4673 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4674 case NFA_ZEND:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4675 if (state->c == NFA_ZEND)
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4676 {
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4677 subidx = 0;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4678 sub = &subs->norm;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4679 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4680 #ifdef FEAT_SYN_HL
5300
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4681 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
4682 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4683 subidx = state->c - NFA_ZCLOSE;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4684 sub = &subs->synt;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4685 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4686 #endif
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
4687 else
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4688 {
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
4689 subidx = state->c - NFA_MCLOSE;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4690 sub = &subs->norm;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4691 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4692
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4693 // We don't fill in gaps here, there must have been an MOPEN that
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4694 // has done that.
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4695 save_in_use = sub->in_use;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4696 if (sub->in_use <= subidx)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4697 sub->in_use = subidx + 1;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4698 if (REG_MULTI)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4699 {
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4700 save_multipos = sub->list.multi[subidx];
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4701 if (off == -1)
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4702 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4703 sub->list.multi[subidx].end_lnum = rex.lnum + 1;
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4704 sub->list.multi[subidx].end_col = 0;
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4705 }
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4706 else
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4707 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4708 sub->list.multi[subidx].end_lnum = rex.lnum;
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4709 sub->list.multi[subidx].end_col =
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4710 (colnr_T)(rex.input - rex.line + off);
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
4711 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4712 // avoid compiler warnings
5210
839ebe7c1b2f updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents: 5188
diff changeset
4713 save_ptr = NULL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4714 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4715 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4716 {
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4717 save_ptr = sub->list.line[subidx].end;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4718 sub->list.line[subidx].end = rex.input + off;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4719 // avoid compiler warnings
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4720 vim_memset(&save_multipos, 0, sizeof(save_multipos));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4721 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4722
10170
4acacf4081ce commit https://github.com/vim/vim/commit/16b3578f355282846f2600ce77fb344950f0b9ce
Christian Brabandt <cb@256bit.org>
parents: 10168
diff changeset
4723 subs = addstate(l, state->out, subs, pim, off_arg);
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4724 if (subs == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4725 break;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4726 // "subs" may have changed, need to set "sub" again
5300
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4727 #ifdef FEAT_SYN_HL
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4728 if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9)
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4729 sub = &subs->synt;
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4730 else
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4731 #endif
560a6a232950 updated for version 7.4.003
Bram Moolenaar <bram@vim.org>
parents: 5298
diff changeset
4732 sub = &subs->norm;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4733
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4734 if (REG_MULTI)
10168
3c37899baa8d commit https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4735 sub->list.multi[subidx] = save_multipos;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4736 else
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4737 sub->list.line[subidx].end = save_ptr;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4738 sub->in_use = save_in_use;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4739 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4740 }
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4741 --depth;
5074
1cacf785299e updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents: 5058
diff changeset
4742 return subs;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4743 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4744
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4745 /*
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4746 * 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
4747 * 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
4748 * 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
4749 * matters for alternatives.
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4750 */
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4751 static regsubs_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4752 addstate_here(
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4753 nfa_list_T *l, // runtime state list
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4754 nfa_state_T *state, // state to update
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4755 regsubs_T *subs, // pointers to subexpressions
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4756 nfa_pim_T *pim, // postponed look-behind match
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4757 int *ip)
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4758 {
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4759 int tlen = l->n;
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4760 int count;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
4761 int listidx = *ip;
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4762 regsubs_T *r;
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4763
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4764 // First add the state(s) at the end, so that we know how many there are.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4765 // Pass the listidx as offset (avoids adding another argument to
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4766 // addstate().
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4767 r = addstate(l, state, subs, pim, -listidx - ADDSTATE_HERE_OFFSET);
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4768 if (r == NULL)
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4769 return NULL;
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4770
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4771 // 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
4772 if (listidx + 1 == tlen)
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4773 return r;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4774
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4775 // re-order to put the new state at the current position
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4776 count = l->n - tlen;
4924
6ae32a64e153 updated for version 7.3.1207
Bram Moolenaar <bram@vim.org>
parents: 4897
diff changeset
4777 if (count == 0)
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4778 return r; // no state got added
4647
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4779 if (count == 1)
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4780 {
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4781 // overwrite the current state
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
4782 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
4783 }
857f6c53f117 updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents: 4615
diff changeset
4784 else if (count > 1)
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4785 {
5058
a00cd1839ac4 updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents: 5029
diff changeset
4786 if (l->n + count - 1 >= l->len)
a00cd1839ac4 updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents: 5029
diff changeset
4787 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4788 // not enough space to move the new states, reallocate the list
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4789 // and move the states to the right position
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4790 int newlen = l->len * 3 / 2 + 50;
15812
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4791 size_t newsize = newlen * sizeof(nfa_thread_T);
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4792 nfa_thread_T *newl;
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4793
15812
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4794 if ((long)(newsize >> 10) >= p_mmp)
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4795 {
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4796 emsg(_(e_maxmempat));
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4797 return NULL;
3808b583889e patch 8.1.0913: CI crashes when running out of memory
Bram Moolenaar <Bram@vim.org>
parents: 15806
diff changeset
4798 }
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
4799 newl = alloc(newsize);
5058
a00cd1839ac4 updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents: 5029
diff changeset
4800 if (newl == NULL)
15806
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4801 return NULL;
6a4e9d9f1d66 patch 8.1.0910: crash with tricky search pattern
Bram Moolenaar <Bram@vim.org>
parents: 15802
diff changeset
4802 l->len = newlen;
5058
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 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4817 // make space for new states, then move them from the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4818 // end to the current position
5058
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;
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4829
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
4830 return r;
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4831 }
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4832
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
4833 /*
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4834 * Check character class "class" against current character c.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4835 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4836 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4837 check_char_class(int class, int c)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4838 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4839 switch (class)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4840 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4841 case NFA_CLASS_ALNUM:
9015
42b228c8701b commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents: 8989
diff changeset
4842 if (c >= 1 && c < 128 && isalnum(c))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4843 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4844 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4845 case NFA_CLASS_ALPHA:
9015
42b228c8701b commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents: 8989
diff changeset
4846 if (c >= 1 && c < 128 && isalpha(c))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4847 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4848 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4849 case NFA_CLASS_BLANK:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4850 if (c == ' ' || c == '\t')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4851 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4852 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4853 case NFA_CLASS_CNTRL:
11267
588de97b40e7 patch 8.0.0519: character classes are not well tested
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
4854 if (c >= 1 && c <= 127 && iscntrl(c))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4855 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4856 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4857 case NFA_CLASS_DIGIT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4858 if (VIM_ISDIGIT(c))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4859 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4860 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4861 case NFA_CLASS_GRAPH:
11267
588de97b40e7 patch 8.0.0519: character classes are not well tested
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
4862 if (c >= 1 && c <= 127 && isgraph(c))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4863 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4864 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4865 case NFA_CLASS_LOWER:
9015
42b228c8701b commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents: 8989
diff changeset
4866 if (MB_ISLOWER(c) && c != 170 && c != 186)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4867 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4868 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4869 case NFA_CLASS_PRINT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4870 if (vim_isprintc(c))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4871 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4872 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4873 case NFA_CLASS_PUNCT:
9015
42b228c8701b commit https://github.com/vim/vim/commit/e8aee7dcf9b12becff86e8ce1783a86801c5f9f6
Christian Brabandt <cb@256bit.org>
parents: 8989
diff changeset
4874 if (c >= 1 && c < 128 && ispunct(c))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4875 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4876 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4877 case NFA_CLASS_SPACE:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
4878 if ((c >= 9 && c <= 13) || (c == ' '))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4879 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4880 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4881 case NFA_CLASS_UPPER:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4882 if (MB_ISUPPER(c))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4883 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4884 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4885 case NFA_CLASS_XDIGIT:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4886 if (vim_isxdigit(c))
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4887 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4888 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4889 case NFA_CLASS_TAB:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4890 if (c == '\t')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4891 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4892 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4893 case NFA_CLASS_RETURN:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4894 if (c == '\r')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4895 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4896 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4897 case NFA_CLASS_BACKSPACE:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4898 if (c == '\b')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4899 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4900 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4901 case NFA_CLASS_ESCAPE:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4902 if (c == '\033')
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4903 return OK;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4904 break;
15709
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4905 case NFA_CLASS_IDENT:
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4906 if (vim_isIDc(c))
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4907 return OK;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4908 break;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4909 case NFA_CLASS_KEYWORD:
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4910 if (reg_iswordc(c))
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4911 return OK;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4912 break;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4913 case NFA_CLASS_FNAME:
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4914 if (vim_isfilec(c))
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4915 return OK;
2e2f07561f4b patch 8.1.0862: no verbose version of character classes
Bram Moolenaar <Bram@vim.org>
parents: 15603
diff changeset
4916 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4917
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4918 default:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4919 // should not be here :P
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
4920 siemsg(_(e_ill_char_class), class);
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
4921 return FAIL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4922 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4923 return FAIL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4924 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4925
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4926 /*
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4927 * Check for a match with subexpression "subidx".
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4928 * Return TRUE if it matches.
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4929 */
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4930 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4931 match_backref(
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4932 regsub_T *sub, // pointers to subexpressions
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4933 int subidx,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4934 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
4935 {
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4936 int len;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4937
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4938 if (sub->in_use <= subidx)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4939 {
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4940 retempty:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4941 // backref was not set, match an empty string
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4942 *bytelen = 0;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4943 return TRUE;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4944 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4945
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4946 if (REG_MULTI)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4947 {
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4948 if (sub->list.multi[subidx].start_lnum < 0
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4949 || sub->list.multi[subidx].end_lnum < 0)
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4950 goto retempty;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4951 if (sub->list.multi[subidx].start_lnum == rex.lnum
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4952 && sub->list.multi[subidx].end_lnum == rex.lnum)
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4953 {
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4954 len = sub->list.multi[subidx].end_col
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4955 - sub->list.multi[subidx].start_col;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4956 if (cstrncmp(rex.line + sub->list.multi[subidx].start_col,
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4957 rex.input, &len) == 0)
4891
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4958 {
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4959 *bytelen = len;
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4960 return TRUE;
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4961 }
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4962 }
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4963 else
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4964 {
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4965 if (match_with_backref(
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4966 sub->list.multi[subidx].start_lnum,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4967 sub->list.multi[subidx].start_col,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4968 sub->list.multi[subidx].end_lnum,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
4969 sub->list.multi[subidx].end_col,
4891
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4970 bytelen) == RA_MATCH)
4c42efb4c098 updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents: 4887
diff changeset
4971 return TRUE;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4972 }
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 else
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4975 {
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4976 if (sub->list.line[subidx].start == NULL
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4977 || sub->list.line[subidx].end == NULL)
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4978 goto retempty;
4577
b22bff1a6af8 updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents: 4573
diff changeset
4979 len = (int)(sub->list.line[subidx].end - sub->list.line[subidx].start);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
4980 if (cstrncmp(sub->list.line[subidx].start, rex.input, &len) == 0)
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4981 {
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4982 *bytelen = len;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4983 return TRUE;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4984 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4985 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4986 return FALSE;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4987 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
4988
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4989 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4990
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4991 /*
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4992 * Check for a match with \z subexpression "subidx".
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4993 * Return TRUE if it matches.
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4994 */
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
4995 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4996 match_zref(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4997 int subidx,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
4998 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
4999 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5000 int len;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5001
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5002 cleanup_zsubexpr();
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5003 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
5004 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5005 // backref was not set, match an empty string
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5006 *bytelen = 0;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5007 return TRUE;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5008 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5009
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5010 len = (int)STRLEN(re_extmatch_in->matches[subidx]);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5011 if (cstrncmp(re_extmatch_in->matches[subidx], rex.input, &len) == 0)
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5012 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5013 *bytelen = len;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5014 return TRUE;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5015 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5016 return FALSE;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5017 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5018 #endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5019
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5020 /*
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5021 * 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
5022 * Also reset the IDs to zero.
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5023 * Only used for the recursive value lastlist[1].
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5024 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5025 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5026 nfa_save_listids(nfa_regprog_T *prog, int *list)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5027 {
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5028 int i;
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5029 nfa_state_T *p;
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5030
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5031 // Order in the list is reverse, it's a bit faster that way.
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5032 p = &prog->state[0];
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5033 for (i = prog->nstate; --i >= 0; )
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5034 {
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5035 list[i] = p->lastlist[1];
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5036 p->lastlist[1] = 0;
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5037 ++p;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5038 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5039 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5040
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5041 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5042 * Restore list IDs from "list" to all NFA states.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5043 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5044 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5045 nfa_restore_listids(nfa_regprog_T *prog, int *list)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5046 {
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5047 int i;
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5048 nfa_state_T *p;
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5049
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5050 p = &prog->state[0];
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5051 for (i = prog->nstate; --i >= 0; )
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5052 {
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5053 p->lastlist[1] = list[i];
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5054 ++p;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5055 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5056 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5057
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
5058 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5059 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
5060 {
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
5061 if (op == 1) return pos > val;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
5062 if (op == 2) return pos < val;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
5063 return val == pos;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
5064 }
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
5065
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7258
diff changeset
5066 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
5067
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5068 /*
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5069 * Recursively call nfa_regmatch()
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5070 * "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
5071 * position).
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5072 */
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5073 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5074 recursive_regmatch(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5075 nfa_state_T *state,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5076 nfa_pim_T *pim,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5077 nfa_regprog_T *prog,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5078 regsubs_T *submatch,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5079 regsubs_T *m,
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
5080 int **listids,
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
5081 int *listids_len)
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5082 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5083 int save_reginput_col = (int)(rex.input - rex.line);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5084 int save_reglnum = rex.lnum;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5085 int save_nfa_match = nfa_match;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5086 int save_nfa_listid = rex.nfa_listid;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5087 save_se_T *save_nfa_endp = nfa_endp;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5088 save_se_T endpos;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5089 save_se_T *endposp = NULL;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5090 int result;
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5091 int need_restore = FALSE;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5092
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5093 if (pim != NULL)
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5094 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5095 // start at the position where the postponed match was
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5096 if (REG_MULTI)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5097 rex.input = rex.line + pim->end.pos.col;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5098 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5099 rex.input = pim->end.ptr;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5100 }
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5101
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
5102 if (state->c == NFA_START_INVISIBLE_BEFORE
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
5103 || state->c == NFA_START_INVISIBLE_BEFORE_FIRST
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
5104 || state->c == NFA_START_INVISIBLE_BEFORE_NEG
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
5105 || 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
5106 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5107 // The recursive match must end at the current position. When "pim" is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5108 // not NULL it specifies the current position.
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5109 endposp = &endpos;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5110 if (REG_MULTI)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5111 {
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5112 if (pim == NULL)
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5113 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5114 endpos.se_u.pos.col = (int)(rex.input - rex.line);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5115 endpos.se_u.pos.lnum = rex.lnum;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5116 }
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5117 else
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5118 endpos.se_u.pos = pim->end.pos;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5119 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5120 else
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5121 {
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5122 if (pim == NULL)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5123 endpos.se_u.ptr = rex.input;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5124 else
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5125 endpos.se_u.ptr = pim->end.ptr;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5126 }
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5127
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5128 // Go back the specified number of bytes, or as far as the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5129 // start of the previous line, to try matching "\@<=" or
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5130 // not matching "\@<!". This is very inefficient, limit the number of
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5131 // bytes if possible.
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5132 if (state->val <= 0)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5133 {
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5134 if (REG_MULTI)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5135 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5136 rex.line = reg_getline(--rex.lnum);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5137 if (rex.line == NULL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5138 // can't go before the first line
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5139 rex.line = reg_getline(++rex.lnum);
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5140 }
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5141 rex.input = rex.line;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5142 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5143 else
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5144 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5145 if (REG_MULTI && (int)(rex.input - rex.line) < state->val)
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5146 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5147 // Not enough bytes in this line, go to end of
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5148 // previous line.
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5149 rex.line = reg_getline(--rex.lnum);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5150 if (rex.line == NULL)
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5151 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5152 // can't go before the first line
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5153 rex.line = reg_getline(++rex.lnum);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5154 rex.input = rex.line;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5155 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5156 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5157 rex.input = rex.line + STRLEN(rex.line);
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5158 }
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5159 if ((int)(rex.input - rex.line) >= state->val)
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5160 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5161 rex.input -= state->val;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5162 if (has_mbyte)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5163 rex.input -= mb_head_off(rex.line, rex.input);
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5164 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5165 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5166 rex.input = rex.line;
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5167 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5168 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5169
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5170 #ifdef ENABLE_LOG
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5171 if (log_fd != stderr)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5172 fclose(log_fd);
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5173 log_fd = NULL;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5174 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5175 // Have to clear the lastlist field of the NFA nodes, so that
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5176 // nfa_regmatch() and addstate() can run properly after recursion.
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5177 if (nfa_ll_index == 1)
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5178 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5179 // Already calling nfa_regmatch() recursively. Save the lastlist[1]
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5180 // values and clear them.
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5181 if (*listids == NULL || *listids_len < prog->nstate)
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5182 {
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
5183 vim_free(*listids);
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
5184 *listids = ALLOC_MULT(int, prog->nstate);
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5185 if (*listids == NULL)
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5186 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
5187 emsg(_("E878: (NFA) Could not allocate memory for branch traversal!"));
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5188 return 0;
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5189 }
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5190 *listids_len = prog->nstate;
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5191 }
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5192 nfa_save_listids(prog, *listids);
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5193 need_restore = TRUE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5194 // any value of rex.nfa_listid will do
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5195 }
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5196 else
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5197 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5198 // First recursive nfa_regmatch() call, switch to the second lastlist
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5199 // entry. Make sure rex.nfa_listid is different from a previous
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5200 // recursive call, because some states may still have this ID.
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5201 ++nfa_ll_index;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5202 if (rex.nfa_listid <= rex.nfa_alt_listid)
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5203 rex.nfa_listid = rex.nfa_alt_listid;
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5204 }
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5205
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5206 // Call nfa_regmatch() to check if the current concat matches at this
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5207 // 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
5208 nfa_endp = endposp;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5209 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
5210
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5211 if (need_restore)
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5212 nfa_restore_listids(prog, *listids);
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5213 else
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5214 {
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5215 --nfa_ll_index;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5216 rex.nfa_alt_listid = rex.nfa_listid;
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
5217 }
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5218
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5219 // restore position in input text
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5220 rex.lnum = save_reglnum;
4877
9e36c6b1ebf4 updated for version 7.3.1184
Bram Moolenaar <bram@vim.org>
parents: 4845
diff changeset
5221 if (REG_MULTI)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5222 rex.line = reg_getline(rex.lnum);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5223 rex.input = rex.line + save_reginput_col;
9371
3666915cac0b commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents: 9015
diff changeset
5224 if (result != NFA_TOO_EXPENSIVE)
3666915cac0b commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents: 9015
diff changeset
5225 {
3666915cac0b commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents: 9015
diff changeset
5226 nfa_match = save_nfa_match;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5227 rex.nfa_listid = save_nfa_listid;
9371
3666915cac0b commit https://github.com/vim/vim/commit/6747fabc7348bf5f41ccfe851e2be3e900ec8ee0
Christian Brabandt <cb@256bit.org>
parents: 9015
diff changeset
5228 }
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5229 nfa_endp = save_nfa_endp;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5230
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5231 #ifdef ENABLE_LOG
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5232 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5233 if (log_fd != NULL)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5234 {
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5235 fprintf(log_fd, "****************************\n");
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5236 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
5237 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
5238 fprintf(log_fd, "****************************\n");
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5239 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5240 else
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5241 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
5242 emsg(_(e_log_open_failed));
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5243 log_fd = stderr;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5244 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5245 #endif
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5246
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5247 return result;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5248 }
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5249
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5250 /*
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5251 * 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
5252 * empty match: 0
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5253 * NFA_ANY: 1
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5254 * specific character: 99
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5255 */
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5256 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5257 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
5258 {
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5259 int c = state->c;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5260 int l, r;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5261
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5262 // detect looping
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5263 if (depth > 4)
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5264 return 1;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5265
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5266 switch (c)
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5267 {
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5268 case NFA_SPLIT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5269 if (state->out->c == NFA_SPLIT || state->out1->c == NFA_SPLIT)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5270 // avoid recursive stuff
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5271 return 1;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5272 // two alternatives, use the lowest failure chance
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5273 l = failure_chance(state->out, depth + 1);
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5274 r = failure_chance(state->out1, depth + 1);
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5275 return l < r ? l : r;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5276
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5277 case NFA_ANY:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5278 // matches anything, unlikely to fail
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5279 return 1;
4821
2f1ee97f5f23 updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents: 4819
diff changeset
5280
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5281 case NFA_MATCH:
4821
2f1ee97f5f23 updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents: 4819
diff changeset
5282 case NFA_MCLOSE:
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
5283 case NFA_ANY_COMPOSING:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5284 // empty match works always
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5285 return 0;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5286
4897
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5287 case NFA_START_INVISIBLE:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5288 case NFA_START_INVISIBLE_FIRST:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5289 case NFA_START_INVISIBLE_NEG:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5290 case NFA_START_INVISIBLE_NEG_FIRST:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5291 case NFA_START_INVISIBLE_BEFORE:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5292 case NFA_START_INVISIBLE_BEFORE_FIRST:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5293 case NFA_START_INVISIBLE_BEFORE_NEG:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5294 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST:
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5295 case NFA_START_PATTERN:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5296 // recursive regmatch is expensive, use low failure chance
4897
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5297 return 5;
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5298
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5299 case NFA_BOL:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5300 case NFA_EOL:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5301 case NFA_BOF:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5302 case NFA_EOF:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5303 case NFA_NEWL:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5304 return 99;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5305
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5306 case NFA_BOW:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5307 case NFA_EOW:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5308 return 90;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5309
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5310 case NFA_MOPEN:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5311 case NFA_MOPEN1:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5312 case NFA_MOPEN2:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5313 case NFA_MOPEN3:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5314 case NFA_MOPEN4:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5315 case NFA_MOPEN5:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5316 case NFA_MOPEN6:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5317 case NFA_MOPEN7:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5318 case NFA_MOPEN8:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5319 case NFA_MOPEN9:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5320 #ifdef FEAT_SYN_HL
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5321 case NFA_ZOPEN:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5322 case NFA_ZOPEN1:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5323 case NFA_ZOPEN2:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5324 case NFA_ZOPEN3:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5325 case NFA_ZOPEN4:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5326 case NFA_ZOPEN5:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5327 case NFA_ZOPEN6:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5328 case NFA_ZOPEN7:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5329 case NFA_ZOPEN8:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5330 case NFA_ZOPEN9:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5331 case NFA_ZCLOSE:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5332 case NFA_ZCLOSE1:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5333 case NFA_ZCLOSE2:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5334 case NFA_ZCLOSE3:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5335 case NFA_ZCLOSE4:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5336 case NFA_ZCLOSE5:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5337 case NFA_ZCLOSE6:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5338 case NFA_ZCLOSE7:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5339 case NFA_ZCLOSE8:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5340 case NFA_ZCLOSE9:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5341 #endif
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5342 case NFA_NOPEN:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5343 case NFA_MCLOSE1:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5344 case NFA_MCLOSE2:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5345 case NFA_MCLOSE3:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5346 case NFA_MCLOSE4:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5347 case NFA_MCLOSE5:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5348 case NFA_MCLOSE6:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5349 case NFA_MCLOSE7:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5350 case NFA_MCLOSE8:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5351 case NFA_MCLOSE9:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5352 case NFA_NCLOSE:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5353 return failure_chance(state->out, depth + 1);
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5354
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5355 case NFA_BACKREF1:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5356 case NFA_BACKREF2:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5357 case NFA_BACKREF3:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5358 case NFA_BACKREF4:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5359 case NFA_BACKREF5:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5360 case NFA_BACKREF6:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5361 case NFA_BACKREF7:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5362 case NFA_BACKREF8:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5363 case NFA_BACKREF9:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5364 #ifdef FEAT_SYN_HL
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5365 case NFA_ZREF1:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5366 case NFA_ZREF2:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5367 case NFA_ZREF3:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5368 case NFA_ZREF4:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5369 case NFA_ZREF5:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5370 case NFA_ZREF6:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5371 case NFA_ZREF7:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5372 case NFA_ZREF8:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5373 case NFA_ZREF9:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5374 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5375 // backreferences don't match in many places
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5376 return 94;
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_GT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5379 case NFA_LNUM_LT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5380 case NFA_COL_GT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5381 case NFA_COL_LT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5382 case NFA_VCOL_GT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5383 case NFA_VCOL_LT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5384 case NFA_MARK_GT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5385 case NFA_MARK_LT:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5386 case NFA_VISUAL:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5387 // before/after positions don't match very often
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5388 return 85;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5389
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5390 case NFA_LNUM:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5391 return 90;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5392
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5393 case NFA_CURSOR:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5394 case NFA_COL:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5395 case NFA_VCOL:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5396 case NFA_MARK:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5397 // specific positions rarely match
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5398 return 98;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5399
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5400 case NFA_COMPOSING:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5401 return 95;
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5402
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5403 default:
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5404 if (c > 0)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5405 // character match fails often
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5406 return 95;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5407 }
4742
6a706ca7a889 updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents: 4740
diff changeset
5408
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5409 // something else, includes character classes
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5410 return 50;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5411 }
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5412
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5413 /*
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5414 * 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
5415 */
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5416 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5417 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
5418 {
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5419 char_u *s;
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5420
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5421 // Used often, do some work to avoid call overhead.
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
5422 if (!rex.reg_ic && !has_mbyte)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5423 s = vim_strbyte(rex.line + *colp, c);
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5424 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5425 s = cstrchr(rex.line + *colp, c);
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5426 if (s == NULL)
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5427 return FAIL;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5428 *colp = (int)(s - rex.line);
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5429 return OK;
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5430 }
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5431
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
5432 /*
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5433 * Check for a match with match_text.
4807
3dbd251777de updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
5434 * 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
5435 * 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
5436 */
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5437 static long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5438 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
5439 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5440 colnr_T col = startcol;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5441 int c1, c2;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5442 int len1, len2;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5443 int match;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5444
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5445 for (;;)
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 = TRUE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5448 len2 = MB_CHAR2LEN(regstart); // skip regstart
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5449 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
5450 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5451 c1 = PTR2CHAR(match_text + len1);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5452 c2 = PTR2CHAR(rex.line + col + len2);
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
5453 if (c1 != c2 && (!rex.reg_ic || MB_TOLOWER(c1) != MB_TOLOWER(c2)))
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5454 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5455 match = FALSE;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5456 break;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5457 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5458 len2 += MB_CHAR2LEN(c2);
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 if (match
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5461 // check that no composing char follows
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5462 && !(enc_utf8
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
5463 && utf_iscomposing(PTR2CHAR(rex.line + col + len2))))
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5464 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5465 cleanup_subexpr();
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5466 if (REG_MULTI)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5467 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5468 rex.reg_startpos[0].lnum = rex.lnum;
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
5469 rex.reg_startpos[0].col = col;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5470 rex.reg_endpos[0].lnum = rex.lnum;
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
5471 rex.reg_endpos[0].col = col + len2;
4805
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 else
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5474 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5475 rex.reg_startp[0] = rex.line + col;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5476 rex.reg_endp[0] = rex.line + col + len2;
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5477 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5478 return 1L;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5479 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5480
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5481 // Try finding regstart after the current match.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5482 col += MB_CHAR2LEN(regstart); // skip regstart
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5483 if (skip_to_start(regstart, &col) == FAIL)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5484 break;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5485 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5486 return 0L;
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5487 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5488
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5489 #ifdef FEAT_RELTIME
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5490 static int
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5491 nfa_did_time_out()
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5492 {
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5493 if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit))
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5494 {
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5495 if (nfa_timed_out != NULL)
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5496 *nfa_timed_out = TRUE;
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5497 return TRUE;
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5498 }
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5499 return FALSE;
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5500 }
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5501 #endif
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5502
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
5503 /*
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5504 * Main matching routine.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5505 *
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5506 * Run NFA to determine whether it matches rex.input.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5507 *
4694
efc4fb311d5d updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents: 4692
diff changeset
5508 * 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
5509 *
16491
38a323a6fd18 patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5510 * Return TRUE if there is a match, FALSE if there is no match,
38a323a6fd18 patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5511 * NFA_TOO_EXPENSIVE if we end up with too many states.
5372
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
5512 * When there is a match "submatch" contains the positions.
16491
38a323a6fd18 patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5513 *
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5514 * Note: Caller must ensure that: start != NULL.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5515 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5516 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5517 nfa_regmatch(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5518 nfa_regprog_T *prog,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5519 nfa_state_T *start,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5520 regsubs_T *submatch,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5521 regsubs_T *m)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5522 {
16491
38a323a6fd18 patch 8.1.1249: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5523 int result = FALSE;
6545
1ef8ce97fc40 updated for version 7.4.599
Bram Moolenaar <bram@vim.org>
parents: 6533
diff changeset
5524 size_t size = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5525 int flag = 0;
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
5526 int go_to_nextline = FALSE;
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
5527 nfa_thread_T *t;
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5528 nfa_list_T list[2];
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5529 int listidx;
4539
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
5530 nfa_list_T *thislist;
532c2e850256 updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents: 4537
diff changeset
5531 nfa_list_T *nextlist;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5532 int *listids = NULL;
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
5533 int listids_len = 0;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5534 nfa_state_T *add_state;
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
5535 int add_here;
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5536 int add_count;
4819
8c4324e6f477 updated for version 7.3.1156
Bram Moolenaar <bram@vim.org>
parents: 4815
diff changeset
5537 int add_off = 0;
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5538 int toplevel = start->c == NFA_MOPEN;
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5539 regsubs_T *r;
4460
fe8a0a6a1c2a updated for version 7.3.978
Bram Moolenaar <bram@vim.org>
parents: 4458
diff changeset
5540 #ifdef NFA_REGEXP_DEBUG_LOG
8989
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5541 FILE *debug;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5542 #endif
8989
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5543
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5544 // Some patterns may take a long time to match, especially when using
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5545 // recursive_regmatch(). Allow interrupting them with CTRL-C.
5310
b04bdb2c5fce updated for version 7.4.008
Bram Moolenaar <bram@vim.org>
parents: 5300
diff changeset
5546 fast_breakcheck();
b04bdb2c5fce updated for version 7.4.008
Bram Moolenaar <bram@vim.org>
parents: 5300
diff changeset
5547 if (got_int)
b04bdb2c5fce updated for version 7.4.008
Bram Moolenaar <bram@vim.org>
parents: 5300
diff changeset
5548 return FALSE;
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
5549 #ifdef FEAT_RELTIME
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5550 if (nfa_did_time_out())
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
5551 return FALSE;
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
5552 #endif
5310
b04bdb2c5fce updated for version 7.4.008
Bram Moolenaar <bram@vim.org>
parents: 5300
diff changeset
5553
8989
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5554 #ifdef NFA_REGEXP_DEBUG_LOG
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5555 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
5556 if (debug == NULL)
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5557 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
5558 semsg("(NFA) COULD NOT OPEN %s!", NFA_REGEXP_DEBUG_LOG);
8989
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5559 return FALSE;
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5560 }
e600e696c0a1 commit https://github.com/vim/vim/commit/dc633cf82758f67f656cda7fa8ccc30414ee53f8
Christian Brabandt <cb@256bit.org>
parents: 8841
diff changeset
5561 #endif
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
5562 nfa_match = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5563
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5564 // Allocate memory for the lists of nodes.
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5565 size = (prog->nstate + 1) * sizeof(nfa_thread_T);
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
5566
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
5567 list[0].t = alloc(size);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5568 list[0].len = prog->nstate + 1;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
5569 list[1].t = alloc(size);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5570 list[1].len = prog->nstate + 1;
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5571 if (list[0].t == NULL || list[1].t == NULL)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5572 goto theend;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5573
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5574 #ifdef ENABLE_LOG
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
5575 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5576 if (log_fd != NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5577 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5578 fprintf(log_fd, "**********************************\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5579 nfa_set_code(start->c);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5580 fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n",
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5581 abs(start->id), code);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5582 fprintf(log_fd, "**********************************\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5583 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5584 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5585 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
5586 emsg(_(e_log_open_failed));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5587 log_fd = stderr;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5588 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5589 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5590
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5591 thislist = &list[0];
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5592 thislist->n = 0;
5227
a08fa2919f2b updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents: 5221
diff changeset
5593 thislist->has_pim = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5594 nextlist = &list[1];
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5595 nextlist->n = 0;
5227
a08fa2919f2b updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents: 5221
diff changeset
5596 nextlist->has_pim = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5597 #ifdef ENABLE_LOG
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5598 fprintf(log_fd, "(---) STARTSTATE first\n");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5599 #endif
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5600 thislist->id = rex.nfa_listid + 1;
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5601
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5602 // Inline optimized code for addstate(thislist, start, m, 0) if we know
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5603 // it's the first MOPEN.
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5604 if (toplevel)
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5605 {
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5606 if (REG_MULTI)
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5607 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5608 m->norm.list.multi[0].start_lnum = rex.lnum;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5609 m->norm.list.multi[0].start_col = (colnr_T)(rex.input - rex.line);
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5610 }
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5611 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5612 m->norm.list.line[0].start = rex.input;
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5613 m->norm.in_use = 1;
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5614 r = addstate(thislist, start->out, m, NULL, 0);
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5615 }
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
5616 else
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5617 r = addstate(thislist, start, m, NULL, 0);
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5618 if (r == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5619 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5620 nfa_match = NFA_TOO_EXPENSIVE;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5621 goto theend;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5622 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5623
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5624 #define ADD_STATE_IF_MATCH(state) \
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5625 if (result) { \
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5626 add_state = state->out; \
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5627 add_off = clen; \
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5628 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5629
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5630 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5631 * Run for each character.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5632 */
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
5633 for (;;)
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
5634 {
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5635 int curc;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5636 int clen;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5637
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5638 if (has_mbyte)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5639 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5640 curc = (*mb_ptr2char)(rex.input);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5641 clen = (*mb_ptr2len)(rex.input);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5642 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5643 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5644 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5645 curc = *rex.input;
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5646 clen = 1;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5647 }
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5648 if (curc == NUL)
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
5649 {
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5650 clen = 0;
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
5651 go_to_nextline = FALSE;
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
5652 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5653
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5654 // swap lists
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5655 thislist = &list[flag];
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5656 nextlist = &list[flag ^= 1];
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5657 nextlist->n = 0; // clear nextlist
5227
a08fa2919f2b updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents: 5221
diff changeset
5658 nextlist->has_pim = FALSE;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5659 ++rex.nfa_listid;
14161
7cac4646c552 patch 8.1.0098: segfault when pattern with z() is very slow
Christian Brabandt <cb@256bit.org>
parents: 14159
diff changeset
5660 if (prog->re_engine == AUTOMATIC_ENGINE
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5661 && (rex.nfa_listid >= NFA_MAX_STATES
14173
4b59671bce9c patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents: 14163
diff changeset
5662 # ifdef FEAT_EVAL
4b59671bce9c patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents: 14163
diff changeset
5663 || nfa_fail_for_testing
4b59671bce9c patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents: 14163
diff changeset
5664 # endif
4b59671bce9c patch 8.1.0104: can't build without the +eval feature
Christian Brabandt <cb@256bit.org>
parents: 14163
diff changeset
5665 ))
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5666 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5667 // too many states, retry with old engine
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5668 nfa_match = NFA_TOO_EXPENSIVE;
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5669 goto theend;
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5670 }
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5671
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5672 thislist->id = rex.nfa_listid;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5673 nextlist->id = rex.nfa_listid + 1;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5674
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5675 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5676 fprintf(log_fd, "------------------------------------------\n");
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5677 fprintf(log_fd, ">>> Reginput is \"%s\"\n", rex.input);
14145
1cf832945469 patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents: 14121
diff changeset
5678 fprintf(log_fd, ">>> Advanced one character... Current char is %c (code %d) \n", curc, (int)curc);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5679 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
5680 {
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5681 int i;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5682
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5683 for (i = 0; i < thislist->n; i++)
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
5684 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
5685 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5686 fprintf(log_fd, "\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5687 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5688
4460
fe8a0a6a1c2a updated for version 7.3.978
Bram Moolenaar <bram@vim.org>
parents: 4458
diff changeset
5689 #ifdef NFA_REGEXP_DEBUG_LOG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5690 fprintf(debug, "\n-------------------\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5691 #endif
4480
035fb0d5e7ce updated for version 7.3.988
Bram Moolenaar <bram@vim.org>
parents: 4470
diff changeset
5692 /*
035fb0d5e7ce updated for version 7.3.988
Bram Moolenaar <bram@vim.org>
parents: 4470
diff changeset
5693 * If the state lists are empty we can stop.
035fb0d5e7ce updated for version 7.3.988
Bram Moolenaar <bram@vim.org>
parents: 4470
diff changeset
5694 */
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5695 if (thislist->n == 0)
4480
035fb0d5e7ce updated for version 7.3.988
Bram Moolenaar <bram@vim.org>
parents: 4470
diff changeset
5696 break;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5697
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5698 // compute nextlist
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5699 for (listidx = 0; listidx < thislist->n; ++listidx)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5700 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5701 // If the list gets very long there probably is something wrong.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5702 // At least allow interrupting with CTRL-C.
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5703 fast_breakcheck();
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5704 if (got_int)
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5705 break;
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5706 #ifdef FEAT_RELTIME
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5707 if (nfa_time_limit != NULL && ++nfa_time_count == 20)
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5708 {
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5709 nfa_time_count = 0;
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5710 if (nfa_did_time_out())
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5711 break;
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5712 }
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
5713 #endif
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5714 t = &thislist->t[listidx];
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5715
4460
fe8a0a6a1c2a updated for version 7.3.978
Bram Moolenaar <bram@vim.org>
parents: 4458
diff changeset
5716 #ifdef NFA_REGEXP_DEBUG_LOG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5717 nfa_set_code(t->state->c);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5718 fprintf(debug, "%s, ", code);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5719 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5720 #ifdef ENABLE_LOG
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5721 {
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5722 int col;
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5723
4690
9d97a0c045ef updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents: 4688
diff changeset
5724 if (t->subs.norm.in_use <= 0)
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5725 col = -1;
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5726 else if (REG_MULTI)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
5727 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
5728 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5729 col = (int)(t->subs.norm.list.line[0].start - rex.line);
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5730 nfa_set_code(t->state->c);
14145
1cf832945469 patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents: 14121
diff changeset
5731 fprintf(log_fd, "(%d) char %d %s (start col %d)%s... \n",
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5732 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
5733 pim_info(&t->pim));
4657
93b7ed814bec updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents: 4655
diff changeset
5734 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5735 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5736
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5737 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5738 * Handle the possible codes of the current state.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5739 * The most important is NFA_MATCH.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5740 */
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5741 add_state = NULL;
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
5742 add_here = FALSE;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5743 add_count = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5744 switch (t->state->c)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5745 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5746 case NFA_MATCH:
4567
96c1a7850097 updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents: 4565
diff changeset
5747 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5748 // If the match ends before a composing characters and
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5749 // rex.reg_icombine is not set, that is not really a match.
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
5750 if (enc_utf8 && !rex.reg_icombine && utf_iscomposing(curc))
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
5751 break;
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
5752
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
5753 nfa_match = TRUE;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5754 copy_sub(&submatch->norm, &t->subs.norm);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5755 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5756 if (rex.nfa_has_zsubexpr)
4712
832bf8136d86 updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents: 4696
diff changeset
5757 copy_sub(&submatch->synt, &t->subs.synt);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5758 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5759 #ifdef ENABLE_LOG
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5760 log_subsexpr(&t->subs);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5761 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5762 // Found the left-most longest match, do not look at any other
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5763 // states at this position. When the list of states is going
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5764 // to be empty quit without advancing, so that "rex.input" is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5765 // correct.
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
5766 if (nextlist->n == 0)
4553
7b835b2969af updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents: 4551
diff changeset
5767 clen = 0;
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
5768 goto nextchar;
4567
96c1a7850097 updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents: 4565
diff changeset
5769 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5770
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5771 case NFA_END_INVISIBLE:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
5772 case NFA_END_INVISIBLE_NEG:
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5773 case NFA_END_PATTERN:
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5774 /*
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5775 * 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
5776 * NFA_START_INVISIBLE_BEFORE node.
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
5777 * They surround a zero-width group, used with "\@=", "\&",
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
5778 * "\@!", "\@<=" and "\@<!".
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5779 * If we got here, it means that the current "invisible" group
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5780 * 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
5781 * 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
5782 * in the position in "nfa_endp".
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5783 * 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
5784 */
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
5785 #ifdef ENABLE_LOG
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5786 if (nfa_endp != NULL)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5787 {
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5788 if (REG_MULTI)
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5789 fprintf(log_fd, "Current lnum: %d, endp lnum: %d; current col: %d, endp col: %d\n",
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5790 (int)rex.lnum,
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5791 (int)nfa_endp->se_u.pos.lnum,
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5792 (int)(rex.input - rex.line),
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5793 nfa_endp->se_u.pos.col);
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5794 else
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5795 fprintf(log_fd, "Current col: %d, endp col: %d\n",
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5796 (int)(rex.input - rex.line),
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5797 (int)(nfa_endp->se_u.ptr - rex.input));
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5798 }
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
5799 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5800 // If "nfa_endp" is set it's only a match if it ends at
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5801 // "nfa_endp"
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5802 if (nfa_endp != NULL && (REG_MULTI
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5803 ? (rex.lnum != nfa_endp->se_u.pos.lnum
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5804 || (int)(rex.input - rex.line)
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5805 != nfa_endp->se_u.pos.col)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5806 : rex.input != nfa_endp->se_u.ptr))
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5807 break;
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5808
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5809 // do not set submatches for \@!
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
5810 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
5811 {
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5812 copy_sub(&m->norm, &t->subs.norm);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5813 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5814 if (rex.nfa_has_zsubexpr)
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5815 copy_sub(&m->synt, &t->subs.synt);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
5816 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5817 }
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5818 #ifdef ENABLE_LOG
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5819 fprintf(log_fd, "Match found:\n");
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5820 log_subsexpr(m);
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5821 #endif
4716
a804309e7327 updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents: 4714
diff changeset
5822 nfa_match = TRUE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5823 // See comment above at "goto nextchar".
5334
c1ae5baa41f4 updated for version 7.4.020
Bram Moolenaar <bram@vim.org>
parents: 5310
diff changeset
5824 if (nextlist->n == 0)
c1ae5baa41f4 updated for version 7.4.020
Bram Moolenaar <bram@vim.org>
parents: 5310
diff changeset
5825 clen = 0;
c1ae5baa41f4 updated for version 7.4.020
Bram Moolenaar <bram@vim.org>
parents: 5310
diff changeset
5826 goto nextchar;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5827
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5828 case NFA_START_INVISIBLE:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5829 case NFA_START_INVISIBLE_FIRST:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
5830 case NFA_START_INVISIBLE_NEG:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5831 case NFA_START_INVISIBLE_NEG_FIRST:
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
5832 case NFA_START_INVISIBLE_BEFORE:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5833 case NFA_START_INVISIBLE_BEFORE_FIRST:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
5834 case NFA_START_INVISIBLE_BEFORE_NEG:
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5835 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST:
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5836 {
4821
2f1ee97f5f23 updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents: 4819
diff changeset
5837 #ifdef ENABLE_LOG
2f1ee97f5f23 updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents: 4819
diff changeset
5838 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
5839 failure_chance(t->state->out, 0),
2f1ee97f5f23 updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents: 4819
diff changeset
5840 failure_chance(t->state->out1->out, 0));
2f1ee97f5f23 updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents: 4819
diff changeset
5841 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5842 // Do it directly if there already is a PIM or when
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5843 // nfa_postprocess() detected it will work better.
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5844 if (t->pim.result != NFA_PIM_UNUSED
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5845 || t->state->c == NFA_START_INVISIBLE_FIRST
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5846 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5847 || t->state->c == NFA_START_INVISIBLE_BEFORE_FIRST
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5848 || 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
5849 {
5029
c9e2ccc53f2e updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents: 5006
diff changeset
5850 int in_use = m->norm.in_use;
c9e2ccc53f2e updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents: 5006
diff changeset
5851
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5852 // Copy submatch info for the recursive call, opposite
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5853 // of what happens on success below.
4997
8a7d3a73adab updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents: 4958
diff changeset
5854 copy_sub_off(&m->norm, &t->subs.norm);
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5855 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5856 if (rex.nfa_has_zsubexpr)
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5857 copy_sub_off(&m->synt, &t->subs.synt);
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5858 #endif
4997
8a7d3a73adab updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents: 4958
diff changeset
5859
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5860 /*
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5861 * First try matching the invisible match, then what
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5862 * follows.
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5863 */
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5864 result = recursive_regmatch(t->state, NULL, prog,
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
5865 submatch, m, &listids, &listids_len);
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5866 if (result == NFA_TOO_EXPENSIVE)
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5867 {
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5868 nfa_match = result;
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5869 goto theend;
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5870 }
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5871
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5872 // for \@! and \@<! it is a match when the result is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5873 // FALSE
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
5874 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
5875 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5876 || t->state->c
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5877 == NFA_START_INVISIBLE_BEFORE_NEG
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5878 || t->state->c
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
5879 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST))
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5880 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5881 // Copy submatch info from the recursive call
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5882 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
5883 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5884 if (rex.nfa_has_zsubexpr)
4768
82e6588762e4 updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents: 4762
diff changeset
5885 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
5886 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5887 // If the pattern has \ze and it matched in the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5888 // sub pattern, use it.
5372
c3d379c2a115 updated for version 7.4.037
Bram Moolenaar <bram@vim.org>
parents: 5370
diff changeset
5889 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
5890
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5891 // t->state->out1 is the corresponding
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5892 // END_INVISIBLE node; Add its out to the current
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5893 // list (zero-width match).
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
5894 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
5895 add_state = t->state->out1->out;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5896 }
5029
c9e2ccc53f2e updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents: 5006
diff changeset
5897 m->norm.in_use = in_use;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5898 }
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5899 else
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5900 {
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5901 nfa_pim_T pim;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5902
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5903 /*
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5904 * 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
5905 * 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
5906 * 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
5907 * about the invisible match.
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5908 */
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5909 pim.state = t->state;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5910 pim.result = NFA_PIM_TODO;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5911 pim.subs.norm.in_use = 0;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5912 #ifdef FEAT_SYN_HL
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5913 pim.subs.synt.in_use = 0;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5914 #endif
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5915 if (REG_MULTI)
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5916 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5917 pim.end.pos.col = (int)(rex.input - rex.line);
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5918 pim.end.pos.lnum = rex.lnum;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5919 }
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5920 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5921 pim.end.ptr = rex.input;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5922
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5923 // t->state->out1 is the corresponding END_INVISIBLE
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5924 // node; Add its out to the current list (zero-width
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5925 // match).
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5926 if (addstate_here(thislist, t->state->out1->out,
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5927 &t->subs, &pim, &listidx) == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5928 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5929 nfa_match = NFA_TOO_EXPENSIVE;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5930 goto theend;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
5931 }
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
5932 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5933 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5934 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5935
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5936 case NFA_START_PATTERN:
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5937 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5938 nfa_state_T *skip = NULL;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5939 #ifdef ENABLE_LOG
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5940 int skip_lid = 0;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5941 #endif
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5942
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5943 // There is no point in trying to match the pattern if the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5944 // output state is not going to be added to the list.
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5945 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
5946 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5947 skip = t->state->out1->out;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5948 #ifdef ENABLE_LOG
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5949 skip_lid = nextlist->id;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5950 #endif
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5951 }
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5952 else if (state_in_list(nextlist,
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5953 t->state->out1->out->out, &t->subs))
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5954 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5955 skip = t->state->out1->out->out;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5956 #ifdef ENABLE_LOG
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5957 skip_lid = nextlist->id;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5958 #endif
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5959 }
4897
91136a41f83f updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents: 4893
diff changeset
5960 else if (state_in_list(thislist,
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5961 t->state->out1->out->out, &t->subs))
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5962 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5963 skip = t->state->out1->out->out;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5964 #ifdef ENABLE_LOG
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5965 skip_lid = thislist->id;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5966 #endif
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5967 }
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5968 if (skip != NULL)
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5969 {
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5970 #ifdef ENABLE_LOG
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5971 nfa_set_code(skip->c);
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5972 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
5973 abs(skip->id), skip_lid, skip->c, code);
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5974 #endif
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5975 break;
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5976 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5977 // Copy submatch info to the recursive call, opposite of what
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5978 // happens afterwards.
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5979 copy_sub_off(&m->norm, &t->subs.norm);
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5980 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
5981 if (rex.nfa_has_zsubexpr)
5370
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5982 copy_sub_off(&m->synt, &t->subs.synt);
90e2f0729a0d updated for version 7.4.036
Bram Moolenaar <bram@vim.org>
parents: 5360
diff changeset
5983 #endif
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
5984
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
5985 // First try matching the pattern.
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
5986 result = recursive_regmatch(t->state, NULL, prog,
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
5987 submatch, m, &listids, &listids_len);
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5988 if (result == NFA_TOO_EXPENSIVE)
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5989 {
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5990 nfa_match = result;
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5991 goto theend;
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
5992 }
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5993 if (result)
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 int bytelen;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5996
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5997 #ifdef ENABLE_LOG
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5998 fprintf(log_fd, "NFA_START_PATTERN matches:\n");
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
5999 log_subsexpr(m);
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6000 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6001 // Copy submatch info from the recursive call
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6002 copy_sub_off(&t->subs.norm, &m->norm);
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6003 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6004 if (rex.nfa_has_zsubexpr)
4768
82e6588762e4 updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents: 4762
diff changeset
6005 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
6006 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6007 // Now we need to skip over the matched text and then
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6008 // continue with what follows.
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6009 if (REG_MULTI)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6010 // TODO: multi-line match
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
6011 bytelen = m->norm.list.multi[0].end_col
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6012 - (int)(rex.input - rex.line);
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6013 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6014 bytelen = (int)(m->norm.list.line[0].end - rex.input);
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6015
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6016 #ifdef ENABLE_LOG
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6017 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
6018 #endif
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6019 if (bytelen == 0)
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6020 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6021 // empty match, output of corresponding
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6022 // NFA_END_PATTERN/NFA_SKIP to be used at current
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6023 // position
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6024 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6025 add_state = t->state->out1->out->out;
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6026 }
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6027 else if (bytelen <= clen)
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6028 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6029 // match current character, output of corresponding
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6030 // NFA_END_PATTERN to be used at next position.
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6031 add_state = t->state->out1->out->out;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6032 add_off = clen;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6033 }
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6034 else
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6035 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6036 // skip over the matched characters, set character
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6037 // count in NFA_SKIP
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6038 add_state = t->state->out1->out;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6039 add_off = bytelen;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6040 add_count = bytelen - clen;
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6041 }
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6042 }
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6043 break;
4787
7fde662e1db2 updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents: 4785
diff changeset
6044 }
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6045
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6046 case NFA_BOL:
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6047 if (rex.input == rex.line)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6048 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6049 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6050 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6051 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6052 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6053
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6054 case NFA_EOL:
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6055 if (curc == NUL)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6056 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6057 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6058 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6059 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6060 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6061
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6062 case NFA_BOW:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6063 result = TRUE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6064
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6065 if (curc == NUL)
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6066 result = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6067 else if (has_mbyte)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6068 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6069 int this_class;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6070
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6071 // Get class of current and previous char (if it exists).
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6072 this_class = mb_get_class_buf(rex.input, rex.reg_buf);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6073 if (this_class <= 1)
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6074 result = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6075 else if (reg_prev_class() == this_class)
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6076 result = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6077 }
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6078 else if (!vim_iswordc_buf(curc, rex.reg_buf)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6079 || (rex.input > rex.line
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6080 && vim_iswordc_buf(rex.input[-1], rex.reg_buf)))
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6081 result = FALSE;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6082 if (result)
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 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6087 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6088
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6089 case NFA_EOW:
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6090 result = TRUE;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6091 if (rex.input == rex.line)
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6092 result = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6093 else if (has_mbyte)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6094 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6095 int this_class, prev_class;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6096
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6097 // Get class of current and previous char (if it exists).
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6098 this_class = mb_get_class_buf(rex.input, rex.reg_buf);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6099 prev_class = reg_prev_class();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6100 if (this_class == prev_class
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6101 || prev_class == 0 || prev_class == 1)
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6102 result = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6103 }
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6104 else if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf)
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6105 || (rex.input[0] != NUL
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6106 && vim_iswordc_buf(curc, rex.reg_buf)))
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6107 result = FALSE;
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6108 if (result)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6109 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6110 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6111 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6112 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6113 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6114
4671
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
6115 case NFA_BOF:
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6116 if (rex.lnum == 0 && rex.input == rex.line
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6117 && (!REG_MULTI || rex.reg_firstlnum == 1))
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6118 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6119 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6120 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6121 }
4671
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
6122 break;
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
6123
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
6124 case NFA_EOF:
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6125 if (rex.lnum == rex.reg_maxline && curc == NUL)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6126 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6127 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6128 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6129 }
4671
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
6130 break;
b3c59716e700 updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents: 4669
diff changeset
6131
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6132 case NFA_COMPOSING:
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
6133 {
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6134 int mc = curc;
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
6135 int len = 0;
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
6136 nfa_state_T *end;
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
6137 nfa_state_T *sta;
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6138 int cchars[MAX_MCO];
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6139 int ccount = 0;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6140 int j;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6141
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6142 sta = t->state->out;
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
6143 len = 0;
4535
45f97c349537 updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents: 4533
diff changeset
6144 if (utf_iscomposing(sta->c))
45f97c349537 updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents: 4533
diff changeset
6145 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6146 // Only match composing character(s), ignore base
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6147 // character. Used for ".{composing}" and "{composing}"
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6148 // (no preceding character).
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6149 len += mb_char2len(mc);
4535
45f97c349537 updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents: 4533
diff changeset
6150 }
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6151 if (rex.reg_icombine && len == 0)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6152 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6153 // If \Z was present, then ignore composing characters.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6154 // When ignoring the base character this always matches.
13208
e96663c35bab patch 8.0.1478: unnecessary condition
Christian Brabandt <cb@256bit.org>
parents: 13192
diff changeset
6155 if (sta->c != curc)
4529
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6156 result = FAIL;
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6157 else
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6158 result = OK;
4529
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6159 while (sta->c != NFA_END_COMPOSING)
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6160 sta = sta->out;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6161 }
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6162
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6163 // Check base character matches first, unless ignored.
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6164 else if (len > 0 || mc == sta->c)
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6165 {
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6166 if (len == 0)
4529
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6167 {
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6168 len += mb_char2len(mc);
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6169 sta = sta->out;
432a6b8c7d93 updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents: 4527
diff changeset
6170 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6171
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6172 // We don't care about the order of composing characters.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6173 // Get them into cchars[] first.
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6174 while (len < clen)
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6175 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6176 mc = mb_ptr2char(rex.input + len);
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6177 cchars[ccount++] = mc;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6178 len += mb_char2len(mc);
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6179 if (ccount == MAX_MCO)
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6180 break;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6181 }
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6182
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6183 // Check that each composing char in the pattern matches a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6184 // composing char in the text. We do not check if all
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6185 // composing chars are matched.
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6186 result = OK;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6187 while (sta->c != NFA_END_COMPOSING)
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6188 {
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6189 for (j = 0; j < ccount; ++j)
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6190 if (cchars[j] == sta->c)
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6191 break;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6192 if (j == ccount)
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6193 {
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6194 result = FAIL;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6195 break;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6196 }
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6197 sta = sta->out;
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6198 }
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6199 }
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6200 else
4525
36ddcf4cecbc updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents: 4517
diff changeset
6201 result = FAIL;
4547
fc997f05cbc7 updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents: 4543
diff changeset
6202
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6203 end = t->state->out1; // NFA_END_COMPOSING
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6204 ADD_STATE_IF_MATCH(end);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6205 break;
4527
55bcaa1d2749 updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents: 4525
diff changeset
6206 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6207
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6208 case NFA_NEWL:
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6209 if (curc == NUL && !rex.reg_line_lbr && REG_MULTI
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6210 && rex.lnum <= rex.reg_maxline)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6211 {
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
6212 go_to_nextline = TRUE;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6213 // Pass -1 for the offset, which means taking the position
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6214 // at the start of the next line.
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6215 add_state = t->state->out;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6216 add_off = -1;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6217 }
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6218 else if (curc == '\n' && rex.reg_line_lbr)
4555
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
6219 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6220 // 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
6221 add_state = t->state->out;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6222 add_off = 1;
4555
b2946c06d1b6 updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents: 4553
diff changeset
6223 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6224 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6225
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6226 case NFA_START_COLL:
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6227 case NFA_START_NEG_COLL:
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6228 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6229 // What follows is a list of characters, until NFA_END_COLL.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6230 // One of them must match or none of them must match.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6231 nfa_state_T *state;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6232 int result_if_matched;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6233 int c1, c2;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6234
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6235 // Never match EOL. If it's part of the collection it is added
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6236 // as a separate state with an OR.
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6237 if (curc == NUL)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6238 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6239
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6240 state = t->state->out;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6241 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
6242 for (;;)
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6243 {
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6244 if (state->c == NFA_END_COLL)
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 result = !result_if_matched;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6247 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6248 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6249 if (state->c == NFA_RANGE_MIN)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6250 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6251 c1 = state->val;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6252 state = state->out; // advance to NFA_RANGE_MAX
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6253 c2 = state->val;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6254 #ifdef ENABLE_LOG
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6255 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
6256 curc, c1, c2);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6257 #endif
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6258 if (curc >= c1 && curc <= c2)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6259 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6260 result = result_if_matched;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6261 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6262 }
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6263 if (rex.reg_ic)
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6264 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6265 int curc_low = MB_TOLOWER(curc);
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6266 int done = FALSE;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6267
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6268 for ( ; c1 <= c2; ++c1)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6269 if (MB_TOLOWER(c1) == curc_low)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6270 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6271 result = result_if_matched;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6272 done = TRUE;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6273 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6274 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6275 if (done)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6276 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6277 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6278 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6279 else if (state->c < 0 ? check_char_class(state->c, curc)
13192
9bd4151e5aeb patch 8.0.1470: integer overflow when using regexp pattern
Christian Brabandt <cb@256bit.org>
parents: 13043
diff changeset
6280 : (curc == state->c
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6281 || (rex.reg_ic && MB_TOLOWER(curc)
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6282 == MB_TOLOWER(state->c))))
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6283 {
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6284 result = result_if_matched;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6285 break;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6286 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6287 state = state->out;
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6288 }
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6289 if (result)
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6290 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6291 // next state is in out of the NFA_END_COLL, out1 of
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6292 // START points to the END state
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6293 add_state = t->state->out1->out;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6294 add_off = clen;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6295 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6296 break;
4781
c02c7df9bdc9 updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents: 4772
diff changeset
6297 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6298
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6299 case NFA_ANY:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6300 // 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
6301 if (curc > 0)
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6302 {
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6303 add_state = t->state->out;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6304 add_off = clen;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6305 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6306 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6307
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6308 case NFA_ANY_COMPOSING:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6309 // On a composing character skip over it. Otherwise do
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6310 // nothing. Always matches.
5901
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6311 if (enc_utf8 && utf_iscomposing(curc))
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6312 {
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6313 add_off = clen;
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6314 }
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6315 else
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6316 {
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6317 add_here = TRUE;
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6318 add_off = 0;
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6319 }
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6320 add_state = t->state->out;
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6321 break;
10fc95f48546 updated for version 7.4.293
Bram Moolenaar <bram@vim.org>
parents: 5895
diff changeset
6322
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6323 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6324 * Character classes like \a for alpha, \d for digit etc.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6325 */
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6326 case NFA_IDENT: // \i
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6327 result = vim_isIDc(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6328 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6329 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6330
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6331 case NFA_SIDENT: // \I
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6332 result = !VIM_ISDIGIT(curc) && vim_isIDc(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6333 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6334 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6335
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6336 case NFA_KWORD: // \k
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6337 result = vim_iswordp_buf(rex.input, rex.reg_buf);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6338 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6339 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6340
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6341 case NFA_SKWORD: // \K
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6342 result = !VIM_ISDIGIT(curc)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6343 && vim_iswordp_buf(rex.input, rex.reg_buf);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6344 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6345 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6346
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6347 case NFA_FNAME: // \f
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6348 result = vim_isfilec(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6349 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6350 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6351
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6352 case NFA_SFNAME: // \F
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6353 result = !VIM_ISDIGIT(curc) && vim_isfilec(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6354 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6355 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6356
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6357 case NFA_PRINT: // \p
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6358 result = vim_isprintc(PTR2CHAR(rex.input));
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6359 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6360 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6361
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6362 case NFA_SPRINT: // \P
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6363 result = !VIM_ISDIGIT(curc) && vim_isprintc(PTR2CHAR(rex.input));
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6364 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6365 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6366
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6367 case NFA_WHITE: // \s
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
6368 result = VIM_ISWHITE(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6369 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6370 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6371
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6372 case NFA_NWHITE: // \S
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
6373 result = curc != NUL && !VIM_ISWHITE(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6374 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6375 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6376
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6377 case NFA_DIGIT: // \d
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6378 result = ri_digit(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6379 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6380 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6381
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6382 case NFA_NDIGIT: // \D
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6383 result = curc != NUL && !ri_digit(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6384 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6385 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6386
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6387 case NFA_HEX: // \x
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6388 result = ri_hex(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6389 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6390 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6391
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6392 case NFA_NHEX: // \X
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6393 result = curc != NUL && !ri_hex(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6394 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6395 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6396
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6397 case NFA_OCTAL: // \o
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6398 result = ri_octal(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6399 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6400 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6401
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6402 case NFA_NOCTAL: // \O
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6403 result = curc != NUL && !ri_octal(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6404 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6405 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6406
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6407 case NFA_WORD: // \w
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6408 result = ri_word(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6409 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6410 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6411
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6412 case NFA_NWORD: // \W
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6413 result = curc != NUL && !ri_word(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6414 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6415 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6416
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6417 case NFA_HEAD: // \h
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6418 result = ri_head(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6419 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6420 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6421
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6422 case NFA_NHEAD: // \H
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6423 result = curc != NUL && !ri_head(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6424 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6425 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6426
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6427 case NFA_ALPHA: // \a
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6428 result = ri_alpha(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6429 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6430 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6431
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6432 case NFA_NALPHA: // \A
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6433 result = curc != NUL && !ri_alpha(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6434 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6435 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6436
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6437 case NFA_LOWER: // \l
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6438 result = ri_lower(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6439 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6440 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6441
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6442 case NFA_NLOWER: // \L
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6443 result = curc != NUL && !ri_lower(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6444 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6445 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6446
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6447 case NFA_UPPER: // \u
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6448 result = ri_upper(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6449 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6450 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6451
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6452 case NFA_NUPPER: // \U
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6453 result = curc != NUL && !ri_upper(curc);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6454 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6455 break;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6456
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6457 case NFA_LOWER_IC: // [a-z]
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6458 result = ri_lower(curc) || (rex.reg_ic && ri_upper(curc));
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6459 ADD_STATE_IF_MATCH(t->state);
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6460 break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6461
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6462 case NFA_NLOWER_IC: // [^a-z]
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6463 result = curc != NUL
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6464 && !(ri_lower(curc) || (rex.reg_ic && ri_upper(curc)));
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6465 ADD_STATE_IF_MATCH(t->state);
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6466 break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6467
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6468 case NFA_UPPER_IC: // [A-Z]
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6469 result = ri_upper(curc) || (rex.reg_ic && ri_lower(curc));
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6470 ADD_STATE_IF_MATCH(t->state);
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6471 break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6472
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6473 case NFA_NUPPER_IC: // ^[A-Z]
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6474 result = curc != NUL
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6475 && !(ri_upper(curc) || (rex.reg_ic && ri_lower(curc)));
5296
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6476 ADD_STATE_IF_MATCH(t->state);
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6477 break;
3e9107b86b68 updated for version 7.4.001
Bram Moolenaar <bram@vim.org>
parents: 5255
diff changeset
6478
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6479 case NFA_BACKREF1:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6480 case NFA_BACKREF2:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6481 case NFA_BACKREF3:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6482 case NFA_BACKREF4:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6483 case NFA_BACKREF5:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6484 case NFA_BACKREF6:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6485 case NFA_BACKREF7:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6486 case NFA_BACKREF8:
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6487 case NFA_BACKREF9:
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6488 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6489 case NFA_ZREF1:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6490 case NFA_ZREF2:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6491 case NFA_ZREF3:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6492 case NFA_ZREF4:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6493 case NFA_ZREF5:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6494 case NFA_ZREF6:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6495 case NFA_ZREF7:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6496 case NFA_ZREF8:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6497 case NFA_ZREF9:
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6498 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6499 // \1 .. \9 \z1 .. \z9
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6500 {
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6501 int subidx;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6502 int bytelen;
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6503
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6504 if (t->state->c <= NFA_BACKREF9)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6505 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6506 subidx = t->state->c - NFA_BACKREF1 + 1;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6507 result = match_backref(&t->subs.norm, subidx, &bytelen);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6508 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6509 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6510 else
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6511 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6512 subidx = t->state->c - NFA_ZREF1 + 1;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6513 result = match_zref(subidx, &bytelen);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6514 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6515 #endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6516
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6517 if (result)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6518 {
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6519 if (bytelen == 0)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6520 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6521 // empty match always works, output of NFA_SKIP to be
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6522 // used next
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6523 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6524 add_state = t->state->out->out;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6525 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6526 else if (bytelen <= clen)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6527 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6528 // match current character, jump ahead to out of
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6529 // NFA_SKIP
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6530 add_state = t->state->out->out;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6531 add_off = clen;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6532 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6533 else
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6534 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6535 // skip over the matched characters, set character
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6536 // count in NFA_SKIP
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6537 add_state = t->state->out;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6538 add_off = bytelen;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6539 add_count = bytelen - clen;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6540 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6541 }
4482
cd005ab15ef3 updated for version 7.3.989
Bram Moolenaar <bram@vim.org>
parents: 4480
diff changeset
6542 break;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6543 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6544 case NFA_SKIP:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6545 // character of previous matching \1 .. \9 or \@>
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6546 if (t->count - clen <= 0)
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6547 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6548 // end of match, go to what follows
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6549 add_state = t->state->out;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6550 add_off = clen;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6551 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6552 else
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6553 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6554 // add state again with decremented count
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6555 add_state = t->state;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6556 add_off = 0;
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6557 add_count = t->count - clen;
4571
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6558 }
b2a8e3a66f8c updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents: 4569
diff changeset
6559 break;
4482
cd005ab15ef3 updated for version 7.3.989
Bram Moolenaar <bram@vim.org>
parents: 4480
diff changeset
6560
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6561 case NFA_LNUM:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6562 case NFA_LNUM_GT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6563 case NFA_LNUM_LT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6564 result = (REG_MULTI &&
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6565 nfa_re_num_cmp(t->state->val, t->state->c - NFA_LNUM,
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6566 (long_u)(rex.lnum + rex.reg_firstlnum)));
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6567 if (result)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6568 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6569 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6570 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6571 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6572 break;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6573
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6574 case NFA_COL:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6575 case NFA_COL_GT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6576 case NFA_COL_LT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6577 result = nfa_re_num_cmp(t->state->val, t->state->c - NFA_COL,
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6578 (long_u)(rex.input - rex.line) + 1);
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6579 if (result)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6580 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6581 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6582 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6583 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6584 break;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6585
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6586 case NFA_VCOL:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6587 case NFA_VCOL_GT:
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6588 case NFA_VCOL_LT:
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6589 {
6499
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6590 int op = t->state->c - NFA_VCOL;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6591 colnr_T col = (colnr_T)(rex.input - rex.line);
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6592 win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win;
6499
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6593
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6594 // Bail out quickly when there can't be a match, avoid the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6595 // overhead of win_linetabsize() on long lines.
6653
2c7f279d419c updated for version 7.4.651
Bram Moolenaar <bram@vim.org>
parents: 6594
diff changeset
6596 if (op != 1 && col > t->state->val
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
6597 * (has_mbyte ? MB_MAXBYTES : 1))
6499
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6598 break;
6510
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6599 result = FALSE;
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6600 if (op == 1 && col - 1 > t->state->val && col > 100)
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6601 {
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6602 int ts = wp->w_buffer->b_p_ts;
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6603
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6604 // Guess that a character won't use more columns than
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6605 // 'tabstop', with a minimum of 4.
6510
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6606 if (ts < 4)
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6607 ts = 4;
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6608 result = col > t->state->val * ts;
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6609 }
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6610 if (!result)
dfd593d81818 updated for version 7.4.582
Bram Moolenaar <bram@vim.org>
parents: 6499
diff changeset
6611 result = nfa_re_num_cmp(t->state->val, op,
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6612 (long_u)win_linetabsize(wp, rex.line, col) + 1);
6499
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6613 if (result)
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6614 {
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6615 add_here = TRUE;
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6616 add_state = t->state->out;
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6617 }
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6618 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6619 break;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6620
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6621 case NFA_MARK:
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6622 case NFA_MARK_GT:
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6623 case NFA_MARK_LT:
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6624 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6625 pos_T *pos = getmark_buf(rex.reg_buf, t->state->val, FALSE);
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6626
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6627 // Compare the mark position to the match position.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6628 result = (pos != NULL // mark doesn't exist
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6629 && pos->lnum > 0 // mark isn't set in reg_buf
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6630 && (pos->lnum == rex.lnum + rex.reg_firstlnum
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6631 ? (pos->col == (colnr_T)(rex.input - rex.line)
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6632 ? t->state->c == NFA_MARK
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6633 : (pos->col < (colnr_T)(rex.input - rex.line)
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6634 ? t->state->c == NFA_MARK_GT
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6635 : t->state->c == NFA_MARK_LT))
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6636 : (pos->lnum < rex.lnum + rex.reg_firstlnum
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6637 ? t->state->c == NFA_MARK_GT
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6638 : t->state->c == NFA_MARK_LT)));
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6639 if (result)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6640 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6641 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6642 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6643 }
4732
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6644 break;
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6645 }
0798b096bab3 updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents: 4730
diff changeset
6646
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6647 case NFA_CURSOR:
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6648 result = (rex.reg_win != NULL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6649 && (rex.lnum + rex.reg_firstlnum
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6650 == rex.reg_win->w_cursor.lnum)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6651 && ((colnr_T)(rex.input - rex.line)
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6652 == rex.reg_win->w_cursor.col));
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6653 if (result)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6654 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6655 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6656 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6657 }
4583
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6658 break;
321cfbef9431 updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents: 4579
diff changeset
6659
4756
96f3348f9f11 updated for version 7.3.1125
Bram Moolenaar <bram@vim.org>
parents: 4750
diff changeset
6660 case NFA_VISUAL:
4730
749e2b2755d5 updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents: 4728
diff changeset
6661 result = reg_match_visual();
749e2b2755d5 updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents: 4728
diff changeset
6662 if (result)
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6663 {
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6664 add_here = TRUE;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6665 add_state = t->state->out;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6666 }
4730
749e2b2755d5 updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents: 4728
diff changeset
6667 break;
749e2b2755d5 updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents: 4728
diff changeset
6668
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6669 case NFA_MOPEN1:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6670 case NFA_MOPEN2:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6671 case NFA_MOPEN3:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6672 case NFA_MOPEN4:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6673 case NFA_MOPEN5:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6674 case NFA_MOPEN6:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6675 case NFA_MOPEN7:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6676 case NFA_MOPEN8:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6677 case NFA_MOPEN9:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6678 #ifdef FEAT_SYN_HL
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6679 case NFA_ZOPEN:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6680 case NFA_ZOPEN1:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6681 case NFA_ZOPEN2:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6682 case NFA_ZOPEN3:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6683 case NFA_ZOPEN4:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6684 case NFA_ZOPEN5:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6685 case NFA_ZOPEN6:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6686 case NFA_ZOPEN7:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6687 case NFA_ZOPEN8:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6688 case NFA_ZOPEN9:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6689 #endif
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6690 case NFA_NOPEN:
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6691 case NFA_ZSTART:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6692 // These states are only added to be able to bail out when
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6693 // they are added again, nothing is to be done.
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6694 break;
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6695
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6696 default: // regular character
4559
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6697 {
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6698 int c = t->state->c;
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6699
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6700 #ifdef DEBUG
4785
3b5a023a4543 updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents: 4783
diff changeset
6701 if (c < 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
6702 siemsg("INTERNAL: Negative state char: %ld", c);
5251
2e63b6c763f7 updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents: 5227
diff changeset
6703 #endif
4559
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6704 result = (c == curc);
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6705
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6706 if (!result && rex.reg_ic)
4559
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6707 result = MB_TOLOWER(c) == MB_TOLOWER(curc);
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6708 // If rex.reg_icombine is not set only skip over the character
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6709 // itself. When it is set skip over composing characters.
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6710 if (result && enc_utf8 && !rex.reg_icombine)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6711 clen = utf_ptr2len(rex.input);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6712 ADD_STATE_IF_MATCH(t->state);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6713 break;
4559
04086e297563 updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents: 4557
diff changeset
6714 }
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6715
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6716 } // switch (t->state->c)
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6717
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6718 if (add_state != NULL)
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6719 {
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6720 nfa_pim_T *pim;
5401
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6721 nfa_pim_T pim_copy;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6722
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6723 if (t->pim.result == NFA_PIM_UNUSED)
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6724 pim = NULL;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6725 else
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6726 pim = &t->pim;
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6727
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6728 // Handle the postponed invisible match if the match might end
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6729 // without advancing and before the end of the line.
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6730 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
6731 {
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6732 if (pim->result == NFA_PIM_TODO)
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6733 {
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6734 #ifdef ENABLE_LOG
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6735 fprintf(log_fd, "\n");
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6736 fprintf(log_fd, "==================================\n");
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6737 fprintf(log_fd, "Postponed recursive nfa_regmatch()\n");
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6738 fprintf(log_fd, "\n");
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6739 #endif
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6740 result = recursive_regmatch(pim->state, pim,
14309
15530de011bc patch 8.1.0170: invalid memory use with complicated pattern
Christian Brabandt <cb@256bit.org>
parents: 14173
diff changeset
6741 prog, submatch, m, &listids, &listids_len);
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6742 pim->result = result ? NFA_PIM_MATCH : NFA_PIM_NOMATCH;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6743 // for \@! and \@<! it is a match when the result is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6744 // FALSE
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6745 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
6746 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6747 || pim->state->c
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6748 == NFA_START_INVISIBLE_BEFORE_NEG
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6749 || pim->state->c
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6750 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST))
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6751 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6752 // Copy submatch info from the recursive call
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6753 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
6754 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6755 if (rex.nfa_has_zsubexpr)
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6756 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
6757 #endif
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 }
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6760 else
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6761 {
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6762 result = (pim->result == NFA_PIM_MATCH);
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6763 #ifdef ENABLE_LOG
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6764 fprintf(log_fd, "\n");
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6765 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
6766 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
6767 fprintf(log_fd, "\n");
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6768 #endif
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6769 }
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6770
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6771 // 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
6772 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
6773 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6774 || pim->state->c
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6775 == NFA_START_INVISIBLE_BEFORE_NEG
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6776 || pim->state->c
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
6777 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST))
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6778 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6779 // Copy submatch info from the recursive call
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6780 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
6781 #ifdef FEAT_SYN_HL
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6782 if (rex.nfa_has_zsubexpr)
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6783 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
6784 #endif
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6785 }
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6786 else
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6787 // look-behind match failed, don't add the state
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6788 continue;
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6789
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6790 // Postponed invisible match was handled, don't add it to
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6791 // following states.
4813
bc3f4804cf47 updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents: 4811
diff changeset
6792 pim = NULL;
4726
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6793 }
3849c811cc0b updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents: 4720
diff changeset
6794
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6795 // If "pim" points into l->t it will become invalid when
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6796 // adding the state causes the list to be reallocated. Make a
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6797 // local copy to avoid that.
5401
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6798 if (pim == &t->pim)
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6799 {
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6800 copy_pim(&pim_copy, pim);
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6801 pim = &pim_copy;
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6802 }
e7a2f217a385 updated for version 7.4.051
Bram Moolenaar <bram@vim.org>
parents: 5372
diff changeset
6803
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6804 if (add_here)
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6805 r = addstate_here(thislist, add_state, &t->subs,
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6806 pim, &listidx);
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6807 else
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6808 {
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6809 r = addstate(nextlist, add_state, &t->subs, pim, add_off);
4799
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6810 if (add_count > 0)
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6811 nextlist->t[nextlist->n - 1].count = add_count;
e3f9e33fb28c updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents: 4797
diff changeset
6812 }
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6813 if (r == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6814 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6815 nfa_match = NFA_TOO_EXPENSIVE;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6816 goto theend;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6817 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6818 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6819
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6820 } // for (thislist = thislist; thislist->state; thislist++)
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6821
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6822 // Look for the start of a match in the current position by adding the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6823 // start state to the list of states.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6824 // The first found match is the leftmost one, thus the order of states
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6825 // matters!
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6826 // Do not add the start state in recursive calls of nfa_regmatch(),
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6827 // because recursive calls should only start in the first position.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6828 // Unless "nfa_endp" is not NULL, then we match the end position.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6829 // 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
6830 if (nfa_match == FALSE
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
6831 && ((toplevel
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6832 && rex.lnum == 0
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
6833 && clen != 0
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6834 && (rex.reg_maxcol == 0
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6835 || (colnr_T)(rex.input - rex.line) < rex.reg_maxcol))
4694
efc4fb311d5d updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents: 4692
diff changeset
6836 || (nfa_endp != NULL
4682
2f51ee8825db updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents: 4679
diff changeset
6837 && (REG_MULTI
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6838 ? (rex.lnum < nfa_endp->se_u.pos.lnum
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6839 || (rex.lnum == nfa_endp->se_u.pos.lnum
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6840 && (int)(rex.input - rex.line)
4694
efc4fb311d5d updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents: 4692
diff changeset
6841 < nfa_endp->se_u.pos.col))
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6842 : rex.input < nfa_endp->se_u.ptr))))
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6843 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6844 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6845 fprintf(log_fd, "(---) STARTSTATE\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6846 #endif
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6847 // Inline optimized code for addstate() if we know the state is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6848 // the first MOPEN.
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
6849 if (toplevel)
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
6850 {
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6851 int add = TRUE;
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6852 int c;
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6853
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6854 if (prog->regstart != NUL && clen != 0)
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6855 {
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6856 if (nextlist->n == 0)
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6857 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6858 colnr_T col = (colnr_T)(rex.input - rex.line) + clen;
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6859
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6860 // Nextlist is empty, we can skip ahead to the
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6861 // character that must appear at the start.
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6862 if (skip_to_start(prog->regstart, &col) == FAIL)
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6863 break;
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6864 #ifdef ENABLE_LOG
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6865 fprintf(log_fd, " Skipping ahead %d bytes to regstart\n",
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6866 col - ((colnr_T)(rex.input - rex.line) + clen));
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6867 #endif
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6868 rex.input = rex.line + col - clen;
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6869 }
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6870 else
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6871 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6872 // Checking if the required start character matches is
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6873 // cheaper than adding a state that won't match.
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6874 c = PTR2CHAR(rex.input + clen);
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6875 if (c != prog->regstart && (!rex.reg_ic
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
6876 || MB_TOLOWER(c) != MB_TOLOWER(prog->regstart)))
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6877 {
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6878 #ifdef ENABLE_LOG
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6879 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
6880 #endif
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6881 add = FALSE;
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6882 }
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6883 }
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6884 }
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6885
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6886 if (add)
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6887 {
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6888 if (REG_MULTI)
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
6889 m->norm.list.multi[0].start_col =
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6890 (colnr_T)(rex.input - rex.line) + clen;
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6891 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6892 m->norm.list.line[0].start = rex.input + clen;
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6893 if (addstate(nextlist, start->out, m, NULL, clen) == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6894 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6895 nfa_match = NFA_TOO_EXPENSIVE;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6896 goto theend;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6897 }
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
6898 }
4797
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
6899 }
a30e3762957d updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents: 4787
diff changeset
6900 else
15796
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6901 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6902 if (addstate(nextlist, start, m, NULL, clen) == NULL)
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6903 {
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6904 nfa_match = NFA_TOO_EXPENSIVE;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6905 goto theend;
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6906 }
481452f6687c patch 8.1.0905: complicated regexp causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 15709
diff changeset
6907 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6908 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6909
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6910 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6911 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
6912 {
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6913 int i;
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6914
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6915 for (i = 0; i < thislist->n; i++)
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6916 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
6917 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6918 fprintf(log_fd, "\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6919 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6920
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6921 nextchar:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6922 // Advance to the next character, or advance to the next line, or
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6923 // finish.
4549
849180347ac3 updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents: 4547
diff changeset
6924 if (clen != 0)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6925 rex.input += clen;
4694
efc4fb311d5d updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents: 4692
diff changeset
6926 else if (go_to_nextline || (nfa_endp != NULL && REG_MULTI
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6927 && rex.lnum < nfa_endp->se_u.pos.lnum))
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
6928 reg_nextline();
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
6929 else
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
6930 break;
6499
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6931
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6932 // Allow interrupting with CTRL-C.
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6933 line_breakcheck();
6499
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6934 if (got_int)
bcf9d3a6007f updated for version 7.4.577
Bram Moolenaar <bram@vim.org>
parents: 6392
diff changeset
6935 break;
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6936 #ifdef FEAT_RELTIME
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6937 // Check for timeout once in a twenty times to avoid overhead.
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6938 if (nfa_time_limit != NULL && ++nfa_time_count == 20)
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6939 {
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6940 nfa_time_count = 0;
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
6941 if (nfa_did_time_out())
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6942 break;
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6943 }
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6944 #endif
4515
90e9917d4114 updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents: 4507
diff changeset
6945 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6946
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6947 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6948 if (log_fd != stderr)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6949 fclose(log_fd);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6950 log_fd = NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6951 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6952
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6953 theend:
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6954 // Free memory
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6955 vim_free(list[0].t);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6956 vim_free(list[1].t);
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
6957 vim_free(listids);
4783
47222d8b1e94 updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents: 4781
diff changeset
6958 #undef ADD_STATE_IF_MATCH
4460
fe8a0a6a1c2a updated for version 7.3.978
Bram Moolenaar <bram@vim.org>
parents: 4458
diff changeset
6959 #ifdef NFA_REGEXP_DEBUG_LOG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6960 fclose(debug);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6961 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6962
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
6963 return nfa_match;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6964 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6965
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6966 /*
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6967 * Try match of "prog" with at rex.line["col"].
6392
2bb019eb60ca updated for version 7.4.527
Bram Moolenaar <bram@vim.org>
parents: 6328
diff changeset
6968 * Returns <= 0 for failure, number of lines contained in the match otherwise.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6969 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6970 static long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6971 nfa_regtry(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6972 nfa_regprog_T *prog,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6973 colnr_T col,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6974 proftime_T *tm UNUSED, // timeout limit or NULL
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6975 int *timed_out UNUSED) // flag set on timeout or NULL
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6976 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6977 int i;
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6978 regsubs_T subs, m;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
6979 nfa_state_T *start = prog->start;
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
6980 int result;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6981 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6982 FILE *f;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6983 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6984
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
6985 rex.input = rex.line + col;
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6986 #ifdef FEAT_RELTIME
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6987 nfa_time_limit = tm;
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
6988 nfa_timed_out = timed_out;
6573
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6989 nfa_time_count = 0;
ffba266e064d updated for version 7.4.613
Bram Moolenaar <bram@vim.org>
parents: 6547
diff changeset
6990 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6991
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6992 #ifdef ENABLE_LOG
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
6993 f = fopen(NFA_REGEXP_RUN_LOG, "a");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6994 if (f != NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6995 {
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
6996 fprintf(f, "\n\n\t=======================================================\n");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6997 #ifdef DEBUG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6998 fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6999 #endif
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7000 fprintf(f, "\tInput text is \"%s\" \n", rex.input);
4750
7793e737ec87 updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents: 4748
diff changeset
7001 fprintf(f, "\t=======================================================\n\n");
4533
6a2005efa02b updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents: 4531
diff changeset
7002 nfa_print_state(f, start);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7003 fprintf(f, "\n\n");
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7004 fclose(f);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7005 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7006 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
7007 emsg("Could not open temporary log file for writing");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7008 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7009
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7010 clear_sub(&subs.norm);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7011 clear_sub(&m.norm);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7012 #ifdef FEAT_SYN_HL
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7013 clear_sub(&subs.synt);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7014 clear_sub(&m.synt);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7015 #endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7016
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
7017 result = nfa_regmatch(prog, start, &subs, &m);
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
7018 if (result == FALSE)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7019 return 0;
6328
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
7020 else if (result == NFA_TOO_EXPENSIVE)
adfbffe1e642 updated for version 7.4.497
Bram Moolenaar <bram@vim.org>
parents: 6280
diff changeset
7021 return result;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7022
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7023 cleanup_subexpr();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7024 if (REG_MULTI)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7025 {
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7026 for (i = 0; i < subs.norm.in_use; i++)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7027 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7028 rex.reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7029 rex.reg_startpos[i].col = subs.norm.list.multi[i].start_col;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7030
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7031 rex.reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7032 rex.reg_endpos[i].col = subs.norm.list.multi[i].end_col;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7033 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7034
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7035 if (rex.reg_startpos[0].lnum < 0)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7036 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7037 rex.reg_startpos[0].lnum = 0;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7038 rex.reg_startpos[0].col = col;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7039 }
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7040 if (rex.reg_endpos[0].lnum < 0)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7041 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7042 // pattern has a \ze but it didn't match, use current end
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7043 rex.reg_endpos[0].lnum = rex.lnum;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7044 rex.reg_endpos[0].col = (int)(rex.input - rex.line);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7045 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7046 else
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7047 // Use line number of "\ze".
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7048 rex.lnum = rex.reg_endpos[0].lnum;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7049 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7050 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7051 {
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7052 for (i = 0; i < subs.norm.in_use; i++)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7053 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7054 rex.reg_startp[i] = subs.norm.list.line[i].start;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7055 rex.reg_endp[i] = subs.norm.list.line[i].end;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7056 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7057
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7058 if (rex.reg_startp[0] == NULL)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7059 rex.reg_startp[0] = rex.line + col;
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7060 if (rex.reg_endp[0] == NULL)
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7061 rex.reg_endp[0] = rex.input;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7062 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7063
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7064 #ifdef FEAT_SYN_HL
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7065 // Package any found \z(...\) matches for export. Default is none.
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7066 unref_extmatch(re_extmatch_out);
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7067 re_extmatch_out = NULL;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7068
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7069 if (prog->reghasz == REX_SET)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7070 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7071 cleanup_zsubexpr();
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7072 re_extmatch_out = make_extmatch();
18945
c62d63d2b9f0 patch 8.2.0033: crash when make_extmatch() runs out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
7073 if (re_extmatch_out == NULL)
c62d63d2b9f0 patch 8.2.0033: crash when make_extmatch() runs out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
7074 return 0;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7075 // Loop over \z1, \z2, etc. There is no \z0.
7258
7245d8635ac7 commit https://github.com/vim/vim/commit/5ad075c0735d3d8b97708d17c22de8facb15f997
Christian Brabandt <cb@256bit.org>
parents: 7152
diff changeset
7076 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
7077 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7078 if (REG_MULTI)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7079 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7080 struct multipos *mpos = &subs.synt.list.multi[i];
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7081
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7082 // Only accept single line matches that are valid.
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
7083 if (mpos->start_lnum >= 0
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
7084 && mpos->start_lnum == mpos->end_lnum
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
7085 && mpos->end_col >= mpos->start_col)
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7086 re_extmatch_out->matches[i] =
6547
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
7087 vim_strnsave(reg_getline(mpos->start_lnum)
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
7088 + mpos->start_col,
436d6c9e57f2 updated for version 7.4.600
Bram Moolenaar <bram@vim.org>
parents: 6545
diff changeset
7089 mpos->end_col - mpos->start_col);
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7090 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7091 else
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7092 {
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7093 struct linepos *lpos = &subs.synt.list.line[i];
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7094
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7095 if (lpos->start != NULL && lpos->end != NULL)
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7096 re_extmatch_out->matches[i] =
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7097 vim_strnsave(lpos->start,
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7098 (int)(lpos->end - lpos->start));
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7099 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7100 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7101 }
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7102 #endif
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7103
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7104 return 1 + rex.lnum;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7105 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7106
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7107 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7108 * Match a regexp against a string ("line" points to the string) or multiple
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7109 * lines ("line" is NULL, use reg_getline()).
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7110 *
6392
2bb019eb60ca updated for version 7.4.527
Bram Moolenaar <bram@vim.org>
parents: 6328
diff changeset
7111 * Returns <= 0 for failure, number of lines contained in the match otherwise.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7112 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7113 static long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7114 nfa_regexec_both(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7115 char_u *line,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7116 colnr_T startcol, // column to start looking for match
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7117 proftime_T *tm, // timeout limit or NULL
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7118 int *timed_out) // flag set on timeout or NULL
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7119 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7120 nfa_regprog_T *prog;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7121 long retval = 0L;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7122 int i;
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7123 colnr_T col = startcol;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7124
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7125 if (REG_MULTI)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7126 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7127 prog = (nfa_regprog_T *)rex.reg_mmatch->regprog;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7128 line = reg_getline((linenr_T)0); // relative to the cursor
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7129 rex.reg_startpos = rex.reg_mmatch->startpos;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7130 rex.reg_endpos = rex.reg_mmatch->endpos;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7131 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7132 else
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7133 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7134 prog = (nfa_regprog_T *)rex.reg_match->regprog;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7135 rex.reg_startp = rex.reg_match->startp;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7136 rex.reg_endp = rex.reg_match->endp;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7137 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7138
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7139 // Be paranoid...
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7140 if (prog == NULL || line == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7141 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15265
diff changeset
7142 emsg(_(e_null));
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7143 goto theend;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7144 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7145
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7146 // If pattern contains "\c" or "\C": overrule value of rex.reg_ic
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7147 if (prog->regflags & RF_ICASE)
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7148 rex.reg_ic = TRUE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7149 else if (prog->regflags & RF_NOICASE)
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7150 rex.reg_ic = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7151
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7152 // If pattern contains "\Z" overrule value of rex.reg_icombine
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7153 if (prog->regflags & RF_ICOMBINE)
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7154 rex.reg_icombine = TRUE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7155
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7156 rex.line = line;
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7157 rex.lnum = 0; // relative to line
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7158
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7159 rex.nfa_has_zend = prog->has_zend;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7160 rex.nfa_has_backref = prog->has_backref;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7161 rex.nfa_nsubexpr = prog->nsubexp;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7162 rex.nfa_listid = 1;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7163 rex.nfa_alt_listid = 2;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7164 #ifdef DEBUG
4690
9d97a0c045ef updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents: 4688
diff changeset
7165 nfa_regengine.expr = prog->pattern;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7166 #endif
4553
7b835b2969af updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents: 4551
diff changeset
7167
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7168 if (prog->reganch && col > 0)
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7169 return 0L;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7170
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7171 rex.need_clear_subexpr = TRUE;
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7172 #ifdef FEAT_SYN_HL
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7173 // Clear the external match subpointers if necessary.
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7174 if (prog->reghasz == REX_SET)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7175 {
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7176 rex.nfa_has_zsubexpr = TRUE;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7177 rex.need_clear_zsubexpr = TRUE;
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7178 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7179 else
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7180 {
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7181 rex.nfa_has_zsubexpr = FALSE;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7182 rex.need_clear_zsubexpr = FALSE;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7183 }
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7184 #endif
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7185
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7186 if (prog->regstart != NUL)
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7187 {
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7188 // Skip ahead until a character we know the match must start with.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7189 // When there is none there is no match.
4801
3cd3cc1e9119 updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents: 4799
diff changeset
7190 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
7191 return 0L;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7192
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7193 // If match_text is set it contains the full text that must match.
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7194 // Nothing else to try. Doesn't handle combining chars well.
15603
639b8318472c patch 8.1.0809: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
7195 if (prog->match_text != NULL && !rex.reg_icombine)
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7196 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
7197 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7198
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7199 // If the start column is past the maximum column: no need to try.
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7200 if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol)
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7201 goto theend;
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7202
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7203 // Set the "nstate" used by nfa_regcomp() to zero to trigger an error when
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7204 // it's accidentally used during execution.
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7205 nstate = 0;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7206 for (i = 0; i < prog->nstate; ++i)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7207 {
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7208 prog->state[i].id = i;
4718
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
7209 prog->state[i].lastlist[0] = 0;
ec72bb4a0fc2 updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents: 4716
diff changeset
7210 prog->state[i].lastlist[1] = 0;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7211 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7212
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
7213 retval = nfa_regtry(prog, col, tm, timed_out);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7214
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7215 #ifdef DEBUG
4690
9d97a0c045ef updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents: 4688
diff changeset
7216 nfa_regengine.expr = NULL;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7217 #endif
4690
9d97a0c045ef updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents: 4688
diff changeset
7218
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7219 theend:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7220 return retval;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7221 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7222
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7223 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7224 * Compile a regular expression into internal code for the NFA matcher.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7225 * Returns the program in allocated space. Returns NULL for an error.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7226 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7227 static regprog_T *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7228 nfa_regcomp(char_u *expr, int re_flags)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7229 {
4541
80170d61a85c updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents: 4539
diff changeset
7230 nfa_regprog_T *prog = NULL;
4458
21e13403140a updated for version 7.3.977
Bram Moolenaar <bram@vim.org>
parents: 4456
diff changeset
7231 size_t prog_size;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7232 int *postfix;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7233
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7234 if (expr == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7235 return NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7236
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7237 #ifdef DEBUG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7238 nfa_regengine.expr = expr;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7239 #endif
6533
bdc8e71633e4 updated for version 7.4.593
Bram Moolenaar <bram@vim.org>
parents: 6510
diff changeset
7240 nfa_re_flags = re_flags;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7241
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7242 init_class_tab();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7243
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7244 if (nfa_regcomp_start(expr, re_flags) == FAIL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7245 return NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7246
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7247 // Build postfix form of the regexp. Needed to build the NFA
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7248 // (and count its size).
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7249 postfix = re2post();
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7250 if (postfix == NULL)
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7251 goto fail; // Cascaded (syntax?) error
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7252
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7253 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7254 * In order to build the NFA, we parse the input regexp twice:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7255 * 1. first pass to count size (so we can allocate space)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7256 * 2. second to emit code
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7257 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7258 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7259 {
4531
1be43c095aff updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents: 4529
diff changeset
7260 FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a");
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7261
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7262 if (f != NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7263 {
14145
1cf832945469 patch 8.1.0090: "..." used inconsistently in a message
Christian Brabandt <cb@256bit.org>
parents: 14121
diff changeset
7264 fprintf(f, "\n*****************************\n\n\n\n\tCompiling regexp \"%s\"... hold on !\n", expr);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7265 fclose(f);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7266 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7267 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7268 #endif
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7269
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7270 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7271 * PASS 1
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7272 * Count number of NFA states in "nstate". Do not build the NFA.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7273 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7274 post2nfa(postfix, post_ptr, TRUE);
4541
80170d61a85c updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents: 4539
diff changeset
7275
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7276 // allocate the regprog with space for the compiled regexp
4837
05b8436873d4 updated for version 7.3.1165
Bram Moolenaar <bram@vim.org>
parents: 4821
diff changeset
7277 prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1);
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
7278 prog = alloc(prog_size);
4541
80170d61a85c updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents: 4539
diff changeset
7279 if (prog == NULL)
80170d61a85c updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents: 4539
diff changeset
7280 goto fail;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7281 state_ptr = prog->state;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7282 prog->re_in_use = FALSE;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7283
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7284 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7285 * PASS 2
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7286 * Build the NFA
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7287 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7288 prog->start = post2nfa(postfix, post_ptr, FALSE);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7289 if (prog->start == NULL)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7290 goto fail;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7291
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7292 prog->regflags = regflags;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7293 prog->engine = &nfa_regengine;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7294 prog->nstate = nstate;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7295 prog->has_zend = rex.nfa_has_zend;
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7296 prog->has_backref = rex.nfa_has_backref;
4561
4d81fdda8f35 updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents: 4559
diff changeset
7297 prog->nsubexp = regnpar;
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7298
4845
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
7299 nfa_postprocess(prog);
a83fb2bd8c8e updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents: 4837
diff changeset
7300
4772
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7301 prog->reganch = nfa_get_reganch(prog->start, 0);
03375ccf28a2 updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents: 4770
diff changeset
7302 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
7303 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
7304
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7305 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7306 nfa_postfix_dump(expr, OK);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7307 nfa_dump(prog);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7308 #endif
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7309 #ifdef FEAT_SYN_HL
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7310 // Remember whether this pattern has any \z specials in it.
4686
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7311 prog->reghasz = re_has_z;
8db697ae406a updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents: 4682
diff changeset
7312 #endif
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7313 prog->pattern = vim_strsave(expr);
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7314 #ifdef DEBUG
4690
9d97a0c045ef updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents: 4688
diff changeset
7315 nfa_regengine.expr = NULL;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7316 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7317
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7318 out:
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13208
diff changeset
7319 VIM_CLEAR(post_start);
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13208
diff changeset
7320 post_ptr = post_end = NULL;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7321 state_ptr = NULL;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7322 return (regprog_T *)prog;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7323
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7324 fail:
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13208
diff changeset
7325 VIM_CLEAR(prog);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7326 #ifdef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7327 nfa_postfix_dump(expr, FAIL);
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7328 #endif
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7329 #ifdef DEBUG
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7330 nfa_regengine.expr = NULL;
14354
ffd834f893aa patch 8.1.0192: executing regexp recursively fails with a crash
Christian Brabandt <cb@256bit.org>
parents: 14309
diff changeset
7331 #endif
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7332 goto out;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7333 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7334
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7335 /*
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7336 * 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
7337 */
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7338 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7339 nfa_regfree(regprog_T *prog)
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7340 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7341 if (prog != NULL)
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7342 {
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7343 vim_free(((nfa_regprog_T *)prog)->match_text);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7344 vim_free(((nfa_regprog_T *)prog)->pattern);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7345 vim_free(prog);
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7346 }
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4801
diff changeset
7347 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7348
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7349 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7350 * Match a regexp against a string.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7351 * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7352 * Uses curbuf for line count and 'iskeyword'.
5838
0ea551fa607d updated for version 7.4.262
Bram Moolenaar <bram@vim.org>
parents: 5820
diff changeset
7353 * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7354 *
6392
2bb019eb60ca updated for version 7.4.527
Bram Moolenaar <bram@vim.org>
parents: 6328
diff changeset
7355 * Returns <= 0 for failure, number of lines contained in the match otherwise.
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7356 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7357 static int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7358 nfa_regexec_nl(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7359 regmatch_T *rmp,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7360 char_u *line, // string to match against
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7361 colnr_T col, // column to start looking for match
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7362 int line_lbr)
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7363 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7364 rex.reg_match = rmp;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7365 rex.reg_mmatch = NULL;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7366 rex.reg_maxline = 0;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7367 rex.reg_line_lbr = line_lbr;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7368 rex.reg_buf = curbuf;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7369 rex.reg_win = NULL;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7370 rex.reg_ic = rmp->rm_ic;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7371 rex.reg_icombine = FALSE;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7372 rex.reg_maxcol = 0;
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
7373 return nfa_regexec_both(line, col, NULL, NULL);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7374 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7375
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7376
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7377 /*
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7378 * Match a regexp against multiple lines.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7379 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7380 * Uses curbuf for line count and 'iskeyword'.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7381 *
6392
2bb019eb60ca updated for version 7.4.527
Bram Moolenaar <bram@vim.org>
parents: 6328
diff changeset
7382 * Return <= 0 if there is no match. Return number of lines contained in the
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7383 * match otherwise.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7384 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7385 * Note: the body is the same as bt_regexec() except for nfa_regexec_both()
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7386 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7387 * ! Also NOTE : match may actually be in another line. e.g.:
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7388 * when r.e. is \nc, cursor is at 'a' and the text buffer looks like
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7389 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7390 * +-------------------------+
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7391 * |a |
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7392 * |b |
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7393 * |c |
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7394 * | |
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7395 * +-------------------------+
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7396 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7397 * then nfa_regexec_multi() returns 3. while the original
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7398 * vim_regexec_multi() returns 0 and a second call at line 2 will return 2.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7399 *
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7400 * FIXME if this behavior is not compatible.
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7401 */
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7402 static long
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7403 nfa_regexec_multi(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7404 regmmatch_T *rmp,
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7405 win_T *win, // window in which to search or NULL
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7406 buf_T *buf, // buffer in which to search
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7407 linenr_T lnum, // nr of line to start looking for match
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7408 colnr_T col, // column to start looking for match
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7409 proftime_T *tm, // timeout limit or NULL
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
7410 int *timed_out) // flag set on timeout or NULL
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7411 {
10245
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7412 rex.reg_match = NULL;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7413 rex.reg_mmatch = rmp;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7414 rex.reg_buf = buf;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7415 rex.reg_win = win;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7416 rex.reg_firstlnum = lnum;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7417 rex.reg_maxline = rex.reg_buf->b_ml.ml_line_count - lnum;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7418 rex.reg_line_lbr = FALSE;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7419 rex.reg_ic = rmp->rmm_ic;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7420 rex.reg_icombine = FALSE;
d76ccdacb41e commit https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d
Christian Brabandt <cb@256bit.org>
parents: 10170
diff changeset
7421 rex.reg_maxcol = rmp->rmm_maxcol;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7422
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11480
diff changeset
7423 return nfa_regexec_both(NULL, col, tm, timed_out);
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7424 }
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7425
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7426 #ifdef DEBUG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7427 # undef ENABLE_LOG
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7428 #endif