#define MARK_PUSH(lastmark) \
do if (lastmark >= 0) { \
- i = lastmark; /* ctx->lastmark may change if reallocated */ \
- DATA_STACK_PUSH(state, state->mark, (i+1)*sizeof(void*)); \
+ size_t _marks_size = (lastmark+1) * sizeof(void*); \
+ DATA_STACK_PUSH(state, state->mark, _marks_size); \
} while (0)
#define MARK_POP(lastmark) \
do if (lastmark >= 0) { \
- DATA_STACK_POP(state, state->mark, (lastmark+1)*sizeof(void*), 1); \
+ size_t _marks_size = (lastmark+1) * sizeof(void*); \
+ DATA_STACK_POP(state, state->mark, _marks_size, 1); \
} while (0)
#define MARK_POP_KEEP(lastmark) \
do if (lastmark >= 0) { \
- DATA_STACK_POP(state, state->mark, (lastmark+1)*sizeof(void*), 0); \
+ size_t _marks_size = (lastmark+1) * sizeof(void*); \
+ DATA_STACK_POP(state, state->mark, _marks_size, 0); \
} while (0)
#define MARK_POP_DISCARD(lastmark) \
do if (lastmark >= 0) { \
- DATA_STACK_POP_DISCARD(state, (lastmark+1)*sizeof(void*)); \
+ size_t _marks_size = (lastmark+1) * sizeof(void*); \
+ DATA_STACK_POP_DISCARD(state, _marks_size); \
} while (0)
#define JUMP_NONE 0
ctx->pattern = pattern; \
ctx->ptr = ptr; \
DATA_ALLOC(SRE(match_context), nextctx); \
- nextctx->last_ctx_pos = ctx_pos; \
- nextctx->jump = jumpvalue; \
nextctx->pattern = nextpattern; \
nextctx->toplevel = toplevel_; \
+ nextctx->jump = jumpvalue; \
+ nextctx->last_ctx_pos = ctx_pos; \
pattern = nextpattern; \
ctx_pos = alloc_pos; \
ctx = nextctx; \
DO_JUMPX(jumpvalue, jumplabel, nextpattern, 0)
typedef struct {
- Py_ssize_t last_ctx_pos;
- Py_ssize_t jump;
- const SRE_CHAR* ptr;
- const SRE_CODE* pattern;
Py_ssize_t count;
- Py_ssize_t lastmark;
- Py_ssize_t lastindex;
union {
SRE_CODE chr;
SRE_REPEAT* rep;
} u;
+ int lastmark;
+ int lastindex;
+ const SRE_CODE* pattern;
+ const SRE_CHAR* ptr;
int toplevel;
+ int jump;
+ Py_ssize_t last_ctx_pos;
} SRE(match_context);
#define MAYBE_CHECK_SIGNALS \
{
const SRE_CHAR* end = (const SRE_CHAR *)state->end;
Py_ssize_t alloc_pos, ctx_pos = -1;
- Py_ssize_t i, ret = 0;
- Py_ssize_t jump;
+ Py_ssize_t ret = 0;
+ int jump;
unsigned int sigcount=0;
SRE(match_context)* ctx;
/* <MARK> <gid> */
TRACE(("|%p|%p|MARK %d\n", pattern,
ptr, pattern[0]));
- i = pattern[0];
- if (i & 1)
- state->lastindex = i/2 + 1;
- if (i > state->lastmark) {
- /* state->lastmark is the highest valid index in the
- state->mark array. If it is increased by more than 1,
- the intervening marks must be set to NULL to signal
- that these marks have not been encountered. */
- Py_ssize_t j = state->lastmark + 1;
- while (j < i)
- state->mark[j++] = NULL;
- state->lastmark = i;
+ {
+ int i = pattern[0];
+ if (i & 1)
+ state->lastindex = i/2 + 1;
+ if (i > state->lastmark) {
+ /* state->lastmark is the highest valid index in the
+ state->mark array. If it is increased by more than 1,
+ the intervening marks must be set to NULL to signal
+ that these marks have not been encountered. */
+ int j = state->lastmark + 1;
+ while (j < i)
+ state->mark[j++] = NULL;
+ state->lastmark = i;
+ }
+ state->mark[i] = ptr;
}
- state->mark[i] = ptr;
pattern++;
DISPATCH;
/* match backreference */
TRACE(("|%p|%p|GROUPREF %d\n", pattern,
ptr, pattern[0]));
- i = pattern[0];
{
- Py_ssize_t groupref = i+i;
+ int groupref = pattern[0] * 2;
if (groupref >= state->lastmark) {
RETURN_FAILURE;
} else {
/* match backreference */
TRACE(("|%p|%p|GROUPREF_IGNORE %d\n", pattern,
ptr, pattern[0]));
- i = pattern[0];
{
- Py_ssize_t groupref = i+i;
+ int groupref = pattern[0] * 2;
if (groupref >= state->lastmark) {
RETURN_FAILURE;
} else {
/* match backreference */
TRACE(("|%p|%p|GROUPREF_UNI_IGNORE %d\n", pattern,
ptr, pattern[0]));
- i = pattern[0];
{
- Py_ssize_t groupref = i+i;
+ int groupref = pattern[0] * 2;
if (groupref >= state->lastmark) {
RETURN_FAILURE;
} else {
/* match backreference */
TRACE(("|%p|%p|GROUPREF_LOC_IGNORE %d\n", pattern,
ptr, pattern[0]));
- i = pattern[0];
{
- Py_ssize_t groupref = i+i;
+ int groupref = pattern[0] * 2;
if (groupref >= state->lastmark) {
RETURN_FAILURE;
} else {
TRACE(("|%p|%p|GROUPREF_EXISTS %d\n", pattern,
ptr, pattern[0]));
/* <GROUPREF_EXISTS> <group> <skip> codeyes <JUMP> codeno ... */
- i = pattern[0];
{
- Py_ssize_t groupref = i+i;
+ int groupref = pattern[0] * 2;
if (groupref >= state->lastmark) {
pattern += pattern[1];
DISPATCH;