Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

compile(3) OSS Library Calls Reference Manual
NAME
compile - Compiles regular expressions
LIBRARY
None. This application program interface is implemented as a macro.
SYNOPSIS
#dene INIT declarations
#dene GETC() getc code
#dene PEEKC() peekc code
#dene UNGETC(c) ungetc code
#dene RETURN(ptr) return code
#dene ERROR(val) error code
#include <regexp.h>
char *compile (
char *instring,
char *expbuf,
const char *endbuf,
int eof);
extern char *loc1, *loc2, *locs;
PARAMETERS
c The value returned by the next call to the GETC() and PEEKC() macros.
ptr Species a pointer to the character following the last character of the compiled
regular expression.
val Species an error value.
instring Species a string to be passed to the compile() macro. The instring parameter is
never used explicitly by the compile() macro, but you can use it in your macros.
For example, you may want to pass the string containing a pattern as the instring
parameter to the compile() macro and use the INIT( ) macro to set a pointer to
the beginning of this string. When your macros do not use instring, call the
compile() macro with a value of ((char *) 0) for this parameter.
expbuf Points to a character array where the compiled regular expression is stored.
endbuf Points to the location that immediately follows the character array where the
compiled regular expression is stored. When the compiled expression cannot be
contained in (endbuf-expbuf) number of bytes, a call to the ERROR(50) macro
is made.
eof Species the character that marks the end of the regular expression. For example,
in ed this character is usually a / (slash).
DESCRIPTION
The compile(), advance(), and step() macros are used for general-purpose expression matching.
The compile() macro takes a simple regular expression as input and produces a compiled expres-
sion that can be used with the step() and advance() macros.
The following six macros, used in the compile() macro, must be dened before the #include
<regexp.h> statement in programs. The GETC(),PEEKC(), and UNGETC() macros operate
on the regular expression provided as input for the compile() macro.
154 Hewlett-Packard Company 527187-007