Skip to content

Commit

Permalink
regcomp.c: Put common code in a macro
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed Oct 11, 2018
1 parent 0acc902 commit ec5cf66
Showing 1 changed file with 46 additions and 55 deletions.
101 changes: 46 additions & 55 deletions regcomp.c
Expand Up @@ -790,95 +790,86 @@ static const scan_data_t zero_scan_data = {
REPORT_LOCATION_ARGS(RExC_parse)); \ REPORT_LOCATION_ARGS(RExC_parse)); \
} STMT_END } 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 * 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 * 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 * would get output again. So they should be output in pass2, and this
* asserts make sure new warnings follow that paradigm. */ * assert makes sure new warnings follow that paradigm. */
#define _WARN_HELPER(loc, code) \
STMT_START { \
__ASSERT_(PASS2) code; \
} STMT_END


/* m is not necessarily a "literal string", in this macro */ /* m is not necessarily a "literal string", in this macro */
#define reg_warn_non_literal_string(loc, m) STMT_START { \ #define reg_warn_non_literal_string(loc, m) \
__ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_warner(aTHX_ packWARN(WARN_REGEXP), \
"%s" REPORT_LOCATION, \ "%s" REPORT_LOCATION, \
m, REPORT_LOCATION_ARGS(loc)); \ m, REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARNreg(loc,m) STMT_START { \ #define ckWARNreg(loc,m) \
__ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define vWARN(loc, m) STMT_START { \ #define vWARN(loc, m) \
__ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc))) \
} STMT_END


#define vWARN_dep(loc, m) STMT_START { \ #define vWARN_dep(loc, m) \
__ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), \ _WARN_HELPER(loc, Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARNdep(loc,m) STMT_START { \ #define ckWARNdep(loc,m) \
__ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), \ _WARN_HELPER(loc, Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARNregdep(loc,m) STMT_START { \ #define ckWARNregdep(loc,m) \
__ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, \ _WARN_HELPER(loc, Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, \
WARN_REGEXP), \ WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARN2reg_d(loc,m, a1) STMT_START { \ #define ckWARN2reg_d(loc,m, a1) \
__ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_ck_warner_d(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, REPORT_LOCATION_ARGS(loc)); \ a1, REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARN2reg(loc, m, a1) STMT_START { \ #define ckWARN2reg(loc, m, a1) \
__ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, REPORT_LOCATION_ARGS(loc)); \ a1, REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define vWARN3(loc, m, a1, a2) STMT_START { \ #define vWARN3(loc, m, a1, a2) \
__ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, a2, REPORT_LOCATION_ARGS(loc)); \ a1, a2, REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARN3reg(loc, m, a1, a2) STMT_START { \ #define ckWARN3reg(loc, m, a1, a2) \
__ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, a2, \ a1, a2, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define vWARN4(loc, m, a1, a2, a3) STMT_START { \ #define vWARN4(loc, m, a1, a2, a3) \
__ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, a2, a3, \ a1, a2, a3, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define ckWARN4reg(loc, m, a1, a2, a3) STMT_START { \ #define ckWARN4reg(loc, m, a1, a2, a3) \
__ASSERT_(PASS2) Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, a2, a3, \ a1, a2, a3, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


#define vWARN5(loc, m, a1, a2, a3, a4) STMT_START { \ #define vWARN5(loc, m, a1, a2, a3, a4) \
__ASSERT_(PASS2) Perl_warner(aTHX_ packWARN(WARN_REGEXP), \ _WARN_HELPER(loc, Perl_warner(aTHX_ packWARN(WARN_REGEXP), \
m REPORT_LOCATION, \ m REPORT_LOCATION, \
a1, a2, a3, a4, \ a1, a2, a3, a4, \
REPORT_LOCATION_ARGS(loc)); \ REPORT_LOCATION_ARGS(loc)))
} STMT_END


/* Convert between a pointer to a node and its offset from the beginning of the /* Convert between a pointer to a node and its offset from the beginning of the
* program */ * program */
Expand Down

0 comments on commit ec5cf66

Please sign in to comment.