Blame src/lib/libast/man/regex.3

Packit Service a8c26c
.fp 5 B
Packit Service a8c26c
.de Af
Packit Service a8c26c
.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
Packit Service a8c26c
.if !?\\$4?? .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
Packit Service a8c26c
..
Packit Service a8c26c
.de aF
Packit Service a8c26c
.ie ?\\$3?? .ft \\$1
Packit Service a8c26c
.el \{\
Packit Service a8c26c
.ds ;G \&
Packit Service a8c26c
.nr ;G \\n(.f
Packit Service a8c26c
.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
Packit Service a8c26c
\\*(;G
Packit Service a8c26c
.ft \\n(;G \}
Packit Service a8c26c
..
Packit Service a8c26c
.de L
Packit Service a8c26c
.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
Packit Service a8c26c
..
Packit Service a8c26c
.de LR
Packit Service a8c26c
.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
Packit Service a8c26c
..
Packit Service a8c26c
.de RL
Packit Service a8c26c
.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
Packit Service a8c26c
..
Packit Service a8c26c
.de EX		\" start example
Packit Service a8c26c
.ta 1i 2i 3i 4i 5i 6i
Packit Service a8c26c
.PP
Packit Service a8c26c
.RS 
Packit Service a8c26c
.PD 0
Packit Service a8c26c
.ft 5
Packit Service a8c26c
.nf
Packit Service a8c26c
..
Packit Service a8c26c
.de EE		\" end example
Packit Service a8c26c
.fi
Packit Service a8c26c
.ft
Packit Service a8c26c
.PD
Packit Service a8c26c
.RE
Packit Service a8c26c
.PP
Packit Service a8c26c
..
Packit Service a8c26c
.TH REGEX 3
Packit Service a8c26c
.SH NAME
Packit Service a8c26c
regex \- regular expression interface
Packit Service a8c26c
.SH SYNOPSIS
Packit Service a8c26c
.EX
Packit Service a8c26c
#include <regex.h>
Packit Service a8c26c
Packit Service a8c26c
int        regcomp(regex_t* \fIre\fP, const char* \fIregex\fP, int \fIcflags\fP);
Packit Service a8c26c
int        regexec(const regex_t* \fIre\fP, const char* \fIstring\fP, size_t \fInmatch\fP, regmatch_t \fIpmatch\fP[], int \fIeflags\fP);
Packit Service a8c26c
size_t     regerror(int \fIcode\fP, const regex_t* \fIre\fP, char* \fIerrbuf\fP, size_t \fIerrbuf_size\fP);
Packit Service a8c26c
void       regfree(regex_t* \fIre\fP);
Packit Service a8c26c
Packit Service a8c26c
regclass_t regclass(const char* \fIstr\fP, char** \fIend\fP);
Packit Service a8c26c
int        regaddclass(const char* \fIname\fP, regclass_t \fIclassf\fP);
Packit Service a8c26c
int        regcollate(const char* \fIstr\fP, char** \fIend\fP, char* \fIbuf\fP, int \fIsize\fP);
Packit Service a8c26c
Packit Service a8c26c
int        regcomb(regex_t* \fIre_1\fP, regex_t* \fIre_2\fP);
Packit Service a8c26c
size_t     regdecomp(regex_t* \fIre\fP, regflags_t \fIflags\fP, char* \fIbuf\fP, size_t \fIsize\fP);
Packit Service a8c26c
int        regdup(regex_t* \fIre_old\fP, regex_t* \fIre_new\fP);
Packit Service a8c26c
regstat_t* regstat(const regex_t* \fIre\fP);
Packit Service a8c26c
Packit Service a8c26c
regex_t*   regcache(const char* \fIpattern\fP, regflags_t \fIflags\fP, int* \fIpcode\fP);
Packit Service a8c26c
Packit Service a8c26c
int        regncomp(regex_t* \fIre\fP, const char* \fIpattern\fP, size_t \fIsize\fP, regflags_t \fIflags\fP);
Packit Service a8c26c
int        regnexec(const regex_t* \fIre\fP, const char* \fIsubject\fP, size_t \fIsize\fP, size_t \fInmatch\fP, regmatch_t* \fImatch\fP, regflags_t \fIflags\fP);
Packit Service a8c26c
int        regrecord(const regex_t* \fIre\fP);
Packit Service a8c26c
int        regrexec(const regex_t* \fIre\fP, const char* \fIbuf\fP, size_t \fIsize\fP, size_t \fInmatch\fP, regmatch_t* \fImatch\fP, regflags_t \fIflags\fP, int \fIsep\fP, void* \fIhandle\fP, regrecord_t \fIrecordf\fP);
Packit Service a8c26c
void       regfatal(regex_t* \fIre\fP, int \fIlevel\fP, int \fIcode\fP);
Packit Service a8c26c
void       regfatalpat(regex_t* \fIre\fP, int \fIlevel\fP, int \fIcode\fP, const char* \fIpattern\fP);
Packit Service a8c26c
Packit Service a8c26c
int        regsubcomp(regex_t* \fIre\fP, const char* \fIstr\fP, const regflags_t* \fImap\fP, int \fIminmatch\fP, regflags_t \fIflags\fP);
Packit Service a8c26c
int        regsubexec(const regex_t* \fIre\fP, const char* \fIsubject\fP, size_t \fInmatch\fP, regmatch_t* match);
Packit Service a8c26c
int        regsubflags(regex_t* \fIre\fP, const char* \fIstr\fP, char** \fIend\fP, int \fIdelim\fP, const regflags_t* \fImap\fP, int* \fIpm\fP, regflags_t* \fIpf\fP);
Packit Service a8c26c
void       regsubfree(regex_t* \fIre\fP);
Packit Service a8c26c
.EE
Packit Service a8c26c
Packit Service a8c26c
.SH DESCRIPTION
Packit Service a8c26c
.LR regcomp() ,
Packit Service a8c26c
.LR regexec() ,
Packit Service a8c26c
.LR regerror() ,
Packit Service a8c26c
and
Packit Service a8c26c
.L regfree()
Packit Service a8c26c
are the POSIX regular expression functions.
Packit Service a8c26c
The remaining functions are
Packit Service a8c26c
.B ast
Packit Service a8c26c
extensions.
Packit Service a8c26c
.B ast
Packit Service a8c26c
also provides
Packit Service a8c26c
.I flags
Packit Service a8c26c
extensions to the
Packit Service a8c26c
.LR regcomp() ,
Packit Service a8c26c
.LR regexec()
Packit Service a8c26c
functions and
Packit Service a8c26c
.I code
Packit Service a8c26c
extensions to the
Packit Service a8c26c
.L regerror()
Packit Service a8c26c
function.
Packit Service a8c26c
Packit Service a8c26c
.PP
Packit Service a8c26c
.L regcache()
Packit Service a8c26c
maintains a cache of compiled regular expressions for patterns of size
Packit Service a8c26c
255 bytes or less.
Packit Service a8c26c
The initial cache size is 8.
Packit Service a8c26c
.L pattern
Packit Service a8c26c
and
Packit Service a8c26c
.L flags
Packit Service a8c26c
are passed to
Packit Service a8c26c
.L regcomp()
Packit Service a8c26c
with an
Packit Service a8c26c
.L re
Packit Service a8c26c
pointer maintained by
Packit Service a8c26c
.LR regcache() .
Packit Service a8c26c
.LR pcode ,
Packit Service a8c26c
if not 0, points to the return value of the
Packit Service a8c26c
.L regcomp()
Packit Service a8c26c
call.
Packit Service a8c26c
If the
Packit Service a8c26c
.L regcomp()
Packit Service a8c26c
call fails,
Packit Service a8c26c
.L regcache()
Packit Service a8c26c
returns 0 and
Packit Service a8c26c
.L pcode
Packit Service a8c26c
will point to the non-zero error code.
Packit Service a8c26c
Do not call
Packit Service a8c26c
.L regfree()
Packit Service a8c26c
on the
Packit Service a8c26c
.L re
Packit Service a8c26c
returned by
Packit Service a8c26c
.LR regcache() .
Packit Service a8c26c
Both
Packit Service a8c26c
.L pattern
Packit Service a8c26c
and
Packit Service a8c26c
.L flags
Packit Service a8c26c
are used to match entries in the cache.
Packit Service a8c26c
When the cache is full the least recently used
Packit Service a8c26c
.L re
Packit Service a8c26c
is freed (via
Packit Service a8c26c
.LR regfree() )
Packit Service a8c26c
to make space for the new pattern.
Packit Service a8c26c
Any
Packit Service a8c26c
.L re
Packit Service a8c26c
previously returned by
Packit Service a8c26c
.L regcache()
Packit Service a8c26c
may be freed (invalidated) on the next call to
Packit Service a8c26c
.LR regcache() .
Packit Service a8c26c
If
Packit Service a8c26c
.L pattern
Packit Service a8c26c
is longer that 255 bytes then it is still passed on to
Packit Service a8c26c
.LR regcomp() ,
Packit Service a8c26c
but it will not be cached.
Packit Service a8c26c
If
Packit Service a8c26c
.L pattern
Packit Service a8c26c
is 0 then the cache is flushed.
Packit Service a8c26c
In addition, if the integer value of
Packit Service a8c26c
.L flags
Packit Service a8c26c
is greater than the current cache size, the cache size is increased
Packit Service a8c26c
to that integer value.
Packit Service a8c26c
0 is always returned when
Packit Service a8c26c
.L pattern
Packit Service a8c26c
is 0;
Packit Service a8c26c
.L pcode
Packit Service a8c26c
will point to a non-zero value on error.
Packit Service a8c26c
Packit Service a8c26c
.SH "SEE ALSO"
Packit Service a8c26c
strmatch(3)