Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
compile(3) OSS Library Calls Reference Manual
NAME
compile - Compiles regular expressions
LIBRARY
None. This application program interface is implemented as a macro.
SYNOPSIS
#define INIT declarations
#define GETC( ) getc code
#define PEEKC( ) peekc code
#define UNGETC(c) ungetc code
#define RETURN(ptr) return code
#define 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 Specifies a pointer to the character following the last character of the compiled
regular expression.
val Specifies an error value.
instring Specifies 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 Specifies 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 defined 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.
1−122 Hewlett-Packard Company 527187-017