Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.8 KiB

  1. /* regexp.h
  2. */
  3. /*
  4. * Definitions etc. for regexp(3) routines.
  5. *
  6. * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
  7. * not the System V one.
  8. */
  9. struct regnode {
  10. U8 flags;
  11. U8 type;
  12. U16 next_off;
  13. };
  14. typedef struct regnode regnode;
  15. struct reg_substr_data;
  16. struct reg_data;
  17. typedef struct regexp {
  18. I32 *startp;
  19. I32 *endp;
  20. regnode *regstclass;
  21. struct reg_substr_data *substrs;
  22. char *precomp; /* pre-compilation regular expression */
  23. struct reg_data *data; /* Additional data. */
  24. char *subbeg; /* saved or original string
  25. so \digit works forever. */
  26. I32 sublen; /* Length of string pointed by subbeg */
  27. I32 refcnt;
  28. I32 minlen; /* mininum possible length of $& */
  29. I32 prelen; /* length of precomp */
  30. U32 nparens; /* number of parentheses */
  31. U32 lastparen; /* last paren matched */
  32. U32 reganch; /* Internal use only +
  33. Tainted information used by regexec? */
  34. regnode program[1]; /* Unwarranted chumminess with compiler. */
  35. } regexp;
  36. #define ROPT_ANCH (ROPT_ANCH_BOL|ROPT_ANCH_MBOL|ROPT_ANCH_GPOS|ROPT_ANCH_SBOL)
  37. #define ROPT_ANCH_SINGLE (ROPT_ANCH_SBOL|ROPT_ANCH_GPOS)
  38. #define ROPT_ANCH_BOL 0x00001
  39. #define ROPT_ANCH_MBOL 0x00002
  40. #define ROPT_ANCH_SBOL 0x00004
  41. #define ROPT_ANCH_GPOS 0x00008
  42. #define ROPT_SKIP 0x00010
  43. #define ROPT_IMPLICIT 0x00020 /* Converted .* to ^.* */
  44. #define ROPT_NOSCAN 0x00040 /* Check-string always at start. */
  45. #define ROPT_GPOS_SEEN 0x00080
  46. #define ROPT_CHECK_ALL 0x00100
  47. #define ROPT_LOOKBEHIND_SEEN 0x00200
  48. #define ROPT_EVAL_SEEN 0x00400
  49. /* 0xf800 of reganch is used by PMf_COMPILETIME */
  50. #define ROPT_UTF8 0x10000
  51. #define ROPT_NAUGHTY 0x20000 /* how exponential is this pattern? */
  52. #define ROPT_COPY_DONE 0x40000 /* subbeg is a copy of the string */
  53. #define ROPT_TAINTED_SEEN 0x80000
  54. #define RE_USE_INTUIT_NOML 0x0100000 /* Best to intuit before matching */
  55. #define RE_USE_INTUIT_ML 0x0200000
  56. #define REINT_AUTORITATIVE_NOML 0x0400000 /* Can trust a positive answer */
  57. #define REINT_AUTORITATIVE_ML 0x0800000
  58. #define REINT_ONCE_NOML 0x1000000 /* Intuit can succed once only. */
  59. #define REINT_ONCE_ML 0x2000000
  60. #define RE_INTUIT_ONECHAR 0x4000000
  61. #define RE_INTUIT_TAIL 0x8000000
  62. #define RE_USE_INTUIT (RE_USE_INTUIT_NOML|RE_USE_INTUIT_ML)
  63. #define REINT_AUTORITATIVE (REINT_AUTORITATIVE_NOML|REINT_AUTORITATIVE_ML)
  64. #define REINT_ONCE (REINT_ONCE_NOML|REINT_ONCE_ML)
  65. #define RX_MATCH_TAINTED(prog) ((prog)->reganch & ROPT_TAINTED_SEEN)
  66. #define RX_MATCH_TAINTED_on(prog) ((prog)->reganch |= ROPT_TAINTED_SEEN)
  67. #define RX_MATCH_TAINTED_off(prog) ((prog)->reganch &= ~ROPT_TAINTED_SEEN)
  68. #define RX_MATCH_TAINTED_set(prog, t) ((t) \
  69. ? RX_MATCH_TAINTED_on(prog) \
  70. : RX_MATCH_TAINTED_off(prog))
  71. #define RX_MATCH_COPIED(prog) ((prog)->reganch & ROPT_COPY_DONE)
  72. #define RX_MATCH_COPIED_on(prog) ((prog)->reganch |= ROPT_COPY_DONE)
  73. #define RX_MATCH_COPIED_off(prog) ((prog)->reganch &= ~ROPT_COPY_DONE)
  74. #define RX_MATCH_COPIED_set(prog,t) ((t) \
  75. ? RX_MATCH_COPIED_on(prog) \
  76. : RX_MATCH_COPIED_off(prog))
  77. #define REXEC_COPY_STR 0x01 /* Need to copy the string. */
  78. #define REXEC_CHECKED 0x02 /* check_substr already checked. */
  79. #define REXEC_SCREAM 0x04 /* use scream table. */
  80. #define REXEC_IGNOREPOS 0x08 /* \G matches at start. */
  81. #define REXEC_NOT_FIRST 0x10 /* This is another iteration of //g. */
  82. #define REXEC_ML 0x20 /* $* was set. */
  83. #define ReREFCNT_inc(re) ((void)(re && re->refcnt++), re)
  84. #define ReREFCNT_dec(re) CALLREGFREE(aTHX_ re)
  85. #define FBMcf_TAIL_DOLLAR 1
  86. #define FBMcf_TAIL_DOLLARM 2
  87. #define FBMcf_TAIL_Z 4
  88. #define FBMcf_TAIL_z 8
  89. #define FBMcf_TAIL (FBMcf_TAIL_DOLLAR|FBMcf_TAIL_DOLLARM|FBMcf_TAIL_Z|FBMcf_TAIL_z)
  90. #define FBMrf_MULTILINE 1
  91. struct re_scream_pos_data_s;