Deleted Added
sdiff udiff text old ( 49094 ) new ( 62232 )
full compact
1/*-
2 * Copyright (c) 1992, 1993, 1994 Henry Spencer.
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Henry Spencer.
8 *

--- 21 unchanged lines hidden (view full) ---

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)regcomp.c 8.5 (Berkeley) 3/20/94
38 */
39
40#if defined(LIBC_SCCS) && !defined(lint)
41static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
42#endif /* LIBC_SCCS and not lint */
43
44#include <sys/types.h>
45#include <stdio.h>

--- 71 unchanged lines hidden (view full) ---

117static void categorize __P((struct parse *p, struct re_guts *g));
118static sopno dupl __P((struct parse *p, sopno start, sopno finish));
119static void doemit __P((struct parse *p, sop op, size_t opnd));
120static void doinsert __P((struct parse *p, sop op, size_t opnd, sopno pos));
121static void dofwd __P((struct parse *p, sopno pos, sop value));
122static void enlarge __P((struct parse *p, sopno size));
123static void stripsnug __P((struct parse *p, struct re_guts *g));
124static void findmust __P((struct parse *p, struct re_guts *g));
125static sopno pluscount __P((struct parse *p, struct re_guts *g));
126
127#ifdef __cplusplus
128}
129#endif
130/* ========= end header generated by ./mkh ========= */
131
132static char nuls[10]; /* place to point scanner in event of error */

--- 29 unchanged lines hidden (view full) ---

162#define DROP(n) (p->slen -= (n))
163
164#ifndef NDEBUG
165static int never = 0; /* for use in asserts; shuts lint up */
166#else
167#define never 0 /* some <assert.h>s have bugs too */
168#endif
169
170/*
171 - regcomp - interface for parser and compilation
172 = extern int regcomp(regex_t *, const char *, int);
173 = #define REG_BASIC 0000
174 = #define REG_EXTENDED 0001
175 = #define REG_ICASE 0002
176 = #define REG_NOSUB 0004
177 = #define REG_NEWLINE 0010

--- 79 unchanged lines hidden (view full) ---

257 p_bre(p, OUT, OUT);
258 EMIT(OEND, 0);
259 g->laststate = THERE();
260
261 /* tidy up loose ends and fill things in */
262 categorize(p, g);
263 stripsnug(p, g);
264 findmust(p, g);
265 g->nplus = pluscount(p, g);
266 g->magic = MAGIC2;
267 preg->re_nsub = g->nsub;
268 preg->re_g = g;
269 preg->re_magic = MAGIC1;
270#ifndef REDEBUG
271 /* not debugging, so can't rely on the assert() in regexec() */
272 if (g->iflags&BAD)

--- 1463 unchanged lines hidden (view full) ---

1736 assert(cp < g->must + g->mlen);
1737 *cp++ = (char)OPND(s);
1738 }
1739 assert(cp == g->must + g->mlen);
1740 *cp++ = '\0'; /* just on general principles */
1741}
1742
1743/*
1744 - pluscount - count + nesting
1745 == static sopno pluscount(register struct parse *p, register struct re_guts *g);
1746 */
1747static sopno /* nesting depth */
1748pluscount(p, g)
1749struct parse *p;
1750register struct re_guts *g;
1751{

--- 26 unchanged lines hidden ---