5 #error Need jimautoconf.h
8 #if defined(HAVE_REGCOMP) && !defined(JIM_REGEXP)
17 * Definitions etc. for regexp(3) routines.
19 * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
20 * not the System V one.
22 * 11/04/02 (seiwald) - const-ing for string literals
31 * The "internal use only" fields in regexp.h are present to pass info from
32 * compile to execute that permits the execute phase to run lots faster on
33 * simple cases. They are:
35 * regstart char that must begin a match; '\0' if none obvious
36 * reganch is the match anchored (at beginning-of-line only)?
37 * regmust string (pointer into program) that match must include, or NULL
38 * regmlen length of regmust string
40 * Regstart and reganch permit very fast decisions on suitable starting points
41 * for a match, cutting down the work a lot. Regmust permits fast rejection
42 * of lines that cannot possibly match. The regmust tests are costly enough
43 * that regcomp() supplies a regmust only if the r.e. contains something
44 * potentially expensive (at present, the only such thing detected is * or +
45 * at the start of the r.e., which can involve a lot of backup). Regmlen is
46 * supplied because the test in regexec() needs it and regcomp() is computing
50 typedef struct regexp
{
52 int re_nsub
; /* number of parenthesized subexpressions */
55 int cflags
; /* Flags used when compiling */
56 int err
; /* Any error which occurred during compile */
57 int regstart
; /* Internal use only. */
58 int reganch
; /* Internal use only. */
59 int regmust
; /* Internal use only. */
60 int regmlen
; /* Internal use only. */
61 int *program
; /* Allocated */
63 /* working state - compile */
64 const char *regparse
; /* Input-scan pointer. */
65 int p
; /* Current output pos in program */
66 int proglen
; /* Allocated program size */
68 /* working state - exec */
69 int eflags
; /* Flags used when executing */
70 const char *start
; /* Initial string pointer. */
71 const char *reginput
; /* Current input pointer. */
72 const char *regbol
; /* Beginning of input, for ^ check. */
74 /* Input to regexec() */
75 regmatch_t
*pmatch
; /* submatches will be stored here */
76 int nmatch
; /* size of pmatch[] */
79 typedef regexp regex_t
;
81 #define REG_EXTENDED 0
88 REG_NOERROR
, /* Success. */
89 REG_NOMATCH
, /* Didn't find a match (for regexec). */
90 REG_BADPAT
, /* >= REG_BADPAT is an error */
91 REG_ERR_NULL_ARGUMENT
,
95 REG_ERR_TOO_MANY_PAREN
,
96 REG_ERR_UNMATCHED_PAREN
,
97 REG_ERR_UNMATCHED_BRACES
,
100 REG_ERR_OPERAND_COULD_BE_EMPTY
,
101 REG_ERR_NESTED_COUNT
,
103 REG_ERR_COUNT_FOLLOWS_NOTHING
,
104 REG_ERR_TRAILING_BACKSLASH
,
110 int regcomp(regex_t
*preg
, const char *regex
, int cflags
);
111 int regexec(regex_t
*preg
, const char *string
, size_t nmatch
, regmatch_t pmatch
[], int eflags
);
112 size_t regerror(int errcode
, const regex_t
*preg
, char *errbuf
, size_t errbuf_size
);
113 void regfree(regex_t
*preg
);