diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-21 00:15:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-21 00:15:27 +0000 |
commit | a4c42bfb2337d37da89d789cb8cc226367994e32 (patch) | |
tree | c3eabdef5d565a4e515d2be0d9d4d0540bde0250 /Master/tlpkg/tlperl/lib/pods/perlapi.pod | |
parent | 8274475057f024d35332ac47c2e2f23ea156e6ed (diff) |
perl 5.14.2 from siep
git-svn-id: svn://tug.org/texlive/trunk@26525 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/pods/perlapi.pod')
-rw-r--r-- | Master/tlpkg/tlperl/lib/pods/perlapi.pod | 2940 |
1 files changed, 2664 insertions, 276 deletions
diff --git a/Master/tlpkg/tlperl/lib/pods/perlapi.pod b/Master/tlpkg/tlperl/lib/pods/perlapi.pod index 3a8792b899d..5c7a2b98bfd 100644 --- a/Master/tlpkg/tlperl/lib/pods/perlapi.pod +++ b/Master/tlpkg/tlperl/lib/pods/perlapi.pod @@ -13,10 +13,12 @@ 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 -that may be used by extension writers. The interfaces of any functions that -are not listed here are subject to change without notice. For this reason, -blindly using functions listed in proto.h is to be avoided when writing -extensions. +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 +not part of the public API, and should not be used by extension writers at +all. For these reasons, blindly using functions listed in proto.h is to be +avoided when writing extensions. Note that all Perl API global variables must be referenced with the C<PL_> prefix. Some macros are provided for compatibility with the older, @@ -69,7 +71,7 @@ X<GIMME_V> The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>, C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context, -respectively. +respectively. See L<perlcall> for a usage example. U32 GIMME_V @@ -150,7 +152,7 @@ Found in file av.h X<av_clear> Clears an array, making it empty. Does not free the memory used by the -array itself. +array itself. Perl equivalent: C<@myarray = ();>. void av_clear(AV *av) @@ -189,9 +191,11 @@ Found in file av.c =item av_delete X<av_delete> -Deletes the element indexed by C<key> from the array. Returns the -deleted element. If C<flags> equals C<G_DISCARD>, the element is freed -and null is returned. +Deletes the element indexed by C<key> from the array, makes the element mortal, +and returns it. If C<flags> equals C<G_DISCARD>, the element is freed and null +is returned. Perl equivalent: C<my $elem = delete($myarray[$idx]);> for the +non-C<G_DISCARD> version and a void-context C<delete($myarray[$idx]);> for the +C<G_DISCARD> version. SV* av_delete(AV *av, I32 key, I32 flags) @@ -206,6 +210,8 @@ Returns true if the element indexed by C<key> has been initialized. This relies on the fact that uninitialized array elements are set to C<&PL_sv_undef>. +Perl equivalent: C<exists($myarray[$key])>. + bool av_exists(AV *av, I32 key) =for hackers @@ -226,12 +232,14 @@ Found in file av.c X<av_fetch> Returns the SV at the specified index in the array. The C<key> is the -index. 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 a C<SV*>. +index. If lval is true, you are guaranteed to get a real SV back (in case +it wasn't real before), which you can then modify. Check that the return +value is non-null before dereferencing it to a C<SV*>. 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 @@ -244,7 +252,7 @@ Set the highest index in the array to the given number, equivalent to Perl's C<$#array = $fill;>. The number of elements in the an array will be C<fill + 1> after -av_fill() returns. If the array was previously shorter then the +av_fill() returns. If the array was previously shorter, then the additional elements appended are set to C<PL_sv_undef>. If the array was longer, then the excess elements are freed. C<av_fill(av, -1)> is the same as C<av_clear(av)>. @@ -260,6 +268,8 @@ X<av_len> Returns the highest index in the array. The number of elements in the array is C<av_len(av) + 1>. Returns -1 if the array is empty. +The Perl equivalent for this is C<$#myarray>. + I32 av_len(AV *av) =for hackers @@ -272,6 +282,8 @@ Creates a new AV and populates it with a list of SVs. The SVs are copied into the array, so they may be freed after the call to av_make. The new AV will have a reference count of 1. +Perl equivalent: C<my @new_array = ($scalar1, $scalar2, $scalar3...);> + AV* av_make(I32 size, SV **strp) =for hackers @@ -292,8 +304,7 @@ 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. Like C<av_store>, this takes ownership of one -reference count. +to accommodate the addition. This takes ownership of one reference count. void av_push(AV *av, SV *val) @@ -484,7 +495,8 @@ Found in file perl.c =item eval_sv X<eval_sv> -Tells Perl to C<eval> the string in the SV. +Tells Perl to C<eval> the string in the SV. It supports the same flags +as C<call_sv>, with the obvious exception of G_EVAL. See L<perlcall>. NOTE: the perl_ form of this function is deprecated. @@ -528,37 +540,92 @@ Found in file scope.h =back -=head1 Character classes +=head1 Character case changing =over 8 -=item isALNUM -X<isALNUM> +=item toLOWER +X<toLOWER> -Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin) -alphanumeric character (including underscore) or digit. +Converts the specified character to lowercase in the platform's native +character set, if possible; otherwise returns the input character itself. - bool isALNUM(char ch) + char toLOWER(char ch) =for hackers Found in file handy.h +=item toUPPER +X<toUPPER> + +Converts the specified character to uppercase in the platform's native +character set, if possible; otherwise returns the input character itself. + + char toUPPER(char ch) + +=for hackers +Found in file handy.h + + +=back + +=head1 Character classes + +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 + +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 +Latin-1 character set onto the platform. That is, the code points that are +ASCII are unaffected, since ASCII is a subset of Latin-1. But the non-ASCII +code points are treated as if they are Latin-1 characters. For example, +C<isSPACE_L1()> will return true when called with the code point 0xA0, which is +the Latin-1 NO-BREAK SPACE. + +For EBCDIC platforms, the base function with no suffix and the one with the +C<_L1> suffix should be identical, since, as of this writing, the EBCDIC code +pages that Perl knows about all are equivalent to Latin-1. The function that +ends in an C<_A> suffix will not return true unless the specified character also +has an ASCII equivalent. + + +=over 8 + =item isALPHA X<isALPHA> -Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin) -alphabetic character. +Returns a boolean indicating whether the specified character is an +alphabetic character in the platform's native character set. +See the L<top of this section|/Character classes> for an explanation of variants +C<isALPHA_A> and C<isALPHA_L1>. bool isALPHA(char ch) =for hackers Found in file handy.h +=item isASCII +X<isASCII> + +Returns a boolean indicating whether the specified character is one of the 128 +characters in the ASCII character set. On non-ASCII platforms, it is if this +character corresponds to an ASCII character. Variants C<isASCII_A()> and +C<isASCII_L1()> are identical to C<isASCII()>. + + bool isASCII(char ch) + +=for hackers +Found in file handy.h + =item isDIGIT X<isDIGIT> -Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin) -digit. +Returns a boolean indicating whether the specified character is a +digit in the platform's native character set. +Variants C<isDIGIT_A> and C<isDIGIT_L1> are identical to C<isDIGIT>. bool isDIGIT(char ch) @@ -568,19 +635,36 @@ Found in file handy.h =item isLOWER X<isLOWER> -Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin) -lowercase character. +Returns a boolean indicating whether the specified character is a +lowercase character in the platform's native character set. +See the L<top of this section|/Character classes> for an explanation of variants +C<isLOWER_A> and C<isLOWER_L1>. bool isLOWER(char ch) =for hackers Found in file handy.h +=item isOCTAL +X<isOCTAL> + +Returns a boolean indicating whether the specified character is an +octal digit, [0-7] in the platform's native character set. +Variants C<isOCTAL_A> and C<isOCTAL_L1> are identical to C<isOCTAL>. + + bool isOCTAL(char ch) + +=for hackers +Found in file handy.h + =item isSPACE X<isSPACE> -Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin) -whitespace. +Returns a boolean indicating whether the specified character is a +whitespace character in the platform's native character set. This is the same +as what C<\s> matches in a regular expression. +See the L<top of this section|/Character classes> for an explanation of variants +C<isSPACE_A> and C<isSPACE_L1>. bool isSPACE(char ch) @@ -590,32 +674,41 @@ Found in file handy.h =item isUPPER X<isUPPER> -Returns a boolean indicating whether the C C<char> is a US-ASCII (Basic Latin) -uppercase character. +Returns a boolean indicating whether the specified character is an +uppercase character in the platform's native character set. +See the L<top of this section|/Character classes> for an explanation of variants +C<isUPPER_A> and C<isUPPER_L1>. bool isUPPER(char ch) =for hackers Found in file handy.h -=item toLOWER -X<toLOWER> +=item isWORDCHAR +X<isWORDCHAR> -Converts the specified character to lowercase. Characters outside the -US-ASCII (Basic Latin) range are viewed as not having any case. +Returns a boolean indicating whether the specified character is a +character that is any of: alphabetic, numeric, or an underscore. This is the +same as what C<\w> matches in a regular expression. +C<isALNUM()> is a synonym provided for backward compatibility. Note that it +does not have the standard C language meaning of alphanumeric, since it matches +an underscore and the standard meaning does not. +See the L<top of this section|/Character classes> for an explanation of variants +C<isWORDCHAR_A> and C<isWORDCHAR_L1>. - char toLOWER(char ch) + bool isWORDCHAR(char ch) =for hackers Found in file handy.h -=item toUPPER -X<toUPPER> +=item isXDIGIT +X<isXDIGIT> -Converts the specified character to uppercase. Characters outside the -US-ASCII (Basic Latin) range are viewed as not having any case. +Returns a boolean indicating whether the specified character is a hexadecimal +digit, [0-9A-Fa-f]. Variants C<isXDIGIT_A()> and C<isXDIGIT_L1()> are +identical to C<isXDIGIT()>. - char toUPPER(char ch) + bool isXDIGIT(char ch) =for hackers Found in file handy.h @@ -669,6 +762,486 @@ Found in file sv.c =back +=head1 Compile-time scope hooks + +=over 8 + +=item BhkDISABLE +X<BhkDISABLE> + +Temporarily disable an entry in this BHK structure, by clearing the +appropriate flag. I<which> is a preprocessor token indicating which +entry to disable. + +NOTE: this function is experimental and may change or be +removed without notice. + + void BhkDISABLE(BHK *hk, which) + +=for hackers +Found in file op.h + +=item BhkENABLE +X<BhkENABLE> + +Re-enable an entry in this BHK structure, by setting the appropriate +flag. I<which> is a preprocessor token indicating which entry to enable. +This will assert (under -DDEBUGGING) if the entry doesn't contain a valid +pointer. + +NOTE: this function is experimental and may change or be +removed without notice. + + void BhkENABLE(BHK *hk, which) + +=for hackers +Found in file op.h + +=item BhkENTRY_set +X<BhkENTRY_set> + +Set an entry in the BHK structure, and set the flags to indicate it is +valid. I<which> is a preprocessing token indicating which entry to set. +The type of I<ptr> depends on the entry. + +NOTE: this function is experimental and may change or be +removed without notice. + + void BhkENTRY_set(BHK *hk, which, void *ptr) + +=for hackers +Found in file op.h + +=item blockhook_register +X<blockhook_register> + +Register a set of hooks to be called when the Perl lexical scope changes +at compile time. See L<perlguts/"Compile-time scope hooks">. + +NOTE: this function is experimental and may change or be +removed without notice. + +NOTE: this function must be explicitly called as Perl_blockhook_register with an aTHX_ parameter. + + void Perl_blockhook_register(pTHX_ BHK *hk) + +=for hackers +Found in file op.c + + +=back + +=head1 COP Hint Hashes + +=over 8 + +=item cophh_2hv +X<cophh_2hv> + +Generates and returns a standard Perl hash representing the full set of +key/value pairs in the cop hints hash I<cophh>. I<flags> is currently +unused and must be zero. + +NOTE: this function is experimental and may change or be +removed without notice. + + HV * cophh_2hv(const COPHH *cophh, U32 flags) + +=for hackers +Found in file cop.h + +=item cophh_copy +X<cophh_copy> + +Make and return a complete copy of the cop hints hash I<cophh>. + +NOTE: this function is experimental and may change or be +removed without notice. + + COPHH * cophh_copy(COPHH *cophh) + +=for hackers +Found in file cop.h + +=item cophh_delete_pv +X<cophh_delete_pv> + +Like L</cophh_delete_pvn>, but takes a nul-terminated string instead of +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) + +=for hackers +Found in file cop.h + +=item cophh_delete_pvn +X<cophh_delete_pvn> + +Delete a key and its associated value from the cop hints hash I<cophh>, +and returns the modified hash. The returned hash pointer is in general +not the same as the hash pointer that was passed in. The input hash is +consumed by the function, and the pointer to it must not be subsequently +used. Use L</cophh_copy> if you need both hashes. + +The key is specified by I<keypv> and I<keylen>. If I<flags> has the +C<COPHH_KEY_UTF8> bit set, the key octets are interpreted as UTF-8, +otherwise they are interpreted as Latin-1. I<hash> is a precomputed +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) + +=for hackers +Found in file cop.h + +=item cophh_delete_pvs +X<cophh_delete_pvs> + +Like L</cophh_delete_pvn>, but takes a literal string instead of a +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) + +=for hackers +Found in file cop.h + +=item cophh_delete_sv +X<cophh_delete_sv> + +Like L</cophh_delete_pvn>, but takes a Perl scalar instead of a +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) + +=for hackers +Found in file cop.h + +=item cophh_fetch_pv +X<cophh_fetch_pv> + +Like L</cophh_fetch_pvn>, but takes a nul-terminated string instead of +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) + +=for hackers +Found in file cop.h + +=item cophh_fetch_pvn +X<cophh_fetch_pvn> + +Look up the entry in the cop hints hash I<cophh> with the key specified by +I<keypv> and I<keylen>. If I<flags> has the C<COPHH_KEY_UTF8> bit set, +the key octets are interpreted as UTF-8, otherwise they are interpreted +as Latin-1. I<hash> is a precomputed hash of the key string, or zero if +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. + +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) + +=for hackers +Found in file cop.h + +=item cophh_fetch_pvs +X<cophh_fetch_pvs> + +Like L</cophh_fetch_pvn>, but takes a literal string instead of a +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) + +=for hackers +Found in file cop.h + +=item cophh_fetch_sv +X<cophh_fetch_sv> + +Like L</cophh_fetch_pvn>, but takes a Perl scalar instead of a +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) + +=for hackers +Found in file cop.h + +=item cophh_free +X<cophh_free> + +Discard the cop hints hash I<cophh>, freeing all resources associated +with it. + +NOTE: this function is experimental and may change or be +removed without notice. + + void cophh_free(COPHH *cophh) + +=for hackers +Found in file cop.h + +=item cophh_new_empty +X<cophh_new_empty> + +Generate and return a fresh cop hints hash containing no entries. + +NOTE: this function is experimental and may change or be +removed without notice. + + COPHH * cophh_new_empty() + +=for hackers +Found in file cop.h + +=item cophh_store_pv +X<cophh_store_pv> + +Like L</cophh_store_pvn>, but takes a nul-terminated string instead of +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) + +=for hackers +Found in file cop.h + +=item cophh_store_pvn +X<cophh_store_pvn> + +Stores a value, associated with a key, in the cop hints hash I<cophh>, +and returns the modified hash. The returned hash pointer is in general +not the same as the hash pointer that was passed in. The input hash is +consumed by the function, and the pointer to it must not be subsequently +used. Use L</cophh_copy> if you need both hashes. + +The key is specified by I<keypv> and I<keylen>. If I<flags> has the +C<COPHH_KEY_UTF8> bit set, the key octets are interpreted as UTF-8, +otherwise they are interpreted as Latin-1. I<hash> is a precomputed +hash of the key string, or zero if it has not been precomputed. + +I<value> is the scalar value to store for this key. I<value> is copied +by this function, which thus does not take ownership of any reference +to it, and later changes to the scalar will not be reflected in the +value visible in the cop hints hash. Complex types of scalar will not +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) + +=for hackers +Found in file cop.h + +=item cophh_store_pvs +X<cophh_store_pvs> + +Like L</cophh_store_pvn>, but takes a literal string instead of a +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) + +=for hackers +Found in file cop.h + +=item cophh_store_sv +X<cophh_store_sv> + +Like L</cophh_store_pvn>, but takes a Perl scalar instead of a +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) + +=for hackers +Found in file cop.h + + +=back + +=head1 COP Hint Reading + +=over 8 + +=item cop_hints_2hv +X<cop_hints_2hv> + +Generates and returns a standard Perl hash representing the full set of +hint entries in the cop I<cop>. I<flags> is currently unused and must +be zero. + + HV * cop_hints_2hv(const COP *cop, U32 flags) + +=for hackers +Found in file cop.h + +=item cop_hints_fetch_pv +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) + +=for hackers +Found in file cop.h + +=item cop_hints_fetch_pvn +X<cop_hints_fetch_pvn> + +Look up the hint entry in the cop I<cop> with the key specified by +I<keypv> and I<keylen>. If I<flags> has the C<COPHH_KEY_UTF8> bit set, +the key octets are interpreted as UTF-8, otherwise they are interpreted +as Latin-1. I<hash> is a precomputed hash of the key string, or zero if +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) + +=for hackers +Found in file cop.h + +=item cop_hints_fetch_pvs +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) + +=for hackers +Found in file cop.h + +=item cop_hints_fetch_sv +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) + +=for hackers +Found in file cop.h + + +=back + +=head1 Custom Operators + +=over 8 + +=item custom_op_register +X<custom_op_register> + +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) + +=for hackers +Found in file op.c + +=item custom_op_xop +X<custom_op_xop> + +Return the XOP structure for a given custom op. This function should be +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) + +=for hackers +Found in file op.c + +=item XopDISABLE +X<XopDISABLE> + +Temporarily disable a member of the XOP, by clearing the appropriate flag. + + void XopDISABLE(XOP *xop, which) + +=for hackers +Found in file op.h + +=item XopENABLE +X<XopENABLE> + +Reenable a member of the XOP which has been disabled. + + void XopENABLE(XOP *xop, which) + +=for hackers +Found in file op.h + +=item XopENTRY +X<XopENTRY> + +Return a member of the XOP structure. I<which> is a cpp token indicating +which entry to return. If the member is not set this will return a +default value. The return type depends on I<which>. + + XopENTRY(XOP *xop, which) + +=for hackers +Found in file op.h + +=item XopENTRY_set +X<XopENTRY_set> + +Set a member of the XOP structure. I<which> is a cpp token indicating +which entry to set. See L<perlguts/"Custom Operators"> for details about +the available members and how they are used. + + void XopENTRY_set(XOP *xop, which, value) + +=for hackers +Found in file op.h + +=item XopFLAGS +X<XopFLAGS> + +Return the XOP's flags. + + U32 XopFLAGS(XOP *xop) + +=for hackers +Found in file op.h + + +=back + =head1 CV Manipulation Functions =over 8 @@ -729,7 +1302,7 @@ children can still follow the full lexical scope chain. void cv_undef(CV* cv) =for hackers -Found in file op.c +Found in file pad.c =item load_module X<load_module> @@ -763,6 +1336,34 @@ no threads. =for hackers Found in file perl.c +=item pad_findmy +X<pad_findmy> + +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. + +NOTE: this function is experimental and may change or be +removed without notice. + + PADOFFSET pad_findmy(const char* name, STRLEN len, U32 flags) + +=for hackers +Found in file pad.c + +=item pad_sv +X<pad_sv> + +Get the value at offset po in the current pad. +Use macro PAD_SV instead of calling this function directly. + + SV* pad_sv(PADOFFSET po) + +=for hackers +Found in file pad.c + =item perl_alloc X<perl_alloc> @@ -880,18 +1481,18 @@ if PERL_PV_ESCAPE_UNI_DETECT is set then the input string is scanned using C<is_utf8_string()> to determine if it is Unicode. If PERL_PV_ESCAPE_ALL is set then all input chars will be output -using C<\x01F1> style escapes, otherwise only chars above 255 will be -escaped using this style, other non printable chars will use octal or -common escaped patterns like C<\n>. If PERL_PV_ESCAPE_NOBACKSLASH -then all chars below 255 will be treated as printable and +using C<\x01F1> style escapes, otherwise if PERL_PV_ESCAPE_NONASCII is set, only +chars above 127 will be escaped using this style; otherwise, only chars above +255 will be so escaped; other non printable chars will use octal or +common escaped patterns like C<\n>. Otherwise, if PERL_PV_ESCAPE_NOBACKSLASH +then all chars below 255 will be treated as printable and will be output as literals. If PERL_PV_ESCAPE_FIRSTCHAR is set then only the first char of the -string will be escaped, regardles of max. If the string is utf8 and -the chars value is >255 then it will be returned as a plain hex -sequence. Thus the output will either be a single char, -an octal escape sequence, a special escape like C<\n> or a 3 or -more digit hex value. +string will be escaped, regardless of max. If the output is to be in hex, +then it will be returned as a plain hex +sequence. Thus the output will either be a single char, +an octal escape sequence, a special escape like C<\n> or a hex value. If PERL_PV_ESCAPE_RE is set then the escape char used will be a '%' and not a '\\'. This is because regexes very often contain backslashed @@ -914,18 +1515,18 @@ If the PERL_PV_PRETTY_QUOTE flag is set then the result will be double quoted with any double quotes in the string escaped. Otherwise if the PERL_PV_PRETTY_LTGT flag is set then the result be wrapped in angle brackets. - + If the PERL_PV_PRETTY_ELLIPSES flag is set and not all characters in string were output then an ellipsis C<...> will be appended to the string. Note that this happens AFTER it has been quoted. - + If start_color is non-null then it will be inserted after the opening quote (if there is one) but before the escaped text. If end_color is non-null then it will be inserted after the escaped text but before 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) =for hackers @@ -939,6 +1540,30 @@ Found in file dump.c =over 8 +=item custom_op_desc +X<custom_op_desc> + +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) + +=for hackers +Found in file mathoms.c + +=item custom_op_name +X<custom_op_name> + +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) + +=for hackers +Found in file mathoms.c + =item gv_fetchmethod X<gv_fetchmethod> @@ -1212,6 +1837,27 @@ Found in file mathoms.c =back +=head1 Functions in file op.c + + +=over 8 + +=item op_contextualize +X<op_contextualize> + +Applies a syntactic context to an op tree representing an expression. +I<o> is the op tree, and I<context> must be C<G_SCALAR>, C<G_ARRAY>, +or C<G_VOID> to specify the context to apply. The modified op tree +is returned. + + OP * op_contextualize(OP *o, I32 context) + +=for hackers +Found in file op.c + + +=back + =head1 Functions in file perl.h @@ -1261,6 +1907,27 @@ Found in file perl.h =over 8 +=item caller_cx +X<caller_cx> + +The XSUB-writer's equivalent of L<caller()|perlfunc/caller>. The +returned C<PERL_CONTEXT> structure can be interrogated to find all the +information returned to Perl by C<caller>. Note that XSUBs don't get a +stack frame, so C<caller_cx(0, NULL)> will return information for the +immediately-surrounding Perl code. + +This function skips over the automatic calls to C<&DB::sub> made on the +behalf of the debugger. If the stack frame requested was a sub called by +C<DB::sub>, the return value will be the frame for the call to +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) + +=for hackers +Found in file pp_ctl.c + =item find_runcv X<find_runcv> @@ -1329,6 +1996,52 @@ Found in file pp_sys.c =back +=head1 Functions in file utf8.h + + +=over 8 + +=item ibcmp_utf8 +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) + +=for hackers +Found in file utf8.h + + +=back + +=head1 Functions in file util.h + + +=over 8 + +=item ibcmp +X<ibcmp> + +This is a synonym for (! foldEQ()) + + I32 ibcmp(const char* a, const char* b, I32 len) + +=for hackers +Found in file util.h + +=item ibcmp_locale +X<ibcmp_locale> + +This is a synonym for (! foldEQ_locale()) + + I32 ibcmp_locale(const char* a, const char* b, I32 len) + +=for hackers +Found in file util.h + + +=back + =head1 Global Variables =over 8 @@ -1358,7 +2071,7 @@ introduced by the keyword. See L</Lexer interface> for details. When a keyword is being handled, the plugin function must build a tree of C<OP> structures, representing the code that was parsed. The root of the tree must be stored in C<*op_ptr>. The function then -returns a contant indicating the syntactic role of the construct that +returns a constant indicating the syntactic role of the construct that it has parsed: C<KEYWORD_PLUGIN_STMT> if it is a complete statement, or C<KEYWORD_PLUGIN_EXPR> if it is an expression. Note that a statement construct cannot be used inside an expression (except via C<do BLOCK> @@ -1735,6 +2448,21 @@ Returns the value slot (type C<SV*>) stored in the hash entry. =for hackers Found in file hv.h +=item HvENAME +X<HvENAME> + +Returns the effective name of a stash, or NULL if there is none. The +effective name represents a location in the symbol table where this stash +resides. It is updated automatically when packages are aliased or deleted. +A stash that is no longer in the symbol table has no effective name. This +name is preferable to C<HvNAME> for use in MRO linearisations and isa +caches. + + char* HvENAME(HV* stash) + +=for hackers +Found in file hv.h + =item HvNAME X<HvNAME> @@ -1782,13 +2510,27 @@ See Hash::Util::lock_keys() for an example of its use. =for hackers Found in file hv.c +=item hv_copy_hints_hv +X<hv_copy_hints_hv> + +A specialised version of L</newHVhv> for copying C<%^H>. I<ohv> must be +a pointer to a hash (which may have C<%^H> magic, but should be generally +non-magical), or C<NULL> (interpreted as an empty hash). The content +of I<ohv> is copied to a new hash, which has the C<%^H>-specific magic +added to it. A pointer to the new hash is returned. + + HV * hv_copy_hints_hv(HV *ohv) + +=for hackers +Found in file hv.c + =item hv_delete X<hv_delete> -Deletes a key/value pair in the hash. The value SV is removed from the -hash 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. +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. SV* hv_delete(HV *hv, const char *key, I32 klen, I32 flags) @@ -1798,10 +2540,11 @@ Found in file hv.c =item hv_delete_ent X<hv_delete_ent> -Deletes a key/value pair in the hash. The value SV is removed from the -hash and returned to the caller. The C<flags> value will normally be zero; -if set to G_DISCARD then NULL will be returned. C<hash> can be a valid -precomputed hash value, or 0 to ask for it to be computed. +Deletes a key/value pair in the hash. The value SV is removed from the hash, +made mortal, and returned to the caller. 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. 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) @@ -1864,7 +2607,7 @@ Returns the hash entry which corresponds to the specified key in the hash. C<hash> must be a valid precomputed hash number for the given C<key>, or 0 if you want the function to compute it. IF C<lval> is set then the fetch will be part of a store. Make sure the return value is non-null before -accessing it. The return value when C<tb> is a tied hash is a pointer to a +accessing it. The return value when C<hv> is a tied hash is a pointer to a static location, so be sure to make a copy of the structure if you need to store it somewhere. @@ -1876,16 +2619,30 @@ information on how to use this function on tied hashes. =for hackers Found in file hv.c +=item hv_fill +X<hv_fill> + +Returns the number of hash buckets that happen to be in use. This function is +wrapped by the macro C<HvFILL>. + +Previously this value was stored in the HV structure, rather than being +calculated on demand. + + STRLEN hv_fill(HV const *const hv) + +=for hackers +Found in file hv.c + =item hv_iterinit 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(tb)>). The return value is +keys in the hash (i.e. the same as C<HvKEYS(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 hash buckets that happen to be in use. If you still need that esoteric -value, you can get it through the macro C<HvFILL(tb)>. +value, you can get it through the macro C<HvFILL(hv)>. I32 hv_iterinit(HV *hv) @@ -2135,7 +2892,7 @@ it is not permitted to discard text that has yet to be lexed. Normally it is not necessarily to do this directly, because it suffices to use the implicit discarding behaviour of L</lex_next_chunk> and things based on it. However, if a token stretches across multiple lines, -and the lexing code has kept multiple lines of text in the buffer fof +and the lexing code has kept multiple lines of text in the buffer for that purpose, then after completion of the token it would be wise to explicitly discard the now-unneeded earlier lines, to avoid future multi-line tokens growing the buffer without bound. @@ -2288,6 +3045,63 @@ removed without notice. =for hackers Found in file toke.c +=item lex_start +X<lex_start> + +Creates and initialises a new lexer/parser state object, supplying +a context in which to lex and parse from a new source of Perl code. +A pointer to the new state object is placed in L</PL_parser>. An entry +is made on the save stack so that upon unwinding the new state object +will be destroyed and the former value of L</PL_parser> will be restored. +Nothing else need be done to clean up the parsing context. + +The code to be parsed comes from I<line> and I<rsfp>. I<line>, if +non-null, provides a string (in SV form) containing code to be parsed. +A copy of the string is made, so subsequent modification of I<line> +does not affect parsing. I<rsfp>, if non-null, provides an input stream +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. + +NOTE: this function is experimental and may change or be +removed without notice. + + void lex_start(SV *line, PerlIO *rsfp, U32 flags) + +=for hackers +Found in file toke.c + +=item lex_stuff_pv +X<lex_stuff_pv> + +Insert characters into the lexer buffer (L</PL_parser-E<gt>linestr>), +immediately after the current lexing point (L</PL_parser-E<gt>bufptr>), +reallocating the buffer if necessary. This means that lexing code that +runs later will see the characters as if they had appeared in the input. +It is not recommended to do this as part of normal parsing, and most +uses of this facility run the risk of the inserted characters being +interpreted in an unintended manner. + +The string to be inserted is represented by octets starting at I<pv> +and continuing to the first nul. These octets are interpreted as either +UTF-8 or Latin-1, according to whether the C<LEX_STUFF_UTF8> flag is set +in I<flags>. The characters are recoded for the lexer buffer, according +to how the buffer is currently being interpreted (L</lex_bufutf8>). +If it is not convenient to nul-terminate a string to be inserted, the +L</lex_stuff_pvn> function is more appropriate. + +NOTE: this function is experimental and may change or be +removed without notice. + + void lex_stuff_pv(const char *pv, U32 flags) + +=for hackers +Found in file toke.c + =item lex_stuff_pvn X<lex_stuff_pvn> @@ -2304,17 +3118,31 @@ at I<pv>. These octets are interpreted as either UTF-8 or Latin-1, according to whether the C<LEX_STUFF_UTF8> flag is set in I<flags>. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (L</lex_bufutf8>). If a string -to be interpreted is available as a Perl scalar, the L</lex_stuff_sv> +to be inserted is available as a Perl scalar, the L</lex_stuff_sv> function is more convenient. NOTE: this function is experimental and may change or be removed without notice. - void lex_stuff_pvn(char *pv, STRLEN len, U32 flags) + void lex_stuff_pvn(const char *pv, STRLEN len, U32 flags) =for hackers Found in file toke.c +=item lex_stuff_pvs +X<lex_stuff_pvs> + +Like L</lex_stuff_pvn>, but takes a literal string instead of a +string/length pair. + +NOTE: this function is experimental and may change or be +removed without notice. + + void lex_stuff_pvs(const char *pv, U32 flags) + +=for hackers +Found in file handy.h + =item lex_stuff_sv X<lex_stuff_sv> @@ -2328,7 +3156,7 @@ interpreted in an unintended manner. The string to be inserted is the string value of I<sv>. The characters are recoded for the lexer buffer, according to how the buffer is currently -being interpreted (L</lex_bufutf8>). If a string to be interpreted is +being interpreted (L</lex_bufutf8>). If a string to be inserted is not already a Perl scalar, the L</lex_stuff_pvn> function avoids the need to construct a scalar. @@ -2359,6 +3187,291 @@ removed without notice. =for hackers Found in file toke.c +=item parse_arithexpr +X<parse_arithexpr> + +Parse a Perl arithmetic expression. This may contain operators of precedence +down to the bit shift operators. The expression must be followed (and thus +terminated) either by a comparison or lower-precedence operator or by +something that would normally terminate an expression such as semicolon. +If I<flags> includes C<PARSE_OPTIONAL> then the expression is optional, +otherwise it is mandatory. It is up to the caller to ensure that the +dynamic parser state (L</PL_parser> et al) is correctly set to reflect +the source of the code to be parsed and the lexical context for the +expression. + +The op tree representing the expression is returned. If an optional +expression is absent, a null pointer is returned, otherwise the pointer +will be non-null. + +If an error occurs in parsing or compilation, in most cases a valid op +tree is returned anyway. The error is reflected in the parser state, +normally resulting in a single exception at the top level of parsing +which covers all the compilation errors that occurred. Some compilation +errors, however, will throw an exception immediately. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_arithexpr(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_barestmt +X<parse_barestmt> + +Parse a single unadorned Perl statement. This may be a normal imperative +statement or a declaration that has compile-time effect. It does not +include any label or other affixture. It is up to the caller to ensure +that the dynamic parser state (L</PL_parser> et al) is correctly set to +reflect the source of the code to be parsed and the lexical context for +the statement. + +The op tree representing the statement is returned. This may be a +null pointer if the statement is null, for example if it was actually +a subroutine definition (which has compile-time side effects). If not +null, it will be ops directly implementing the statement, suitable to +pass to L</newSTATEOP>. It will not normally include a C<nextstate> or +equivalent op (except for those embedded in a scope contained entirely +within the statement). + +If an error occurs in parsing or compilation, in most cases a valid op +tree (most likely null) is returned anyway. The error is reflected in +the parser state, normally resulting in a single exception at the top +level of parsing which covers all the compilation errors that occurred. +Some compilation errors, however, will throw an exception immediately. + +The I<flags> parameter is reserved for future use, and must always +be zero. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_barestmt(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_block +X<parse_block> + +Parse a single complete Perl code block. This consists of an opening +brace, a sequence of statements, and a closing brace. The block +constitutes a lexical scope, so C<my> variables and various compile-time +effects can be contained within it. It is up to the caller to ensure +that the dynamic parser state (L</PL_parser> et al) is correctly set to +reflect the source of the code to be parsed and the lexical context for +the statement. + +The op tree representing the code block is returned. This is always a +real op, never a null pointer. It will normally be a C<lineseq> list, +including C<nextstate> or equivalent ops. No ops to construct any kind +of runtime scope are included by virtue of it being a block. + +If an error occurs in parsing or compilation, in most cases a valid op +tree (most likely null) is returned anyway. The error is reflected in +the parser state, normally resulting in a single exception at the top +level of parsing which covers all the compilation errors that occurred. +Some compilation errors, however, will throw an exception immediately. + +The I<flags> parameter is reserved for future use, and must always +be zero. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_block(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_fullexpr +X<parse_fullexpr> + +Parse a single complete Perl expression. This allows the full +expression grammar, including the lowest-precedence operators such +as C<or>. The expression must be followed (and thus terminated) by a +token that an expression would normally be terminated by: end-of-file, +closing bracketing punctuation, semicolon, or one of the keywords that +signals a postfix expression-statement modifier. If I<flags> includes +C<PARSE_OPTIONAL> then the expression is optional, otherwise it is +mandatory. It is up to the caller to ensure that the dynamic parser +state (L</PL_parser> et al) is correctly set to reflect the source of +the code to be parsed and the lexical context for the expression. + +The op tree representing the expression is returned. If an optional +expression is absent, a null pointer is returned, otherwise the pointer +will be non-null. + +If an error occurs in parsing or compilation, in most cases a valid op +tree is returned anyway. The error is reflected in the parser state, +normally resulting in a single exception at the top level of parsing +which covers all the compilation errors that occurred. Some compilation +errors, however, will throw an exception immediately. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_fullexpr(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_fullstmt +X<parse_fullstmt> + +Parse a single complete Perl statement. This may be a normal imperative +statement or a declaration that has compile-time effect, and may include +optional labels. It is up to the caller to ensure that the dynamic +parser state (L</PL_parser> et al) is correctly set to reflect the source +of the code to be parsed and the lexical context for the statement. + +The op tree representing the statement is returned. This may be a +null pointer if the statement is null, for example if it was actually +a subroutine definition (which has compile-time side effects). If not +null, it will be the result of a L</newSTATEOP> call, normally including +a C<nextstate> or equivalent op. + +If an error occurs in parsing or compilation, in most cases a valid op +tree (most likely null) is returned anyway. The error is reflected in +the parser state, normally resulting in a single exception at the top +level of parsing which covers all the compilation errors that occurred. +Some compilation errors, however, will throw an exception immediately. + +The I<flags> parameter is reserved for future use, and must always +be zero. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_fullstmt(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_label +X<parse_label> + +Parse a single label, possibly optional, of the type that may prefix a +Perl statement. It is up to the caller to ensure that the dynamic parser +state (L</PL_parser> et al) is correctly set to reflect the source of +the code to be parsed. If I<flags> includes C<PARSE_OPTIONAL> then the +label is optional, otherwise it is mandatory. + +The name of the label is returned in the form of a fresh scalar. If an +optional label is absent, a null pointer is returned. + +If an error occurs in parsing, which can only occur if the label is +mandatory, a valid label is returned anyway. The error is reflected in +the parser state, normally resulting in a single exception at the top +level of parsing which covers all the compilation errors that occurred. + +NOTE: this function is experimental and may change or be +removed without notice. + + SV * parse_label(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_listexpr +X<parse_listexpr> + +Parse a Perl list expression. This may contain operators of precedence +down to the comma operator. The expression must be followed (and thus +terminated) either by a low-precedence logic operator such as C<or> or by +something that would normally terminate an expression such as semicolon. +If I<flags> includes C<PARSE_OPTIONAL> then the expression is optional, +otherwise it is mandatory. It is up to the caller to ensure that the +dynamic parser state (L</PL_parser> et al) is correctly set to reflect +the source of the code to be parsed and the lexical context for the +expression. + +The op tree representing the expression is returned. If an optional +expression is absent, a null pointer is returned, otherwise the pointer +will be non-null. + +If an error occurs in parsing or compilation, in most cases a valid op +tree is returned anyway. The error is reflected in the parser state, +normally resulting in a single exception at the top level of parsing +which covers all the compilation errors that occurred. Some compilation +errors, however, will throw an exception immediately. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_listexpr(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_stmtseq +X<parse_stmtseq> + +Parse a sequence of zero or more Perl statements. These may be normal +imperative statements, including optional labels, or declarations +that have compile-time effect, or any mixture thereof. The statement +sequence ends when a closing brace or end-of-file is encountered in a +place where a new statement could have validly started. It is up to +the caller to ensure that the dynamic parser state (L</PL_parser> et al) +is correctly set to reflect the source of the code to be parsed and the +lexical context for the statements. + +The op tree representing the statement sequence is returned. This may +be a null pointer if the statements were all null, for example if there +were no statements or if there were only subroutine definitions (which +have compile-time side effects). If not null, it will be a C<lineseq> +list, normally including C<nextstate> or equivalent ops. + +If an error occurs in parsing or compilation, in most cases a valid op +tree is returned anyway. The error is reflected in the parser state, +normally resulting in a single exception at the top level of parsing +which covers all the compilation errors that occurred. Some compilation +errors, however, will throw an exception immediately. + +The I<flags> parameter is reserved for future use, and must always +be zero. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_stmtseq(U32 flags) + +=for hackers +Found in file toke.c + +=item parse_termexpr +X<parse_termexpr> + +Parse a Perl term expression. This may contain operators of precedence +down to the assignment operators. The expression must be followed (and thus +terminated) either by a comma or lower-precedence operator or by +something that would normally terminate an expression such as semicolon. +If I<flags> includes C<PARSE_OPTIONAL> then the expression is optional, +otherwise it is mandatory. It is up to the caller to ensure that the +dynamic parser state (L</PL_parser> et al) is correctly set to reflect +the source of the code to be parsed and the lexical context for the +expression. + +The op tree representing the expression is returned. If an optional +expression is absent, a null pointer is returned, otherwise the pointer +will be non-null. + +If an error occurs in parsing or compilation, in most cases a valid op +tree is returned anyway. The error is reflected in the parser state, +normally resulting in a single exception at the top level of parsing +which covers all the compilation errors that occurred. Some compilation +errors, however, will throw an exception immediately. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * parse_termexpr(U32 flags) + +=for hackers +Found in file toke.c + =item PL_parser X<PL_parser> @@ -2495,6 +3608,17 @@ Finds the magic pointer for type matching the SV. See C<sv_magic>. =for hackers Found in file mg.c +=item mg_findext +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) + +=for hackers +Found in file mg.c + =item mg_free X<mg_free> @@ -2505,6 +3629,16 @@ Free any magic storage used by the SV. See C<sv_magic>. =for hackers Found in file mg.c +=item mg_free_type +X<mg_free_type> + +Remove any magic of type I<how> from the SV I<sv>. See L</sv_magic>. + + void mg_free_type(SV *sv, int how) + +=for hackers +Found in file mg.c + =item mg_get X<mg_get> @@ -2864,6 +3998,28 @@ pointer is not acceptable) =for hackers Found in file util.c +=item savesharedpvs +X<savesharedpvs> + +A version of C<savepvs()> which allocates the duplicate string in memory +which is shared between threads. + + char* savesharedpvs(const char* s) + +=for hackers +Found in file handy.h + +=item savesharedsvpv +X<savesharedsvpv> + +A version of C<savesharedpv()> which allocates the duplicate string in +memory which is shared between threads. + + char* savesharedsvpv(SV *sv) + +=for hackers +Found in file util.c + =item savesvpv X<savesvpv> @@ -2938,6 +4094,30 @@ then. =for hackers Found in file util.c +=item foldEQ +X<foldEQ> + +Returns true if the leading len bytes of the strings s1 and s2 are the same +case-insensitively; false otherwise. Uppercase and lowercase ASCII range bytes +match themselves and their opposite case counterparts. Non-cased and non-ASCII +range bytes match only themselves. + + I32 foldEQ(const char* a, const char* b, I32 len) + +=for hackers +Found in file util.c + +=item foldEQ_locale +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) + +=for hackers +Found in file util.c + =item form X<form> @@ -2969,6 +4149,49 @@ Fill the sv with current working directory =for hackers Found in file util.c +=item mess +X<mess> + +Take a sprintf-style format pattern and argument list. These are used to +generate a string message. If the message does not end with a newline, +then it will be extended with some indication of the current location +in the code, as described for L</mess_sv>. + +Normally, the resulting message is returned in a new mortal SV. +During global destruction a single SV may be shared between uses of +this function. + + SV * mess(const char *pat, ...) + +=for hackers +Found in file util.c + +=item mess_sv +X<mess_sv> + +Expands a message, intended for the user, to include an indication of +the current location in the code, if the message does not already appear +to be complete. + +C<basemsg> is the initial message or object. If it is a reference, it +will be used as-is and will be the result of this function. Otherwise it +is used as a string, and if it already ends with a newline, it is taken +to be complete, and the result of this function will be the same string. +If the message does not end with a newline, then a segment such as C<at +foo.pl line 37> will be appended, and possibly other clauses indicating +the current state of execution. The resulting message will end with a +dot and a newline. + +Normally, the resulting message is returned in a new mortal SV. +During global destruction a single SV may be shared between uses of this +function. If C<consume> is true, then the function is permitted (but not +required) to modify and return C<basemsg> instead of allocating a new SV. + + SV * mess_sv(SV *basemsg, bool consume) + +=for hackers +Found in file util.c + =item my_snprintf X<my_snprintf> @@ -3028,6 +4251,11 @@ Found in file util.c =item prescan_version X<prescan_version> +Validate that a given string can be parsed as a version object, but doesn't +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) =for hackers @@ -3198,6 +4426,24 @@ converted into version objects. =for hackers Found in file util.c +=item vmess +X<vmess> + +C<pat> and C<args> are a sprintf-style format pattern and encapsulated +argument list. These are used to generate a string message. If the +message does not end with a newline, then it will be extended with +some indication of the current location in the code, as described for +L</mess_sv>. + +Normally, the resulting message is returned in a new mortal SV. +During global destruction a single SV may be shared between uses of +this function. + + SV * vmess(const char *pat, va_list *args) + +=for hackers +Found in file util.c + =item vnormal X<vnormal> @@ -3209,6 +4455,8 @@ representation. Call like: NOTE: you can pass either the object directly or the SV contained within the RV. +The SV returned has a refcount of 1. + SV* vnormal(SV *vs) =for hackers @@ -3225,6 +4473,8 @@ point representation. Call like: NOTE: you can pass either the object directly or the SV contained within the RV. +The SV returned has a refcount of 1. + SV* vnumify(SV *vs) =for hackers @@ -3236,7 +4486,9 @@ X<vstringify> In order to maintain maximum compatibility with earlier versions of Perl, this function will return either the floating point notation or the multiple dotted notation, depending on whether -the original version contained 1 or more dots, respectively +the original version contained 1 or more dots, respectively. + +The SV returned has a refcount of 1. SV* vstringify(SV *vs) @@ -3246,14 +4498,17 @@ Found in file util.c =item vverify X<vverify> -Validates that the SV contains a valid version object. +Validates that the SV contains valid internal structure for a version object. +It may be passed either the version object (RV) or the hash itself (HV). If +the structure is valid, it returns the HV. If the structure is invalid, +it returns NULL. - bool vverify(SV *vobj); + SV *hv = vverify(sv); Note that it only confirms the bare minimum structure (so as not to get confused by derived classes which may contain additional hash entries): - bool vverify(SV *vs) + SV* vverify(SV *vs) =for hackers Found in file util.c @@ -3477,7 +4732,7 @@ On entry I<start> and I<*len> give the string to scan, I<*flags> gives conversion flags, and I<result> should be NULL or a pointer to an NV. The scan stops at the end of the string, or the first invalid character. Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an -invalid character will also trigger a warning. +8 or 9 will also trigger a warning. On return I<*len> is set to the length of the scanned string, and I<*flags> gives output flags. @@ -3559,10 +4814,451 @@ Found in file numeric.c =back +=head1 Optree construction + +=over 8 + +=item newASSIGNOP +X<newASSIGNOP> + +Constructs, checks, and returns an assignment op. I<left> and I<right> +supply the parameters of the assignment; they are consumed by this +function and become part of the constructed op tree. + +If I<optype> is C<OP_ANDASSIGN>, C<OP_ORASSIGN>, or C<OP_DORASSIGN>, then +a suitable conditional optree is constructed. If I<optype> is the opcode +of a binary operator, such as C<OP_BIT_OR>, then an op is constructed that +performs the binary operation and assigns the result to the left argument. +Either way, if I<optype> is non-zero then I<flags> has no effect. + +If I<optype> is zero, then a plain scalar or list assignment is +constructed. Which type of assignment it is is automatically determined. +I<flags> gives the eight bits of C<op_flags>, except that C<OPf_KIDS> +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) + +=for hackers +Found in file op.c + +=item newBINOP +X<newBINOP> + +Constructs, checks, and returns an op of any binary type. I<type> +is the opcode. I<flags> gives the eight bits of C<op_flags>, except +that C<OPf_KIDS> 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. I<first> and I<last> supply up to +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) + +=for hackers +Found in file op.c + +=item newCONDOP +X<newCONDOP> + +Constructs, checks, and returns a conditional-expression (C<cond_expr>) +op. I<flags> gives the eight bits of C<op_flags>, except that C<OPf_KIDS> +will be set automatically, and, shifted up eight bits, the eight bits of +C<op_private>, except that the bit with value 1 is automatically set. +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) + +=for hackers +Found in file op.c + +=item newFOROP +X<newFOROP> + +Constructs, checks, and returns an op tree expressing a C<foreach> +loop (iteration through a list of values). This is a heavyweight loop, +with structure that allows exiting the loop by C<last> and suchlike. + +I<sv> optionally supplies the variable that will be aliased to each +item in turn; if null, it defaults to C<$_> (either lexical or global). +I<expr> supplies the list of values to iterate over. I<block> supplies +the main body of the loop, and I<cont> optionally supplies a C<continue> +block that operates as a second half of the body. All of these optree +inputs are consumed by this function and become part of the constructed +op tree. + +I<flags> gives the eight bits of C<op_flags> for the C<leaveloop> +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) + +=for hackers +Found in file op.c + +=item newGIVENOP +X<newGIVENOP> + +Constructs, checks, and returns an op tree expressing a C<given> block. +I<cond> supplies the expression that will be locally assigned to a lexical +variable, and I<block> supplies the body of the C<given> construct; they +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) + +=for hackers +Found in file op.c + +=item newGVOP +X<newGVOP> + +Constructs, checks, and returns an op of any type that involves an +embedded reference to a GV. I<type> is the opcode. I<flags> gives the +eight bits of C<op_flags>. I<gv> identifies the GV that the op should +reference; calling this function does not transfer ownership of any +reference to it. + + OP * newGVOP(I32 type, I32 flags, GV *gv) + +=for hackers +Found in file op.c + +=item newLISTOP +X<newLISTOP> + +Constructs, checks, and returns an op of any list type. I<type> is +the opcode. I<flags> gives the eight bits of C<op_flags>, except that +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) + +=for hackers +Found in file op.c + +=item newLOGOP +X<newLOGOP> + +Constructs, checks, and returns a logical (flow control) op. I<type> +is the opcode. I<flags> gives the eight bits of C<op_flags>, except +that C<OPf_KIDS> will be set automatically, and, shifted up eight bits, +the eight bits of C<op_private>, except that the bit with value 1 is +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) + +=for hackers +Found in file op.c + +=item newLOOPEX +X<newLOOPEX> + +Constructs, checks, and returns a loop-exiting op (such as C<goto> +or C<last>). I<type> is the opcode. I<label> supplies the parameter +determining the target of the op; it is consumed by this function and +become part of the constructed op tree. + + OP * newLOOPEX(I32 type, OP *label) + +=for hackers +Found in file op.c + +=item newLOOPOP +X<newLOOPOP> + +Constructs, checks, and returns an op tree expressing a loop. This is +only a loop in the control flow through the op tree; it does not have +the heavyweight loop structure that allows exiting the loop by C<last> +and suchlike. I<flags> gives the eight bits of C<op_flags> for the +top-level op, except that some bits will be set automatically as required. +I<expr> supplies the expression controlling loop iteration, and I<block> +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) + +=for hackers +Found in file op.c + +=item newNULLLIST +X<newNULLLIST> + +Constructs, checks, and returns a new C<stub> op, which represents an +empty list expression. + + OP * newNULLLIST() + +=for hackers +Found in file op.c + +=item newOP +X<newOP> + +Constructs, checks, and returns an op of any base type (any type that +has no extra fields). I<type> is the opcode. I<flags> gives the +eight bits of C<op_flags>, and, shifted up eight bits, the eight bits +of C<op_private>. + + OP * newOP(I32 type, I32 flags) + +=for hackers +Found in file op.c + +=item newPADOP +X<newPADOP> + +Constructs, checks, and returns an op of any type that involves a +reference to a pad element. I<type> is the opcode. I<flags> gives the +eight bits of C<op_flags>. A pad slot is automatically allocated, and +is populated with I<sv>; this function takes ownership of one reference +to it. + +This function only exists if Perl has been compiled to use ithreads. + + OP * newPADOP(I32 type, I32 flags, SV *sv) + +=for hackers +Found in file op.c + +=item newPMOP +X<newPMOP> + +Constructs, checks, and returns an op of any pattern matching type. +I<type> is the opcode. I<flags> gives the eight bits of C<op_flags> +and, shifted up eight bits, the eight bits of C<op_private>. + + OP * newPMOP(I32 type, I32 flags) + +=for hackers +Found in file op.c + +=item newPVOP +X<newPVOP> + +Constructs, checks, and returns an op of any type that involves an +embedded C-level pointer (PV). I<type> is the opcode. I<flags> gives +the eight bits of C<op_flags>. I<pv> supplies the C-level pointer, which +must have been allocated using L</PerlMemShared_malloc>; the memory will +be freed when the op is destroyed. + + OP * newPVOP(I32 type, I32 flags, char *pv) + +=for hackers +Found in file op.c + +=item newRANGE +X<newRANGE> + +Constructs and returns a C<range> op, with subordinate C<flip> and +C<flop> ops. I<flags> gives the eight bits of C<op_flags> for the +C<flip> op and, shifted up eight bits, the eight bits of C<op_private> +for both the C<flip> and C<range> ops, except that the bit with value +1 is automatically set. I<left> and I<right> supply the expressions +controlling the endpoints of the range; they are consumed by this function +and become part of the constructed op tree. + + OP * newRANGE(I32 flags, OP *left, OP *right) + +=for hackers +Found in file op.c + +=item newSLICEOP +X<newSLICEOP> + +Constructs, checks, and returns an C<lslice> (list slice) op. I<flags> +gives the eight bits of C<op_flags>, except that C<OPf_KIDS> 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. 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) + +=for hackers +Found in file op.c + +=item newSTATEOP +X<newSTATEOP> + +Constructs a state op (COP). The state op is normally a C<nextstate> op, +but will be a C<dbstate> op if debugging is enabled for currently-compiled +code. The state op is populated from L</PL_curcop> (or L</PL_compiling>). +If I<label> is non-null, it supplies the name of a label to attach to +the state op; this function takes ownership of the memory pointed at by +I<label>, and will free it. I<flags> gives the eight bits of C<op_flags> +for the state op. + +If I<o> is null, the state op is returned. Otherwise the state op is +combined with I<o> into a C<lineseq> list op, which is returned. I<o> +is consumed by this function and becomes part of the returned op tree. + + OP * newSTATEOP(I32 flags, char *label, OP *o) + +=for hackers +Found in file op.c + +=item newSVOP +X<newSVOP> + +Constructs, checks, and returns an op of any type that involves an +embedded SV. I<type> is the opcode. I<flags> gives the eight bits +of C<op_flags>. I<sv> gives the SV to embed in the op; this function +takes ownership of one reference to it. + + OP * newSVOP(I32 type, I32 flags, SV *sv) + +=for hackers +Found in file op.c + +=item newUNOP +X<newUNOP> + +Constructs, checks, and returns an op of any unary type. I<type> is +the opcode. I<flags> gives the eight bits of C<op_flags>, except that +C<OPf_KIDS> will be set automatically if required, and, shifted up eight +bits, the eight bits of C<op_private>, except that the bit with value 1 +is automatically set. I<first> supplies an optional op to be the direct +child of the unary op; it is consumed by this function and become part +of the constructed op tree. + + OP * newUNOP(I32 type, I32 flags, OP *first) + +=for hackers +Found in file op.c + +=item newWHENOP +X<newWHENOP> + +Constructs, checks, and returns an op tree expressing a C<when> block. +I<cond> supplies the test expression, and I<block> supplies the block +that will be executed if the test evaluates to true; they are consumed +by this function and become part of the constructed op tree. I<cond> +will be interpreted DWIMically, often as a comparison against C<$_>, +and may be null to generate a C<default> block. + + OP * newWHENOP(OP *cond, OP *block) + +=for hackers +Found in file op.c + +=item newWHILEOP +X<newWHILEOP> + +Constructs, checks, and returns an op tree expressing a C<while> loop. +This is a heavyweight loop, with structure that allows exiting the loop +by C<last> and suchlike. + +I<loop> is an optional preconstructed C<enterloop> op to use in the +loop; if it is null then a suitable op will be constructed automatically. +I<expr> supplies the loop's controlling expression. I<block> supplies the +main body of the loop, and I<cont> optionally supplies a C<continue> block +that operates as a second half of the body. All of these optree inputs +are consumed by this function and become part of the constructed op tree. + +I<flags> gives the eight bits of C<op_flags> for the C<leaveloop> +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. 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) + +=for hackers +Found in file op.c + + +=back + =head1 Optree Manipulation Functions =over 8 +=item ck_entersub_args_list +X<ck_entersub_args_list> + +Performs the default fixup of the arguments part of an C<entersub> +op tree. This consists of applying list context to each of the +argument ops. This is the standard treatment used on a call marked +with C<&>, or a method call, or a call through a subroutine reference, +or any other call where the callee can't be identified at compile time, +or a call where the callee has no prototype. + + OP * ck_entersub_args_list(OP *entersubop) + +=for hackers +Found in file op.c + +=item ck_entersub_args_proto +X<ck_entersub_args_proto> + +Performs the fixup of the arguments part of an C<entersub> op tree +based on a subroutine prototype. This makes various modifications to +the argument ops, from applying context up to inserting C<refgen> ops, +and checking the number and syntactic types of arguments, as directed by +the prototype. This is the standard treatment used on a subroutine call, +not marked with C<&>, where the callee can be identified at compile time +and has a prototype. + +I<protosv> supplies the subroutine prototype to be applied to the call. +It may be a normal defined scalar, of which the string value will be used. +Alternatively, for convenience, it may be a subroutine object (a C<CV*> +that has been cast to C<SV*>) which has a prototype. The prototype +supplied, in whichever form, does not need to match the actual callee +referenced by the op tree. + +If the argument ops disagree with the prototype, for example by having +an unacceptable number of arguments, a valid op tree is returned anyway. +The error is reflected in the parser state, normally resulting in a single +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) + +=for hackers +Found in file op.c + +=item ck_entersub_args_proto_or_list +X<ck_entersub_args_proto_or_list> + +Performs the fixup of the arguments part of an C<entersub> op tree either +based on a subroutine prototype or using default list-context processing. +This is the standard treatment used on a subroutine call, not marked +with C<&>, where the callee can be identified at compile time. + +I<protosv> supplies the subroutine prototype to be applied to the call, +or indicates that there is no prototype. It may be a normal scalar, +in which case if it is defined then the string value will be used +as a prototype, and if it is undefined then there is no prototype. +Alternatively, for convenience, it may be a subroutine object (a C<CV*> +that has been cast to C<SV*>), of which the prototype will be used if it +has one. The prototype (or lack thereof) supplied, in whichever form, +does not need to match the actual callee referenced by the op tree. + +If the argument ops disagree with the prototype, for example by having +an unacceptable number of arguments, a valid op tree is returned anyway. +The error is reflected in the parser state, normally resulting in a single +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) + +=for hackers +Found in file op.c + =item cv_const_sv X<cv_const_sv> @@ -3577,6 +5273,81 @@ L<perlsub/"Constant Functions">. =for hackers Found in file op.c +=item cv_get_call_checker +X<cv_get_call_checker> + +Retrieves the function that will be used to fix up a call to I<cv>. +Specifically, the function is applied to an C<entersub> op tree for a +subroutine call, not marked with C<&>, where the callee can be identified +at compile time as I<cv>. + +The C-level function pointer is returned in I<*ckfun_p>, and an SV +argument for it is returned in I<*ckobj_p>. The function is intended +to be called in this manner: + + entersubop = (*ckfun_p)(aTHX_ entersubop, namegv, (*ckobj_p)); + +In this call, I<entersubop> is a pointer to the C<entersub> op, +which may be replaced by the check function, and I<namegv> is a GV +supplying the name that should be used by the check function to refer +to the callee of the C<entersub> op if it needs to emit any diagnostics. +It is permitted to apply the check function in non-standard situations, +such as to a call to a different subroutine or to a method call. + +By default, the function is +L<Perl_ck_entersub_args_proto_or_list|/ck_entersub_args_proto_or_list>, +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) + +=for hackers +Found in file op.c + +=item cv_set_call_checker +X<cv_set_call_checker> + +Sets the function that will be used to fix up a call to I<cv>. +Specifically, the function is applied to an C<entersub> op tree for a +subroutine call, not marked with C<&>, where the callee can be identified +at compile time as I<cv>. + +The C-level function pointer is supplied in I<ckfun>, and an SV argument +for it is supplied in I<ckobj>. The function is intended to be called +in this manner: + + entersubop = ckfun(aTHX_ entersubop, namegv, ckobj); + +In this call, I<entersubop> is a pointer to the C<entersub> op, +which may be replaced by the check function, and I<namegv> is a GV +supplying the name that should be used by the check function to refer +to the callee of the C<entersub> op if it needs to emit any diagnostics. +It is permitted to apply the check function in non-standard situations, +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) + +=for hackers +Found in file op.c + +=item LINKLIST +X<LINKLIST> + +Given the root of an optree, link the tree in execution order using the +C<op_next> pointers and return the first op executed. If this has +already been done, it will not be redone, and C<< o->op_next >> will be +returned. If C<< o->op_next >> is not already set, I<o> should be at +least an C<UNOP>. + + OP* LINKLIST(OP *o) + +=for hackers +Found in file op.h + =item newCONSTSUB X<newCONSTSUB> @@ -3602,40 +5373,181 @@ static storage, as it is used directly as CvFILE(), without a copy being made. =for hackers Found in file op.c +=item op_append_elem +X<op_append_elem> -=back +Append an item to the list of ops contained directly within a list-type +op, returning the lengthened list. I<first> is the list-type op, +and I<last> is the op to append to the list. I<optype> specifies the +intended opcode for the list. If I<first> is not already a list of the +right type, it will be upgraded into one. If either I<first> or I<last> +is null, the other is returned unchanged. -=head1 Pad Data Structures + OP * op_append_elem(I32 optype, OP *first, OP *last) -=over 8 +=for hackers +Found in file op.c -=item pad_findmy -X<pad_findmy> +=item op_append_list +X<op_append_list> -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. +Concatenate the lists of ops contained directly within two list-type ops, +returning the combined list. I<first> and I<last> are the list-type ops +to concatenate. I<optype> specifies the intended opcode for the list. +If either I<first> or I<last> is not already a list of the right type, +it will be upgraded into one. If either I<first> or I<last> is null, +the other is returned unchanged. + + OP * op_append_list(I32 optype, OP *first, OP *last) + +=for hackers +Found in file op.c + +=item OP_CLASS +X<OP_CLASS> + +Return the class of the provided OP: that is, which of the *OP +structures it uses. For core ops this currently gets the information out +of PL_opargs, which does not always accurately reflect the type used. +For custom ops the type is returned from the registration, and it is up +to the registree to ensure it is accurate. The value returned will be +one of the OA_* constants from op.h. + + U32 OP_CLASS(OP *o) + +=for hackers +Found in file op.h + +=item OP_DESC +X<OP_DESC> + +Return a short description of the provided OP. + + const char * OP_DESC(OP *o) + +=for hackers +Found in file op.h + +=item op_linklist +X<op_linklist> + +This function is the implementation of the L</LINKLIST> macro. It should +not be called directly. + + OP* op_linklist(OP *o) + +=for hackers +Found in file op.c + +=item op_lvalue +X<op_lvalue> + +Propagate lvalue ("modifiable") context to an op and its children. +I<type> represents the context type, roughly based on the type of op that +would do the modifying, although C<local()> is represented by OP_NULL, +because it has no op type of its own (it is signalled by a flag on +the lvalue op). + +This function detects things that can't be modified, such as C<$x+1>, and +generates errors for them. For example, C<$x+1 = 2> would cause it to be +called with an op of type OP_ADD and a C<type> argument of OP_SASSIGN. + +It also flags things that need to behave specially in an lvalue context, +such as C<$$x = 5> which might have to vivify a reference in C<$x>. NOTE: this function is experimental and may change or be removed without notice. - PADOFFSET pad_findmy(const char* name, STRLEN len, U32 flags) + OP * op_lvalue(OP *o, I32 type) =for hackers -Found in file pad.c +Found in file op.c -=item pad_sv -X<pad_sv> +=item OP_NAME +X<OP_NAME> -Get the value at offset po in the current pad. -Use macro PAD_SV instead of calling this function directly. +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. - SV* pad_sv(PADOFFSET po) + const char * OP_NAME(OP *o) =for hackers -Found in file pad.c +Found in file op.h + +=item op_prepend_elem +X<op_prepend_elem> + +Prepend an item to the list of ops contained directly within a list-type +op, returning the lengthened list. I<first> is the op to prepend to the +list, and I<last> is the list-type op. I<optype> specifies the intended +opcode for the list. If I<last> is not already a list of the right type, +it will be upgraded into one. If either I<first> or I<last> is null, +the other is returned unchanged. + + OP * op_prepend_elem(I32 optype, OP *first, OP *last) + +=for hackers +Found in file op.c + +=item op_scope +X<op_scope> + +Wraps up an op tree with some additional ops so that at runtime a dynamic +scope will be created. The original ops run in the new dynamic scope, +and then, provided that they exit normally, the scope will be unwound. +The additional ops used to create and unwind the dynamic scope will +normally be an C<enter>/C<leave> pair, but a C<scope> op may be used +instead if the ops are simple enough to not need the full dynamic scope +structure. + +NOTE: this function is experimental and may change or be +removed without notice. + + OP * op_scope(OP *o) + +=for hackers +Found in file op.c + +=item rv2cv_op_cv +X<rv2cv_op_cv> + +Examines an op, which is expected to identify a subroutine at runtime, +and attempts to determine at compile time which subroutine it identifies. +This is normally used during Perl compilation to determine whether +a prototype can be applied to a function call. I<cvop> is the op +being considered, normally an C<rv2cv> op. A pointer to the identified +subroutine is returned, if it could be determined statically, and a null +pointer is returned if it was not possible to determine statically. + +Currently, the subroutine can be identified statically if the RV that the +C<rv2cv> is to operate on is provided by a suitable C<gv> or C<const> op. +A C<gv> op is suitable if the GV's CV slot is populated. A C<const> op is +suitable if the constant value must be an RV pointing to a CV. Details of +this process may change in future versions of Perl. If the C<rv2cv> op +has the C<OPpENTERSUB_AMPER> flag set then no attempt is made to identify +the subroutine statically: this flag is used to suppress compile-time +magic on a subroutine call, forcing it to use default runtime behaviour. + +If I<flags> has the bit C<RV2CVOPCV_MARK_EARLY> set, then the handling +of a GV reference is modified. If a GV was examined and its CV slot was +found to be empty, then the C<gv> op has the C<OPpEARLY_CV> flag set. +If the op is not optimised away, and the CV slot is later populated with +a subroutine having a prototype, that flag eventually triggers the warning +"called too early to check prototype". + +If I<flags> has the bit C<RV2CVOPCV_RETURN_NAME_GV> set, then instead +of returning a pointer to the subroutine it returns a pointer to the +GV giving the most appropriate name for the subroutine in this context. +Normally this is just the C<CvGV> of the subroutine, but for an anonymous +(C<CvANON>) subroutine that is referenced through a GV it will be the +referencing GV. The resulting C<GV*> is cast to C<CV*> to be returned. +A null pointer is returned as usual if there is no statically-determinable +subroutine. + + CV * rv2cv_op_cv(OP *cvop, U32 flags) + +=for hackers +Found in file op.c =back @@ -3685,6 +5597,53 @@ When you replace this variable, it is considered a good practice to store the po =for hackers Found in file intrpvar.h +=item PL_peepp +X<PL_peepp> + +Pointer to the per-subroutine peephole optimiser. This is a function +that gets called at the end of compilation of a Perl subroutine (or +equivalently independent piece of Perl code) to perform fixups of +some ops and to perform small-scale optimisations. The function is +called once for each subroutine that is compiled, and is passed, as sole +parameter, a pointer to the op that is the entry point to the subroutine. +It modifies the op tree in place. + +The peephole optimiser should never be completely replaced. Rather, +add code to it by wrapping the existing optimiser. The basic way to do +this can be seen in L<perlguts/Compile pass 3: peephole optimization>. +If the new code wishes to operate on ops throughout the subroutine's +structure, rather than just at the top level, it is likely to be more +convenient to wrap the L</PL_rpeepp> hook. + + peep_t PL_peepp + +=for hackers +Found in file intrpvar.h + +=item PL_rpeepp +X<PL_rpeepp> + +Pointer to the recursive peephole optimiser. This is a function +that gets called at the end of compilation of a Perl subroutine (or +equivalently independent piece of Perl code) to perform fixups of some +ops and to perform small-scale optimisations. The function is called +once for each chain of ops linked through their C<op_next> fields; +it is recursively called to handle each side chain. It is passed, as +sole parameter, a pointer to the op that is at the head of the chain. +It modifies the op tree in place. + +The peephole optimiser should never be completely replaced. Rather, +add code to it by wrapping the existing optimiser. The basic way to do +this can be seen in L<perlguts/Compile pass 3: peephole optimization>. +If the new code wishes to operate only on ops at a subroutine's top level, +rather than throughout the structure, it is likely to be more convenient +to wrap the L</PL_peepp> hook. + + peep_t PL_rpeepp + +=for hackers +Found in file intrpvar.h + =item PL_sv_no X<PL_sv_no> @@ -3732,13 +5691,10 @@ equivalent to the following snippet: if (SvMAGICAL(sv)) mg_get(sv); - if (SvROK(sv) && - (tmpsv = (SV*)SvRV(sv)) && - SvTYPE(tmpsv) == SVt_PVMG && - (tmpmg = mg_find(tmpsv, PERL_MAGIC_qr))) - { - return (REGEXP *)tmpmg->mg_obj; - } + if (SvROK(sv)) + sv = MUTABLE_SV(SvRV(sv)); + if (SvTYPE(sv) == SVt_REGEXP) + return (REGEXP*) sv; NULL will be returned if a REGEXP* is not found. @@ -3750,8 +5706,8 @@ Found in file regexp.h =item SvRXOK X<SvRXOK> -Returns a boolean indicating whether the SV contains qr magic -(PERL_MAGIC_qr). +Returns a boolean indicating whether the SV (or the one it references) +is a REGEXP. If you want to do something with the REGEXP* later use SvRX instead and check for NULL. @@ -4505,7 +6461,7 @@ 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: %s::%s(%s)", "ouch" "awk", "eee_yow"); void croak_xs_usage(const CV *const cv, const char *const params) @@ -4917,6 +6873,16 @@ otherwise use the more efficient C<SvNV>. =for hackers Found in file sv.h +=item SvNV_nomg +X<SvNV_nomg> + +Like C<SvNV> but doesn't process magic. + + NV SvNV_nomg(SV* sv) + +=for hackers +Found in file sv.h + =item SvNV_set X<SvNV_set> @@ -5221,6 +7187,16 @@ Like C<SvPV> but doesn't process magic. =for hackers Found in file sv.h +=item SvPV_nomg_nolen +X<SvPV_nomg_nolen> + +Like C<SvPV_nolen> but doesn't process magic. + + char* SvPV_nomg_nolen(SV* sv) + +=for hackers +Found in file sv.h + =item SvPV_set X<SvPV_set> @@ -5467,13 +7443,26 @@ Found in file sv.h X<SvTRUE> Returns a boolean indicating whether Perl would evaluate the SV as true or -false. See SvOK() for a defined/undefined test. Does not handle 'get' magic. +false. See SvOK() for a defined/undefined test. Handles 'get' magic +unless the scalar is already SvPOK, SvIOK or SvNOK (the public, not the +private flags). bool SvTRUE(SV* sv) =for hackers Found in file sv.h +=item SvTRUE_nomg +X<SvTRUE_nomg> + +Returns a boolean indicating whether Perl would evaluate the SV as true or +false. See SvOK() for a defined/undefined test. Does not handle 'get' magic. + + bool SvTRUE_nomg(SV* sv) + +=for hackers +Found in file sv.h + =item SvTYPE X<SvTYPE> @@ -5612,6 +7601,16 @@ Like C<sv_catpvn> but doesn't process magic. =for hackers Found in file sv.h +=item sv_catpv_nomg +X<sv_catpv_nomg> + +Like C<sv_catpv> but doesn't process magic. + + void sv_catpv_nomg(SV* sv, const char* ptr) + +=for hackers +Found in file sv.h + =item sv_catsv_nomg X<sv_catsv_nomg> @@ -5802,7 +7801,7 @@ 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. Currently the only flag bits accepted are C<SVf_UTF8> and C<SVs_TEMP>. -If C<SVs_TEMP> is set, then C<sv2mortal()> is called on the result before +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 C<SVf_UTF8> flag will be set on the new SV. C<newSVpvn_utf8()> is a convenience wrapper for this function, defined as @@ -5863,6 +7862,17 @@ pair and omits the hash parameter. =for hackers Found in file handy.h +=item newSVpv_share +X<newSVpv_share> + +Like C<newSVpvn_share>, but takes a nul-terminated string instead of a +string/length pair. + + SV* newSVpv_share(const char* s, U32 hash) + +=for hackers +Found in file sv.c + =item newSVrv X<newSVrv> @@ -5912,14 +7922,28 @@ Found in file sv.c =item sv_2bool X<sv_2bool> -This function is only called on magical items, and is only used by -sv_true() or its macro equivalent. +This macro is only used by sv_true() or its macro equivalent, and only if +the latter's argument is neither SvPOK, SvIOK nor SvNOK. +It calls sv_2bool_flags with the SV_GMAGIC flag. bool sv_2bool(SV *const sv) =for hackers Found in file sv.c +=item sv_2bool_flags +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 +contain SV_GMAGIC, then it does an mg_get() first. + + + bool sv_2bool_flags(SV *const sv, const I32 flags) + +=for hackers +Found in file sv.c + =item sv_2cv X<sv_2cv> @@ -5970,14 +7994,14 @@ and C<sv_mortalcopy>. =for hackers Found in file sv.c -=item sv_2nv -X<sv_2nv> +=item sv_2nv_flags +X<sv_2nv_flags> Return the num value of an SV, doing any necessary string or integer -conversion, magic etc. Normally used via the C<SvNV(sv)> and C<SvNVx(sv)> -macros. +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(SV *const sv) + NV sv_2nv_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c @@ -6134,6 +8158,52 @@ Like C<sv_catpvn>, but takes a literal string instead of a string/length pair. =for hackers Found in file handy.h +=item sv_catpvs_flags +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) + +=for hackers +Found in file handy.h + +=item sv_catpvs_mg +X<sv_catpvs_mg> + +Like C<sv_catpvn_mg>, but takes a literal string instead of a +string/length pair. + + void sv_catpvs_mg(SV* sv, const char* s) + +=for hackers +Found in file handy.h + +=item sv_catpvs_nomg +X<sv_catpvs_nomg> + +Like C<sv_catpvn_nomg>, but takes a literal string instead of a +string/length pair. + + void sv_catpvs_nomg(SV* sv, const char* s) + +=for hackers +Found in file handy.h + +=item sv_catpv_flags +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. + + void sv_catpv_flags(SV *dstr, const char *sstr, const I32 flags) + +=for hackers +Found in file sv.c + =item sv_catpv_mg X<sv_catpv_mg> @@ -6195,7 +8265,7 @@ 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. - void sv_clear(SV *const sv) + void sv_clear(SV *const orig_sv) =for hackers Found in file sv.c @@ -6213,6 +8283,20 @@ coerce its args to strings if necessary. See also C<sv_cmp_locale>. =for hackers Found in file sv.c +=item sv_cmp_flags +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 +also C<sv_cmp_locale_flags>. + + I32 sv_cmp_flags(SV *const sv1, SV *const sv2, const U32 flags) + +=for hackers +Found in file sv.c + =item sv_cmp_locale X<sv_cmp_locale> @@ -6225,17 +8309,41 @@ if necessary. See also C<sv_cmp>. =for hackers 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>. + + I32 sv_cmp_locale_flags(SV *const sv1, SV *const sv2, const U32 flags) + +=for hackers +Found in file sv.c + =item sv_collxfrm X<sv_collxfrm> -Add Collate Transform magic to an SV if it doesn't already have it. +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) + +=for hackers +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 +flags contain SV_GMAGIC, it handles get-magic. Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the 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(SV *const sv, STRLEN *const nxp) + char* sv_collxfrm_flags(SV *const sv, STRLEN *const nxp, I32 const flags) =for hackers Found in file sv.c @@ -6260,13 +8368,24 @@ 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. +if necessary. Handles 'get' magic and operator overloading. void sv_dec(SV *const sv) =for hackers Found in file sv.c +=item sv_dec_nomg +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. + + void sv_dec_nomg(SV *const sv) + +=for hackers +Found in file sv.c + =item sv_eq X<sv_eq> @@ -6279,6 +8398,18 @@ coerce its args to strings if necessary. =for hackers Found in file sv.c +=item sv_eq_flags +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. + + I32 sv_eq_flags(SV* sv1, SV* sv2, const U32 flags) + +=for hackers +Found in file sv.c + =item sv_force_normal_flags X<sv_force_normal_flags> @@ -6289,7 +8420,7 @@ 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 unrefing. C<sv_force_normal> calls this function +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) @@ -6337,13 +8468,24 @@ 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. +if necessary. Handles 'get' magic and operator overloading. void sv_inc(SV *const sv) =for hackers Found in file sv.c +=item sv_inc_nomg +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. + + void sv_inc_nomg(SV *const sv) + +=for hackers +Found in file sv.c + =item sv_insert X<sv_insert> @@ -6755,6 +8897,17 @@ Like C<sv_setpvn>, but takes a literal string instead of a string/length pair. =for hackers Found in file handy.h +=item sv_setpvs_mg +X<sv_setpvs_mg> + +Like C<sv_setpvn_mg>, but takes a literal string instead of a +string/length pair. + + void sv_setpvs_mg(SV* sv, const char* s) + +=for hackers +Found in file handy.h + =item sv_setpv_mg X<sv_setpv_mg> @@ -6830,6 +8983,17 @@ Note that C<sv_setref_pv> copies the pointer while this copies the string. =for hackers Found in file sv.c +=item sv_setref_pvs +X<sv_setref_pvs> + +Like C<sv_setref_pvn>, but takes a literal string instead of a +string/length pair. + + SV * sv_setref_pvs(const char* s) + +=for hackers +Found in file handy.h + =item sv_setref_uv X<sv_setref_uv> @@ -6949,6 +9113,16 @@ Removes all magic of type C<type> from an SV. =for hackers Found in file sv.c +=item sv_unmagicext +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) + +=for hackers +Found in file sv.c + =item sv_unref_flags X<sv_unref_flags> @@ -7190,6 +9364,23 @@ Found in file sv.c =over 8 +=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 +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. + +-1 or +1 is returned if the shorter string was identical to the start of the +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) + +=for hackers +Found in file utf8.c + =item bytes_from_utf8 X<bytes_from_utf8> @@ -7212,9 +9403,10 @@ Found in file utf8.c =item bytes_to_utf8 X<bytes_to_utf8> -Converts a string C<s> of length C<len> from the native encoding into UTF-8. +Converts a string C<s> of length C<len> bytes from the native encoding into +UTF-8. Returns a pointer to the newly-created string, and sets C<len> to -reflect the new length. +reflect the new length in bytes. A NUL character will be written after the end of the string. @@ -7230,31 +9422,45 @@ removed without notice. =for hackers Found in file utf8.c -=item ibcmp_utf8 -X<ibcmp_utf8> +=item foldEQ_utf8 +X<foldEQ_utf8> -Return true if the strings s1 and s2 differ case-insensitively, false -if not (if they are equal case-insensitively). If u1 is true, the -string s1 is assumed to be in UTF-8-encoded Unicode. If u2 is true, -the string s2 is assumed to be in UTF-8-encoded Unicode. If u1 or u2 -are false, the respective string is assumed to be in native 8-bit -encoding. +Returns true if the leading portions of the strings s1 and 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 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 +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 +get as far as its goal (and in fact is asserted against). Correspondingly for +pe2 with respect to s2. -If the pe1 and pe2 are non-NULL, the scanning pointers will be copied -in there (they will point at the beginning of the I<next> character). -If the pointers behind pe1 or pe2 are non-NULL, they are the end -pointers beyond which scanning will not continue under any -circumstances. If the byte lengths l1 and l2 are non-zero, s1+l1 and -s2+l2 will be used as goal end pointers that will also stop the scan, -and which qualify towards defining a successful match: all the scans -that define an explicit length must reach their goal pointers for -a match to succeed). +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 +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. 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). - I32 ibcmp_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 @@ -7262,8 +9468,12 @@ Found in file utf8.c =item is_ascii_string X<is_ascii_string> -Returns true if first C<len> bytes of the given string are ASCII (i.e. none -of them even raise the question of UTF-8-ness). +Returns true if the first C<len> bytes of the given string 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(). @@ -7289,9 +9499,10 @@ Found in file utf8.c X<is_utf8_string> Returns true if first C<len> bytes of the given string form a valid -UTF-8 string, false otherwise. 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. +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. See also is_ascii_string(), is_utf8_string_loclen(), and is_utf8_string_loc(). @@ -7415,7 +9626,7 @@ of the result. The "swashp" is a pointer to the swash to use. -Both the special and normal mappings are stored lib/unicore/To/Foo.pl, +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, but not always, a multicharacter mapping), is tried first. @@ -7499,14 +9710,12 @@ Found in file utf8.c =item utf8n_to_uvchr X<utf8n_to_uvchr> -flags - -Returns the native character value of the first character in the string +Returns the native character value 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. -Allows length and flags to be passed to low level routine. +length and flags are the same as utf8n_to_uvuni(). UV utf8n_to_uvchr(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags) @@ -7517,20 +9726,62 @@ Found in file utf8.c X<utf8n_to_uvuni> Bottom level UTF-8 decode routine. -Returns the Unicode code point value of the first character in the string C<s> -which is assumed to be in UTF-8 encoding and no longer than C<curlen>; -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, the behaviour -is dependent on the value of C<flags>: if it contains UTF8_CHECK_ONLY, -it is assumed that the caller will raise a warning, and this function -will silently just set C<retlen> to C<-1> and return zero. If the -C<flags> does not contain UTF8_CHECK_ONLY, warnings about -malformations will be given, C<retlen> will be set to the expected -length of the UTF-8 character in bytes, and zero will be returned. - -The C<flags> can also contain various flags to allow deviations from -the strict UTF-8 encoding (see F<utf8.h>). +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. + +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. + +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 +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. + +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 +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. +By default these are considered regular code points, but certain situations +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 +maximum) can be set to disallow these categories individually. + +The flags UTF8_WARN_ILLEGAL_INTERCHANGE, UTF8_WARN_SURROGATE, +UTF8_WARN_NONCHAR, and UTF8_WARN_SUPER will cause warning messages to be raised +for their respective categories, but otherwise the code points are considered +valid (not malformations). To get a category to both be treated as a +malformation and raise a warning, specify both the WARN and DISALLOW flags. +(But note that warnings are not raised if lexically disabled nor if +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. + +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. @@ -7601,7 +9852,7 @@ Found in file utf8.c =item utf8_to_uvchr X<utf8_to_uvchr> -Returns the native character value of the first character in the string C<s> +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. @@ -7634,7 +9885,7 @@ Found in file utf8.c =item uvchr_to_utf8 X<uvchr_to_utf8> -Adds the UTF-8 representation of the Native codepoint C<uv> to the end +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 bytes available. The return value is the pointer to the byte after the end of the new character. In other words, @@ -7653,8 +9904,8 @@ Found in file utf8.c =item uvuni_to_utf8_flags X<uvuni_to_utf8_flags> -Adds the UTF-8 representation of the Unicode codepoint C<uv> to the end -of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free +Adds the UTF-8 representation of the code point C<uv> to the end +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, @@ -7668,10 +9919,31 @@ or, in most cases, d = uvuni_to_utf8_flags(d, uv, 0); -is the recommended Unicode-aware way of saying +This is the recommended Unicode-aware way of saying *(d++) = uv; +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. +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. +If both flags are set, the function will both warn and return NULL. + +The UNICODE_WARN_NONCHAR and UNICODE_DISALLOW_NONCHAR flags correspondingly +affect how the function handles a Unicode non-character. And, likewise for the +UNICODE_WARN_SUPER and UNICODE_DISALLOW_SUPER flags, and code points that are +above the Unicode maximum of 0x10FFFF. Code points above 0x7FFF_FFFF (which are +even less portable) can be warned and/or disallowed even if other above-Unicode +code points are accepted by the UNICODE_WARN_FE_FF and UNICODE_DISALLOW_FE_FF +flags. + +And finally, the flag UNICODE_WARN_ILLEGAL_INTERCHANGE selects all four of the +above WARN flags; and UNICODE_DISALLOW_ILLEGAL_INTERCHANGE selects all four +DISALLOW flags. + + U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags) =for hackers @@ -7743,8 +10015,9 @@ Found in file XSUB.h =item dUNDERBAR X<dUNDERBAR> -Sets up the C<padoff_du> variable for an XSUB that wishes to use -C<UNDERBAR>. +Sets up any variable needed by the C<UNDERBAR> macro. It used to define +C<padoff_du>, but it is currently a noop. However, it is strongly advised +to still use it for ensuring past and future compatibility. dUNDERBAR; @@ -7857,6 +10130,17 @@ C<xsubpp>. =for hackers Found in file XSUB.h +=item XS_APIVERSION_BOOTCHECK +X<XS_APIVERSION_BOOTCHECK> + +Macro to verify that the perl api version an XS module has been compiled against +matches the api version of the perl interpreter it's being loaded into. + + XS_APIVERSION_BOOTCHECK; + +=for hackers +Found in file XSUB.h + =item XS_VERSION X<XS_VERSION> @@ -7888,19 +10172,132 @@ Found in file XSUB.h =item croak X<croak> -This is the XSUB-writer's interface to Perl's C<die> function. -Normally call this function the same way you call the C C<printf> -function. Calling C<croak> returns control directly to Perl, -sidestepping the normal C order of execution. See C<warn>. +This is an XS interface to Perl's C<die> function. + +Take a sprintf-style format pattern and argument list. These are used to +generate a string message. If the message does not end with a newline, +then it will be extended with some indication of the current location +in the code, as described for L</mess_sv>. + +The error message will be used as an exception, by default +returning control to the nearest enclosing C<eval>, but subject to +modification by a C<$SIG{__DIE__}> handler. In any case, the C<croak> +function never returns normally. + +For historical reasons, if C<pat> is null then the contents of C<ERRSV> +(C<$@>) will be used as an error message or object instead of building an +error message from arguments. If you want to throw a non-string object, +or build an error message in an SV yourself, it is preferable to use +the L</croak_sv> function, which does not involve clobbering C<ERRSV>. + + void croak(const char *pat, ...) + +=for hackers +Found in file util.c + +=item croak_no_modify +X<croak_no_modify> + +Exactly equivalent to C<Perl_croak(aTHX_ "%s", PL_no_modify)>, but generates +terser object code than using C<Perl_croak>. Less code used on exception code +paths reduces CPU cache pressure. + + void croak_no_modify() + +=for hackers +Found in file util.c + +=item croak_sv +X<croak_sv> + +This is an XS interface to Perl's C<die> function. + +C<baseex> is the error message or object. If it is a reference, it +will be used as-is. Otherwise it is used as a string, and if it does +not end with a newline then it will be extended with some indication of +the current location in the code, as described for L</mess_sv>. + +The error message or object will be used as an exception, by default +returning control to the nearest enclosing C<eval>, but subject to +modification by a C<$SIG{__DIE__}> handler. In any case, the C<croak_sv> +function never returns normally. + +To die with a simple string message, the L</croak> function may be +more convenient. + + void croak_sv(SV *baseex) -If you want to throw an exception object, assign the object to -C<$@> and then pass C<NULL> to croak(): +=for hackers +Found in file util.c + +=item die +X<die> - errsv = get_sv("@", GV_ADD); - sv_setsv(errsv, exception_object); - croak(NULL); +Behaves the same as L</croak>, except for the return type. +It should be used only where the C<OP *> return type is required. +The function never actually returns. - void croak(const char* pat, ...) + OP * die(const char *pat, ...) + +=for hackers +Found in file util.c + +=item die_sv +X<die_sv> + +Behaves the same as L</croak_sv>, except for the return type. +It should be used only where the C<OP *> return type is required. +The function never actually returns. + + OP * die_sv(SV *baseex) + +=for hackers +Found in file util.c + +=item vcroak +X<vcroak> + +This is an XS interface to Perl's C<die> function. + +C<pat> and C<args> are a sprintf-style format pattern and encapsulated +argument list. These are used to generate a string message. If the +message does not end with a newline, then it will be extended with +some indication of the current location in the code, as described for +L</mess_sv>. + +The error message will be used as an exception, by default +returning control to the nearest enclosing C<eval>, but subject to +modification by a C<$SIG{__DIE__}> handler. In any case, the C<croak> +function never returns normally. + +For historical reasons, if C<pat> is null then the contents of C<ERRSV> +(C<$@>) will be used as an error message or object instead of building an +error message from arguments. If you want to throw a non-string object, +or build an error message in an SV yourself, it is preferable to use +the L</croak_sv> function, which does not involve clobbering C<ERRSV>. + + void vcroak(const char *pat, va_list *args) + +=for hackers +Found in file util.c + +=item vwarn +X<vwarn> + +This is an XS interface to Perl's C<warn> function. + +C<pat> and C<args> are a sprintf-style format pattern and encapsulated +argument list. These are used to generate a string message. If the +message does not end with a newline, then it will be extended with +some indication of the current location in the code, as described for +L</mess_sv>. + +The error message or object will by default be written to standard error, +but this is subject to modification by a C<$SIG{__WARN__}> handler. + +Unlike with L</vcroak>, C<pat> is not permitted to be null. + + void vwarn(const char *pat, va_list *args) =for hackers Found in file util.c @@ -7908,10 +10305,40 @@ Found in file util.c =item warn X<warn> -This is the XSUB-writer's interface to Perl's C<warn> function. Call this -function the same way you call the C C<printf> function. See C<croak>. +This is an XS interface to Perl's C<warn> function. + +Take a sprintf-style format pattern and argument list. These are used to +generate a string message. If the message does not end with a newline, +then it will be extended with some indication of the current location +in the code, as described for L</mess_sv>. + +The error message or object will by default be written to standard error, +but this is subject to modification by a C<$SIG{__WARN__}> handler. - void warn(const char* pat, ...) +Unlike with L</croak>, C<pat> is not permitted to be null. + + void warn(const char *pat, ...) + +=for hackers +Found in file util.c + +=item warn_sv +X<warn_sv> + +This is an XS interface to Perl's C<warn> function. + +C<baseex> is the error message or object. If it is a reference, it +will be used as-is. Otherwise it is used as a string, and if it does +not end with a newline then it will be extended with some indication of +the current location in the code, as described for L</mess_sv>. + +The error message or object will by default be written to standard error, +but this is subject to modification by a C<$SIG{__WARN__}> handler. + +To warn with a simple string message, the L</warn> function may be +more convenient. + + void warn_sv(SV *baseex) =for hackers Found in file util.c @@ -7921,7 +10348,13 @@ Found in file util.c =head1 Undocumented functions -These functions are currently undocumented: +The following functions have been flagged as part of the public API, +but are currently undocumented. Use them at your own risk, as the +interfaces are subject to change. + +If you use one of them, you may wish to consider creating and submitting +documentation for it. If your patch is accepted, this will indicate that +the interface is stable (unless it is explicitly marked otherwise). =over @@ -8006,9 +10439,18 @@ 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 amagic_call X<amagic_call> +=item amagic_deref_call +X<amagic_deref_call> + =item any_dup X<any_dup> @@ -8063,18 +10505,18 @@ X<ckwarn> =item ckwarn_d X<ckwarn_d> +=item clone_params_del +X<clone_params_del> + +=item clone_params_new +X<clone_params_new> + =item croak_nocontext X<croak_nocontext> =item csighandler X<csighandler> -=item custom_op_desc -X<custom_op_desc> - -=item custom_op_name -X<custom_op_name> - =item cx_dump X<cx_dump> @@ -8108,9 +10550,6 @@ X<delimcpy> =item despatch_signals X<despatch_signals> -=item die -X<die> - =item die_nocontext X<die_nocontext> @@ -8219,9 +10658,18 @@ 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> @@ -8381,12 +10829,6 @@ X<hv_riter_set> =item hv_store_flags X<hv_store_flags> -=item ibcmp -X<ibcmp> - -=item ibcmp_locale -X<ibcmp_locale> - =item init_global_struct X<init_global_struct> @@ -8540,6 +10982,12 @@ X<is_utf8_upper> =item is_utf8_xdigit X<is_utf8_xdigit> +=item is_utf8_xidcont +X<is_utf8_xidcont> + +=item is_utf8_xidfirst +X<is_utf8_xidfirst> + =item leave_scope X<leave_scope> @@ -8555,9 +11003,6 @@ X<malloc> =item markstack_grow X<markstack_grow> -=item mess -X<mess> - =item mess_nocontext X<mess_nocontext> @@ -8684,36 +11129,18 @@ X<newANONLIST> =item newANONSUB X<newANONSUB> -=item newASSIGNOP -X<newASSIGNOP> - =item newATTRSUB X<newATTRSUB> =item newAVREF X<newAVREF> -=item newBINOP -X<newBINOP> - -=item newCONDOP -X<newCONDOP> - =item newCVREF X<newCVREF> =item newFORM X<newFORM> -=item newFOROP -X<newFOROP> - -=item newGIVENOP -X<newGIVENOP> - -=item newGVOP -X<newGVOP> - =item newGVREF X<newGVREF> @@ -8729,72 +11156,24 @@ X<newHVhv> =item newIO X<newIO> -=item newLISTOP -X<newLISTOP> - -=item newLOGOP -X<newLOGOP> - -=item newLOOPEX -X<newLOOPEX> - -=item newLOOPOP -X<newLOOPOP> - =item newMYSUB X<newMYSUB> -=item newNULLLIST -X<newNULLLIST> - -=item newOP -X<newOP> - -=item newPADOP -X<newPADOP> - -=item newPMOP -X<newPMOP> - =item newPROG X<newPROG> -=item newPVOP -X<newPVOP> - -=item newRANGE -X<newRANGE> - =item newRV X<newRV> -=item newSLICEOP -X<newSLICEOP> - -=item newSTATEOP -X<newSTATEOP> - =item newSUB X<newSUB> -=item newSVOP -X<newSVOP> - =item newSVREF X<newSVREF> =item newSVpvf_nocontext X<newSVpvf_nocontext> -=item newUNOP -X<newUNOP> - -=item newWHENOP -X<newWHENOP> - -=item newWHILEOP -X<newWHILEOP> - =item newXS_flags X<newXS_flags> @@ -9023,6 +11402,9 @@ X<save_destructor> =item save_destructor_x X<save_destructor_x> +=item save_freeop +X<save_freeop> + =item save_freepv X<save_freepv> @@ -9050,6 +11432,9 @@ X<save_helem> =item save_helem_flags X<save_helem_flags> +=item save_hints +X<save_hints> + =item save_hptr X<save_hptr> @@ -9074,15 +11459,24 @@ X<save_mortalizesv> =item save_nogv X<save_nogv> +=item save_op +X<save_op> + =item save_padsv_and_mortalize X<save_padsv_and_mortalize> =item save_pptr X<save_pptr> +=item save_pushi32ptr +X<save_pushi32ptr> + =item save_pushptr X<save_pushptr> +=item save_pushptrptr +X<save_pushptrptr> + =item save_re_context X<save_re_context> @@ -9179,6 +11573,9 @@ X<sv_dump> =item sv_dup X<sv_dup> +=item sv_dup_inc +X<sv_dup_inc> + =item sv_peek X<sv_peek> @@ -9266,9 +11663,6 @@ X<uvchr_to_utf8_flags> =item uvuni_to_utf8 X<uvuni_to_utf8> -=item vcroak -X<vcroak> - =item vdeb X<vdeb> @@ -9278,15 +11672,9 @@ X<vform> =item vload_module X<vload_module> -=item vmess -X<vmess> - =item vnewSVpvf X<vnewSVpvf> -=item vwarn -X<vwarn> - =item vwarner X<vwarner> |