summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-10-02 12:33:01 -0600
committerKarl Williamson <khw@cpan.org>2019-11-06 21:22:24 -0700
commitf534d5462959256391e14ee587e98cbc036c9e4a (patch)
tree7b017a252461ebc1fc20ffd214ae519663c70e30
parentdc8faf6bad9ccc8bd6101ba9aa256e7146845799 (diff)
downloadperl-f534d5462959256391e14ee587e98cbc036c9e4a.tar.gz
doop.c: Add a parameter to a few fcns
instead of deriving it each time from inside the function. This is in preparation for future commits.
-rw-r--r--doop.c24
-rw-r--r--embed.fnc6
-rw-r--r--embed.h6
-rw-r--r--proto.h12
4 files changed, 18 insertions, 30 deletions
diff --git a/doop.c b/doop.c
index 88e0c317c6..483d261845 100644
--- a/doop.c
+++ b/doop.c
@@ -36,19 +36,15 @@
*/
STATIC Size_t
-S_do_trans_simple(pTHX_ SV * const sv)
+S_do_trans_simple(pTHX_ SV * const sv, const OPtrans_map * const tbl)
{
Size_t matches = 0;
STRLEN len;
U8 *s = (U8*)SvPV_nomg(sv,len);
U8 * const send = s+len;
- const OPtrans_map * const tbl = (OPtrans_map*)cPVOP->op_pv;
PERL_ARGS_ASSERT_DO_TRANS_SIMPLE;
- if (!tbl)
- Perl_croak(aTHX_ "panic: do_trans_simple line %d",__LINE__);
-
/* First, take care of non-UTF-8 input strings, because they're easy */
if (!SvUTF8(sv)) {
while (s < send) {
@@ -115,19 +111,15 @@ S_do_trans_simple(pTHX_ SV * const sv)
*/
STATIC Size_t
-S_do_trans_count(pTHX_ SV * const sv)
+S_do_trans_count(pTHX_ SV * const sv, const OPtrans_map * const tbl)
{
STRLEN len;
const U8 *s = (const U8*)SvPV_nomg_const(sv, len);
const U8 * const send = s + len;
Size_t matches = 0;
- const OPtrans_map * const tbl = (OPtrans_map*)cPVOP->op_pv;
PERL_ARGS_ASSERT_DO_TRANS_COUNT;
- if (!tbl)
- Perl_croak(aTHX_ "panic: do_trans_count line %d",__LINE__);
-
if (!SvUTF8(sv)) {
while (s < send) {
if (tbl->map[*s++] >= 0)
@@ -160,19 +152,15 @@ S_do_trans_count(pTHX_ SV * const sv)
*/
STATIC Size_t
-S_do_trans_complex(pTHX_ SV * const sv)
+S_do_trans_complex(pTHX_ SV * const sv, const OPtrans_map * const tbl)
{
STRLEN len;
U8 *s = (U8*)SvPV_nomg(sv, len);
U8 * const send = s+len;
Size_t matches = 0;
- const OPtrans_map * const tbl = (OPtrans_map*)cPVOP->op_pv;
PERL_ARGS_ASSERT_DO_TRANS_COMPLEX;
- if (!tbl)
- Perl_croak(aTHX_ "panic: do_trans_complex line %d",__LINE__);
-
if (!SvUTF8(sv)) {
U8 *d = s;
U8 * const dstart = d;
@@ -636,11 +624,11 @@ Perl_do_trans(pTHX_ SV *sv)
* we must also rely on it to choose the readonly strategy.
*/
if (flags & OPpTRANS_IDENTICAL) {
- return hasutf ? do_trans_count_utf8(sv) : do_trans_count(sv);
+ return hasutf ? do_trans_count_utf8(sv) : do_trans_count(sv, (OPtrans_map*)cPVOP->op_pv);
} else if (flags & (OPpTRANS_SQUASH|OPpTRANS_DELETE|OPpTRANS_COMPLEMENT)) {
- return hasutf ? do_trans_complex_utf8(sv) : do_trans_complex(sv);
+ return hasutf ? do_trans_complex_utf8(sv) : do_trans_complex(sv, (OPtrans_map*)cPVOP->op_pv);
} else {
- return hasutf ? do_trans_simple_utf8(sv) : do_trans_simple(sv);
+ return hasutf ? do_trans_simple_utf8(sv) : do_trans_simple(sv, (OPtrans_map*)cPVOP->op_pv);
}
}
diff --git a/embed.fnc b/embed.fnc
index 0950aebd95..3b678c16a2 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -2302,9 +2302,9 @@ Adp |int |nothreadhook
p |void |init_constants
#if defined(PERL_IN_DOOP_C)
-SR |Size_t |do_trans_simple |NN SV * const sv
-SR |Size_t |do_trans_count |NN SV * const sv
-SR |Size_t |do_trans_complex |NN SV * const sv
+SR |Size_t |do_trans_simple |NN SV * const sv|NN const OPtrans_map * const tbl
+SR |Size_t |do_trans_count |NN SV * const sv|NN const OPtrans_map * const tbl
+SR |Size_t |do_trans_complex |NN SV * const sv|NN const OPtrans_map * const tbl
SR |Size_t |do_trans_simple_utf8 |NN SV * const sv
SR |Size_t |do_trans_count_utf8 |NN SV * const sv
SR |Size_t |do_trans_complex_utf8 |NN SV * const sv
diff --git a/embed.h b/embed.h
index ae4794f51a..44f50f1d20 100644
--- a/embed.h
+++ b/embed.h
@@ -1601,11 +1601,11 @@
#define openn_setup(a,b,c,d,e,f) S_openn_setup(aTHX_ a,b,c,d,e,f)
# endif
# if defined(PERL_IN_DOOP_C)
-#define do_trans_complex(a) S_do_trans_complex(aTHX_ a)
+#define do_trans_complex(a,b) S_do_trans_complex(aTHX_ a,b)
#define do_trans_complex_utf8(a) S_do_trans_complex_utf8(aTHX_ a)
-#define do_trans_count(a) S_do_trans_count(aTHX_ a)
+#define do_trans_count(a,b) S_do_trans_count(aTHX_ a,b)
#define do_trans_count_utf8(a) S_do_trans_count_utf8(aTHX_ a)
-#define do_trans_simple(a) S_do_trans_simple(aTHX_ a)
+#define do_trans_simple(a,b) S_do_trans_simple(aTHX_ a,b)
#define do_trans_simple_utf8(a) S_do_trans_simple_utf8(aTHX_ a)
# endif
# if defined(PERL_IN_DUMP_C)
diff --git a/proto.h b/proto.h
index 9ba4dd9251..4520772315 100644
--- a/proto.h
+++ b/proto.h
@@ -4851,30 +4851,30 @@ STATIC IO * S_openn_setup(pTHX_ GV *gv, char *mode, PerlIO **saveifp, PerlIO **s
assert(gv); assert(mode); assert(saveifp); assert(saveofp); assert(savefd); assert(savetype)
#endif
#if defined(PERL_IN_DOOP_C)
-STATIC Size_t S_do_trans_complex(pTHX_ SV * const sv)
+STATIC Size_t S_do_trans_complex(pTHX_ SV * const sv, const OPtrans_map * const tbl)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_DO_TRANS_COMPLEX \
- assert(sv)
+ assert(sv); assert(tbl)
STATIC Size_t S_do_trans_complex_utf8(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_DO_TRANS_COMPLEX_UTF8 \
assert(sv)
-STATIC Size_t S_do_trans_count(pTHX_ SV * const sv)
+STATIC Size_t S_do_trans_count(pTHX_ SV * const sv, const OPtrans_map * const tbl)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_DO_TRANS_COUNT \
- assert(sv)
+ assert(sv); assert(tbl)
STATIC Size_t S_do_trans_count_utf8(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_DO_TRANS_COUNT_UTF8 \
assert(sv)
-STATIC Size_t S_do_trans_simple(pTHX_ SV * const sv)
+STATIC Size_t S_do_trans_simple(pTHX_ SV * const sv, const OPtrans_map * const tbl)
__attribute__warn_unused_result__;
#define PERL_ARGS_ASSERT_DO_TRANS_SIMPLE \
- assert(sv)
+ assert(sv); assert(tbl)
STATIC Size_t S_do_trans_simple_utf8(pTHX_ SV * const sv)
__attribute__warn_unused_result__;