one now should call 'setup-windoze' as the 1st rule if he wants windoze builds
[k8jam.git] / src / hsregexp.h
bloba07487f24563c29e9cd4876e7118f6cf2dc4e356
1 /*
2 * definitions etc. for regexp(3) routines
4 * caveat: this is V8 regexp(3) [actually, a reimplementation thereof], not the System V one
6 * 11/04/02 (seiwald) - const-ing for string literals
7 */
8 #ifndef HEADER_LIBHSRX_H
9 #define HEADER_LIBHSRX_H
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
15 #include <stdlib.h>
19 * The "internal use only" fields in regexp.h are present to pass info from
20 * compile to execute that permits the execute phase to run lots faster on
21 * simple cases. They are:
23 * regstart char that must begin a match; '\0' if none obvious
24 * reganch is the match anchored (at beginning-of-line only)?
25 * regmust string (pointer into program) that match must include, or NULL
26 * regmlen length of regmust string
28 * Regstart and reganch permit very fast decisions on suitable starting points
29 * for a match, cutting down the work a lot. Regmust permits fast rejection
30 * of lines that cannot possibly match. The regmust tests are costly enough
31 * that hsrxCompile() supplies a regmust only if the r.e. contains something
32 * potentially expensive (at present, the only such thing detected is * or +
33 * at the start of the r.e., which can involve a lot of backup). Regmlen is
34 * supplied because the test in hsrxExec() needs it and hsrxCompile() is computing
35 * it anyway.
37 typedef struct {
38 int rm_so;
39 int rm_eo;
40 } HSRxMatch;
43 typedef struct HSRegExp {
44 /* -- public -- */
45 int re_nsub; /* number of parenthesized subexpressions */
46 /* -- private -- */
47 int cflags; /* flags used when compiling */
48 int err; /* any error which occurred during compile */
49 int regstart; /* internal use only */
50 int reganch; /* internal use only */
51 int regmust; /* internal use only */
52 int regmlen; /* internal use only */
53 int *program; /* allocated */
54 /* working state - compile */
55 const char *regparse; /* input-scan pointer */
56 int p; /* current output pos in program */
57 int proglen; /* allocated program size */
58 /* working state - exec */
59 int eflags; /* flags used when executing */
60 const char *start; /* initial string pointer */
61 const char *reginput; /* current input pointer */
62 const char *regbol; /* beginning of input, for ^ check */
63 /* input to hsrxExec() */
64 HSRxMatch *pmatch; /* submatches will be stored here */
65 int nmatch; /* size of pmatch[] */
66 } HSRegExp;
69 enum {
70 HSRX_EXTENDED,
71 HSRX_NEWLINE,
72 HSRX_ICASE,
73 HSRX_NOTBOL = 16
77 enum {
78 HSRX_NOERROR, /* success */
79 HSRX_NOMATCH, /* didn't find a match (for hsrxExec) */
80 HSRX_BADPAT, /* >= HSRX_BADPAT is an error */
81 HSRX_ERR_NULL_ARGUMENT,
82 HSRX_ERR_UNKNOWN,
83 HSRX_ERR_TOO_BIG,
84 HSRX_ERR_NOMEM,
85 HSRX_ERR_TOO_MANY_PAREN,
86 HSRX_ERR_UNMATCHED_PAREN,
87 HSRX_ERR_UNMATCHED_BRACES,
88 HSRX_ERR_BAD_COUNT,
89 HSRX_ERR_JUNK_ON_END,
90 HSRX_ERR_OPERAND_COULD_BE_EMPTY,
91 HSRX_ERR_NESTED_COUNT,
92 HSRX_ERR_INTERNAL,
93 HSRX_ERR_COUNT_FOLLOWS_NOTHING,
94 HSRX_ERR_TRAILING_BACKSLASH,
95 HSRX_ERR_CORRUPTED,
96 HSRX_ERR_NULL_CHAR,
97 HSRX_ERR_NUM
101 extern int hsrxCompile (HSRegExp *preg, const char *regex, int cflags);
102 extern int hsrxExec (HSRegExp *preg, const char *string, size_t nmatch, HSRxMatch pmatch[], int eflags);
103 extern size_t hsrxError (int errcode, const HSRegExp *preg, char *errbuf, size_t errbuf_size);
104 extern void hsrxFree (HSRegExp *preg);
107 #ifdef HSRX_DEBUG
108 extern int hsrxNarrate;
109 extern void hsrxDump (HSRegExp *preg);
110 #endif
113 #ifdef __cplusplus
115 #endif
116 #endif