• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..07-May-2022-

MakefileH A D27-Nov-19942 KiB7439

READMEH A D19-Nov-19944.2 KiB8571

README.STDCH A D18-Feb-2000816 2818

args.hH A D25-Nov-1994469 2923

regerror.cH A D22-Nov-1994300 2319

regexp.3H A D19-Nov-19946.5 KiB180175

regexp.cH A D18-Feb-200028.7 KiB1,305921

regexp.hH A D24-Nov-1994945 3222

regmagic.hH A D19-Nov-1994153 61

regsub.cH A D18-Feb-20002 KiB8959

testsH A D19-Nov-19942.7 KiB128127

timer.cH A D18-Feb-20004 KiB187138

try.cH A D18-Feb-20005.7 KiB253198

try.errsH A D19-Nov-1994171 64

README

1This is a nearly-public-domain reimplementation of the V8 regexp(3) package.
2It gives C programs the ability to use egrep-style regular expressions, and
3does it in a much cleaner fashion than the analogous routines in SysV.
4
5	Copyright (c) 1986 by University of Toronto.
6	Written by Henry Spencer.  Not derived from licensed software.
7
8	Permission is granted to anyone to use this software for any
9	purpose on any computer system, and to redistribute it freely,
10	subject to the following restrictions:
11
12	1. The author is not responsible for the consequences of use of
13		this software, no matter how awful, even if they arise
14		from defects in it.
15
16	2. The origin of this software must not be misrepresented, either
17		by explicit claim or by omission.
18
19	3. Altered versions must be plainly marked as such, and must not
20		be misrepresented as being the original software.
21
22Barring a couple of small items in the BUGS list, this implementation is
23believed 100% compatible with V8.  It should even be binary-compatible,
24sort of, since the only fields in a "struct regexp" that other people have
25any business touching are declared in exactly the same way at the same
26location in the struct (the beginning).
27
28This implementation is *NOT* AT&T/Bell code, and is not derived from licensed
29software.  Even though U of T is a V8 licensee.  This software is based on
30a V8 manual page sent to me by Dennis Ritchie (the manual page enclosed
31here is a complete rewrite and hence is not covered by AT&T copyright).
32The software was nearly complete at the time of arrival of our V8 tape.
33I haven't even looked at V8 yet, although a friend elsewhere at U of T has
34been kind enough to run a few test programs using the V8 regexp(3) to resolve
35a few fine points.  I admit to some familiarity with regular-expression
36implementations of the past, but the only one that this code traces any
37ancestry to is the one published in Kernighan & Plauger (from which this
38one draws ideas but not code).
39
40Simplistically:  put this stuff into a source directory, copy regexp.h into
41/usr/include, inspect Makefile for compilation options that need changing
42to suit your local environment, and then do "make r".  This compiles the
43regexp(3) functions, compiles a test program, and runs a large set of
44regression tests.  If there are no complaints, then put regexp.o, regsub.o,
45and regerror.o into your C library, and regexp.3 into your manual-pages
46directory.
47
48Note that if you don't put regexp.h into /usr/include *before* compiling,
49you'll have to add "-I." to CFLAGS before compiling.
50
51The files are:
52
53Makefile	instructions to make everything
54regexp.3	manual page
55regexp.h	header file, for /usr/include
56regexp.c	source for regcomp() and regexec()
57regsub.c	source for regsub()
58regerror.c	source for default regerror()
59regmagic.h	internal header file
60try.c		source for test program
61timer.c		source for timing program
62tests		test list for try and timer
63
64This implementation uses nondeterministic automata rather than the
65deterministic ones found in some other implementations, which makes it
66simpler, smaller, and faster at compiling regular expressions, but slower
67at executing them.  In theory, anyway.  This implementation does employ
68some special-case optimizations to make the simpler cases (which do make
69up the bulk of regular expressions actually used) run quickly.  In general,
70if you want blazing speed you're in the wrong place.  Replacing the insides
71of egrep with this stuff is probably a mistake; if you want your own egrep
72you're going to have to do a lot more work.  But if you want to use regular
73expressions a little bit in something else, you're in luck.  Note that many
74existing text editors use nondeterministic regular-expression implementations,
75so you're in good company.
76
77This stuff should be pretty portable, given appropriate option settings.
78If your chars have less than 8 bits, you're going to have to change the
79internal representation of the automaton, although knowledge of the details
80of this is fairly localized.  There are no "reserved" char values except for
81NUL, and no special significance is attached to the top bit of chars.
82The string(3) functions are used a fair bit, on the grounds that they are
83probably faster than coding the operations in line.  Some attempts at code
84tuning have been made, but this is invariably a bit machine-specific.
85

README.STDC

1[18-Feb-2000]
2
3The code in this directory has been converted to ANSI/ISO Standard C
4and Standard C++ by
5
6	* addition of const modifiers to char* pointers in several
7          places;
8
9	* addition of required #include <...> statements;
10
11	* addition of Standard C function prototypes;
12
13	* changing arguments 0 and 1 to exit() to EXIT_FAILURE and
14          EXIT_SUCCESS respectively;
15
16	* conversion of function definitions to Standard C form;
17
18	* replacing calls to exit() by return statements in main()
19          programs;
20
21	* replacing the C++ reserved word `try' by `try_re' and
22          `try_group'.
23
24The code should now compile successfully with any Standard C or C++
25compiler, PROVIDED that you remember to use the -I. switch to force
26the compiler to use the *.h files in this directory, instead of system
27ones!
28