Reduce `if` for decreasing counter on OP_REPEAT_INC (#9393)

This commit also reduces the warning `'stkp' may be used
uninitialized in this function`.
This commit is contained in:
Hiroya Fujinami 2023-12-30 01:08:51 +09:00 коммит произвёл GitHub
Родитель 0c923fed7d
Коммит 2571d5376a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -2531,6 +2531,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
#define MATCH_CACHE_DEBUG_HIT ((void) 0) #define MATCH_CACHE_DEBUG_HIT ((void) 0)
#endif #endif
#define MATCH_CACHE_HIT ((void) 0)
# define CHECK_MATCH_CACHE do {\ # define CHECK_MATCH_CACHE do {\
if (msa->match_cache_status == MATCH_CACHE_STATUS_ENABLED) {\ if (msa->match_cache_status == MATCH_CACHE_STATUS_ENABLED) {\
const OnigCacheOpcode *cache_opcode;\ const OnigCacheOpcode *cache_opcode;\
@ -2541,8 +2543,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
uint8_t match_cache_point_mask = 1 << (match_cache_point & 7);\ uint8_t match_cache_point_mask = 1 << (match_cache_point & 7);\
MATCH_CACHE_DEBUG;\ MATCH_CACHE_DEBUG;\
if (msa->match_cache_buf[match_cache_point_index] & match_cache_point_mask) {\ if (msa->match_cache_buf[match_cache_point_index] & match_cache_point_mask) {\
MATCH_CACHE_DEBUG_HIT;\ MATCH_CACHE_DEBUG_HIT; MATCH_CACHE_HIT;\
if (*pbegin == OP_REPEAT_INC) stkp->u.repeat.count--;\
if (cache_opcode->lookaround_nesting == 0) goto fail;\ if (cache_opcode->lookaround_nesting == 0) goto fail;\
else if (cache_opcode->lookaround_nesting < 0) {\ else if (cache_opcode->lookaround_nesting < 0) {\
if (check_extended_match_cache_point(msa->match_cache_buf, match_cache_point_index, match_cache_point_mask)) {\ if (check_extended_match_cache_point(msa->match_cache_buf, match_cache_point_index, match_cache_point_mask)) {\
@ -3814,9 +3815,15 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
/* end of repeat. Nothing to do. */ /* end of repeat. Nothing to do. */
} }
else if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) { else if (stkp->u.repeat.count >= reg->repeat_range[mem].lower) {
#ifdef USE_MATCH_CACHE
if (*pbegin == OP_REPEAT_INC) { if (*pbegin == OP_REPEAT_INC) {
#undef MATCH_CACHE_HIT
#define MATCH_CACHE_HIT stkp->u.repeat.count--;
CHECK_MATCH_CACHE; CHECK_MATCH_CACHE;
#undef MATCH_CACHE_HIT
#define MATCH_CACHE_HIT ((void) 0)
} }
#endif
STACK_PUSH_ALT(p, s, sprev, pkeep); STACK_PUSH_ALT(p, s, sprev, pkeep);
p = STACK_AT(si)->u.repeat.pcode; /* Don't use stkp after PUSH. */ p = STACK_AT(si)->u.repeat.pcode; /* Don't use stkp after PUSH. */
} }