Standards
Standards / Extensions |
C or C++ |
Dependencies |
XPG4
XPG4.2
|
both |
|
Format
#define _XOPEN_SOURCE
#include <regexp.h>
int advance(const char *string, const char *expbuf);
extern char *loc2, *locs;
General description
Restriction: This function is not supported in AMODE 64.
The
advance() function attempts to match an input string of characters
with the compiled regular expression which was obtained by an earlier
call to compile().
The first parameter string is
a pointer to a string of characters to be checked for a match.
expbuf is
the pointer to the regular expression which was previously obtained
by a call to compile().
The external variable loc2 will
point to the next character in string after
the last character that matched the regular expression.
The
external variable locs can be optionally
set to point to some point in the input regular expression string
to cause the advance() function to exit its back up loop.
Note: The
external variables cirf, sed,
and nbra are reserved.
During
the pattern matching operation, when advance() encounters a * or \{\}
sequence in the regular expression, it will advance its pointer to
the string to be matched as far as possible and will recursively call
itself trying to match the rest of the string to the rest of the regular
expression. As long as there is no match, advance() will back up along
the string until it finds a match or reaches the point in the string
that initially matched the * or \{\}. It is sometime desirable to
stop this backing up before the initial point in the string is reached.
If the external character pointer
locs is
equal to the point in the string at some time during the back up process,
advance() will break out of the loop that backs up and will return
0 (a failure indication).
Notes: - The application must provide the proper serialization for the
compile(), step(), and advance() functions if they are run under a
multithreaded environment.
- The compile(), step(), and advance() functions
are provided for historical reasons. These functions were part of
the Legacy Feature in Single UNIX Specification,
Version 2. They have been withdrawn and are not supported as part
of Single UNIX Specification,
Version 3. New applications should use the newer functions fnmatch(),
glob(), regcomp() and regexec(), which provide full internationalized
regular expression functionality compatible with IEEE Std 1003.1-2001.
Returned value
If the initial substring
of string matches the regular expression
in expbuf, advance() returns nonzero.
If
there is no match, advance() returns 0.
If there is a match,
advance() sets an external character pointer, loc2,
as a side effect. The variable loc2 points
to the next character in string after the
last character that matched the regular expression.