From: K.Kosako Date: Thu, 8 Mar 2018 04:21:45 +0000 (+0900) Subject: set slot 1 and 2 in (*COUNT) and (*TOTAL_COUNT) X-Git-Tag: v6.8.0~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a49734ee581e0d32ada34dbcbfcae9ff9d3bc20d;p=onig set slot 1 and 2 in (*COUNT) and (*TOTAL_COUNT) --- diff --git a/src/regexec.c b/src/regexec.c index d484500..c532322 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -5351,28 +5351,41 @@ onig_builtin_total_count(OnigCalloutArgs* args, void* user_data ARG_UNUSED) if (count_type != '>' && count_type != 'X' && count_type != '<') return ONIGERR_INVALID_CALLOUT_ARG; - slot = 0; - r = onig_get_callout_data_by_callout_args_self_dont_clear_old(args, slot, + r = onig_get_callout_data_by_callout_args_self_dont_clear_old(args, 0, &type, &val); if (r < ONIG_NORMAL) return r; else if (r > ONIG_NORMAL) { /* type == void: initial state */ - type = ONIG_TYPE_LONG; val.l = 0; } if (args->in == ONIG_CALLOUT_IN_RETRACTION) { + slot = 2; if (count_type == '<') val.l++; else if (count_type == 'X') val.l--; } else { + slot = 1; if (count_type != '<') val.l++; } + r = onig_set_callout_data_by_callout_args_self(args, 0, ONIG_TYPE_LONG, &val); + if (r != ONIG_NORMAL) return r; + + /* slot 1: in progress counter, slot 2: in retraction counter */ + r = onig_get_callout_data_by_callout_args_self_dont_clear_old(args, slot, + &type, &val); + if (r < ONIG_NORMAL) + return r; + else if (r > ONIG_NORMAL) { + val.l = 0; + } + + val.l++; r = onig_set_callout_data_by_callout_args_self(args, slot, ONIG_TYPE_LONG, &val); if (r != ONIG_NORMAL) return r;