44 #include <sys/types.h>
56 #define states1 long long
57 #define states states1
58 #define CLEAR(v) ((v) = 0)
59 #define SET0(v, n) ((v) &= ~((unsigned states)1 << (n)))
60 #define SET1(v, n) ((v) |= (unsigned states)1 << (n))
61 #define ISSET(v, n) (((v) & ((unsigned states)1 << (n))) != 0)
62 #define ASSIGN(d, s) ((d) = (s))
63 #define EQ(a, b) ((a) == (b))
64 #define STATEVARS states dummy
65 #define STATESETUP(m, n)
66 #define STATETEARDOWN(m)
67 #define SETUP(v) ((v) = 0)
68 #define onestate states
69 #define INIT(o, n) ((o) = (unsigned states)1 << (n))
70 #define INC(o) ((o) <<= 1)
71 #define ISSTATEIN(v, o) (((v) & (o)) != 0)
74 #define FWD(dst, src, n) ((dst) |= ((unsigned states)(src) & (here)) << (n))
75 #define BACK(dst, src, n) ((dst) |= ((unsigned states)(src) & (here)) >> (n))
76 #define ISSETBACK(v, n) (((v) & ((unsigned states)here >> (n))) != 0)
104 #define states char *
105 #define CLEAR(v) memset(v, 0, m->g->nstates)
106 #define SET0(v, n) ((v)[n] = 0)
107 #define SET1(v, n) ((v)[n] = 1)
108 #define ISSET(v, n) ((v)[n])
109 #define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
110 #define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
114 #define STATESETUP(m, nv) \
116 (m)->space = malloc((nv) * (m)->g->nstates); \
118 return RZ_REGEX_ESPACE; \
121 #define STATETEARDOWN(m) \
122 { free((m)->space); }
123 #define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
124 #define onestate states1
125 #define INIT(o, n) ((o) = (n))
126 #define INC(o) ((o)++)
127 #define ISSTATEIN(v, o) ((v)[o])
130 #define FWD(dst, src, n) ((dst)[here + (n)] |= (src)[here])
131 #define BACK(dst, src, n) ((dst)[here - (n)] |= (src)[here])
132 #define ISSETBACK(v, n) ((v)[here - (n)])
153 #define GOODFLAGS(f) (f)
155 #define GOODFLAGS(f) ((f) & (RZ_REGEX_NOTBOL | RZ_REGEX_NOTEOL | RZ_REGEX_STARTEND | RZ_REGEX_LARGE))
157 if (!preg || !
string) {
165 if (
g->iflags &
BAD) {
170 return (smatcher(
g, (
char *)
string, nmatch, pmatch, eflags));
172 return (lmatcher(
g, (
char *)
string, nmatch, pmatch, eflags));
RZ_API int rz_regex_exec(const RzRegex *preg, const char *string, size_t nmatch, RzRegexMatch pmatch[], int eflags)
RZ_API bool rz_regex_check(const RzRegex *rr, const char *str)