diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-11-07 13:37:12 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-11-07 15:37:33 +0000 |
commit | f8f98e0a8bdbde83a9cdc3573d818f69d0a64c78 (patch) | |
tree | a11a9634e18216edad55a2be0986db162c4a59a8 /pad.c | |
parent | eda4663d0f345e78f0a82529a08f3aa28c98ff2c (diff) | |
download | perl-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.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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) |