annotate src/regexp_bt.c @ 26958:d92e0d85923f v8.2.4008

patch 8.2.4008: error messages are spread out Commit: https://github.com/vim/vim/commit/677658ae49de31fe2e5b1fa6d93fdfab85a4362e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 5 16:09:06 2022 +0000 patch 8.2.4008: error messages are spread out Problem: Error messages are spread out. Solution: Move more error messages to errors.h.
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Jan 2022 17:15:05 +0100
parents b34ddbca305c
children b31cc7630773
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * Backtracking regular expression implementation.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * This file is included in "regexp.c".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * NOTICE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 * This is NOT the original regular expression code as written by Henry
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 * Spencer. This code has been modified specifically for use with the VIM
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * editor, and should not be used separately from Vim. If you want a good
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 * regular expression library, get the original code. The copyright notice
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 * that follows is from the original.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 * END NOTICE
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 * Copyright (c) 1986 by University of Toronto.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 * Written by Henry Spencer. Not derived from licensed software.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 * Permission is granted to anyone to use this software for any
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 * purpose on any computer system, and to redistribute it freely,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 * subject to the following restrictions:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 * 1. The author is not responsible for the consequences of use of
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 * this software, no matter how awful, even if they arise
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 * from defects in it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 * 2. The origin of this software must not be misrepresented, either
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 * by explicit claim or by omission.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 * 3. Altered versions must be plainly marked as such, and must not
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 * be misrepresented as being the original software.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 * Beware that some of this code is subtly aware of the way operator
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 * precedence is structured in regular expressions. Serious changes in
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 * regular-expression syntax might require a total rethink.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 * Changes have been made by Tony Andrews, Olaf 'Rhialto' Seibert, Robert
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 * Webb, Ciaran McCreesh and Bram Moolenaar.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 * Named character class support added by Walter Briscoe (1998 Jul 01)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 * The "internal use only" fields in regexp.h are present to pass info from
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 * compile to execute that permits the execute phase to run lots faster on
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 * simple cases. They are:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 * regstart char that must begin a match; NUL if none obvious; Can be a
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 * multi-byte character.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 * reganch is the match anchored (at beginning-of-line only)?
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 * regmust string (pointer into program) that match must include, or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 * regmlen length of regmust string
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 * regflags RF_ values or'ed together
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 * Regstart and reganch permit very fast decisions on suitable starting points
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 * for a match, cutting down the work a lot. Regmust permits fast rejection
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 * of lines that cannot possibly match. The regmust tests are costly enough
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 * that vim_regcomp() supplies a regmust only if the r.e. contains something
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 * potentially expensive (at present, the only such thing detected is * or +
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 * at the start of the r.e., which can involve a lot of backup). Regmlen is
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 * supplied because the test in vim_regexec() needs it and vim_regcomp() is
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 * computing it anyway.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 * Structure for regexp "program". This is essentially a linear encoding
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 * of a nondeterministic finite-state machine (aka syntax charts or
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 * "railroad normal form" in parsing technology). Each node is an opcode
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 * plus a "next" pointer, possibly plus an operand. "Next" pointers of
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 * all nodes except BRANCH and BRACES_COMPLEX implement concatenation; a "next"
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 * pointer with a BRANCH on both ends of it is connecting two alternatives.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 * (Here we have one of the subtle syntax dependencies: an individual BRANCH
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 * (as opposed to a collection of them) is never concatenated with anything
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 * because of operator precedence). The "next" pointer of a BRACES_COMPLEX
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 * node points to the node after the stuff to be repeated.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 * The operand of some types of node is a literal string; for others, it is a
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 * node leading into a sub-FSM. In particular, the operand of a BRANCH node
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 * is the first node of the branch.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 * (NB this is *not* a tree structure: the tail of the branch connects to the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 * thing following the set of BRANCHes.)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 * pattern is coded like:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 * +-----------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 * | V
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 * <aa>\|<bb> BRANCH <aa> BRANCH <bb> --> END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 * | ^ | ^
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 * +------+ +----------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 * +------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 * V |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 * <aa>* BRANCH BRANCH <aa> --> BACK BRANCH --> NOTHING --> END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 * | | ^ ^
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 * | +---------------+ |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 * +---------------------------------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 * +----------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 * V |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 * <aa>\+ BRANCH <aa> --> BRANCH --> BACK BRANCH --> NOTHING --> END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 * | | ^ ^
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 * | +-----------+ |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 * +--------------------------------------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 * +-------------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 * V |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 * <aa>\{} BRANCH BRACE_LIMITS --> BRACE_COMPLEX <aa> --> BACK END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 * | | ^
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 * | +----------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 * +-----------------------------------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 * <aa>\@!<bb> BRANCH NOMATCH <aa> --> END <bb> --> END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 * | | ^ ^
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 * | +----------------+ |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 * +--------------------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 * +---------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 * | V
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 * \z[abc] BRANCH BRANCH a BRANCH b BRANCH c BRANCH NOTHING --> END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 * | | | | ^ ^
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 * | | | +-----+ |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 * | | +----------------+ |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 * | +---------------------------+ |
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 * +------------------------------------------------------+
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 * They all start with a BRANCH for "\|" alternatives, even when there is only
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 * one alternative.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 * The opcodes are:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
137 // definition number opnd? meaning
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
138 #define END 0 // End of program or NOMATCH operand.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
139 #define BOL 1 // Match "" at beginning of line.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
140 #define EOL 2 // Match "" at end of line.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
141 #define BRANCH 3 // node Match this alternative, or the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
142 // next...
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
143 #define BACK 4 // Match "", "next" ptr points backward.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
144 #define EXACTLY 5 // str Match this string.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
145 #define NOTHING 6 // Match empty string.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
146 #define STAR 7 // node Match this (simple) thing 0 or more
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
147 // times.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
148 #define PLUS 8 // node Match this (simple) thing 1 or more
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
149 // times.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
150 #define MATCH 9 // node match the operand zero-width
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
151 #define NOMATCH 10 // node check for no match with operand
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
152 #define BEHIND 11 // node look behind for a match with operand
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
153 #define NOBEHIND 12 // node look behind for no match with operand
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
154 #define SUBPAT 13 // node match the operand here
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
155 #define BRACE_SIMPLE 14 // node Match this (simple) thing between m and
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
156 // n times (\{m,n\}).
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
157 #define BOW 15 // Match "" after [^a-zA-Z0-9_]
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
158 #define EOW 16 // Match "" at [^a-zA-Z0-9_]
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
159 #define BRACE_LIMITS 17 // nr nr define the min & max for BRACE_SIMPLE
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
160 // and BRACE_COMPLEX.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
161 #define NEWL 18 // Match line-break
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
162 #define BHPOS 19 // End position for BEHIND or NOBEHIND
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
163
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
164
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
165 // character classes: 20-48 normal, 50-78 include a line-break
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 #define ADD_NL 30
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 #define FIRST_NL ANY + ADD_NL
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
168 #define ANY 20 // Match any one character.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
169 #define ANYOF 21 // str Match any character in this string.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
170 #define ANYBUT 22 // str Match any character not in this
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
171 // string.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
172 #define IDENT 23 // Match identifier char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
173 #define SIDENT 24 // Match identifier char but no digit
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
174 #define KWORD 25 // Match keyword char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
175 #define SKWORD 26 // Match word char but no digit
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
176 #define FNAME 27 // Match file name char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
177 #define SFNAME 28 // Match file name char but no digit
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
178 #define PRINT 29 // Match printable char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
179 #define SPRINT 30 // Match printable char but no digit
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
180 #define WHITE 31 // Match whitespace char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
181 #define NWHITE 32 // Match non-whitespace char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
182 #define DIGIT 33 // Match digit char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
183 #define NDIGIT 34 // Match non-digit char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
184 #define HEX 35 // Match hex char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
185 #define NHEX 36 // Match non-hex char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
186 #define OCTAL 37 // Match octal char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
187 #define NOCTAL 38 // Match non-octal char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
188 #define WORD 39 // Match word char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
189 #define NWORD 40 // Match non-word char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
190 #define HEAD 41 // Match head char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
191 #define NHEAD 42 // Match non-head char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
192 #define ALPHA 43 // Match alpha char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
193 #define NALPHA 44 // Match non-alpha char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
194 #define LOWER 45 // Match lowercase char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
195 #define NLOWER 46 // Match non-lowercase char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
196 #define UPPER 47 // Match uppercase char
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
197 #define NUPPER 48 // Match non-uppercase char
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 #define LAST_NL NUPPER + ADD_NL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 #define WITH_NL(op) ((op) >= FIRST_NL && (op) <= LAST_NL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
201 #define MOPEN 80 // -89 Mark this point in input as start of
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
202 // \( subexpr. MOPEN + 0 marks start of
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
203 // match.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
204 #define MCLOSE 90 // -99 Analogous to MOPEN. MCLOSE + 0 marks
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
205 // end of match.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
206 #define BACKREF 100 // -109 node Match same string again \1-\9
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 #ifdef FEAT_SYN_HL
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
209 # define ZOPEN 110 // -119 Mark this point in input as start of
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
210 // \z( subexpr.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
211 # define ZCLOSE 120 // -129 Analogous to ZOPEN.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
212 # define ZREF 130 // -139 node Match external submatch \z1-\z9
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
215 #define BRACE_COMPLEX 140 // -149 node Match nodes between m & n times
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
216
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
217 #define NOPEN 150 // Mark this point in input as start of
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
218 // \%( subexpr.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
219 #define NCLOSE 151 // Analogous to NOPEN.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
220
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
221 #define MULTIBYTECODE 200 // mbc Match one multi-byte character
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
222 #define RE_BOF 201 // Match "" at beginning of file.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
223 #define RE_EOF 202 // Match "" at end of file.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
224 #define CURSOR 203 // Match location of cursor.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
225
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
226 #define RE_LNUM 204 // nr cmp Match line number
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
227 #define RE_COL 205 // nr cmp Match column number
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
228 #define RE_VCOL 206 // nr cmp Match virtual column number
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
229
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
230 #define RE_MARK 207 // mark cmp Match mark position
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
231 #define RE_VISUAL 208 // Match Visual area
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
232 #define RE_COMPOSING 209 // any composing characters
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 * Flags to be passed up and down.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 */
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
237 #define HASWIDTH 0x1 // Known never to match null string.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
238 #define SIMPLE 0x2 // Simple enough to be STAR/PLUS operand.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
239 #define SPSTART 0x4 // Starts with * or +.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
240 #define HASNL 0x8 // Contains some \n.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
241 #define HASLOOKBH 0x10 // Contains "\@<=" or "\@<!".
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
242 #define WORST 0 // Worst case.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
243
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
244 static int num_complex_braces; // Complex \{...} count
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
245 static char_u *regcode; // Code-emit pointer, or JUST_CALC_SIZE
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
246 static long regsize; // Code size.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
247 static int reg_toolong; // TRUE when offset out of range
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
248 static char_u had_endbrace[NSUBEXP]; // flags, TRUE if end of () found
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
249 static long brace_min[10]; // Minimums for complex brace repeats
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
250 static long brace_max[10]; // Maximums for complex brace repeats
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
251 static int brace_count[10]; // Current counts for complex brace repeats
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
252 static int one_exactly = FALSE; // only do one char for EXACTLY
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
253
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
254 // When making changes to classchars also change nfa_classcodes.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 static char_u *classchars = (char_u *)".iIkKfFpPsSdDxXoOwWhHaAlLuU";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 static int classcodes[] = {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 ANY, IDENT, SIDENT, KWORD, SKWORD,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 FNAME, SFNAME, PRINT, SPRINT,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 WHITE, NWHITE, DIGIT, NDIGIT,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 HEX, NHEX, OCTAL, NOCTAL,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 WORD, NWORD, HEAD, NHEAD,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 ALPHA, NALPHA, LOWER, NLOWER,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 UPPER, NUPPER
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 };
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 * When regcode is set to this value, code is not emitted and size is computed
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 * instead.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 #define JUST_CALC_SIZE ((char_u *) -1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
272 // Values for rs_state in regitem_T.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 typedef enum regstate_E
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
275 RS_NOPEN = 0 // NOPEN and NCLOSE
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
276 , RS_MOPEN // MOPEN + [0-9]
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
277 , RS_MCLOSE // MCLOSE + [0-9]
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 #ifdef FEAT_SYN_HL
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
279 , RS_ZOPEN // ZOPEN + [0-9]
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
280 , RS_ZCLOSE // ZCLOSE + [0-9]
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 #endif
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
282 , RS_BRANCH // BRANCH
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
283 , RS_BRCPLX_MORE // BRACE_COMPLEX and trying one more match
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
284 , RS_BRCPLX_LONG // BRACE_COMPLEX and trying longest match
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
285 , RS_BRCPLX_SHORT // BRACE_COMPLEX and trying shortest match
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
286 , RS_NOMATCH // NOMATCH
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
287 , RS_BEHIND1 // BEHIND / NOBEHIND matching rest
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
288 , RS_BEHIND2 // BEHIND / NOBEHIND matching behind part
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
289 , RS_STAR_LONG // STAR/PLUS/BRACE_SIMPLE longest match
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
290 , RS_STAR_SHORT // STAR/PLUS/BRACE_SIMPLE shortest match
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 } regstate_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 * Structure used to save the current input state, when it needs to be
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 * restored after trying a match. Used by reg_save() and reg_restore().
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 * Also stores the length of "backpos".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 typedef struct
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 union
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
302 char_u *ptr; // rex.input pointer, for single-line regexp
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
303 lpos_T pos; // rex.input pos, for multi-line regexp
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 } rs_u;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 int rs_len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 } regsave_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
308 // struct to save start/end pointer/position in for \(\)
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 typedef struct
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 union
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 char_u *ptr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 lpos_T pos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 } se_u;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 } save_se_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
318 // used for BEHIND and NOBEHIND matching
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 typedef struct regbehind_S
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 regsave_T save_after;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 regsave_T save_behind;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 int save_need_clear_subexpr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 save_se_T save_start[NSUBEXP];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 save_se_T save_end[NSUBEXP];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 } regbehind_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 * When there are alternatives a regstate_T is put on the regstack to remember
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 * what we are doing.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 * Before it may be another type of item, depending on rs_state, to remember
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 * more things.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 typedef struct regitem_S
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 regstate_T rs_state; // what we are doing, one of RS_ above
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 short rs_no; // submatch nr or BEHIND/NOBEHIND
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 char_u *rs_scan; // current node in program
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 union
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 save_se_T sesave;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 regsave_T regsave;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 } rs_un; // room for saving rex.input
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 } regitem_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
347 // used for STAR, PLUS and BRACE_SIMPLE matching
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 typedef struct regstar_S
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
350 int nextb; // next byte
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
351 int nextb_ic; // next byte reverse case
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 long count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 long minval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 long maxval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 } regstar_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
357 // used to store input position when a BACK was encountered, so that we now if
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
358 // we made any progress since the last time.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 typedef struct backpos_S
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
361 char_u *bp_scan; // "scan" where BACK was encountered
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
362 regsave_T bp_pos; // last input position
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 } backpos_T;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 * "regstack" and "backpos" are used by regmatch(). They are kept over calls
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 * to avoid invoking malloc() and free() often.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 * "regstack" is a stack with regitem_T items, sometimes preceded by regstar_T
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 * or regbehind_T.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 * "backpos_T" is a table with backpos_T for BACK
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 static garray_T regstack = {0, 0, 0, 0, NULL};
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 static garray_T backpos = {0, 0, 0, 0, NULL};
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 static regsave_T behind_pos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 * Both for regstack and backpos tables we use the following strategy of
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 * allocation (to reduce malloc/free calls):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 * - Initial size is fairly small.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 * - When needed, the tables are grown bigger (8 times at first, double after
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 * that).
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 * - After executing the match we free the memory only if the array has grown.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 * Thus the memory is kept allocated when it's at the initial size.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 * This makes it fast while not keeping a lot of memory allocated.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 * A three times speed increase was observed when using many simple patterns.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 #define REGSTACK_INITIAL 2048
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 #define BACKPOS_INITIAL 64
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 * Opcode notes:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 * BRANCH The set of branches constituting a single choice are hooked
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 * together with their "next" pointers, since precedence prevents
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 * anything being concatenated to any individual branch. The
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 * "next" pointer of the last BRANCH in a choice points to the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 * thing following the whole choice. This is also where the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 * final "next" pointer of each individual branch points; each
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 * branch starts with the operand node of a BRANCH node.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 * BACK Normal "next" pointers all implicitly point forward; BACK
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 * exists to make loop structures possible.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 * STAR,PLUS '=', and complex '*' and '+', are implemented as circular
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 * BRANCH structures using BACK. Simple cases (one character
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 * per match) are implemented with STAR and PLUS for speed
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 * and to minimize recursive plunges.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 * BRACE_LIMITS This is always followed by a BRACE_SIMPLE or BRACE_COMPLEX
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 * node, and defines the min and max limits to be used for that
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 * node.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 * MOPEN,MCLOSE ...are numbered at compile time.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 * ZOPEN,ZCLOSE ...ditto
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 * A node is one char of opcode followed by two chars of "next" pointer.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 * "Next" pointers are stored as two 8-bit bytes, high order first. The
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 * value is a positive offset from the opcode of the node containing it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 * An operand, if any, simply follows the node. (Note that much of the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 * code generation knows about this implicit relationship.)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 * Using two bytes for the "next" pointer is vast overkill for most things,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 * but allows patterns to get big without disasters.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 #define OP(p) ((int)*(p))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 #define NEXT(p) (((*((p) + 1) & 0377) << 8) + (*((p) + 2) & 0377))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 #define OPERAND(p) ((p) + 3)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
431 // Obtain an operand that was stored as four bytes, MSB first.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 #define OPERAND_MIN(p) (((long)(p)[3] << 24) + ((long)(p)[4] << 16) \
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 + ((long)(p)[5] << 8) + (long)(p)[6])
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
434 // Obtain a second operand stored as four bytes.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 #define OPERAND_MAX(p) OPERAND_MIN((p) + 4)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
436 // Obtain a second single-byte operand stored after a four bytes operand.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 #define OPERAND_CMP(p) (p)[7]
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 static char_u *reg(int paren, int *flagp);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 #ifdef BT_REGEXP_DUMP
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 static void regdump(char_u *, bt_regprog_T *);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 static int re_num_cmp(long_u val, char_u *scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 static char_u *regprop(char_u *);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 static int regnarrate = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 * Setup to parse the regexp. Used once to get the length and once to do it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 regcomp_start(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 char_u *expr,
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
460 int re_flags) // see vim_regcomp()
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 initchr(expr);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 if (re_flags & RE_MAGIC)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 reg_magic = MAGIC_ON;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 reg_magic = MAGIC_OFF;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 reg_string = (re_flags & RE_STRING);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 reg_strict = (re_flags & RE_STRICT);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 get_cpo_flags();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 num_complex_braces = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 regnpar = 1;
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19405
diff changeset
473 CLEAR_FIELD(had_endbrace);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 regnzpar = 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 re_has_z = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 regsize = 0L;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 reg_toolong = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 regflags = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 #if defined(FEAT_SYN_HL) || defined(PROTO)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 had_eol = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 * Return TRUE if MULTIBYTECODE should be used instead of EXACTLY for
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 * character "c".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 use_multibytecode(int c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 return has_mbyte && (*mb_char2len)(c) > 1
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 && (re_multi_type(peekchr()) != NOT_MULTI
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 || (enc_utf8 && utf_iscomposing(c)));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 * Emit (if appropriate) a byte of code
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 regc(int b)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 if (regcode == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 regsize++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 *regcode++ = b;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 * Emit (if appropriate) a multi-byte character of code
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 regmbc(int c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 if (!has_mbyte && c > 0xff)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 if (regcode == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 regsize += (*mb_char2len)(c);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 regcode += (*mb_char2bytes)(c, regcode);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 * Produce the bytes for equivalence class "c".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 * Currently only handles latin1, latin9 and utf-8.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 * NOTE: When changing this function, also change nfa_emit_equi_class()
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 reg_equi_class(int c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 || STRCMP(p_enc, "iso-8859-15") == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 #ifdef EBCDIC
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 int i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
539 // This might be slower than switch/case below.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 for (i = 0; i < 16; i++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 if (vim_strchr(EQUIVAL_CLASS_C[i], c) != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 char *p = EQUIVAL_CLASS_C[i];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 while (*p != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 regmbc(*p++);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 #else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 switch (c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
554 // Do not use '\300' style, it results in a negative number.
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
555 case 'A': case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
556 case 0xc5: case 0x100: case 0x102: case 0x104: case 0x1cd:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
557 case 0x1de: case 0x1e0: case 0x1fa: case 0x202: case 0x226:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
558 case 0x23a: case 0x1e00: case 0x1ea0: case 0x1ea2: case 0x1ea4:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
559 case 0x1ea6: case 0x1ea8: case 0x1eaa: case 0x1eac: case 0x1eae:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
560 case 0x1eb0: case 0x1eb2: case 0x1eb4: case 0x1eb6:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
561 regmbc('A'); regmbc(0xc0); regmbc(0xc1); regmbc(0xc2);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
562 regmbc(0xc3); regmbc(0xc4); regmbc(0xc5);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
563 regmbc(0x100); regmbc(0x102); regmbc(0x104);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
564 regmbc(0x1cd); regmbc(0x1de); regmbc(0x1e0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
565 regmbc(0x1fa); regmbc(0x202); regmbc(0x226);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
566 regmbc(0x23a); regmbc(0x1e00); regmbc(0x1ea0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
567 regmbc(0x1ea2); regmbc(0x1ea4); regmbc(0x1ea6);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
568 regmbc(0x1ea8); regmbc(0x1eaa); regmbc(0x1eac);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
569 regmbc(0x1eae); regmbc(0x1eb0); regmbc(0x1eb2);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
570 regmbc(0x1eb4); regmbc(0x1eb6);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
572 case 'B': case 0x181: case 0x243: case 0x1e02:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
573 case 0x1e04: case 0x1e06:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
574 regmbc('B');
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
575 regmbc(0x181); regmbc(0x243); regmbc(0x1e02);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
576 regmbc(0x1e04); regmbc(0x1e06);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 case 'C': case 0xc7:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
579 case 0x106: case 0x108: case 0x10a: case 0x10c: case 0x187:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
580 case 0x23b: case 0x1e08: case 0xa792:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 regmbc('C'); regmbc(0xc7);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
582 regmbc(0x106); regmbc(0x108); regmbc(0x10a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
583 regmbc(0x10c); regmbc(0x187); regmbc(0x23b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
584 regmbc(0x1e08); regmbc(0xa792);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
586 case 'D': case 0x10e: case 0x110: case 0x18a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
587 case 0x1e0a: case 0x1e0c: case 0x1e0e: case 0x1e10:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
588 case 0x1e12:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
589 regmbc('D'); regmbc(0x10e); regmbc(0x110);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
590 regmbc(0x18a); regmbc(0x1e0a); regmbc(0x1e0c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
591 regmbc(0x1e0e); regmbc(0x1e10); regmbc(0x1e12);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 case 'E': case 0xc8: case 0xc9: case 0xca: case 0xcb:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
594 case 0x112: case 0x114: case 0x116: case 0x118: case 0x11a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
595 case 0x204: case 0x206: case 0x228: case 0x246: case 0x1e14:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
596 case 0x1e16: case 0x1e18: case 0x1e1a: case 0x1e1c:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
597 case 0x1eb8: case 0x1eba: case 0x1ebc: case 0x1ebe:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
598 case 0x1ec0: case 0x1ec2: case 0x1ec4: case 0x1ec6:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 regmbc('E'); regmbc(0xc8); regmbc(0xc9);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
600 regmbc(0xca); regmbc(0xcb); regmbc(0x112);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
601 regmbc(0x114); regmbc(0x116); regmbc(0x118);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
602 regmbc(0x11a); regmbc(0x204); regmbc(0x206);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
603 regmbc(0x228); regmbc(0x246); regmbc(0x1e14);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
604 regmbc(0x1e16); regmbc(0x1e18); regmbc(0x1e1a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
605 regmbc(0x1e1c); regmbc(0x1eb8); regmbc(0x1eba);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
606 regmbc(0x1ebc); regmbc(0x1ebe); regmbc(0x1ec0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
607 regmbc(0x1ec2); regmbc(0x1ec4); regmbc(0x1ec6);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
609 case 'F': case 0x191: case 0x1e1e: case 0xa798:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
610 regmbc('F'); regmbc(0x191); regmbc(0x1e1e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
611 regmbc(0xa798);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
613 case 'G': case 0x11c: case 0x11e: case 0x120:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
614 case 0x122: case 0x193: case 0x1e4: case 0x1e6:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
615 case 0x1f4: case 0x1e20: case 0xa7a0:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
616 regmbc('G'); regmbc(0x11c); regmbc(0x11e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
617 regmbc(0x120); regmbc(0x122); regmbc(0x193);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
618 regmbc(0x1e4); regmbc(0x1e6); regmbc(0x1f4);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
619 regmbc(0x1e20); regmbc(0xa7a0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
620 return;
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
621 case 'H': case 0x124: case 0x126: case 0x21e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
622 case 0x1e22: case 0x1e24: case 0x1e26:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
623 case 0x1e28: case 0x1e2a: case 0x2c67:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
624 regmbc('H'); regmbc(0x124); regmbc(0x126);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
625 regmbc(0x21e); regmbc(0x1e22); regmbc(0x1e24);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
626 regmbc(0x1e26); regmbc(0x1e28); regmbc(0x1e2a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
627 regmbc(0x2c67);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 case 'I': case 0xcc: case 0xcd: case 0xce: case 0xcf:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
630 case 0x128: case 0x12a: case 0x12c: case 0x12e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
631 case 0x130: case 0x197: case 0x1cf: case 0x208:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
632 case 0x20a: case 0x1e2c: case 0x1e2e: case 0x1ec8:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
633 case 0x1eca:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 regmbc('I'); regmbc(0xcc); regmbc(0xcd);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
635 regmbc(0xce); regmbc(0xcf); regmbc(0x128);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
636 regmbc(0x12a); regmbc(0x12c); regmbc(0x12e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
637 regmbc(0x130); regmbc(0x197); regmbc(0x1cf);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
638 regmbc(0x208); regmbc(0x20a); regmbc(0x1e2c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
639 regmbc(0x1e2e); regmbc(0x1ec8); regmbc(0x1eca);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
641 case 'J': case 0x134: case 0x248:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
642 regmbc('J'); regmbc(0x134); regmbc(0x248);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
644 case 'K': case 0x136: case 0x198: case 0x1e8: case 0x1e30:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
645 case 0x1e32: case 0x1e34: case 0x2c69: case 0xa740:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
646 regmbc('K'); regmbc(0x136); regmbc(0x198);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
647 regmbc(0x1e8); regmbc(0x1e30); regmbc(0x1e32);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
648 regmbc(0x1e34); regmbc(0x2c69); regmbc(0xa740);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
650 case 'L': case 0x139: case 0x13b: case 0x13d: case 0x13f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
651 case 0x141: case 0x23d: case 0x1e36: case 0x1e38:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
652 case 0x1e3a: case 0x1e3c: case 0x2c60:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
653 regmbc('L'); regmbc(0x139); regmbc(0x13b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
654 regmbc(0x13d); regmbc(0x13f); regmbc(0x141);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
655 regmbc(0x23d); regmbc(0x1e36); regmbc(0x1e38);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
656 regmbc(0x1e3a); regmbc(0x1e3c); regmbc(0x2c60);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
658 case 'M': case 0x1e3e: case 0x1e40: case 0x1e42:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
659 regmbc('M'); regmbc(0x1e3e); regmbc(0x1e40);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
660 regmbc(0x1e42);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 case 'N': case 0xd1:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
663 case 0x143: case 0x145: case 0x147: case 0x1f8:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
664 case 0x1e44: case 0x1e46: case 0x1e48: case 0x1e4a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
665 case 0xa7a4:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 regmbc('N'); regmbc(0xd1);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
667 regmbc(0x143); regmbc(0x145); regmbc(0x147);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
668 regmbc(0x1f8); regmbc(0x1e44); regmbc(0x1e46);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
669 regmbc(0x1e48); regmbc(0x1e4a); regmbc(0xa7a4);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
671 case 'O': case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
672 case 0xd8: case 0x14c: case 0x14e: case 0x150: case 0x19f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
673 case 0x1a0: case 0x1d1: case 0x1ea: case 0x1ec: case 0x1fe:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
674 case 0x20c: case 0x20e: case 0x22a: case 0x22c: case 0x22e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
675 case 0x230: case 0x1e4c: case 0x1e4e: case 0x1e50: case 0x1e52:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
676 case 0x1ecc: case 0x1ece: case 0x1ed0: case 0x1ed2: case 0x1ed4:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
677 case 0x1ed6: case 0x1ed8: case 0x1eda: case 0x1edc: case 0x1ede:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
678 case 0x1ee0: case 0x1ee2:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
679 regmbc('O'); regmbc(0xd2); regmbc(0xd3); regmbc(0xd4);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
680 regmbc(0xd5); regmbc(0xd6); regmbc(0xd8);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
681 regmbc(0x14c); regmbc(0x14e); regmbc(0x150);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
682 regmbc(0x19f); regmbc(0x1a0); regmbc(0x1d1);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
683 regmbc(0x1ea); regmbc(0x1ec); regmbc(0x1fe);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
684 regmbc(0x20c); regmbc(0x20e); regmbc(0x22a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
685 regmbc(0x22c); regmbc(0x22e); regmbc(0x230);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
686 regmbc(0x1e4c); regmbc(0x1e4e); regmbc(0x1e50);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
687 regmbc(0x1e52); regmbc(0x1ecc); regmbc(0x1ece);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
688 regmbc(0x1ed0); regmbc(0x1ed2); regmbc(0x1ed4);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
689 regmbc(0x1ed6); regmbc(0x1ed8); regmbc(0x1eda);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
690 regmbc(0x1edc); regmbc(0x1ede); regmbc(0x1ee0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
691 regmbc(0x1ee2);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
693 case 'P': case 0x1a4: case 0x1e54: case 0x1e56: case 0x2c63:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
694 regmbc('P'); regmbc(0x1a4); regmbc(0x1e54);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
695 regmbc(0x1e56); regmbc(0x2c63);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
696 return;
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
697 case 'Q': case 0x24a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
698 regmbc('Q'); regmbc(0x24a);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
700 case 'R': case 0x154: case 0x156: case 0x158: case 0x210:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
701 case 0x212: case 0x24c: case 0x1e58: case 0x1e5a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
702 case 0x1e5c: case 0x1e5e: case 0x2c64: case 0xa7a6:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
703 regmbc('R'); regmbc(0x154); regmbc(0x156);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
704 regmbc(0x210); regmbc(0x212); regmbc(0x158);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
705 regmbc(0x24c); regmbc(0x1e58); regmbc(0x1e5a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
706 regmbc(0x1e5c); regmbc(0x1e5e); regmbc(0x2c64);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
707 regmbc(0xa7a6);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
709 case 'S': case 0x15a: case 0x15c: case 0x15e: case 0x160:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
710 case 0x218: case 0x1e60: case 0x1e62: case 0x1e64:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
711 case 0x1e66: case 0x1e68: case 0x2c7e: case 0xa7a8:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
712 regmbc('S'); regmbc(0x15a); regmbc(0x15c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
713 regmbc(0x15e); regmbc(0x160); regmbc(0x218);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
714 regmbc(0x1e60); regmbc(0x1e62); regmbc(0x1e64);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
715 regmbc(0x1e66); regmbc(0x1e68); regmbc(0x2c7e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
716 regmbc(0xa7a8);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
718 case 'T': case 0x162: case 0x164: case 0x166: case 0x1ac:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
719 case 0x1ae: case 0x21a: case 0x23e: case 0x1e6a: case 0x1e6c:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
720 case 0x1e6e: case 0x1e70:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
721 regmbc('T'); regmbc(0x162); regmbc(0x164);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
722 regmbc(0x166); regmbc(0x1ac); regmbc(0x23e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
723 regmbc(0x1ae); regmbc(0x21a); regmbc(0x1e6a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
724 regmbc(0x1e6c); regmbc(0x1e6e); regmbc(0x1e70);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 case 'U': case 0xd9: case 0xda: case 0xdb: case 0xdc:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
727 case 0x168: case 0x16a: case 0x16c: case 0x16e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
728 case 0x170: case 0x172: case 0x1af: case 0x1d3:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
729 case 0x1d5: case 0x1d7: case 0x1d9: case 0x1db:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
730 case 0x214: case 0x216: case 0x244: case 0x1e72:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
731 case 0x1e74: case 0x1e76: case 0x1e78: case 0x1e7a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
732 case 0x1ee4: case 0x1ee6: case 0x1ee8: case 0x1eea:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
733 case 0x1eec: case 0x1eee: case 0x1ef0:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 regmbc('U'); regmbc(0xd9); regmbc(0xda);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
735 regmbc(0xdb); regmbc(0xdc); regmbc(0x168);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
736 regmbc(0x16a); regmbc(0x16c); regmbc(0x16e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
737 regmbc(0x170); regmbc(0x172); regmbc(0x1af);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
738 regmbc(0x1d3); regmbc(0x1d5); regmbc(0x1d7);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
739 regmbc(0x1d9); regmbc(0x1db); regmbc(0x214);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
740 regmbc(0x216); regmbc(0x244); regmbc(0x1e72);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
741 regmbc(0x1e74); regmbc(0x1e76); regmbc(0x1e78);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
742 regmbc(0x1e7a); regmbc(0x1ee4); regmbc(0x1ee6);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
743 regmbc(0x1ee8); regmbc(0x1eea); regmbc(0x1eec);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
744 regmbc(0x1eee); regmbc(0x1ef0);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
746 case 'V': case 0x1b2: case 0x1e7c: case 0x1e7e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
747 regmbc('V'); regmbc(0x1b2); regmbc(0x1e7c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
748 regmbc(0x1e7e);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
750 case 'W': case 0x174: case 0x1e80: case 0x1e82:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
751 case 0x1e84: case 0x1e86: case 0x1e88:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
752 regmbc('W'); regmbc(0x174); regmbc(0x1e80);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
753 regmbc(0x1e82); regmbc(0x1e84); regmbc(0x1e86);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
754 regmbc(0x1e88);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
756 case 'X': case 0x1e8a: case 0x1e8c:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
757 regmbc('X'); regmbc(0x1e8a); regmbc(0x1e8c);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 case 'Y': case 0xdd:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
760 case 0x176: case 0x178: case 0x1b3: case 0x232: case 0x24e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
761 case 0x1e8e: case 0x1ef2: case 0x1ef6: case 0x1ef4: case 0x1ef8:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
762 regmbc('Y'); regmbc(0xdd); regmbc(0x176);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
763 regmbc(0x178); regmbc(0x1b3); regmbc(0x232);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
764 regmbc(0x24e); regmbc(0x1e8e); regmbc(0x1ef2);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
765 regmbc(0x1ef4); regmbc(0x1ef6); regmbc(0x1ef8);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
767 case 'Z': case 0x179: case 0x17b: case 0x17d: case 0x1b5:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
768 case 0x1e90: case 0x1e92: case 0x1e94: case 0x2c6b:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
769 regmbc('Z'); regmbc(0x179); regmbc(0x17b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
770 regmbc(0x17d); regmbc(0x1b5); regmbc(0x1e90);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
771 regmbc(0x1e92); regmbc(0x1e94); regmbc(0x2c6b);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 case 'a': case 0xe0: case 0xe1: case 0xe2:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
774 case 0xe3: case 0xe4: case 0xe5: case 0x101: case 0x103:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
775 case 0x105: case 0x1ce: case 0x1df: case 0x1e1: case 0x1fb:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
776 case 0x201: case 0x203: case 0x227: case 0x1d8f: case 0x1e01:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
777 case 0x1e9a: case 0x1ea1: case 0x1ea3: case 0x1ea5:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
778 case 0x1ea7: case 0x1ea9: case 0x1eab: case 0x1ead:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
779 case 0x1eaf: case 0x1eb1: case 0x1eb3: case 0x1eb5:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
780 case 0x1eb7: case 0x2c65:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 regmbc('a'); regmbc(0xe0); regmbc(0xe1);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 regmbc(0xe2); regmbc(0xe3); regmbc(0xe4);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
783 regmbc(0xe5); regmbc(0x101); regmbc(0x103);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
784 regmbc(0x105); regmbc(0x1ce); regmbc(0x1df);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
785 regmbc(0x1e1); regmbc(0x1fb); regmbc(0x201);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
786 regmbc(0x203); regmbc(0x227); regmbc(0x1d8f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
787 regmbc(0x1e01); regmbc(0x1e9a); regmbc(0x1ea1);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
788 regmbc(0x1ea3); regmbc(0x1ea5); regmbc(0x1ea7);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
789 regmbc(0x1ea9); regmbc(0x1eab); regmbc(0x1ead);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
790 regmbc(0x1eaf); regmbc(0x1eb1); regmbc(0x1eb3);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
791 regmbc(0x1eb5); regmbc(0x1eb7); regmbc(0x2c65);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
793 case 'b': case 0x180: case 0x253: case 0x1d6c: case 0x1d80:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
794 case 0x1e03: case 0x1e05: case 0x1e07:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
795 regmbc('b');
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
796 regmbc(0x180); regmbc(0x253); regmbc(0x1d6c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
797 regmbc(0x1d80); regmbc(0x1e03); regmbc(0x1e05);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
798 regmbc(0x1e07);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 case 'c': case 0xe7:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
801 case 0x107: case 0x109: case 0x10b: case 0x10d: case 0x188:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
802 case 0x23c: case 0x1e09: case 0xa793: case 0xa794:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
803 regmbc('c'); regmbc(0xe7); regmbc(0x107);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
804 regmbc(0x109); regmbc(0x10b); regmbc(0x10d);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
805 regmbc(0x188); regmbc(0x23c); regmbc(0x1e09);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
806 regmbc(0xa793); regmbc(0xa794);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
808 case 'd': case 0x10f: case 0x111: case 0x257: case 0x1d6d:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
809 case 0x1d81: case 0x1d91: case 0x1e0b: case 0x1e0d:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
810 case 0x1e0f: case 0x1e11: case 0x1e13:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
811 regmbc('d'); regmbc(0x10f); regmbc(0x111);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
812 regmbc(0x257); regmbc(0x1d6d); regmbc(0x1d81);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
813 regmbc(0x1d91); regmbc(0x1e0b); regmbc(0x1e0d);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
814 regmbc(0x1e0f); regmbc(0x1e11); regmbc(0x1e13);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816 case 'e': case 0xe8: case 0xe9: case 0xea: case 0xeb:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
817 case 0x113: case 0x115: case 0x117: case 0x119:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
818 case 0x11b: case 0x205: case 0x207: case 0x229:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
819 case 0x247: case 0x1d92: case 0x1e15: case 0x1e17:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
820 case 0x1e19: case 0x1e1b: case 0x1eb9: case 0x1ebb:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
821 case 0x1e1d: case 0x1ebd: case 0x1ebf: case 0x1ec1:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
822 case 0x1ec3: case 0x1ec5: case 0x1ec7:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 regmbc('e'); regmbc(0xe8); regmbc(0xe9);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
824 regmbc(0xea); regmbc(0xeb); regmbc(0x113);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
825 regmbc(0x115); regmbc(0x117); regmbc(0x119);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
826 regmbc(0x11b); regmbc(0x205); regmbc(0x207);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
827 regmbc(0x229); regmbc(0x247); regmbc(0x1d92);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
828 regmbc(0x1e15); regmbc(0x1e17); regmbc(0x1e19);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
829 regmbc(0x1e1b); regmbc(0x1e1d); regmbc(0x1eb9);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
830 regmbc(0x1ebb); regmbc(0x1ebd); regmbc(0x1ebf);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
831 regmbc(0x1ec1); regmbc(0x1ec3); regmbc(0x1ec5);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
832 regmbc(0x1ec7);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
834 case 'f': case 0x192: case 0x1d6e: case 0x1d82:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
835 case 0x1e1f: case 0xa799:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
836 regmbc('f'); regmbc(0x192); regmbc(0x1d6e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
837 regmbc(0x1d82); regmbc(0x1e1f); regmbc(0xa799);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
838 return;
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
839 case 'g': case 0x11d: case 0x11f: case 0x121: case 0x123:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
840 case 0x1e5: case 0x1e7: case 0x260: case 0x1f5: case 0x1d83:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
841 case 0x1e21: case 0xa7a1:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
842 regmbc('g'); regmbc(0x11d); regmbc(0x11f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
843 regmbc(0x121); regmbc(0x123); regmbc(0x1e5);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
844 regmbc(0x1e7); regmbc(0x1f5); regmbc(0x260);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
845 regmbc(0x1d83); regmbc(0x1e21); regmbc(0xa7a1);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
847 case 'h': case 0x125: case 0x127: case 0x21f: case 0x1e23:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
848 case 0x1e25: case 0x1e27: case 0x1e29: case 0x1e2b:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
849 case 0x1e96: case 0x2c68: case 0xa795:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
850 regmbc('h'); regmbc(0x125); regmbc(0x127);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
851 regmbc(0x21f); regmbc(0x1e23); regmbc(0x1e25);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
852 regmbc(0x1e27); regmbc(0x1e29); regmbc(0x1e2b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
853 regmbc(0x1e96); regmbc(0x2c68); regmbc(0xa795);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 case 'i': case 0xec: case 0xed: case 0xee: case 0xef:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
856 case 0x129: case 0x12b: case 0x12d: case 0x12f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
857 case 0x1d0: case 0x209: case 0x20b: case 0x268:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
858 case 0x1d96: case 0x1e2d: case 0x1e2f: case 0x1ec9:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
859 case 0x1ecb:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 regmbc('i'); regmbc(0xec); regmbc(0xed);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
861 regmbc(0xee); regmbc(0xef); regmbc(0x129);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
862 regmbc(0x12b); regmbc(0x12d); regmbc(0x12f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
863 regmbc(0x1d0); regmbc(0x209); regmbc(0x20b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
864 regmbc(0x268); regmbc(0x1d96); regmbc(0x1e2d);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
865 regmbc(0x1e2f); regmbc(0x1ec9); regmbc(0x1ecb);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
867 case 'j': case 0x135: case 0x1f0: case 0x249:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
868 regmbc('j'); regmbc(0x135); regmbc(0x1f0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
869 regmbc(0x249);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
871 case 'k': case 0x137: case 0x199: case 0x1e9:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
872 case 0x1d84: case 0x1e31: case 0x1e33: case 0x1e35:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
873 case 0x2c6a: case 0xa741:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
874 regmbc('k'); regmbc(0x137); regmbc(0x199);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
875 regmbc(0x1e9); regmbc(0x1d84); regmbc(0x1e31);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
876 regmbc(0x1e33); regmbc(0x1e35); regmbc(0x2c6a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
877 regmbc(0xa741);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
879 case 'l': case 0x13a: case 0x13c: case 0x13e:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
880 case 0x140: case 0x142: case 0x19a: case 0x1e37:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
881 case 0x1e39: case 0x1e3b: case 0x1e3d: case 0x2c61:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
882 regmbc('l'); regmbc(0x13a); regmbc(0x13c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
883 regmbc(0x13e); regmbc(0x140); regmbc(0x142);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
884 regmbc(0x19a); regmbc(0x1e37); regmbc(0x1e39);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
885 regmbc(0x1e3b); regmbc(0x1e3d); regmbc(0x2c61);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
887 case 'm': case 0x1d6f: case 0x1e3f: case 0x1e41: case 0x1e43:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
888 regmbc('m'); regmbc(0x1d6f); regmbc(0x1e3f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
889 regmbc(0x1e41); regmbc(0x1e43);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
890 return;
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
891 case 'n': case 0xf1: case 0x144: case 0x146: case 0x148:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
892 case 0x149: case 0x1f9: case 0x1d70: case 0x1d87:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
893 case 0x1e45: case 0x1e47: case 0x1e49: case 0x1e4b:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
894 case 0xa7a5:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
895 regmbc('n'); regmbc(0xf1); regmbc(0x144);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
896 regmbc(0x146); regmbc(0x148); regmbc(0x149);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
897 regmbc(0x1f9); regmbc(0x1d70); regmbc(0x1d87);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
898 regmbc(0x1e45); regmbc(0x1e47); regmbc(0x1e49);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
899 regmbc(0x1e4b); regmbc(0xa7a5);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 case 'o': case 0xf2: case 0xf3: case 0xf4: case 0xf5:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
902 case 0xf6: case 0xf8: case 0x14d: case 0x14f: case 0x151:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
903 case 0x1a1: case 0x1d2: case 0x1eb: case 0x1ed: case 0x1ff:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
904 case 0x20d: case 0x20f: case 0x22b: case 0x22d: case 0x22f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
905 case 0x231: case 0x275: case 0x1e4d: case 0x1e4f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
906 case 0x1e51: case 0x1e53: case 0x1ecd: case 0x1ecf:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
907 case 0x1ed1: case 0x1ed3: case 0x1ed5: case 0x1ed7:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
908 case 0x1ed9: case 0x1edb: case 0x1edd: case 0x1edf:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
909 case 0x1ee1: case 0x1ee3:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 regmbc('o'); regmbc(0xf2); regmbc(0xf3);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 regmbc(0xf4); regmbc(0xf5); regmbc(0xf6);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
912 regmbc(0xf8); regmbc(0x14d); regmbc(0x14f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
913 regmbc(0x151); regmbc(0x1a1); regmbc(0x1d2);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
914 regmbc(0x1eb); regmbc(0x1ed); regmbc(0x1ff);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
915 regmbc(0x20d); regmbc(0x20f); regmbc(0x22b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
916 regmbc(0x22d); regmbc(0x22f); regmbc(0x231);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
917 regmbc(0x275); regmbc(0x1e4d); regmbc(0x1e4f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
918 regmbc(0x1e51); regmbc(0x1e53); regmbc(0x1ecd);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
919 regmbc(0x1ecf); regmbc(0x1ed1); regmbc(0x1ed3);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
920 regmbc(0x1ed5); regmbc(0x1ed7); regmbc(0x1ed9);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
921 regmbc(0x1edb); regmbc(0x1edd); regmbc(0x1edf);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
922 regmbc(0x1ee1); regmbc(0x1ee3);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
924 case 'p': case 0x1a5: case 0x1d71: case 0x1d88: case 0x1d7d:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
925 case 0x1e55: case 0x1e57:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
926 regmbc('p'); regmbc(0x1a5); regmbc(0x1d71);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
927 regmbc(0x1d7d); regmbc(0x1d88); regmbc(0x1e55);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
928 regmbc(0x1e57);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
929 return;
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
930 case 'q': case 0x24b: case 0x2a0:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
931 regmbc('q'); regmbc(0x24b); regmbc(0x2a0);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
933 case 'r': case 0x155: case 0x157: case 0x159: case 0x211:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
934 case 0x213: case 0x24d: case 0x27d: case 0x1d72: case 0x1d73:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
935 case 0x1d89: case 0x1e59: case 0x1e5b: case 0x1e5d: case 0x1e5f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
936 case 0xa7a7:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
937 regmbc('r'); regmbc(0x155); regmbc(0x157);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
938 regmbc(0x159); regmbc(0x211); regmbc(0x213);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
939 regmbc(0x24d); regmbc(0x1d72); regmbc(0x1d73);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
940 regmbc(0x1d89); regmbc(0x1e59); regmbc(0x27d);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
941 regmbc(0x1e5b); regmbc(0x1e5d); regmbc(0x1e5f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
942 regmbc(0xa7a7);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
944 case 's': case 0x15b: case 0x15d: case 0x15f: case 0x161:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
945 case 0x1e61: case 0x219: case 0x23f: case 0x1d74: case 0x1d8a:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
946 case 0x1e63: case 0x1e65: case 0x1e67: case 0x1e69: case 0xa7a9:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
947 regmbc('s'); regmbc(0x15b); regmbc(0x15d);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
948 regmbc(0x15f); regmbc(0x161); regmbc(0x23f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
949 regmbc(0x219); regmbc(0x1d74); regmbc(0x1d8a);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
950 regmbc(0x1e61); regmbc(0x1e63); regmbc(0x1e65);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
951 regmbc(0x1e67); regmbc(0x1e69); regmbc(0xa7a9);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
953 case 't': case 0x163: case 0x165: case 0x167: case 0x1ab:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
954 case 0x1ad: case 0x21b: case 0x288: case 0x1d75: case 0x1e6b:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
955 case 0x1e6d: case 0x1e6f: case 0x1e71: case 0x1e97: case 0x2c66:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
956 regmbc('t'); regmbc(0x163); regmbc(0x165);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
957 regmbc(0x167); regmbc(0x1ab); regmbc(0x21b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
958 regmbc(0x1ad); regmbc(0x288); regmbc(0x1d75);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
959 regmbc(0x1e6b); regmbc(0x1e6d); regmbc(0x1e6f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
960 regmbc(0x1e71); regmbc(0x1e97); regmbc(0x2c66);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 case 'u': case 0xf9: case 0xfa: case 0xfb: case 0xfc:
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
963 case 0x169: case 0x16b: case 0x16d: case 0x16f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
964 case 0x171: case 0x173: case 0x1b0: case 0x1d4:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
965 case 0x1d6: case 0x1d8: case 0x1da: case 0x1dc:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
966 case 0x215: case 0x217: case 0x289: case 0x1e73:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
967 case 0x1d7e: case 0x1d99: case 0x1e75: case 0x1e77:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
968 case 0x1e79: case 0x1e7b: case 0x1ee5: case 0x1ee7:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
969 case 0x1ee9: case 0x1eeb: case 0x1eed: case 0x1eef:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
970 case 0x1ef1:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 regmbc('u'); regmbc(0xf9); regmbc(0xfa);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
972 regmbc(0xfb); regmbc(0xfc); regmbc(0x169);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
973 regmbc(0x16b); regmbc(0x16d); regmbc(0x16f);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
974 regmbc(0x171); regmbc(0x173); regmbc(0x1d6);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
975 regmbc(0x1d8); regmbc(0x1da); regmbc(0x1dc);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
976 regmbc(0x215); regmbc(0x217); regmbc(0x1b0);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
977 regmbc(0x1d4); regmbc(0x289); regmbc(0x1d7e);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
978 regmbc(0x1d99); regmbc(0x1e73); regmbc(0x1e75);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
979 regmbc(0x1e77); regmbc(0x1e79); regmbc(0x1e7b);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
980 regmbc(0x1ee5); regmbc(0x1ee7); regmbc(0x1ee9);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
981 regmbc(0x1eeb); regmbc(0x1eed); regmbc(0x1eef);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
982 regmbc(0x1ef1);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
984 case 'v': case 0x28b: case 0x1d8c: case 0x1e7d: case 0x1e7f:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
985 regmbc('v'); regmbc(0x28b); regmbc(0x1d8c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
986 regmbc(0x1e7d); regmbc(0x1e7f);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
988 case 'w': case 0x175: case 0x1e81: case 0x1e83:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
989 case 0x1e85: case 0x1e87: case 0x1e89: case 0x1e98:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
990 regmbc('w'); regmbc(0x175); regmbc(0x1e81);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
991 regmbc(0x1e83); regmbc(0x1e85); regmbc(0x1e87);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
992 regmbc(0x1e89); regmbc(0x1e98);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
994 case 'x': case 0x1e8b: case 0x1e8d:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
995 regmbc('x'); regmbc(0x1e8b); regmbc(0x1e8d);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
997 case 'y': case 0xfd: case 0xff: case 0x177: case 0x1b4:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
998 case 0x233: case 0x24f: case 0x1e8f: case 0x1e99: case 0x1ef3:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
999 case 0x1ef5: case 0x1ef7: case 0x1ef9:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 regmbc('y'); regmbc(0xfd); regmbc(0xff);
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1001 regmbc(0x177); regmbc(0x1b4); regmbc(0x233);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1002 regmbc(0x24f); regmbc(0x1e8f); regmbc(0x1e99);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1003 regmbc(0x1ef3); regmbc(0x1ef5); regmbc(0x1ef7);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1004 regmbc(0x1ef9);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 return;
24351
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1006 case 'z': case 0x17a: case 0x17c: case 0x17e: case 0x1b6:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1007 case 0x1d76: case 0x1d8e: case 0x1e91: case 0x1e93:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1008 case 0x1e95: case 0x2c6c:
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1009 regmbc('z'); regmbc(0x17a); regmbc(0x17c);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1010 regmbc(0x17e); regmbc(0x1b6); regmbc(0x1d76);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1011 regmbc(0x1d8e); regmbc(0x1e91); regmbc(0x1e93);
585695c70392 patch 8.2.2716: the equivalent class regexp is missing some characters
Bram Moolenaar <Bram@vim.org>
parents: 23270
diff changeset
1012 regmbc(0x1e95); regmbc(0x2c6c);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 regmbc(c);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 * Emit a node.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 * Return pointer to generated code.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 regnode(int op)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 char_u *ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 ret = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 if (ret == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 regsize += 3;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 *regcode++ = op;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1035 *regcode++ = NUL; // Null "next" pointer.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 *regcode++ = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 return ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 * Write a long as four bytes at "p" and return pointer to the next char.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 re_put_long(char_u *p, long_u val)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 *p++ = (char_u) ((val >> 24) & 0377);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 *p++ = (char_u) ((val >> 16) & 0377);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 *p++ = (char_u) ((val >> 8) & 0377);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 *p++ = (char_u) (val & 0377);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 return p;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 * regnext - dig the "next" pointer out of a node
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 * Returns NULL when calculating size, when there is no next item and when
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 * there is an error.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 regnext(char_u *p)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 int offset;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 if (p == JUST_CALC_SIZE || reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 offset = NEXT(p);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 if (offset == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 if (OP(p) == BACK)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 return p - offset;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 return p + offset;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 * Set the next-pointer at the end of a node chain.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 regtail(char_u *p, char_u *val)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 char_u *scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 char_u *temp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 int offset;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 if (p == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1090 // Find last node.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 scan = p;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 for (;;)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 temp = regnext(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 if (temp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 scan = temp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 if (OP(scan) == BACK)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 offset = (int)(scan - val);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 offset = (int)(val - scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1104 // When the offset uses more than 16 bits it can no longer fit in the two
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1105 // bytes available. Use a global flag to avoid having to check return
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1106 // values in too many places.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 if (offset > 0xffff)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 reg_toolong = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 *(scan + 1) = (char_u) (((unsigned)offset >> 8) & 0377);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 *(scan + 2) = (char_u) (offset & 0377);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 * Like regtail, on item after a BRANCH; nop if none.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1118 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 regoptail(char_u *p, char_u *val)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1122 // When op is neither BRANCH nor BRACE_COMPLEX0-9, it is "operandless"
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 if (p == NULL || p == JUST_CALC_SIZE
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 || (OP(p) != BRANCH
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 && (OP(p) < BRACE_COMPLEX || OP(p) > BRACE_COMPLEX + 9)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 regtail(OPERAND(p), val);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 * Insert an operator in front of already-emitted operand
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 * Means relocating the operand.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 reginsert(int op, char_u *opnd)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 char_u *src;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 char_u *dst;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 char_u *place;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 if (regcode == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 regsize += 3;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 src = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 regcode += 3;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 dst = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 while (src > opnd)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 *--dst = *--src;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1153 place = opnd; // Op node, where operand used to be.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 *place++ = op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 *place++ = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 *place = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 * Insert an operator in front of already-emitted operand.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 * Add a number to the operator.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 reginsert_nr(int op, long val, char_u *opnd)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 char_u *src;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 char_u *dst;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 char_u *place;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 if (regcode == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 regsize += 7;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 src = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176 regcode += 7;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 dst = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 while (src > opnd)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 *--dst = *--src;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1181 place = opnd; // Op node, where operand used to be.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 *place++ = op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 *place++ = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 *place++ = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 re_put_long(place, (long_u)val);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 * Insert an operator in front of already-emitted operand.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 * The operator has the given limit values as operands. Also set next pointer.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 * Means relocating the operand.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 reginsert_limits(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 int op,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 long minval,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 long maxval,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 char_u *opnd)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 char_u *src;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 char_u *dst;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 char_u *place;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 if (regcode == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 regsize += 11;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 src = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 regcode += 11;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 dst = regcode;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 while (src > opnd)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 *--dst = *--src;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1216 place = opnd; // Op node, where operand used to be.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 *place++ = op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218 *place++ = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 *place++ = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 place = re_put_long(place, (long_u)minval);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 place = re_put_long(place, (long_u)maxval);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 regtail(opnd, place);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1224
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1226 * Return TRUE if the back reference is legal. We must have seen the close
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1227 * brace.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1228 * TODO: Should also check that we don't refer to something that is repeated
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1229 * (+*=): what instance of the repetition should we match?
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 seen_endbrace(int refnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 if (!had_endbrace[refnum])
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 char_u *p;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1238 // Trick: check if "@<=" or "@<!" follows, in which case
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1239 // the \1 can appear before the referenced match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 for (p = regparse; *p != NUL; ++p)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 if (p[0] == '@' && p[1] == '<' && (p[2] == '!' || p[2] == '='))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 if (*p == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 {
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1245 emsg(_(e_illegal_back_reference));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 rc_did_emsg = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 return FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250 return TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 * Parse the lowest level.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 * Optimization: gobbles an entire sequence of ordinary characters so that
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 * it can turn them into a single node, which is smaller to store and
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 * faster to run. Don't do this when one_exactly is set.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 regatom(int *flagp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 char_u *ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 int flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 int c;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 char_u *p;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 int extra = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 int save_prev_at_start = prev_at_start;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1270 *flagp = WORST; // Tentatively.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 c = getchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 switch (c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275 case Magic('^'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 ret = regnode(BOL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 case Magic('$'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 ret = regnode(EOL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 #if defined(FEAT_SYN_HL) || defined(PROTO)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 had_eol = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 case Magic('<'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 ret = regnode(BOW);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 case Magic('>'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 ret = regnode(EOW);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 case Magic('_'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 c = no_Magic(getchr());
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1296 if (c == '^') // "\_^" is start-of-line
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298 ret = regnode(BOL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1301 if (c == '$') // "\_$" is end-of-line
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 ret = regnode(EOL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 #if defined(FEAT_SYN_HL) || defined(PROTO)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 had_eol = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 extra = ADD_NL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311 *flagp |= HASNL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1313 // "\_[" is character range plus newline
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 if (c == '[')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 goto collection;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1317 // "\_x" is character class plus newline
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1318 // FALLTHROUGH
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1319
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1320 // Character classes.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 case Magic('.'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 case Magic('i'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 case Magic('I'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 case Magic('k'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 case Magic('K'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 case Magic('f'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 case Magic('F'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 case Magic('p'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1329 case Magic('P'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 case Magic('s'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331 case Magic('S'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332 case Magic('d'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1333 case Magic('D'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1334 case Magic('x'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335 case Magic('X'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1336 case Magic('o'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 case Magic('O'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1338 case Magic('w'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 case Magic('W'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1340 case Magic('h'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 case Magic('H'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 case Magic('a'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 case Magic('A'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1344 case Magic('l'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1345 case Magic('L'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 case Magic('u'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 case Magic('U'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 p = vim_strchr(classchars, no_Magic(c));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 if (p == NULL)
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1350 EMSG_RET_NULL(_(e_invalid_use_of_underscore));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1352 // When '.' is followed by a composing char ignore the dot, so that
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1353 // the composing char is matched here.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1354 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr()))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 c = getchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357 goto do_multibyte;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 ret = regnode(classcodes[p - classchars] + extra);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 *flagp |= HASWIDTH | SIMPLE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 case Magic('n'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364 if (reg_string)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1365 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1366 // In a string "\n" matches a newline character.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1367 ret = regnode(EXACTLY);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1368 regc(NL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 regc(NUL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1370 *flagp |= HASWIDTH | SIMPLE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1371 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1372 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1374 // In buffer text "\n" matches the end of a line.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375 ret = regnode(NEWL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 *flagp |= HASWIDTH | HASNL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1379
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 case Magic('('):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381 if (one_exactly)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 EMSG_ONE_RET_NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1383 ret = reg(REG_PAREN, &flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384 if (ret == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1386 *flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1387 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 case NUL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390 case Magic('|'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1391 case Magic('&'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 case Magic(')'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 if (one_exactly)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 EMSG_ONE_RET_NULL;
26867
d66ba549f68a patch 8.2.3962: build fails for missing error message
Bram Moolenaar <Bram@vim.org>
parents: 26436
diff changeset
1395 // Supposed to be caught earlier.
d66ba549f68a patch 8.2.3962: build fails for missing error message
Bram Moolenaar <Bram@vim.org>
parents: 26436
diff changeset
1396 IEMSG_RET_NULL(_(e_internal_error_in_regexp));
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1397 // NOTREACHED
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399 case Magic('='):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 case Magic('?'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 case Magic('+'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 case Magic('@'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 case Magic('{'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 case Magic('*'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405 c = no_Magic(c);
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1406 EMSG3_RET_NULL(_(e_str_chr_follows_nothing),
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1407 (c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL), c);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1408 // NOTREACHED
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1409
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1410 case Magic('~'): // previous substitute pattern
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1411 if (reg_prev_sub != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413 char_u *lp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 ret = regnode(EXACTLY);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 lp = reg_prev_sub;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 while (*lp != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 regc(*lp++);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 regc(NUL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420 if (*reg_prev_sub != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1422 *flagp |= HASWIDTH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 if ((lp - reg_prev_sub) == 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424 *flagp |= SIMPLE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1425 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 else
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25147
diff changeset
1428 EMSG_RET_NULL(_(e_no_previous_substitute_regular_expression));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431 case Magic('1'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 case Magic('2'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433 case Magic('3'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1434 case Magic('4'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 case Magic('5'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 case Magic('6'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1437 case Magic('7'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 case Magic('8'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 case Magic('9'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1440 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 int refnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1442
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1443 refnum = c - Magic('0');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 if (!seen_endbrace(refnum))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 ret = regnode(BACKREF + refnum);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1448 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450 case Magic('z'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 c = no_Magic(getchr());
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453 switch (c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1454 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1455 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1456 case '(': if ((reg_do_extmatch & REX_SET) == 0)
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1457 EMSG_RET_NULL(_(e_z_not_allowed_here));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1458 if (one_exactly)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1459 EMSG_ONE_RET_NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1460 ret = reg(REG_ZPAREN, &flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1461 if (ret == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1462 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1463 *flagp |= flags & (HASWIDTH|SPSTART|HASNL|HASLOOKBH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1464 re_has_z = REX_SET;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1465 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1466
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1467 case '1':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1468 case '2':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 case '3':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1470 case '4':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471 case '5':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 case '6':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1473 case '7':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1474 case '8':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1475 case '9': if ((reg_do_extmatch & REX_USE) == 0)
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1476 EMSG_RET_NULL(_(e_z1_z9_not_allowed_here));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477 ret = regnode(ZREF + c - '0');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1478 re_has_z = REX_USE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1479 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1480 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1482 case 's': ret = regnode(MOPEN + 0);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1483 if (re_mult_next("\\zs") == FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1484 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1485 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1486
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1487 case 'e': ret = regnode(MCLOSE + 0);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1488 if (re_mult_next("\\ze") == FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1489 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1490 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1491
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1492 default: EMSG_RET_NULL(_("E68: Invalid character after \\z"));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1494 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1495 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1496
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1497 case Magic('%'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1498 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1499 c = no_Magic(getchr());
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1500 switch (c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1501 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1502 // () without a back reference
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1503 case '(':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1504 if (one_exactly)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1505 EMSG_ONE_RET_NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1506 ret = reg(REG_NPAREN, &flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 if (ret == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1508 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509 *flagp |= flags & (HASWIDTH | SPSTART | HASNL | HASLOOKBH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1510 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1511
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1512 // Catch \%^ and \%$ regardless of where they appear in the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1513 // pattern -- regardless of whether or not it makes sense.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514 case '^':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 ret = regnode(RE_BOF);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1516 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1517
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1518 case '$':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 ret = regnode(RE_EOF);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1520 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1522 case '#':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 ret = regnode(CURSOR);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1524 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1526 case 'V':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1527 ret = regnode(RE_VISUAL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1528 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1529
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 case 'C':
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531 ret = regnode(RE_COMPOSING);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1532 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1533
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1534 // \%[abc]: Emit as a list of branches, all ending at the last
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1535 // branch which matches nothing.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 case '[':
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1537 if (one_exactly) // doesn't nest
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 EMSG_ONE_RET_NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1539 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1540 char_u *lastbranch;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 char_u *lastnode = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1542 char_u *br;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1543
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1544 ret = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1545 while ((c = getchr()) != ']')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1546 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1547 if (c == NUL)
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1548 EMSG2_RET_NULL(_(e_missing_sb_after_str),
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1549 reg_magic == MAGIC_ALL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1550 br = regnode(BRANCH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551 if (ret == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1552 ret = br;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1553 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1554 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1555 regtail(lastnode, br);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556 if (reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1557 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1558 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1560 ungetchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 one_exactly = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 lastnode = regatom(flagp);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1563 one_exactly = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1564 if (lastnode == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1565 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1566 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1567 if (ret == NULL)
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1568 EMSG2_RET_NULL(_(e_empty_str_brackets),
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569 reg_magic == MAGIC_ALL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 lastbranch = regnode(BRANCH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1571 br = regnode(NOTHING);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572 if (ret != JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1573 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1574 regtail(lastnode, br);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1575 regtail(lastbranch, br);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1576 // connect all branches to the NOTHING
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1577 // branch at the end
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1578 for (br = ret; br != lastnode; )
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1579 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1580 if (OP(br) == BRANCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1581 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1582 regtail(br, lastbranch);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1583 if (reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 br = OPERAND(br);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1586 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1587 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1588 br = regnext(br);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1589 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1590 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1591 *flagp &= ~(HASWIDTH | SIMPLE);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1592 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1593 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1594
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1595 case 'd': // %d123 decimal
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1596 case 'o': // %o123 octal
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1597 case 'x': // %xab hex 2
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1598 case 'u': // %uabcd hex 4
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1599 case 'U': // %U1234abcd hex 8
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1600 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1601 long i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1602
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1603 switch (c)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1604 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1605 case 'd': i = getdecchrs(); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1606 case 'o': i = getoctchrs(); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1607 case 'x': i = gethexchrs(2); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 case 'u': i = gethexchrs(4); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1609 case 'U': i = gethexchrs(8); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1610 default: i = -1; break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1611 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1612
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613 if (i < 0 || i > INT_MAX)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1614 EMSG2_RET_NULL(
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
1615 _(e_invalid_character_after_str_2),
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
1616 reg_magic == MAGIC_ALL);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1617 if (use_multibytecode(i))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1618 ret = regnode(MULTIBYTECODE);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1620 ret = regnode(EXACTLY);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1621 if (i == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1622 regc(0x0a);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1623 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 regmbc(i);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 regc(NUL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1626 *flagp |= HASWIDTH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1627 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1629
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1630 default:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631 if (VIM_ISDIGIT(c) || c == '<' || c == '>'
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1632 || c == '\'' || c == '.')
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1633 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634 long_u n = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 int cmp;
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1636 int cur = FALSE;
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1637
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1638 cmp = c;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1639 if (cmp == '<' || cmp == '>')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1640 c = getchr();
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1641 if (no_Magic(c) == '.')
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1642 {
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1643 cur = TRUE;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1644 c = getchr();
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1645 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1646 while (VIM_ISDIGIT(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1647 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1648 n = n * 10 + (c - '0');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1649 c = getchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1650 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1651 if (c == '\'' && n == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1652 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1653 // "\%'m", "\%<'m" and "\%>'m": Mark
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1654 c = getchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 ret = regnode(RE_MARK);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1656 if (ret == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657 regsize += 2;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1659 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 *regcode++ = c;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 *regcode++ = cmp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1662 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1663 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1664 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1665 else if (c == 'l' || c == 'c' || c == 'v')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1666 {
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1667 if (cur && n)
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1668 {
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1669 semsg(_(e_regexp_number_after_dot_pos_search), no_Magic(c));
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1670 rc_did_emsg = TRUE;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1671 return NULL;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1672 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1673 if (c == 'l')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1674 {
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1675 if (cur)
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1676 n = curwin->w_cursor.lnum;
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1677 ret = regnode(RE_LNUM);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 if (save_prev_at_start)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 at_start = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1681 else if (c == 'c')
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1682 {
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1683 if (cur)
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1684 {
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1685 n = curwin->w_cursor.col;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1686 n++;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1687 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1688 ret = regnode(RE_COL);
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1689 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1690 else
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1691 {
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1692 if (cur)
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1693 {
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1694 colnr_T vcol = 0;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1695
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1696 getvvcol(curwin, &curwin->w_cursor,
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1697 NULL, NULL, &vcol);
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1698 ++vcol;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1699 n = vcol;
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1700 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1701 ret = regnode(RE_VCOL);
25147
10b269321459 patch 8.2.3110: a pattern that matches the cursor position is complicated
Bram Moolenaar <Bram@vim.org>
parents: 24693
diff changeset
1702 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 if (ret == JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1704 regsize += 5;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1706 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1707 // put the number and the optional
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1708 // comparator after the opcode
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1709 regcode = re_put_long(regcode, n);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1710 *regcode++ = cmp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1712 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1713 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1714 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1715
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
1716 EMSG2_RET_NULL(_(e_invalid_character_after_str),
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1717 reg_magic == MAGIC_ALL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1718 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1719 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1721
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1722 case Magic('['):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1723 collection:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1725 char_u *lp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1727 // If there is no matching ']', we assume the '[' is a normal
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1728 // character. This makes 'incsearch' and ":help [" work.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1729 lp = skip_anyof(regparse);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1730 if (*lp == ']') // there is a matching ']'
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1731 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1732 int startc = -1; // > 0 when next '-' is a range
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1733 int endc;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1735 // In a character class, different parsing rules apply.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1736 // Not even \ is special anymore, nothing is.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1737 if (*regparse == '^') // Complement of range.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1738 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1739 ret = regnode(ANYBUT + extra);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1740 regparse++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1741 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1742 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1743 ret = regnode(ANYOF + extra);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1744
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1745 // At the start ']' and '-' mean the literal character.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 if (*regparse == ']' || *regparse == '-')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1747 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1748 startc = *regparse;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1749 regc(*regparse++);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1750 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1751
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1752 while (*regparse != NUL && *regparse != ']')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 if (*regparse == '-')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 ++regparse;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1757 // The '-' is not used for a range at the end and
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1758 // after or before a '\n'.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1759 if (*regparse == ']' || *regparse == NUL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1760 || startc == -1
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 || (regparse[0] == '\\' && regparse[1] == 'n'))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1762 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1763 regc('-');
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1764 startc = '-'; // [--x] is a range
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1765 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1768 // Also accept "a-[.z.]"
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1769 endc = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 if (*regparse == '[')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1771 endc = get_coll_element(&regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1772 if (endc == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1773 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1774 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 endc = mb_ptr2char_adv(&regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777 endc = *regparse++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1778 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1780 // Handle \o40, \x20 and \u20AC style sequences
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1781 if (endc == '\\' && !reg_cpo_lit && !reg_cpo_bsl)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1782 endc = coll_get_char();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1783
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1784 if (startc > endc)
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
1785 EMSG_RET_NULL(_(e_reverse_range_in_character_class));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1786 if (has_mbyte && ((*mb_char2len)(startc) > 1
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1787 || (*mb_char2len)(endc) > 1))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1788 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1789 // Limit to a range of 256 chars.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1790 if (endc > startc + 256)
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
1791 EMSG_RET_NULL(_(e_range_too_large_in_character_class));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1792 while (++startc <= endc)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1793 regmbc(startc);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1794 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1795 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1796 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1797 #ifdef EBCDIC
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798 int alpha_only = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1799
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1800 // for alphabetical range skip the gaps
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1801 // 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1802 if (isalpha(startc) && isalpha(endc))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1803 alpha_only = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1804 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1805 while (++startc <= endc)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1806 #ifdef EBCDIC
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1807 if (!alpha_only || isalpha(startc))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1808 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1809 regc(startc);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1811 startc = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1813 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1814 // Only "\]", "\^", "\]" and "\\" are special in Vi. Vim
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1815 // accepts "\t", "\e", etc., but only when the 'l' flag in
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1816 // 'cpoptions' is not included.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1817 // Posix doesn't recognize backslash at all.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1818 else if (*regparse == '\\'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1819 && !reg_cpo_bsl
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1820 && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1821 || (!reg_cpo_lit
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1822 && vim_strchr(REGEXP_ABBR,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 regparse[1]) != NULL)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1824 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1825 regparse++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1826 if (*regparse == 'n')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1828 // '\n' in range: also match NL
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829 if (ret != JUST_CALC_SIZE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1830 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1831 // Using \n inside [^] does not change what
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1832 // matches. "[^\n]" is the same as ".".
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1833 if (*ret == ANYOF)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1834 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1835 *ret = ANYOF + ADD_NL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1836 *flagp |= HASNL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1837 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1838 // else: must have had a \n already
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1839 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1840 regparse++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1841 startc = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1842 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1843 else if (*regparse == 'd'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1844 || *regparse == 'o'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1845 || *regparse == 'x'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1846 || *regparse == 'u'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1847 || *regparse == 'U')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1848 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1849 startc = coll_get_char();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1850 if (startc == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1851 regc(0x0a);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1852 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1853 regmbc(startc);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1854 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1855 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1856 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1857 startc = backslash_trans(*regparse++);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1858 regc(startc);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1859 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1860 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1861 else if (*regparse == '[')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1862 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1863 int c_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1864 int cu;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1865
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1866 c_class = get_char_class(&regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1867 startc = -1;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1868 // Characters assumed to be 8 bits!
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1869 switch (c_class)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1870 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1871 case CLASS_NONE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1872 c_class = get_equi_class(&regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1873 if (c_class != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1874 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1875 // produce equivalence class
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1876 reg_equi_class(c_class);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1877 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1878 else if ((c_class =
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1879 get_coll_element(&regparse)) != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1880 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1881 // produce a collating element
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1882 regmbc(c_class);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1883 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1884 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1885 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1886 // literal '[', allow [[-x] as a range
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1887 startc = *regparse++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1888 regc(startc);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1889 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1890 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1891 case CLASS_ALNUM:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1892 for (cu = 1; cu < 128; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1893 if (isalnum(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1894 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1895 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1896 case CLASS_ALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1897 for (cu = 1; cu < 128; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1898 if (isalpha(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1899 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1900 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1901 case CLASS_BLANK:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1902 regc(' ');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1903 regc('\t');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1904 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1905 case CLASS_CNTRL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1906 for (cu = 1; cu <= 127; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1907 if (iscntrl(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1908 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1909 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1910 case CLASS_DIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1911 for (cu = 1; cu <= 127; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1912 if (VIM_ISDIGIT(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1913 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1914 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1915 case CLASS_GRAPH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1916 for (cu = 1; cu <= 127; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1917 if (isgraph(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1918 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1919 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1920 case CLASS_LOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1921 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1922 if (MB_ISLOWER(cu) && cu != 170
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1923 && cu != 186)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1924 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1925 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1926 case CLASS_PRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1927 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1928 if (vim_isprintc(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1929 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1931 case CLASS_PUNCT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1932 for (cu = 1; cu < 128; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1933 if (ispunct(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1934 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1935 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1936 case CLASS_SPACE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1937 for (cu = 9; cu <= 13; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1938 regc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1939 regc(' ');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1940 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1941 case CLASS_UPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1942 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1943 if (MB_ISUPPER(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1944 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1945 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 case CLASS_XDIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1947 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1948 if (vim_isxdigit(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1949 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1950 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1951 case CLASS_TAB:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1952 regc('\t');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1953 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1954 case CLASS_RETURN:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1955 regc('\r');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1956 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1957 case CLASS_BACKSPACE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1958 regc('\b');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1959 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1960 case CLASS_ESCAPE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1961 regc('\033');
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1962 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1963 case CLASS_IDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1964 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1965 if (vim_isIDc(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1966 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1967 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1968 case CLASS_KEYWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1969 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1970 if (reg_iswordc(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1971 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1972 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1973 case CLASS_FNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1974 for (cu = 1; cu <= 255; cu++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1975 if (vim_isfilec(cu))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1976 regmbc(cu);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1977 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1978 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1979 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1980 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1981 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1982 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1983 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1984 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1985
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1986 // produce a multibyte character, including any
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1987 // following composing characters
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1988 startc = mb_ptr2char(regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1989 len = (*mb_ptr2len)(regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1990 if (enc_utf8 && utf_char2len(startc) != len)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
1991 startc = -1; // composing chars
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1992 while (--len >= 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1993 regc(*regparse++);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1994 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1995 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1996 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1997 startc = *regparse++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1998 regc(startc);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1999 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2000 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2001 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2002 regc(NUL);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2003 prevchr_len = 1; // last char was the ']'
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2004 if (*regparse != ']')
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
2005 EMSG_RET_NULL(_(e_too_many_brackets)); // Cannot happen?
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2006 skipchr(); // let's be friends with the lexer again
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2007 *flagp |= HASWIDTH | SIMPLE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2008 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2009 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2010 else if (reg_strict)
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
2011 EMSG2_RET_NULL(_(e_missing_rsb_after_str_lsb),
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
2012 reg_magic > MAGIC_OFF);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2013 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2014 // FALLTHROUGH
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2015
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2016 default:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2017 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2018 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2019
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2020 // A multi-byte character is handled as a separate atom if it's
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2021 // before a multi and when it's a composing char.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2022 if (use_multibytecode(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2023 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2024 do_multibyte:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2025 ret = regnode(MULTIBYTECODE);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2026 regmbc(c);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2027 *flagp |= HASWIDTH | SIMPLE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2028 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2029 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2030
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2031 ret = regnode(EXACTLY);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2032
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2033 // Append characters as long as:
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2034 // - there is no following multi, we then need the character in
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2035 // front of it as a single character operand
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2036 // - not running into a Magic character
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2037 // - "one_exactly" is not set
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2038 // But always emit at least one character. Might be a Multi,
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2039 // e.g., a "[" without matching "]".
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2040 for (len = 0; c != NUL && (len == 0
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2041 || (re_multi_type(peekchr()) == NOT_MULTI
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2042 && !one_exactly
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2043 && !is_Magic(c))); ++len)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2044 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2045 c = no_Magic(c);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2046 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2047 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2048 regmbc(c);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2049 if (enc_utf8)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2050 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2051 int l;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2052
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2053 // Need to get composing character too.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2054 for (;;)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2055 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2056 l = utf_ptr2len(regparse);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2057 if (!UTF_COMPOSINGLIKE(regparse, regparse + l))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2058 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2059 regmbc(utf_ptr2char(regparse));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2060 skipchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2061 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2062 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2063 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2064 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2065 regc(c);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2066 c = getchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2067 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2068 ungetchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2069
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2070 regc(NUL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2071 *flagp |= HASWIDTH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2072 if (len == 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2073 *flagp |= SIMPLE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2074 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2075 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2076 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2077
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2078 return ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2079 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2080
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2081 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2082 * Parse something followed by possible [*+=].
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2083 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2084 * Note that the branching code sequences used for = and the general cases
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2085 * of * and + are somewhat optimized: they use the same NOTHING node as
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2086 * both the endmarker for their branch list and the body of the last branch.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2087 * It might seem that this node could be dispensed with entirely, but the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2088 * endmarker role is not redundant.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2089 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2090 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2091 regpiece(int *flagp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2092 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2093 char_u *ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2094 int op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2095 char_u *next;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2096 int flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2097 long minval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2098 long maxval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2099
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2100 ret = regatom(&flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2101 if (ret == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2102 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2103
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2104 op = peekchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2105 if (re_multi_type(op) == NOT_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2106 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2107 *flagp = flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2108 return ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2109 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2110 // default flags
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2111 *flagp = (WORST | SPSTART | (flags & (HASNL | HASLOOKBH)));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2112
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2113 skipchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2114 switch (op)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2115 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2116 case Magic('*'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2117 if (flags & SIMPLE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2118 reginsert(STAR, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2119 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2120 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2121 // Emit x* as (x&|), where & means "self".
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2122 reginsert(BRANCH, ret); // Either x
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2123 regoptail(ret, regnode(BACK)); // and loop
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2124 regoptail(ret, ret); // back
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2125 regtail(ret, regnode(BRANCH)); // or
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2126 regtail(ret, regnode(NOTHING)); // null.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2127 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2128 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2129
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2130 case Magic('+'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2131 if (flags & SIMPLE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2132 reginsert(PLUS, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2133 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2134 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2135 // Emit x+ as x(&|), where & means "self".
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2136 next = regnode(BRANCH); // Either
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2137 regtail(ret, next);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2138 regtail(regnode(BACK), ret); // loop back
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2139 regtail(next, regnode(BRANCH)); // or
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2140 regtail(ret, regnode(NOTHING)); // null.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2141 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2142 *flagp = (WORST | HASWIDTH | (flags & (HASNL | HASLOOKBH)));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2143 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2144
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2145 case Magic('@'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2146 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2147 int lop = END;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2148 long nr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2149
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2150 nr = getdecchrs();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2151 switch (no_Magic(getchr()))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2152 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2153 case '=': lop = MATCH; break; // \@=
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2154 case '!': lop = NOMATCH; break; // \@!
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2155 case '>': lop = SUBPAT; break; // \@>
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2156 case '<': switch (no_Magic(getchr()))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2157 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2158 case '=': lop = BEHIND; break; // \@<=
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2159 case '!': lop = NOBEHIND; break; // \@<!
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2160 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2161 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2162 if (lop == END)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2163 EMSG2_RET_NULL(_(e_invalid_character_after_str_at),
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2164 reg_magic == MAGIC_ALL);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2165 // Look behind must match with behind_pos.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2166 if (lop == BEHIND || lop == NOBEHIND)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2167 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2168 regtail(ret, regnode(BHPOS));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2169 *flagp |= HASLOOKBH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2170 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2171 regtail(ret, regnode(END)); // operand ends
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2172 if (lop == BEHIND || lop == NOBEHIND)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2173 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2174 if (nr < 0)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2175 nr = 0; // no limit is same as zero limit
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2176 reginsert_nr(lop, nr, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2177 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2178 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2179 reginsert(lop, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2180 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2181 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2182
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2183 case Magic('?'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2184 case Magic('='):
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2185 // Emit x= as (x|)
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2186 reginsert(BRANCH, ret); // Either x
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2187 regtail(ret, regnode(BRANCH)); // or
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2188 next = regnode(NOTHING); // null.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2189 regtail(ret, next);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2190 regoptail(ret, next);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2191 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2192
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2193 case Magic('{'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2194 if (!read_limits(&minval, &maxval))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2195 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2196 if (flags & SIMPLE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2197 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2198 reginsert(BRACE_SIMPLE, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2199 reginsert_limits(BRACE_LIMITS, minval, maxval, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2200 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2201 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2202 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2203 if (num_complex_braces >= 10)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2204 EMSG2_RET_NULL(_(e_too_many_complex_str_curly),
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2205 reg_magic == MAGIC_ALL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2206 reginsert(BRACE_COMPLEX + num_complex_braces, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2207 regoptail(ret, regnode(BACK));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2208 regoptail(ret, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2209 reginsert_limits(BRACE_LIMITS, minval, maxval, ret);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2210 ++num_complex_braces;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2211 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2212 if (minval > 0 && maxval > 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2213 *flagp = (HASWIDTH | (flags & (HASNL | HASLOOKBH)));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2214 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2215 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2216 if (re_multi_type(peekchr()) != NOT_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2217 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2218 // Can't have a multi follow a multi.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2219 if (peekchr() == Magic('*'))
26436
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
2220 EMSG2_RET_NULL(_(e_nested_str), reg_magic >= MAGIC_ON);
ef0c07cbf53f patch 8.2.3749: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
2221 EMSG3_RET_NULL(_(e_nested_str_chr), reg_magic == MAGIC_ALL,
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2222 no_Magic(peekchr()));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2223 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2224
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2225 return ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2226 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2227
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2228 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2229 * Parse one alternative of an | or & operator.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2230 * Implements the concatenation operator.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2231 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2232 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2233 regconcat(int *flagp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2234 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2235 char_u *first = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2236 char_u *chain = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2237 char_u *latest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2238 int flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2239 int cont = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2240
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2241 *flagp = WORST; // Tentatively.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2242
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2243 while (cont)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2244 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2245 switch (peekchr())
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2246 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2247 case NUL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2248 case Magic('|'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2249 case Magic('&'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2250 case Magic(')'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2251 cont = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2252 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2253 case Magic('Z'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2254 regflags |= RF_ICOMBINE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2255 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2256 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2257 case Magic('c'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2258 regflags |= RF_ICASE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2259 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2260 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2261 case Magic('C'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2262 regflags |= RF_NOICASE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2263 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2264 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2265 case Magic('v'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2266 reg_magic = MAGIC_ALL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2267 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2268 curchr = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2269 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2270 case Magic('m'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2271 reg_magic = MAGIC_ON;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2272 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2273 curchr = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2274 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2275 case Magic('M'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2276 reg_magic = MAGIC_OFF;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2277 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2278 curchr = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2279 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2280 case Magic('V'):
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2281 reg_magic = MAGIC_NONE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2282 skipchr_keepstart();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2283 curchr = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2284 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2285 default:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2286 latest = regpiece(&flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2287 if (latest == NULL || reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2288 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2289 *flagp |= flags & (HASWIDTH | HASNL | HASLOOKBH);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2290 if (chain == NULL) // First piece.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2291 *flagp |= flags & SPSTART;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2292 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2293 regtail(chain, latest);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2294 chain = latest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2295 if (first == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2296 first = latest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2297 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2298 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2299 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2300 if (first == NULL) // Loop ran zero times.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2301 first = regnode(NOTHING);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2302 return first;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2303 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2304
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2305 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2306 * Parse one alternative of an | operator.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2307 * Implements the & operator.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2308 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2309 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2310 regbranch(int *flagp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2311 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2312 char_u *ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2313 char_u *chain = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2314 char_u *latest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2315 int flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2316
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2317 *flagp = WORST | HASNL; // Tentatively.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2318
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2319 ret = regnode(BRANCH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2320 for (;;)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2321 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2322 latest = regconcat(&flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2323 if (latest == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2324 return NULL;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2325 // If one of the branches has width, the whole thing has. If one of
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2326 // the branches anchors at start-of-line, the whole thing does.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2327 // If one of the branches uses look-behind, the whole thing does.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2328 *flagp |= flags & (HASWIDTH | SPSTART | HASLOOKBH);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2329 // If one of the branches doesn't match a line-break, the whole thing
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2330 // doesn't.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2331 *flagp &= ~HASNL | (flags & HASNL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2332 if (chain != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2333 regtail(chain, latest);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2334 if (peekchr() != Magic('&'))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2335 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2336 skipchr();
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2337 regtail(latest, regnode(END)); // operand ends
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2338 if (reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2339 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2340 reginsert(MATCH, latest);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2341 chain = latest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2342 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2343
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2344 return ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2345 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2346
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2347 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2348 * Parse regular expression, i.e. main body or parenthesized thing.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2349 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2350 * Caller must absorb opening parenthesis.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2351 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2352 * Combining parenthesis handling with the base level of regular expression
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2353 * is a trifle forced, but the need to tie the tails of the branches to what
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2354 * follows makes it hard to avoid.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2355 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2356 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2357 reg(
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2358 int paren, // REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2359 int *flagp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2360 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2361 char_u *ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2362 char_u *br;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2363 char_u *ender;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2364 int parno = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2365 int flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2366
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2367 *flagp = HASWIDTH; // Tentatively.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2368
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2369 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2370 if (paren == REG_ZPAREN)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2371 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2372 // Make a ZOPEN node.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2373 if (regnzpar >= NSUBEXP)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2374 EMSG_RET_NULL(_(e_too_many_z));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2375 parno = regnzpar;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2376 regnzpar++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2377 ret = regnode(ZOPEN + parno);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2378 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2379 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2380 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2381 if (paren == REG_PAREN)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2382 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2383 // Make a MOPEN node.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2384 if (regnpar >= NSUBEXP)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2385 EMSG2_RET_NULL(_(e_too_many_str_open), reg_magic == MAGIC_ALL);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2386 parno = regnpar;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2387 ++regnpar;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2388 ret = regnode(MOPEN + parno);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2389 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2390 else if (paren == REG_NPAREN)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2391 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2392 // Make a NOPEN node.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2393 ret = regnode(NOPEN);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2394 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2395 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2396 ret = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2397
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2398 // Pick up the branches, linking them together.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2399 br = regbranch(&flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2400 if (br == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2401 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2402 if (ret != NULL)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2403 regtail(ret, br); // [MZ]OPEN -> first.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2404 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2405 ret = br;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2406 // If one of the branches can be zero-width, the whole thing can.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2407 // If one of the branches has * at start or matches a line-break, the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2408 // whole thing can.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2409 if (!(flags & HASWIDTH))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2410 *flagp &= ~HASWIDTH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2411 *flagp |= flags & (SPSTART | HASNL | HASLOOKBH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2412 while (peekchr() == Magic('|'))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2413 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2414 skipchr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2415 br = regbranch(&flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2416 if (br == NULL || reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2417 return NULL;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2418 regtail(ret, br); // BRANCH -> BRANCH.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2419 if (!(flags & HASWIDTH))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2420 *flagp &= ~HASWIDTH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2421 *flagp |= flags & (SPSTART | HASNL | HASLOOKBH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2422 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2423
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2424 // Make a closing node, and hook it on the end.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2425 ender = regnode(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2426 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2427 paren == REG_ZPAREN ? ZCLOSE + parno :
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2428 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2429 paren == REG_PAREN ? MCLOSE + parno :
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2430 paren == REG_NPAREN ? NCLOSE : END);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2431 regtail(ret, ender);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2432
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2433 // Hook the tails of the branches to the closing node.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2434 for (br = ret; br != NULL; br = regnext(br))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2435 regoptail(br, ender);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2436
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2437 // Check for proper termination.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2438 if (paren != REG_NOPAREN && getchr() != Magic(')'))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2439 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2440 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2441 if (paren == REG_ZPAREN)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2442 EMSG_RET_NULL(_(e_unmatched_z));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2443 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2444 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2445 if (paren == REG_NPAREN)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2446 EMSG2_RET_NULL(_(e_unmatched_str_percent_open), reg_magic == MAGIC_ALL);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2447 else
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2448 EMSG2_RET_NULL(_(e_unmatched_str_open), reg_magic == MAGIC_ALL);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2449 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2450 else if (paren == REG_NOPAREN && peekchr() != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2451 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2452 if (curchr == Magic(')'))
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2453 EMSG2_RET_NULL(_(e_unmatched_str_close), reg_magic == MAGIC_ALL);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2454 else
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26867
diff changeset
2455 EMSG_RET_NULL(_(e_trailing_characters)); // "Can't happen".
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2456 // NOTREACHED
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2457 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2458 // Here we set the flag allowing back references to this set of
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2459 // parentheses.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2460 if (paren == REG_PAREN)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2461 had_endbrace[parno] = TRUE; // have seen the close paren
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2462 return ret;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2463 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2464
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2465 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2466 * bt_regcomp() - compile a regular expression into internal code for the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2467 * traditional back track matcher.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2468 * Returns the program in allocated space. Returns NULL for an error.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2469 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2470 * We can't allocate space until we know how big the compiled form will be,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2471 * but we can't compile it (and thus know how big it is) until we've got a
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2472 * place to put the code. So we cheat: we compile it twice, once with code
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2473 * generation turned off and size counting turned on, and once "for real".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2474 * This also means that we don't allocate space until we are sure that the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2475 * thing really will compile successfully, and we never have to move the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2476 * code and thus invalidate pointers into it. (Note that it has to be in
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2477 * one piece because vim_free() must be able to free it all.)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2478 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2479 * Whether upper/lower case is to be ignored is decided when executing the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2480 * program, it does not matter here.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2481 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2482 * Beware that the optimization-preparation code in here knows about some
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2483 * of the structure of the compiled regexp.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2484 * "re_flags": RE_MAGIC and/or RE_STRING.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2485 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2486 static regprog_T *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2487 bt_regcomp(char_u *expr, int re_flags)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2488 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2489 bt_regprog_T *r;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2490 char_u *scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2491 char_u *longest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2492 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2493 int flags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2494
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2495 if (expr == NULL)
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25147
diff changeset
2496 IEMSG_RET_NULL(_(e_null_argument));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2497
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2498 init_class_tab();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2499
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2500 // First pass: determine size, legality.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2501 regcomp_start(expr, re_flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2502 regcode = JUST_CALC_SIZE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2503 regc(REGMAGIC);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2504 if (reg(REG_NOPAREN, &flags) == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2505 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2506
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2507 // Allocate space.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2508 r = alloc(offsetof(bt_regprog_T, program) + regsize);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2509 if (r == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2510 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2511 r->re_in_use = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2512
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2513 // Second pass: emit code.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2514 regcomp_start(expr, re_flags);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2515 regcode = r->program;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2516 regc(REGMAGIC);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2517 if (reg(REG_NOPAREN, &flags) == NULL || reg_toolong)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2518 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2519 vim_free(r);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2520 if (reg_toolong)
26909
aa65d1808bd0 patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
2521 EMSG_RET_NULL(_(e_pattern_too_long));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2522 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2523 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2524
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2525 // Dig out information for optimizations.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2526 r->regstart = NUL; // Worst-case defaults.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2527 r->reganch = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2528 r->regmust = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2529 r->regmlen = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2530 r->regflags = regflags;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2531 if (flags & HASNL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2532 r->regflags |= RF_HASNL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2533 if (flags & HASLOOKBH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2534 r->regflags |= RF_LOOKBH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2535 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2536 // Remember whether this pattern has any \z specials in it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2537 r->reghasz = re_has_z;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2538 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2539 scan = r->program + 1; // First BRANCH.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2540 if (OP(regnext(scan)) == END) // Only one top-level choice.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2541 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2542 scan = OPERAND(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2543
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2544 // Starting-point info.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2545 if (OP(scan) == BOL || OP(scan) == RE_BOF)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2546 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2547 r->reganch++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2548 scan = regnext(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2549 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2550
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2551 if (OP(scan) == EXACTLY)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2552 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2553 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2554 r->regstart = (*mb_ptr2char)(OPERAND(scan));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2555 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2556 r->regstart = *OPERAND(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2557 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2558 else if ((OP(scan) == BOW
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2559 || OP(scan) == EOW
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2560 || OP(scan) == NOTHING
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2561 || OP(scan) == MOPEN + 0 || OP(scan) == NOPEN
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2562 || OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2563 && OP(regnext(scan)) == EXACTLY)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2564 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2565 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2566 r->regstart = (*mb_ptr2char)(OPERAND(regnext(scan)));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2567 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2568 r->regstart = *OPERAND(regnext(scan));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2569 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2570
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2571 // If there's something expensive in the r.e., find the longest
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2572 // literal string that must appear and make it the regmust. Resolve
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2573 // ties in favor of later strings, since the regstart check works
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2574 // with the beginning of the r.e. and avoiding duplication
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2575 // strengthens checking. Not a strong reason, but sufficient in the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2576 // absence of others.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2577
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2578 // When the r.e. starts with BOW, it is faster to look for a regmust
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2579 // first. Used a lot for "#" and "*" commands. (Added by mool).
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2580 if ((flags & SPSTART || OP(scan) == BOW || OP(scan) == EOW)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2581 && !(flags & HASNL))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2582 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2583 longest = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2584 len = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2585 for (; scan != NULL; scan = regnext(scan))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2586 if (OP(scan) == EXACTLY && STRLEN(OPERAND(scan)) >= (size_t)len)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2587 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2588 longest = OPERAND(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2589 len = (int)STRLEN(OPERAND(scan));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2590 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2591 r->regmust = longest;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2592 r->regmlen = len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2593 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2594 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2595 #ifdef BT_REGEXP_DUMP
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2596 regdump(expr, r);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2597 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2598 r->engine = &bt_regengine;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2599 return (regprog_T *)r;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2600 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2601
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2602 #if defined(FEAT_SYN_HL) || defined(PROTO)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2603 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2604 * Check if during the previous call to vim_regcomp the EOL item "$" has been
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2605 * found. This is messy, but it works fine.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2606 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2607 int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2608 vim_regcomp_had_eol(void)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2609 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2610 return had_eol;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2611 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2612 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2613
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2614 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2615 * Get a number after a backslash that is inside [].
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2616 * When nothing is recognized return a backslash.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2617 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2618 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2619 coll_get_char(void)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2620 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2621 long nr = -1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2622
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2623 switch (*regparse++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2624 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2625 case 'd': nr = getdecchrs(); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2626 case 'o': nr = getoctchrs(); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2627 case 'x': nr = gethexchrs(2); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2628 case 'u': nr = gethexchrs(4); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2629 case 'U': nr = gethexchrs(8); break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2630 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2631 if (nr < 0 || nr > INT_MAX)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2632 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2633 // If getting the number fails be backwards compatible: the character
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2634 // is a backslash.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2635 --regparse;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2636 nr = '\\';
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2637 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2638 return nr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2639 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2640
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2641 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2642 * Free a compiled regexp program, returned by bt_regcomp().
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2643 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2644 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2645 bt_regfree(regprog_T *prog)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2646 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2647 vim_free(prog);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2648 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2649
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2650 #define ADVANCE_REGINPUT() MB_PTR_ADV(rex.input)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2651
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2652 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2653 * The arguments from BRACE_LIMITS are stored here. They are actually local
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2654 * to regmatch(), but they are here to reduce the amount of stack space used
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2655 * (it can be called recursively many times).
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2656 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2657 static long bl_minval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2658 static long bl_maxval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2659
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2660 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2661 * Save the input line and position in a regsave_T.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2662 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2663 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2664 reg_save(regsave_T *save, garray_T *gap)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2665 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2666 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2667 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2668 save->rs_u.pos.col = (colnr_T)(rex.input - rex.line);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2669 save->rs_u.pos.lnum = rex.lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2670 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2671 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2672 save->rs_u.ptr = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2673 save->rs_len = gap->ga_len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2674 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2675
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2676 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2677 * Restore the input line and position from a regsave_T.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2678 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2679 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2680 reg_restore(regsave_T *save, garray_T *gap)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2681 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2682 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2683 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2684 if (rex.lnum != save->rs_u.pos.lnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2685 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2686 // only call reg_getline() when the line number changed to save
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2687 // a bit of time
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2688 rex.lnum = save->rs_u.pos.lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2689 rex.line = reg_getline(rex.lnum);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2690 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2691 rex.input = rex.line + save->rs_u.pos.col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2692 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2693 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2694 rex.input = save->rs_u.ptr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2695 gap->ga_len = save->rs_len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2696 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2697
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2698 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2699 * Return TRUE if current position is equal to saved position.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2700 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2701 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2702 reg_save_equal(regsave_T *save)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2703 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2704 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2705 return rex.lnum == save->rs_u.pos.lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2706 && rex.input == rex.line + save->rs_u.pos.col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2707 return rex.input == save->rs_u.ptr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2708 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2709
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2710 // Save the sub-expressions before attempting a match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2711 #define save_se(savep, posp, pp) \
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2712 REG_MULTI ? save_se_multi((savep), (posp)) : save_se_one((savep), (pp))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2713
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2714 // After a failed match restore the sub-expressions.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2715 #define restore_se(savep, posp, pp) { \
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2716 if (REG_MULTI) \
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2717 *(posp) = (savep)->se_u.pos; \
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2718 else \
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2719 *(pp) = (savep)->se_u.ptr; }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2720
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2721 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2722 * Tentatively set the sub-expression start to the current position (after
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2723 * calling regmatch() they will have changed). Need to save the existing
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2724 * values for when there is no match.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2725 * Use se_save() to use pointer (save_se_multi()) or position (save_se_one()),
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2726 * depending on REG_MULTI.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2727 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2728 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2729 save_se_multi(save_se_T *savep, lpos_T *posp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2730 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2731 savep->se_u.pos = *posp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2732 posp->lnum = rex.lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2733 posp->col = (colnr_T)(rex.input - rex.line);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2734 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2735
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2736 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2737 save_se_one(save_se_T *savep, char_u **pp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2738 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2739 savep->se_u.ptr = *pp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2740 *pp = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2741 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2742
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2743 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2744 * regrepeat - repeatedly match something simple, return how many.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2745 * Advances rex.input (and rex.lnum) to just after the matched chars.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2746 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2747 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2748 regrepeat(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2749 char_u *p,
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2750 long maxcount) // maximum number of matches allowed
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2751 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2752 long count = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2753 char_u *scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2754 char_u *opnd;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2755 int mask;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2756 int testval = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2757
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2758 scan = rex.input; // Make local copy of rex.input for speed.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2759 opnd = OPERAND(p);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2760 switch (OP(p))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2761 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2762 case ANY:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2763 case ANY + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2764 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2765 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2766 // Matching anything means we continue until end-of-line (or
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2767 // end-of-file for ANY + ADD_NL), only limited by maxcount.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2768 while (*scan != NUL && count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2769 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2770 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2771 MB_PTR_ADV(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2772 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2773 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2774 || rex.reg_line_lbr || count == maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2775 break;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2776 ++count; // count the line-break
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2777 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2778 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2779 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2780 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2781 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2782 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2783
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2784 case IDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2785 case IDENT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2786 testval = TRUE;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2787 // FALLTHROUGH
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2788 case SIDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2789 case SIDENT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2790 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2791 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2792 if (vim_isIDc(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2793 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2794 MB_PTR_ADV(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2795 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2796 else if (*scan == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2797 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2798 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2799 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2800 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2801 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2802 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2803 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2804 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2805 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2806 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2807 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2808 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2809 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2810 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2811 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2812 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2813
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2814 case KWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2815 case KWORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2816 testval = TRUE;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2817 // FALLTHROUGH
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2818 case SKWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2819 case SKWORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2820 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2821 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2822 if (vim_iswordp_buf(scan, rex.reg_buf)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2823 && (testval || !VIM_ISDIGIT(*scan)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2824 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2825 MB_PTR_ADV(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2826 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2827 else if (*scan == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2828 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2829 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2830 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2831 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2832 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2833 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2834 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2835 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2836 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2837 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2838 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2839 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2840 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2841 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2842 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2843 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2844
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2845 case FNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2846 case FNAME + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2847 testval = TRUE;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2848 // FALLTHROUGH
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2849 case SFNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2850 case SFNAME + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2851 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2852 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2853 if (vim_isfilec(PTR2CHAR(scan)) && (testval || !VIM_ISDIGIT(*scan)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2854 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2855 MB_PTR_ADV(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2856 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2857 else if (*scan == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2858 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2859 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2860 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2861 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2862 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2863 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2864 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2865 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2866 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2867 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2868 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2869 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2870 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2871 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2872 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2873 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2874
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2875 case PRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2876 case PRINT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2877 testval = TRUE;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
2878 // FALLTHROUGH
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2879 case SPRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2880 case SPRINT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2881 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2882 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2883 if (*scan == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2884 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2885 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2886 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2887 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2888 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2889 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2890 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2891 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2892 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2893 else if (vim_isprintc(PTR2CHAR(scan)) == 1
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2894 && (testval || !VIM_ISDIGIT(*scan)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2895 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2896 MB_PTR_ADV(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2897 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2898 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2899 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2900 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2901 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2902 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2903 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2904 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2905
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2906 case WHITE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2907 case WHITE + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2908 testval = mask = RI_WHITE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2909 do_class:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2910 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2911 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2912 int l;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2913
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2914 if (*scan == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2915 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2916 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2917 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2918 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2919 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2920 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2921 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2922 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2923 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2924 else if (has_mbyte && (l = (*mb_ptr2len)(scan)) > 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2925 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2926 if (testval != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2927 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2928 scan += l;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2929 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2930 else if ((class_tab[*scan] & mask) == testval)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2931 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2932 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2933 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2934 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2935 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2936 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2937 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2938 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2939
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2940 case NWHITE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2941 case NWHITE + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2942 mask = RI_WHITE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2943 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2944 case DIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2945 case DIGIT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2946 testval = mask = RI_DIGIT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2947 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2948 case NDIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2949 case NDIGIT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2950 mask = RI_DIGIT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2951 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2952 case HEX:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2953 case HEX + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2954 testval = mask = RI_HEX;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2955 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2956 case NHEX:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2957 case NHEX + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2958 mask = RI_HEX;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2959 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2960 case OCTAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2961 case OCTAL + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2962 testval = mask = RI_OCTAL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2963 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2964 case NOCTAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2965 case NOCTAL + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2966 mask = RI_OCTAL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2967 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2968 case WORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2969 case WORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2970 testval = mask = RI_WORD;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2971 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2972 case NWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2973 case NWORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2974 mask = RI_WORD;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2975 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2976 case HEAD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2977 case HEAD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2978 testval = mask = RI_HEAD;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2979 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2980 case NHEAD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2981 case NHEAD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2982 mask = RI_HEAD;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2983 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2984 case ALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2985 case ALPHA + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2986 testval = mask = RI_ALPHA;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2987 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2988 case NALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2989 case NALPHA + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2990 mask = RI_ALPHA;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2991 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2992 case LOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2993 case LOWER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2994 testval = mask = RI_LOWER;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2995 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2996 case NLOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2997 case NLOWER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2998 mask = RI_LOWER;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2999 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3000 case UPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3001 case UPPER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3002 testval = mask = RI_UPPER;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3003 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3004 case NUPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3005 case NUPPER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3006 mask = RI_UPPER;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3007 goto do_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3008
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3009 case EXACTLY:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3010 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3011 int cu, cl;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3012
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3013 // This doesn't do a multi-byte character, because a MULTIBYTECODE
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3014 // would have been used for it. It does handle single-byte
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3015 // characters, such as latin1.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3016 if (rex.reg_ic)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3017 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3018 cu = MB_TOUPPER(*opnd);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3019 cl = MB_TOLOWER(*opnd);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3020 while (count < maxcount && (*scan == cu || *scan == cl))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3021 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3022 count++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3023 scan++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3024 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3025 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3026 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3027 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3028 cu = *opnd;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3029 while (count < maxcount && *scan == cu)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3030 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3031 count++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3032 scan++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3033 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3034 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3035 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3036 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3037
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3038 case MULTIBYTECODE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3039 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3040 int i, len, cf = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3041
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3042 // Safety check (just in case 'encoding' was changed since
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3043 // compiling the program).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3044 if ((len = (*mb_ptr2len)(opnd)) > 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3045 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3046 if (rex.reg_ic && enc_utf8)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3047 cf = utf_fold(utf_ptr2char(opnd));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3048 while (count < maxcount && (*mb_ptr2len)(scan) >= len)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3049 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3050 for (i = 0; i < len; ++i)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3051 if (opnd[i] != scan[i])
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3052 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3053 if (i < len && (!rex.reg_ic || !enc_utf8
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3054 || utf_fold(utf_ptr2char(scan)) != cf))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3055 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3056 scan += len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3057 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3058 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3059 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3060 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3061 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3062
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3063 case ANYOF:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3064 case ANYOF + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3065 testval = TRUE;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3066 // FALLTHROUGH
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3067
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3068 case ANYBUT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3069 case ANYBUT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3070 while (count < maxcount)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3071 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3072 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3073
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3074 if (*scan == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3075 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3076 if (!REG_MULTI || !WITH_NL(OP(p)) || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3077 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3078 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3079 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3080 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3081 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3082 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3083 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3084 else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3085 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3086 else if (has_mbyte && (len = (*mb_ptr2len)(scan)) > 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3087 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3088 if ((cstrchr(opnd, (*mb_ptr2char)(scan)) == NULL) == testval)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3089 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3090 scan += len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3091 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3092 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3093 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3094 if ((cstrchr(opnd, *scan) == NULL) == testval)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3095 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3096 ++scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3097 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3098 ++count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3099 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3100 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3101
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3102 case NEWL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3103 while (count < maxcount
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3104 && ((*scan == NUL && rex.lnum <= rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3105 && !rex.reg_line_lbr && REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3106 || (*scan == '\n' && rex.reg_line_lbr)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3107 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3108 count++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3109 if (rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3110 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3111 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3112 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3113 scan = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3114 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3115 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3116 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3117 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3118
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3119 default: // Oh dear. Called inappropriately.
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25147
diff changeset
3120 iemsg(_(e_corrupted_regexp_program));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3121 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3122 printf("Called regrepeat with op code %d\n", OP(p));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3123 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3124 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3125 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3126
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3127 rex.input = scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3128
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3129 return (int)count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3130 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3131
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3132 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3133 * Push an item onto the regstack.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3134 * Returns pointer to new item. Returns NULL when out of memory.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3135 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3136 static regitem_T *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3137 regstack_push(regstate_T state, char_u *scan)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3138 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3139 regitem_T *rp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3140
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3141 if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3142 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26867
diff changeset
3143 emsg(_(e_pattern_uses_more_memory_than_maxmempattern));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3144 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3145 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3146 if (ga_grow(&regstack, sizeof(regitem_T)) == FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3147 return NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3148
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3149 rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3150 rp->rs_state = state;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3151 rp->rs_scan = scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3152
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3153 regstack.ga_len += sizeof(regitem_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3154 return rp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3155 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3156
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3157 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3158 * Pop an item from the regstack.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3159 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3160 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3161 regstack_pop(char_u **scan)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3162 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3163 regitem_T *rp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3164
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3165 rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3166 *scan = rp->rs_scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3167
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3168 regstack.ga_len -= sizeof(regitem_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3169 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3170
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3171 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3172 * Save the current subexpr to "bp", so that they can be restored
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3173 * later by restore_subexpr().
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3174 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3175 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3176 save_subexpr(regbehind_T *bp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3177 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3178 int i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3179
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3180 // When "rex.need_clear_subexpr" is set we don't need to save the values,
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3181 // only remember that this flag needs to be set again when restoring.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3182 bp->save_need_clear_subexpr = rex.need_clear_subexpr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3183 if (!rex.need_clear_subexpr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3184 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3185 for (i = 0; i < NSUBEXP; ++i)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3186 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3187 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3188 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3189 bp->save_start[i].se_u.pos = rex.reg_startpos[i];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3190 bp->save_end[i].se_u.pos = rex.reg_endpos[i];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3191 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3192 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3193 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3194 bp->save_start[i].se_u.ptr = rex.reg_startp[i];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3195 bp->save_end[i].se_u.ptr = rex.reg_endp[i];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3196 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3197 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3198 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3199 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3200
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3201 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3202 * Restore the subexpr from "bp".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3203 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3204 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3205 restore_subexpr(regbehind_T *bp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3206 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3207 int i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3208
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3209 // Only need to restore saved values when they are not to be cleared.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3210 rex.need_clear_subexpr = bp->save_need_clear_subexpr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3211 if (!rex.need_clear_subexpr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3212 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3213 for (i = 0; i < NSUBEXP; ++i)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3214 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3215 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3216 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3217 rex.reg_startpos[i] = bp->save_start[i].se_u.pos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3218 rex.reg_endpos[i] = bp->save_end[i].se_u.pos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3219 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3220 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3221 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3222 rex.reg_startp[i] = bp->save_start[i].se_u.ptr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3223 rex.reg_endp[i] = bp->save_end[i].se_u.ptr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3224 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3225 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3226 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3227 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3228
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3229 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3230 * regmatch - main matching routine
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3231 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3232 * Conceptually the strategy is simple: Check to see whether the current node
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3233 * matches, push an item onto the regstack and loop to see whether the rest
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3234 * matches, and then act accordingly. In practice we make some effort to
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3235 * avoid using the regstack, in particular by going through "ordinary" nodes
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3236 * (that don't need to know whether the rest of the match failed) by a nested
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3237 * loop.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3238 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3239 * Returns TRUE when there is a match. Leaves rex.input and rex.lnum just after
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3240 * the last matched character.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3241 * Returns FALSE when there is no match. Leaves rex.input and rex.lnum in an
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3242 * undefined state!
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3243 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3244 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3245 regmatch(
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3246 char_u *scan, // Current node.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3247 proftime_T *tm UNUSED, // timeout limit or NULL
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3248 int *timed_out UNUSED) // flag set on timeout or NULL
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3249 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3250 char_u *next; // Next node.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3251 int op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3252 int c;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3253 regitem_T *rp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3254 int no;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3255 int status; // one of the RA_ values:
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3256 #ifdef FEAT_RELTIME
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3257 int tm_count = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3258 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3259
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3260 // Make "regstack" and "backpos" empty. They are allocated and freed in
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3261 // bt_regexec_both() to reduce malloc()/free() calls.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3262 regstack.ga_len = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3263 backpos.ga_len = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3264
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3265 // Repeat until "regstack" is empty.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3266 for (;;)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3267 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3268 // Some patterns may take a long time to match, e.g., "\([a-z]\+\)\+Q".
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3269 // Allow interrupting them with CTRL-C.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3270 fast_breakcheck();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3271
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3272 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3273 if (scan != NULL && regnarrate)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3274 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3275 mch_errmsg((char *)regprop(scan));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3276 mch_errmsg("(\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3277 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3278 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3279
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3280 // Repeat for items that can be matched sequentially, without using the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3281 // regstack.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3282 for (;;)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3283 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3284 if (got_int || scan == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3285 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3286 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3287 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3288 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3289 #ifdef FEAT_RELTIME
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3290 // Check for timeout once in a 100 times to avoid overhead.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3291 if (tm != NULL && ++tm_count == 100)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3292 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3293 tm_count = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3294 if (profile_passed_limit(tm))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3295 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3296 if (timed_out != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3297 *timed_out = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3298 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3299 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3300 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3301 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3302 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3303 status = RA_CONT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3304
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3305 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3306 if (regnarrate)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3307 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3308 mch_errmsg((char *)regprop(scan));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3309 mch_errmsg("...\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3310 # ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3311 if (re_extmatch_in != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3312 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3313 int i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3314
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3315 mch_errmsg(_("External submatches:\n"));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3316 for (i = 0; i < NSUBEXP; i++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3317 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3318 mch_errmsg(" \"");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3319 if (re_extmatch_in->matches[i] != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3320 mch_errmsg((char *)re_extmatch_in->matches[i]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3321 mch_errmsg("\"\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3322 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3323 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3324 # endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3325 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3326 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3327 next = regnext(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3328
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3329 op = OP(scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3330 // Check for character class with NL added.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3331 if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3332 && *rex.input == NUL && rex.lnum <= rex.reg_maxline)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3333 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3334 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3335 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3336 else if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\n')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3337 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3338 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3339 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3340 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3341 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3342 if (WITH_NL(op))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3343 op -= ADD_NL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3344 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3345 c = (*mb_ptr2char)(rex.input);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3346 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3347 c = *rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3348 switch (op)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3349 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3350 case BOL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3351 if (rex.input != rex.line)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3352 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3353 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3354
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3355 case EOL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3356 if (c != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3357 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3358 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3359
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3360 case RE_BOF:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3361 // We're not at the beginning of the file when below the first
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3362 // line where we started, not at the start of the line or we
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3363 // didn't start at the first line of the buffer.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3364 if (rex.lnum != 0 || rex.input != rex.line
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3365 || (REG_MULTI && rex.reg_firstlnum > 1))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3366 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3367 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3368
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3369 case RE_EOF:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3370 if (rex.lnum != rex.reg_maxline || c != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3371 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3372 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3373
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3374 case CURSOR:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3375 // Check if the buffer is in a window and compare the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3376 // rex.reg_win->w_cursor position to the match position.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3377 if (rex.reg_win == NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3378 || (rex.lnum + rex.reg_firstlnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3379 != rex.reg_win->w_cursor.lnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3380 || ((colnr_T)(rex.input - rex.line)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3381 != rex.reg_win->w_cursor.col))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3382 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3383 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3384
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3385 case RE_MARK:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3386 // Compare the mark position to the match position.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3387 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3388 int mark = OPERAND(scan)[0];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3389 int cmp = OPERAND(scan)[1];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3390 pos_T *pos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3391
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3392 pos = getmark_buf(rex.reg_buf, mark, FALSE);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3393 if (pos == NULL // mark doesn't exist
24693
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3394 || pos->lnum <= 0) // mark isn't set in reg_buf
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3395 {
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3396 status = RA_NOMATCH;
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3397 }
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3398 else
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3399 {
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3400 colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3401 && pos->col == MAXCOL
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3402 ? (colnr_T)STRLEN(reg_getline(
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3403 pos->lnum - rex.reg_firstlnum))
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3404 : pos->col;
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3405
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3406 if ((pos->lnum == rex.lnum + rex.reg_firstlnum
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3407 ? (pos_col == (colnr_T)(rex.input - rex.line)
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3408 ? (cmp == '<' || cmp == '>')
24693
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3409 : (pos_col < (colnr_T)(rex.input - rex.line)
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3410 ? cmp != '>'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3411 : cmp != '<'))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3412 : (pos->lnum < rex.lnum + rex.reg_firstlnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3413 ? cmp != '>'
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3414 : cmp != '<')))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3415 status = RA_NOMATCH;
24693
97789fcef0cf patch 8.2.2885: searching for %'> does not match linewise end of line
Bram Moolenaar <Bram@vim.org>
parents: 24580
diff changeset
3416 }
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3417 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3418 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3419
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3420 case RE_VISUAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3421 if (!reg_match_visual())
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3422 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3423 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3424
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3425 case RE_LNUM:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3426 if (!REG_MULTI || !re_num_cmp((long_u)(rex.lnum + rex.reg_firstlnum),
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3427 scan))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3428 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3429 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3430
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3431 case RE_COL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3432 if (!re_num_cmp((long_u)(rex.input - rex.line) + 1, scan))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3433 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3434 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3435
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3436 case RE_VCOL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3437 if (!re_num_cmp((long_u)win_linetabsize(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3438 rex.reg_win == NULL ? curwin : rex.reg_win,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3439 rex.line, (colnr_T)(rex.input - rex.line)) + 1, scan))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3440 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3441 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3442
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3443 case BOW: // \<word; rex.input points to w
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3444 if (c == NUL) // Can't match at end of line
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3445 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3446 else if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3447 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3448 int this_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3449
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3450 // Get class of current and previous char (if it exists).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3451 this_class = mb_get_class_buf(rex.input, rex.reg_buf);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3452 if (this_class <= 1)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3453 status = RA_NOMATCH; // not on a word at all
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3454 else if (reg_prev_class() == this_class)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3455 status = RA_NOMATCH; // previous char is in same word
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3456 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3457 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3458 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3459 if (!vim_iswordc_buf(c, rex.reg_buf) || (rex.input > rex.line
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3460 && vim_iswordc_buf(rex.input[-1], rex.reg_buf)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3461 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3462 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3463 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3464
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3465 case EOW: // word\>; rex.input points after d
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3466 if (rex.input == rex.line) // Can't match at start of line
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3467 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3468 else if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3469 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3470 int this_class, prev_class;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3471
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3472 // Get class of current and previous char (if it exists).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3473 this_class = mb_get_class_buf(rex.input, rex.reg_buf);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3474 prev_class = reg_prev_class();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3475 if (this_class == prev_class
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3476 || prev_class == 0 || prev_class == 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3477 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3478 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3479 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3480 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3481 if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3482 || (rex.input[0] != NUL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3483 && vim_iswordc_buf(c, rex.reg_buf)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3484 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3485 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3486 break; // Matched with EOW
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3487
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3488 case ANY:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3489 // ANY does not match new lines.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3490 if (c == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3491 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3492 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3493 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3494 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3495
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3496 case IDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3497 if (!vim_isIDc(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3498 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3499 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3500 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3501 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3502
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3503 case SIDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3504 if (VIM_ISDIGIT(*rex.input) || !vim_isIDc(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3505 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3506 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3507 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3508 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3509
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3510 case KWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3511 if (!vim_iswordp_buf(rex.input, rex.reg_buf))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3512 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3513 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3514 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3515 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3516
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3517 case SKWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3518 if (VIM_ISDIGIT(*rex.input)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3519 || !vim_iswordp_buf(rex.input, rex.reg_buf))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3520 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3521 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3522 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3523 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3524
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3525 case FNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3526 if (!vim_isfilec(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3527 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3528 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3529 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3530 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3531
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3532 case SFNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3533 if (VIM_ISDIGIT(*rex.input) || !vim_isfilec(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3534 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3535 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3536 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3537 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3538
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3539 case PRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3540 if (!vim_isprintc(PTR2CHAR(rex.input)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3541 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3542 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3543 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3544 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3545
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3546 case SPRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3547 if (VIM_ISDIGIT(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3548 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3549 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3550 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3551 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3552
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3553 case WHITE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3554 if (!VIM_ISWHITE(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3555 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3556 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3557 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3558 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3559
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3560 case NWHITE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3561 if (c == NUL || VIM_ISWHITE(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3562 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3563 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3564 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3565 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3566
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3567 case DIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3568 if (!ri_digit(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3569 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3570 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3571 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3572 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3573
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3574 case NDIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3575 if (c == NUL || ri_digit(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3576 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3577 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3578 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3579 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3580
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3581 case HEX:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3582 if (!ri_hex(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3583 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3584 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3585 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3586 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3587
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3588 case NHEX:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3589 if (c == NUL || ri_hex(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3590 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3591 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3592 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3593 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3594
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3595 case OCTAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3596 if (!ri_octal(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3597 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3598 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3599 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3600 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3601
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3602 case NOCTAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3603 if (c == NUL || ri_octal(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3604 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3605 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3606 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3607 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3608
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3609 case WORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3610 if (!ri_word(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3611 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3612 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3613 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3614 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3615
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3616 case NWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3617 if (c == NUL || ri_word(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3618 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3619 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3620 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3621 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3622
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3623 case HEAD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3624 if (!ri_head(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3625 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3626 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3627 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3628 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3629
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3630 case NHEAD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3631 if (c == NUL || ri_head(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3632 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3633 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3634 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3635 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3636
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3637 case ALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3638 if (!ri_alpha(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3639 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3640 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3641 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3642 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3643
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3644 case NALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3645 if (c == NUL || ri_alpha(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3646 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3647 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3648 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3649 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3650
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3651 case LOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3652 if (!ri_lower(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3653 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3654 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3655 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3656 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3657
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3658 case NLOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3659 if (c == NUL || ri_lower(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3660 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3661 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3662 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3663 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3664
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3665 case UPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3666 if (!ri_upper(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3667 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3668 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3669 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3670 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3671
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3672 case NUPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3673 if (c == NUL || ri_upper(c))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3674 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3675 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3676 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3677 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3678
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3679 case EXACTLY:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3680 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3681 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3682 char_u *opnd;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3683
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3684 opnd = OPERAND(scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3685 // Inline the first byte, for speed.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3686 if (*opnd != *rex.input
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3687 && (!rex.reg_ic
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3688 || (!enc_utf8
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3689 && MB_TOLOWER(*opnd) != MB_TOLOWER(*rex.input))))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3690 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3691 else if (*opnd == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3692 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3693 // match empty string always works; happens when "~" is
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3694 // empty.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3695 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3696 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3697 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3698 if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3699 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3700 len = 1; // matched a single byte above
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3701 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3702 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3703 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3704 // Need to match first byte again for multi-byte.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3705 len = (int)STRLEN(opnd);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3706 if (cstrncmp(opnd, rex.input, &len) != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3707 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3708 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3709 // Check for following composing character, unless %C
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3710 // follows (skips over all composing chars).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3711 if (status != RA_NOMATCH
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3712 && enc_utf8
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3713 && UTF_COMPOSINGLIKE(rex.input, rex.input + len)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3714 && !rex.reg_icombine
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3715 && OP(next) != RE_COMPOSING)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3716 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3717 // raaron: This code makes a composing character get
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3718 // ignored, which is the correct behavior (sometimes)
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3719 // for voweled Hebrew texts.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3720 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3721 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3722 if (status != RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3723 rex.input += len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3724 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3725 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3726 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3727
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3728 case ANYOF:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3729 case ANYBUT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3730 if (c == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3731 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3732 else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3733 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3734 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3735 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3736 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3737
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3738 case MULTIBYTECODE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3739 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3740 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3741 int i, len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3742 char_u *opnd;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3743 int opndc = 0, inpc;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3744
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3745 opnd = OPERAND(scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3746 // Safety check (just in case 'encoding' was changed since
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3747 // compiling the program).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3748 if ((len = (*mb_ptr2len)(opnd)) < 2)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3749 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3750 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3751 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3752 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3753 if (enc_utf8)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3754 opndc = utf_ptr2char(opnd);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3755 if (enc_utf8 && utf_iscomposing(opndc))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3756 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3757 // When only a composing char is given match at any
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3758 // position where that composing char appears.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3759 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3760 for (i = 0; rex.input[i] != NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3761 i += utf_ptr2len(rex.input + i))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3762 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3763 inpc = utf_ptr2char(rex.input + i);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3764 if (!utf_iscomposing(inpc))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3765 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3766 if (i > 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3767 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3768 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3769 else if (opndc == inpc)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3770 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3771 // Include all following composing chars.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3772 len = i + utfc_ptr2len(rex.input + i);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3773 status = RA_MATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3774 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3775 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3776 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3777 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3778 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3779 for (i = 0; i < len; ++i)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3780 if (opnd[i] != rex.input[i])
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3781 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3782 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3783 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3784 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3785 rex.input += len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3786 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3787 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3788 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3789 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3790 case RE_COMPOSING:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3791 if (enc_utf8)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3792 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3793 // Skip composing characters.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3794 while (utf_iscomposing(utf_ptr2char(rex.input)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3795 MB_CPTR_ADV(rex.input);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3796 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3797 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3798
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3799 case NOTHING:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3800 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3801
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3802 case BACK:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3803 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3804 int i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3805 backpos_T *bp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3806
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3807 // When we run into BACK we need to check if we don't keep
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3808 // looping without matching any input. The second and later
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3809 // times a BACK is encountered it fails if the input is still
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3810 // at the same position as the previous time.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3811 // The positions are stored in "backpos" and found by the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3812 // current value of "scan", the position in the RE program.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3813 bp = (backpos_T *)backpos.ga_data;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3814 for (i = 0; i < backpos.ga_len; ++i)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3815 if (bp[i].bp_scan == scan)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3816 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3817 if (i == backpos.ga_len)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3818 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3819 // First time at this BACK, make room to store the pos.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3820 if (ga_grow(&backpos, 1) == FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3821 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3822 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3823 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3824 // get "ga_data" again, it may have changed
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3825 bp = (backpos_T *)backpos.ga_data;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3826 bp[i].bp_scan = scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3827 ++backpos.ga_len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3828 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3829 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3830 else if (reg_save_equal(&bp[i].bp_pos))
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3831 // Still at same position as last time, fail.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3832 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3833
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3834 if (status != RA_FAIL && status != RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3835 reg_save(&bp[i].bp_pos, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3836 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3837 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3838
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3839 case MOPEN + 0: // Match start: \zs
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3840 case MOPEN + 1: // \(
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3841 case MOPEN + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3842 case MOPEN + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3843 case MOPEN + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3844 case MOPEN + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3845 case MOPEN + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3846 case MOPEN + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3847 case MOPEN + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3848 case MOPEN + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3849 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3850 no = op - MOPEN;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3851 cleanup_subexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3852 rp = regstack_push(RS_MOPEN, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3853 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3854 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3855 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3856 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3857 rp->rs_no = no;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3858 save_se(&rp->rs_un.sesave, &rex.reg_startpos[no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3859 &rex.reg_startp[no]);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3860 // We simply continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3861 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3862 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3863 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3864
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3865 case NOPEN: // \%(
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3866 case NCLOSE: // \) after \%(
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3867 if (regstack_push(RS_NOPEN, scan) == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3868 status = RA_FAIL;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3869 // We simply continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3870 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3871
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3872 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3873 case ZOPEN + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3874 case ZOPEN + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3875 case ZOPEN + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3876 case ZOPEN + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3877 case ZOPEN + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3878 case ZOPEN + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3879 case ZOPEN + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3880 case ZOPEN + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3881 case ZOPEN + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3882 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3883 no = op - ZOPEN;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3884 cleanup_zsubexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3885 rp = regstack_push(RS_ZOPEN, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3886 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3887 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3888 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3889 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3890 rp->rs_no = no;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3891 save_se(&rp->rs_un.sesave, &reg_startzpos[no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3892 &reg_startzp[no]);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3893 // We simply continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3894 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3895 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3896 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3897 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3898
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3899 case MCLOSE + 0: // Match end: \ze
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3900 case MCLOSE + 1: // \)
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3901 case MCLOSE + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3902 case MCLOSE + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3903 case MCLOSE + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3904 case MCLOSE + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3905 case MCLOSE + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3906 case MCLOSE + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3907 case MCLOSE + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3908 case MCLOSE + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3909 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3910 no = op - MCLOSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3911 cleanup_subexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3912 rp = regstack_push(RS_MCLOSE, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3913 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3914 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3915 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3916 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3917 rp->rs_no = no;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3918 save_se(&rp->rs_un.sesave, &rex.reg_endpos[no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3919 &rex.reg_endp[no]);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3920 // We simply continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3921 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3922 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3923 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3924
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3925 #ifdef FEAT_SYN_HL
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3926 case ZCLOSE + 1: // \) after \z(
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3927 case ZCLOSE + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3928 case ZCLOSE + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3929 case ZCLOSE + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3930 case ZCLOSE + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3931 case ZCLOSE + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3932 case ZCLOSE + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3933 case ZCLOSE + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3934 case ZCLOSE + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3935 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3936 no = op - ZCLOSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3937 cleanup_zsubexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3938 rp = regstack_push(RS_ZCLOSE, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3939 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3940 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3941 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3942 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3943 rp->rs_no = no;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3944 save_se(&rp->rs_un.sesave, &reg_endzpos[no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3945 &reg_endzp[no]);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3946 // We simply continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3947 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3948 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3949 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3950 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3951
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3952 case BACKREF + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3953 case BACKREF + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3954 case BACKREF + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3955 case BACKREF + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3956 case BACKREF + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3957 case BACKREF + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3958 case BACKREF + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3959 case BACKREF + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3960 case BACKREF + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3961 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3962 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3963
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3964 no = op - BACKREF;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3965 cleanup_subexpr();
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3966 if (!REG_MULTI) // Single-line regexp
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3967 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3968 if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3969 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3970 // Backref was not set: Match an empty string.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3971 len = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3972 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3973 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3974 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3975 // Compare current input with back-ref in the same
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3976 // line.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3977 len = (int)(rex.reg_endp[no] - rex.reg_startp[no]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3978 if (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3979 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3980 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3981 }
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3982 else // Multi-line regexp
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3983 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3984 if (rex.reg_startpos[no].lnum < 0
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3985 || rex.reg_endpos[no].lnum < 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3986 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3987 // Backref was not set: Match an empty string.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3988 len = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3989 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3990 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3991 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3992 if (rex.reg_startpos[no].lnum == rex.lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3993 && rex.reg_endpos[no].lnum == rex.lnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3994 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
3995 // Compare back-ref within the current line.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3996 len = rex.reg_endpos[no].col
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3997 - rex.reg_startpos[no].col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3998 if (cstrncmp(rex.line + rex.reg_startpos[no].col,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3999 rex.input, &len) != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4000 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4001 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4002 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4003 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4004 // Messy situation: Need to compare between two
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4005 // lines.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4006 int r = match_with_backref(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4007 rex.reg_startpos[no].lnum,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4008 rex.reg_startpos[no].col,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4009 rex.reg_endpos[no].lnum,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4010 rex.reg_endpos[no].col,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4011 &len);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4012
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4013 if (r != RA_MATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4014 status = r;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4015 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4016 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4017 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4018
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4019 // Matched the backref, skip over it.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4020 rex.input += len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4021 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4022 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4023
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4024 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4025 case ZREF + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4026 case ZREF + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4027 case ZREF + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4028 case ZREF + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4029 case ZREF + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4030 case ZREF + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4031 case ZREF + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4032 case ZREF + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4033 case ZREF + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4034 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4035 int len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4036
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4037 cleanup_zsubexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4038 no = op - ZREF;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4039 if (re_extmatch_in != NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4040 && re_extmatch_in->matches[no] != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4041 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4042 len = (int)STRLEN(re_extmatch_in->matches[no]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4043 if (cstrncmp(re_extmatch_in->matches[no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4044 rex.input, &len) != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4045 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4046 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4047 rex.input += len;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4048 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4049 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4050 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4051 // Backref was not set: Match an empty string.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4052 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4053 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4054 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4055 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4056
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4057 case BRANCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4058 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4059 if (OP(next) != BRANCH) // No choice.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4060 next = OPERAND(scan); // Avoid recursion.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4061 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4062 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4063 rp = regstack_push(RS_BRANCH, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4064 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4065 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4066 else
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4067 status = RA_BREAK; // rest is below
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4068 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4069 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4070 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4071
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4072 case BRACE_LIMITS:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4073 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4074 if (OP(next) == BRACE_SIMPLE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4075 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4076 bl_minval = OPERAND_MIN(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4077 bl_maxval = OPERAND_MAX(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4078 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4079 else if (OP(next) >= BRACE_COMPLEX
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4080 && OP(next) < BRACE_COMPLEX + 10)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4081 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4082 no = OP(next) - BRACE_COMPLEX;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4083 brace_min[no] = OPERAND_MIN(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4084 brace_max[no] = OPERAND_MAX(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4085 brace_count[no] = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4086 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4087 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4088 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4089 internal_error("BRACE_LIMITS");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4090 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4091 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4092 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4093 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4094
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4095 case BRACE_COMPLEX + 0:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4096 case BRACE_COMPLEX + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4097 case BRACE_COMPLEX + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4098 case BRACE_COMPLEX + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4099 case BRACE_COMPLEX + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4100 case BRACE_COMPLEX + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4101 case BRACE_COMPLEX + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4102 case BRACE_COMPLEX + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4103 case BRACE_COMPLEX + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4104 case BRACE_COMPLEX + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4105 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4106 no = op - BRACE_COMPLEX;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4107 ++brace_count[no];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4108
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4109 // If not matched enough times yet, try one more
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4110 if (brace_count[no] <= (brace_min[no] <= brace_max[no]
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4111 ? brace_min[no] : brace_max[no]))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4112 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4113 rp = regstack_push(RS_BRCPLX_MORE, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4114 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4115 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4116 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4117 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4118 rp->rs_no = no;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4119 reg_save(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4120 next = OPERAND(scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4121 // We continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4122 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4123 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4124 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4125
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4126 // If matched enough times, may try matching some more
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4127 if (brace_min[no] <= brace_max[no])
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4128 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4129 // Range is the normal way around, use longest match
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4130 if (brace_count[no] <= brace_max[no])
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4131 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4132 rp = regstack_push(RS_BRCPLX_LONG, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4133 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4134 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4135 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4136 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4137 rp->rs_no = no;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4138 reg_save(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4139 next = OPERAND(scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4140 // We continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4141 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4142 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4143 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4144 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4145 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4146 // Range is backwards, use shortest match first
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4147 if (brace_count[no] <= brace_min[no])
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4148 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4149 rp = regstack_push(RS_BRCPLX_SHORT, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4150 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4151 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4152 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4153 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4154 reg_save(&rp->rs_un.regsave, &backpos);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4155 // We continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4156 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4157 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4158 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4159 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4160 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4161
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4162 case BRACE_SIMPLE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4163 case STAR:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4164 case PLUS:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4165 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4166 regstar_T rst;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4167
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4168 // Lookahead to avoid useless match attempts when we know
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4169 // what character comes next.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4170 if (OP(next) == EXACTLY)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4171 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4172 rst.nextb = *OPERAND(next);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4173 if (rex.reg_ic)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4174 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4175 if (MB_ISUPPER(rst.nextb))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4176 rst.nextb_ic = MB_TOLOWER(rst.nextb);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4177 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4178 rst.nextb_ic = MB_TOUPPER(rst.nextb);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4179 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4180 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4181 rst.nextb_ic = rst.nextb;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4182 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4183 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4184 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4185 rst.nextb = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4186 rst.nextb_ic = NUL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4187 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4188 if (op != BRACE_SIMPLE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4189 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4190 rst.minval = (op == STAR) ? 0 : 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4191 rst.maxval = MAX_LIMIT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4192 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4193 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4194 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4195 rst.minval = bl_minval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4196 rst.maxval = bl_maxval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4197 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4198
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4199 // When maxval > minval, try matching as much as possible, up
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4200 // to maxval. When maxval < minval, try matching at least the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4201 // minimal number (since the range is backwards, that's also
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4202 // maxval!).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4203 rst.count = regrepeat(OPERAND(scan), rst.maxval);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4204 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4205 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4206 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4207 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4208 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4209 if (rst.minval <= rst.maxval
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4210 ? rst.count >= rst.minval : rst.count >= rst.maxval)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4211 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4212 // It could match. Prepare for trying to match what
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4213 // follows. The code is below. Parameters are stored in
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4214 // a regstar_T on the regstack.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4215 if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4216 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26867
diff changeset
4217 emsg(_(e_pattern_uses_more_memory_than_maxmempattern));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4218 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4219 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4220 else if (ga_grow(&regstack, sizeof(regstar_T)) == FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4221 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4222 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4223 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4224 regstack.ga_len += sizeof(regstar_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4225 rp = regstack_push(rst.minval <= rst.maxval
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4226 ? RS_STAR_LONG : RS_STAR_SHORT, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4227 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4228 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4229 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4230 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4231 *(((regstar_T *)rp) - 1) = rst;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4232 status = RA_BREAK; // skip the restore bits
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4233 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4234 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4235 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4236 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4237 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4238
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4239 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4240 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4241
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4242 case NOMATCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4243 case MATCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4244 case SUBPAT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4245 rp = regstack_push(RS_NOMATCH, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4246 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4247 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4248 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4249 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4250 rp->rs_no = op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4251 reg_save(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4252 next = OPERAND(scan);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4253 // We continue and handle the result when done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4254 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4255 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4256
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4257 case BEHIND:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4258 case NOBEHIND:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4259 // Need a bit of room to store extra positions.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4260 if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4261 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26867
diff changeset
4262 emsg(_(e_pattern_uses_more_memory_than_maxmempattern));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4263 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4264 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4265 else if (ga_grow(&regstack, sizeof(regbehind_T)) == FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4266 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4267 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4268 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4269 regstack.ga_len += sizeof(regbehind_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4270 rp = regstack_push(RS_BEHIND1, scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4271 if (rp == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4272 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4273 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4274 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4275 // Need to save the subexpr to be able to restore them
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4276 // when there is a match but we don't use it.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4277 save_subexpr(((regbehind_T *)rp) - 1);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4278
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4279 rp->rs_no = op;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4280 reg_save(&rp->rs_un.regsave, &backpos);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4281 // First try if what follows matches. If it does then we
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4282 // check the behind match by looping.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4283 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4284 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4285 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4286
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4287 case BHPOS:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4288 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4289 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4290 if (behind_pos.rs_u.pos.col != (colnr_T)(rex.input - rex.line)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4291 || behind_pos.rs_u.pos.lnum != rex.lnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4292 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4293 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4294 else if (behind_pos.rs_u.ptr != rex.input)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4295 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4296 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4297
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4298 case NEWL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4299 if ((c != NUL || !REG_MULTI || rex.lnum > rex.reg_maxline
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4300 || rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4301 && (c != '\n' || !rex.reg_line_lbr))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4302 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4303 else if (rex.reg_line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4304 ADVANCE_REGINPUT();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4305 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4306 reg_nextline();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4307 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4308
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4309 case END:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4310 status = RA_MATCH; // Success!
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4311 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4312
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4313 default:
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25147
diff changeset
4314 iemsg(_(e_corrupted_regexp_program));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4315 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4316 printf("Illegal op code %d\n", op);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4317 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4318 status = RA_FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4319 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4320 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4321 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4322
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4323 // If we can't continue sequentially, break the inner loop.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4324 if (status != RA_CONT)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4325 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4326
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4327 // Continue in inner loop, advance to next item.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4328 scan = next;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4329
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4330 } // end of inner loop
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4331
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4332 // If there is something on the regstack execute the code for the state.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4333 // If the state is popped then loop and use the older state.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4334 while (regstack.ga_len > 0 && status != RA_FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4335 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4336 rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4337 switch (rp->rs_state)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4338 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4339 case RS_NOPEN:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4340 // Result is passed on as-is, simply pop the state.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4341 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4342 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4343
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4344 case RS_MOPEN:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4345 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4346 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4347 restore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4348 &rex.reg_startp[rp->rs_no]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4349 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4350 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4351
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4352 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4353 case RS_ZOPEN:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4354 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4355 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4356 restore_se(&rp->rs_un.sesave, &reg_startzpos[rp->rs_no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4357 &reg_startzp[rp->rs_no]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4358 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4359 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4360 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4361
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4362 case RS_MCLOSE:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4363 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4364 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4365 restore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4366 &rex.reg_endp[rp->rs_no]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4367 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4368 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4369
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4370 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4371 case RS_ZCLOSE:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4372 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4373 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4374 restore_se(&rp->rs_un.sesave, &reg_endzpos[rp->rs_no],
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4375 &reg_endzp[rp->rs_no]);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4376 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4377 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4378 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4379
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4380 case RS_BRANCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4381 if (status == RA_MATCH)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4382 // this branch matched, use it
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4383 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4384 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4385 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4386 if (status != RA_BREAK)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4387 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4388 // After a non-matching branch: try next one.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4389 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4390 scan = rp->rs_scan;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4391 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4392 if (scan == NULL || OP(scan) != BRANCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4393 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4394 // no more branches, didn't find a match
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4395 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4396 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4397 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4398 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4399 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4400 // Prepare to try a branch.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4401 rp->rs_scan = regnext(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4402 reg_save(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4403 scan = OPERAND(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4404 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4405 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4406 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4407
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4408 case RS_BRCPLX_MORE:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4409 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4410 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4411 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4412 reg_restore(&rp->rs_un.regsave, &backpos);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4413 --brace_count[rp->rs_no]; // decrement match count
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4414 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4415 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4416 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4417
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4418 case RS_BRCPLX_LONG:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4419 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4420 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4421 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4422 // There was no match, but we did find enough matches.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4423 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4424 --brace_count[rp->rs_no];
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4425 // continue with the items after "\{}"
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4426 status = RA_CONT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4427 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4428 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4429 if (status == RA_CONT)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4430 scan = regnext(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4431 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4432
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4433 case RS_BRCPLX_SHORT:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4434 // Pop the state. Restore pointers when there is no match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4435 if (status == RA_NOMATCH)
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4436 // There was no match, try to match one more item.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4437 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4438 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4439 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4440 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4441 scan = OPERAND(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4442 status = RA_CONT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4443 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4444 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4445
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4446 case RS_NOMATCH:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4447 // Pop the state. If the operand matches for NOMATCH or
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4448 // doesn't match for MATCH/SUBPAT, we fail. Otherwise backup,
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4449 // except for SUBPAT, and continue with the next item.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4450 if (status == (rp->rs_no == NOMATCH ? RA_MATCH : RA_NOMATCH))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4451 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4452 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4453 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4454 status = RA_CONT;
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4455 if (rp->rs_no != SUBPAT) // zero-width
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4456 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4457 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4458 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4459 if (status == RA_CONT)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4460 scan = regnext(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4461 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4462
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4463 case RS_BEHIND1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4464 if (status == RA_NOMATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4465 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4466 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4467 regstack.ga_len -= sizeof(regbehind_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4468 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4469 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4470 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4471 // The stuff after BEHIND/NOBEHIND matches. Now try if
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4472 // the behind part does (not) match before the current
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4473 // position in the input. This must be done at every
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4474 // position in the input and checking if the match ends at
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4475 // the current position.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4476
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4477 // save the position after the found match for next
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4478 reg_save(&(((regbehind_T *)rp) - 1)->save_after, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4479
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4480 // Start looking for a match with operand at the current
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4481 // position. Go back one character until we find the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4482 // result, hitting the start of the line or the previous
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4483 // line (for multi-line matching).
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4484 // Set behind_pos to where the match should end, BHPOS
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4485 // will match it. Save the current value.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4486 (((regbehind_T *)rp) - 1)->save_behind = behind_pos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4487 behind_pos = rp->rs_un.regsave;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4488
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4489 rp->rs_state = RS_BEHIND2;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4490
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4491 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4492 scan = OPERAND(rp->rs_scan) + 4;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4493 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4494 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4495
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4496 case RS_BEHIND2:
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4497 // Looping for BEHIND / NOBEHIND match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4498 if (status == RA_MATCH && reg_save_equal(&behind_pos))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4499 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4500 // found a match that ends where "next" started
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4501 behind_pos = (((regbehind_T *)rp) - 1)->save_behind;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4502 if (rp->rs_no == BEHIND)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4503 reg_restore(&(((regbehind_T *)rp) - 1)->save_after,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4504 &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4505 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4506 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4507 // But we didn't want a match. Need to restore the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4508 // subexpr, because what follows matched, so they have
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4509 // been set.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4510 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4511 restore_subexpr(((regbehind_T *)rp) - 1);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4512 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4513 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4514 regstack.ga_len -= sizeof(regbehind_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4515 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4516 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4517 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4518 long limit;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4519
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4520 // No match or a match that doesn't end where we want it: Go
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4521 // back one character. May go to previous line once.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4522 no = OK;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4523 limit = OPERAND_MIN(rp->rs_scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4524 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4525 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4526 if (limit > 0
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4527 && ((rp->rs_un.regsave.rs_u.pos.lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4528 < behind_pos.rs_u.pos.lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4529 ? (colnr_T)STRLEN(rex.line)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4530 : behind_pos.rs_u.pos.col)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4531 - rp->rs_un.regsave.rs_u.pos.col >= limit))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4532 no = FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4533 else if (rp->rs_un.regsave.rs_u.pos.col == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4534 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4535 if (rp->rs_un.regsave.rs_u.pos.lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4536 < behind_pos.rs_u.pos.lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4537 || reg_getline(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4538 --rp->rs_un.regsave.rs_u.pos.lnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4539 == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4540 no = FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4541 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4542 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4543 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4544 rp->rs_un.regsave.rs_u.pos.col =
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4545 (colnr_T)STRLEN(rex.line);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4546 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4547 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4548 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4549 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4550 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4551 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4552 char_u *line =
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4553 reg_getline(rp->rs_un.regsave.rs_u.pos.lnum);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4554
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4555 rp->rs_un.regsave.rs_u.pos.col -=
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4556 (*mb_head_off)(line, line
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4557 + rp->rs_un.regsave.rs_u.pos.col - 1) + 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4558 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4559 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4560 --rp->rs_un.regsave.rs_u.pos.col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4561 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4562 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4563 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4564 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4565 if (rp->rs_un.regsave.rs_u.ptr == rex.line)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4566 no = FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4567 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4568 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4569 MB_PTR_BACK(rex.line, rp->rs_un.regsave.rs_u.ptr);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4570 if (limit > 0 && (long)(behind_pos.rs_u.ptr
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4571 - rp->rs_un.regsave.rs_u.ptr) > limit)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4572 no = FAIL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4573 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4574 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4575 if (no == OK)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4576 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4577 // Advanced, prepare for finding match again.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4578 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4579 scan = OPERAND(rp->rs_scan) + 4;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4580 if (status == RA_MATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4581 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4582 // We did match, so subexpr may have been changed,
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4583 // need to restore them for the next try.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4584 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4585 restore_subexpr(((regbehind_T *)rp) - 1);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4586 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4587 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4588 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4589 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4590 // Can't advance. For NOBEHIND that's a match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4591 behind_pos = (((regbehind_T *)rp) - 1)->save_behind;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4592 if (rp->rs_no == NOBEHIND)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4593 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4594 reg_restore(&(((regbehind_T *)rp) - 1)->save_after,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4595 &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4596 status = RA_MATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4597 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4598 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4599 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4600 // We do want a proper match. Need to restore the
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4601 // subexpr if we had a match, because they may have
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4602 // been set.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4603 if (status == RA_MATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4604 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4605 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4606 restore_subexpr(((regbehind_T *)rp) - 1);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4607 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4608 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4609 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4610 regstack.ga_len -= sizeof(regbehind_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4611 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4612 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4613 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4614
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4615 case RS_STAR_LONG:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4616 case RS_STAR_SHORT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4617 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4618 regstar_T *rst = ((regstar_T *)rp) - 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4619
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4620 if (status == RA_MATCH)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4621 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4622 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4623 regstack.ga_len -= sizeof(regstar_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4624 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4625 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4626
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4627 // Tried once already, restore input pointers.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4628 if (status != RA_BREAK)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4629 reg_restore(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4630
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4631 // Repeat until we found a position where it could match.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4632 for (;;)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4633 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4634 if (status != RA_BREAK)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4635 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4636 // Tried first position already, advance.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4637 if (rp->rs_state == RS_STAR_LONG)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4638 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4639 // Trying for longest match, but couldn't or
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4640 // didn't match -- back up one char.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4641 if (--rst->count < rst->minval)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4642 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4643 if (rex.input == rex.line)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4644 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4645 // backup to last char of previous line
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4646 --rex.lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4647 rex.line = reg_getline(rex.lnum);
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4648 // Just in case regrepeat() didn't count
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4649 // right.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4650 if (rex.line == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4651 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4652 rex.input = rex.line + STRLEN(rex.line);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4653 fast_breakcheck();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4654 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4655 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4656 MB_PTR_BACK(rex.line, rex.input);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4657 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4658 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4659 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4660 // Range is backwards, use shortest match first.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4661 // Careful: maxval and minval are exchanged!
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4662 // Couldn't or didn't match: try advancing one
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4663 // char.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4664 if (rst->count == rst->minval
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4665 || regrepeat(OPERAND(rp->rs_scan), 1L) == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4666 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4667 ++rst->count;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4668 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4669 if (got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4670 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4671 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4672 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4673 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4674
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4675 // If it could match, try it.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4676 if (rst->nextb == NUL || *rex.input == rst->nextb
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4677 || *rex.input == rst->nextb_ic)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4678 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4679 reg_save(&rp->rs_un.regsave, &backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4680 scan = regnext(rp->rs_scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4681 status = RA_CONT;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4682 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4683 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4684 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4685 if (status != RA_CONT)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4686 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4687 // Failed.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4688 regstack_pop(&scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4689 regstack.ga_len -= sizeof(regstar_T);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4690 status = RA_NOMATCH;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4691 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4692 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4693 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4694 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4695
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4696 // If we want to continue the inner loop or didn't pop a state
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4697 // continue matching loop
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4698 if (status == RA_CONT || rp == (regitem_T *)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4699 ((char *)regstack.ga_data + regstack.ga_len) - 1)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4700 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4701 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4702
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4703 // May need to continue with the inner loop, starting at "scan".
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4704 if (status == RA_CONT)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4705 continue;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4706
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4707 // If the regstack is empty or something failed we are done.
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4708 if (regstack.ga_len == 0 || status == RA_FAIL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4709 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4710 if (scan == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4711 {
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4712 // We get here only if there's trouble -- normally "case END" is
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4713 // the terminating point.
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25147
diff changeset
4714 iemsg(_(e_corrupted_regexp_program));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4715 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4716 printf("Premature EOL\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4717 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4718 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4719 return (status == RA_MATCH);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4720 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4721
18029
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4722 } // End of loop until the regstack is empty.
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4723
72524e906658 patch 8.1.2010: new file uses old style comments
Bram Moolenaar <Bram@vim.org>
parents: 18019
diff changeset
4724 // NOTREACHED
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4725 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4726
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4727 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4728 * regtry - try match of "prog" with at rex.line["col"].
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4729 * Returns 0 for failure, number of lines contained in the match otherwise.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4730 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4731 static long
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4732 regtry(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4733 bt_regprog_T *prog,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4734 colnr_T col,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4735 proftime_T *tm, // timeout limit or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4736 int *timed_out) // flag set on timeout or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4737 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4738 rex.input = rex.line + col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4739 rex.need_clear_subexpr = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4740 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4741 // Clear the external match subpointers if necessary.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4742 rex.need_clear_zsubexpr = (prog->reghasz == REX_SET);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4743 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4744
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4745 if (regmatch(prog->program + 1, tm, timed_out) == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4746 return 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4747
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4748 cleanup_subexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4749 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4750 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4751 if (rex.reg_startpos[0].lnum < 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4752 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4753 rex.reg_startpos[0].lnum = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4754 rex.reg_startpos[0].col = col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4755 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4756 if (rex.reg_endpos[0].lnum < 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4757 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4758 rex.reg_endpos[0].lnum = rex.lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4759 rex.reg_endpos[0].col = (int)(rex.input - rex.line);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4760 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4761 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4762 // Use line number of "\ze".
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4763 rex.lnum = rex.reg_endpos[0].lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4764 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4765 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4766 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4767 if (rex.reg_startp[0] == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4768 rex.reg_startp[0] = rex.line + col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4769 if (rex.reg_endp[0] == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4770 rex.reg_endp[0] = rex.input;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4771 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4772 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4773 // Package any found \z(...\) matches for export. Default is none.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4774 unref_extmatch(re_extmatch_out);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4775 re_extmatch_out = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4776
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4777 if (prog->reghasz == REX_SET)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4778 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4779 int i;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4780
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4781 cleanup_zsubexpr();
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4782 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: 18029
diff changeset
4783 if (re_extmatch_out == NULL)
c62d63d2b9f0 patch 8.2.0033: crash when make_extmatch() runs out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18029
diff changeset
4784 return 0;
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4785 for (i = 0; i < NSUBEXP; i++)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4786 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4787 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4788 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4789 // Only accept single line matches.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4790 if (reg_startzpos[i].lnum >= 0
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4791 && reg_endzpos[i].lnum == reg_startzpos[i].lnum
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4792 && reg_endzpos[i].col >= reg_startzpos[i].col)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4793 re_extmatch_out->matches[i] =
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4794 vim_strnsave(reg_getline(reg_startzpos[i].lnum)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4795 + reg_startzpos[i].col,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4796 reg_endzpos[i].col - reg_startzpos[i].col);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4797 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4798 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4799 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4800 if (reg_startzp[i] != NULL && reg_endzp[i] != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4801 re_extmatch_out->matches[i] =
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4802 vim_strnsave(reg_startzp[i],
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
4803 reg_endzp[i] - reg_startzp[i]);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4804 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4805 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4806 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4807 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4808 return 1 + rex.lnum;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4809 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4810
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4811 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4812 * Match a regexp against a string ("line" points to the string) or multiple
24580
87ff80c08e4b patch 8.2.2829: some comments are not correct or clear
Bram Moolenaar <Bram@vim.org>
parents: 24351
diff changeset
4813 * lines (if "line" is NULL, use reg_getline()).
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4814 * Returns 0 for failure, number of lines contained in the match otherwise.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4815 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4816 static long
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4817 bt_regexec_both(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4818 char_u *line,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4819 colnr_T col, // column to start looking for match
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4820 proftime_T *tm, // timeout limit or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4821 int *timed_out) // flag set on timeout or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4822 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4823 bt_regprog_T *prog;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4824 char_u *s;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4825 long retval = 0L;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4826
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4827 // Create "regstack" and "backpos" if they are not allocated yet.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4828 // We allocate *_INITIAL amount of bytes first and then set the grow size
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4829 // to much bigger value to avoid many malloc calls in case of deep regular
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4830 // expressions.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4831 if (regstack.ga_data == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4832 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4833 // Use an item size of 1 byte, since we push different things
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4834 // onto the regstack.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4835 ga_init2(&regstack, 1, REGSTACK_INITIAL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4836 (void)ga_grow(&regstack, REGSTACK_INITIAL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4837 regstack.ga_growsize = REGSTACK_INITIAL * 8;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4838 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4839
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4840 if (backpos.ga_data == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4841 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4842 ga_init2(&backpos, sizeof(backpos_T), BACKPOS_INITIAL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4843 (void)ga_grow(&backpos, BACKPOS_INITIAL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4844 backpos.ga_growsize = BACKPOS_INITIAL * 8;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4845 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4846
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4847 if (REG_MULTI)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4848 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4849 prog = (bt_regprog_T *)rex.reg_mmatch->regprog;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4850 line = reg_getline((linenr_T)0);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4851 rex.reg_startpos = rex.reg_mmatch->startpos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4852 rex.reg_endpos = rex.reg_mmatch->endpos;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4853 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4854 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4855 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4856 prog = (bt_regprog_T *)rex.reg_match->regprog;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4857 rex.reg_startp = rex.reg_match->startp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4858 rex.reg_endp = rex.reg_match->endp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4859 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4860
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4861 // Be paranoid...
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4862 if (prog == NULL || line == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4863 {
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25147
diff changeset
4864 iemsg(_(e_null_argument));
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4865 goto theend;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4866 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4867
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4868 // Check validity of program.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4869 if (prog_magic_wrong())
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4870 goto theend;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4871
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4872 // If the start column is past the maximum column: no need to try.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4873 if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4874 goto theend;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4875
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4876 // If pattern contains "\c" or "\C": overrule value of rex.reg_ic
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4877 if (prog->regflags & RF_ICASE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4878 rex.reg_ic = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4879 else if (prog->regflags & RF_NOICASE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4880 rex.reg_ic = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4881
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4882 // If pattern contains "\Z" overrule value of rex.reg_icombine
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4883 if (prog->regflags & RF_ICOMBINE)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4884 rex.reg_icombine = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4885
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4886 // If there is a "must appear" string, look for it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4887 if (prog->regmust != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4888 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4889 int c;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4890
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4891 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4892 c = (*mb_ptr2char)(prog->regmust);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4893 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4894 c = *prog->regmust;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4895 s = line + col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4896
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4897 // This is used very often, esp. for ":global". Use three versions of
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4898 // the loop to avoid overhead of conditions.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4899 if (!rex.reg_ic && !has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4900 while ((s = vim_strbyte(s, c)) != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4901 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4902 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4903 break; // Found it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4904 ++s;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4905 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4906 else if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4907 while ((s = vim_strchr(s, c)) != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4908 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4909 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4910 break; // Found it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4911 MB_PTR_ADV(s);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4912 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4913 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4914 while ((s = cstrchr(s, c)) != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4915 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4916 if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4917 break; // Found it.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4918 MB_PTR_ADV(s);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4919 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4920 if (s == NULL) // Not present.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4921 goto theend;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4922 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4923
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4924 rex.line = line;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4925 rex.lnum = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4926 reg_toolong = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4927
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4928 // Simplest case: Anchored match need be tried only once.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4929 if (prog->reganch)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4930 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4931 int c;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4932
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4933 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4934 c = (*mb_ptr2char)(rex.line + col);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4935 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4936 c = rex.line[col];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4937 if (prog->regstart == NUL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4938 || prog->regstart == c
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4939 || (rex.reg_ic
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4940 && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4941 || (c < 255 && prog->regstart < 255 &&
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4942 MB_TOLOWER(prog->regstart) == MB_TOLOWER(c)))))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4943 retval = regtry(prog, col, tm, timed_out);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4944 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4945 retval = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4946 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4947 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4948 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4949 #ifdef FEAT_RELTIME
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4950 int tm_count = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4951 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4952 // Messy cases: unanchored match.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4953 while (!got_int)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4954 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4955 if (prog->regstart != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4956 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4957 // Skip until the char we know it must start with.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4958 // Used often, do some work to avoid call overhead.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4959 if (!rex.reg_ic && !has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4960 s = vim_strbyte(rex.line + col, prog->regstart);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4961 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4962 s = cstrchr(rex.line + col, prog->regstart);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4963 if (s == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4964 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4965 retval = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4966 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4967 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4968 col = (int)(s - rex.line);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4969 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4970
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4971 // Check for maximum column to try.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4972 if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4973 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4974 retval = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4975 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4976 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4977
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4978 retval = regtry(prog, col, tm, timed_out);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4979 if (retval > 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4980 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4981
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4982 // if not currently on the first line, get it again
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4983 if (rex.lnum != 0)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4984 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4985 rex.lnum = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4986 rex.line = reg_getline((linenr_T)0);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4987 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4988 if (rex.line[col] == NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4989 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4990 if (has_mbyte)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4991 col += (*mb_ptr2len)(rex.line + col);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4992 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4993 ++col;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4994 #ifdef FEAT_RELTIME
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4995 // Check for timeout once in a twenty times to avoid overhead.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4996 if (tm != NULL && ++tm_count == 20)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4997 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4998 tm_count = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4999 if (profile_passed_limit(tm))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5000 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5001 if (timed_out != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5002 *timed_out = TRUE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5003 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5004 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5005 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5006 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5007 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5008 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5009
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5010 theend:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5011 // Free "reg_tofree" when it's a bit big.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5012 // Free regstack and backpos if they are bigger than their initial size.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5013 if (reg_tofreelen > 400)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5014 VIM_CLEAR(reg_tofree);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5015 if (regstack.ga_maxlen > REGSTACK_INITIAL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5016 ga_clear(&regstack);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5017 if (backpos.ga_maxlen > BACKPOS_INITIAL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5018 ga_clear(&backpos);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5019
23270
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5020 if (retval > 0)
23150
90b16a0022e5 patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22167
diff changeset
5021 {
23270
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5022 // Make sure the end is never before the start. Can happen when \zs
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5023 // and \ze are used.
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5024 if (REG_MULTI)
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5025 {
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5026 lpos_T *start = &rex.reg_mmatch->startpos[0];
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5027 lpos_T *end = &rex.reg_mmatch->endpos[0];
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5028
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5029 if (end->lnum < start->lnum
23150
90b16a0022e5 patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22167
diff changeset
5030 || (end->lnum == start->lnum && end->col < start->col))
23270
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5031 rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0];
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5032 }
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5033 else
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5034 {
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5035 if (rex.reg_match->endp[0] < rex.reg_match->startp[0])
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5036 rex.reg_match->endp[0] = rex.reg_match->startp[0];
22d0c25869d8 patch 8.2.2181: valgrind warnings for using uninitialized value
Bram Moolenaar <Bram@vim.org>
parents: 23150
diff changeset
5037 }
23150
90b16a0022e5 patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22167
diff changeset
5038 }
90b16a0022e5 patch 8.2.2121: internal error when using ze before zs in a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22167
diff changeset
5039
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5040 return retval;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5041 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5042
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5043 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5044 * Match a regexp against a string.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5045 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5046 * Uses curbuf for line count and 'iskeyword'.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5047 * if "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5048 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5049 * Returns 0 for failure, number of lines contained in the match otherwise.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5050 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5051 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5052 bt_regexec_nl(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5053 regmatch_T *rmp,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5054 char_u *line, // string to match against
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5055 colnr_T col, // column to start looking for match
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5056 int line_lbr)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5057 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5058 rex.reg_match = rmp;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5059 rex.reg_mmatch = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5060 rex.reg_maxline = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5061 rex.reg_line_lbr = line_lbr;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5062 rex.reg_buf = curbuf;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5063 rex.reg_win = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5064 rex.reg_ic = rmp->rm_ic;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5065 rex.reg_icombine = FALSE;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5066 rex.reg_maxcol = 0;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5067
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5068 return bt_regexec_both(line, col, NULL, NULL);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5069 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5070
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5071 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5072 * Match a regexp against multiple lines.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5073 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5074 * Uses curbuf for line count and 'iskeyword'.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5075 *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5076 * Return zero if there is no match. Return number of lines contained in the
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5077 * match otherwise.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5078 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5079 static long
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5080 bt_regexec_multi(
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5081 regmmatch_T *rmp,
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5082 win_T *win, // window in which to search or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5083 buf_T *buf, // buffer in which to search
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5084 linenr_T lnum, // nr of line to start looking for match
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5085 colnr_T col, // column to start looking for match
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5086 proftime_T *tm, // timeout limit or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5087 int *timed_out) // flag set on timeout or NULL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5088 {
19405
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 18945
diff changeset
5089 init_regexec_multi(rmp, win, buf, lnum);
18019
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5090 return bt_regexec_both(NULL, col, tm, timed_out);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5091 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5092
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5093 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5094 * Compare a number with the operand of RE_LNUM, RE_COL or RE_VCOL.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5095 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5096 static int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5097 re_num_cmp(long_u val, char_u *scan)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5098 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5099 long_u n = OPERAND_MIN(scan);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5100
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5101 if (OPERAND_CMP(scan) == '>')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5102 return val > n;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5103 if (OPERAND_CMP(scan) == '<')
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5104 return val < n;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5105 return val == n;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5106 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5107
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5108 #ifdef BT_REGEXP_DUMP
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5109
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5110 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5111 * regdump - dump a regexp onto stdout in vaguely comprehensible form
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5112 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5113 static void
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5114 regdump(char_u *pattern, bt_regprog_T *r)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5115 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5116 char_u *s;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5117 int op = EXACTLY; // Arbitrary non-END op.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5118 char_u *next;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5119 char_u *end = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5120 FILE *f;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5121
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5122 #ifdef BT_REGEXP_LOG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5123 f = fopen("bt_regexp_log.log", "a");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5124 #else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5125 f = stdout;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5126 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5127 if (f == NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5128 return;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5129 fprintf(f, "-------------------------------------\n\r\nregcomp(%s):\r\n", pattern);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5130
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5131 s = r->program + 1;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5132 // Loop until we find the END that isn't before a referred next (an END
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5133 // can also appear in a NOMATCH operand).
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5134 while (op != END || s <= end)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5135 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5136 op = OP(s);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5137 fprintf(f, "%2d%s", (int)(s - r->program), regprop(s)); // Where, what.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5138 next = regnext(s);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5139 if (next == NULL) // Next ptr.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5140 fprintf(f, "(0)");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5141 else
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5142 fprintf(f, "(%d)", (int)((s - r->program) + (next - s)));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5143 if (end < next)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5144 end = next;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5145 if (op == BRACE_LIMITS)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5146 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5147 // Two ints
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5148 fprintf(f, " minval %ld, maxval %ld", OPERAND_MIN(s), OPERAND_MAX(s));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5149 s += 8;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5150 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5151 else if (op == BEHIND || op == NOBEHIND)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5152 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5153 // one int
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5154 fprintf(f, " count %ld", OPERAND_MIN(s));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5155 s += 4;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5156 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5157 else if (op == RE_LNUM || op == RE_COL || op == RE_VCOL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5158 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5159 // one int plus comparator
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5160 fprintf(f, " count %ld", OPERAND_MIN(s));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5161 s += 5;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5162 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5163 s += 3;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5164 if (op == ANYOF || op == ANYOF + ADD_NL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5165 || op == ANYBUT || op == ANYBUT + ADD_NL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5166 || op == EXACTLY)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5167 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5168 // Literal string, where present.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5169 fprintf(f, "\nxxxxxxxxx\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5170 while (*s != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5171 fprintf(f, "%c", *s++);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5172 fprintf(f, "\nxxxxxxxxx\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5173 s++;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5174 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5175 fprintf(f, "\r\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5176 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5177
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5178 // Header fields of interest.
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5179 if (r->regstart != NUL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5180 fprintf(f, "start `%s' 0x%x; ", r->regstart < 256
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5181 ? (char *)transchar(r->regstart)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5182 : "multibyte", r->regstart);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5183 if (r->reganch)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5184 fprintf(f, "anchored; ");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5185 if (r->regmust != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5186 fprintf(f, "must have \"%s\"", r->regmust);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5187 fprintf(f, "\r\n");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5188
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5189 #ifdef BT_REGEXP_LOG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5190 fclose(f);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5191 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5192 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5193 #endif // BT_REGEXP_DUMP
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5194
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5195 #ifdef DEBUG
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5196 /*
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5197 * regprop - printable representation of opcode
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5198 */
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5199 static char_u *
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5200 regprop(char_u *op)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5201 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5202 char *p;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5203 static char buf[50];
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5204
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5205 STRCPY(buf, ":");
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5206
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5207 switch ((int) OP(op))
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5208 {
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5209 case BOL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5210 p = "BOL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5211 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5212 case EOL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5213 p = "EOL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5214 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5215 case RE_BOF:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5216 p = "BOF";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5217 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5218 case RE_EOF:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5219 p = "EOF";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5220 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5221 case CURSOR:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5222 p = "CURSOR";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5223 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5224 case RE_VISUAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5225 p = "RE_VISUAL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5226 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5227 case RE_LNUM:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5228 p = "RE_LNUM";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5229 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5230 case RE_MARK:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5231 p = "RE_MARK";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5232 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5233 case RE_COL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5234 p = "RE_COL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5235 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5236 case RE_VCOL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5237 p = "RE_VCOL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5238 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5239 case BOW:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5240 p = "BOW";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5241 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5242 case EOW:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5243 p = "EOW";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5244 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5245 case ANY:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5246 p = "ANY";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5247 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5248 case ANY + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5249 p = "ANY+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5250 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5251 case ANYOF:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5252 p = "ANYOF";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5253 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5254 case ANYOF + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5255 p = "ANYOF+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5256 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5257 case ANYBUT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5258 p = "ANYBUT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5259 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5260 case ANYBUT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5261 p = "ANYBUT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5262 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5263 case IDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5264 p = "IDENT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5265 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5266 case IDENT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5267 p = "IDENT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5268 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5269 case SIDENT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5270 p = "SIDENT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5271 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5272 case SIDENT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5273 p = "SIDENT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5274 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5275 case KWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5276 p = "KWORD";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5277 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5278 case KWORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5279 p = "KWORD+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5280 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5281 case SKWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5282 p = "SKWORD";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5283 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5284 case SKWORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5285 p = "SKWORD+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5286 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5287 case FNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5288 p = "FNAME";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5289 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5290 case FNAME + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5291 p = "FNAME+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5292 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5293 case SFNAME:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5294 p = "SFNAME";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5295 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5296 case SFNAME + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5297 p = "SFNAME+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5298 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5299 case PRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5300 p = "PRINT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5301 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5302 case PRINT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5303 p = "PRINT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5304 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5305 case SPRINT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5306 p = "SPRINT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5307 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5308 case SPRINT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5309 p = "SPRINT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5310 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5311 case WHITE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5312 p = "WHITE";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5313 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5314 case WHITE + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5315 p = "WHITE+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5316 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5317 case NWHITE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5318 p = "NWHITE";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5319 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5320 case NWHITE + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5321 p = "NWHITE+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5322 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5323 case DIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5324 p = "DIGIT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5325 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5326 case DIGIT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5327 p = "DIGIT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5328 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5329 case NDIGIT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5330 p = "NDIGIT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5331 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5332 case NDIGIT + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5333 p = "NDIGIT+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5334 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5335 case HEX:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5336 p = "HEX";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5337 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5338 case HEX + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5339 p = "HEX+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5340 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5341 case NHEX:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5342 p = "NHEX";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5343 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5344 case NHEX + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5345 p = "NHEX+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5346 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5347 case OCTAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5348 p = "OCTAL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5349 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5350 case OCTAL + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5351 p = "OCTAL+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5352 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5353 case NOCTAL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5354 p = "NOCTAL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5355 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5356 case NOCTAL + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5357 p = "NOCTAL+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5358 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5359 case WORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5360 p = "WORD";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5361 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5362 case WORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5363 p = "WORD+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5364 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5365 case NWORD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5366 p = "NWORD";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5367 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5368 case NWORD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5369 p = "NWORD+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5370 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5371 case HEAD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5372 p = "HEAD";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5373 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5374 case HEAD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5375 p = "HEAD+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5376 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5377 case NHEAD:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5378 p = "NHEAD";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5379 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5380 case NHEAD + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5381 p = "NHEAD+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5382 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5383 case ALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5384 p = "ALPHA";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5385 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5386 case ALPHA + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5387 p = "ALPHA+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5388 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5389 case NALPHA:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5390 p = "NALPHA";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5391 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5392 case NALPHA + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5393 p = "NALPHA+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5394 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5395 case LOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5396 p = "LOWER";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5397 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5398 case LOWER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5399 p = "LOWER+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5400 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5401 case NLOWER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5402 p = "NLOWER";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5403 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5404 case NLOWER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5405 p = "NLOWER+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5406 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5407 case UPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5408 p = "UPPER";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5409 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5410 case UPPER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5411 p = "UPPER+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5412 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5413 case NUPPER:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5414 p = "NUPPER";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5415 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5416 case NUPPER + ADD_NL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5417 p = "NUPPER+NL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5418 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5419 case BRANCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5420 p = "BRANCH";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5421 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5422 case EXACTLY:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5423 p = "EXACTLY";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5424 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5425 case NOTHING:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5426 p = "NOTHING";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5427 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5428 case BACK:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5429 p = "BACK";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5430 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5431 case END:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5432 p = "END";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5433 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5434 case MOPEN + 0:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5435 p = "MATCH START";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5436 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5437 case MOPEN + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5438 case MOPEN + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5439 case MOPEN + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5440 case MOPEN + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5441 case MOPEN + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5442 case MOPEN + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5443 case MOPEN + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5444 case MOPEN + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5445 case MOPEN + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5446 sprintf(buf + STRLEN(buf), "MOPEN%d", OP(op) - MOPEN);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5447 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5448 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5449 case MCLOSE + 0:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5450 p = "MATCH END";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5451 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5452 case MCLOSE + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5453 case MCLOSE + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5454 case MCLOSE + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5455 case MCLOSE + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5456 case MCLOSE + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5457 case MCLOSE + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5458 case MCLOSE + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5459 case MCLOSE + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5460 case MCLOSE + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5461 sprintf(buf + STRLEN(buf), "MCLOSE%d", OP(op) - MCLOSE);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5462 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5463 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5464 case BACKREF + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5465 case BACKREF + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5466 case BACKREF + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5467 case BACKREF + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5468 case BACKREF + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5469 case BACKREF + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5470 case BACKREF + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5471 case BACKREF + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5472 case BACKREF + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5473 sprintf(buf + STRLEN(buf), "BACKREF%d", OP(op) - BACKREF);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5474 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5475 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5476 case NOPEN:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5477 p = "NOPEN";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5478 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5479 case NCLOSE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5480 p = "NCLOSE";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5481 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5482 #ifdef FEAT_SYN_HL
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5483 case ZOPEN + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5484 case ZOPEN + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5485 case ZOPEN + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5486 case ZOPEN + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5487 case ZOPEN + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5488 case ZOPEN + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5489 case ZOPEN + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5490 case ZOPEN + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5491 case ZOPEN + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5492 sprintf(buf + STRLEN(buf), "ZOPEN%d", OP(op) - ZOPEN);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5493 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5494 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5495 case ZCLOSE + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5496 case ZCLOSE + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5497 case ZCLOSE + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5498 case ZCLOSE + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5499 case ZCLOSE + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5500 case ZCLOSE + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5501 case ZCLOSE + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5502 case ZCLOSE + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5503 case ZCLOSE + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5504 sprintf(buf + STRLEN(buf), "ZCLOSE%d", OP(op) - ZCLOSE);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5505 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5506 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5507 case ZREF + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5508 case ZREF + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5509 case ZREF + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5510 case ZREF + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5511 case ZREF + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5512 case ZREF + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5513 case ZREF + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5514 case ZREF + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5515 case ZREF + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5516 sprintf(buf + STRLEN(buf), "ZREF%d", OP(op) - ZREF);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5517 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5518 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5519 #endif
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5520 case STAR:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5521 p = "STAR";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5522 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5523 case PLUS:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5524 p = "PLUS";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5525 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5526 case NOMATCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5527 p = "NOMATCH";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5528 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5529 case MATCH:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5530 p = "MATCH";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5531 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5532 case BEHIND:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5533 p = "BEHIND";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5534 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5535 case NOBEHIND:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5536 p = "NOBEHIND";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5537 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5538 case SUBPAT:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5539 p = "SUBPAT";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5540 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5541 case BRACE_LIMITS:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5542 p = "BRACE_LIMITS";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5543 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5544 case BRACE_SIMPLE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5545 p = "BRACE_SIMPLE";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5546 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5547 case BRACE_COMPLEX + 0:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5548 case BRACE_COMPLEX + 1:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5549 case BRACE_COMPLEX + 2:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5550 case BRACE_COMPLEX + 3:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5551 case BRACE_COMPLEX + 4:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5552 case BRACE_COMPLEX + 5:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5553 case BRACE_COMPLEX + 6:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5554 case BRACE_COMPLEX + 7:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5555 case BRACE_COMPLEX + 8:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5556 case BRACE_COMPLEX + 9:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5557 sprintf(buf + STRLEN(buf), "BRACE_COMPLEX%d", OP(op) - BRACE_COMPLEX);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5558 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5559 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5560 case MULTIBYTECODE:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5561 p = "MULTIBYTECODE";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5562 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5563 case NEWL:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5564 p = "NEWL";
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5565 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5566 default:
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5567 sprintf(buf + STRLEN(buf), "corrupt %d", OP(op));
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5568 p = NULL;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5569 break;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5570 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5571 if (p != NULL)
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5572 STRCAT(buf, p);
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5573 return (char_u *)buf;
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5574 }
68fd5296bf73 patch 8.1.2005: the regexp.c file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5575 #endif // DEBUG