regexp.3x (2010 09)
r
regexp(3X) regexp(3X)
NAME
compile( ), step( ), advance( ) - regular expression compile and match routines
SYNOPSIS
#define INIT declarations
#define GETC() getc statements
#define PEEKC() peekc statements
#define UNGETC(c) ungetc statements
#define RETURN(pointer)
return statements
#define ERROR(val) error statements
#include <regexp.h>
char *compile(
char *instring,
char *expbuf,
const char *endbuf,
int eof
);
int step(const char *string, const char *expbuf);
int advance(const char *string, const char *expbuf);
extern char *loc1, *loc2, *locs;
extern int circf, sed, nbra;
Remarks
Features documented in this manual entry are obsolescent and may be removed in a future
HP-UX
release. Use of regcomp (3C) functions instead is recommended.
DESCRIPTION
These functions are general-purpose regular expression matching routines to be used in programs that
perform Basic Regular Expression (see regexp(5)) matching. These functions are defined in
<
regexp.h>.
The functions
step() and advance() do pattern matching given a character string and a compiled
regular expression as input. compile() takes a Basic Regular Expression as input and produces a
compiled expression that can be used with step() and advance().
The interface to this file is unpleasantly complex. Programs that include this file must have the following
five macros declared before the
#include <regexp.h> statement. These macros are used by the
compile() routine.
GETC() Return the value of the next byte in the regular expression pattern. Successive calls to
GETC() should return successive bytes of the regular expression.
PEEKC() Return the next byte in the regular expression. Successive calls to PEEKC() should
return the same byte (which should also be the next byte returned by GETC().
UNGETC(c) Cause the argument c to be returned by the next call to GETC() (and PEEKC()). No
more than one byte of pushback is ever needed, and this byte is guaranteed to be the last
byte read by GETC(). The value of the macro UNGETC(c) is always ignored.
RETURN(pointer )
This macro is used on normal exit of the compile() routine. The value of the argu-
ment pointer is a pointer to the character after the last character of the compiled regular
expression. This is useful to programs that must manage memory allocation.
ERROR(val ) This is the abnormal return from the compile() routine. The argument val is an
error number (see table below for meanings). This call should never return.
Error Meaning
11 Range endpoint too large.
16 Bad number.
25 ‘‘\digit’’ out of range.
36 Illegal or missing delimiter.
41 No remembered search string.
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1