2
0

regguts.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*
  2. * Internal interface definitions, etc., for the reg package
  3. *
  4. * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
  5. *
  6. * Development of this software was funded, in part, by Cray Research Inc.,
  7. * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
  8. * Corporation, none of whom are responsible for the results. The author
  9. * thanks all of them.
  10. *
  11. * Redistribution and use in source and binary forms -- with or without
  12. * modification -- are permitted for any purpose, provided that
  13. * redistributions in source form retain this entire copyright notice and
  14. * indicate the origin and nature of any modifications.
  15. *
  16. * I'd appreciate being given credit for this package in the documentation
  17. * of software which uses it, but that is not a requirement.
  18. *
  19. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
  20. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  21. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  22. * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  25. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  27. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  28. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. * src/include/regex/regguts.h
  31. */
  32. /*
  33. * Environmental customization. It should not (I hope) be necessary to
  34. * alter the file you are now reading -- regcustom.h should handle it all,
  35. * given care here and elsewhere.
  36. */
  37. #include "regcustom.h"
  38. /*
  39. * Things that regcustom.h might override.
  40. */
  41. /* assertions */
  42. #ifndef assert
  43. #ifndef REG_DEBUG
  44. #define NDEBUG /* no assertions */
  45. #endif
  46. #include <assert.h>
  47. #endif
  48. /* voids */
  49. #ifndef DISCARD
  50. #define DISCARD void /* for throwing values away */
  51. #endif
  52. #ifndef VS
  53. #define VS(x) ((void *)(x)) /* cast something to generic ptr */
  54. #endif
  55. /* function-pointer declarator */
  56. #ifndef FUNCPTR
  57. #define FUNCPTR(name, args) (*(name)) args
  58. #endif
  59. /* memory allocation */
  60. #ifndef MALLOC
  61. #define MALLOC(n) malloc(n)
  62. #endif
  63. #ifndef REALLOC
  64. #define REALLOC(p, n) realloc(VS(p), n)
  65. #endif
  66. #ifndef FREE
  67. #define FREE(p) free(VS(p))
  68. #endif
  69. /* want size of a char in bits, and max value in bounded quantifiers */
  70. #ifndef _POSIX2_RE_DUP_MAX
  71. #define _POSIX2_RE_DUP_MAX 255 /* normally from <limits.h> */
  72. #endif
  73. /*
  74. * misc
  75. */
  76. #define NOTREACHED 0
  77. #define DUPMAX _POSIX2_RE_DUP_MAX
  78. #define DUPINF (DUPMAX+1)
  79. #define REMAGIC 0xfed7 /* magic number for main struct */
  80. /* Type codes for lookaround constraints */
  81. #define LATYPE_AHEAD_POS 03 /* positive lookahead */
  82. #define LATYPE_AHEAD_NEG 02 /* negative lookahead */
  83. #define LATYPE_BEHIND_POS 01 /* positive lookbehind */
  84. #define LATYPE_BEHIND_NEG 00 /* negative lookbehind */
  85. #define LATYPE_IS_POS(la) ((la) & 01)
  86. #define LATYPE_IS_AHEAD(la) ((la) & 02)
  87. /*
  88. * debugging facilities
  89. */
  90. #ifdef REG_DEBUG
  91. /* FDEBUG does finite-state tracing */
  92. #define FDEBUG(arglist) { if (v->eflags&REG_FTRACE) printf arglist; }
  93. /* MDEBUG does higher-level tracing */
  94. #define MDEBUG(arglist) { if (v->eflags&REG_MTRACE) printf arglist; }
  95. #else
  96. #define FDEBUG(arglist) {}
  97. #define MDEBUG(arglist) {}
  98. #endif
  99. /*
  100. * bitmap manipulation
  101. */
  102. #define UBITS (CHAR_BIT * sizeof(unsigned))
  103. #define BSET(uv, sn) ((uv)[(sn)/UBITS] |= (unsigned)1 << ((sn)%UBITS))
  104. #define ISBSET(uv, sn) ((uv)[(sn)/UBITS] & ((unsigned)1 << ((sn)%UBITS)))
  105. /*
  106. * known character classes
  107. */
  108. enum char_classes
  109. {
  110. CC_ALNUM, CC_ALPHA, CC_ASCII, CC_BLANK, CC_CNTRL, CC_DIGIT, CC_GRAPH,
  111. CC_LOWER, CC_PRINT, CC_PUNCT, CC_SPACE, CC_UPPER, CC_XDIGIT, CC_WORD
  112. };
  113. #define NUM_CCLASSES 14
  114. /*
  115. * As soon as possible, we map chrs into equivalence classes -- "colors" --
  116. * which are of much more manageable number.
  117. *
  118. * To further reduce the number of arcs in NFAs and DFAs, we also have a
  119. * special RAINBOW "color" that can be assigned to an arc. This is not a
  120. * real color, in that it has no entry in color maps.
  121. */
  122. typedef short color; /* colors of characters */
  123. #define MAX_COLOR 32767 /* max color (must fit in 'color' datatype) */
  124. #define COLORLESS (-1) /* impossible color */
  125. #define RAINBOW (-2) /* represents all colors except pseudocolors */
  126. #define WHITE 0 /* default color, parent of all others */
  127. /* Note: various places in the code know that WHITE is zero */
  128. /*
  129. * Per-color data structure for the compile-time color machinery
  130. *
  131. * If "sub" is not NOSUB then it is the number of the color's current
  132. * subcolor, i.e. we are in process of dividing this color (character
  133. * equivalence class) into two colors. See src/backend/regex/README for
  134. * discussion of subcolors.
  135. *
  136. * Currently-unused colors have the FREECOL bit set and are linked into a
  137. * freelist using their "sub" fields, but only if their color numbers are
  138. * less than colormap.max. Any array entries beyond "max" are just garbage.
  139. */
  140. struct colordesc
  141. {
  142. int nschrs; /* number of simple chars of this color */
  143. int nuchrs; /* number of upper map entries of this color */
  144. color sub; /* open subcolor, if any; or free-chain ptr */
  145. #define NOSUB COLORLESS /* value of "sub" when no open subcolor */
  146. struct arc *arcs; /* chain of all arcs of this color */
  147. chr firstchr; /* simple char first assigned to this color */
  148. int flags; /* bitmask of the following flags: */
  149. #define FREECOL 01 /* currently free */
  150. #define PSEUDO 02 /* pseudocolor, no real chars */
  151. #define COLMARK 04 /* temporary marker used in some functions */
  152. };
  153. #define UNUSEDCOLOR(cd) ((cd)->flags & FREECOL)
  154. /*
  155. * The color map itself
  156. *
  157. * This struct holds both data used only at compile time, and the chr to
  158. * color mapping information, used at both compile and run time. The latter
  159. * is the bulk of the space, so it's not really worth separating out the
  160. * compile-only portion.
  161. *
  162. * Ideally, the mapping data would just be an array of colors indexed by
  163. * chr codes; but for large character sets that's impractical. Fortunately,
  164. * common characters have smaller codes, so we can use a simple array for chr
  165. * codes up to MAX_SIMPLE_CHR, and do something more complex for codes above
  166. * that, without much loss of performance. The "something more complex" is a
  167. * 2-D array of color entries, where row indexes correspond to individual chrs
  168. * or chr ranges that have been mentioned in the regex (with row zero
  169. * representing all other chrs), and column indexes correspond to different
  170. * sets of locale-dependent character classes such as "isalpha". The
  171. * classbits[k] entry is zero if we do not care about the k'th character class
  172. * in this regex, and otherwise it is the bit to be OR'd into the column index
  173. * if the character in question is a member of that class. We find the color
  174. * of a high-valued chr by identifying which colormaprange it is in to get
  175. * the row index (use row zero if it's in none of them), identifying which of
  176. * the interesting cclasses it's in to get the column index, and then indexing
  177. * into the 2-D hicolormap array.
  178. *
  179. * The colormapranges are required to be nonempty, nonoverlapping, and to
  180. * appear in increasing chr-value order.
  181. */
  182. typedef struct colormaprange
  183. {
  184. chr cmin; /* range represents cmin..cmax inclusive */
  185. chr cmax;
  186. int rownum; /* row index in hicolormap array (>= 1) */
  187. } colormaprange;
  188. struct colormap
  189. {
  190. int magic;
  191. #define CMMAGIC 0x876
  192. struct vars *v; /* for compile error reporting */
  193. size_t ncds; /* allocated length of colordescs array */
  194. size_t max; /* highest color number currently in use */
  195. color free; /* beginning of free chain (if non-0) */
  196. struct colordesc *cd; /* pointer to array of colordescs */
  197. #define CDEND(cm) (&(cm)->cd[(cm)->max + 1])
  198. /* mapping data for chrs <= MAX_SIMPLE_CHR: */
  199. color *locolormap; /* simple array indexed by chr code */
  200. /* mapping data for chrs > MAX_SIMPLE_CHR: */
  201. int classbits[NUM_CCLASSES]; /* see comment above */
  202. int numcmranges; /* number of colormapranges */
  203. colormaprange *cmranges; /* ranges of high chrs */
  204. color *hicolormap; /* 2-D array of color entries */
  205. int maxarrayrows; /* number of array rows allocated */
  206. int hiarrayrows; /* number of array rows in use */
  207. int hiarraycols; /* number of array columns (2^N) */
  208. /* If we need up to NINLINECDS, we store them here to save a malloc */
  209. #define NINLINECDS ((size_t) 10)
  210. struct colordesc cdspace[NINLINECDS];
  211. };
  212. /* fetch color for chr; beware of multiple evaluation of c argument */
  213. #define GETCOLOR(cm, c) \
  214. ((c) <= MAX_SIMPLE_CHR ? (cm)->locolormap[(c) - CHR_MIN] : pg_reg_getcolor(cm, c))
  215. /*
  216. * Interface definitions for locale-interface functions in regc_locale.c.
  217. */
  218. /*
  219. * Representation of a set of characters. chrs[] represents individual
  220. * code points, ranges[] represents ranges in the form min..max inclusive.
  221. *
  222. * If the cvec represents a locale-specific character class, eg [[:alpha:]],
  223. * then the chrs[] and ranges[] arrays contain only members of that class
  224. * up to MAX_SIMPLE_CHR (inclusive). cclasscode is set to regc_locale.c's
  225. * code for the class, rather than being -1 as it is in an ordinary cvec.
  226. *
  227. * Note that in cvecs gotten from newcvec() and intended to be freed by
  228. * freecvec(), both arrays of chrs are after the end of the struct, not
  229. * separately malloc'd; so chrspace and rangespace are effectively immutable.
  230. */
  231. struct cvec
  232. {
  233. int nchrs; /* number of chrs */
  234. int chrspace; /* number of chrs allocated in chrs[] */
  235. chr *chrs; /* pointer to vector of chrs */
  236. int nranges; /* number of ranges (chr pairs) */
  237. int rangespace; /* number of ranges allocated in ranges[] */
  238. chr *ranges; /* pointer to vector of chr pairs */
  239. int cclasscode; /* value of "enum classes", or -1 */
  240. };
  241. /*
  242. * definitions for NFA internal representation
  243. */
  244. struct state;
  245. struct arc
  246. {
  247. int type; /* 0 if free, else an NFA arc type code */
  248. color co; /* color the arc matches (possibly RAINBOW) */
  249. struct state *from; /* where it's from */
  250. struct state *to; /* where it's to */
  251. struct arc *outchain; /* link in *from's outs chain or free chain */
  252. struct arc *outchainRev; /* back-link in *from's outs chain */
  253. #define freechain outchain /* we do not maintain "freechainRev" */
  254. struct arc *inchain; /* link in *to's ins chain */
  255. struct arc *inchainRev; /* back-link in *to's ins chain */
  256. /* these fields are not used when co == RAINBOW: */
  257. struct arc *colorchain; /* link in color's arc chain */
  258. struct arc *colorchainRev; /* back-link in color's arc chain */
  259. };
  260. struct arcbatch
  261. { /* for bulk allocation of arcs */
  262. struct arcbatch *next; /* chain link */
  263. size_t narcs; /* number of arcs allocated in this arcbatch */
  264. struct arc a[FLEXIBLE_ARRAY_MEMBER];
  265. };
  266. #define ARCBATCHSIZE(n) ((n) * sizeof(struct arc) + offsetof(struct arcbatch, a))
  267. /* first batch will have FIRSTABSIZE arcs; then double it until MAXABSIZE */
  268. #define FIRSTABSIZE 64
  269. #define MAXABSIZE 1024
  270. struct state
  271. {
  272. int no; /* state number, zero and up; or FREESTATE */
  273. #define FREESTATE (-1)
  274. char flag; /* marks special states */
  275. int nins; /* number of inarcs */
  276. int nouts; /* number of outarcs */
  277. struct arc *ins; /* chain of inarcs */
  278. struct arc *outs; /* chain of outarcs */
  279. struct state *tmp; /* temporary for traversal algorithms */
  280. struct state *next; /* chain for traversing all live states */
  281. /* the "next" field is also used to chain free states together */
  282. struct state *prev; /* back-link in chain of all live states */
  283. };
  284. struct statebatch
  285. { /* for bulk allocation of states */
  286. struct statebatch *next; /* chain link */
  287. size_t nstates; /* number of states allocated in this batch */
  288. struct state s[FLEXIBLE_ARRAY_MEMBER];
  289. };
  290. #define STATEBATCHSIZE(n) ((n) * sizeof(struct state) + offsetof(struct statebatch, s))
  291. /* first batch will have FIRSTSBSIZE states; then double it until MAXSBSIZE */
  292. #define FIRSTSBSIZE 32
  293. #define MAXSBSIZE 1024
  294. struct nfa
  295. {
  296. struct state *pre; /* pre-initial state */
  297. struct state *init; /* initial state */
  298. struct state *final; /* final state */
  299. struct state *post; /* post-final state */
  300. int nstates; /* for numbering states */
  301. struct state *states; /* chain of live states */
  302. struct state *slast; /* tail of the chain */
  303. struct state *freestates; /* chain of free states */
  304. struct arc *freearcs; /* chain of free arcs */
  305. struct statebatch *lastsb; /* chain of statebatches */
  306. struct arcbatch *lastab; /* chain of arcbatches */
  307. size_t lastsbused; /* number of states consumed from *lastsb */
  308. size_t lastabused; /* number of arcs consumed from *lastab */
  309. struct colormap *cm; /* the color map */
  310. color bos[2]; /* colors, if any, assigned to BOS and BOL */
  311. color eos[2]; /* colors, if any, assigned to EOS and EOL */
  312. int flags; /* flags to pass forward to cNFA */
  313. int minmatchall; /* min number of chrs to match, if matchall */
  314. int maxmatchall; /* max number of chrs to match, or DUPINF */
  315. struct vars *v; /* simplifies compile error reporting */
  316. struct nfa *parent; /* parent NFA, if any */
  317. };
  318. /*
  319. * definitions for compacted NFA
  320. *
  321. * The main space savings in a compacted NFA is from making the arcs as small
  322. * as possible. We store only the transition color and next-state number for
  323. * each arc. The list of out arcs for each state is an array beginning at
  324. * cnfa.states[statenumber], and terminated by a dummy carc struct with
  325. * co == COLORLESS.
  326. *
  327. * The non-dummy carc structs are of two types: plain arcs and LACON arcs.
  328. * Plain arcs just store the transition color number as "co". LACON arcs
  329. * store the lookaround constraint number plus cnfa.ncolors as "co". LACON
  330. * arcs can be distinguished from plain by testing for co >= cnfa.ncolors.
  331. *
  332. * Note that in a plain arc, "co" can be RAINBOW; since that's negative,
  333. * it doesn't break the rule about how to recognize LACON arcs.
  334. *
  335. * We have special markings for "trivial" NFAs that can match any string
  336. * (possibly with limits on the number of characters therein). In such a
  337. * case, flags & MATCHALL is set (and HASLACONS can't be set). Then the
  338. * fields minmatchall and maxmatchall give the minimum and maximum numbers
  339. * of characters to match. For example, ".*" produces minmatchall = 0
  340. * and maxmatchall = DUPINF, while ".+" produces minmatchall = 1 and
  341. * maxmatchall = DUPINF.
  342. */
  343. struct carc
  344. {
  345. color co; /* COLORLESS is list terminator */
  346. int to; /* next-state number */
  347. };
  348. struct cnfa
  349. {
  350. int nstates; /* number of states */
  351. int ncolors; /* number of colors (max color in use + 1) */
  352. int flags; /* bitmask of the following flags: */
  353. #define HASLACONS 01 /* uses lookaround constraints */
  354. #define MATCHALL 02 /* matches all strings of a range of lengths */
  355. int pre; /* setup state number */
  356. int post; /* teardown state number */
  357. color bos[2]; /* colors, if any, assigned to BOS and BOL */
  358. color eos[2]; /* colors, if any, assigned to EOS and EOL */
  359. char *stflags; /* vector of per-state flags bytes */
  360. #define CNFA_NOPROGRESS 01 /* flag bit for a no-progress state */
  361. struct carc **states; /* vector of pointers to outarc lists */
  362. /* states[n] are pointers into a single malloc'd array of arcs */
  363. struct carc *arcs; /* the area for the lists */
  364. /* these fields are used only in a MATCHALL NFA (else they're -1): */
  365. int minmatchall; /* min number of chrs to match */
  366. int maxmatchall; /* max number of chrs to match, or DUPINF */
  367. };
  368. /*
  369. * When debugging, it's helpful if an un-filled CNFA is all-zeroes.
  370. * In production, though, we only require nstates to be zero.
  371. */
  372. #ifdef REG_DEBUG
  373. #define ZAPCNFA(cnfa) memset(&(cnfa), 0, sizeof(cnfa))
  374. #else
  375. #define ZAPCNFA(cnfa) ((cnfa).nstates = 0)
  376. #endif
  377. #define NULLCNFA(cnfa) ((cnfa).nstates == 0)
  378. /*
  379. * This symbol limits the transient heap space used by the regex compiler,
  380. * and thereby also the maximum complexity of NFAs that we'll deal with.
  381. * Currently we only count NFA states and arcs against this; the other
  382. * transient data is generally not large enough to notice compared to those.
  383. * Note that we do not charge anything for the final output data structures
  384. * (the compacted NFA and the colormap).
  385. * The scaling here is based on an empirical measurement that very large
  386. * NFAs tend to have about 4 arcs/state.
  387. */
  388. #ifndef REG_MAX_COMPILE_SPACE
  389. #define REG_MAX_COMPILE_SPACE \
  390. (500000 * (sizeof(struct state) + 4 * sizeof(struct arc)))
  391. #endif
  392. /*
  393. * subexpression tree
  394. *
  395. * "op" is one of:
  396. * '=' plain regex without interesting substructure (implemented as DFA)
  397. * 'b' back-reference (has no substructure either)
  398. * '(' no-op capture node: captures the match of its single child
  399. * '.' concatenation: matches a match for first child, then second child
  400. * '|' alternation: matches a match for any of its children
  401. * '*' iteration: matches some number of matches of its single child
  402. *
  403. * An alternation node can have any number of children (but at least two),
  404. * linked through their sibling fields.
  405. *
  406. * A concatenation node must have exactly two children. It might be useful
  407. * to support more, but that would complicate the executor. Note that it is
  408. * the first child's greediness that determines the node's preference for
  409. * where to split a match.
  410. *
  411. * Note: when a backref is directly quantified, we stick the min/max counts
  412. * into the backref rather than plastering an iteration node on top. This is
  413. * for efficiency: there is no need to search for possible division points.
  414. */
  415. struct subre
  416. {
  417. char op; /* see type codes above */
  418. char flags;
  419. #define LONGER 01 /* prefers longer match */
  420. #define SHORTER 02 /* prefers shorter match */
  421. #define MIXED 04 /* mixed preference below */
  422. #define CAP 010 /* capturing parens here or below */
  423. #define BACKR 020 /* back reference here or below */
  424. #define BRUSE 040 /* is referenced by a back reference */
  425. #define INUSE 0100 /* in use in final tree */
  426. #define UPPROP (MIXED|CAP|BACKR) /* flags which should propagate up */
  427. #define LMIX(f) ((f)<<2) /* LONGER -> MIXED */
  428. #define SMIX(f) ((f)<<1) /* SHORTER -> MIXED */
  429. #define UP(f) (((f)&UPPROP) | (LMIX(f) & SMIX(f) & MIXED))
  430. #define MESSY(f) ((f)&(MIXED|CAP|BACKR))
  431. #define PREF(f) ((f)&(LONGER|SHORTER))
  432. #define PREF2(f1, f2) ((PREF(f1) != 0) ? PREF(f1) : PREF(f2))
  433. #define COMBINE(f1, f2) (UP((f1)|(f2)) | PREF2(f1, f2))
  434. char latype; /* LATYPE code, if lookaround constraint */
  435. int id; /* ID of subre (1..ntree-1) */
  436. int capno; /* if capture node, subno to capture into */
  437. int backno; /* if backref node, subno it refers to */
  438. short min; /* min repetitions for iteration or backref */
  439. short max; /* max repetitions for iteration or backref */
  440. struct subre *child; /* first child, if any (also freelist chain) */
  441. struct subre *sibling; /* next child of same parent, if any */
  442. struct state *begin; /* outarcs from here... */
  443. struct state *end; /* ...ending in inarcs here */
  444. struct cnfa cnfa; /* compacted NFA, if any */
  445. struct subre *chain; /* for bookkeeping and error cleanup */
  446. };
  447. /*
  448. * table of function pointers for generic manipulation functions
  449. * A regex_t's re_fns points to one of these.
  450. */
  451. struct fns
  452. {
  453. void FUNCPTR(free, (regex_t *));
  454. int FUNCPTR(cancel_requested, (void));
  455. int FUNCPTR(stack_too_deep, (void));
  456. };
  457. #define CANCEL_REQUESTED(re) \
  458. ((*((struct fns *) (re)->re_fns)->cancel_requested) ())
  459. #define STACK_TOO_DEEP(re) \
  460. ((*((struct fns *) (re)->re_fns)->stack_too_deep) ())
  461. /*
  462. * the insides of a regex_t, hidden behind a void *
  463. */
  464. struct guts
  465. {
  466. int magic;
  467. #define GUTSMAGIC 0xfed9
  468. int cflags; /* copy of compile flags */
  469. long info; /* copy of re_info */
  470. size_t nsub; /* copy of re_nsub */
  471. struct subre *tree;
  472. struct cnfa search; /* for fast preliminary search */
  473. int ntree; /* number of subre's, plus one */
  474. struct colormap cmap;
  475. int FUNCPTR(compare, (const chr *, const chr *, size_t));
  476. struct subre *lacons; /* lookaround-constraint vector */
  477. int nlacons; /* size of lacons[]; note that only slots
  478. * numbered 1 .. nlacons-1 are used */
  479. };
  480. /* prototypes for functions that are exported from regcomp.c to regexec.c */
  481. extern void pg_set_regex_collation(Oid collation);
  482. extern color pg_reg_getcolor(struct colormap *cm, chr c);