Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

step(3) OSS Library Calls Reference Manual
NAME
step - Compile and match regular expressions
LIBRARY
None. This application program interface is implemented as a macro.
SYNOPSIS
#include <regexp.h>
int step (
const char *string,
const char *expbuf);
extern char *loc1, *loc2, *locs;
PARAMETERS
string Points to a null-terminated string of characters to be searched for a match.
expbuf Points to a character array where the compiled regular expression is stored.
DESCRIPTION
The compile( ), advance( ), and step( ) macros are used for general-purpose expression matching.
The step( ) macro finds the first substring of the string parameter that matches the compiled
expression pointed to by the expbuf parameter. When there is no match, the step( ) macro returns
a value of 0 (zero). When there is a match, the step( ) macro returns a nonzero value and sets two
global character pointers:
loc1 which points to the first character of the substring that matches the pattern
loc2 which points to the character immediately following the substring that matches
the pattern.
When the regular expression matches the entire expression, loc1 points to the first character of
the string parameter and loc2 points to the null character at the end of the expression specified by
the string parameter.
The step( ) macro uses the integer variable circf, which is set by the compile( ) macro when the
regular expression begins with a ˆ (circumflex) character. When this variable is set, the step( )
macro only tries to match the regular expression to the beginning of the string. When you com-
pile more than one regular expression before executing the first one, save the value of circf for
each compiled expression and set circf to the saved value before each call to step( ).
Using the same parameters that were passed to it, the step( ) macro calls the advance( ) macro.
The step( ) macro increments a pointer through the string parameter characters and calls
advance( ) until a nonzero value, which indicates a match, is returned, or until the end of the
expression pointed to by the string parameter is reached. To unconditionally constrain string to
point to the beginning of the expression, call the advance( ) macro directly instead of calling
step( ).
NOTES
The step( ) macro can be called by native processes only.
The functionality provided by advance( ), compile( ), and step( ) is defined to be obsolete by
POSIX. Functions such as regcomp( ) and regexec() should be used instead.
6128 Hewlett-Packard Company 527187-017