From f8220fe23fc461dfb1ca2485af368876e65be2d1 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 8 Oct 2018 07:06:52 -0600 Subject: [PATCH] regcomp.c: Put common code in a macro This trivial code is extracted into a common macro in preparation for a future commit when it will become non-trivial, and hence that logic will only have to occur once. --- regcomp.c | 114 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 59 insertions(+), 55 deletions(-) diff --git a/regcomp.c b/regcomp.c index 13295d0..703c3c3 100644 --- a/regcomp.c +++ b/regcomp.c @@ -791,95 +791,99 @@ static const scan_data_t zero_scan_data = { REPORT_LOCATION_ARGS(RExC_parse)); \ } STMT_END -/* These have asserts in them because of [perl #122671] Many warnings in +/* This has an assert in it because of [perl #122671] Many warnings in * regcomp.c can occur twice. If they get output in pass1 and later in that * pass, the pattern has to be converted to UTF-8 and the pass restarted, they - * would get output again. So they should be output in pass2, and these - * asserts make sure new warnings follow that paradigm. */ + * would get output again. So they should be output in pass2, and this + * assert makes sure new warnings follow that paradigm. */ +#define _WARN_HELPER(loc, warns, code) \ + STMT_START { \ + __ASSERT_(PASS2) code; \ + } STMT_END /* m is not necessarily a "literal string", in this macro */ -#define reg_warn_non_literal_string(loc, m) STMT_START { \ - __ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define reg_warn_non_literal_string(loc, m) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ "%s" REPORT_LOCATION, \ - m, REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + m, REPORT_LOCATION_ARGS(loc))) -#define ckWARNreg(loc,m) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define ckWARNreg(loc,m) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define vWARN(loc, m) STMT_START { \ - __ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define vWARN(loc, m) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) \ -#define vWARN_dep(loc, m) STMT_START { \ - __ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), \ +#define vWARN_dep(loc, m) \ + _WARN_HELPER(loc, packWARN(WARN_DEPRECATED), \ + Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), \ m REPORT_LOCATION, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define ckWARNdep(loc,m) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), \ +#define ckWARNdep(loc,m) \ + _WARN_HELPER(loc, packWARN(WARN_DEPRECATED), \ + Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), \ m REPORT_LOCATION, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define ckWARNregdep(loc,m) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, \ +#define ckWARNregdep(loc,m) \ + _WARN_HELPER(loc, packWARN2(WARN_DEPRECATED, WARN_REGEXP), \ + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, \ WARN_REGEXP), \ m REPORT_LOCATION, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define ckWARN2reg_d(loc,m, a1) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN(WARN_REGEXP), \ +#define ckWARN2reg_d(loc,m, a1) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_ck_warner_d(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ - a1, REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + a1, REPORT_LOCATION_ARGS(loc))) -#define ckWARN2reg(loc, m, a1) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define ckWARN2reg(loc, m, a1) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ - a1, REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + a1, REPORT_LOCATION_ARGS(loc))) -#define vWARN3(loc, m, a1, a2) STMT_START { \ - __ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define vWARN3(loc, m, a1, a2) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ - a1, a2, REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + a1, a2, REPORT_LOCATION_ARGS(loc))) -#define ckWARN3reg(loc, m, a1, a2) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define ckWARN3reg(loc, m, a1, a2) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ a1, a2, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define vWARN4(loc, m, a1, a2, a3) STMT_START { \ - __ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define vWARN4(loc, m, a1, a2, a3) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ a1, a2, a3, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define ckWARN4reg(loc, m, a1, a2, a3) STMT_START { \ - __ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define ckWARN4reg(loc, m, a1, a2, a3) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ a1, a2, a3, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) -#define vWARN5(loc, m, a1, a2, a3, a4) STMT_START { \ - __ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ +#define vWARN5(loc, m, a1, a2, a3, a4) \ + _WARN_HELPER(loc, packWARN(WARN_REGEXP), \ + Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ m REPORT_LOCATION, \ a1, a2, a3, a4, \ - REPORT_LOCATION_ARGS(loc)); \ -} STMT_END + REPORT_LOCATION_ARGS(loc))) /* Convert between a pointer to a node and its offset from the beginning of the * program */ -- 1.8.3.1