xref: /freebsd/lib/libcompat/4.3/re_comp.3 (revision 257e70f1d5ee61037c8c59b116538d3b6b1427a2)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd June 4, 1993
29.Dt RE_COMP 3
30.Os
31.Sh NAME
32.Nm re_comp ,
33.Nm re_exec
34.Nd regular expression handler
35.Sh LIBRARY
36.Lb libcompat
37.Sh SYNOPSIS
38.In unistd.h
39.Ft char *
40.Fn re_comp "const char *s"
41.Ft int
42.Fn re_exec "const char *s"
43.Sh DESCRIPTION
44.Bf -symbolic
45This interface is made obsolete by
46.Xr regex 3 .
47.Ef
48.Pp
49The
50.Fn re_comp
51function
52compiles a string into an internal form suitable for pattern matching.
53The
54.Fn re_exec
55function
56checks the argument string against the last string passed to
57.Fn re_comp .
58.Pp
59The
60.Fn re_comp
61function
62returns 0 if the string
63.Fa s
64was compiled successfully; otherwise a string containing an
65error message is returned.
66If
67.Fn re_comp
68is passed 0 or a null string, it returns without changing the currently
69compiled regular expression.
70.Pp
71The
72.Fn re_exec
73function
74returns 1 if the string
75.Fa s
76matches the last compiled regular expression, 0 if the string
77.Fa s
78failed to match the last compiled regular expression, and \-1 if the compiled
79regular expression was invalid (indicating an internal error).
80.Pp
81The strings passed to both
82.Fn re_comp
83and
84.Fn re_exec
85may have trailing or embedded newline characters;
86they are terminated by
87.Dv NUL Ns s .
88The regular expressions recognized are described in the manual entry for
89.Xr ed 1 ,
90given the above difference.
91.Sh DIAGNOSTICS
92The
93.Fn re_exec
94function
95returns \-1 for an internal error.
96.Pp
97The
98.Fn re_comp
99function
100returns
101.Dq no previous regular expression
102or one of the strings generated by
103.Xr regerror 3 .
104.Sh SEE ALSO
105.Xr ed 1 ,
106.Xr egrep 1 ,
107.Xr ex 1 ,
108.Xr fgrep 1 ,
109.Xr grep 1 ,
110.Xr regex 3
111.Sh HISTORY
112The
113.Fn re_comp
114and
115.Fn re_exec
116functions appeared in
117.Bx 4.0 .
118