From: K.Kosako Date: Thu, 8 Mar 2018 05:29:02 +0000 (+0900) Subject: allow abbreviated notation for callouts of contents in condition (?(?{...})...|...) X-Git-Tag: v6.8.0~36 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a31a0a9f794f486263c6bfd80804407e788b6be;p=onig allow abbreviated notation for callouts of contents in condition (?(?{...})...|...) --- diff --git a/src/regparse.c b/src/regparse.c index c981069..dd2d9d4 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -7205,6 +7205,22 @@ parse_enclosure(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, if (c != ')') goto err_if_else; } } +#ifdef USE_CALLOUT + else if (c == '?') { + if (IS_SYNTAX_OP2(env->syntax, + ONIG_SYN_OP2_QMARK_BRACE_CALLOUT_CONTENTS)) { + if (! PEND && PPEEK_IS('{')) { + /* condition part is callouts of contents: (?(?{...})THEN|ELSE) */ + condition_is_checker = 0; + PFETCH(c); + r = parse_callout_of_contents(&condition, ')', &p, end, env); + if (r != 0) return r; + goto end_condition; + } + } + goto any_condition; + } +#endif else { any_condition: PUNFETCH; @@ -7218,6 +7234,7 @@ parse_enclosure(Node** np, OnigToken* tok, int term, UChar** src, UChar* end, } } + end_condition: CHECK_NULL_RETURN_MEMERR(condition); if (PEND) {