summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/pods/perlapi.pod
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/pods/perlapi.pod')
-rw-r--r--Master/tlpkg/tlperl/lib/pods/perlapi.pod2168
1 files changed, 1692 insertions, 476 deletions
diff --git a/Master/tlpkg/tlperl/lib/pods/perlapi.pod b/Master/tlpkg/tlperl/lib/pods/perlapi.pod
index 5c7a2b98bfd..57ddb06f97f 100644
--- a/Master/tlpkg/tlperl/lib/pods/perlapi.pod
+++ b/Master/tlpkg/tlperl/lib/pods/perlapi.pod
@@ -12,7 +12,7 @@ perlapi - autogenerated documentation for the perl public API
X<Perl API> X<API> X<api>
This file contains the documentation of the perl public API generated by
-embed.pl, specifically a listing of functions, macros, flags, and variables
+F<embed.pl>, specifically a listing of functions, macros, flags, and variables
that may be used by extension writers. L<At the end|/Undocumented functions>
is a list of functions which have yet to be documented. The interfaces of
those are subject to change without notice. Any functions not listed here are
@@ -151,8 +151,11 @@ Found in file av.h
=item av_clear
X<av_clear>
-Clears an array, making it empty. Does not free the memory used by the
-array itself. Perl equivalent: C<@myarray = ();>.
+Clears an array, making it empty. Does not free the memory the av uses to
+store its list of scalars. If any destructors are triggered as a result,
+the av itself may be freed when this function returns.
+
+Perl equivalent: C<@myarray = ();>.
void av_clear(AV *av)
@@ -168,7 +171,8 @@ A small internal helper function to remove a commonly duplicated idiom.
NOTE: this function is experimental and may change or be
removed without notice.
- void av_create_and_push(AV **const avp, SV *const val)
+ void av_create_and_push(AV **const avp,
+ SV *const val)
=for hackers
Found in file av.c
@@ -183,7 +187,8 @@ A small internal helper function to remove a commonly duplicated idiom.
NOTE: this function is experimental and may change or be
removed without notice.
- SV** av_create_and_unshift_one(AV **const avp, SV *const val)
+ SV** av_create_and_unshift_one(AV **const avp,
+ SV *const val)
=for hackers
Found in file av.c
@@ -240,6 +245,7 @@ See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
more information on how to use this function on tied arrays.
The rough perl equivalent is C<$myarray[$idx]>.
+
SV** av_fetch(AV *av, I32 key, I32 lval)
=for hackers
@@ -295,6 +301,8 @@ X<av_pop>
Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array
is empty.
+Perl equivalent: C<pop(@myarray);>
+
SV* av_pop(AV *av)
=for hackers
@@ -304,7 +312,9 @@ Found in file av.c
X<av_push>
Pushes an SV onto the end of the array. The array will grow automatically
-to accommodate the addition. This takes ownership of one reference count.
+to accommodate the addition. This takes ownership of one reference count.
+
+Perl equivalent: C<push @myarray, $elem;>.
void av_push(AV *av, SV *val)
@@ -314,9 +324,12 @@ Found in file av.c
=item av_shift
X<av_shift>
-Shifts an SV off the beginning of the array. Returns C<&PL_sv_undef> if the
+Shifts an SV off the beginning of the
+array. Returns C<&PL_sv_undef> if the
array is empty.
+Perl equivalent: C<shift(@myarray);>
+
SV* av_shift(AV *av)
=for hackers
@@ -328,11 +341,16 @@ X<av_store>
Stores an SV in an array. The array index is specified as C<key>. The
return value will be NULL if the operation failed or if the value did not
need to be actually stored within the array (as in the case of tied
-arrays). Otherwise it can be dereferenced to get the original C<SV*>. Note
-that the caller is responsible for suitably incrementing the reference
+arrays). Otherwise, it can be dereferenced
+to get the C<SV*> that was stored
+there (= C<val>)).
+
+Note that the caller is responsible for suitably incrementing the reference
count of C<val> before the call, and decrementing it if the function
returned NULL.
+Approximate Perl equivalent: C<$myarray[$key] = $val;>.
+
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
more information on how to use this function on tied arrays.
@@ -344,7 +362,9 @@ Found in file av.c
=item av_undef
X<av_undef>
-Undefines the array. Frees the memory used by the array itself.
+Undefines the array. Frees the memory used by the av to store its list of
+scalars. If any destructors are triggered as a result, the av itself may
+be freed.
void av_undef(AV *av)
@@ -358,6 +378,8 @@ Unshift the given number of C<undef> values onto the beginning of the
array. The array will grow automatically to accommodate the addition. You
must then use C<av_store> to assign values to these new elements.
+Perl equivalent: C<unshift @myarray, ( (undef) x $n );>
+
void av_unshift(AV *av, I32 num)
=for hackers
@@ -366,11 +388,14 @@ Found in file av.c
=item get_av
X<get_av>
-Returns the AV of the specified Perl array. C<flags> are passed to
-C<gv_fetchpv>. If C<GV_ADD> is set and the
+Returns the AV of the specified Perl global or package array with the given
+name (so it won't work on lexical variables). C<flags> are passed
+to C<gv_fetchpv>. If C<GV_ADD> is set and the
Perl variable does not exist then it will be created. If C<flags> is zero
and the variable does not exist then NULL is returned.
+Perl equivalent: C<@{"$name"}>.
+
NOTE: the perl_ form of this function is deprecated.
AV* get_av(const char *name, I32 flags)
@@ -383,6 +408,8 @@ X<newAV>
Creates a new AV. The reference count is set to 1.
+Perl equivalent: C<my @array;>.
+
AV* newAV()
=for hackers
@@ -398,7 +425,8 @@ Sort an array. Here is an example:
Currently this always uses mergesort. See sortsv_flags for a more
flexible routine.
- void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp)
+ void sortsv(SV** array, size_t num_elts,
+ SVCOMPARE_t cmp)
=for hackers
Found in file pp_sort.c
@@ -408,7 +436,8 @@ X<sortsv_flags>
Sort an array, with various options.
- void sortsv_flags(SV** array, size_t num_elts, SVCOMPARE_t cmp, U32 flags)
+ void sortsv_flags(SV** array, size_t num_elts,
+ SVCOMPARE_t cmp, U32 flags)
=for hackers
Found in file pp_sort.c
@@ -423,11 +452,15 @@ Found in file pp_sort.c
=item call_argv
X<call_argv>
-Performs a callback to the specified Perl sub. See L<perlcall>.
+Performs a callback to the specified named and package-scoped Perl subroutine
+with C<argv> (a NULL-terminated array of strings) as arguments. See L<perlcall>.
+
+Approximate Perl equivalent: C<&{"$sub_name"}(@$argv)>.
NOTE: the perl_ form of this function is deprecated.
- I32 call_argv(const char* sub_name, I32 flags, char** argv)
+ I32 call_argv(const char* sub_name, I32 flags,
+ char** argv)
=for hackers
Found in file perl.c
@@ -575,7 +608,7 @@ There are three variants for all the functions in this section. The base ones
operate using the character set of the platform Perl is running on. The ones
with an C<_A> suffix operate on the ASCII character set, and the ones with an
C<_L1> suffix operate on the full Latin1 character set. All are unaffected by
-locale
+locale and by C<use bytes>.
For ASCII platforms, the base function with no suffix and the one with the
C<_A> suffix are identical. The function with the C<_L1> suffix imposes the
@@ -734,19 +767,19 @@ ready to run at the exact same point as the previous one.
The pseudo-fork code uses COPY_STACKS while the
threads->create doesn't.
-CLONEf_KEEP_PTR_TABLE
+CLONEf_KEEP_PTR_TABLE -
perl_clone keeps a ptr_table with the pointer of the old
variable as a key and the new variable as a value,
this allows it to check if something has been cloned and not
clone it again but rather just use the value and increase the
-refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill
+refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill
the ptr_table using the function
C<ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;>,
reason to keep it around is if you want to dup some of your own
variable who are outside the graph perl scans, example of this
-code is in threads.xs create
+code is in threads.xs create.
-CLONEf_CLONE_HOST
+CLONEf_CLONE_HOST -
This is a win32 thing, it is ignored on unix, it tells perls
win32host code (which is c++) to clone itself, this is needed on
win32 if you want to run two threads at the same time,
@@ -754,7 +787,10 @@ if you just want to do some stuff in a separate perl interpreter
and then throw it away and return to the original one,
you don't need to do anything.
- PerlInterpreter* perl_clone(PerlInterpreter *proto_perl, UV flags)
+ PerlInterpreter* perl_clone(
+ PerlInterpreter *proto_perl,
+ UV flags
+ )
=for hackers
Found in file sv.c
@@ -872,7 +908,9 @@ a string/length pair.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_delete_pv(const COPHH *cophh, const char *key, U32 hash, U32 flags)
+ COPHH * cophh_delete_pv(const COPHH *cophh,
+ const char *key, U32 hash,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -894,7 +932,10 @@ hash of the key string, or zero if it has not been precomputed.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_delete_pvn(COPHH *cophh, const char *keypv, STRLEN keylen, U32 hash, U32 flags)
+ COPHH * cophh_delete_pvn(COPHH *cophh,
+ const char *keypv,
+ STRLEN keylen, U32 hash,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -908,7 +949,8 @@ string/length pair, and no precomputed hash.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_delete_pvs(const COPHH *cophh, const char *key, U32 flags)
+ COPHH * cophh_delete_pvs(const COPHH *cophh,
+ const char *key, U32 flags)
=for hackers
Found in file cop.h
@@ -922,7 +964,8 @@ string/length pair.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_delete_sv(const COPHH *cophh, SV *key, U32 hash, U32 flags)
+ COPHH * cophh_delete_sv(const COPHH *cophh, SV *key,
+ U32 hash, U32 flags)
=for hackers
Found in file cop.h
@@ -936,7 +979,9 @@ a string/length pair.
NOTE: this function is experimental and may change or be
removed without notice.
- SV * cophh_fetch_pv(const COPHH *cophh, const char *key, U32 hash, U32 flags)
+ SV * cophh_fetch_pv(const COPHH *cophh,
+ const char *key, U32 hash,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -955,7 +1000,10 @@ associated with the key.
NOTE: this function is experimental and may change or be
removed without notice.
- SV * cophh_fetch_pvn(const COPHH *cophh, const char *keypv, STRLEN keylen, U32 hash, U32 flags)
+ SV * cophh_fetch_pvn(const COPHH *cophh,
+ const char *keypv,
+ STRLEN keylen, U32 hash,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -969,7 +1017,8 @@ string/length pair, and no precomputed hash.
NOTE: this function is experimental and may change or be
removed without notice.
- SV * cophh_fetch_pvs(const COPHH *cophh, const char *key, U32 flags)
+ SV * cophh_fetch_pvs(const COPHH *cophh,
+ const char *key, U32 flags)
=for hackers
Found in file cop.h
@@ -983,7 +1032,8 @@ string/length pair.
NOTE: this function is experimental and may change or be
removed without notice.
- SV * cophh_fetch_sv(const COPHH *cophh, SV *key, U32 hash, U32 flags)
+ SV * cophh_fetch_sv(const COPHH *cophh, SV *key,
+ U32 hash, U32 flags)
=for hackers
Found in file cop.h
@@ -1024,7 +1074,9 @@ a string/length pair.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_store_pv(const COPHH *cophh, const char *key, U32 hash, SV *value, U32 flags)
+ COPHH * cophh_store_pv(const COPHH *cophh,
+ const char *key, U32 hash,
+ SV *value, U32 flags)
=for hackers
Found in file cop.h
@@ -1052,7 +1104,9 @@ be stored with referential integrity, but will be coerced to strings.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_store_pvn(COPHH *cophh, const char *keypv, STRLEN keylen, U32 hash, SV *value, U32 flags)
+ COPHH * cophh_store_pvn(COPHH *cophh, const char *keypv,
+ STRLEN keylen, U32 hash,
+ SV *value, U32 flags)
=for hackers
Found in file cop.h
@@ -1066,7 +1120,9 @@ string/length pair, and no precomputed hash.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_store_pvs(const COPHH *cophh, const char *key, SV *value, U32 flags)
+ COPHH * cophh_store_pvs(const COPHH *cophh,
+ const char *key, SV *value,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -1080,7 +1136,8 @@ string/length pair.
NOTE: this function is experimental and may change or be
removed without notice.
- COPHH * cophh_store_sv(const COPHH *cophh, SV *key, U32 hash, SV *value, U32 flags)
+ COPHH * cophh_store_sv(const COPHH *cophh, SV *key,
+ U32 hash, SV *value, U32 flags)
=for hackers
Found in file cop.h
@@ -1110,7 +1167,9 @@ X<cop_hints_fetch_pv>
Like L</cop_hints_fetch_pvn>, but takes a nul-terminated string instead
of a string/length pair.
- SV * cop_hints_fetch_pv(const COP *cop, const char *key, U32 hash, U32 flags)
+ SV * cop_hints_fetch_pv(const COP *cop,
+ const char *key, U32 hash,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -1126,7 +1185,10 @@ it has not been precomputed. Returns a mortal scalar copy of the value
associated with the key, or C<&PL_sv_placeholder> if there is no value
associated with the key.
- SV * cop_hints_fetch_pvn(const COP *cop, const char *keypv, STRLEN keylen, U32 hash, U32 flags)
+ SV * cop_hints_fetch_pvn(const COP *cop,
+ const char *keypv,
+ STRLEN keylen, U32 hash,
+ U32 flags)
=for hackers
Found in file cop.h
@@ -1137,7 +1199,8 @@ X<cop_hints_fetch_pvs>
Like L</cop_hints_fetch_pvn>, but takes a literal string instead of a
string/length pair, and no precomputed hash.
- SV * cop_hints_fetch_pvs(const COP *cop, const char *key, U32 flags)
+ SV * cop_hints_fetch_pvs(const COP *cop,
+ const char *key, U32 flags)
=for hackers
Found in file cop.h
@@ -1148,7 +1211,8 @@ X<cop_hints_fetch_sv>
Like L</cop_hints_fetch_pvn>, but takes a Perl scalar instead of a
string/length pair.
- SV * cop_hints_fetch_sv(const COP *cop, SV *key, U32 hash, U32 flags)
+ SV * cop_hints_fetch_sv(const COP *cop, SV *key,
+ U32 hash, U32 flags)
=for hackers
Found in file cop.h
@@ -1167,7 +1231,9 @@ Register a custom op. See L<perlguts/"Custom Operators">.
NOTE: this function must be explicitly called as Perl_custom_op_register with an aTHX_ parameter.
- void Perl_custom_op_register(pTHX_ Perl_ppaddr_t ppaddr, const XOP *xop)
+ void Perl_custom_op_register(pTHX_
+ Perl_ppaddr_t ppaddr,
+ const XOP *xop)
=for hackers
Found in file op.c
@@ -1180,7 +1246,7 @@ considered internal to OP_NAME and the other access macros: use them instead.
NOTE: this function must be explicitly called as Perl_custom_op_xop with an aTHX_ parameter.
- const XOP * Perl_custom_op_xop(pTHX_ const OP *o)
+ const XOP * Perl_custom_op_xop(pTHX_ const OP *o)
=for hackers
Found in file op.c
@@ -1249,7 +1315,12 @@ Found in file op.h
=item CvSTASH
X<CvSTASH>
-Returns the stash of the CV.
+Returns the stash of the CV. A stash is the symbol table hash, containing
+the package-scoped variables in the package where the subroutine was defined.
+For more information, see L<perlguts>.
+
+This also has a special use with XS AUTOLOAD subs.
+See L<perlguts/Autoloading with XSUBs>.
HV* CvSTASH(CV* cv)
@@ -1279,7 +1350,8 @@ then NULL is returned.
NOTE: the perl_ form of this function is deprecated.
- CV* get_cvn_flags(const char* name, STRLEN len, I32 flags)
+ CV* get_cvn_flags(const char* name, STRLEN len,
+ I32 flags)
=for hackers
Found in file perl.c
@@ -1291,6 +1363,20 @@ Found in file perl.c
=over 8
+=item cv_clone
+X<cv_clone>
+
+Clone a CV, making a lexical closure. I<proto> supplies the prototype
+of the function: its code, pad structure, and other attributes.
+The prototype is combined with a capture of outer lexicals to which the
+code refers, which are taken from the currently-executing instance of
+the immediately surrounding code.
+
+ CV * cv_clone(CV *proto)
+
+=for hackers
+Found in file pad.c
+
=item cv_undef
X<cv_undef>
@@ -1304,6 +1390,34 @@ children can still follow the full lexical scope chain.
=for hackers
Found in file pad.c
+=item find_rundefsv
+X<find_rundefsv>
+
+Find and return the variable that is named C<$_> in the lexical scope
+of the currently-executing function. This may be a lexical C<$_>,
+or will otherwise be the global one.
+
+ SV * find_rundefsv()
+
+=for hackers
+Found in file pad.c
+
+=item find_rundefsvoffset
+X<find_rundefsvoffset>
+
+Find the position of the lexical C<$_> in the pad of the
+currently-executing function. Returns the offset in the current pad,
+or C<NOT_IN_PAD> if there is no lexical C<$_> in scope (in which case
+the global one should be used instead).
+L</find_rundefsv> is likely to be more convenient.
+
+NOTE: the perl_ form of this function is deprecated.
+
+ PADOFFSET find_rundefsvoffset()
+
+=for hackers
+Found in file pad.c
+
=item load_module
X<load_module>
@@ -1311,7 +1425,7 @@ Loads the module whose name is pointed to by the string part of name.
Note that the actual module name, not its filename, should be given.
Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of
PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS
-(or 0 for no flags). ver, if specified, provides version semantics
+(or 0 for no flags). ver, if specified and not NULL, provides version semantics
similar to C<use Foo::Bar VERSION>. The optional trailing SV*
arguments can be used to specify arguments to the module's import()
method, similar to C<use Foo::Bar VERSION LIST>. They must be
@@ -1320,6 +1434,8 @@ be omitted when the PERL_LOADMOD_NOIMPORT flag has been used.
Otherwise at least a single NULL pointer to designate the default
import list is required.
+The reference count for each specified C<SV*> parameter is decremented.
+
void load_module(U32 flags, SV* name, SV* ver, ...)
=for hackers
@@ -1336,19 +1452,156 @@ no threads.
=for hackers
Found in file perl.c
-=item pad_findmy
-X<pad_findmy>
+=item pad_add_anon
+X<pad_add_anon>
+
+Allocates a place in the currently-compiling pad (via L</pad_alloc>)
+for an anonymous function that is lexically scoped inside the
+currently-compiling function.
+The function I<func> is linked into the pad, and its C<CvOUTSIDE> link
+to the outer scope is weakened to avoid a reference loop.
+
+I<optype> should be an opcode indicating the type of operation that the
+pad entry is to support. This doesn't affect operational semantics,
+but is used for debugging.
+
+ PADOFFSET pad_add_anon(CV *func, I32 optype)
+
+=for hackers
+Found in file pad.c
+
+=item pad_add_name_pv
+X<pad_add_name_pv>
+
+Exactly like L</pad_add_name_pvn>, but takes a nul-terminated string
+instead of a string/length pair.
+
+ PADOFFSET pad_add_name_pv(const char *name, U32 flags,
+ HV *typestash, HV *ourstash)
+
+=for hackers
+Found in file pad.c
+
+=item pad_add_name_pvn
+X<pad_add_name_pvn>
+
+Allocates a place in the currently-compiling pad for a named lexical
+variable. Stores the name and other metadata in the name part of the
+pad, and makes preparations to manage the variable's lexical scoping.
+Returns the offset of the allocated pad slot.
+
+I<namepv>/I<namelen> specify the variable's name, including leading sigil.
+If I<typestash> is non-null, the name is for a typed lexical, and this
+identifies the type. If I<ourstash> is non-null, it's a lexical reference
+to a package variable, and this identifies the package. The following
+flags can be OR'ed together:
+
+ padadd_OUR redundantly specifies if it's a package var
+ padadd_STATE variable will retain value persistently
+ padadd_NO_DUP_CHECK skip check for lexical shadowing
+
+ PADOFFSET pad_add_name_pvn(const char *namepv,
+ STRLEN namelen, U32 flags,
+ HV *typestash, HV *ourstash)
+
+=for hackers
+Found in file pad.c
+
+=item pad_add_name_sv
+X<pad_add_name_sv>
+
+Exactly like L</pad_add_name_pvn>, but takes the name string in the form
+of an SV instead of a string/length pair.
-Given a lexical name, try to find its offset, first in the current pad,
-or failing that, in the pads of any lexically enclosing subs (including
-the complications introduced by eval). If the name is found in an outer pad,
-then a fake entry is added to the current pad.
-Returns the offset in the current pad, or NOT_IN_PAD on failure.
+ PADOFFSET pad_add_name_sv(SV *name, U32 flags,
+ HV *typestash, HV *ourstash)
+
+=for hackers
+Found in file pad.c
+
+=item pad_alloc
+X<pad_alloc>
+
+Allocates a place in the currently-compiling pad,
+returning the offset of the allocated pad slot.
+No name is initially attached to the pad slot.
+I<tmptype> is a set of flags indicating the kind of pad entry required,
+which will be set in the value SV for the allocated pad entry:
+
+ SVs_PADMY named lexical variable ("my", "our", "state")
+ SVs_PADTMP unnamed temporary store
+
+I<optype> should be an opcode indicating the type of operation that the
+pad entry is to support. This doesn't affect operational semantics,
+but is used for debugging.
NOTE: this function is experimental and may change or be
removed without notice.
- PADOFFSET pad_findmy(const char* name, STRLEN len, U32 flags)
+ PADOFFSET pad_alloc(I32 optype, U32 tmptype)
+
+=for hackers
+Found in file pad.c
+
+=item pad_compname_type
+X<pad_compname_type>
+
+Looks up the type of the lexical variable at position I<po> in the
+currently-compiling pad. If the variable is typed, the stash of the
+class to which it is typed is returned. If not, C<NULL> is returned.
+
+ HV * pad_compname_type(PADOFFSET po)
+
+=for hackers
+Found in file pad.c
+
+=item pad_findmy_pv
+X<pad_findmy_pv>
+
+Exactly like L</pad_findmy_pvn>, but takes a nul-terminated string
+instead of a string/length pair.
+
+ PADOFFSET pad_findmy_pv(const char *name, U32 flags)
+
+=for hackers
+Found in file pad.c
+
+=item pad_findmy_pvn
+X<pad_findmy_pvn>
+
+Given the name of a lexical variable, find its position in the
+currently-compiling pad.
+I<namepv>/I<namelen> specify the variable's name, including leading sigil.
+I<flags> is reserved and must be zero.
+If it is not in the current pad but appears in the pad of any lexically
+enclosing scope, then a pseudo-entry for it is added in the current pad.
+Returns the offset in the current pad,
+or C<NOT_IN_PAD> if no such lexical is in scope.
+
+ PADOFFSET pad_findmy_pvn(const char *namepv,
+ STRLEN namelen, U32 flags)
+
+=for hackers
+Found in file pad.c
+
+=item pad_findmy_sv
+X<pad_findmy_sv>
+
+Exactly like L</pad_findmy_pvn>, but takes the name string in the form
+of an SV instead of a string/length pair.
+
+ PADOFFSET pad_findmy_sv(SV *name, U32 flags)
+
+=for hackers
+Found in file pad.c
+
+=item pad_setsv
+X<pad_setsv>
+
+Set the value at offset I<po> in the current (compiling or executing) pad.
+Use the macro PAD_SETSV() rather than calling this function directly.
+
+ void pad_setsv(PADOFFSET po, SV *sv)
=for hackers
Found in file pad.c
@@ -1356,10 +1609,30 @@ Found in file pad.c
=item pad_sv
X<pad_sv>
-Get the value at offset po in the current pad.
+Get the value at offset I<po> in the current (compiling or executing) pad.
Use macro PAD_SV instead of calling this function directly.
- SV* pad_sv(PADOFFSET po)
+ SV * pad_sv(PADOFFSET po)
+
+=for hackers
+Found in file pad.c
+
+=item pad_tidy
+X<pad_tidy>
+
+Tidy up a pad at the end of compilation of the code to which it belongs.
+Jobs performed here are: remove most stuff from the pads of anonsub
+prototypes; give it a @_; mark temporaries as such. I<type> indicates
+the kind of subroutine:
+
+ padtidy_SUB ordinary subroutine
+ padtidy_SUBCLONE prototype for lexical closure
+ padtidy_FORMAT format
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+ void pad_tidy(padtidy_type type)
=for hackers
Found in file pad.c
@@ -1369,7 +1642,7 @@ X<perl_alloc>
Allocates a new Perl interpreter. See L<perlembed>.
- PerlInterpreter* perl_alloc()
+ PerlInterpreter* perl_alloc()
=for hackers
Found in file perl.c
@@ -1409,7 +1682,9 @@ X<perl_parse>
Tells a Perl interpreter to parse a Perl script. See L<perlembed>.
- int perl_parse(PerlInterpreter *my_perl, XSINIT_t xsinit, int argc, char** argv, char** env)
+ int perl_parse(PerlInterpreter *my_perl,
+ XSINIT_t xsinit, int argc,
+ char** argv, char** env)
=for hackers
Found in file perl.c
@@ -1458,7 +1733,8 @@ len > cur and pv[cur] is "\0".
Note that the final string may be up to 7 chars longer than pvlim.
- char* pv_display(SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim)
+ char* pv_display(SV *dsv, const char *pv, STRLEN cur,
+ STRLEN len, STRLEN pvlim)
=for hackers
Found in file dump.c
@@ -1500,7 +1776,10 @@ sequences, whereas '%' is not a particularly common character in patterns.
Returns a pointer to the escaped text as held by dsv.
- char* pv_escape(SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags)
+ char* pv_escape(SV *dsv, char const * const str,
+ const STRLEN count, const STRLEN max,
+ STRLEN * const escaped,
+ const U32 flags)
=for hackers
Found in file dump.c
@@ -1527,7 +1806,11 @@ any quotes or ellipses.
Returns a pointer to the prettified text as held by dsv.
- char* pv_pretty(SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags)
+ char* pv_pretty(SV *dsv, char const * const str,
+ const STRLEN count, const STRLEN max,
+ char const * const start_color,
+ char const * const end_color,
+ const U32 flags)
=for hackers
Found in file dump.c
@@ -1547,7 +1830,7 @@ Return the description of a given custom op. This was once used by the
OP_DESC macro, but is no longer: it has only been kept for
compatibility, and should not be used.
- const char * custom_op_desc(const OP *o)
+ const char * custom_op_desc(const OP *o)
=for hackers
Found in file mathoms.c
@@ -1559,7 +1842,7 @@ Return the name for a given custom op. This was once used by the OP_NAME
macro, but is no longer: it has only been kept for compatibility, and
should not be used.
- const char * custom_op_name(const OP *o)
+ const char * custom_op_name(const OP *o)
=for hackers
Found in file mathoms.c
@@ -1567,7 +1850,7 @@ Found in file mathoms.c
=item gv_fetchmethod
X<gv_fetchmethod>
-See L<gv_fetchmethod_autoload>.
+See L</gv_fetchmethod_autoload>.
GV* gv_fetchmethod(HV* stash, const char* name)
@@ -1580,7 +1863,10 @@ X<pack_cat>
The engine implementing pack() Perl function. Note: parameters next_in_list and
flags are not used. This call should not be used; use packlist instead.
- void pack_cat(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
+ void pack_cat(SV *cat, const char *pat,
+ const char *patend, SV **beglist,
+ SV **endlist, SV ***next_in_list,
+ U32 flags)
=for hackers
Found in file mathoms.c
@@ -1616,6 +1902,7 @@ X<sv_2pv_nolen>
Like C<sv_2pv()>, but doesn't return the length too. You should usually
use the macro wrapper C<SvPV_nolen(sv)> instead.
+
char* sv_2pv_nolen(SV* sv)
=for hackers
@@ -1626,7 +1913,8 @@ X<sv_catpvn_mg>
Like C<sv_catpvn>, but also handles 'set' magic.
- void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
+ void sv_catpvn_mg(SV *sv, const char *ptr,
+ STRLEN len)
=for hackers
Found in file mathoms.c
@@ -1772,6 +2060,7 @@ Found in file mathoms.c
X<sv_taint>
Taint an SV. Use C<SvTAINTED_on> instead.
+
void sv_taint(SV* sv)
=for hackers
@@ -1829,7 +2118,10 @@ X<unpack_str>
The engine implementing unpack() Perl function. Note: parameters strbeg, new_s
and ocnt are not used. This call should not be used, use unpackstring instead.
- I32 unpack_str(const char *pat, const char *patend, const char *s, const char *strbeg, const char *strend, char **new_s, I32 ocnt, U32 flags)
+ I32 unpack_str(const char *pat, const char *patend,
+ const char *s, const char *strbeg,
+ const char *strend, char **new_s,
+ I32 ocnt, U32 flags)
=for hackers
Found in file mathoms.c
@@ -1882,7 +2174,8 @@ Provides system-specific tune up of the C runtime environment necessary to
run Perl interpreters. This should be called only once, before creating
any Perl interpreters.
- void PERL_SYS_INIT3(int argc, char** argv, char** env)
+ void PERL_SYS_INIT3(int argc, char** argv,
+ char** env)
=for hackers
Found in file perl.h
@@ -1923,7 +2216,10 @@ C<DB::sub>, since that has the correct line number/etc. for the call
site. If I<dbcxp> is non-C<NULL>, it will be set to a pointer to the
frame for the sub call itself.
- const PERL_CONTEXT * caller_cx(I32 level, const PERL_CONTEXT **dbcxp)
+ const PERL_CONTEXT * caller_cx(
+ I32 level,
+ const PERL_CONTEXT **dbcxp
+ )
=for hackers
Found in file pp_ctl.c
@@ -1955,7 +2251,9 @@ X<packlist>
The engine implementing pack() Perl function.
- void packlist(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist)
+ void packlist(SV *cat, const char *pat,
+ const char *patend, SV **beglist,
+ SV **endlist)
=for hackers
Found in file pp_pack.c
@@ -1967,7 +2265,9 @@ The engine implementing unpack() Perl function. C<unpackstring> puts the
extracted list items on the stack and returns the number of elements.
Issue C<PUTBACK> before and C<SPAGAIN> after the call to this function.
- I32 unpackstring(const char *pat, const char *patend, const char *s, const char *strend, U32 flags)
+ I32 unpackstring(const char *pat,
+ const char *patend, const char *s,
+ const char *strend, U32 flags)
=for hackers
Found in file pp_pack.c
@@ -2006,7 +2306,9 @@ X<ibcmp_utf8>
This is a synonym for (! foldEQ_utf8())
- I32 ibcmp_utf8(const char *s1, char **pe1, UV l1, bool u1, const char *s2, char **pe2, UV l2, bool u2)
+ I32 ibcmp_utf8(const char *s1, char **pe1, UV l1,
+ bool u1, const char *s2, char **pe2,
+ UV l2, bool u2)
=for hackers
Found in file utf8.h
@@ -2034,7 +2336,8 @@ X<ibcmp_locale>
This is a synonym for (! foldEQ_locale())
- I32 ibcmp_locale(const char* a, const char* b, I32 len)
+ I32 ibcmp_locale(const char* a, const char* b,
+ I32 len)
=for hackers
Found in file util.h
@@ -2046,6 +2349,38 @@ Found in file util.h
=over 8
+=item PL_check
+X<PL_check>
+
+Array, indexed by opcode, of functions that will be called for the "check"
+phase of optree building during compilation of Perl code. For most (but
+not all) types of op, once the op has been initially built and populated
+with child ops it will be filtered through the check function referenced
+by the appropriate element of this array. The new op is passed in as the
+sole argument to the check function, and the check function returns the
+completed op. The check function may (as the name suggests) check the op
+for validity and signal errors. It may also initialise or modify parts of
+the ops, or perform more radical surgery such as adding or removing child
+ops, or even throw the op away and return a different op in its place.
+
+This array of function pointers is a convenient place to hook into the
+compilation process. An XS module can put its own custom check function
+in place of any of the standard ones, to influence the compilation of a
+particular type of op. However, a custom check function must never fully
+replace a standard check function (or even a custom check function from
+another module). A module modifying checking must instead B<wrap> the
+preexisting check function. A custom check function must be selective
+about when to apply its custom behaviour. In the usual case where
+it decides not to do anything special with an op, it must chain the
+preexisting op function. Check functions are thus linked in a chain,
+with the core's base checker at the end.
+
+For thread safety, modules should not write directly to this array.
+Instead, use the function L</wrap_op_checker>.
+
+=for hackers
+Found in file perlvars.h
+
=item PL_keyword_plugin
X<PL_keyword_plugin>
@@ -2135,22 +2470,10 @@ Found in file gv.c
=item gv_fetchmeth
X<gv_fetchmeth>
-Returns the glob with the given C<name> and a defined subroutine or
-C<NULL>. The glob lives in the given C<stash>, or in the stashes
-accessible via @ISA and UNIVERSAL::.
+Like L</gv_fetchmeth_pvn>, but lacks a flags parameter.
-The argument C<level> should be either 0 or -1. If C<level==0>, as a
-side-effect creates a glob with the given C<name> in the given C<stash>
-which in the case of success contains an alias for the subroutine, and sets
-up caching info for this glob.
-
-This function grants C<"SUPER"> token as a postfix of the stash name. The
-GV returned from C<gv_fetchmeth> may be a method cache entry, which is not
-visible to Perl code. So when calling C<call_sv>, you should not use
-the GV directly; instead, you should use the method's CV, which can be
-obtained from the GV with the C<GvCV> macro.
-
- GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)
+ GV* gv_fetchmeth(HV* stash, const char* name,
+ STRLEN len, I32 level)
=for hackers
Found in file gv.c
@@ -2180,7 +2503,9 @@ C<level==0>. C<name> should be writable if contains C<':'> or C<'
''>. The warning against passing the GV returned by C<gv_fetchmeth> to
C<call_sv> apply equally to these functions.
- GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)
+ GV* gv_fetchmethod_autoload(HV* stash,
+ const char* name,
+ I32 autoload)
=for hackers
Found in file gv.c
@@ -2188,14 +2513,175 @@ Found in file gv.c
=item gv_fetchmeth_autoload
X<gv_fetchmeth_autoload>
-Same as gv_fetchmeth(), but looks for autoloaded subroutines too.
+This is the old form of L</gv_fetchmeth_pvn_autoload>, which has no flags
+parameter.
+
+ GV* gv_fetchmeth_autoload(HV* stash,
+ const char* name,
+ STRLEN len, I32 level)
+
+=for hackers
+Found in file gv.c
+
+=item gv_fetchmeth_pv
+X<gv_fetchmeth_pv>
+
+Exactly like L</gv_fetchmeth_pvn>, but takes a nul-terminated string
+instead of a string/length pair.
+
+ GV* gv_fetchmeth_pv(HV* stash, const char* name,
+ I32 level, U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_fetchmeth_pvn
+X<gv_fetchmeth_pvn>
+
+Returns the glob with the given C<name> and a defined subroutine or
+C<NULL>. The glob lives in the given C<stash>, or in the stashes
+accessible via @ISA and UNIVERSAL::.
+
+The argument C<level> should be either 0 or -1. If C<level==0>, as a
+side-effect creates a glob with the given C<name> in the given C<stash>
+which in the case of success contains an alias for the subroutine, and sets
+up caching info for this glob.
+
+Currently, the only significant value for C<flags> is SVf_UTF8.
+
+This function grants C<"SUPER"> token as a postfix of the stash name. The
+GV returned from C<gv_fetchmeth> may be a method cache entry, which is not
+visible to Perl code. So when calling C<call_sv>, you should not use
+the GV directly; instead, you should use the method's CV, which can be
+obtained from the GV with the C<GvCV> macro.
+
+ GV* gv_fetchmeth_pvn(HV* stash, const char* name,
+ STRLEN len, I32 level,
+ U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_fetchmeth_pvn_autoload
+X<gv_fetchmeth_pvn_autoload>
+
+Same as gv_fetchmeth_pvn(), but looks for autoloaded subroutines too.
Returns a glob for the subroutine.
For an autoloaded subroutine without a GV, will create a GV even
if C<level < 0>. For an autoloaded subroutine without a stub, GvCV()
of the result may be zero.
- GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)
+Currently, the only significant value for C<flags> is SVf_UTF8.
+
+ GV* gv_fetchmeth_pvn_autoload(HV* stash,
+ const char* name,
+ STRLEN len, I32 level,
+ U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_fetchmeth_pv_autoload
+X<gv_fetchmeth_pv_autoload>
+
+Exactly like L</gv_fetchmeth_pvn_autoload>, but takes a nul-terminated string
+instead of a string/length pair.
+
+ GV* gv_fetchmeth_pv_autoload(HV* stash,
+ const char* name,
+ I32 level, U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_fetchmeth_sv
+X<gv_fetchmeth_sv>
+
+Exactly like L</gv_fetchmeth_pvn>, but takes the name string in the form
+of an SV instead of a string/length pair.
+
+ GV* gv_fetchmeth_sv(HV* stash, SV* namesv,
+ I32 level, U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_fetchmeth_sv_autoload
+X<gv_fetchmeth_sv_autoload>
+
+Exactly like L</gv_fetchmeth_pvn_autoload>, but takes the name string in the form
+of an SV instead of a string/length pair.
+
+ GV* gv_fetchmeth_sv_autoload(HV* stash, SV* namesv,
+ I32 level, U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_init
+X<gv_init>
+
+The old form of gv_init_pvn(). It does not work with UTF8 strings, as it
+has no flags parameter. If the C<multi> parameter is set, the
+GV_ADDMULTI flag will be passed to gv_init_pvn().
+
+ void gv_init(GV* gv, HV* stash, const char* name,
+ STRLEN len, int multi)
+
+=for hackers
+Found in file gv.c
+
+=item gv_init_pv
+X<gv_init_pv>
+
+Same as gv_init_pvn(), but takes a nul-terminated string for the name
+instead of separate char * and length parameters.
+
+ void gv_init_pv(GV* gv, HV* stash, const char* name,
+ U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_init_pvn
+X<gv_init_pvn>
+
+Converts a scalar into a typeglob. This is an incoercible typeglob;
+assigning a reference to it will assign to one of its slots, instead of
+overwriting it as happens with typeglobs created by SvSetSV. Converting
+any scalar that is SvOK() may produce unpredictable results and is reserved
+for perl's internal use.
+
+C<gv> is the scalar to be converted.
+
+C<stash> is the parent stash/package, if any.
+
+C<name> and C<len> give the name. The name must be unqualified;
+that is, it must not include the package name. If C<gv> is a
+stash element, it is the caller's responsibility to ensure that the name
+passed to this function matches the name of the element. If it does not
+match, perl's internal bookkeeping will get out of sync.
+
+C<flags> can be set to SVf_UTF8 if C<name> is a UTF8 string, or
+the return value of SvUTF8(sv). It can also take the
+GV_ADDMULTI flag, which means to pretend that the GV has been
+seen before (i.e., suppress "Used once" warnings).
+
+ void gv_init_pvn(GV* gv, HV* stash, const char* name,
+ STRLEN len, U32 flags)
+
+=for hackers
+Found in file gv.c
+
+=item gv_init_sv
+X<gv_init_sv>
+
+Same as gv_init_pvn(), but takes an SV * for the name instead of separate
+char * and length parameters. C<flags> is currently unused.
+
+ void gv_init_sv(GV* gv, HV* stash, SV* namesv,
+ U32 flags)
=for hackers
Found in file gv.c
@@ -2222,7 +2708,8 @@ C<flags> is 0 (or any other setting that does not create packages) then NULL
is returned.
- HV* gv_stashpvn(const char* name, U32 namelen, I32 flags)
+ HV* gv_stashpvn(const char* name, U32 namelen,
+ I32 flags)
=for hackers
Found in file gv.c
@@ -2307,6 +2794,37 @@ Found in file handy.h
=over 8
+=item cop_fetch_label
+X<cop_fetch_label>
+
+Returns the label attached to a cop.
+The flags pointer may be set to C<SVf_UTF8> or 0.
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+ const char * cop_fetch_label(COP *const cop,
+ STRLEN *len, U32 *flags)
+
+=for hackers
+Found in file hv.c
+
+=item cop_store_label
+X<cop_store_label>
+
+Save a label into a C<cop_hints_hash>. You need to set flags to C<SVf_UTF8>
+for a utf-8 label.
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+ void cop_store_label(COP *const cop,
+ const char *label, STRLEN len,
+ U32 flags)
+
+=for hackers
+Found in file hv.c
+
=item get_hv
X<get_hv>
@@ -2463,6 +2981,26 @@ caches.
=for hackers
Found in file hv.h
+=item HvENAMELEN
+X<HvENAMELEN>
+
+Returns the length of the stash's effective name.
+
+ STRLEN HvENAMELEN(HV *stash)
+
+=for hackers
+Found in file hv.h
+
+=item HvENAMEUTF8
+X<HvENAMEUTF8>
+
+Returns true if the effective name is in UTF8 encoding.
+
+ unsigned char HvENAMEUTF8(HV *stash)
+
+=for hackers
+Found in file hv.h
+
=item HvNAME
X<HvNAME>
@@ -2474,6 +3012,26 @@ See C<SvSTASH>, C<CvSTASH>.
=for hackers
Found in file hv.h
+=item HvNAMELEN
+X<HvNAMELEN>
+
+Returns the length of the stash's name.
+
+ STRLEN HvNAMELEN(HV *stash)
+
+=for hackers
+Found in file hv.h
+
+=item HvNAMEUTF8
+X<HvNAMEUTF8>
+
+Returns true if the name is in UTF8 encoding.
+
+ unsigned char HvNAMEUTF8(HV *stash)
+
+=for hackers
+Found in file hv.h
+
=item hv_assert
X<hv_assert>
@@ -2487,7 +3045,11 @@ Found in file hv.c
=item hv_clear
X<hv_clear>
-Clears a hash, making it empty.
+Frees the all the elements of a hash, leaving it empty.
+The XS equivalent of C<%hash = ()>. See also L</hv_undef>.
+
+If any destructors are triggered as a result, the hv itself may
+be freed.
void hv_clear(HV *hv)
@@ -2527,12 +3089,15 @@ Found in file hv.c
=item hv_delete
X<hv_delete>
-Deletes a key/value pair in the hash. The value's SV is removed from the
-hash, made mortal, and returned to the caller. The C<klen> is the length of
-the key. The C<flags> value will normally be zero; if set to G_DISCARD then
-NULL will be returned. NULL will also be returned if the key is not found.
+Deletes a key/value pair in the hash. The value's SV is removed from
+the hash, made mortal, and returned to the caller. The absolute
+value of C<klen> is the length of the key. If C<klen> is negative the
+key is assumed to be in UTF-8-encoded Unicode. The C<flags> value
+will normally be zero; if set to G_DISCARD then NULL will be returned.
+NULL will also be returned if the key is not found.
- SV* hv_delete(HV *hv, const char *key, I32 klen, I32 flags)
+ SV* hv_delete(HV *hv, const char *key, I32 klen,
+ I32 flags)
=for hackers
Found in file hv.c
@@ -2546,7 +3111,8 @@ zero; if set to G_DISCARD then NULL will be returned. NULL will also be
returned if the key is not found. C<hash> can be a valid precomputed hash
value, or 0 to ask for it to be computed.
- SV* hv_delete_ent(HV *hv, SV *keysv, I32 flags, U32 hash)
+ SV* hv_delete_ent(HV *hv, SV *keysv, I32 flags,
+ U32 hash)
=for hackers
Found in file hv.c
@@ -2555,7 +3121,8 @@ Found in file hv.c
X<hv_exists>
Returns a boolean indicating whether the specified hash key exists. The
-C<klen> is the length of the key.
+absolute value of C<klen> is the length of the key. If C<klen> is
+negative the key is assumed to be in UTF-8-encoded Unicode.
bool hv_exists(HV *hv, const char *key, I32 klen)
@@ -2565,7 +3132,8 @@ Found in file hv.c
=item hv_exists_ent
X<hv_exists_ent>
-Returns a boolean indicating whether the specified hash key exists. C<hash>
+Returns a boolean indicating whether
+the specified hash key exists. C<hash>
can be a valid precomputed hash value, or 0 to ask for it to be
computed.
@@ -2577,15 +3145,17 @@ Found in file hv.c
=item hv_fetch
X<hv_fetch>
-Returns the SV which corresponds to the specified key in the hash. The
-C<klen> is the length of the key. If C<lval> is set then the fetch will be
-part of a store. Check that the return value is non-null before
-dereferencing it to an C<SV*>.
+Returns the SV which corresponds to the specified key in the hash.
+The absolute value of C<klen> is the length of the key. If C<klen> is
+negative the key is assumed to be in UTF-8-encoded Unicode. If
+C<lval> is set then the fetch will be part of a store. Check that the
+return value is non-null before dereferencing it to an C<SV*>.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
- SV** hv_fetch(HV *hv, const char *key, I32 klen, I32 lval)
+ SV** hv_fetch(HV *hv, const char *key, I32 klen,
+ I32 lval)
=for hackers
Found in file hv.c
@@ -2614,7 +3184,8 @@ store it somewhere.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
- HE* hv_fetch_ent(HV *hv, SV *keysv, I32 lval, U32 hash)
+ HE* hv_fetch_ent(HV *hv, SV *keysv, I32 lval,
+ U32 hash)
=for hackers
Found in file hv.c
@@ -2637,7 +3208,7 @@ Found in file hv.c
X<hv_iterinit>
Prepares a starting point to traverse a hash table. Returns the number of
-keys in the hash (i.e. the same as C<HvKEYS(hv)>). The return value is
+keys in the hash (i.e. the same as C<HvUSEDKEYS(hv)>). The return value is
currently only meaningful for hashes without tie magic.
NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of
@@ -2710,7 +3281,7 @@ The C<flags> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is
set the placeholders keys (for restricted hashes) will be returned in addition
to normal keys. By default placeholders are automatically skipped over.
Currently a placeholder is implemented with a value that is
-C<&Perl_sv_placeholder>. Note that the implementation of placeholders and
+C<&PL_sv_placeholder>. Note that the implementation of placeholders and
restricted hashes may change, and the implementation currently is
insufficiently abstracted for any change to be tidy.
@@ -2756,9 +3327,13 @@ Found in file hv.c
=item hv_store
X<hv_store>
-Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is
-the length of the key. The C<hash> parameter is the precomputed hash
-value; if it is zero then Perl will compute it. The return value will be
+Stores an SV in a hash. The hash key is specified as C<key> and the
+absolute value of C<klen> is the length of the key. If C<klen> is
+negative the key is assumed to be in UTF-8-encoded Unicode. The
+C<hash> parameter is the precomputed hash value; if it is zero then
+Perl will compute it.
+
+The return value will be
NULL if the operation failed or if the value did not need to be actually
stored within the hash (as in the case of tied hashes). Otherwise it can
be dereferenced to get the original C<SV*>. Note that the caller is
@@ -2776,7 +3351,8 @@ hv_store_ent.
See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
information on how to use this function on tied hashes.
- SV** hv_store(HV *hv, const char *key, I32 klen, SV *val, U32 hash)
+ SV** hv_store(HV *hv, const char *key, I32 klen,
+ SV *val, U32 hash)
=for hackers
Found in file hv.c
@@ -2787,7 +3363,8 @@ X<hv_stores>
Like C<hv_store>, but takes a literal string instead of a string/length pair
and omits the hash parameter.
- SV** hv_stores(HV* tb, const char* key, NULLOK SV* val)
+ SV** hv_stores(HV* tb, const char* key,
+ NULLOK SV* val)
=for hackers
Found in file handy.h
@@ -2826,7 +3403,15 @@ Found in file hv.c
=item hv_undef
X<hv_undef>
-Undefines the hash.
+Undefines the hash. The XS equivalent of C<undef(%hash)>.
+
+As well as freeing all the elements of the hash (like hv_clear()), this
+also frees any auxiliary data and storage associated with the hash.
+
+If any destructors are triggered as a result, the hv itself may
+be freed.
+
+See also L</hv_clear>.
void hv_undef(HV *hv)
@@ -2846,6 +3431,57 @@ Found in file hv.h
=back
+=head1 Hook manipulation
+
+=over 8
+
+=item wrap_op_checker
+X<wrap_op_checker>
+
+Puts a C function into the chain of check functions for a specified op
+type. This is the preferred way to manipulate the L</PL_check> array.
+I<opcode> specifies which type of op is to be affected. I<new_checker>
+is a pointer to the C function that is to be added to that opcode's
+check chain, and I<old_checker_p> points to the storage location where a
+pointer to the next function in the chain will be stored. The value of
+I<new_pointer> is written into the L</PL_check> array, while the value
+previously stored there is written to I<*old_checker_p>.
+
+L</PL_check> is global to an entire process, and a module wishing to
+hook op checking may find itself invoked more than once per process,
+typically in different threads. To handle that situation, this function
+is idempotent. The location I<*old_checker_p> must initially (once
+per process) contain a null pointer. A C variable of static duration
+(declared at file scope, typically also marked C<static> to give
+it internal linkage) will be implicitly initialised appropriately,
+if it does not have an explicit initialiser. This function will only
+actually modify the check chain if it finds I<*old_checker_p> to be null.
+This function is also thread safe on the small scale. It uses appropriate
+locking to avoid race conditions in accessing L</PL_check>.
+
+When this function is called, the function referenced by I<new_checker>
+must be ready to be called, except for I<*old_checker_p> being unfilled.
+In a threading situation, I<new_checker> may be called immediately,
+even before this function has returned. I<*old_checker_p> will always
+be appropriately set before I<new_checker> is called. If I<new_checker>
+decides not to do anything special with an op that it is given (which
+is the usual case for most uses of op check hooking), it must chain the
+check function referenced by I<*old_checker_p>.
+
+If you want to influence compilation of calls to a specific subroutine,
+then use L</cv_set_call_checker> rather than hooking checking of all
+C<entersub> ops.
+
+ void wrap_op_checker(Optype opcode,
+ Perl_check_t new_checker,
+ Perl_check_t *old_checker_p)
+
+=for hackers
+Found in file op.c
+
+
+=back
+
=head1 Lexer interface
=over 8
@@ -3063,9 +3699,8 @@ from which code will be read to be parsed. If both are non-null, the
code in I<line> comes first and must consist of complete lines of input,
and I<rsfp> supplies the remainder of the source.
-The I<flags> parameter is reserved for future use, and must always
-be zero, except for one flag that is currently reserved for perl's internal
-use.
+The I<flags> parameter is reserved for future use. Currently it is only
+used by perl internally, so extensions should always pass zero.
NOTE: this function is experimental and may change or be
removed without notice.
@@ -3124,7 +3759,8 @@ function is more convenient.
NOTE: this function is experimental and may change or be
removed without notice.
- void lex_stuff_pvn(const char *pv, STRLEN len, U32 flags)
+ void lex_stuff_pvn(const char *pv, STRLEN len,
+ U32 flags)
=for hackers
Found in file toke.c
@@ -3593,7 +4229,8 @@ X<mg_copy>
Copies the magic from one SV to another. See C<sv_magic>.
- int mg_copy(SV *sv, SV *nsv, const char *key, I32 klen)
+ int mg_copy(SV *sv, SV *nsv, const char *key,
+ I32 klen)
=for hackers
Found in file mg.c
@@ -3614,7 +4251,8 @@ X<mg_findext>
Finds the magic pointer of C<type> with the given C<vtbl> for the C<SV>. See
C<sv_magicext>.
- MAGIC* mg_findext(const SV* sv, int type, const MGVTBL *vtbl)
+ MAGIC* mg_findext(const SV* sv, int type,
+ const MGVTBL *vtbl)
=for hackers
Found in file mg.c
@@ -3642,7 +4280,7 @@ Found in file mg.c
=item mg_get
X<mg_get>
-Do magic after a value is retrieved from the SV. See C<sv_magic>.
+Do magic before a value is retrieved from the SV. See C<sv_magic>.
int mg_get(SV* sv)
@@ -3747,7 +4385,7 @@ Found in file sv.h
X<SvSetSV_nosteal>
Calls a non-destructive version of C<sv_setsv> if dsv is not the same as
-ssv. May evaluate arguments more than once.
+ssv. May evaluate arguments more than once.
void SvSetSV_nosteal(SV* dsv, SV* ssv)
@@ -3837,7 +4475,7 @@ The XSUB-writer's interface to the C C<malloc> function.
In 5.9.3, Newx() and friends replace the older New() API, and drops
the first parameter, I<x>, a debug aid which allowed callers to identify
themselves. This aid has been superseded by a new build option,
-PERL_MEM_LOG (see L<perlhack/PERL_MEM_LOG>). The older API is still
+PERL_MEM_LOG (see L<perlhacktips/PERL_MEM_LOG>). The older API is still
there for use in XS modules supporting older perls.
void Newx(void* ptr, int nitems, type)
@@ -3903,7 +4541,8 @@ X<PoisonWith>
Fill up memory with a byte pattern (a byte repeated over and over
again) that hopefully catches attempts to access uninitialized memory.
- void PoisonWith(void* dest, int nitems, type, U8 byte)
+ void PoisonWith(void* dest, int nitems, type,
+ U8 byte)
=for hackers
Found in file handy.h
@@ -3993,7 +4632,8 @@ A version of C<savepvn()> which allocates the duplicate string in memory
which is shared between threads. (With the specific difference that a NULL
pointer is not acceptable)
- char* savesharedpvn(const char *const pv, const STRLEN len)
+ char* savesharedpvn(const char *const pv,
+ const STRLEN len)
=for hackers
Found in file util.c
@@ -4089,7 +4729,9 @@ C<strend>. It returns C<NULL> if the string can't be found. The C<sv>
does not have to be fbm_compiled, but the search will not be as fast
then.
- char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlestr, U32 flags)
+ char* fbm_instr(unsigned char* big,
+ unsigned char* bigend, SV* littlestr,
+ U32 flags)
=for hackers
Found in file util.c
@@ -4113,7 +4755,8 @@ X<foldEQ_locale>
Returns true if the leading len bytes of the strings s1 and s2 are the same
case-insensitively in the current locale; false otherwise.
- I32 foldEQ_locale(const char* a, const char* b, I32 len)
+ I32 foldEQ_locale(const char* a, const char* b,
+ I32 len)
=for hackers
Found in file util.c
@@ -4202,7 +4845,8 @@ C<vsprintf> which can overrun the buffer (there is an overrun check,
but that may be too late). Consider using C<sv_vcatpvf> instead, or
getting C<vsnprintf>.
- int my_snprintf(char *buffer, const Size_t len, const char *format, ...)
+ int my_snprintf(char *buffer, const Size_t len,
+ const char *format, ...)
=for hackers
Found in file util.c
@@ -4228,7 +4872,8 @@ use the unsafe C<vsprintf> which can overrun the buffer (there is an
overrun check, but that may be too late). Consider using
C<sv_vcatpvf> instead, or getting C<vsnprintf>.
- int my_vsnprintf(char *buffer, const Size_t len, const char *format, va_list ap)
+ int my_vsnprintf(char *buffer, const Size_t len,
+ const char *format, va_list ap)
=for hackers
Found in file util.c
@@ -4256,7 +4901,11 @@ actually perform the parsing. Can use either strict or lax validation rules.
Can optionally set a number of hint variables to save the parsing code
some time when tokenizing.
- const char* prescan_version(const char *s, bool strict, const char** errstr, bool *sqv, int *ssaw_decimal, int *swidth, bool *salpha)
+ const char* prescan_version(const char *s, bool strict,
+ const char** errstr,
+ bool *sqv,
+ int *ssaw_decimal,
+ int *swidth, bool *salpha)
=for hackers
Found in file util.c
@@ -4280,7 +4929,7 @@ is an alpha version). The boolean qv denotes that the version
should be interpreted as if it had multiple decimals, even if
it doesn't.
- const char* scan_version(const char *s, SV *rv, bool qv)
+ const char* scan_version(const char *s, SV *rv, bool qv)
=for hackers
Found in file util.c
@@ -4523,10 +5172,9 @@ Found in file util.c
=item mro_get_linear_isa
X<mro_get_linear_isa>
-Returns either C<mro_get_linear_isa_c3> or
-C<mro_get_linear_isa_dfs> for the given stash,
-dependant upon which MRO is in effect
-for that stash. The return value is a
+Returns the mro linearisation for the given stash. By default, this
+will be whatever C<mro_get_linear_isa_dfs> returns unless some
+other MRO is in effect for the stash. The return value is a
read-only AV*.
You are responsible for C<SvREFCNT_inc()> on the
@@ -4548,7 +5196,7 @@ of the given stash, so that they might notice
the changes in this one.
Ideally, all instances of C<PL_sub_generation++> in
-perl source outside of C<mro.c> should be
+perl source outside of F<mro.c> should be
replaced by calls to this.
Perl automatically handles most of the common
@@ -4573,6 +5221,16 @@ via, C<mro::method_changed_in(classname)>.
=for hackers
Found in file mro.c
+=item mro_register
+X<mro_register>
+
+Registers a custom mro plugin. See L<perlmroapi> for details.
+
+ void mro_register(const struct mro_alg *mro)
+
+=for hackers
+Found in file mro.c
+
=back
@@ -4583,7 +5241,7 @@ Found in file mro.c
=item dMULTICALL
X<dMULTICALL>
-Declare local variables for a multicall. See L<perlcall/Lightweight Callbacks>.
+Declare local variables for a multicall. See L<perlcall/LIGHTWEIGHT CALLBACKS>.
dMULTICALL;
@@ -4593,7 +5251,7 @@ Found in file cop.h
=item MULTICALL
X<MULTICALL>
-Make a lightweight callback. See L<perlcall/Lightweight Callbacks>.
+Make a lightweight callback. See L<perlcall/LIGHTWEIGHT CALLBACKS>.
MULTICALL;
@@ -4604,7 +5262,7 @@ Found in file cop.h
X<POP_MULTICALL>
Closing bracket for a lightweight callback.
-See L<perlcall/Lightweight Callbacks>.
+See L<perlcall/LIGHTWEIGHT CALLBACKS>.
POP_MULTICALL;
@@ -4615,7 +5273,7 @@ Found in file cop.h
X<PUSH_MULTICALL>
Opening bracket for a lightweight callback.
-See L<perlcall/Lightweight Callbacks>.
+See L<perlcall/LIGHTWEIGHT CALLBACKS>.
PUSH_MULTICALL;
@@ -4653,7 +5311,8 @@ C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If
C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the binary
number may use '_' characters to separate digits.
- UV grok_bin(const char* start, STRLEN* len_p, I32* flags, NV *result)
+ UV grok_bin(const char* start, STRLEN* len_p,
+ I32* flags, NV *result)
=for hackers
Found in file numeric.c
@@ -4682,7 +5341,8 @@ C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If
C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the hex
number may use '_' characters to separate digits.
- UV grok_hex(const char* start, STRLEN* len_p, I32* flags, NV *result)
+ UV grok_hex(const char* start, STRLEN* len_p,
+ I32* flags, NV *result)
=for hackers
Found in file numeric.c
@@ -4708,7 +5368,8 @@ IS_NUMBER_NEG if the number is negative (in which case *valuep holds the
absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the
number is larger than a UV.
- int grok_number(const char *pv, STRLEN len, UV *valuep)
+ int grok_number(const char *pv, STRLEN len,
+ UV *valuep)
=for hackers
Found in file numeric.c
@@ -4718,7 +5379,8 @@ X<grok_numeric_radix>
Scan and skip for a numeric decimal separator (radix).
- bool grok_numeric_radix(const char **sp, const char *send)
+ bool grok_numeric_radix(const char **sp,
+ const char *send)
=for hackers
Found in file numeric.c
@@ -4745,7 +5407,8 @@ is NULL).
If C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the octal
number may use '_' characters to separate digits.
- UV grok_oct(const char* start, STRLEN* len_p, I32* flags, NV *result)
+ UV grok_oct(const char* start, STRLEN* len_p,
+ I32* flags, NV *result)
=for hackers
Found in file numeric.c
@@ -4786,7 +5449,8 @@ X<scan_bin>
For backwards compatibility. Use C<grok_bin> instead.
- NV scan_bin(const char* start, STRLEN len, STRLEN* retlen)
+ NV scan_bin(const char* start, STRLEN len,
+ STRLEN* retlen)
=for hackers
Found in file numeric.c
@@ -4796,7 +5460,8 @@ X<scan_hex>
For backwards compatibility. Use C<grok_hex> instead.
- NV scan_hex(const char* start, STRLEN len, STRLEN* retlen)
+ NV scan_hex(const char* start, STRLEN len,
+ STRLEN* retlen)
=for hackers
Found in file numeric.c
@@ -4806,7 +5471,8 @@ X<scan_oct>
For backwards compatibility. Use C<grok_oct> instead.
- NV scan_oct(const char* start, STRLEN len, STRLEN* retlen)
+ NV scan_oct(const char* start, STRLEN len,
+ STRLEN* retlen)
=for hackers
Found in file numeric.c
@@ -4838,7 +5504,8 @@ will be set automatically, and, shifted up eight bits, the eight bits
of C<op_private>, except that the bit with value 1 or 2 is automatically
set as required.
- OP * newASSIGNOP(I32 flags, OP *left, I32 optype, OP *right)
+ OP * newASSIGNOP(I32 flags, OP *left, I32 optype,
+ OP *right)
=for hackers
Found in file op.c
@@ -4854,7 +5521,8 @@ the eight bits of C<op_private>, except that the bit with value 1 or
two ops to be the direct children of the binary op; they are consumed
by this function and become part of the constructed op tree.
- OP * newBINOP(I32 type, I32 flags, OP *first, OP *last)
+ OP * newBINOP(I32 type, I32 flags, OP *first,
+ OP *last)
=for hackers
Found in file op.c
@@ -4870,7 +5538,8 @@ I<first> supplies the expression selecting between the two branches,
and I<trueop> and I<falseop> supply the branches; they are consumed by
this function and become part of the constructed op tree.
- OP * newCONDOP(I32 flags, OP *first, OP *trueop, OP *falseop)
+ OP * newCONDOP(I32 flags, OP *first, OP *trueop,
+ OP *falseop)
=for hackers
Found in file op.c
@@ -4895,7 +5564,8 @@ op and, shifted up eight bits, the eight bits of C<op_private> for
the C<leaveloop> op, except that (in both cases) some bits will be set
automatically.
- OP * newFOROP(I32 flags, OP *sv, OP *expr, OP *block, OP *cont)
+ OP * newFOROP(I32 flags, OP *sv, OP *expr, OP *block,
+ OP *cont)
=for hackers
Found in file op.c
@@ -4910,7 +5580,8 @@ are consumed by this function and become part of the constructed op tree.
I<defsv_off> is the pad offset of the scalar lexical variable that will
be affected.
- OP * newGIVENOP(OP *cond, OP *block, PADOFFSET defsv_off)
+ OP * newGIVENOP(OP *cond, OP *block,
+ PADOFFSET defsv_off)
=for hackers
Found in file op.c
@@ -4938,7 +5609,8 @@ C<OPf_KIDS> will be set automatically if required. I<first> and I<last>
supply up to two ops to be direct children of the list op; they are
consumed by this function and become part of the constructed op tree.
- OP * newLISTOP(I32 type, I32 flags, OP *first, OP *last)
+ OP * newLISTOP(I32 type, I32 flags, OP *first,
+ OP *last)
=for hackers
Found in file op.c
@@ -4954,7 +5626,8 @@ automatically set. I<first> supplies the expression controlling the
flow, and I<other> supplies the side (alternate) chain of ops; they are
consumed by this function and become part of the constructed op tree.
- OP * newLOGOP(I32 type, I32 flags, OP *first, OP *other)
+ OP * newLOGOP(I32 type, I32 flags, OP *first,
+ OP *other)
=for hackers
Found in file op.c
@@ -4985,7 +5658,8 @@ supplies the body of the loop; they are consumed by this function and
become part of the constructed op tree. I<debuggable> is currently
unused and should always be 1.
- OP * newLOOPOP(I32 flags, I32 debuggable, OP *expr, OP *block)
+ OP * newLOOPOP(I32 flags, I32 debuggable, OP *expr,
+ OP *block)
=for hackers
Found in file op.c
@@ -5083,7 +5757,8 @@ set as required. I<listval> and I<subscript> supply the parameters of
the slice; they are consumed by this function and become part of the
constructed op tree.
- OP * newSLICEOP(I32 flags, OP *subscript, OP *listval)
+ OP * newSLICEOP(I32 flags, OP *subscript,
+ OP *listval)
=for hackers
Found in file op.c
@@ -5173,7 +5848,9 @@ automatically. I<debuggable> is currently unused and should always be 1.
I<has_my> can be supplied as true to force the
loop body to be enclosed in its own scope.
- OP * newWHILEOP(I32 flags, I32 debuggable, LOOP *loop, OP *expr, OP *block, OP *cont, I32 has_my)
+ OP * newWHILEOP(I32 flags, I32 debuggable,
+ LOOP *loop, OP *expr, OP *block,
+ OP *cont, I32 has_my)
=for hackers
Found in file op.c
@@ -5225,7 +5902,8 @@ exception at the top level of parsing which covers all the compilation
errors that occurred. In the error message, the callee is referred to
by the name defined by the I<namegv> parameter.
- OP * ck_entersub_args_proto(OP *entersubop, GV *namegv, SV *protosv)
+ OP * ck_entersub_args_proto(OP *entersubop,
+ GV *namegv, SV *protosv)
=for hackers
Found in file op.c
@@ -5254,7 +5932,9 @@ exception at the top level of parsing which covers all the compilation
errors that occurred. In the error message, the callee is referred to
by the name defined by the I<namegv> parameter.
- OP * ck_entersub_args_proto_or_list(OP *entersubop, GV *namegv, SV *protosv)
+ OP * ck_entersub_args_proto_or_list(OP *entersubop,
+ GV *namegv,
+ SV *protosv)
=for hackers
Found in file op.c
@@ -5300,7 +5980,9 @@ and the SV parameter is I<cv> itself. This implements standard
prototype processing. It can be changed, for a particular subroutine,
by L</cv_set_call_checker>.
- void cv_get_call_checker(CV *cv, Perl_call_checker *ckfun_p, SV **ckobj_p)
+ void cv_get_call_checker(CV *cv,
+ Perl_call_checker *ckfun_p,
+ SV **ckobj_p)
=for hackers
Found in file op.c
@@ -5329,7 +6011,9 @@ such as to a call to a different subroutine or to a method call.
The current setting for a particular CV can be retrieved by
L</cv_get_call_checker>.
- void cv_set_call_checker(CV *cv, Perl_call_checker ckfun, SV *ckobj)
+ void cv_set_call_checker(CV *cv,
+ Perl_call_checker ckfun,
+ SV *ckobj)
=for hackers
Found in file op.c
@@ -5351,15 +6035,28 @@ Found in file op.h
=item newCONSTSUB
X<newCONSTSUB>
+See L</newCONSTSUB_flags>.
+
+ CV* newCONSTSUB(HV* stash, const char* name, SV* sv)
+
+=for hackers
+Found in file op.c
+
+=item newCONSTSUB_flags
+X<newCONSTSUB_flags>
+
Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is
eligible for inlining at compile-time.
+Currently, the only useful value for C<flags> is SVf_UTF8.
+
Passing NULL for SV creates a constant sub equivalent to C<sub BAR () {}>,
which won't be called if used as a destructor, but will suppress the overhead
of a call to C<AUTOLOAD>. (This form, however, isn't eligible for inlining at
compile time.)
- CV* newCONSTSUB(HV* stash, const char* name, SV* sv)
+ CV* newCONSTSUB_flags(HV* stash, const char* name,
+ STRLEN len, U32 flags, SV* sv)
=for hackers
Found in file op.c
@@ -5423,7 +6120,7 @@ X<OP_DESC>
Return a short description of the provided OP.
- const char * OP_DESC(OP *o)
+ const char * OP_DESC(OP *o)
=for hackers
Found in file op.h
@@ -5469,7 +6166,7 @@ X<OP_NAME>
Return the name of the provided OP. For core ops this looks up the name
from the op_type; for custom ops from the op_ppaddr.
- const char * OP_NAME(OP *o)
+ const char * OP_NAME(OP *o)
=for hackers
Found in file op.h
@@ -5552,6 +6249,183 @@ Found in file op.c
=back
+=head1 Pad Data Structures
+
+=over 8
+
+=item CvPADLIST
+X<CvPADLIST>
+
+CV's can have CvPADLIST(cv) set to point to an AV. This is the CV's
+scratchpad, which stores lexical variables and opcode temporary and
+per-thread values.
+
+For these purposes "forms" are a kind-of CV, eval""s are too (except they're
+not callable at will and are always thrown away after the eval"" is done
+executing). Require'd files are simply evals without any outer lexical
+scope.
+
+XSUBs don't have CvPADLIST set - dXSTARG fetches values from PL_curpad,
+but that is really the callers pad (a slot of which is allocated by
+every entersub).
+
+The CvPADLIST AV has the REFCNT of its component items managed "manually"
+(mostly in pad.c) rather than by normal av.c rules. So we turn off AvREAL
+just before freeing it, to let av.c know not to touch the entries.
+The items in the AV are not SVs as for a normal AV, but other AVs:
+
+0'th Entry of the CvPADLIST is an AV which represents the "names" or rather
+the "static type information" for lexicals.
+
+The CvDEPTH'th entry of CvPADLIST AV is an AV which is the stack frame at that
+depth of recursion into the CV.
+The 0'th slot of a frame AV is an AV which is @_.
+other entries are storage for variables and op targets.
+
+Iterating over the names AV iterates over all possible pad
+items. Pad slots that are SVs_PADTMP (targets/GVs/constants) end up having
+&PL_sv_undef "names" (see pad_alloc()).
+
+Only my/our variable (SVs_PADMY/SVs_PADOUR) slots get valid names.
+The rest are op targets/GVs/constants which are statically allocated
+or resolved at compile time. These don't have names by which they
+can be looked up from Perl code at run time through eval"" like
+my/our variables can be. Since they can't be looked up by "name"
+but only by their index allocated at compile time (which is usually
+in PL_op->op_targ), wasting a name SV for them doesn't make sense.
+
+The SVs in the names AV have their PV being the name of the variable.
+xlow+1..xhigh inclusive in the NV union is a range of cop_seq numbers for
+which the name is valid (accessed through the macros COP_SEQ_RANGE_LOW and
+_HIGH). During compilation, these fields may hold the special value
+PERL_PADSEQ_INTRO to indicate various stages:
+
+ COP_SEQ_RANGE_LOW _HIGH
+ ----------------- -----
+ PERL_PADSEQ_INTRO 0 variable not yet introduced: { my ($x
+ valid-seq# PERL_PADSEQ_INTRO variable in scope: { my ($x)
+ valid-seq# valid-seq# compilation of scope complete: { my ($x) }
+
+For typed lexicals name SV is SVt_PVMG and SvSTASH
+points at the type. For C<our> lexicals, the type is also SVt_PVMG, with the
+SvOURSTASH slot pointing at the stash of the associated global (so that
+duplicate C<our> declarations in the same package can be detected). SvUVX is
+sometimes hijacked to store the generation number during compilation.
+
+If SvFAKE is set on the name SV, then that slot in the frame AV is
+a REFCNT'ed reference to a lexical from "outside". In this case,
+the name SV does not use xlow and xhigh to store a cop_seq range, since it is
+in scope throughout. Instead xhigh stores some flags containing info about
+the real lexical (is it declared in an anon, and is it capable of being
+instantiated multiple times?), and for fake ANONs, xlow contains the index
+within the parent's pad where the lexical's value is stored, to make
+cloning quicker.
+
+If the 'name' is '&' the corresponding entry in frame AV
+is a CV representing a possible closure.
+(SvFAKE and name of '&' is not a meaningful combination currently but could
+become so if C<my sub foo {}> is implemented.)
+
+Note that formats are treated as anon subs, and are cloned each time
+write is called (if necessary).
+
+The flag SVs_PADSTALE is cleared on lexicals each time the my() is executed,
+and set on scope exit. This allows the 'Variable $x is not available' warning
+to be generated in evals, such as
+
+ { my $x = 1; sub f { eval '$x'} } f();
+
+For state vars, SVs_PADSTALE is overloaded to mean 'not yet initialised'
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+ PADLIST * CvPADLIST(CV *cv)
+
+=for hackers
+Found in file pad.c
+
+=item pad_add_name_pvs
+X<pad_add_name_pvs>
+
+Exactly like L</pad_add_name_pvn>, but takes a literal string instead
+of a string/length pair.
+
+ PADOFFSET pad_add_name_pvs(const char *name, U32 flags,
+ HV *typestash, HV *ourstash)
+
+=for hackers
+Found in file pad.h
+
+=item pad_findmy_pvs
+X<pad_findmy_pvs>
+
+Exactly like L</pad_findmy_pvn>, but takes a literal string instead
+of a string/length pair.
+
+ PADOFFSET pad_findmy_pvs(const char *name, U32 flags)
+
+=for hackers
+Found in file pad.h
+
+=item pad_new
+X<pad_new>
+
+Create a new padlist, updating the global variables for the
+currently-compiling padlist to point to the new padlist. The following
+flags can be OR'ed together:
+
+ padnew_CLONE this pad is for a cloned CV
+ padnew_SAVE save old globals on the save stack
+ padnew_SAVESUB also save extra stuff for start of sub
+
+ PADLIST * pad_new(int flags)
+
+=for hackers
+Found in file pad.c
+
+=item PL_comppad
+X<PL_comppad>
+
+During compilation, this points to the array containing the values
+part of the pad for the currently-compiling code. (At runtime a CV may
+have many such value arrays; at compile time just one is constructed.)
+At runtime, this points to the array containing the currently-relevant
+values for the pad for the currently-executing code.
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+=for hackers
+Found in file pad.c
+
+=item PL_comppad_name
+X<PL_comppad_name>
+
+During compilation, this points to the array containing the names part
+of the pad for the currently-compiling code.
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+=for hackers
+Found in file pad.c
+
+=item PL_curpad
+X<PL_curpad>
+
+Points directly to the body of the L</PL_comppad> array.
+(I.e., this is C<AvARRAY(PL_comppad)>.)
+
+NOTE: this function is experimental and may change or be
+removed without notice.
+
+=for hackers
+Found in file pad.c
+
+
+=back
+
=head1 Per-Interpreter Variables
=over 8
@@ -5698,7 +6572,7 @@ equivalent to the following snippet:
NULL will be returned if a REGEXP* is not found.
- REGEXP * SvRX(SV *sv)
+ REGEXP * SvRX(SV *sv)
=for hackers
Found in file regexp.h
@@ -6451,6 +7325,18 @@ Found in file sv.h
=over 8
+=item boolSV
+X<boolSV>
+
+Returns a true SV if C<b> is a true value, or a false SV if C<b> is 0.
+
+See also C<PL_sv_yes> and C<PL_sv_no>.
+
+ SV * boolSV(bool b)
+
+=for hackers
+Found in file sv.h
+
=item croak_xs_usage
X<croak_xs_usage>
@@ -6461,9 +7347,10 @@ A specialised variant of C<croak()> for emitting the usage message for xsubs
works out the package name and subroutine name from C<cv>, and then calls
C<croak()>. Hence if C<cv> is C<&ouch::awk>, it would call C<croak> as:
- Perl_croak(aTHX_ "Usage: %s::%s(%s)", "ouch" "awk", "eee_yow");
+ Perl_croak(aTHX_ "Usage: %"SVf"::%"SVf"(%s)", "ouch" "awk", "eee_yow");
- void croak_xs_usage(const CV *const cv, const char *const params)
+ void croak_xs_usage(const CV *const cv,
+ const char *const params)
=for hackers
Found in file universal.c
@@ -6500,7 +7387,8 @@ X<newSVpvn_utf8>
Creates a new SV and copies a string into it. If utf8 is true, calls
C<SvUTF8_on> on the new SV. Implemented as a wrapper around C<newSVpvn_flags>.
- SV* newSVpvn_utf8(NULLOK const char* s, STRLEN len, U32 utf8)
+ SV* newSVpvn_utf8(NULLOK const char* s, STRLEN len,
+ U32 utf8)
=for hackers
Found in file sv.h
@@ -6529,9 +7417,14 @@ Found in file sv.h
=item SvEND
X<SvEND>
-Returns a pointer to the last character in the string which is in the SV.
+Returns a pointer to the spot just after the last character in
+the string which is in the SV, where there is usually a trailing
+null (even though Perl scalars do not strictly require it).
See C<SvCUR>. Access the character as *(SvEND(sv)).
+Warning: If C<SvCUR> is equal to C<SvLEN>, then C<SvEND> points to
+unallocated memory.
+
char* SvEND(SV* sv)
=for hackers
@@ -6540,10 +7433,12 @@ Found in file sv.h
=item SvGAMAGIC
X<SvGAMAGIC>
-Returns true if the SV has get magic or overloading. If either is true then
+Returns true if the SV has get magic or
+overloading. If either is true then
the scalar is active data, and has the potential to return a new value every
-time it is accessed. Hence you must be careful to only read it once per user
-logical operation and work with that returned value. If neither is true then
+time it is accessed. Hence you must be careful to
+only read it once per user logical operation and work
+with that returned value. If neither is true then
the scalar's value cannot change unless written to.
U32 SvGAMAGIC(SV* sv)
@@ -6648,9 +7543,9 @@ Found in file sv.h
=item SvIsCOW
X<SvIsCOW>
-Returns a boolean indicating whether the SV is Copy-On-Write. (either shared
+Returns a boolean indicating whether the SV is Copy-On-Write (either shared
hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for
-COW)
+COW).
bool SvIsCOW(SV* sv)
@@ -6671,7 +7566,7 @@ Found in file sv.h
=item SvIV
X<SvIV>
-Coerces the given SV to an integer and returns it. See C<SvIVx> for a
+Coerces the given SV to an integer and returns it. See C<SvIVx> for a
version which guarantees to evaluate sv only once.
IV SvIV(SV* sv)
@@ -6683,7 +7578,7 @@ Found in file sv.h
X<SvIVX>
Returns the raw value in the SV's IV slot, without checks or conversions.
-Only use when you are sure SvIOK is true. See also C<SvIV()>.
+Only use when you are sure SvIOK is true. See also C<SvIV()>.
IV SvIVX(SV* sv)
@@ -6693,8 +7588,9 @@ Found in file sv.h
=item SvIVx
X<SvIVx>
-Coerces the given SV to an integer and returns it. Guarantees to evaluate
-C<sv> only once. Only use this if C<sv> is an expression with side effects,
+Coerces the given SV to an integer and returns it.
+Guarantees to evaluate C<sv> only once. Only use
+this if C<sv> is an expression with side effects,
otherwise use the more efficient C<SvIV>.
IV SvIVx(SV* sv)
@@ -6842,7 +7738,7 @@ Found in file sv.h
=item SvNV
X<SvNV>
-Coerce the given SV to a double and return it. See C<SvNVx> for a version
+Coerce the given SV to a double and return it. See C<SvNVx> for a version
which guarantees to evaluate sv only once.
NV SvNV(SV* sv)
@@ -6854,7 +7750,7 @@ Found in file sv.h
X<SvNVX>
Returns the raw value in the SV's NV slot, without checks or conversions.
-Only use when you are sure SvNOK is true. See also C<SvNV()>.
+Only use when you are sure SvNOK is true. See also C<SvNV()>.
NV SvNVX(SV* sv)
@@ -6864,8 +7760,9 @@ Found in file sv.h
=item SvNVx
X<SvNVx>
-Coerces the given SV to a double and returns it. Guarantees to evaluate
-C<sv> only once. Only use this if C<sv> is an expression with side effects,
+Coerces the given SV to a double and returns it.
+Guarantees to evaluate C<sv> only once. Only use
+this if C<sv> is an expression with side effects,
otherwise use the more efficient C<SvNV>.
NV SvNVx(SV* sv)
@@ -6924,9 +7821,9 @@ X<SvOOK_offset>
Reads into I<len> the offset from SvPVX back to the true start of the
allocated buffer, which will be non-zero if C<sv_chop> has been used to
-efficiently remove characters from start of the buffer. Implemented as a
+efficiently remove characters from start of the buffer. Implemented as a
macro, which takes the address of I<len>, which must be of type C<STRLEN>.
-Evaluates I<sv> more than once. Sets I<len> to 0 if C<SvOOK(sv)> is false.
+Evaluates I<sv> more than once. Sets I<len> to 0 if C<SvOOK(sv)> is false.
void SvOOK_offset(NN SV*sv, STRLEN len)
@@ -7002,7 +7899,7 @@ X<SvPV>
Returns a pointer to the string in the SV, or a stringified form of
the SV if the SV does not contain a string. The SV may cache the
-stringified version becoming C<SvPOK>. Handles 'get' magic. See also
+stringified version becoming C<SvPOK>. Handles 'get' magic. See also
C<SvPVx> for a version which guarantees to evaluate sv only once.
char* SvPV(SV* sv, STRLEN len)
@@ -7124,6 +8021,9 @@ X<SvPVX>
Returns a pointer to the physical string in the SV. The SV must contain a
string.
+This is also used to store the name of an autoloaded subroutine in an XS
+AUTOLOAD routine. See L<perlguts/Autoloading with XSUBs>.
+
char* SvPVX(SV* sv)
=for hackers
@@ -7134,7 +8034,7 @@ X<SvPVx>
A version of C<SvPV> which guarantees to evaluate C<sv> only once.
Only use this if C<sv> is an expression with side effects, otherwise use the
-more efficient C<SvPVX>.
+more efficient C<SvPV>.
char* SvPVx(SV* sv, STRLEN len)
@@ -7158,7 +8058,7 @@ X<SvPV_force_nomg>
Like C<SvPV> but will force the SV into containing just a string
(C<SvPOK_only>). You want force if you are going to update the C<SvPVX>
-directly. Doesn't process magic.
+directly. Doesn't process magic.
char* SvPV_force_nomg(SV* sv, STRLEN len)
@@ -7396,7 +8296,11 @@ Found in file sv.h
=item SvTAINT
X<SvTAINT>
-Taints an SV if tainting is enabled.
+Taints an SV if tainting is enabled, and if some input to the current
+expression is tainted--usually a variable, but possibly also implicit
+inputs such as locale settings. C<SvTAINT> propagates that taintedness to
+the outputs of an expression in a pessimistic fashion; i.e., without paying
+attention to precisely which outputs are influenced by which inputs.
void SvTAINT(SV* sv)
@@ -7406,7 +8310,7 @@ Found in file sv.h
=item SvTAINTED
X<SvTAINTED>
-Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if
+Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if
not.
bool SvTAINTED(SV* sv)
@@ -7417,8 +8321,8 @@ Found in file sv.h
=item SvTAINTED_off
X<SvTAINTED_off>
-Untaints an SV. Be I<very> careful with this routine, as it short-circuits
-some of Perl's fundamental security features. XS module authors should not
+Untaints an SV. Be I<very> careful with this routine, as it short-circuits
+some of Perl's fundamental security features. XS module authors should not
use this function unless they fully understand all the implications of
unconditionally untainting the value. Untainting should be done in the
standard perl fashion, via a carefully crafted regexp, rather than directly
@@ -7497,7 +8401,8 @@ Found in file sv.h
=item SvUTF8
X<SvUTF8>
-Returns a U32 value indicating whether the SV contains UTF-8 encoded data.
+Returns a U32 value indicating the UTF-8 status of an SV. If things are set-up
+properly, this indicates whether or not the SV contains UTF-8 encoded data.
Call this after SvPV() in case any call to string overloading updates the
internal flag.
@@ -7509,7 +8414,8 @@ Found in file sv.h
=item SvUTF8_off
X<SvUTF8_off>
-Unsets the UTF-8 status of an SV.
+Unsets the UTF-8 status of an SV (the data is not changed, just the flag).
+Do not use frivolously.
void SvUTF8_off(SV *sv)
@@ -7542,7 +8448,7 @@ Found in file sv.h
X<SvUVX>
Returns the raw value in the SV's UV slot, without checks or conversions.
-Only use when you are sure SvIOK is true. See also C<SvUV()>.
+Only use when you are sure SvIOK is true. See also C<SvUV()>.
UV SvUVX(SV* sv)
@@ -7552,8 +8458,9 @@ Found in file sv.h
=item SvUVx
X<SvUVx>
-Coerces the given SV to an unsigned integer and returns it. Guarantees to
-C<sv> only once. Only use this if C<sv> is an expression with side effects,
+Coerces the given SV to an unsigned integer and
+returns it. Guarantees to C<sv> only once. Only
+use this if C<sv> is an expression with side effects,
otherwise use the more efficient C<SvUV>.
UV SvUVx(SV* sv)
@@ -7596,7 +8503,8 @@ X<sv_catpvn_nomg>
Like C<sv_catpvn> but doesn't process magic.
- void sv_catpvn_nomg(SV* sv, const char* ptr, STRLEN len)
+ void sv_catpvn_nomg(SV* sv, const char* ptr,
+ STRLEN len)
=for hackers
Found in file sv.h
@@ -7624,11 +8532,50 @@ Found in file sv.h
=item sv_derived_from
X<sv_derived_from>
+Exactly like L</sv_derived_from_pv>, but doesn't take a C<flags> parameter.
+
+ bool sv_derived_from(SV* sv, const char *const name)
+
+=for hackers
+Found in file universal.c
+
+=item sv_derived_from_pv
+X<sv_derived_from_pv>
+
+Exactly like L</sv_derived_from_pvn>, but takes a nul-terminated string
+instead of a string/length pair.
+
+ bool sv_derived_from_pv(SV* sv,
+ const char *const name,
+ U32 flags)
+
+=for hackers
+Found in file universal.c
+
+=item sv_derived_from_pvn
+X<sv_derived_from_pvn>
+
Returns a boolean indicating whether the SV is derived from the specified class
I<at the C level>. To check derivation at the Perl level, call C<isa()> as a
normal Perl method.
- bool sv_derived_from(SV* sv, const char *const name)
+Currently, the only significant value for C<flags> is SVf_UTF8.
+
+ bool sv_derived_from_pvn(SV* sv,
+ const char *const name,
+ const STRLEN len, U32 flags)
+
+=for hackers
+Found in file universal.c
+
+=item sv_derived_from_sv
+X<sv_derived_from_sv>
+
+Exactly like L</sv_derived_from_pvn>, but takes the name string in the form
+of an SV instead of a string/length pair.
+
+ bool sv_derived_from_sv(SV* sv, SV *namesv,
+ U32 flags)
=for hackers
Found in file universal.c
@@ -7636,10 +8583,42 @@ Found in file universal.c
=item sv_does
X<sv_does>
+Like L</sv_does_pv>, but doesn't take a C<flags> parameter.
+
+ bool sv_does(SV* sv, const char *const name)
+
+=for hackers
+Found in file universal.c
+
+=item sv_does_pv
+X<sv_does_pv>
+
+Like L</sv_does_sv>, but takes a nul-terminated string instead of an SV.
+
+ bool sv_does_pv(SV* sv, const char *const name,
+ U32 flags)
+
+=for hackers
+Found in file universal.c
+
+=item sv_does_pvn
+X<sv_does_pvn>
+
+Like L</sv_does_sv>, but takes a string/length pair instead of an SV.
+
+ bool sv_does_pvn(SV* sv, const char *const name,
+ const STRLEN len, U32 flags)
+
+=for hackers
+Found in file universal.c
+
+=item sv_does_sv
+X<sv_does_sv>
+
Returns a boolean indicating whether the SV performs a specific, named role.
The SV can be a Perl object or the name of a Perl class.
- bool sv_does(SV* sv, const char *const name)
+ bool sv_does_sv(SV* sv, SV* namesv, U32 flags)
=for hackers
Found in file universal.c
@@ -7647,7 +8626,7 @@ Found in file universal.c
=item sv_report_used
X<sv_report_used>
-Dump the contents of all SVs not yet freed. (Debugging aid).
+Dump the contents of all SVs not yet freed (debugging aid).
void sv_report_used()
@@ -7667,7 +8646,7 @@ Found in file sv.h
=item sv_utf8_upgrade_nomg
X<sv_utf8_upgrade_nomg>
-Like sv_utf8_upgrade, but doesn't do magic on C<sv>
+Like sv_utf8_upgrade, but doesn't do magic on C<sv>.
STRLEN sv_utf8_upgrade_nomg(NN SV *sv)
@@ -7686,7 +8665,8 @@ X<looks_like_number>
Test if the content of an SV looks like a number (or is a number).
C<Inf> and C<Infinity> are treated as numbers (so will not issue a
-non-numeric warning), even if your atof() doesn't grok them.
+non-numeric warning), even if your atof() doesn't grok them. Get-magic is
+ignored.
I32 looks_like_number(SV *const sv)
@@ -7715,7 +8695,7 @@ space is allocated.) The reference count for the new SV is set to 1.
In 5.9.3, newSV() replaces the older NEWSV() API, and drops the first
parameter, I<x>, a debug aid which allowed callers to identify themselves.
This aid has been superseded by a new build option, PERL_MEM_LOG (see
-L<perlhack/PERL_MEM_LOG>). The older API is still there for use in XS
+L<perlhacktips/PERL_MEM_LOG>). The older API is still there for use in XS
modules supporting older perls.
SV* newSV(const STRLEN len)
@@ -7727,7 +8707,7 @@ Found in file sv.c
X<newSVhek>
Creates a new SV from the hash key structure. It will generate scalars that
-point to the shared string table where possible. Returns a new (undefined)
+point to the shared string table where possible. Returns a new (undefined)
SV if the hek is NULL.
SV* newSVhek(const HEK *const hek)
@@ -7783,10 +8763,12 @@ Found in file sv.c
=item newSVpvn
X<newSVpvn>
-Creates a new SV and copies a string into it. The reference count for the
-SV is set to 1. Note that if C<len> is zero, Perl will create a zero length
-string. You are responsible for ensuring that the source string is at least
-C<len> bytes long. If the C<s> argument is NULL the new SV will be undefined.
+Creates a new SV and copies a buffer into it, which may contain NUL characters
+(C<\0>) and other binary data. The reference count for the SV is set to 1.
+Note that if C<len> is zero, Perl will create a zero length (Perl) string. You
+are responsible for ensuring that the source buffer is at least
+C<len> bytes long. If the C<buffer> argument is NULL the new SV will be
+undefined.
SV* newSVpvn(const char *const s, const STRLEN len)
@@ -7802,14 +8784,17 @@ string. You are responsible for ensuring that the source string is at least
C<len> bytes long. If the C<s> argument is NULL the new SV will be undefined.
Currently the only flag bits accepted are C<SVf_UTF8> and C<SVs_TEMP>.
If C<SVs_TEMP> is set, then C<sv_2mortal()> is called on the result before
-returning. If C<SVf_UTF8> is set, C<s> is considered to be in UTF-8 and the
+returning. If C<SVf_UTF8> is set, C<s>
+is considered to be in UTF-8 and the
C<SVf_UTF8> flag will be set on the new SV.
C<newSVpvn_utf8()> is a convenience wrapper for this function, defined as
#define newSVpvn_utf8(s, len, u) \
newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0)
- SV* newSVpvn_flags(const char *const s, const STRLEN len, const U32 flags)
+ SV* newSVpvn_flags(const char *const s,
+ const STRLEN len,
+ const U32 flags)
=for hackers
Found in file sv.c
@@ -7818,10 +8803,11 @@ Found in file sv.c
X<newSVpvn_share>
Creates a new SV with its SvPVX_const pointing to a shared string in the string
-table. If the string does not already exist in the table, it is created
-first. Turns on READONLY and FAKE. If the C<hash> parameter is non-zero, that
-value is used; otherwise the hash is computed. The string's hash can be later
-be retrieved from the SV with the C<SvSHARED_HASH()> macro. The idea here is
+table. If the string does not already exist in the table, it is
+created first. Turns on READONLY and FAKE. If the C<hash> parameter
+is non-zero, that value is used; otherwise the hash is computed.
+The string's hash can later be retrieved from the SV
+with the C<SvSHARED_HASH()> macro. The idea here is
that as the string table is used for shared hash keys these strings will have
SvPVX_const == HeKEY and hash lookup will avoid string compare.
@@ -7881,7 +8867,8 @@ it will be upgraded to one. If C<classname> is non-null then the new SV will
be blessed in the specified package. The new SV is returned and its
reference count is 1.
- SV* newSVrv(SV *const rv, const char *const classname)
+ SV* newSVrv(SV *const rv,
+ const char *const classname)
=for hackers
Found in file sv.c
@@ -7890,7 +8877,7 @@ Found in file sv.c
X<newSVsv>
Creates a new SV which is an exact duplicate of the original SV.
-(Uses C<sv_setsv>).
+(Uses C<sv_setsv>.)
SV* newSVsv(SV *const old)
@@ -7935,7 +8922,7 @@ Found in file sv.c
X<sv_2bool_flags>
This function is only used by sv_true() and friends, and only if
-the latter's argument is neither SvPOK, SvIOK nor SvNOK. If the flags
+the latter's argument is neither SvPOK, SvIOK nor SvNOK. If the flags
contain SV_GMAGIC, then it does an mg_get() first.
@@ -7951,7 +8938,8 @@ Using various gambits, try to get a CV from an SV; in addition, try if
possible to set C<*st> and C<*gvp> to the stash and GV associated with it.
The flags in C<lref> are passed to gv_fetchsv.
- CV* sv_2cv(SV* sv, HV **const st, GV **const gvp, const I32 lref)
+ CV* sv_2cv(SV* sv, HV **const st, GV **const gvp,
+ const I32 lref)
=for hackers
Found in file sv.c
@@ -7963,6 +8951,9 @@ Using various gambits, try to get an IO from an SV: the IO slot if its a
GV; or the recursive result if we're an RV; or the IO slot of the symbol
named after the PV if we're a string.
+'Get' magic is ignored on the sv passed in, but will be called on
+C<SvRV(sv)> if sv is an RV.
+
IO* sv_2io(SV *const sv)
=for hackers
@@ -7986,7 +8977,7 @@ X<sv_2mortal>
Marks an existing SV as mortal. The SV will be destroyed "soon", either
by an explicit call to FREETMPS, or by an implicit call at places such as
statement boundaries. SvTEMP() is turned on which means that the SV's
-string buffer can be "stolen" if this SV is copied. See also C<sv_newmortal>
+string buffer can be "stolen" if this SV is copied. See also C<sv_newmortal>
and C<sv_mortalcopy>.
SV* sv_2mortal(SV *const sv)
@@ -7998,7 +8989,7 @@ Found in file sv.c
X<sv_2nv_flags>
Return the num value of an SV, doing any necessary string or integer
-conversion. If flags includes SV_GMAGIC, does an mg_get() first.
+conversion. If flags includes SV_GMAGIC, does an mg_get() first.
Normally used via the C<SvNV(sv)> and C<SvNVx(sv)> macros.
NV sv_2nv_flags(SV *const sv, const I32 flags)
@@ -8015,7 +9006,7 @@ side-effect.
Usually accessed via the C<SvPVbyte> macro.
- char* sv_2pvbyte(SV *const sv, STRLEN *const lp)
+ char* sv_2pvbyte(SV *sv, STRLEN *const lp)
=for hackers
Found in file sv.c
@@ -8028,7 +9019,7 @@ to its length. May cause the SV to be upgraded to UTF-8 as a side-effect.
Usually accessed via the C<SvPVutf8> macro.
- char* sv_2pvutf8(SV *const sv, STRLEN *const lp)
+ char* sv_2pvutf8(SV *sv, STRLEN *const lp)
=for hackers
Found in file sv.c
@@ -8037,12 +9028,12 @@ Found in file sv.c
X<sv_2pv_flags>
Returns a pointer to the string value of an SV, and sets *lp to its length.
-If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string
-if necessary.
-Normally invoked via the C<SvPV_flags> macro. C<sv_2pv()> and C<sv_2pv_nomg>
-usually end up here too.
+If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a
+string if necessary. Normally invoked via the C<SvPV_flags> macro.
+C<sv_2pv()> and C<sv_2pv_nomg> usually end up here too.
- char* sv_2pv_flags(SV *const sv, STRLEN *const lp, const I32 flags)
+ char* sv_2pv_flags(SV *const sv, STRLEN *const lp,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -8062,7 +9053,7 @@ Found in file sv.c
=item sv_backoff
X<sv_backoff>
-Remove any string offset. You should normally use the C<SvOOK_off> macro
+Remove any string offset. You should normally use the C<SvOOK_off> macro
wrapper instead.
int sv_backoff(SV *const sv)
@@ -8102,10 +9093,11 @@ output to an SV. If the appended data contains "wide" characters
(including, but not limited to, SVs with a UTF-8 PV formatted with %s,
and characters >255 formatted with %c), the original SV might get
upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. See
-C<sv_catpvf_mg>. If the original SV was UTF-8, the pattern should be
+C<sv_catpvf_mg>. If the original SV was UTF-8, the pattern should be
valid UTF-8; if the original SV was bytes, the pattern should be too.
- void sv_catpvf(SV *const sv, const char *const pat, ...)
+ void sv_catpvf(SV *const sv, const char *const pat,
+ ...)
=for hackers
Found in file sv.c
@@ -8115,7 +9107,8 @@ X<sv_catpvf_mg>
Like C<sv_catpvf>, but also handles 'set' magic.
- void sv_catpvf_mg(SV *const sv, const char *const pat, ...)
+ void sv_catpvf_mg(SV *const sv,
+ const char *const pat, ...)
=for hackers
Found in file sv.c
@@ -8139,11 +9132,15 @@ X<sv_catpvn_flags>
Concatenates the string onto the end of the string which is in the SV. The
C<len> indicates number of bytes to copy. If the SV has the UTF-8
status set, then the bytes appended should be valid UTF-8.
-If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<dsv> if
-appropriate, else not. C<sv_catpvn> and C<sv_catpvn_nomg> are implemented
+If C<flags> has the C<SV_SMAGIC> bit set, will
+C<mg_set> on C<dsv> afterwards if appropriate.
+C<sv_catpvn> and C<sv_catpvn_nomg> are implemented
in terms of this function.
- void sv_catpvn_flags(SV *const dstr, const char *sstr, const STRLEN len, const I32 flags)
+ void sv_catpvn_flags(SV *const dstr,
+ const char *sstr,
+ const STRLEN len,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -8164,7 +9161,8 @@ X<sv_catpvs_flags>
Like C<sv_catpvn_flags>, but takes a literal string instead of a
string/length pair.
- void sv_catpvs_flags(SV* sv, const char* s, I32 flags)
+ void sv_catpvs_flags(SV* sv, const char* s,
+ I32 flags)
=for hackers
Found in file handy.h
@@ -8196,10 +9194,11 @@ X<sv_catpv_flags>
Concatenates the string onto the end of the string which is in the SV.
If the SV has the UTF-8 status set, then the bytes appended should
-be valid UTF-8. If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get>
-on the SVs if appropriate, else not.
+be valid UTF-8. If C<flags> has the C<SV_SMAGIC> bit set, will C<mg_set>
+on the modified SV if appropriate.
- void sv_catpv_flags(SV *dstr, const char *sstr, const I32 flags)
+ void sv_catpv_flags(SV *dstr, const char *sstr,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -8231,10 +9230,13 @@ X<sv_catsv_flags>
Concatenates the string from SV C<ssv> onto the end of the string in
SV C<dsv>. Modifies C<dsv> but not C<ssv>. If C<flags> has C<SV_GMAGIC>
-bit set, will C<mg_get> on the SVs if appropriate, else not. C<sv_catsv>
+bit set, will C<mg_get> on the C<ssv>, if appropriate, before
+reading it. If the C<flags> contain C<SV_SMAGIC>, C<mg_set> will be
+called on the modified SV afterward, if appropriate. C<sv_catsv>
and C<sv_catsv_nomg> are implemented in terms of this function.
- void sv_catsv_flags(SV *const dsv, SV *const ssv, const I32 flags)
+ void sv_catsv_flags(SV *const dsv, SV *const ssv,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -8245,10 +9247,15 @@ X<sv_chop>
Efficient removal of characters from the beginning of the string buffer.
SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside
the string buffer. The C<ptr> becomes the first character of the adjusted
-string. Uses the "OOK hack".
+string. Uses the "OOK hack".
+
Beware: after this function returns, C<ptr> and SvPVX_const(sv) may no longer
refer to the same chunk of data.
+The unfortunate similarity of this function's name to that of Perl's C<chop>
+operator is strictly coincidental. This function works from the left;
+C<chop> works from the right.
+
void sv_chop(SV *const sv, const char *const ptr)
=for hackers
@@ -8258,10 +9265,10 @@ Found in file sv.c
X<sv_clear>
Clear an SV: call any destructors, free up any memory used by the body,
-and free the body itself. The SV's head is I<not> freed, although
+and free the body itself. The SV's head is I<not> freed, although
its type is set to all 1's so that it won't inadvertently be assumed
to be live during global destruction etc.
-This function should only be called when REFCNT is zero. Most of the time
+This function should only be called when REFCNT is zero. Most of the time
you'll want to call C<sv_free()> (or its macro wrapper C<SvREFCNT_dec>)
instead.
@@ -8275,7 +9282,7 @@ X<sv_cmp>
Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the
string in C<sv1> is less than, equal to, or greater than the string in
-C<sv2>. Is UTF-8 and 'use bytes' aware, handles get magic, and will
+C<sv2>. Is UTF-8 and 'use bytes' aware, handles get magic, and will
coerce its args to strings if necessary. See also C<sv_cmp_locale>.
I32 sv_cmp(SV *const sv1, SV *const sv2)
@@ -8288,11 +9295,12 @@ X<sv_cmp_flags>
Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the
string in C<sv1> is less than, equal to, or greater than the string in
-C<sv2>. Is UTF-8 and 'use bytes' aware and will coerce its args to strings
-if necessary. If the flags include SV_GMAGIC, it handles get magic. See
+C<sv2>. Is UTF-8 and 'use bytes' aware and will coerce its args to strings
+if necessary. If the flags include SV_GMAGIC, it handles get magic. See
also C<sv_cmp_locale_flags>.
- I32 sv_cmp_flags(SV *const sv1, SV *const sv2, const U32 flags)
+ I32 sv_cmp_flags(SV *const sv1, SV *const sv2,
+ const U32 flags)
=for hackers
Found in file sv.c
@@ -8300,7 +9308,7 @@ Found in file sv.c
=item sv_cmp_locale
X<sv_cmp_locale>
-Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and
+Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and
'use bytes' aware, handles get magic, and will coerce its args to strings
if necessary. See also C<sv_cmp>.
@@ -8312,11 +9320,13 @@ Found in file sv.c
=item sv_cmp_locale_flags
X<sv_cmp_locale_flags>
-Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and
-'use bytes' aware and will coerce its args to strings if necessary. If the
-flags contain SV_GMAGIC, it handles get magic. See also C<sv_cmp_flags>.
+Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and
+'use bytes' aware and will coerce its args to strings if necessary. If the
+flags contain SV_GMAGIC, it handles get magic. See also C<sv_cmp_flags>.
- I32 sv_cmp_locale_flags(SV *const sv1, SV *const sv2, const U32 flags)
+ I32 sv_cmp_locale_flags(SV *const sv1,
+ SV *const sv2,
+ const U32 flags)
=for hackers
Found in file sv.c
@@ -8324,7 +9334,7 @@ Found in file sv.c
=item sv_collxfrm
X<sv_collxfrm>
-This calls C<sv_collxfrm_flags> with the SV_GMAGIC flag. See
+This calls C<sv_collxfrm_flags> with the SV_GMAGIC flag. See
C<sv_collxfrm_flags>.
char* sv_collxfrm(SV *const sv, STRLEN *const nxp)
@@ -8335,7 +9345,7 @@ Found in file sv.c
=item sv_collxfrm_flags
X<sv_collxfrm_flags>
-Add Collate Transform magic to an SV if it doesn't already have it. If the
+Add Collate Transform magic to an SV if it doesn't already have it. If the
flags contain SV_GMAGIC, it handles get-magic.
Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the
@@ -8343,7 +9353,9 @@ scalar data of the variable, but transformed to such a format that a normal
memory comparison can be used to compare the data according to the locale
settings.
- char* sv_collxfrm_flags(SV *const sv, STRLEN *const nxp, I32 const flags)
+ char* sv_collxfrm_flags(SV *const sv,
+ STRLEN *const nxp,
+ I32 const flags)
=for hackers
Found in file sv.c
@@ -8368,7 +9380,7 @@ Found in file sv.c
X<sv_dec>
Auto-decrement of the value in the SV, doing string to numeric conversion
-if necessary. Handles 'get' magic and operator overloading.
+if necessary. Handles 'get' magic and operator overloading.
void sv_dec(SV *const sv)
@@ -8379,7 +9391,7 @@ Found in file sv.c
X<sv_dec_nomg>
Auto-decrement of the value in the SV, doing string to numeric conversion
-if necessary. Handles operator overloading. Skips handling 'get' magic.
+if necessary. Handles operator overloading. Skips handling 'get' magic.
void sv_dec_nomg(SV *const sv)
@@ -8390,7 +9402,7 @@ Found in file sv.c
X<sv_eq>
Returns a boolean indicating whether the strings in the two SVs are
-identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will
+identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will
coerce its args to strings if necessary.
I32 sv_eq(SV* sv1, SV* sv2)
@@ -8402,8 +9414,8 @@ Found in file sv.c
X<sv_eq_flags>
Returns a boolean indicating whether the strings in the two SVs are
-identical. Is UTF-8 and 'use bytes' aware and coerces its args to strings
-if necessary. If the flags include SV_GMAGIC, it handles get-magic, too.
+identical. Is UTF-8 and 'use bytes' aware and coerces its args to strings
+if necessary. If the flags include SV_GMAGIC, it handles get-magic, too.
I32 sv_eq_flags(SV* sv1, SV* sv2, const U32 flags)
@@ -8416,14 +9428,16 @@ X<sv_force_normal_flags>
Undo various types of fakery on an SV: if the PV is a shared string, make
a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
an xpvmg; if we're a copy-on-write scalar, this is the on-write time when
-we do the copy, and is also used locally. If C<SV_COW_DROP_PV> is set
+we do the copy, and is also used locally. If C<SV_COW_DROP_PV> is set
then a copy-on-write scalar drops its PV buffer (if any) and becomes
-SvPOK_off rather than making a copy. (Used where this scalar is about to be
-set to some other value.) In addition, the C<flags> parameter gets passed to
-C<sv_unref_flags()> when unreffing. C<sv_force_normal> calls this function
+SvPOK_off rather than making a copy. (Used where this
+scalar is about to be set to some other value.) In addition,
+the C<flags> parameter gets passed to C<sv_unref_flags()>
+when unreffing. C<sv_force_normal> calls this function
with flags set to 0.
- void sv_force_normal_flags(SV *const sv, const U32 flags)
+ void sv_force_normal_flags(SV *const sv,
+ const U32 flags)
=for hackers
Found in file sv.c
@@ -8447,7 +9461,8 @@ X<sv_gets>
Get a line from the filehandle and store it into the SV, optionally
appending to the currently-stored string.
- char* sv_gets(SV *const sv, PerlIO *const fp, I32 append)
+ char* sv_gets(SV *const sv, PerlIO *const fp,
+ I32 append)
=for hackers
Found in file sv.c
@@ -8468,7 +9483,7 @@ Found in file sv.c
X<sv_inc>
Auto-increment of the value in the SV, doing string to numeric conversion
-if necessary. Handles 'get' magic and operator overloading.
+if necessary. Handles 'get' magic and operator overloading.
void sv_inc(SV *const sv)
@@ -8479,7 +9494,7 @@ Found in file sv.c
X<sv_inc_nomg>
Auto-increment of the value in the SV, doing string to numeric conversion
-if necessary. Handles operator overloading. Skips handling 'get' magic.
+if necessary. Handles operator overloading. Skips handling 'get' magic.
void sv_inc_nomg(SV *const sv)
@@ -8489,10 +9504,13 @@ Found in file sv.c
=item sv_insert
X<sv_insert>
-Inserts a string at the specified offset/length within the SV. Similar to
-the Perl substr() function. Handles get magic.
+Inserts a string at the specified offset/length within the SV. Similar to
+the Perl substr() function. Handles get magic.
- void sv_insert(SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen)
+ void sv_insert(SV *const bigstr, const STRLEN offset,
+ const STRLEN len,
+ const char *const little,
+ const STRLEN littlelen)
=for hackers
Found in file sv.c
@@ -8500,9 +9518,15 @@ Found in file sv.c
=item sv_insert_flags
X<sv_insert_flags>
-Same as C<sv_insert>, but the extra C<flags> are passed the C<SvPV_force_flags> that applies to C<bigstr>.
+Same as C<sv_insert>, but the extra C<flags> are passed to the
+C<SvPV_force_flags> that applies to C<bigstr>.
- void sv_insert_flags(SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen, const U32 flags)
+ void sv_insert_flags(SV *const bigstr,
+ const STRLEN offset,
+ const STRLEN len,
+ const char *const little,
+ const STRLEN littlelen,
+ const U32 flags)
=for hackers
Found in file sv.c
@@ -8534,7 +9558,7 @@ Found in file sv.c
=item sv_len
X<sv_len>
-Returns the length of the string in the SV. Handles magic and type
+Returns the length of the string in the SV. Handles magic and type
coercion. See also C<SvCUR>, which gives raw access to the xpv_cur slot.
STRLEN sv_len(SV *const sv)
@@ -8546,7 +9570,7 @@ Found in file sv.c
X<sv_len_utf8>
Returns the number of characters in the string in an SV, counting wide
-UTF-8 bytes as a single character. Handles magic and type coercion.
+UTF-8 bytes as a single character. Handles magic and type coercion.
STRLEN sv_len_utf8(SV *const sv)
@@ -8556,8 +9580,9 @@ Found in file sv.c
=item sv_magic
X<sv_magic>
-Adds magic to an SV. First upgrades C<sv> to type C<SVt_PVMG> if necessary,
-then adds a new magic item of type C<how> to the head of the magic list.
+Adds magic to an SV. First upgrades C<sv> to type C<SVt_PVMG> if
+necessary, then adds a new magic item of type C<how> to the head of the
+magic list.
See C<sv_magicext> (which C<sv_magic> now calls) for a description of the
handling of the C<name> and C<namlen> arguments.
@@ -8565,7 +9590,9 @@ handling of the C<name> and C<namlen> arguments.
You need to use C<sv_magicext> to add magic to SvREADONLY SVs and also
to add more than one instance of the same 'how'.
- void sv_magic(SV *const sv, SV *const obj, const int how, const char *const name, const I32 namlen)
+ void sv_magic(SV *const sv, SV *const obj,
+ const int how, const char *const name,
+ const I32 namlen)
=for hackers
Found in file sv.c
@@ -8573,7 +9600,7 @@ Found in file sv.c
=item sv_magicext
X<sv_magicext>
-Adds magic to an SV, upgrading it if necessary. Applies the
+Adds magic to an SV, upgrading it if necessary. Applies the
supplied vtable and returns a pointer to the magic added.
Note that C<sv_magicext> will allow things that C<sv_magic> will not.
@@ -8587,7 +9614,11 @@ to contain an C<SV*> and is stored as-is with its REFCNT incremented.
(This is now used as a subroutine by C<sv_magic>.)
- MAGIC * sv_magicext(SV *const sv, SV *const obj, const int how, const MGVTBL *const vtbl, const char *const name, const I32 namlen)
+ MAGIC * sv_magicext(SV *const sv, SV *const obj,
+ const int how,
+ const MGVTBL *const vtbl,
+ const char *const name,
+ const I32 namlen)
=for hackers
Found in file sv.c
@@ -8596,7 +9627,7 @@ Found in file sv.c
X<sv_mortalcopy>
Creates a new SV which is a copy of the original SV (using C<sv_setsv>).
-The new SV is marked as mortal. It will be destroyed "soon", either by an
+The new SV is marked as mortal. It will be destroyed "soon", either by an
explicit call to FREETMPS, or by an implicit call at places such as
statement boundaries. See also C<sv_newmortal> and C<sv_2mortal>.
@@ -8609,7 +9640,7 @@ Found in file sv.c
X<sv_newmortal>
Creates a new null SV which is mortal. The reference count of the SV is
-set to 1. It will be destroyed "soon", either by an explicit call to
+set to 1. It will be destroyed "soon", either by an explicit call to
FREETMPS, or by an implicit call at places such as statement boundaries.
See also C<sv_mortalcopy> and C<sv_2mortal>.
@@ -8621,7 +9652,7 @@ Found in file sv.c
=item sv_newref
X<sv_newref>
-Increment an SV's reference count. Use the C<SvREFCNT_inc()> wrapper
+Increment an SV's reference count. Use the C<SvREFCNT_inc()> wrapper
instead.
SV* sv_newref(SV *const sv)
@@ -8647,13 +9678,14 @@ X<sv_pos_u2b>
Converts the value pointed to by offsetp from a count of UTF-8 chars from
the start of the string, to a count of the equivalent number of bytes; if
lenp is non-zero, it does the same to lenp, but this time starting from
-the offset, rather than from the start of the string. Handles magic and
+the offset, rather than from the start of the string. Handles magic and
type coercion.
Use C<sv_pos_u2b_flags> in preference, which correctly handles strings longer
than 2Gb.
- void sv_pos_u2b(SV *const sv, I32 *const offsetp, I32 *const lenp)
+ void sv_pos_u2b(SV *const sv, I32 *const offsetp,
+ I32 *const lenp)
=for hackers
Found in file sv.c
@@ -8664,11 +9696,13 @@ X<sv_pos_u2b_flags>
Converts the value pointed to by offsetp from a count of UTF-8 chars from
the start of the string, to a count of the equivalent number of bytes; if
lenp is non-zero, it does the same to lenp, but this time starting from
-the offset, rather than from the start of the string. Handles type coercion.
+the offset, rather than from the start
+of the string. Handles type coercion.
I<flags> is passed to C<SvPV_flags>, and usually should be
C<SV_GMAGIC|SV_CONST_RETURN> to handle magic.
- STRLEN sv_pos_u2b_flags(SV *const sv, STRLEN uoffset, STRLEN *const lenp, U32 flags)
+ STRLEN sv_pos_u2b_flags(SV *const sv, STRLEN uoffset,
+ STRLEN *const lenp, U32 flags)
=for hackers
Found in file sv.c
@@ -8676,7 +9710,8 @@ Found in file sv.c
=item sv_pvbyten_force
X<sv_pvbyten_force>
-The backend for the C<SvPVbytex_force> macro. Always use the macro instead.
+The backend for the C<SvPVbytex_force> macro. Always use the macro
+instead.
char* sv_pvbyten_force(SV *const sv, STRLEN *const lp)
@@ -8688,7 +9723,7 @@ X<sv_pvn_force>
Get a sensible string out of the SV somehow.
A private implementation of the C<SvPV_force> macro for compilers which
-can't cope with complex macro expressions. Always use the macro instead.
+can't cope with complex macro expressions. Always use the macro instead.
char* sv_pvn_force(SV* sv, STRLEN* lp)
@@ -8700,12 +9735,14 @@ X<sv_pvn_force_flags>
Get a sensible string out of the SV somehow.
If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<sv> if
-appropriate, else not. C<sv_pvn_force> and C<sv_pvn_force_nomg> are
+appropriate, else not. C<sv_pvn_force> and C<sv_pvn_force_nomg> are
implemented in terms of this function.
You normally want to use the various wrapper macros instead: see
C<SvPV_force> and C<SvPV_force_nomg>
- char* sv_pvn_force_flags(SV *const sv, STRLEN *const lp, const I32 flags)
+ char* sv_pvn_force_flags(SV *const sv,
+ STRLEN *const lp,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -8713,7 +9750,8 @@ Found in file sv.c
=item sv_pvutf8n_force
X<sv_pvutf8n_force>
-The backend for the C<SvPVutf8x_force> macro. Always use the macro instead.
+The backend for the C<SvPVutf8x_force> macro. Always use the macro
+instead.
char* sv_pvutf8n_force(SV *const sv, STRLEN *const lp)
@@ -8725,7 +9763,7 @@ X<sv_reftype>
Returns a string describing what the SV is a reference to.
- const char* sv_reftype(const SV *const sv, const int ob)
+ const char* sv_reftype(const SV *const sv, const int ob)
=for hackers
Found in file sv.c
@@ -8762,7 +9800,7 @@ X<sv_rvweaken>
Weaken a reference: set the C<SvWEAKREF> flag on this RV; give the
referred-to SV C<PERL_MAGIC_backref> magic if it hasn't already; and
push a back-reference to this RV onto the array of backreferences
-associated with that magic. If the RV is magical, set magic will be
+associated with that magic. If the RV is magical, set magic will be
called after the RV is cleared.
SV* sv_rvweaken(SV *const sv)
@@ -8829,7 +9867,8 @@ X<sv_setpvf>
Works like C<sv_catpvf> but copies the text into the SV instead of
appending it. Does not handle 'set' magic. See C<sv_setpvf_mg>.
- void sv_setpvf(SV *const sv, const char *const pat, ...)
+ void sv_setpvf(SV *const sv, const char *const pat,
+ ...)
=for hackers
Found in file sv.c
@@ -8839,7 +9878,8 @@ X<sv_setpvf_mg>
Like C<sv_setpvf>, but also handles 'set' magic.
- void sv_setpvf_mg(SV *const sv, const char *const pat, ...)
+ void sv_setpvf_mg(SV *const sv,
+ const char *const pat, ...)
=for hackers
Found in file sv.c
@@ -8872,7 +9912,8 @@ Copies a string into an SV. The C<len> parameter indicates the number of
bytes to be copied. If the C<ptr> argument is NULL the SV will become
undefined. Does not handle 'set' magic. See C<sv_setpvn_mg>.
- void sv_setpvn(SV *const sv, const char *const ptr, const STRLEN len)
+ void sv_setpvn(SV *const sv, const char *const ptr,
+ const STRLEN len)
=for hackers
Found in file sv.c
@@ -8882,7 +9923,9 @@ X<sv_setpvn_mg>
Like C<sv_setpvn>, but also handles 'set' magic.
- void sv_setpvn_mg(SV *const sv, const char *const ptr, const STRLEN len)
+ void sv_setpvn_mg(SV *const sv,
+ const char *const ptr,
+ const STRLEN len)
=for hackers
Found in file sv.c
@@ -8927,7 +9970,9 @@ the new SV. The C<classname> argument indicates the package for the
blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV
will have a reference count of 1, and the RV will be returned.
- SV* sv_setref_iv(SV *const rv, const char *const classname, const IV iv)
+ SV* sv_setref_iv(SV *const rv,
+ const char *const classname,
+ const IV iv)
=for hackers
Found in file sv.c
@@ -8941,7 +9986,9 @@ the new SV. The C<classname> argument indicates the package for the
blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV
will have a reference count of 1, and the RV will be returned.
- SV* sv_setref_nv(SV *const rv, const char *const classname, const NV nv)
+ SV* sv_setref_nv(SV *const rv,
+ const char *const classname,
+ const NV nv)
=for hackers
Found in file sv.c
@@ -8961,7 +10008,9 @@ objects will become corrupted by the pointer copy process.
Note that C<sv_setref_pvn> copies the string while this copies the pointer.
- SV* sv_setref_pv(SV *const rv, const char *const classname, void *const pv)
+ SV* sv_setref_pv(SV *const rv,
+ const char *const classname,
+ void *const pv)
=for hackers
Found in file sv.c
@@ -8978,7 +10027,10 @@ of 1, and the RV will be returned.
Note that C<sv_setref_pv> copies the pointer while this copies the string.
- SV* sv_setref_pvn(SV *const rv, const char *const classname, const char *const pv, const STRLEN n)
+ SV* sv_setref_pvn(SV *const rv,
+ const char *const classname,
+ const char *const pv,
+ const STRLEN n)
=for hackers
Found in file sv.c
@@ -9003,7 +10055,9 @@ the new SV. The C<classname> argument indicates the package for the
blessing. Set C<classname> to C<NULL> to avoid the blessing. The new SV
will have a reference count of 1, and the RV will be returned.
- SV* sv_setref_uv(SV *const rv, const char *const classname, const UV uv)
+ SV* sv_setref_uv(SV *const rv,
+ const char *const classname,
+ const UV uv)
=for hackers
Found in file sv.c
@@ -9013,7 +10067,7 @@ X<sv_setsv>
Copies the contents of the source SV C<ssv> into the destination SV
C<dsv>. The source SV may be destroyed if it is mortal, so don't use this
-function if the source SV needs to be reused. Does not handle 'set' magic.
+function if the source SV needs to be reused. Does not handle 'set' magic.
Loosely speaking, it performs a copy-by-value, obliterating any previous
content of the destination.
@@ -9031,12 +10085,13 @@ X<sv_setsv_flags>
Copies the contents of the source SV C<ssv> into the destination SV
C<dsv>. The source SV may be destroyed if it is mortal, so don't use this
-function if the source SV needs to be reused. Does not handle 'set' magic.
+function if the source SV needs to be reused. Does not handle 'set' magic.
Loosely speaking, it performs a copy-by-value, obliterating any previous
content of the destination.
If the C<flags> parameter has the C<SV_GMAGIC> bit set, will C<mg_get> on
-C<ssv> if appropriate, else not. If the C<flags> parameter has the
-C<NOSTEAL> bit set then the buffers of temps will not be stolen. <sv_setsv>
+C<ssv> if appropriate, else not. If the C<flags>
+parameter has the C<NOSTEAL> bit set then the
+buffers of temps will not be stolen. <sv_setsv>
and C<sv_setsv_nomg> are implemented in terms of this function.
You probably want to use one of the assortment of wrappers, such as
@@ -9046,7 +10101,8 @@ C<SvSetMagicSV_nosteal>.
This is the primary function for copying scalars, and most other
copy-ish functions and macros use this underneath.
- void sv_setsv_flags(SV *dstr, SV *sstr, const I32 flags)
+ void sv_setsv_flags(SV *dstr, SV *sstr,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -9085,7 +10141,8 @@ Found in file sv.c
=item sv_tainted
X<sv_tainted>
-Test an SV for taintedness. Use C<SvTAINTED> instead.
+Test an SV for taintedness. Use C<SvTAINTED> instead.
+
bool sv_tainted(SV *const sv)
=for hackers
@@ -9118,7 +10175,8 @@ X<sv_unmagicext>
Removes all magic of type C<type> with the specified C<vtbl> from an SV.
- int sv_unmagicext(SV *const sv, const int type, MGVTBL *vtbl)
+ int sv_unmagicext(SV *const sv, const int type,
+ MGVTBL *vtbl)
=for hackers
Found in file sv.c
@@ -9142,7 +10200,8 @@ Found in file sv.c
=item sv_untaint
X<sv_untaint>
-Untaint an SV. Use C<SvTAINTED_off> instead.
+Untaint an SV. Use C<SvTAINTED_off> instead.
+
void sv_untaint(SV *const sv)
=for hackers
@@ -9153,7 +10212,10 @@ X<sv_upgrade>
Upgrade an SV to a more complex form. Generally adds a new body type to the
SV, then copies across as much information as possible from the old body.
-You generally want to use the C<SvUPGRADE> macro wrapper. See also C<svtype>.
+It croaks if the SV is already in a more complex form than requested. You
+generally want to use the C<SvUPGRADE> macro wrapper, which checks the type
+before calling C<sv_upgrade>, and hence does not croak. See also
+C<svtype>.
void sv_upgrade(SV *const sv, svtype new_type)
@@ -9166,18 +10228,22 @@ X<sv_usepvn_flags>
Tells an SV to use C<ptr> to find its string value. Normally the
string is stored inside the SV but sv_usepvn allows the SV to use an
outside string. The C<ptr> should point to memory that was allocated
-by C<malloc>. The string length, C<len>, must be supplied. By default
+by C<malloc>. It must be the start of a mallocked block
+of memory, and not a pointer to the middle of it. The
+string length, C<len>, must be supplied. By default
this function will realloc (i.e. move) the memory pointed to by C<ptr>,
so that pointer should not be freed or used by the programmer after
giving it to sv_usepvn, and neither should any pointers from "behind"
that pointer (e.g. ptr + 1) be used.
-If C<flags> & SV_SMAGIC is true, will call SvSETMAGIC. If C<flags> &
+If C<flags> & SV_SMAGIC is true, will call SvSETMAGIC. If C<flags> &
SV_HAS_TRAILING_NUL is true, then C<ptr[len]> must be NUL, and the realloc
-will be skipped. (i.e. the buffer is actually at least 1 byte longer than
-C<len>, and already meets the requirements for storing in C<SvPVX>)
+will be skipped (i.e. the buffer is actually at least 1 byte longer than
+C<len>, and already meets the requirements for storing in C<SvPVX>).
- void sv_usepvn_flags(SV *const sv, char* ptr, const STRLEN len, const U32 flags)
+ void sv_usepvn_flags(SV *const sv, char* ptr,
+ const STRLEN len,
+ const U32 flags)
=for hackers
Found in file sv.c
@@ -9187,8 +10253,8 @@ X<sv_utf8_decode>
If the PV of the SV is an octet sequence in UTF-8
and contains a multiple-byte character, the C<SvUTF8> flag is turned on
-so that it looks like a character. If the PV contains only single-byte
-characters, the C<SvUTF8> flag stays being off.
+so that it looks like a character. If the PV contains only single-byte
+characters, the C<SvUTF8> flag stays off.
Scans PV for validity and returns false if the PV is invalid UTF-8.
NOTE: this function is experimental and may change or be
@@ -9214,7 +10280,8 @@ use the Encode extension for that.
NOTE: this function is experimental and may change or be
removed without notice.
- bool sv_utf8_downgrade(SV *const sv, const bool fail_ok)
+ bool sv_utf8_downgrade(SV *const sv,
+ const bool fail_ok)
=for hackers
Found in file sv.c
@@ -9254,7 +10321,8 @@ X<sv_utf8_upgrade_flags>
Converts the PV of an SV to its UTF-8-encoded form.
Forces the SV to string form if it is not already.
Always sets the SvUTF8 flag to avoid future validity checks even
-if all the bytes are invariant in UTF-8. If C<flags> has C<SV_GMAGIC> bit set,
+if all the bytes are invariant in UTF-8.
+If C<flags> has C<SV_GMAGIC> bit set,
will C<mg_get> on C<sv> if appropriate, else not.
Returns the number of bytes in the converted string
C<sv_utf8_upgrade> and
@@ -9263,7 +10331,8 @@ C<sv_utf8_upgrade_nomg> are implemented in terms of this function.
This is not as a general purpose byte encoding to Unicode interface:
use the Encode extension for that.
- STRLEN sv_utf8_upgrade_flags(SV *const sv, const I32 flags)
+ STRLEN sv_utf8_upgrade_flags(SV *const sv,
+ const I32 flags)
=for hackers
Found in file sv.c
@@ -9271,7 +10340,7 @@ Found in file sv.c
=item sv_utf8_upgrade_nomg
X<sv_utf8_upgrade_nomg>
-Like sv_utf8_upgrade, but doesn't do magic on C<sv>
+Like sv_utf8_upgrade, but doesn't do magic on C<sv>.
STRLEN sv_utf8_upgrade_nomg(SV *sv)
@@ -9286,7 +10355,8 @@ to an SV. Does not handle 'set' magic. See C<sv_vcatpvf_mg>.
Usually used via its frontend C<sv_catpvf>.
- void sv_vcatpvf(SV *const sv, const char *const pat, va_list *const args)
+ void sv_vcatpvf(SV *const sv, const char *const pat,
+ va_list *const args)
=for hackers
Found in file sv.c
@@ -9302,7 +10372,11 @@ locales).
Usually used via one of its frontends C<sv_vcatpvf> and C<sv_vcatpvf_mg>.
- void sv_vcatpvfn(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted)
+ void sv_vcatpvfn(SV *const sv, const char *const pat,
+ const STRLEN patlen,
+ va_list *const args,
+ SV **const svargs, const I32 svmax,
+ bool *const maybe_tainted)
=for hackers
Found in file sv.c
@@ -9314,7 +10388,9 @@ Like C<sv_vcatpvf>, but also handles 'set' magic.
Usually used via its frontend C<sv_catpvf_mg>.
- void sv_vcatpvf_mg(SV *const sv, const char *const pat, va_list *const args)
+ void sv_vcatpvf_mg(SV *const sv,
+ const char *const pat,
+ va_list *const args)
=for hackers
Found in file sv.c
@@ -9327,7 +10403,8 @@ appending it. Does not handle 'set' magic. See C<sv_vsetpvf_mg>.
Usually used via its frontend C<sv_setpvf>.
- void sv_vsetpvf(SV *const sv, const char *const pat, va_list *const args)
+ void sv_vsetpvf(SV *const sv, const char *const pat,
+ va_list *const args)
=for hackers
Found in file sv.c
@@ -9340,7 +10417,11 @@ appending it.
Usually used via one of its frontends C<sv_vsetpvf> and C<sv_vsetpvf_mg>.
- void sv_vsetpvfn(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted)
+ void sv_vsetpvfn(SV *const sv, const char *const pat,
+ const STRLEN patlen,
+ va_list *const args,
+ SV **const svargs, const I32 svmax,
+ bool *const maybe_tainted)
=for hackers
Found in file sv.c
@@ -9352,7 +10433,9 @@ Like C<sv_vsetpvf>, but also handles 'set' magic.
Usually used via its frontend C<sv_setpvf_mg>.
- void sv_vsetpvf_mg(SV *const sv, const char *const pat, va_list *const args)
+ void sv_vsetpvf_mg(SV *const sv,
+ const char *const pat,
+ va_list *const args)
=for hackers
Found in file sv.c
@@ -9367,8 +10450,8 @@ Found in file sv.c
=item bytes_cmp_utf8
X<bytes_cmp_utf8>
-Compares the sequence of characters (stored as octets) in b, blen with the
-sequence of characters (stored as UTF-8) in u, ulen. Returns 0 if they are
+Compares the sequence of characters (stored as octets) in C<b>, C<blen> with the
+sequence of characters (stored as UTF-8) in C<u>, C<ulen>. Returns 0 if they are
equal, -1 or -2 if the first string is less than the second string, +1 or +2
if the first string is greater than the second string.
@@ -9376,7 +10459,8 @@ if the first string is greater than the second string.
longer string. -2 or +2 is returned if the was a difference between characters
within the strings.
- int bytes_cmp_utf8(const U8 *b, STRLEN blen, const U8 *u, STRLEN ulen)
+ int bytes_cmp_utf8(const U8 *b, STRLEN blen,
+ const U8 *u, STRLEN ulen)
=for hackers
Found in file utf8.c
@@ -9385,7 +10469,7 @@ Found in file utf8.c
X<bytes_from_utf8>
Converts a string C<s> of length C<len> from UTF-8 into native byte encoding.
-Unlike C<utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
+Unlike L</utf8_to_bytes> but like L</bytes_to_utf8>, returns a pointer to
the newly-created string, and updates C<len> to contain the new
length. Returns the original string if no conversion occurs, C<len>
is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to
@@ -9395,7 +10479,8 @@ in utf8 (i.e., US-ASCII on non-EBCDIC machines).
NOTE: this function is experimental and may change or be
removed without notice.
- U8* bytes_from_utf8(const U8 *s, STRLEN *len, bool *is_utf8)
+ U8* bytes_from_utf8(const U8 *s, STRLEN *len,
+ bool *is_utf8)
=for hackers
Found in file utf8.c
@@ -9412,7 +10497,7 @@ A NUL character will be written after the end of the string.
If you want to convert to UTF-8 from encodings other than
the native (Latin1 or EBCDIC),
-see sv_recode_to_utf8().
+see L</sv_recode_to_utf8>().
NOTE: this function is experimental and may change or be
removed without notice.
@@ -9425,42 +10510,46 @@ Found in file utf8.c
=item foldEQ_utf8
X<foldEQ_utf8>
-Returns true if the leading portions of the strings s1 and s2 (either or both
+Returns true if the leading portions of the strings C<s1> and C<s2> (either or both
of which may be in UTF-8) are the same case-insensitively; false otherwise.
How far into the strings to compare is determined by other input parameters.
-If u1 is true, the string s1 is assumed to be in UTF-8-encoded Unicode;
-otherwise it is assumed to be in native 8-bit encoding. Correspondingly for u2
-with respect to s2.
+If C<u1> is true, the string C<s1> is assumed to be in UTF-8-encoded Unicode;
+otherwise it is assumed to be in native 8-bit encoding. Correspondingly for C<u2>
+with respect to C<s2>.
-If the byte length l1 is non-zero, it says how far into s1 to check for fold
-equality. In other words, s1+l1 will be used as a goal to reach. The
+If the byte length C<l1> is non-zero, it says how far into C<s1> to check for fold
+equality. In other words, C<s1>+C<l1> will be used as a goal to reach. The
scan will not be considered to be a match unless the goal is reached, and
-scanning won't continue past that goal. Correspondingly for l2 with respect to
-s2.
-
-If pe1 is non-NULL and the pointer it points to is not NULL, that pointer is
-considered an end pointer beyond which scanning of s1 will not continue under
-any circumstances. This means that if both l1 and pe1 are specified, and pe1
-is less than s1+l1, the match will never be successful because it can never
+scanning won't continue past that goal. Correspondingly for C<l2> with respect to
+C<s2>.
+
+If C<pe1> is non-NULL and the pointer it points to is not NULL, that pointer is
+considered an end pointer beyond which scanning of C<s1> will not continue under
+any circumstances. This means that if both C<l1> and C<pe1> are specified, and
+C<pe1>
+is less than C<s1>+C<l1>, the match will never be successful because it can
+never
get as far as its goal (and in fact is asserted against). Correspondingly for
-pe2 with respect to s2.
+C<pe2> with respect to C<s2>.
-At least one of s1 and s2 must have a goal (at least one of l1 and l2 must be
-non-zero), and if both do, both have to be
+At least one of C<s1> and C<s2> must have a goal (at least one of C<l1> and
+C<l2> must be non-zero), and if both do, both have to be
reached for a successful match. Also, if the fold of a character is multiple
characters, all of them must be matched (see tr21 reference below for
'folding').
-Upon a successful match, if pe1 is non-NULL,
-it will be set to point to the beginning of the I<next> character of s1 beyond
-what was matched. Correspondingly for pe2 and s2.
+Upon a successful match, if C<pe1> is non-NULL,
+it will be set to point to the beginning of the I<next> character of C<s1>
+beyond what was matched. Correspondingly for C<pe2> and C<s2>.
For case-insensitiveness, the "casefolding" of Unicode is used
instead of upper/lowercasing both the characters, see
-http://www.unicode.org/unicode/reports/tr21/ (Case Mappings).
+L<http://www.unicode.org/unicode/reports/tr21/> (Case Mappings).
- I32 foldEQ_utf8(const char *s1, char **pe1, UV l1, bool u1, const char *s2, char **pe2, UV l2, bool u2)
+ I32 foldEQ_utf8(const char *s1, char **pe1, UV l1,
+ bool u1, const char *s2, char **pe2,
+ UV l2, bool u2)
=for hackers
Found in file utf8.c
@@ -9468,14 +10557,14 @@ Found in file utf8.c
=item is_ascii_string
X<is_ascii_string>
-Returns true if the first C<len> bytes of the given string are the same whether
+Returns true if the first C<len> bytes of the string C<s> are the same whether
or not the string is encoded in UTF-8 (or UTF-EBCDIC on EBCDIC machines). That
is, if they are invariant. On ASCII-ish machines, only ASCII characters
fit this definition, hence the function's name.
If C<len> is 0, it will be calculated using C<strlen(s)>.
-See also is_utf8_string(), is_utf8_string_loclen(), and is_utf8_string_loc().
+See also L</is_utf8_string>(), L</is_utf8_string_loclen>(), and L</is_utf8_string_loc>().
bool is_ascii_string(const U8 *s, STRLEN len)
@@ -9485,26 +10574,49 @@ Found in file utf8.c
=item is_utf8_char
X<is_utf8_char>
+DEPRECATED!
+
Tests if some arbitrary number of bytes begins in a valid UTF-8
character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines)
character is a valid UTF-8 character. The actual number of bytes in the UTF-8
character will be returned if it is valid, otherwise 0.
+This function is deprecated due to the possibility that malformed input could
+cause reading beyond the end of the input buffer. Use L</is_utf8_char_buf>
+instead.
+
STRLEN is_utf8_char(const U8 *s)
=for hackers
Found in file utf8.c
+=item is_utf8_char_buf
+X<is_utf8_char_buf>
+
+Returns the number of bytes that comprise the first UTF-8 encoded character in
+buffer C<buf>. C<buf_end> should point to one position beyond the end of the
+buffer. 0 is returned if C<buf> does not point to a complete, valid UTF-8
+encoded character.
+
+Note that an INVARIANT character (i.e. ASCII on non-EBCDIC
+machines) is a valid UTF-8 character.
+
+ STRLEN is_utf8_char_buf(const U8 *buf,
+ const U8 *buf_end)
+
+=for hackers
+Found in file utf8.c
+
=item is_utf8_string
X<is_utf8_string>
-Returns true if first C<len> bytes of the given string form a valid
+Returns true if the first C<len> bytes of string C<s> form a valid
UTF-8 string, false otherwise. If C<len> is 0, it will be calculated
-using C<strlen(s)>. Note that 'a valid UTF-8 string' does not mean 'a
-string that contains code points above 0x7F encoded in UTF-8' because a
-valid ASCII string is a valid UTF-8 string.
+using C<strlen(s)> (which means if you use this option, that C<s> has to have a
+terminating NUL byte). Note that all characters being ASCII constitute 'a
+valid UTF-8 string'.
-See also is_ascii_string(), is_utf8_string_loclen(), and is_utf8_string_loc().
+See also L</is_ascii_string>(), L</is_utf8_string_loclen>(), and L</is_utf8_string_loc>().
bool is_utf8_string(const U8 *s, STRLEN len)
@@ -9514,13 +10626,14 @@ Found in file utf8.c
=item is_utf8_string_loc
X<is_utf8_string_loc>
-Like is_utf8_string() but stores the location of the failure (in the
-case of "utf8ness failure") or the location s+len (in the case of
+Like L</is_utf8_string> but stores the location of the failure (in the
+case of "utf8ness failure") or the location C<s>+C<len> (in the case of
"utf8ness success") in the C<ep>.
-See also is_utf8_string_loclen() and is_utf8_string().
+See also L</is_utf8_string_loclen>() and L</is_utf8_string>().
- bool is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **p)
+ bool is_utf8_string_loc(const U8 *s, STRLEN len,
+ const U8 **p)
=for hackers
Found in file utf8.c
@@ -9528,14 +10641,15 @@ Found in file utf8.c
=item is_utf8_string_loclen
X<is_utf8_string_loclen>
-Like is_utf8_string() but stores the location of the failure (in the
-case of "utf8ness failure") or the location s+len (in the case of
+Like L</is_utf8_string>() but stores the location of the failure (in the
+case of "utf8ness failure") or the location C<s>+C<len> (in the case of
"utf8ness success") in the C<ep>, and the number of UTF-8
encoded characters in the C<el>.
-See also is_utf8_string_loc() and is_utf8_string().
+See also L</is_utf8_string_loc>() and L</is_utf8_string>().
- bool is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
+ bool is_utf8_string_loclen(const U8 *s, STRLEN len,
+ const U8 **ep, STRLEN *el)
=for hackers
Found in file utf8.c
@@ -9543,20 +10657,22 @@ Found in file utf8.c
=item pv_uni_display
X<pv_uni_display>
-Build to the scalar dsv a displayable version of the string spv,
-length len, the displayable version being at most pvlim bytes long
+Build to the scalar C<dsv> a displayable version of the string C<spv>,
+length C<len>, the displayable version being at most C<pvlim> bytes long
(if longer, the rest is truncated and "..." will be appended).
-The flags argument can have UNI_DISPLAY_ISPRINT set to display
+The C<flags> argument can have UNI_DISPLAY_ISPRINT set to display
isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH
to display the \\[nrfta\\] as the backslashed versions (like '\n')
(UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\).
UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both
UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on.
-The pointer to the PV of the dsv is returned.
+The pointer to the PV of the C<dsv> is returned.
- char* pv_uni_display(SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
+ char* pv_uni_display(SV *dsv, const U8 *spv,
+ STRLEN len, STRLEN pvlim,
+ UV flags)
=for hackers
Found in file utf8.c
@@ -9569,12 +10685,13 @@ assumed to be octets in that encoding and decoding the input starts
from the position which (PV + *offset) pointed to. The dsv will be
concatenated the decoded UTF-8 string from ssv. Decoding will terminate
when the string tstr appears in decoding output or the input ends on
-the PV of the ssv. The value which the offset points will be modified
+the PV of the ssv. The value which the offset points will be modified
to the last input position on the ssv.
Returns TRUE if the terminator was found, else returns FALSE.
- bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen)
+ bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv,
+ int *offset, char* tstr, int tlen)
=for hackers
Found in file sv.c
@@ -9589,7 +10706,7 @@ will be converted into Unicode (and UTF-8).
If the sv already is UTF-8 (or if it is not POK), or if the encoding
is not a reference, nothing is done to the sv. If the encoding is not
an C<Encode::XS> Encoding object, bad things will happen.
-(See F<lib/encoding.pm> and L<Encode>).
+(See F<lib/encoding.pm> and L<Encode>.)
The PV of the sv is returned.
@@ -9601,15 +10718,16 @@ Found in file sv.c
=item sv_uni_display
X<sv_uni_display>
-Build to the scalar dsv a displayable version of the scalar sv,
-the displayable version being at most pvlim bytes long
+Build to the scalar C<dsv> a displayable version of the scalar C<sv>,
+the displayable version being at most C<pvlim> bytes long
(if longer, the rest is truncated and "..." will be appended).
-The flags argument is as in pv_uni_display().
+The C<flags> argument is as in L</pv_uni_display>().
-The pointer to the PV of the dsv is returned.
+The pointer to the PV of the C<dsv> is returned.
- char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
+ char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim,
+ UV flags)
=for hackers
Found in file utf8.c
@@ -9617,27 +10735,31 @@ Found in file utf8.c
=item to_utf8_case
X<to_utf8_case>
-The "p" contains the pointer to the UTF-8 string encoding
-the character that is being converted.
+The C<p> contains the pointer to the UTF-8 string encoding
+the character that is being converted. This routine assumes that the character
+at C<p> is well-formed.
-The "ustrp" is a pointer to the character buffer to put the
-conversion result to. The "lenp" is a pointer to the length
+The C<ustrp> is a pointer to the character buffer to put the
+conversion result to. The C<lenp> is a pointer to the length
of the result.
-The "swashp" is a pointer to the swash to use.
+The C<swashp> is a pointer to the swash to use.
-Both the special and normal mappings are stored in lib/unicore/To/Foo.pl,
-and loaded by SWASHNEW, using lib/utf8_heavy.pl. The special (usually,
+Both the special and normal mappings are stored in F<lib/unicore/To/Foo.pl>,
+and loaded by SWASHNEW, using F<lib/utf8_heavy.pl>. The C<special> (usually,
but not always, a multicharacter mapping), is tried first.
-The "special" is a string like "utf8::ToSpecLower", which means the
+The C<special> is a string like "utf8::ToSpecLower", which means the
hash %utf8::ToSpecLower. The access to the hash is through
Perl_to_utf8_case().
-The "normal" is a string like "ToLower" which means the swash
+The C<normal> is a string like "ToLower" which means the swash
%utf8::ToLower.
- UV to_utf8_case(const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special)
+ UV to_utf8_case(const U8 *p, U8* ustrp,
+ STRLEN *lenp, SV **swashp,
+ const char *normal,
+ const char *special)
=for hackers
Found in file utf8.c
@@ -9645,16 +10767,19 @@ Found in file utf8.c
=item to_utf8_fold
X<to_utf8_fold>
-Convert the UTF-8 encoded character at p to its foldcase version and
-store that in UTF-8 in ustrp and its length in bytes in lenp. Note
-that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
+Convert the UTF-8 encoded character at C<p> to its foldcase version and
+store that in UTF-8 in C<ustrp> and its length in bytes in C<lenp>. Note
+that the C<ustrp> needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
foldcase version may be longer than the original character (up to
three characters).
The first character of the foldcased version is returned
(but note, as explained above, that there may be more.)
- UV to_utf8_fold(const U8 *p, U8* ustrp, STRLEN *lenp)
+The character at C<p> is assumed by this routine to be well-formed.
+
+ UV to_utf8_fold(const U8 *p, U8* ustrp,
+ STRLEN *lenp)
=for hackers
Found in file utf8.c
@@ -9662,15 +10787,18 @@ Found in file utf8.c
=item to_utf8_lower
X<to_utf8_lower>
-Convert the UTF-8 encoded character at p to its lowercase version and
-store that in UTF-8 in ustrp and its length in bytes in lenp. Note
-that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
+Convert the UTF-8 encoded character at C<p> to its lowercase version and
+store that in UTF-8 in ustrp and its length in bytes in C<lenp>. Note
+that the C<ustrp> needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
lowercase version may be longer than the original character.
The first character of the lowercased version is returned
(but note, as explained above, that there may be more.)
- UV to_utf8_lower(const U8 *p, U8* ustrp, STRLEN *lenp)
+The character at C<p> is assumed by this routine to be well-formed.
+
+ UV to_utf8_lower(const U8 *p, U8* ustrp,
+ STRLEN *lenp)
=for hackers
Found in file utf8.c
@@ -9678,15 +10806,18 @@ Found in file utf8.c
=item to_utf8_title
X<to_utf8_title>
-Convert the UTF-8 encoded character at p to its titlecase version and
-store that in UTF-8 in ustrp and its length in bytes in lenp. Note
-that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
+Convert the UTF-8 encoded character at C<p> to its titlecase version and
+store that in UTF-8 in C<ustrp> and its length in bytes in C<lenp>. Note
+that the C<ustrp> needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
titlecase version may be longer than the original character.
The first character of the titlecased version is returned
(but note, as explained above, that there may be more.)
- UV to_utf8_title(const U8 *p, U8* ustrp, STRLEN *lenp)
+The character at C<p> is assumed by this routine to be well-formed.
+
+ UV to_utf8_title(const U8 *p, U8* ustrp,
+ STRLEN *lenp)
=for hackers
Found in file utf8.c
@@ -9694,15 +10825,18 @@ Found in file utf8.c
=item to_utf8_upper
X<to_utf8_upper>
-Convert the UTF-8 encoded character at p to its uppercase version and
-store that in UTF-8 in ustrp and its length in bytes in lenp. Note
+Convert the UTF-8 encoded character at C<p> to its uppercase version and
+store that in UTF-8 in C<ustrp> and its length in bytes in C<lenp>. Note
that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since
the uppercase version may be longer than the original character.
The first character of the uppercased version is returned
(but note, as explained above, that there may be more.)
- UV to_utf8_upper(const U8 *p, U8* ustrp, STRLEN *lenp)
+The character at C<p> is assumed by this routine to be well-formed.
+
+ UV to_utf8_upper(const U8 *p, U8* ustrp,
+ STRLEN *lenp)
=for hackers
Found in file utf8.c
@@ -9715,9 +10849,10 @@ C<s>
which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
length, in bytes, of that character.
-length and flags are the same as utf8n_to_uvuni().
+C<length> and C<flags> are the same as L</utf8n_to_uvuni>().
- UV utf8n_to_uvchr(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
+ UV utf8n_to_uvchr(const U8 *s, STRLEN curlen,
+ STRLEN *retlen, U32 flags)
=for hackers
Found in file utf8.c
@@ -9726,16 +10861,16 @@ Found in file utf8.c
X<utf8n_to_uvuni>
Bottom level UTF-8 decode routine.
-Returns the code point value of the first character in the string C<s>
-which is assumed to be in UTF-8 (or UTF-EBCDIC) encoding and no longer than
-C<curlen> bytes; C<retlen> will be set to the length, in bytes, of that
-character.
+Returns the code point value of the first character in the string C<s>,
+which is assumed to be in UTF-8 (or UTF-EBCDIC) encoding, and no longer than
+C<curlen> bytes; C<*retlen> (if C<retlen> isn't NULL) will be set to
+the length, in bytes, of that character.
The value of C<flags> determines the behavior when C<s> does not point to a
well-formed UTF-8 character. If C<flags> is 0, when a malformation is found,
-C<retlen> is set to the expected length of the UTF-8 character in bytes, zero
-is returned, and if UTF-8 warnings haven't been lexically disabled, a warning
-is raised.
+zero is returned and C<*retlen> is set so that (S<C<s> + C<*retlen>>) is the
+next possible position in C<s> that could begin a non-malformed character.
+Also, if UTF-8 warnings haven't been lexically disabled, a warning is raised.
Various ALLOW flags can be set in C<flags> to allow (and not warn on)
individual types of malformations, such as the sequence being overlong (that
@@ -9743,8 +10878,10 @@ is, when there is a shorter sequence that can express the same code point;
overlong sequences are expressly forbidden in the UTF-8 standard due to
potential security issues). Another malformation example is the first byte of
a character not being a legal first byte. See F<utf8.h> for the list of such
-flags. Of course, the value returned by this function under such conditions is
-not reliable.
+flags. For allowed 0 length strings, this function returns 0; for allowed
+overlong sequences, the computed code point is returned; for all other allowed
+malformations, the Unicode REPLACEMENT CHARACTER is returned, as these have no
+determinable reasonable value.
The UTF8_CHECK_ONLY flag overrides the behavior when a non-allowed (by other
flags) malformation is found. If this flag is set, the routine assumes that
@@ -9752,9 +10889,9 @@ the caller will raise a warning, and this function will silently just set
C<retlen> to C<-1> and return zero.
Certain code points are considered problematic. These are Unicode surrogates,
-Unicode non-characters, and code points above the Unicode maximum of 0x10FFF.
+Unicode non-characters, and code points above the Unicode maximum of 0x10FFFF.
By default these are considered regular code points, but certain situations
-warrant special handling for them. if C<flags> contains
+warrant special handling for them. If C<flags> contains
UTF8_DISALLOW_ILLEGAL_INTERCHANGE, all three classes are treated as
malformations and handled as such. The flags UTF8_DISALLOW_SURROGATE,
UTF8_DISALLOW_NONCHAR, and UTF8_DISALLOW_SUPER (meaning above the legal Unicode
@@ -9770,22 +10907,27 @@ UTF8_CHECK_ONLY is also specified.)
Very large code points (above 0x7FFF_FFFF) are considered more problematic than
the others that are above the Unicode legal maximum. There are several
-reasons, one of which is that the original UTF-8 specification never went above
-this number (the current 0x10FFF limit was imposed later). The UTF-8 encoding
-on ASCII platforms for these large code point begins with a byte containing
-0xFE or 0xFF. The UTF8_DISALLOW_FE_FF flag will cause them to be treated as
-malformations, while allowing smaller above-Unicode code points. (Of course
-UTF8_DISALLOW_SUPER will treat all above-Unicode code points, including these,
-as malformations.) Similarly, UTF8_WARN_FE_FF acts just like the other WARN
-flags, but applies just to these code points.
+reasons: they requre at least 32 bits to represent them on ASCII platforms, are
+not representable at all on EBCDIC platforms, and the original UTF-8
+specification never went above this number (the current 0x10FFFF limit was
+imposed later). (The smaller ones, those that fit into 32 bits, are
+representable by a UV on ASCII platforms, but not by an IV, which means that
+the number of operations that can be performed on them is quite restricted.)
+The UTF-8 encoding on ASCII platforms for these large code points begins with a
+byte containing 0xFE or 0xFF. The UTF8_DISALLOW_FE_FF flag will cause them to
+be treated as malformations, while allowing smaller above-Unicode code points.
+(Of course UTF8_DISALLOW_SUPER will treat all above-Unicode code points,
+including these, as malformations.) Similarly, UTF8_WARN_FE_FF acts just like
+the other WARN flags, but applies just to these code points.
All other code points corresponding to Unicode characters, including private
use and those yet to be assigned, are never considered malformed and never
warn.
-Most code should use utf8_to_uvchr() rather than call this directly.
+Most code should use L</utf8_to_uvchr_buf>() rather than call this directly.
- UV utf8n_to_uvuni(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
+ UV utf8n_to_uvuni(const U8 *s, STRLEN curlen,
+ STRLEN *retlen, U32 flags)
=for hackers
Found in file utf8.c
@@ -9835,11 +10977,11 @@ Found in file utf8.c
X<utf8_to_bytes>
Converts a string C<s> of length C<len> from UTF-8 into native byte encoding.
-Unlike C<bytes_to_utf8>, this over-writes the original string, and
-updates len to contain the new length.
+Unlike L</bytes_to_utf8>, this over-writes the original string, and
+updates C<len> to contain the new length.
Returns zero on failure, setting C<len> to -1.
-If you need a copy of the string, see C<bytes_from_utf8>.
+If you need a copy of the string, see L</bytes_from_utf8>.
NOTE: this function is experimental and may change or be
removed without notice.
@@ -9852,21 +10994,55 @@ Found in file utf8.c
=item utf8_to_uvchr
X<utf8_to_uvchr>
+DEPRECATED!
+
Returns the native code point of the first character in the string C<s>
which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
length, in bytes, of that character.
-If C<s> does not point to a well-formed UTF-8 character, zero is
-returned and retlen is set, if possible, to -1.
+Some, but not all, UTF-8 malformations are detected, and in fact, some
+malformed input could cause reading beyond the end of the input buffer, which
+is why this function is deprecated. Use L</utf8_to_uvchr_buf> instead.
+
+If C<s> points to one of the detected malformations, and UTF8 warnings are
+enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
+NULL) to -1. If those warnings are off, the computed value if well-defined (or
+the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
+is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
+next possible position in C<s> that could begin a non-malformed character.
+See L</utf8n_to_uvuni> for details on when the REPLACEMENT CHARACTER is returned.
UV utf8_to_uvchr(const U8 *s, STRLEN *retlen)
=for hackers
Found in file utf8.c
+=item utf8_to_uvchr_buf
+X<utf8_to_uvchr_buf>
+
+Returns the native code point of the first character in the string C<s> which
+is assumed to be in UTF-8 encoding; C<send> points to 1 beyond the end of C<s>.
+C<*retlen> will be set to the length, in bytes, of that character.
+
+If C<s> does not point to a well-formed UTF-8 character and UTF8 warnings are
+enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
+NULL) to -1. If those warnings are off, the computed value if well-defined (or
+the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
+is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
+next possible position in C<s> that could begin a non-malformed character.
+See L</utf8n_to_uvuni> for details on when the REPLACEMENT CHARACTER is returned.
+
+ UV utf8_to_uvchr_buf(const U8 *s, const U8 *send,
+ STRLEN *retlen)
+
+=for hackers
+Found in file utf8.c
+
=item utf8_to_uvuni
X<utf8_to_uvuni>
+DEPRECATED!
+
Returns the Unicode code point of the first character in the string C<s>
which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
length, in bytes, of that character.
@@ -9874,19 +11050,52 @@ length, in bytes, of that character.
This function should only be used when the returned UV is considered
an index into the Unicode semantic tables (e.g. swashes).
-If C<s> does not point to a well-formed UTF-8 character, zero is
-returned and retlen is set, if possible, to -1.
+Some, but not all, UTF-8 malformations are detected, and in fact, some
+malformed input could cause reading beyond the end of the input buffer, which
+is why this function is deprecated. Use L</utf8_to_uvuni_buf> instead.
+
+If C<s> points to one of the detected malformations, and UTF8 warnings are
+enabled, zero is returned and C<*retlen> is set (if C<retlen> doesn't point to
+NULL) to -1. If those warnings are off, the computed value if well-defined (or
+the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
+is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
+next possible position in C<s> that could begin a non-malformed character.
+See L</utf8n_to_uvuni> for details on when the REPLACEMENT CHARACTER is returned.
UV utf8_to_uvuni(const U8 *s, STRLEN *retlen)
=for hackers
Found in file utf8.c
+=item utf8_to_uvuni_buf
+X<utf8_to_uvuni_buf>
+
+Returns the Unicode code point of the first character in the string C<s> which
+is assumed to be in UTF-8 encoding; C<send> points to 1 beyond the end of C<s>.
+C<retlen> will be set to the length, in bytes, of that character.
+
+This function should only be used when the returned UV is considered
+an index into the Unicode semantic tables (e.g. swashes).
+
+If C<s> does not point to a well-formed UTF-8 character and UTF8 warnings are
+enabled, zero is returned and C<*retlen> is set (if C<retlen> isn't
+NULL) to -1. If those warnings are off, the computed value if well-defined (or
+the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen>
+is set (if C<retlen> isn't NULL) so that (S<C<s> + C<*retlen>>) is the
+next possible position in C<s> that could begin a non-malformed character.
+See L</utf8n_to_uvuni> for details on when the REPLACEMENT CHARACTER is returned.
+
+ UV utf8_to_uvuni_buf(const U8 *s, const U8 *send,
+ STRLEN *retlen)
+
+=for hackers
+Found in file utf8.c
+
=item uvchr_to_utf8
X<uvchr_to_utf8>
Adds the UTF-8 representation of the Native code point C<uv> to the end
-of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
+of the string C<d>; C<d> should have at least C<UTF8_MAXBYTES+1> free
bytes available. The return value is the pointer to the byte after the
end of the new character. In other words,
@@ -9925,7 +11134,8 @@ This is the recommended Unicode-aware way of saying
This function will convert to UTF-8 (and not warn) even code points that aren't
legal Unicode or are problematic, unless C<flags> contains one or more of the
-following flags.
+following flags:
+
If C<uv> is a Unicode surrogate code point and UNICODE_WARN_SURROGATE is set,
the function will raise a warning, provided UTF8 warnings are enabled. If instead
UNICODE_DISALLOW_SURROGATE is set, the function will fail and return NULL.
@@ -10125,7 +11335,7 @@ Found in file XSUB.h
X<XS>
Macro to declare an XSUB and its C parameter list. This is handled by
-C<xsubpp>.
+C<xsubpp>. It is the same as using the more explicit XS_EXTERNAL macro.
=for hackers
Found in file XSUB.h
@@ -10141,6 +11351,24 @@ matches the api version of the perl interpreter it's being loaded into.
=for hackers
Found in file XSUB.h
+=item XS_EXTERNAL
+X<XS_EXTERNAL>
+
+Macro to declare an XSUB and its C parameter list explicitly exporting the symbols.
+
+=for hackers
+Found in file XSUB.h
+
+=item XS_INTERNAL
+X<XS_INTERNAL>
+
+Macro to declare an XSUB and its C parameter list without exporting the symbols.
+This is handled by C<xsubpp> and generally preferable over exporting the XSUB
+symbols unnecessarily.
+
+=for hackers
+Found in file XSUB.h
+
=item XS_VERSION
X<XS_VERSION>
@@ -10439,11 +11667,8 @@ X<Slab_Alloc>
=item Slab_Free
X<Slab_Free>
-=item _to_uni_fold_flags
-X<_to_uni_fold_flags>
-
-=item _to_utf8_fold_flags
-X<_to_utf8_fold_flags>
+=item _is_utf8_quotemeta
+X<_is_utf8_quotemeta>
=item amagic_call
X<amagic_call>
@@ -10454,9 +11679,6 @@ X<amagic_deref_call>
=item any_dup
X<any_dup>
-=item apply_attrs_string
-X<apply_attrs_string>
-
=item atfork_lock
X<atfork_lock>
@@ -10646,9 +11868,6 @@ X<dump_sub>
=item dump_vindent
X<dump_vindent>
-=item fetch_cop_label
-X<fetch_cop_label>
-
=item filter_add
X<filter_add>
@@ -10658,18 +11877,9 @@ X<filter_del>
=item filter_read
X<filter_read>
-=item find_rundefsv
-X<find_rundefsv>
-
-=item find_rundefsvoffset
-X<find_rundefsvoffset>
-
=item foldEQ_latin1
X<foldEQ_latin1>
-=item foldEQ_utf8_flags
-X<foldEQ_utf8_flags>
-
=item form_nocontext
X<form_nocontext>
@@ -10730,6 +11940,15 @@ X<gv_add_by_type>
=item gv_autoload4
X<gv_autoload4>
+=item gv_autoload_pv
+X<gv_autoload_pv>
+
+=item gv_autoload_pvn
+X<gv_autoload_pvn>
+
+=item gv_autoload_sv
+X<gv_autoload_sv>
+
=item gv_check
X<gv_check>
@@ -10751,9 +11970,6 @@ X<gv_fetchfile>
=item gv_fetchfile_flags
X<gv_fetchfile_flags>
-=item gv_fetchmethod_flags
-X<gv_fetchmethod_flags>
-
=item gv_fetchpv
X<gv_fetchpv>
@@ -10775,9 +11991,6 @@ X<gv_fullname4>
=item gv_handler
X<gv_handler>
-=item gv_init
-X<gv_init>
-
=item gv_name_set
X<gv_name_set>
@@ -10826,9 +12039,6 @@ X<hv_riter_p>
=item hv_riter_set
X<hv_riter_set>
-=item hv_store_flags
-X<hv_store_flags>
-
=item init_global_struct
X<init_global_struct>
@@ -11027,9 +12237,6 @@ X<mro_get_from_name>
=item mro_get_private_data
X<mro_get_private_data>
-=item mro_register
-X<mro_register>
-
=item mro_set_mro
X<mro_set_mro>
@@ -11147,6 +12354,9 @@ X<newGVREF>
=item newGVgen
X<newGVgen>
+=item newGVgen_flags
+X<newGVgen_flags>
+
=item newHVREF
X<newHVREF>
@@ -11174,9 +12384,6 @@ X<newSVREF>
=item newSVpvf_nocontext
X<newSVpvf_nocontext>
-=item newXS_flags
-X<newXS_flags>
-
=item new_collate
X<new_collate>
@@ -11690,6 +12897,15 @@ X<warner_nocontext>
=item whichsig
X<whichsig>
+=item whichsig_pv
+X<whichsig_pv>
+
+=item whichsig_pvn
+X<whichsig_pvn>
+
+=item whichsig_sv
+X<whichsig_sv>
+
=back