summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-11-07 13:37:12 +0000
committerNicholas Clark <nick@ccl4.org>2009-11-07 15:37:33 +0000
commitf8f98e0a8bdbde83a9cdc3573d818f69d0a64c78 (patch)
treea11a9634e18216edad55a2be0986db162c4a59a8 /pad.c
parenteda4663d0f345e78f0a82529a08f3aa28c98ff2c (diff)
downloadperl-f8f98e0a8bdbde83a9cdc3573d818f69d0a64c78.tar.gz
Add length and flags arguments to Perl_pad_findmy(), moving it to the public API.
Currently no flags bits are used, and the length is cross-checked against strlen() on the pointer, but the intent is to re-work the entire pad API to be UTF-8 aware, from the current situation of char * pointers only.
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/pad.c b/pad.c
index 2e0b863f54..ae69c9e019 100644
--- a/pad.c
+++ b/pad.c
@@ -612,7 +612,7 @@ Returns the offset in the current pad, or NOT_IN_PAD on failure.
*/
PADOFFSET
-Perl_pad_findmy(pTHX_ const char *name)
+Perl_pad_findmy(pTHX_ const char *name, STRLEN len, U32 flags)
{
dVAR;
SV *out_sv;
@@ -624,6 +624,22 @@ Perl_pad_findmy(pTHX_ const char *name)
PERL_ARGS_ASSERT_PAD_FINDMY;
pad_peg("pad_findmy");
+
+ if (flags)
+ Perl_croak(aTHX_ "panic: pad_findmy illegal flag bits 0x%" UVxf,
+ (UV)flags);
+
+ /* Yes, it is a bug (read work in progress) that we're not really using this
+ length parameter, and instead relying on strlen() later on. But I'm not
+ comfortable about changing the pad API piecemeal to use and rely on
+ lengths. This only exists to avoid an "unused parameter" warning. */
+ if (len < 2)
+ return NOT_IN_PAD;
+
+ /* But until we're using the length for real, cross check that we're being
+ told the truth. */
+ assert(strlen(name) == len);
+
offset = pad_findlex(name, PL_compcv, PL_cop_seqmax, 1,
NULL, &out_sv, &out_flags);
if ((PADOFFSET)offset != NOT_IN_PAD)