diff --git a/src/pcre2.h.in b/src/pcre2.h.in index d351bf7..969df6c 100644 --- a/src/pcre2.h.in +++ b/src/pcre2.h.in @@ -313,22 +313,20 @@ versions are generated from this macro below. */ #define PCRE2_STRUCTURE_LIST \ typedef struct pcre2_callout_block { \ - int version; /* Identifies version of block */ \ + uint32_t version; /* Identifies version of block */ \ /* ------------------------ Version 0 ------------------------------- */ \ uint32_t callout_number; /* Number compiled into pattern */ \ + uint32_t capture_top; /* Max current capture */ \ + uint32_t capture_last; /* Most recently closed capture */ \ + void *callout_data; /* Data passed in with the call */ \ PCRE2_SIZE *offset_vector; /* The offset vector */ \ + PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \ PCRE2_SPTR subject; /* The subject being matched */ \ PCRE2_SIZE subject_length; /* The length of the subject */ \ PCRE2_SIZE start_match; /* Offset to start of this match attempt */ \ PCRE2_SIZE current_position; /* Where we currently are in the subject */ \ - uint32_t capture_top; /* Max current capture */ \ - uint32_t capture_last; /* Most recently closed capture */ \ - void *callout_data; /* Data passed in with the call */ \ - /* ------------------- Added for Version 1 -------------------------- */ \ PCRE2_SIZE pattern_position; /* Offset to next item in the pattern */ \ PCRE2_SIZE next_item_length; /* Length of next item in the pattern */ \ - /* ------------------- Added for Version 2 -------------------------- */ \ - PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \ /* ------------------------------------------------------------------ */ \ } pcre2_callout_block; @@ -641,7 +639,7 @@ PCRE2_SUFFIX a no-op. Otherwise, generate an error. */ #define PCRE2_SUFFIX(a) a #else #error PCRE2_CODE_UNIT_WIDTH must be 0, 8, 16, or 32. -#endif +#endif #endif /* PCRE2_CODE_UNIT_WIDTH is defined */ #ifdef __cplusplus diff --git a/src/pcre2_dfa_match.c b/src/pcre2_dfa_match.c index afe5f7b..5d9c59e 100644 --- a/src/pcre2_dfa_match.c +++ b/src/pcre2_dfa_match.c @@ -2612,19 +2612,19 @@ for (;;) if (mb->callout != NULL) { pcre2_callout_block cb; - cb.version = 1; /* Version 1 of the callout block */ + cb.version = 0; cb.callout_number = code[LINK_SIZE+2]; + cb.capture_top = 1; + cb.capture_last = 0; + cb.callout_data = mb->callout_data; cb.offset_vector = offsets; + cb.mark = NULL; /* No (*MARK) support */ cb.subject = start_subject; cb.subject_length = (PCRE2_SIZE)(end_subject - start_subject); cb.start_match = (PCRE2_SIZE)(current_subject - start_subject); cb.current_position = (PCRE2_SIZE)(ptr - start_subject); cb.pattern_position = GET(code, LINK_SIZE + 3); cb.next_item_length = GET(code, 3 + 2*LINK_SIZE); - cb.capture_top = 1; - cb.capture_last = -1; - cb.callout_data = mb->callout_data; - cb.mark = NULL; /* No (*MARK) support */ if ((rrc = (mb->callout)(&cb)) < 0) return rrc; /* Abandon */ } if (rrc > 0) break; /* Fail this thread */ @@ -2959,19 +2959,19 @@ for (;;) if (mb->callout != NULL) { pcre2_callout_block cb; - cb.version = 1; /* Version 1 of the callout block */ + cb.version = 0; cb.callout_number = code[1]; + cb.capture_top = 1; + cb.capture_last = 0; + cb.callout_data = mb->callout_data; cb.offset_vector = offsets; + cb.mark = NULL; /* No (*MARK) support */ cb.subject = start_subject; cb.subject_length = (PCRE2_SIZE)(end_subject - start_subject); cb.start_match = (PCRE2_SIZE)(current_subject - start_subject); cb.current_position = (PCRE2_SIZE)(ptr - start_subject); cb.pattern_position = GET(code, 2); cb.next_item_length = GET(code, 2 + LINK_SIZE); - cb.capture_top = 1; - cb.capture_last = -1; - cb.callout_data = mb->callout_data; - cb.mark = NULL; /* No (*MARK) support */ if ((rrc = (mb->callout)(&cb)) < 0) return rrc; /* Abandon */ } if (rrc == 0) diff --git a/src/pcre2_match.c b/src/pcre2_match.c index c5760fe..88c2d14 100644 --- a/src/pcre2_match.c +++ b/src/pcre2_match.c @@ -1307,19 +1307,19 @@ for (;;) if (mb->callout != NULL) { pcre2_callout_block cb; - cb.version = 2; /* Version 1 of the callout block */ + cb.version = 0; cb.callout_number = ecode[1]; + cb.capture_top = offset_top/2; + cb.capture_last = mb->capture_last & CAPLMASK; + cb.callout_data = mb->callout_data; cb.offset_vector = mb->ovector; + cb.mark = mb->nomatch_mark; cb.subject = mb->start_subject; cb.subject_length = (PCRE2_SIZE)(mb->end_subject - mb->start_subject); cb.start_match = (PCRE2_SIZE)(mstart - mb->start_subject); cb.current_position = (PCRE2_SIZE)(eptr - mb->start_subject); cb.pattern_position = GET(ecode, 2); cb.next_item_length = GET(ecode, 2 + LINK_SIZE); - cb.capture_top = offset_top/2; - cb.capture_last = mb->capture_last & CAPLMASK; - cb.callout_data = mb->callout_data; - cb.mark = mb->nomatch_mark; if ((rrc = mb->callout(&cb)) > 0) RRETURN(MATCH_NOMATCH); if (rrc < 0) RRETURN(rrc); } @@ -1697,19 +1697,19 @@ for (;;) if (mb->callout != NULL) { pcre2_callout_block cb; - cb.version = 2; /* Version 1 of the callout block */ + cb.version = 0; cb.callout_number = ecode[1]; + cb.capture_top = offset_top/2; + cb.capture_last = mb->capture_last & CAPLMASK; + cb.callout_data = mb->callout_data; cb.offset_vector = mb->ovector; + cb.mark = mb->nomatch_mark; cb.subject = mb->start_subject; cb.subject_length = (PCRE2_SIZE)(mb->end_subject - mb->start_subject); cb.start_match = (PCRE2_SIZE)(mstart - mb->start_subject); cb.current_position = (PCRE2_SIZE)(eptr - mb->start_subject); cb.pattern_position = GET(ecode, 2); cb.next_item_length = GET(ecode, 2 + LINK_SIZE); - cb.capture_top = offset_top/2; - cb.capture_last = mb->capture_last & CAPLMASK; - cb.callout_data = mb->callout_data; - cb.mark = mb->nomatch_mark; if ((rrc = mb->callout(&cb)) > 0) RRETURN(MATCH_NOMATCH); if (rrc < 0) RRETURN(rrc); }