Skip to content

Commit 954a921

Browse files
authored
Use named fields for match frame members (#848)
1 parent f483bce commit 954a921

File tree

2 files changed

+231
-119
lines changed

2 files changed

+231
-119
lines changed

src/pcre2_intmodedep.h

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,16 +891,12 @@ we don't generate any code when all is well. */
891891
typedef struct heapframe {
892892

893893
/* The first set of fields are variables that have to be preserved over calls
894-
to RRMATCH(), but which do not need to be copied to new frames. */
894+
to RMATCH(), but which do not need to be copied to new frames. */
895895

896896
PCRE2_SPTR ecode; /* The current position in the pattern */
897-
PCRE2_SPTR temp_sptr[2]; /* Used for short-term PCRE2_SPTR values */
898-
PCRE2_SIZE length; /* Used for character, string, or code lengths */
899897
PCRE2_SIZE back_frame; /* Amount to subtract on RRETURN */
900-
PCRE2_SIZE temp_size; /* Used for short-term PCRE2_SIZE values */
901898
uint32_t rdepth; /* Function "recursion" depth within pcre2_match() */
902899
uint32_t group_frame_type; /* Type information for group frames */
903-
uint32_t temp_32[4]; /* Used for short-term 32-bit or BOOL values */
904900
uint8_t return_id; /* Where to go on in internal "return" */
905901
uint8_t op; /* Processing opcode */
906902

@@ -924,6 +920,117 @@ typedef struct heapframe {
924920
PCRE2_UCHAR occu[1]; /* Used for other case code units */
925921
#endif
926922

923+
union {
924+
/* Fields for storing localized data, which
925+
is preserved by RMATCH() calls. */
926+
927+
struct {
928+
PCRE2_SIZE length;
929+
PCRE2_SIZE oclength;
930+
PCRE2_SPTR start_eptr;
931+
PCRE2_SPTR charptr;
932+
uint32_t min;
933+
uint32_t max;
934+
uint32_t c;
935+
uint32_t oc;
936+
} char_repeat;
937+
938+
struct {
939+
PCRE2_SPTR start_eptr;
940+
uint32_t min;
941+
uint32_t max;
942+
uint32_t c;
943+
uint32_t oc;
944+
} charnot_repeat;
945+
946+
struct {
947+
PCRE2_SPTR start_eptr;
948+
PCRE2_SPTR byte_map_address;
949+
uint32_t min;
950+
uint32_t max;
951+
} class_repeat;
952+
953+
struct {
954+
PCRE2_SPTR start_eptr;
955+
PCRE2_SPTR xclass_data;
956+
uint32_t min;
957+
uint32_t max;
958+
} xclass_repeat;
959+
960+
struct {
961+
PCRE2_SPTR start_eptr;
962+
PCRE2_SPTR eclass_data;
963+
PCRE2_SIZE eclass_len;
964+
uint32_t min;
965+
uint32_t max;
966+
} eclass_repeat;
967+
968+
struct {
969+
PCRE2_SPTR start_eptr;
970+
uint32_t min;
971+
uint32_t max;
972+
uint32_t ctype;
973+
uint32_t propvalue;
974+
} type_repeat;
975+
976+
struct {
977+
PCRE2_SPTR start;
978+
PCRE2_SIZE offset;
979+
PCRE2_SIZE length;
980+
uint32_t min;
981+
uint32_t max;
982+
uint32_t caseless;
983+
uint32_t caseopts;
984+
} ref_repeat;
985+
986+
struct {
987+
PCRE2_SPTR next_branch; /* Used only in OP_BRA handling */
988+
uint32_t frame_type; /* Set for all that use GROUPLOOP */
989+
} op_bra;
990+
991+
struct {
992+
PCRE2_SPTR next_ecode;
993+
} op_brazero;
994+
995+
struct {
996+
PCRE2_SPTR start_eptr;
997+
PCRE2_SPTR start_group;
998+
uint32_t frame_type;
999+
uint32_t matched_once;
1000+
uint32_t zero_allowed;
1001+
} op_brapos;
1002+
1003+
struct {
1004+
PCRE2_SPTR start_branch;
1005+
uint32_t frame_type;
1006+
} op_recurse;
1007+
1008+
struct {
1009+
uint32_t frame_type;
1010+
} op_assert;
1011+
1012+
struct {
1013+
PCRE2_SPTR saved_end_subject;
1014+
PCRE2_SPTR saved_eptr;
1015+
PCRE2_SIZE true_end_extra;
1016+
uint32_t frame_type;
1017+
uint32_t extra_size;
1018+
uint32_t saved_moptions;
1019+
} op_assert_scs;
1020+
1021+
struct {
1022+
PCRE2_SPTR start_branch;
1023+
PCRE2_SIZE length;
1024+
uint32_t positive;
1025+
} op_cond;
1026+
1027+
struct {
1028+
PCRE2_SPTR eptr;
1029+
uint32_t min;
1030+
uint32_t max;
1031+
} op_vreverse;
1032+
} fields;
1033+
9271034
/* The rest have to be copied from the previous frame whenever a new frame
9281035
becomes current. The final field is specified as a large vector so that
9291036
runtime array bound checks don't catch references to it. However, for any

0 commit comments

Comments
 (0)