-*- buffer-read-only: t -*- !!!!!!! DO NOT EDIT THIS FILE !!!!!!! This file is built by autodoc.pl extracting documentation from the C source files. Any changes made here will be lost! =head1 NAME perlapi - autogenerated documentation for the perl public API =head1 DESCRIPTION X X X This file contains the documentation of the perl public API generated by F, specifically a listing of functions, macros, flags, and variables that may be used by extension writers. L is a list of functions which have yet to be documented. The interfaces of those are subject to change without notice. Anything not listed here is 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 prefix. Again, those not listed here are not to be used by extension writers, and can be changed or removed without notice; same with macros. Some macros are provided for compatibility with the older, unadorned names, but this support may be disabled in a future release. Perl was originally written to handle US-ASCII only (that is characters whose ordinal numbers are in the range 0 - 127). And documentation and comments may still use the term ASCII, when sometimes in fact the entire range from 0 - 255 is meant. Note that Perl can be compiled and run under either ASCII or EBCDIC (See L). Most of the documentation (and even comments in the code) ignore the EBCDIC possibility. For almost all purposes the differences are transparent. As an example, under EBCDIC, instead of UTF-8, UTF-EBCDIC is used to encode Unicode strings, and so whenever this documentation refers to C (and variants of that name, including in function names), it also (essentially transparently) means C. But the ordinals of characters differ between ASCII, EBCDIC, and the UTF- encodings, and a string encoded in UTF-EBCDIC may occupy more bytes than in UTF-8. The listing below is alphabetical, case insensitive. =head1 "Gimme" Values =over 8 =item GIMME X A backward-compatible version of C which can only return C or C; in a void context, it returns C. Deprecated. Use C instead. U32 GIMME =for hackers Found in file op.h =item GIMME_V X The XSUB-writer's equivalent to Perl's C. Returns C, C or C for void, scalar or list context, respectively. See L for a usage example. U32 GIMME_V =for hackers Found in file op.h =item G_ARRAY X Used to indicate list context. See C, C and L. =for hackers Found in file cop.h =item G_DISCARD X Indicates that arguments returned from a callback should be discarded. See L. =for hackers Found in file cop.h =item G_EVAL X Used to force a Perl C wrapper around a callback. See L. =for hackers Found in file cop.h =item G_NOARGS X Indicates that no arguments are being sent to a callback. See L. =for hackers Found in file cop.h =item G_SCALAR X Used to indicate scalar context. See C, C, and L. =for hackers Found in file cop.h =item G_VOID X Used to indicate void context. See C and L. =for hackers Found in file cop.h =back =head1 Array Manipulation Functions =over 8 =item AvFILL X Same as C. Deprecated, use C instead. int AvFILL(AV* av) =for hackers Found in file av.h =item av_clear X Frees the all the elements of an array, leaving it empty. The XS equivalent of C<@array = ()>. See also L. Note that it is possible that the actions of a destructor called directly or indirectly by freeing an element of the array could cause the reference count of the array itself to be reduced (e.g. by deleting an entry in the symbol table). So it is a possibility that the AV could have been freed (or even reallocated) on return from the call unless you hold a reference to it. void av_clear(AV *av) =for hackers Found in file av.c =item av_create_and_push X NOTE: this function is experimental and may change or be removed without notice. Push an SV onto the end of the array, creating the array if necessary. A small internal helper function to remove a commonly duplicated idiom. void av_create_and_push(AV **const avp, SV *const val) =for hackers Found in file av.c =item av_create_and_unshift_one X NOTE: this function is experimental and may change or be removed without notice. Unshifts an SV onto the beginning of the array, creating the array if necessary. A small internal helper function to remove a commonly duplicated idiom. SV** av_create_and_unshift_one(AV **const avp, SV *const val) =for hackers Found in file av.c =item av_delete X Deletes the element indexed by C from the array, makes the element mortal, and returns it. If C equals C, the element is freed and null is returned. Perl equivalent: C for the non-C version and a void-context C for the C version. SV* av_delete(AV *av, SSize_t key, I32 flags) =for hackers Found in file av.c =item av_exists X Returns true if the element indexed by C has been initialized. This relies on the fact that uninitialized array elements are set to NULL. Perl equivalent: C. bool av_exists(AV *av, SSize_t key) =for hackers Found in file av.c =item av_extend X Pre-extend an array. The C is the index to which the array should be extended. void av_extend(AV *av, SSize_t key) =for hackers Found in file av.c =item av_fetch X Returns the SV at the specified index in the array. The C is the 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. See L 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, SSize_t key, I32 lval) =for hackers Found in file av.c =item av_fill X Set the highest index in the array to the given number, equivalent to Perl's C<$#array = $fill;>. The number of elements in the array will be C after av_fill() returns. If the array was previously shorter, then the additional elements appended are set to NULL. If the array was longer, then the excess elements are freed. C is the same as C. void av_fill(AV *av, SSize_t fill) =for hackers Found in file av.c =item av_len X Same as L. Note that, unlike what the name implies, it returns the highest index in the array, so to get the size of the array you need to use S>. This is unlike L, which returns what you would expect. SSize_t av_len(AV *av) =for hackers Found in file av.c =item av_make X 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 AV* av_make(SSize_t size, SV **strp) =for hackers Found in file av.c =item av_pop X Removes one SV from the end of the array, reducing its size by one and returning the SV (transferring control of one reference count) to the caller. Returns C<&PL_sv_undef> if the array is empty. Perl equivalent: C SV* av_pop(AV *av) =for hackers Found in file av.c =item av_push X Pushes an SV onto the end of the array. The array will grow automatically to accommodate the addition. This takes ownership of one reference count. Perl equivalent: C. void av_push(AV *av, SV *val) =for hackers Found in file av.c =item av_shift X Removes one SV from the start of the array, reducing its size by one and returning the SV (transferring control of one reference count) to the caller. Returns C<&PL_sv_undef> if the array is empty. Perl equivalent: C SV* av_shift(AV *av) =for hackers Found in file av.c =item av_store X Stores an SV in an array. The array index is specified as C. The return value will be NULL if the operation failed or if the value did not need to be actually stored within the array (as in the case of tied arrays). Otherwise, it can be dereferenced to get the C that was stored there (= C)). Note that the caller is responsible for suitably incrementing the reference count of C before the call, and decrementing it if the function returned NULL. Approximate Perl equivalent: C<$myarray[$key] = $val;>. See L for more information on how to use this function on tied arrays. SV** av_store(AV *av, SSize_t key, SV *val) =for hackers Found in file av.c =item av_tindex X Same as C. int av_tindex(AV* av) =for hackers Found in file av.h =item av_top_index X Returns the highest index in the array. The number of elements in the array is C. Returns -1 if the array is empty. The Perl equivalent for this is C<$#myarray>. (A slightly shorter form is C.) SSize_t av_top_index(AV *av) =for hackers Found in file av.c =item av_undef X Undefines the array. The XS equivalent of C. As well as freeing all the elements of the array (like C), this also frees the memory used by the av to store its list of scalars. See L for a note about the array possibly being invalid on return. void av_undef(AV *av) =for hackers Found in file av.c =item av_unshift X Unshift the given number of C values onto the beginning of the array. The array will grow automatically to accommodate the addition. You must then use C to assign values to these new elements. Perl equivalent: C void av_unshift(AV *av, SSize_t num) =for hackers Found in file av.c =item get_av X Returns the AV of the specified Perl global or package array with the given name (so it won't work on lexical variables). C are passed to C. If C is set and the Perl variable does not exist then it will be created. If C is zero and the variable does not exist then NULL is returned. Perl equivalent: C<@{"$name"}>. NOTE: the perl_ form of this function is deprecated. AV* get_av(const char *name, I32 flags) =for hackers Found in file perl.c =item newAV X Creates a new AV. The reference count is set to 1. Perl equivalent: C. AV* newAV() =for hackers Found in file av.h =item sortsv X Sort an array. Here is an example: sortsv(AvARRAY(av), av_top_index(av)+1, Perl_sv_cmp_locale); Currently this always uses mergesort. See sortsv_flags for a more flexible routine. void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp) =for hackers Found in file pp_sort.c =item sortsv_flags X Sort an array, with various options. void sortsv_flags(SV** array, size_t num_elts, SVCOMPARE_t cmp, U32 flags) =for hackers Found in file pp_sort.c =back =head1 C variables and internal functions =over 8 =item ax X Variable which is setup by C to indicate the stack base offset, used by the C, C and C macros. The C macro must be called prior to setup the C variable. I32 ax =for hackers Found in file XSUB.h =item CLASS X Variable which is setup by C to indicate the class name for a C++ XS constructor. This is always a C. See C. char* CLASS =for hackers Found in file XSUB.h =item dAX X Sets up the C variable. This is usually handled automatically by C by calling C. dAX; =for hackers Found in file XSUB.h =item dAXMARK X Sets up the C variable and stack marker variable C. This is usually handled automatically by C by calling C. dAXMARK; =for hackers Found in file XSUB.h =item dITEMS X Sets up the C variable. This is usually handled automatically by C by calling C. dITEMS; =for hackers Found in file XSUB.h =item dUNDERBAR X Sets up any variable needed by the C macro. It used to define C, but it is currently a noop. However, it is strongly advised to still use it for ensuring past and future compatibility. dUNDERBAR; =for hackers Found in file XSUB.h =item dXSARGS X Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. Sets up the C and C variables by calling C and C. This is usually handled automatically by C. dXSARGS; =for hackers Found in file XSUB.h =item dXSI32 X Sets up the C variable for an XSUB which has aliases. This is usually handled automatically by C. dXSI32; =for hackers Found in file XSUB.h =item items X Variable which is setup by C to indicate the number of items on the stack. See L. I32 items =for hackers Found in file XSUB.h =item ix X Variable which is setup by C to indicate which of an XSUB's aliases was used to invoke it. See L. I32 ix =for hackers Found in file XSUB.h =item RETVAL X Variable which is setup by C to hold the return value for an XSUB. This is always the proper type for the XSUB. See L. (whatever) RETVAL =for hackers Found in file XSUB.h =item ST X Used to access elements on the XSUB's stack. SV* ST(int ix) =for hackers Found in file XSUB.h =item THIS X Variable which is setup by C to designate the object in a C++ XSUB. This is always the proper type for the C++ object. See C and L. (whatever) THIS =for hackers Found in file XSUB.h =item UNDERBAR X The SV* corresponding to the $_ variable. Works even if there is a lexical $_ in scope. =for hackers Found in file XSUB.h =item XS X Macro to declare an XSUB and its C parameter list. This is handled by C. It is the same as using the more explicit XS_EXTERNAL macro. =for hackers Found in file XSUB.h =item XS_EXTERNAL X Macro to declare an XSUB and its C parameter list explicitly exporting the symbols. =for hackers Found in file XSUB.h =item XS_INTERNAL X Macro to declare an XSUB and its C parameter list without exporting the symbols. This is handled by C and generally preferable over exporting the XSUB symbols unnecessarily. =for hackers Found in file XSUB.h =back =head1 Callback Functions =over 8 =item call_argv X Performs a callback to the specified named and package-scoped Perl subroutine with C (a NULL-terminated array of strings) as arguments. See L. Approximate Perl equivalent: C<&{"$sub_name"}(@$argv)>. NOTE: the perl_ form of this function is deprecated. I32 call_argv(const char* sub_name, I32 flags, char** argv) =for hackers Found in file perl.c =item call_method X Performs a callback to the specified Perl method. The blessed object must be on the stack. See L. NOTE: the perl_ form of this function is deprecated. I32 call_method(const char* methname, I32 flags) =for hackers Found in file perl.c =item call_pv X Performs a callback to the specified Perl sub. See L. NOTE: the perl_ form of this function is deprecated. I32 call_pv(const char* sub_name, I32 flags) =for hackers Found in file perl.c =item call_sv X Performs a callback to the Perl sub specified by the SV. If neither the C or C flag is supplied, the SV may be any of a CV, a GV, a reference to a CV, a reference to a GV or C will be used as the name of the sub to call. If the C flag is supplied, the SV may be a reference to a CV or C will be used as the name of the method to call. If the C flag is supplied, C will be used as the name of the method to call. Some other values are treated specially for internal use and should not be depended on. See L. NOTE: the perl_ form of this function is deprecated. I32 call_sv(SV* sv, VOL I32 flags) =for hackers Found in file perl.c =item ENTER X Opening bracket on a callback. See C and L. ENTER; =for hackers Found in file scope.h =item eval_pv X Tells Perl to C the given string in scalar context and return an SV* result. NOTE: the perl_ form of this function is deprecated. SV* eval_pv(const char* p, I32 croak_on_error) =for hackers Found in file perl.c =item eval_sv X Tells Perl to C the string in the SV. It supports the same flags as C, with the obvious exception of G_EVAL. See L. NOTE: the perl_ form of this function is deprecated. I32 eval_sv(SV* sv, I32 flags) =for hackers Found in file perl.c =item FREETMPS X Closing bracket for temporaries on a callback. See C and L. FREETMPS; =for hackers Found in file scope.h =item LEAVE X Closing bracket on a callback. See C and L. LEAVE; =for hackers Found in file scope.h =item SAVETMPS X Opening bracket for temporaries on a callback. See C and L. SAVETMPS; =for hackers Found in file scope.h =back =head1 Character case changing =over 8 =item toFOLD X Converts the specified character to foldcase. If the input is anything but an ASCII uppercase character, that input character itself is returned. Variant C is equivalent. (There is no equivalent C for the full Latin1 range, as the full generality of L is needed there.) U8 toFOLD(U8 ch) =for hackers Found in file handy.h =item toFOLD_uni X Converts the Unicode code point C to its foldcase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the foldcase version may be longer than the original character. The first code point of the foldcased version is returned (but note, as explained just above, that there may be more.) UV toFOLD_uni(UV cp, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toFOLD_utf8 X Converts the UTF-8 encoded character at C

to its foldcase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the foldcase version may be longer than the original character. The first code point of the foldcased version is returned (but note, as explained just above, that there may be more.) The input character at C

is assumed to be well-formed. UV toFOLD_utf8(U8* p, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toLOWER X Converts the specified character to lowercase. If the input is anything but an ASCII uppercase character, that input character itself is returned. Variant C is equivalent. U8 toLOWER(U8 ch) =for hackers Found in file handy.h =item toLOWER_L1 X Converts the specified Latin1 character to lowercase. The results are undefined if the input doesn't fit in a byte. U8 toLOWER_L1(U8 ch) =for hackers Found in file handy.h =item toLOWER_LC X Converts the specified character to lowercase using the current locale's rules, if possible; otherwise returns the input character itself. U8 toLOWER_LC(U8 ch) =for hackers Found in file handy.h =item toLOWER_uni X Converts the Unicode code point C to its lowercase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the lowercase version may be longer than the original character. The first code point of the lowercased version is returned (but note, as explained just above, that there may be more.) UV toLOWER_uni(UV cp, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toLOWER_utf8 X Converts the UTF-8 encoded character at C

to its lowercase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the lowercase version may be longer than the original character. The first code point of the lowercased version is returned (but note, as explained just above, that there may be more.) The input character at C

is assumed to be well-formed. UV toLOWER_utf8(U8* p, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toTITLE X Converts the specified character to titlecase. If the input is anything but an ASCII lowercase character, that input character itself is returned. Variant C is equivalent. (There is no C for the full Latin1 range, as the full generality of L is needed there. Titlecase is not a concept used in locale handling, so there is no functionality for that.) U8 toTITLE(U8 ch) =for hackers Found in file handy.h =item toTITLE_uni X Converts the Unicode code point C to its titlecase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the titlecase version may be longer than the original character. The first code point of the titlecased version is returned (but note, as explained just above, that there may be more.) UV toTITLE_uni(UV cp, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toTITLE_utf8 X Converts the UTF-8 encoded character at C

to its titlecase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the titlecase version may be longer than the original character. The first code point of the titlecased version is returned (but note, as explained just above, that there may be more.) The input character at C

is assumed to be well-formed. UV toTITLE_utf8(U8* p, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toUPPER X Converts the specified character to uppercase. If the input is anything but an ASCII lowercase character, that input character itself is returned. Variant C is equivalent. U8 toUPPER(U8 ch) =for hackers Found in file handy.h =item toUPPER_uni X Converts the Unicode code point C to its uppercase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the uppercase version may be longer than the original character. The first code point of the uppercased version is returned (but note, as explained just above, that there may be more.) UV toUPPER_uni(UV cp, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =item toUPPER_utf8 X Converts the UTF-8 encoded character at C

to its uppercase version, and stores that in UTF-8 in C, and its length in bytes in C. Note that the buffer pointed to by C needs to be at least C bytes since the uppercase version may be longer than the original character. The first code point of the uppercased version is returned (but note, as explained just above, that there may be more.) The input character at C

is assumed to be well-formed. UV toUPPER_utf8(U8* p, U8* s, STRLEN* lenp) =for hackers Found in file handy.h =back =head1 Character classification This section is about functions (really macros) that classify characters into types, such as punctuation versus alphabetic, etc. Most of these are analogous to regular expression character classes. (See L.) There are several variants for each class. (Not all macros have all variants; each item below lists the ones valid for it.) None are affected by C, and only the ones with C in the name are affected by the current locale. The base function, e.g., C, takes an octet (either a C or a C) as input and returns a boolean as to whether or not the character represented by that octet is (or on non-ASCII platforms, corresponds to) an ASCII character in the named class based on platform, Unicode, and Perl rules. If the input is a number that doesn't fit in an octet, FALSE is returned. Variant C (e.g., C) is identical to the base function with no suffix C<"_A">. Variant C imposes the Latin-1 (or EBCDIC equivlalent) 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 will return true when called with the code point 0xDF, which is a word character in both ASCII and EBCDIC (though it represents different characters in each). Variant C is like the C variant, but accepts any UV code point as input. If the code point is larger than 255, Unicode rules are used to determine if it is in the character class. For example, C returns TRUE, since 0x100 is LATIN CAPITAL LETTER A WITH MACRON in Unicode, and is a word character. Variant C is like C, but the input is a pointer to a (known to be well-formed) UTF-8 encoded string (C or C). The classification of just the first (possibly multi-byte) character in the string is tested. Variant C is like the C and C variants, but the result is based on the current locale, which is what C in the name stands for. If Perl can determine that the current locale is a UTF-8 locale, it uses the published Unicode rules; otherwise, it uses the C library function that gives the named classification. For example, C when not in a UTF-8 locale returns the result of calling C. FALSE is always returned if the input won't fit into an octet. On some platforms where the C library function is known to be defective, Perl changes its result to follow the POSIX standard's rules. Variant C is like C, but is defined on any UV. It returns the same as C for input code points less than 256, and returns the hard-coded, not-affected-by-locale, Unicode results for larger ones. Variant C is like C, but the input is a pointer to a (known to be well-formed) UTF-8 encoded string (C or C). The classification of just the first (possibly multi-byte) character in the string is tested. =over 8 =item isALPHA X Returns a boolean indicating whether the specified character is an alphabetic character, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isALPHA(char ch) =for hackers Found in file handy.h =item isALPHANUMERIC X Returns a boolean indicating whether the specified character is a either an alphabetic character or decimal digit, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isALPHANUMERIC(char ch) =for hackers Found in file handy.h =item isASCII X Returns a boolean indicating whether the specified character is one of the 128 characters in the ASCII character set, analogous to C. On non-ASCII platforms, it returns TRUE iff this character corresponds to an ASCII character. Variants C and C are identical to C. See the L for an explanation of variants C, C, C, C, and C. Note, however, that some platforms do not have the C library routine C. In these cases, the variants whose names contain C are the same as the corresponding ones without. Also note, that because all ASCII characters are UTF-8 invariant (meaning they have the exact same representation (always a single byte) whether encoded in UTF-8 or not), C will give the correct results when called with any byte in any string encoded or not in UTF-8. And similarly C will work properly on any string encoded or not in UTF-8. bool isASCII(char ch) =for hackers Found in file handy.h =item isBLANK X Returns a boolean indicating whether the specified character is a character considered to be a blank, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. Note, however, that some platforms do not have the C library routine C. In these cases, the variants whose names contain C are the same as the corresponding ones without. bool isBLANK(char ch) =for hackers Found in file handy.h =item isCNTRL X Returns a boolean indicating whether the specified character is a control character, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C On EBCDIC platforms, you almost always want to use the C variant. bool isCNTRL(char ch) =for hackers Found in file handy.h =item isDIGIT X Returns a boolean indicating whether the specified character is a digit, analogous to C. Variants C and C are identical to C. See the L for an explanation of variants C, C, C, C, and C. bool isDIGIT(char ch) =for hackers Found in file handy.h =item isGRAPH X Returns a boolean indicating whether the specified character is a graphic character, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isGRAPH(char ch) =for hackers Found in file handy.h =item isIDCONT X Returns a boolean indicating whether the specified character can be the second or succeeding character of an identifier. This is very close to, but not quite the same as the official Unicode property C. The difference is that this returns true only if the input character also matches L. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isIDCONT(char ch) =for hackers Found in file handy.h =item isIDFIRST X Returns a boolean indicating whether the specified character can be the first character of an identifier. This is very close to, but not quite the same as the official Unicode property C. The difference is that this returns true only if the input character also matches L. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isIDFIRST(char ch) =for hackers Found in file handy.h =item isLOWER X Returns a boolean indicating whether the specified character is a lowercase character, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isLOWER(char ch) =for hackers Found in file handy.h =item isOCTAL X Returns a boolean indicating whether the specified character is an octal digit, [0-7]. The only two variants are C and C; each is identical to C. bool isOCTAL(char ch) =for hackers Found in file handy.h =item isPRINT X Returns a boolean indicating whether the specified character is a printable character, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isPRINT(char ch) =for hackers Found in file handy.h =item isPSXSPC X (short for Posix Space) Starting in 5.18, this is identical in all its forms to the corresponding C macros. The locale forms of this macro are identical to their corresponding C forms in all Perl releases. In releases prior to 5.18, the non-locale forms differ from their C forms only in that the C forms don't match a Vertical Tab, and the C forms do. Otherwise they are identical. Thus this macro is analogous to what C matches in a regular expression. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isPSXSPC(char ch) =for hackers Found in file handy.h =item isPUNCT X Returns a boolean indicating whether the specified character is a punctuation character, analogous to C. Note that the definition of what is punctuation isn't as straightforward as one might desire. See L for details. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isPUNCT(char ch) =for hackers Found in file handy.h =item isSPACE X Returns a boolean indicating whether the specified character is a whitespace character. This is analogous to what C matches in a regular expression. Starting in Perl 5.18 this also matches what C does. Prior to 5.18, only the locale forms of this macro (the ones with C in their names) matched precisely what C does. In those releases, the only difference, in the non-locale variants, was that C did not match a vertical tab. (See L for a macro that matches a vertical tab in all releases.) See the L for an explanation of variants C, C, C, C, C, C, and C. bool isSPACE(char ch) =for hackers Found in file handy.h =item isUPPER X Returns a boolean indicating whether the specified character is an uppercase character, analogous to C. See the L for an explanation of variants C, C, C, C, C, C, and C. bool isUPPER(char ch) =for hackers Found in file handy.h =item isWORDCHAR X Returns a boolean indicating whether the specified character is a character that is a word character, analogous to what C and C match in a regular expression. A word character is an alphabetic character, a decimal digit, a connecting punctuation character (such as an underscore), or a "mark" character that attaches to one of those (like some sort of accent). C is a synonym provided for backward compatibility, even though a word character includes more than the standard C language meaning of alphanumeric. See the L for an explanation of variants C, C, C, and C. C, C, and C are also as described there, but additionally include the platform's native underscore. bool isWORDCHAR(char ch) =for hackers Found in file handy.h =item isXDIGIT X Returns a boolean indicating whether the specified character is a hexadecimal digit. In the ASCII range these are C<[0-9A-Fa-f]>. Variants C and C are identical to C. See the L for an explanation of variants C, C, C, C, and C. bool isXDIGIT(char ch) =for hackers Found in file handy.h =back =head1 Cloning an interpreter =over 8 =item perl_clone X Create and return a new interpreter by cloning the current one. perl_clone takes these flags as parameters: CLONEf_COPY_STACKS - is used to, well, copy the stacks also, without it we only clone the data and zero the stacks, with it we copy the stacks and the new perl interpreter is ready to run at the exact same point as the previous one. The pseudo-fork code uses COPY_STACKS while the threads->create doesn't. CLONEf_KEEP_PTR_TABLE - perl_clone keeps a ptr_table with the pointer of the old variable as a key and the new variable as a value, this allows it to check if something has been cloned and not clone it again but rather just use the value and increase the refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill the ptr_table using the function C, reason to keep it around is if you want to dup some of your own variable who are outside the graph perl scans, example of this code is in threads.xs create. CLONEf_CLONE_HOST - This is a win32 thing, it is ignored on unix, it tells perls win32host code (which is c++) to clone itself, this is needed on win32 if you want to run two threads at the same time, if you just want to do some stuff in a separate perl interpreter and then throw it away and return to the original one, you don't need to do anything. PerlInterpreter* perl_clone( PerlInterpreter *proto_perl, UV flags ) =for hackers Found in file sv.c =back =head1 Compile-time scope hooks =over 8 =item BhkDISABLE X NOTE: this function is experimental and may change or be removed without notice. Temporarily disable an entry in this BHK structure, by clearing the appropriate flag. I is a preprocessor token indicating which entry to disable. void BhkDISABLE(BHK *hk, which) =for hackers Found in file op.h =item BhkENABLE X NOTE: this function is experimental and may change or be removed without notice. Re-enable an entry in this BHK structure, by setting the appropriate flag. I is a preprocessor token indicating which entry to enable. This will assert (under -DDEBUGGING) if the entry doesn't contain a valid pointer. void BhkENABLE(BHK *hk, which) =for hackers Found in file op.h =item BhkENTRY_set X NOTE: this function is experimental and may change or be removed without notice. Set an entry in the BHK structure, and set the flags to indicate it is valid. I is a preprocessing token indicating which entry to set. The type of I depends on the entry. void BhkENTRY_set(BHK *hk, which, void *ptr) =for hackers Found in file op.h =item blockhook_register X NOTE: this function is experimental and may change or be removed without notice. Register a set of hooks to be called when the Perl lexical scope changes at compile time. See L. 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 NOTE: this function is experimental and may change or be removed without notice. Generates and returns a standard Perl hash representing the full set of key/value pairs in the cop hints hash I. I is currently unused and must be zero. HV * cophh_2hv(const COPHH *cophh, U32 flags) =for hackers Found in file cop.h =item cophh_copy X NOTE: this function is experimental and may change or be removed without notice. Make and return a complete copy of the cop hints hash I. COPHH * cophh_copy(COPHH *cophh) =for hackers Found in file cop.h =item cophh_delete_pv X NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a nul-terminated string instead of a string/length pair. 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 NOTE: this function is experimental and may change or be removed without notice. Delete a key and its associated value from the cop hints hash I, 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 if you need both hashes. The key is specified by I and I. If I has the C bit set, the key octets are interpreted as UTF-8, otherwise they are interpreted as Latin-1. I is a precomputed hash of the key string, or zero if it has not been precomputed. 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 NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a literal string instead of a string/length pair, and no precomputed hash. COPHH * cophh_delete_pvs(const COPHH *cophh, const char *key, U32 flags) =for hackers Found in file cop.h =item cophh_delete_sv X NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a Perl scalar instead of a string/length pair. 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 NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a nul-terminated string instead of a string/length pair. 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 NOTE: this function is experimental and may change or be removed without notice. Look up the entry in the cop hints hash I with the key specified by I and I. If I has the C bit set, the key octets are interpreted as UTF-8, otherwise they are interpreted as Latin-1. I 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 * 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 NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a literal string instead of a string/length pair, and no precomputed hash. SV * cophh_fetch_pvs(const COPHH *cophh, const char *key, U32 flags) =for hackers Found in file cop.h =item cophh_fetch_sv X NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a Perl scalar instead of a string/length pair. SV * cophh_fetch_sv(const COPHH *cophh, SV *key, U32 hash, U32 flags) =for hackers Found in file cop.h =item cophh_free X NOTE: this function is experimental and may change or be removed without notice. Discard the cop hints hash I, freeing all resources associated with it. void cophh_free(COPHH *cophh) =for hackers Found in file cop.h =item cophh_new_empty X NOTE: this function is experimental and may change or be removed without notice. Generate and return a fresh cop hints hash containing no entries. COPHH * cophh_new_empty() =for hackers Found in file cop.h =item cophh_store_pv X NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a nul-terminated string instead of a string/length pair. 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 NOTE: this function is experimental and may change or be removed without notice. Stores a value, associated with a key, in the cop hints hash I, 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 if you need both hashes. The key is specified by I and I. If I has the C bit set, the key octets are interpreted as UTF-8, otherwise they are interpreted as Latin-1. I is a precomputed hash of the key string, or zero if it has not been precomputed. I is the scalar value to store for this key. I 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. 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 NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a literal string instead of a string/length pair, and no precomputed hash. 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 NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a Perl scalar instead of a string/length pair. 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 Generates and returns a standard Perl hash representing the full set of hint entries in the cop I. I 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 Like L, 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 Look up the hint entry in the cop I with the key specified by I and I. If I has the C bit set, the key octets are interpreted as UTF-8, otherwise they are interpreted as Latin-1. I 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 Like L, 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 Like L, 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 Register a custom op. See L. 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 Return the XOP structure for a given custom op. This macro should be considered internal to OP_NAME and the other access macros: use them instead. This macro does call a function. Prior to 5.19.6, this was implemented as a function. 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 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 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 Return a member of the XOP structure. I 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. This macro evaluates its arguments more than once. If you are using C to retreive a C from a C, use the more efficient L instead. XopENTRY(XOP *xop, which) =for hackers Found in file op.h =item XopENTRYCUSTOM X Exactly like C but more efficient. The I parameter is identical to L. XopENTRYCUSTOM(const OP *o, which) =for hackers Found in file op.h =item XopENTRY_set X Set a member of the XOP structure. I is a cpp token indicating which entry to set. See L for details about the available members and how they are used. This macro evaluates its argument more than once. void XopENTRY_set(XOP *xop, which, value) =for hackers Found in file op.h =item XopFLAGS X Return the XOP's flags. U32 XopFLAGS(XOP *xop) =for hackers Found in file op.h =back =head1 CV Manipulation Functions This section documents functions to manipulate CVs which are code-values, or subroutines. For more information, see L. =over 8 =item caller_cx X The XSUB-writer's equivalent of L. The returned C structure can be interrogated to find all the information returned to Perl by C. Note that XSUBs don't get a stack frame, so C 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, the return value will be the frame for the call to C, since that has the correct line number/etc. for the call site. If I is non-C, 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 CvSTASH X Returns the stash of the CV. A stash is the symbol table hash, containing the package-scoped variables in the package where the subroutine was defined. For more information, see L. This also has a special use with XS AUTOLOAD subs. See L. HV* CvSTASH(CV* cv) =for hackers Found in file cv.h =item find_runcv X Locate the CV corresponding to the currently executing sub or eval. If db_seqp is non_null, skip CVs that are in the DB package and populate *db_seqp with the cop sequence number at the point that the DB:: code was entered. (This allows debuggers to eval in the scope of the breakpoint rather than in the scope of the debugger itself.) CV* find_runcv(U32 *db_seqp) =for hackers Found in file pp_ctl.c =item get_cv X Uses C to get the length of C, then calls C. NOTE: the perl_ form of this function is deprecated. CV* get_cv(const char* name, I32 flags) =for hackers Found in file perl.c =item get_cvn_flags X Returns the CV of the specified Perl subroutine. C are passed to C. If C is set and the Perl subroutine does not exist then it will be declared (which has the same effect as saying C). If C is not set and the subroutine does not exist then NULL is returned. NOTE: the perl_ form of this function is deprecated. CV* get_cvn_flags(const char* name, STRLEN len, I32 flags) =for hackers Found in file perl.c =back =head1 Debugging Utilities =over 8 =item dump_all X Dumps the entire optree of the current program starting at C to C. Also dumps the optrees for all visible subroutines in C. void dump_all() =for hackers Found in file dump.c =item dump_packsubs X Dumps the optrees for all visible subroutines in C. void dump_packsubs(const HV* stash) =for hackers Found in file dump.c =item op_dump X Dumps the optree starting at OP C to C. void op_dump(const OP *o) =for hackers Found in file dump.c =item sv_dump X Dumps the contents of an SV to the C filehandle. For an example of its output, see L. void sv_dump(SV* sv) =for hackers Found in file dump.c =back =head1 Display and Dump functions =over 8 =item pv_display X Similar to pv_escape(dsv,pv,cur,pvlim,PERL_PV_ESCAPE_QUOTE); except that an additional "\0" will be appended to the string when len > cur and pv[cur] is "\0". Note that the final string may be up to 7 chars longer than pvlim. char* pv_display(SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) =for hackers Found in file dump.c =item pv_escape X Escapes at most the first "count" chars of pv and puts the results into dsv such that the size of the escaped string will not exceed "max" chars and will not contain any incomplete escape sequences. The number of bytes escaped will be returned in the STRLEN *escaped parameter if it is not null. When the dsv parameter is null no escaping actually occurs, but the number of bytes that would be escaped were it not null will be calculated. If flags contains PERL_PV_ESCAPE_QUOTE then any double quotes in the string will also be escaped. Normally the SV will be cleared before the escaped string is prepared, but when PERL_PV_ESCAPE_NOCLEAR is set this will not occur. If PERL_PV_ESCAPE_UNI is set then the input string is treated as UTF-8 if PERL_PV_ESCAPE_UNI_DETECT is set then the input string is scanned using C to determine if it is UTF-8. If PERL_PV_ESCAPE_ALL is set then all input chars will be output using C<\x01F1> style escapes, otherwise if PERL_PV_ESCAPE_NONASCII is set, only non-ASCII chars 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, 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 sequences, whereas '%' is not a particularly common character in patterns. Returns a pointer to the escaped text as held by dsv. char* pv_escape(SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) =for hackers Found in file dump.c =item pv_pretty X Converts a string into something presentable, handling escaping via pv_escape() and supporting quoting and ellipses. 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 Found in file dump.c =back =head1 Embedding Functions =over 8 =item cv_clone X Clone a CV, making a lexical closure. I supplies the prototype of the function: its code, pad structure, and other attributes. The prototype is combined with a capture of outer lexicals to which the code refers, which are taken from the currently-executing instance of the immediately surrounding code. CV * cv_clone(CV *proto) =for hackers Found in file pad.c =item cv_name X Returns an SV containing the name of the CV, mainly for use in error reporting. The CV may actually be a GV instead, in which case the returned SV holds the GV's name. Anything other than a GV or CV is treated as a string already holding the sub name, but this could change in the future. An SV may be passed as a second argument. If so, the name will be assigned to it and it will be returned. Otherwise the returned SV will be a new mortal. If the I include CV_NAME_NOTQUAL, then the package name will not be included. If the first argument is neither a CV nor a GV, this flag is ignored (subject to change). SV * cv_name(CV *cv, SV *sv, U32 flags) =for hackers Found in file pad.c =item cv_undef X Clear out all the active components of a CV. This can happen either by an explicit C, or by the reference count going to zero. In the former case, we keep the CvOUTSIDE pointer, so that any anonymous children can still follow the full lexical scope chain. void cv_undef(CV* cv) =for hackers Found in file pad.c =item find_rundefsv X Find and return the variable that is named C<$_> in the lexical scope of the currently-executing function. This may be a lexical C<$_>, or will otherwise be the global one. SV * find_rundefsv() =for hackers Found in file pad.c =item find_rundefsvoffset X DEPRECATED! It is planned to remove this function from a future release of Perl. Do not use it for new code; remove it from existing code. Find the position of the lexical C<$_> in the pad of the currently-executing function. Returns the offset in the current pad, or C if there is no lexical C<$_> in scope (in which case the global one should be used instead). L is likely to be more convenient. NOTE: the perl_ form of this function is deprecated. PADOFFSET find_rundefsvoffset() =for hackers Found in file pad.c =item intro_my X "Introduce" C variables to visible status. This is called during parsing at the end of each statement to make lexical variables visible to subsequent statements. U32 intro_my() =for hackers Found in file pad.c =item load_module X Loads the module whose name is pointed to by the string part of name. Note that the actual module name, not its filename, should be given. Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS (or 0 for no flags). ver, if specified and not NULL, provides version semantics similar to C. The optional trailing SV* arguments can be used to specify arguments to the module's import() method, similar to C. They must be terminated with a final NULL pointer. Note that this list can only be omitted when the PERL_LOADMOD_NOIMPORT flag has been used. Otherwise at least a single NULL pointer to designate the default import list is required. The reference count for each specified C parameter is decremented. void load_module(U32 flags, SV* name, SV* ver, ...) =for hackers Found in file op.c =item newPADNAMELIST X NOTE: this function is experimental and may change or be removed without notice. Creates a new pad name list. C is the highest index for which space is allocated. PADNAMELIST * newPADNAMELIST(size_t max) =for hackers Found in file pad.c =item newPADNAMEouter X NOTE: this function is experimental and may change or be removed without notice. Constructs and returns a new pad name. Only use this function for names that refer to outer lexicals. (See also L.) I is the outer pad name that this one mirrors. The returned pad name has the PADNAMEt_OUTER flag already set. PADNAME * newPADNAMEouter(PADNAME *outer) =for hackers Found in file pad.c =item newPADNAMEpvn X NOTE: this function is experimental and may change or be removed without notice. Constructs and returns a new pad name. I must be a UTF8 string. Do not use this for pad names that point to outer lexicals. See L. PADNAME * newPADNAMEpvn(const char *s, STRLEN len) =for hackers Found in file pad.c =item nothreadhook X Stub that provides thread hook for perl_destruct when there are no threads. int nothreadhook() =for hackers Found in file perl.c =item padnamelist_fetch X NOTE: this function is experimental and may change or be removed without notice. Fetches the pad name from the given index. PADNAME * padnamelist_fetch(PADNAMELIST *pnl, SSize_t key) =for hackers Found in file pad.c =item padnamelist_store X NOTE: this function is experimental and may change or be removed without notice. Stores the pad name (which may be null) at the given index, freeing any existing pad name in that slot. PADNAME ** padnamelist_store(PADNAMELIST *pnl, SSize_t key, PADNAME *val) =for hackers Found in file pad.c =item pad_add_anon X Allocates a place in the currently-compiling pad (via L) for an anonymous function that is lexically scoped inside the currently-compiling function. The function I is linked into the pad, and its C link to the outer scope is weakened to avoid a reference loop. One reference count is stolen, so you may need to do C. I should be an opcode indicating the type of operation that the pad entry is to support. This doesn't affect operational semantics, but is used for debugging. PADOFFSET pad_add_anon(CV *func, I32 optype) =for hackers Found in file pad.c =item pad_add_name_pv X Exactly like L, but takes a nul-terminated string instead of a string/length pair. PADOFFSET pad_add_name_pv(const char *name, U32 flags, HV *typestash, HV *ourstash) =for hackers Found in file pad.c =item pad_add_name_pvn X Allocates a place in the currently-compiling pad for a named lexical variable. Stores the name and other metadata in the name part of the pad, and makes preparations to manage the variable's lexical scoping. Returns the offset of the allocated pad slot. I/I specify the variable's name, including leading sigil. If I is non-null, the name is for a typed lexical, and this identifies the type. If I is non-null, it's a lexical reference to a package variable, and this identifies the package. The following flags can be OR'ed together: padadd_OUR redundantly specifies if it's a package var padadd_STATE variable will retain value persistently padadd_NO_DUP_CHECK skip check for lexical shadowing PADOFFSET pad_add_name_pvn(const char *namepv, STRLEN namelen, U32 flags, HV *typestash, HV *ourstash) =for hackers Found in file pad.c =item pad_add_name_sv X Exactly like L, but takes the name string in the form of an SV instead of a string/length pair. PADOFFSET pad_add_name_sv(SV *name, U32 flags, HV *typestash, HV *ourstash) =for hackers Found in file pad.c =item pad_alloc X NOTE: this function is experimental and may change or be removed without notice. Allocates a place in the currently-compiling pad, returning the offset of the allocated pad slot. No name is initially attached to the pad slot. I is a set of flags indicating the kind of pad entry required, which will be set in the value SV for the allocated pad entry: SVs_PADMY named lexical variable ("my", "our", "state") SVs_PADTMP unnamed temporary store SVf_READONLY constant shared between recursion levels C has been supported here only since perl 5.20. To work with earlier versions as well, use C. C does not cause the SV in the pad slot to be marked read-only, but simply tells C that it I be made read-only (by the caller), or at least should be treated as such. I should be an opcode indicating the type of operation that the pad entry is to support. This doesn't affect operational semantics, but is used for debugging. PADOFFSET pad_alloc(I32 optype, U32 tmptype) =for hackers Found in file pad.c =item pad_findmy_pv X Exactly like L, but takes a nul-terminated string instead of a string/length pair. PADOFFSET pad_findmy_pv(const char *name, U32 flags) =for hackers Found in file pad.c =item pad_findmy_pvn X Given the name of a lexical variable, find its position in the currently-compiling pad. I/I specify the variable's name, including leading sigil. I is reserved and must be zero. If it is not in the current pad but appears in the pad of any lexically enclosing scope, then a pseudo-entry for it is added in the current pad. Returns the offset in the current pad, or C if no such lexical is in scope. PADOFFSET pad_findmy_pvn(const char *namepv, STRLEN namelen, U32 flags) =for hackers Found in file pad.c =item pad_findmy_sv X Exactly like L, but takes the name string in the form of an SV instead of a string/length pair. PADOFFSET pad_findmy_sv(SV *name, U32 flags) =for hackers Found in file pad.c =item pad_setsv X Set the value at offset I in the current (compiling or executing) pad. Use the macro PAD_SETSV() rather than calling this function directly. void pad_setsv(PADOFFSET po, SV *sv) =for hackers Found in file pad.c =item pad_sv X Get the value at offset I in the current (compiling or executing) pad. Use macro PAD_SV instead of calling this function directly. SV * pad_sv(PADOFFSET po) =for hackers Found in file pad.c =item pad_tidy X NOTE: this function is experimental and may change or be removed without notice. Tidy up a pad at the end of compilation of the code to which it belongs. Jobs performed here are: remove most stuff from the pads of anonsub prototypes; give it a @_; mark temporaries as such. I indicates the kind of subroutine: padtidy_SUB ordinary subroutine padtidy_SUBCLONE prototype for lexical closure padtidy_FORMAT format void pad_tidy(padtidy_type type) =for hackers Found in file pad.c =item perl_alloc X Allocates a new Perl interpreter. See L. PerlInterpreter* perl_alloc() =for hackers Found in file perl.c =item perl_construct X Initializes a new Perl interpreter. See L. void perl_construct(PerlInterpreter *my_perl) =for hackers Found in file perl.c =item perl_destruct X Shuts down a Perl interpreter. See L. int perl_destruct(PerlInterpreter *my_perl) =for hackers Found in file perl.c =item perl_free X Releases a Perl interpreter. See L. void perl_free(PerlInterpreter *my_perl) =for hackers Found in file perl.c =item perl_parse X Tells a Perl interpreter to parse a Perl script. See L. int perl_parse(PerlInterpreter *my_perl, XSINIT_t xsinit, int argc, char** argv, char** env) =for hackers Found in file perl.c =item perl_run X Tells a Perl interpreter to run. See L. int perl_run(PerlInterpreter *my_perl) =for hackers Found in file perl.c =item require_pv X Tells Perl to C the file named by the string argument. It is analogous to the Perl code C. It's even implemented that way; consider using load_module instead. NOTE: the perl_ form of this function is deprecated. void require_pv(const char* pv) =for hackers Found in file perl.c =back =head1 Exception Handling (simple) Macros =over 8 =item dXCPT X Set up necessary local variables for exception handling. See L. dXCPT; =for hackers Found in file XSUB.h =item XCPT_CATCH X Introduces a catch block. See L. =for hackers Found in file XSUB.h =item XCPT_RETHROW X Rethrows a previously caught exception. See L. XCPT_RETHROW; =for hackers Found in file XSUB.h =item XCPT_TRY_END X Ends a try block. See L. =for hackers Found in file XSUB.h =item XCPT_TRY_START X Starts a try block. See L. =for hackers Found in file XSUB.h =back =head1 Global Variables These variables are global to an entire process. They are shared between all interpreters and all threads in a process. =over 8 =item PL_check X Array, indexed by opcode, of functions that will be called for the "check" phase of optree building during compilation of Perl code. For most (but not all) types of op, once the op has been initially built and populated with child ops it will be filtered through the check function referenced by the appropriate element of this array. The new op is passed in as the sole argument to the check function, and the check function returns the completed op. The check function may (as the name suggests) check the op for validity and signal errors. It may also initialise or modify parts of the ops, or perform more radical surgery such as adding or removing child ops, or even throw the op away and return a different op in its place. This array of function pointers is a convenient place to hook into the compilation process. An XS module can put its own custom check function in place of any of the standard ones, to influence the compilation of a particular type of op. However, a custom check function must never fully replace a standard check function (or even a custom check function from another module). A module modifying checking must instead B the preexisting check function. A custom check function must be selective about when to apply its custom behaviour. In the usual case where it decides not to do anything special with an op, it must chain the preexisting op function. Check functions are thus linked in a chain, with the core's base checker at the end. For thread safety, modules should not write directly to this array. Instead, use the function L. =for hackers Found in file perlvars.h =item PL_keyword_plugin X NOTE: this function is experimental and may change or be removed without notice. Function pointer, pointing at a function used to handle extended keywords. The function should be declared as int keyword_plugin_function(pTHX_ char *keyword_ptr, STRLEN keyword_len, OP **op_ptr) The function is called from the tokeniser, whenever a possible keyword is seen. C points at the word in the parser's input buffer, and C gives its length; it is not null-terminated. The function is expected to examine the word, and possibly other state such as L<%^H|perlvar/%^H>, to decide whether it wants to handle it as an extended keyword. If it does not, the function should return C, and the normal parser process will continue. If the function wants to handle the keyword, it first must parse anything following the keyword that is part of the syntax introduced by the keyword. See L for details. When a keyword is being handled, the plugin function must build a tree of C structures, representing the code that was parsed. The root of the tree must be stored in C<*op_ptr>. The function then returns a constant indicating the syntactic role of the construct that it has parsed: C if it is a complete statement, or C if it is an expression. Note that a statement construct cannot be used inside an expression (except via C and similar), and an expression is not a complete statement (it requires at least a terminating semicolon). When a keyword is handled, the plugin function may also have (compile-time) side effects. It may modify C<%^H>, define functions, and so on. Typically, if side effects are the main purpose of a handler, it does not wish to generate any ops to be included in the normal compilation. In this case it is still required to supply an op tree, but it suffices to generate a single null op. That's how the C<*PL_keyword_plugin> function needs to behave overall. Conventionally, however, one does not completely replace the existing handler function. Instead, take a copy of C before assigning your own function pointer to it. Your handler function should look for keywords that it is interested in and handle those. Where it is not interested, it should call the saved plugin function, passing on the arguments it received. Thus C actually points at a chain of handler functions, all of which have an opportunity to handle keywords, and only the last function in the chain (built into the Perl core) will normally return C. =for hackers Found in file perlvars.h =back =head1 GV Functions A GV is a structure which corresponds to to a Perl typeglob, ie *foo. It is a structure that holds a pointer to a scalar, an array, a hash etc, corresponding to $foo, @foo, %foo. GVs are usually found as values in stashes (symbol table hashes) where Perl stores its global variables. =over 8 =item GvAV X Return the AV from the GV. AV* GvAV(GV* gv) =for hackers Found in file gv.h =item GvCV X Return the CV from the GV. CV* GvCV(GV* gv) =for hackers Found in file gv.h =item GvHV X Return the HV from the GV. HV* GvHV(GV* gv) =for hackers Found in file gv.h =item GvSV X Return the SV from the GV. SV* GvSV(GV* gv) =for hackers Found in file gv.h =item gv_const_sv X If C is a typeglob whose subroutine entry is a constant sub eligible for inlining, or C is a placeholder reference that would be promoted to such a typeglob, then returns the value returned by the sub. Otherwise, returns NULL. SV* gv_const_sv(GV* gv) =for hackers Found in file gv.c =item gv_fetchmeth X Like L, but lacks a flags parameter. GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level) =for hackers Found in file gv.c =item gv_fetchmethod_autoload X Returns the glob which contains the subroutine to call to invoke the method on the C. In fact in the presence of autoloading this may be the glob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD is already setup. The third parameter of C determines whether AUTOLOAD lookup is performed if the given method is not present: non-zero means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD. Calling C is equivalent to calling C with a non-zero C parameter. These functions grant C<"SUPER"> token as a prefix of the method name. Note that if you want to keep the returned glob for a long time, you need to check for it being "AUTOLOAD", since at the later time the call may load a different subroutine due to $AUTOLOAD changing its value. Use the glob created as a side effect to do this. These functions have the same side-effects as C with C. The warning against passing the GV returned by C to C applies equally to these functions. GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload) =for hackers Found in file gv.c =item gv_fetchmeth_autoload X This is the old form of L, which has no flags parameter. GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level) =for hackers Found in file gv.c =item gv_fetchmeth_pv X Exactly like L, but takes a nul-terminated string instead of a string/length pair. GV* gv_fetchmeth_pv(HV* stash, const char* name, I32 level, U32 flags) =for hackers Found in file gv.c =item gv_fetchmeth_pvn X Returns the glob with the given C and a defined subroutine or C. The glob lives in the given C, or in the stashes accessible via @ISA and UNIVERSAL::. The argument C should be either 0 or -1. If C, as a side-effect creates a glob with the given C in the given C which in the case of success contains an alias for the subroutine, and sets up caching info for this glob. The only significant values for C are GV_SUPER and SVf_UTF8. GV_SUPER indicates that we want to look up the method in the superclasses of the C. The GV returned from C may be a method cache entry, which is not visible to Perl code. So when calling C, you should not use the GV directly; instead, you should use the method's CV, which can be obtained from the GV with the C macro. GV* gv_fetchmeth_pvn(HV* stash, const char* name, STRLEN len, I32 level, U32 flags) =for hackers Found in file gv.c =item gv_fetchmeth_pvn_autoload X Same as gv_fetchmeth_pvn(), but looks for autoloaded subroutines too. Returns a glob for the subroutine. For an autoloaded subroutine without a GV, will create a GV even if C. For an autoloaded subroutine without a stub, GvCV() of the result may be zero. Currently, the only significant value for C is SVf_UTF8. GV* gv_fetchmeth_pvn_autoload(HV* stash, const char* name, STRLEN len, I32 level, U32 flags) =for hackers Found in file gv.c =item gv_fetchmeth_pv_autoload X Exactly like L, but takes a nul-terminated string instead of a string/length pair. GV* gv_fetchmeth_pv_autoload(HV* stash, const char* name, I32 level, U32 flags) =for hackers Found in file gv.c =item gv_fetchmeth_sv X Exactly like L, but takes the name string in the form of an SV instead of a string/length pair. GV* gv_fetchmeth_sv(HV* stash, SV* namesv, I32 level, U32 flags) =for hackers Found in file gv.c =item gv_fetchmeth_sv_autoload X Exactly like L, but takes the name string in the form of an SV instead of a string/length pair. GV* gv_fetchmeth_sv_autoload(HV* stash, SV* namesv, I32 level, U32 flags) =for hackers Found in file gv.c =item gv_init X The old form of gv_init_pvn(). It does not work with UTF8 strings, as it has no flags parameter. If the C parameter is set, the GV_ADDMULTI flag will be passed to gv_init_pvn(). void gv_init(GV* gv, HV* stash, const char* name, STRLEN len, int multi) =for hackers Found in file gv.c =item gv_init_pv X Same as gv_init_pvn(), but takes a nul-terminated string for the name instead of separate char * and length parameters. void gv_init_pv(GV* gv, HV* stash, const char* name, U32 flags) =for hackers Found in file gv.c =item gv_init_pvn X Converts a scalar into a typeglob. This is an incoercible typeglob; assigning a reference to it will assign to one of its slots, instead of overwriting it as happens with typeglobs created by SvSetSV. Converting any scalar that is SvOK() may produce unpredictable results and is reserved for perl's internal use. C is the scalar to be converted. C is the parent stash/package, if any. C and C give the name. The name must be unqualified; that is, it must not include the package name. If C is a stash element, it is the caller's responsibility to ensure that the name passed to this function matches the name of the element. If it does not match, perl's internal bookkeeping will get out of sync. C can be set to SVf_UTF8 if C is a UTF8 string, or the return value of SvUTF8(sv). It can also take the GV_ADDMULTI flag, which means to pretend that the GV has been seen before (i.e., suppress "Used once" warnings). void gv_init_pvn(GV* gv, HV* stash, const char* name, STRLEN len, U32 flags) =for hackers Found in file gv.c =item gv_init_sv X Same as gv_init_pvn(), but takes an SV * for the name instead of separate char * and length parameters. C is currently unused. void gv_init_sv(GV* gv, HV* stash, SV* namesv, U32 flags) =for hackers Found in file gv.c =item gv_stashpv X Returns a pointer to the stash for a specified package. Uses C to determine the length of C, then calls C. HV* gv_stashpv(const char* name, I32 flags) =for hackers Found in file gv.c =item gv_stashpvn X Returns a pointer to the stash for a specified package. The C parameter indicates the length of the C, in bytes. C is passed to C, so if set to C then the package will be created if it does not already exist. If the package does not exist and C is 0 (or any other setting that does not create packages) then NULL is returned. Flags may be one of: GV_ADD SVf_UTF8 GV_NOADD_NOINIT GV_NOINIT GV_NOEXPAND GV_ADDMG The most important of which are probably GV_ADD and SVf_UTF8. Note, use of C instead of C where possible is strongly recommended for performance reasons. HV* gv_stashpvn(const char* name, U32 namelen, I32 flags) =for hackers Found in file gv.c =item gv_stashpvs X Like C, but takes a literal string instead of a string/length pair. HV* gv_stashpvs(const char* name, I32 create) =for hackers Found in file handy.h =item gv_stashsv X Returns a pointer to the stash for a specified package. See C. Note this interface is strongly preferred over C for performance reasons. HV* gv_stashsv(SV* sv, I32 flags) =for hackers Found in file gv.c =item setdefout X Sets PL_defoutgv, the default file handle for output, to the passed in typeglob. As PL_defoutgv "owns" a reference on its typeglob, the reference count of the passed in typeglob is increased by one, and the reference count of the typeglob that PL_defoutgv points to is decreased by one. void setdefout(GV* gv) =for hackers Found in file pp_sys.c =back =head1 Handy Values =over 8 =item Nullav X Null AV pointer. (deprecated - use C<(AV *)NULL> instead) =for hackers Found in file av.h =item Nullch X Null character pointer. (No longer available when C is defined.) =for hackers Found in file handy.h =item Nullcv X Null CV pointer. (deprecated - use C<(CV *)NULL> instead) =for hackers Found in file cv.h =item Nullhv X Null HV pointer. (deprecated - use C<(HV *)NULL> instead) =for hackers Found in file hv.h =item Nullsv X Null SV pointer. (No longer available when C is defined.) =for hackers Found in file handy.h =back =head1 Hash Manipulation Functions A HV structure represents a Perl hash. It consists mainly of an array of pointers, each of which points to a linked list of HE structures. The array is indexed by the hash function of the key, so each linked list represents all the hash entries with the same hash value. Each HE contains a pointer to the actual value, plus a pointer to a HEK structure which holds the key and hash value. =over 8 =item cop_fetch_label X NOTE: this function is experimental and may change or be removed without notice. Returns the label attached to a cop. The flags pointer may be set to C or 0. const char * cop_fetch_label(COP *const cop, STRLEN *len, U32 *flags) =for hackers Found in file hv.c =item cop_store_label X NOTE: this function is experimental and may change or be removed without notice. Save a label into a C. You need to set flags to C for a utf-8 label. void cop_store_label(COP *const cop, const char *label, STRLEN len, U32 flags) =for hackers Found in file hv.c =item get_hv X Returns the HV of the specified Perl hash. C are passed to C. If C is set and the Perl variable does not exist then it will be created. If C is zero and the variable does not exist then NULL is returned. NOTE: the perl_ form of this function is deprecated. HV* get_hv(const char *name, I32 flags) =for hackers Found in file perl.c =item HEf_SVKEY X This flag, used in the length slot of hash entries and magic structures, specifies the structure contains an C pointer where a C pointer is to be expected. (For information only--not to be used). =for hackers Found in file hv.h =item HeHASH X Returns the computed hash stored in the hash entry. U32 HeHASH(HE* he) =for hackers Found in file hv.h =item HeKEY X Returns the actual pointer stored in the key slot of the hash entry. The pointer may be either C or C, depending on the value of C. Can be assigned to. The C or C macros are usually preferable for finding the value of a key. void* HeKEY(HE* he) =for hackers Found in file hv.h =item HeKLEN X If this is negative, and amounts to C, it indicates the entry holds an C key. Otherwise, holds the actual length of the key. Can be assigned to. The C macro is usually preferable for finding key lengths. STRLEN HeKLEN(HE* he) =for hackers Found in file hv.h =item HePV X Returns the key slot of the hash entry as a C value, doing any necessary dereferencing of possibly C keys. The length of the string is placed in C (this is a macro, so do I use C<&len>). If you do not care about what the length of the key is, you may use the global variable C, though this is rather less efficient than using a local variable. Remember though, that hash keys in perl are free to contain embedded nulls, so using C or similar is not a good way to find the length of hash keys. This is very similar to the C macro described elsewhere in this document. See also C. If you are using C to get values to pass to C to create a new SV, you should consider using C as it is more efficient. char* HePV(HE* he, STRLEN len) =for hackers Found in file hv.h =item HeSVKEY X Returns the key as an C, or C if the hash entry does not contain an C key. SV* HeSVKEY(HE* he) =for hackers Found in file hv.h =item HeSVKEY_force X Returns the key as an C. Will create and return a temporary mortal C if the hash entry contains only a C key. SV* HeSVKEY_force(HE* he) =for hackers Found in file hv.h =item HeSVKEY_set X Sets the key to a given C, taking care to set the appropriate flags to indicate the presence of an C key, and returns the same C. SV* HeSVKEY_set(HE* he, SV* sv) =for hackers Found in file hv.h =item HeUTF8 X Returns whether the C value returned by C is encoded in UTF-8, doing any necessary dereferencing of possibly C keys. The value returned will be 0 or non-0, not necessarily 1 (or even a value with any low bits set), so B blindly assign this to a C variable, as C may be a typedef for C. U32 HeUTF8(HE* he) =for hackers Found in file hv.h =item HeVAL X Returns the value slot (type C) stored in the hash entry. Can be assigned to. SV *foo= HeVAL(hv); HeVAL(hv)= sv; SV* HeVAL(HE* he) =for hackers Found in file hv.h =item HvENAME X 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 for use in MRO linearisations and isa caches. char* HvENAME(HV* stash) =for hackers Found in file hv.h =item HvENAMELEN X Returns the length of the stash's effective name. STRLEN HvENAMELEN(HV *stash) =for hackers Found in file hv.h =item HvENAMEUTF8 X Returns true if the effective name is in UTF8 encoding. unsigned char HvENAMEUTF8(HV *stash) =for hackers Found in file hv.h =item HvNAME X Returns the package name of a stash, or NULL if C isn't a stash. See C, C. char* HvNAME(HV* stash) =for hackers Found in file hv.h =item HvNAMELEN X Returns the length of the stash's name. STRLEN HvNAMELEN(HV *stash) =for hackers Found in file hv.h =item HvNAMEUTF8 X Returns true if the name is in UTF8 encoding. unsigned char HvNAMEUTF8(HV *stash) =for hackers Found in file hv.h =item hv_assert X Check that a hash is in an internally consistent state. void hv_assert(HV *hv) =for hackers Found in file hv.c =item hv_clear X Frees the all the elements of a hash, leaving it empty. The XS equivalent of C<%hash = ()>. See also L. See L for a note about the hash possibly being invalid on return. void hv_clear(HV *hv) =for hackers Found in file hv.c =item hv_clear_placeholders X Clears any placeholders from a hash. If a restricted hash has any of its keys marked as readonly and the key is subsequently deleted, the key is not actually deleted but is marked by assigning it a value of &PL_sv_placeholder. This tags it so it will be ignored by future operations such as iterating over the hash, but will still allow the hash to have a value reassigned to the key at some future point. This function clears any such placeholder keys from the hash. See Hash::Util::lock_keys() for an example of its use. void hv_clear_placeholders(HV *hv) =for hackers Found in file hv.c =item hv_copy_hints_hv X A specialised version of L for copying C<%^H>. I must be a pointer to a hash (which may have C<%^H> magic, but should be generally non-magical), or C (interpreted as an empty hash). The content of I 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 Deletes a key/value pair in the hash. The value's SV is removed from the hash, made mortal, and returned to the caller. The absolute value of C is the length of the key. If C is negative the key is assumed to be in UTF-8-encoded Unicode. The C 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) =for hackers Found in file hv.c =item hv_delete_ent X 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 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 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) =for hackers Found in file hv.c =item hv_exists X Returns a boolean indicating whether the specified hash key exists. The absolute value of C is the length of the key. If C is negative the key is assumed to be in UTF-8-encoded Unicode. bool hv_exists(HV *hv, const char *key, I32 klen) =for hackers Found in file hv.c =item hv_exists_ent X Returns a boolean indicating whether the specified hash key exists. C can be a valid precomputed hash value, or 0 to ask for it to be computed. bool hv_exists_ent(HV *hv, SV *keysv, U32 hash) =for hackers Found in file hv.c =item hv_fetch X Returns the SV which corresponds to the specified key in the hash. The absolute value of C is the length of the key. If C is negative the key is assumed to be in UTF-8-encoded Unicode. If C is set then the fetch will be part of a store. This means that if there is no value in the hash associated with the given key, then one is created and a pointer to it is returned. The C it points to can be assigned to. But always check that the return value is non-null before dereferencing it to an C. See L for more information on how to use this function on tied hashes. SV** hv_fetch(HV *hv, const char *key, I32 klen, I32 lval) =for hackers Found in file hv.c =item hv_fetchs X Like C, but takes a literal string instead of a string/length pair. SV** hv_fetchs(HV* tb, const char* key, I32 lval) =for hackers Found in file handy.h =item hv_fetch_ent X Returns the hash entry which corresponds to the specified key in the hash. C must be a valid precomputed hash number for the given C, or 0 if you want the function to compute it. IF C 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 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. See L for more information on how to use this function on tied hashes. HE* hv_fetch_ent(HV *hv, SV *keysv, I32 lval, U32 hash) =for hackers Found in file hv.c =item hv_fill X Returns the number of hash buckets that happen to be in use. This function is wrapped by the macro C. Previously this value was always stored in the HV structure, which created an overhead on every hash (and pretty much every object) for something that was rarely used. Now we calculate it on demand the first time that it is needed, and cache it if that calculation is going to be costly to repeat. The cached value is updated by insertions and deletions, but (currently) discarded if the hash is split. STRLEN hv_fill(HV *const hv) =for hackers Found in file hv.c =item hv_iterinit X Prepares a starting point to traverse a hash table. Returns the number of keys in the hash (i.e. the same as C). The return value is currently only meaningful for hashes without tie magic. NOTE: Before version 5.004_65, C 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. I32 hv_iterinit(HV *hv) =for hackers Found in file hv.c =item hv_iterkey X Returns the key from the current position of the hash iterator. See C. char* hv_iterkey(HE* entry, I32* retlen) =for hackers Found in file hv.c =item hv_iterkeysv X Returns the key as an C from the current position of the hash iterator. The return value will always be a mortal copy of the key. Also see C. SV* hv_iterkeysv(HE* entry) =for hackers Found in file hv.c =item hv_iternext X Returns entries from a hash iterator. See C. You may call C or C on the hash entry that the iterator currently points to, without losing your place or invalidating your iterator. Note that in this case the current entry is deleted from the hash with your iterator holding the last reference to it. Your iterator is flagged to free the entry on the next call to C, so you must not discard your iterator immediately else the entry will leak - call C to trigger the resource deallocation. HE* hv_iternext(HV *hv) =for hackers Found in file hv.c =item hv_iternextsv X Performs an C, C, and C in one operation. SV* hv_iternextsv(HV *hv, char **key, I32 *retlen) =for hackers Found in file hv.c =item hv_iternext_flags X NOTE: this function is experimental and may change or be removed without notice. Returns entries from a hash iterator. See C and C. The C value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is set the placeholders keys (for restricted hashes) will be returned in addition to normal keys. By default placeholders are automatically skipped over. Currently a placeholder is implemented with a value that is C<&PL_sv_placeholder>. Note that the implementation of placeholders and restricted hashes may change, and the implementation currently is insufficiently abstracted for any change to be tidy. HE* hv_iternext_flags(HV *hv, I32 flags) =for hackers Found in file hv.c =item hv_iterval X Returns the value from the current position of the hash iterator. See C. SV* hv_iterval(HV *hv, HE *entry) =for hackers Found in file hv.c =item hv_magic X Adds magic to a hash. See C. void hv_magic(HV *hv, GV *gv, int how) =for hackers Found in file hv.c =item hv_scalar X Evaluates the hash in scalar context and returns the result. Handles magic when the hash is tied. SV* hv_scalar(HV *hv) =for hackers Found in file hv.c =item hv_store X Stores an SV in a hash. The hash key is specified as C and the absolute value of C is the length of the key. If C is negative the key is assumed to be in UTF-8-encoded Unicode. The C parameter is the precomputed hash value; if it is zero then Perl will compute it. The return value will be NULL if the operation failed or if the value did not need to be actually stored within the hash (as in the case of tied hashes). Otherwise it can be dereferenced to get the original C. Note that the caller is responsible for suitably incrementing the reference count of C before the call, and decrementing it if the function returned NULL. Effectively a successful hv_store takes ownership of one reference to C. This is usually what you want; a newly created SV has a reference count of one, so if all your code does is create SVs then store them in a hash, hv_store will own the only reference to the new SV, and your code doesn't need to do anything further to tidy up. hv_store is not implemented as a call to hv_store_ent, and does not create a temporary SV for the key, so if your key data is not already in SV form then use hv_store in preference to hv_store_ent. See L for more information on how to use this function on tied hashes. SV** hv_store(HV *hv, const char *key, I32 klen, SV *val, U32 hash) =for hackers Found in file hv.c =item hv_stores X Like C, but takes a literal string instead of a string/length pair and omits the hash parameter. SV** hv_stores(HV* tb, const char* key, NULLOK SV* val) =for hackers Found in file handy.h =item hv_store_ent X Stores C in a hash. The hash key is specified as C. The C parameter is the precomputed hash value; if it is zero then Perl will compute it. The return value is the new hash entry so created. It will be NULL if the operation failed or if the value did not need to be actually stored within the hash (as in the case of tied hashes). Otherwise the contents of the return value can be accessed using the C macros described here. Note that the caller is responsible for suitably incrementing the reference count of C before the call, and decrementing it if the function returned NULL. Effectively a successful hv_store_ent takes ownership of one reference to C. This is usually what you want; a newly created SV has a reference count of one, so if all your code does is create SVs then store them in a hash, hv_store will own the only reference to the new SV, and your code doesn't need to do anything further to tidy up. Note that hv_store_ent only reads the C; unlike C it does not take ownership of it, so maintaining the correct reference count on C is entirely the caller's responsibility. hv_store is not implemented as a call to hv_store_ent, and does not create a temporary SV for the key, so if your key data is not already in SV form then use hv_store in preference to hv_store_ent. See L for more information on how to use this function on tied hashes. HE* hv_store_ent(HV *hv, SV *key, SV *val, U32 hash) =for hackers Found in file hv.c =item hv_undef X Undefines the hash. The XS equivalent of C. As well as freeing all the elements of the hash (like hv_clear()), this also frees any auxiliary data and storage associated with the hash. See L for a note about the hash possibly being invalid on return. void hv_undef(HV *hv) =for hackers Found in file hv.c =item newHV X Creates a new HV. The reference count is set to 1. HV* newHV() =for hackers Found in file hv.h =back =head1 Hook manipulation These functions provide convenient and thread-safe means of manipulating hook variables. =over 8 =item wrap_op_checker X Puts a C function into the chain of check functions for a specified op type. This is the preferred way to manipulate the L array. I specifies which type of op is to be affected. I is a pointer to the C function that is to be added to that opcode's check chain, and I points to the storage location where a pointer to the next function in the chain will be stored. The value of I is written into the L array, while the value previously stored there is written to I<*old_checker_p>. The function should be defined like this: static OP *new_checker(pTHX_ OP *op) { ... } It is intended to be called in this manner: new_checker(aTHX_ op) I should be defined like this: static Perl_check_t old_checker_p; L is global to an entire process, and a module wishing to hook op checking may find itself invoked more than once per process, typically in different threads. To handle that situation, this function is idempotent. The location I<*old_checker_p> must initially (once per process) contain a null pointer. A C variable of static duration (declared at file scope, typically also marked C to give it internal linkage) will be implicitly initialised appropriately, if it does not have an explicit initialiser. This function will only actually modify the check chain if it finds I<*old_checker_p> to be null. This function is also thread safe on the small scale. It uses appropriate locking to avoid race conditions in accessing L. When this function is called, the function referenced by I must be ready to be called, except for I<*old_checker_p> being unfilled. In a threading situation, I may be called immediately, even before this function has returned. I<*old_checker_p> will always be appropriately set before I is called. If I decides not to do anything special with an op that it is given (which is the usual case for most uses of op check hooking), it must chain the check function referenced by I<*old_checker_p>. If you want to influence compilation of calls to a specific subroutine, then use L rather than hooking checking of all C ops. void wrap_op_checker(Optype opcode, Perl_check_t new_checker, Perl_check_t *old_checker_p) =for hackers Found in file op.c =back =head1 Lexer interface This is the lower layer of the Perl parser, managing characters and tokens. =over 8 =item lex_bufutf8 X NOTE: this function is experimental and may change or be removed without notice. Indicates whether the octets in the lexer buffer (Llinestr>) should be interpreted as the UTF-8 encoding of Unicode characters. If not, they should be interpreted as Latin-1 characters. This is analogous to the C flag for scalars. In UTF-8 mode, it is not guaranteed that the lexer buffer actually contains valid UTF-8. Lexing code must be robust in the face of invalid encoding. The actual C flag of the Llinestr> scalar is significant, but not the whole story regarding the input character encoding. Normally, when a file is being read, the scalar contains octets and its C flag is off, but the octets should be interpreted as UTF-8 if the C pragma is in effect. During a string eval, however, the scalar may have the C flag on, and in this case its octets should be interpreted as UTF-8 unless the C pragma is in effect. This logic may change in the future; use this function instead of implementing the logic yourself. bool lex_bufutf8() =for hackers Found in file toke.c =item lex_discard_to X NOTE: this function is experimental and may change or be removed without notice. Discards the first part of the Llinestr> buffer, up to I. The remaining content of the buffer will be moved, and all pointers into the buffer updated appropriately. I must not be later in the buffer than the position of Lbufptr>: 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 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 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. void lex_discard_to(char *ptr) =for hackers Found in file toke.c =item lex_grow_linestr X NOTE: this function is experimental and may change or be removed without notice. Reallocates the lexer buffer (Llinestr>) to accommodate at least I octets (including terminating C). Returns a pointer to the reallocated buffer. This is necessary before making any direct modification of the buffer that would increase its length. L provides a more convenient way to insert text into the buffer. Do not use C or C directly on Clinestr>; this function updates all of the lexer's variables that point directly into the buffer. char * lex_grow_linestr(STRLEN len) =for hackers Found in file toke.c =item lex_next_chunk X NOTE: this function is experimental and may change or be removed without notice. Reads in the next chunk of text to be lexed, appending it to Llinestr>. This should be called when lexing code has looked to the end of the current chunk and wants to know more. It is usual, but not necessary, for lexing to have consumed the entirety of the current chunk at this time. If Lbufptr> is pointing to the very end of the current chunk (i.e., the current chunk has been entirely consumed), normally the current chunk will be discarded at the same time that the new chunk is read in. If I includes C, the current chunk will not be discarded. If the current chunk has not been entirely consumed, then it will not be discarded regardless of the flag. Returns true if some new text was added to the buffer, or false if the buffer has reached the end of the input text. bool lex_next_chunk(U32 flags) =for hackers Found in file toke.c =item lex_peek_unichar X NOTE: this function is experimental and may change or be removed without notice. Looks ahead one (Unicode) character in the text currently being lexed. Returns the codepoint (unsigned integer value) of the next character, or -1 if lexing has reached the end of the input text. To consume the peeked character, use L. If the next character is in (or extends into) the next chunk of input text, the next chunk will be read in. Normally the current chunk will be discarded at the same time, but if I includes C then the current chunk will not be discarded. If the input is being interpreted as UTF-8 and a UTF-8 encoding error is encountered, an exception is generated. I32 lex_peek_unichar(U32 flags) =for hackers Found in file toke.c =item lex_read_space X NOTE: this function is experimental and may change or be removed without notice. Reads optional spaces, in Perl style, in the text currently being lexed. The spaces may include ordinary whitespace characters and Perl-style comments. C<#line> directives are processed if encountered. Lbufptr> is moved past the spaces, so that it points at a non-space character (or the end of the input text). If spaces extend into the next chunk of input text, the next chunk will be read in. Normally the current chunk will be discarded at the same time, but if I includes C then the current chunk will not be discarded. void lex_read_space(U32 flags) =for hackers Found in file toke.c =item lex_read_to X NOTE: this function is experimental and may change or be removed without notice. Consume text in the lexer buffer, from Lbufptr> up to I. This advances Lbufptr> to match I, performing the correct bookkeeping whenever a newline character is passed. This is the normal way to consume lexed text. Interpretation of the buffer's octets can be abstracted out by using the slightly higher-level functions L and L. void lex_read_to(char *ptr) =for hackers Found in file toke.c =item lex_read_unichar X NOTE: this function is experimental and may change or be removed without notice. Reads the next (Unicode) character in the text currently being lexed. Returns the codepoint (unsigned integer value) of the character read, and moves Lbufptr> past the character, or returns -1 if lexing has reached the end of the input text. To non-destructively examine the next character, use L instead. If the next character is in (or extends into) the next chunk of input text, the next chunk will be read in. Normally the current chunk will be discarded at the same time, but if I includes C then the current chunk will not be discarded. If the input is being interpreted as UTF-8 and a UTF-8 encoding error is encountered, an exception is generated. I32 lex_read_unichar(U32 flags) =for hackers Found in file toke.c =item lex_start X NOTE: this function is experimental and may change or be removed without notice. 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. 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 will be restored. Nothing else need be done to clean up the parsing context. The code to be parsed comes from I and I. I, 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 does not affect parsing. I, 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 comes first and must consist of complete lines of input, and I supplies the remainder of the source. The I parameter is reserved for future use. Currently it is only used by perl internally, so extensions should always pass zero. void lex_start(SV *line, PerlIO *rsfp, U32 flags) =for hackers Found in file toke.c =item lex_stuff_pv X NOTE: this function is experimental and may change or be removed without notice. Insert characters into the lexer buffer (Llinestr>), immediately after the current lexing point (Lbufptr>), 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 and continuing to the first nul. These octets are interpreted as either UTF-8 or Latin-1, according to whether the C flag is set in I. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (L). If it is not convenient to nul-terminate a string to be inserted, the L function is more appropriate. void lex_stuff_pv(const char *pv, U32 flags) =for hackers Found in file toke.c =item lex_stuff_pvn X NOTE: this function is experimental and may change or be removed without notice. Insert characters into the lexer buffer (Llinestr>), immediately after the current lexing point (Lbufptr>), 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 I octets starting at I. These octets are interpreted as either UTF-8 or Latin-1, according to whether the C flag is set in I. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (L). If a string to be inserted is available as a Perl scalar, the L function is more convenient. void lex_stuff_pvn(const char *pv, STRLEN len, U32 flags) =for hackers Found in file toke.c =item lex_stuff_pvs X NOTE: this function is experimental and may change or be removed without notice. Like L, but takes a literal string instead of a string/length pair. void lex_stuff_pvs(const char *pv, U32 flags) =for hackers Found in file handy.h =item lex_stuff_sv X NOTE: this function is experimental and may change or be removed without notice. Insert characters into the lexer buffer (Llinestr>), immediately after the current lexing point (Lbufptr>), 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 the string value of I. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (L). If a string to be inserted is not already a Perl scalar, the L function avoids the need to construct a scalar. void lex_stuff_sv(SV *sv, U32 flags) =for hackers Found in file toke.c =item lex_unstuff X NOTE: this function is experimental and may change or be removed without notice. Discards text about to be lexed, from Lbufptr> up to I. Text following I will be moved, and the buffer shortened. This hides the discarded text from any lexing code that runs later, as if the text had never appeared. This is not the normal way to consume lexed text. For that, use L. void lex_unstuff(char *ptr) =for hackers Found in file toke.c =item parse_arithexpr X NOTE: this function is experimental and may change or be removed without notice. 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 includes C then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (L 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. OP * parse_arithexpr(U32 flags) =for hackers Found in file toke.c =item parse_barestmt X NOTE: this function is experimental and may change or be removed without notice. 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 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. It will not normally include a C 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 parameter is reserved for future use, and must always be zero. OP * parse_barestmt(U32 flags) =for hackers Found in file toke.c =item parse_block X NOTE: this function is experimental and may change or be removed without notice. 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 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 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 list, including C 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 parameter is reserved for future use, and must always be zero. OP * parse_block(U32 flags) =for hackers Found in file toke.c =item parse_fullexpr X NOTE: this function is experimental and may change or be removed without notice. Parse a single complete Perl expression. This allows the full expression grammar, including the lowest-precedence operators such as C. 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 includes C then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (L 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. OP * parse_fullexpr(U32 flags) =for hackers Found in file toke.c =item parse_fullstmt X NOTE: this function is experimental and may change or be removed without notice. 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 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 call, normally including a C 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 parameter is reserved for future use, and must always be zero. OP * parse_fullstmt(U32 flags) =for hackers Found in file toke.c =item parse_label X NOTE: this function is experimental and may change or be removed without notice. 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 et al) is correctly set to reflect the source of the code to be parsed. If I includes C 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. SV * parse_label(U32 flags) =for hackers Found in file toke.c =item parse_listexpr X NOTE: this function is experimental and may change or be removed without notice. 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 by something that would normally terminate an expression such as semicolon. If I includes C then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (L 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. OP * parse_listexpr(U32 flags) =for hackers Found in file toke.c =item parse_stmtseq X NOTE: this function is experimental and may change or be removed without notice. 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 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 list, normally including C 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 parameter is reserved for future use, and must always be zero. OP * parse_stmtseq(U32 flags) =for hackers Found in file toke.c =item parse_termexpr X NOTE: this function is experimental and may change or be removed without notice. 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 includes C then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (L 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. OP * parse_termexpr(U32 flags) =for hackers Found in file toke.c =item PL_parser X Pointer to a structure encapsulating the state of the parsing operation currently in progress. The pointer can be locally changed to perform a nested parse without interfering with the state of an outer parse. Individual members of C have their own documentation. =for hackers Found in file toke.c =item PL_parser-Ebufend Xbufend> NOTE: this function is experimental and may change or be removed without notice. Direct pointer to the end of the chunk of text currently being lexed, the end of the lexer buffer. This is equal to Clinestr) + SvCUR(PL_parser-Elinestr)>. A C character (zero octet) is always located at the end of the buffer, and does not count as part of the buffer's contents. =for hackers Found in file toke.c =item PL_parser-Ebufptr Xbufptr> NOTE: this function is experimental and may change or be removed without notice. Points to the current position of lexing inside the lexer buffer. Characters around this point may be freely examined, within the range delimited by Clinestr>)> and Lbufend>. The octets of the buffer may be intended to be interpreted as either UTF-8 or Latin-1, as indicated by L. Lexing code (whether in the Perl core or not) moves this pointer past the characters that it consumes. It is also expected to perform some bookkeeping whenever a newline character is consumed. This movement can be more conveniently performed by the function L, which handles newlines appropriately. Interpretation of the buffer's octets can be abstracted out by using the slightly higher-level functions L and L. =for hackers Found in file toke.c =item PL_parser-Elinestart Xlinestart> NOTE: this function is experimental and may change or be removed without notice. Points to the start of the current line inside the lexer buffer. This is useful for indicating at which column an error occurred, and not much else. This must be updated by any lexing code that consumes a newline; the function L handles this detail. =for hackers Found in file toke.c =item PL_parser-Elinestr Xlinestr> NOTE: this function is experimental and may change or be removed without notice. Buffer scalar containing the chunk currently under consideration of the text currently being lexed. This is always a plain string scalar (for which C is true). It is not intended to be used as a scalar by normal scalar means; instead refer to the buffer directly by the pointer variables described below. The lexer maintains various C pointers to things in the Clinestr> buffer. If Clinestr> is ever reallocated, all of these pointers must be updated. Don't attempt to do this manually, but rather use L if you need to reallocate the buffer. The content of the text chunk in the buffer is commonly exactly one complete line of input, up to and including a newline terminator, but there are situations where it is otherwise. The octets of the buffer may be intended to be interpreted as either UTF-8 or Latin-1. The function L tells you which. Do not use the C flag on this scalar, which may disagree with it. For direct examination of the buffer, the variable Lbufend> points to the end of the buffer. The current lexing position is pointed to by Lbufptr>. Direct use of these pointers is usually preferable to examination of the scalar through normal scalar means. =for hackers Found in file toke.c =back =head1 Locale-related functions and macros =over 8 =item DECLARATION_FOR_LC_NUMERIC_MANIPULATION X This macro should be used as a statement. It declares a private variable (whose name begins with an underscore) that is needed by the other macros in this section. Failing to include this correctly should lead to a syntax error. For compatibility with C89 C compilers it should be placed in a block before any executable statements. void DECLARATION_FOR_LC_NUMERIC_MANIPULATION =for hackers Found in file perl.h =item RESTORE_LC_NUMERIC X This is used in conjunction with one of the macros L and L to properly restore the C state. A call to L must have been made to declare at compile time a private variable used by this macro and the two C ones. This macro should be called as a single statement, not an expression, but with an empty argument list, like this: { DECLARATION_FOR_LC_NUMERIC_MANIPULATION; ... RESTORE_LC_NUMERIC(); ... } void RESTORE_LC_NUMERIC() =for hackers Found in file perl.h =item STORE_LC_NUMERIC_FORCE_TO_UNDERLYING X This is used by XS code that that is C locale-aware to force the locale for category C to be what perl thinks is the current underlying locale. (The perl interpreter could be wrong about what the underlying locale actually is if some C or XS code has called the C library function L behind its back; calling L before calling this macro will update perl's records.) A call to L must have been made to declare at compile time a private variable used by this macro. This macro should be called as a single statement, not an expression, but with an empty argument list, like this: { DECLARATION_FOR_LC_NUMERIC_MANIPULATION; ... STORE_LC_NUMERIC_FORCE_TO_UNDERLYING(); ... RESTORE_LC_NUMERIC(); ... } The private variable is used to save the current locale state, so that the requisite matching call to L can restore it. void STORE_LC_NUMERIC_FORCE_TO_UNDERLYING() =for hackers Found in file perl.h =item STORE_LC_NUMERIC_SET_TO_NEEDED X This is used to help wrap XS or C code that that is C locale-aware. This locale category is generally kept set to the C locale by Perl for backwards compatibility, and because most XS code that reads floating point values can cope only with the decimal radix character being a dot. This macro makes sure the current C state is set properly, to be aware of locale if the call to the XS or C code from the Perl program is from within the scope of a S>; or to ignore locale if the call is instead from outside such scope. This macro is the start of wrapping the C or XS code; the wrap ending is done by calling the L macro after the operation. Otherwise the state can be changed that will adversely affect other XS code. A call to L must have been made to declare at compile time a private variable used by this macro. This macro should be called as a single statement, not an expression, but with an empty argument list, like this: { DECLARATION_FOR_LC_NUMERIC_MANIPULATION; ... STORE_LC_NUMERIC_SET_TO_NEEDED(); ... RESTORE_LC_NUMERIC(); ... } void STORE_LC_NUMERIC_SET_TO_NEEDED() =for hackers Found in file perl.h =item sync_locale X Changing the program's locale should be avoided by XS code. Nevertheless, certain non-Perl libraries called from XS, such as C do so. When this happens, Perl needs to be told that the locale has changed. Use this function to do so, before returning to Perl. void sync_locale() =for hackers Found in file locale.c =back =head1 Magical Functions =over 8 =item mg_clear X Clear something magical that the SV represents. See C. int mg_clear(SV* sv) =for hackers Found in file mg.c =item mg_copy X Copies the magic from one SV to another. See C. int mg_copy(SV *sv, SV *nsv, const char *key, I32 klen) =for hackers Found in file mg.c =item mg_find X Finds the magic pointer for type matching the SV. See C. MAGIC* mg_find(const SV* sv, int type) =for hackers Found in file mg.c =item mg_findext X Finds the magic pointer of C with the given C for the C. See C. MAGIC* mg_findext(const SV* sv, int type, const MGVTBL *vtbl) =for hackers Found in file mg.c =item mg_free X Free any magic storage used by the SV. See C. int mg_free(SV* sv) =for hackers Found in file mg.c =item mg_free_type X Remove any magic of type I from the SV I. See L. void mg_free_type(SV *sv, int how) =for hackers Found in file mg.c =item mg_get X Do magic before a value is retrieved from the SV. The type of SV must be >= SVt_PVMG. See C. int mg_get(SV* sv) =for hackers Found in file mg.c =item mg_length X DEPRECATED! It is planned to remove this function from a future release of Perl. Do not use it for new code; remove it from existing code. Reports on the SV's length in bytes, calling length magic if available, but does not set the UTF8 flag on the sv. It will fall back to 'get' magic if there is no 'length' magic, but with no indication as to whether it called 'get' magic. It assumes the sv is a PVMG or higher. Use sv_len() instead. U32 mg_length(SV* sv) =for hackers Found in file mg.c =item mg_magical X Turns on the magical status of an SV. See C. void mg_magical(SV* sv) =for hackers Found in file mg.c =item mg_set X Do magic after a value is assigned to the SV. See C. int mg_set(SV* sv) =for hackers Found in file mg.c =item SvGETMAGIC X Invokes C on an SV if it has 'get' magic. For example, this will call C on a tied variable. This macro evaluates its argument more than once. void SvGETMAGIC(SV* sv) =for hackers Found in file sv.h =item SvLOCK X Arranges for a mutual exclusion lock to be obtained on sv if a suitable module has been loaded. void SvLOCK(SV* sv) =for hackers Found in file sv.h =item SvSETMAGIC X Invokes C on an SV if it has 'set' magic. This is necessary after modifying a scalar, in case it is a magical variable like C<$|> or a tied variable (it calls C). This macro evaluates its argument more than once. void SvSETMAGIC(SV* sv) =for hackers Found in file sv.h =item SvSetMagicSV X Like C, but does any set magic required afterwards. void SvSetMagicSV(SV* dsv, SV* ssv) =for hackers Found in file sv.h =item SvSetMagicSV_nosteal X Like C, but does any set magic required afterwards. void SvSetMagicSV_nosteal(SV* dsv, SV* ssv) =for hackers Found in file sv.h =item SvSetSV X Calls C if dsv is not the same as ssv. May evaluate arguments more than once. Does not handle 'set' magic on the destination SV. void SvSetSV(SV* dsv, SV* ssv) =for hackers Found in file sv.h =item SvSetSV_nosteal X Calls a non-destructive version of C if dsv is not the same as ssv. May evaluate arguments more than once. void SvSetSV_nosteal(SV* dsv, SV* ssv) =for hackers Found in file sv.h =item SvSHARE X Arranges for sv to be shared between threads if a suitable module has been loaded. void SvSHARE(SV* sv) =for hackers Found in file sv.h =item SvUNLOCK X Releases a mutual exclusion lock on sv if a suitable module has been loaded. void SvUNLOCK(SV* sv) =for hackers Found in file sv.h =back =head1 Memory Management =over 8 =item Copy X The XSUB-writer's interface to the C C function. The C is the source, C is the destination, C is the number of items, and C is the type. May fail on overlapping copies. See also C. void Copy(void* src, void* dest, int nitems, type) =for hackers Found in file handy.h =item CopyD X Like C but returns dest. Useful for encouraging compilers to tail-call optimise. void * CopyD(void* src, void* dest, int nitems, type) =for hackers Found in file handy.h =item Move X The XSUB-writer's interface to the C C function. The C is the source, C is the destination, C is the number of items, and C is the type. Can do overlapping moves. See also C. void Move(void* src, void* dest, int nitems, type) =for hackers Found in file handy.h =item MoveD X Like C but returns dest. Useful for encouraging compilers to tail-call optimise. void * MoveD(void* src, void* dest, int nitems, type) =for hackers Found in file handy.h =item Newx X The XSUB-writer's interface to the C C function. Memory obtained by this should B be freed with L<"Safefree">. In 5.9.3, Newx() and friends replace the older New() API, and drops the first parameter, I, a debug aid which allowed callers to identify themselves. This aid has been superseded by a new build option, PERL_MEM_LOG (see L). The older API is still there for use in XS modules supporting older perls. void Newx(void* ptr, int nitems, type) =for hackers Found in file handy.h =item Newxc X The XSUB-writer's interface to the C C function, with cast. See also C. Memory obtained by this should B be freed with L<"Safefree">. void Newxc(void* ptr, int nitems, type, cast) =for hackers Found in file handy.h =item Newxz X The XSUB-writer's interface to the C C function. The allocated memory is zeroed with C. See also C. Memory obtained by this should B be freed with L<"Safefree">. void Newxz(void* ptr, int nitems, type) =for hackers Found in file handy.h =item Poison X PoisonWith(0xEF) for catching access to freed memory. void Poison(void* dest, int nitems, type) =for hackers Found in file handy.h =item PoisonFree X PoisonWith(0xEF) for catching access to freed memory. void PoisonFree(void* dest, int nitems, type) =for hackers Found in file handy.h =item PoisonNew X PoisonWith(0xAB) for catching access to allocated but uninitialized memory. void PoisonNew(void* dest, int nitems, type) =for hackers Found in file handy.h =item PoisonWith X Fill up memory with a byte pattern (a byte repeated over and over again) that hopefully catches attempts to access uninitialized memory. void PoisonWith(void* dest, int nitems, type, U8 byte) =for hackers Found in file handy.h =item Renew X The XSUB-writer's interface to the C C function. Memory obtained by this should B be freed with L<"Safefree">. void Renew(void* ptr, int nitems, type) =for hackers Found in file handy.h =item Renewc X The XSUB-writer's interface to the C C function, with cast. Memory obtained by this should B be freed with L<"Safefree">. void Renewc(void* ptr, int nitems, type, cast) =for hackers Found in file handy.h =item Safefree X The XSUB-writer's interface to the C C function. This should B be used on memory obtained using L<"Newx"> and friends. void Safefree(void* ptr) =for hackers Found in file handy.h =item savepv X Perl's version of C. Returns a pointer to a newly allocated string which is a duplicate of C. The size of the string is determined by C, which means it may not contain embedded C characters and must have a trailing C. The memory allocated for the new string can be freed with the C function. On some platforms, Windows for example, all allocated memory owned by a thread is deallocated when that thread ends. So if you need that not to happen, you need to use the shared memory functions, such as C>. char* savepv(const char* pv) =for hackers Found in file util.c =item savepvn X Perl's version of what C would be if it existed. Returns a pointer to a newly allocated string which is a duplicate of the first C bytes from C, plus a trailing C byte. The memory allocated for the new string can be freed with the C function. On some platforms, Windows for example, all allocated memory owned by a thread is deallocated when that thread ends. So if you need that not to happen, you need to use the shared memory functions, such as C>. char* savepvn(const char* pv, I32 len) =for hackers Found in file util.c =item savepvs X Like C, but takes a literal C-terminated string instead of a string/length pair. char* savepvs(const char* s) =for hackers Found in file handy.h =item savesharedpv X A version of C which allocates the duplicate string in memory which is shared between threads. char* savesharedpv(const char* pv) =for hackers Found in file util.c =item savesharedpvn X A version of C which allocates the duplicate string in memory which is shared between threads. (With the specific difference that a NULL pointer is not acceptable) char* savesharedpvn(const char *const pv, const STRLEN len) =for hackers Found in file util.c =item savesharedpvs X A version of C 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 A version of C 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 A version of C/C which gets the string to duplicate from the passed in SV using C On some platforms, Windows for example, all allocated memory owned by a thread is deallocated when that thread ends. So if you need that not to happen, you need to use the shared memory functions, such as C>. char* savesvpv(SV* sv) =for hackers Found in file util.c =item StructCopy X This is an architecture-independent macro to copy one structure to another. void StructCopy(type *src, type *dest, type) =for hackers Found in file handy.h =item Zero X The XSUB-writer's interface to the C C function. The C is the destination, C is the number of items, and C is the type. void Zero(void* dest, int nitems, type) =for hackers Found in file handy.h =item ZeroD X Like C but returns dest. Useful for encouraging compilers to tail-call optimise. void * ZeroD(void* dest, int nitems, type) =for hackers Found in file handy.h =back =head1 Miscellaneous Functions =over 8 =item dump_c_backtrace X Dumps the C backtrace to the given fp. Returns true if a backtrace could be retrieved, false if not. bool dump_c_backtrace(PerlIO* fp, int max_depth, int skip) =for hackers Found in file util.c =item fbm_compile X Analyses the string in order to make fast searches on it using fbm_instr() -- the Boyer-Moore algorithm. void fbm_compile(SV* sv, U32 flags) =for hackers Found in file util.c =item fbm_instr X Returns the location of the SV in the string delimited by C and C. It returns C if the string can't be found. The C does not have to be fbm_compiled, but the search will not be as fast then. char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlestr, U32 flags) =for hackers Found in file util.c =item foldEQ X 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 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

Takes a sprintf-style format pattern and conventional (non-SV) arguments and returns the formatted string. (char *) Perl_form(pTHX_ const char* pat, ...) can be used any place a string (char *) is required: char * s = Perl_form("%d.%d",major,minor); Uses a single private buffer so if you want to format several strings you must explicitly copy the earlier strings away (and free the copies when you are done). char* form(const char* pat, ...) =for hackers Found in file util.c =item getcwd_sv X Fill the sv with current working directory int getcwd_sv(SV* sv) =for hackers Found in file util.c =item get_c_backtrace_dump X Returns a SV a dump of |depth| frames of the call stack, skipping the |skip| innermost ones. depth of 20 is usually enough. The appended output looks like: ... 1 10e004812:0082 Perl_croak util.c:1716 /usr/bin/perl 2 10df8d6d2:1d72 perl_parse perl.c:3975 /usr/bin/perl ... The fields are tab-separated. The first column is the depth (zero being the innermost non-skipped frame). In the hex:offset, the hex is where the program counter was in S_parse_body, and the :offset (might be missing) tells how much inside the S_parse_body the program counter was. The util.c:1716 is the source code file and line number. The /usr/bin/perl is obvious (hopefully). Unknowns are C<"-">. Unknowns can happen unfortunately quite easily: if the platform doesn't support retrieving the information; if the binary is missing the debug information; if the optimizer has transformed the code by for example inlining. SV* get_c_backtrace_dump(int max_depth, int skip) =for hackers Found in file util.c =item ibcmp X 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 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 =item is_safe_syscall X Test that the given C doesn't contain any internal C characters. If it does, set C to ENOENT, optionally warn, and return FALSE. Return TRUE if the name is safe. Used by the IS_SAFE_SYSCALL() macro. bool is_safe_syscall(const char *pv, STRLEN len, const char *what, const char *op_name) =for hackers Found in file inline.h =item memEQ X Test two buffers (which may contain embedded C characters, to see if they are equal. The C parameter indicates the number of bytes to compare. Returns zero if equal, or non-zero if non-equal. bool memEQ(char* s1, char* s2, STRLEN len) =for hackers Found in file handy.h =item memNE X Test two buffers (which may contain embedded C characters, to see if they are not equal. The C parameter indicates the number of bytes to compare. Returns zero if non-equal, or non-zero if equal. bool memNE(char* s1, char* s2, STRLEN len) =for hackers Found in file handy.h =item mess X 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. 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 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 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 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 is true, then the function is permitted (but not required) to modify and return C instead of allocating a new SV. SV * mess_sv(SV *basemsg, bool consume) =for hackers Found in file util.c =item my_snprintf X The C library C functionality, if available and standards-compliant (uses C, actually). However, if the C is not available, will unfortunately use the unsafe C which can overrun the buffer (there is an overrun check, but that may be too late). Consider using C instead, or getting C. int my_snprintf(char *buffer, const Size_t len, const char *format, ...) =for hackers Found in file util.c =item my_sprintf X The C library C, wrapped if necessary, to ensure that it will return the length of the string written to the buffer. Only rare pre-ANSI systems need the wrapper function - usually this is a direct call to C. int my_sprintf(char *buffer, const char *pat, ...) =for hackers Found in file util.c =item my_strlcat X The C library C if available, or a Perl implementation of it. This operates on C C-terminated strings. C appends string C to the end of C. It will append at most S> characters. It will then C-terminate, unless C is 0 or the original C string was longer than C (in practice this should not happen as it means that either C is incorrect or that C is not a proper C-terminated string). Note that C is the full size of the destination buffer and the result is guaranteed to be C-terminated if there is room. Note that room for the C should be included in C. Size_t my_strlcat(char *dst, const char *src, Size_t size) =for hackers Found in file util.c =item my_strlcpy X The C library C if available, or a Perl implementation of it. This operates on C C-terminated strings. C copies up to S> characters from the string C to C, C-terminating the result if C is not 0. Size_t my_strlcpy(char *dst, const char *src, Size_t size) =for hackers Found in file util.c =item my_vsnprintf X The C library C if available and standards-compliant. However, if if the C is not available, will unfortunately use the unsafe C which can overrun the buffer (there is an overrun check, but that may be too late). Consider using C instead, or getting C. int my_vsnprintf(char *buffer, const Size_t len, const char *format, va_list ap) =for hackers Found in file util.c =item PERL_SYS_INIT X Provides system-specific tune up of the C runtime environment necessary to run Perl interpreters. This should be called only once, before creating any Perl interpreters. void PERL_SYS_INIT(int *argc, char*** argv) =for hackers Found in file perl.h =item PERL_SYS_INIT3 X Provides system-specific tune up of the C runtime environment necessary to run Perl interpreters. This should be called only once, before creating any Perl interpreters. void PERL_SYS_INIT3(int *argc, char*** argv, char*** env) =for hackers Found in file perl.h =item PERL_SYS_TERM X Provides system-specific clean up of the C runtime environment after running Perl interpreters. This should be called only once, after freeing any remaining Perl interpreters. void PERL_SYS_TERM() =for hackers Found in file perl.h =item quadmath_format_needed X quadmath_format_needed() returns true if the format string seems to contain at least one non-Q-prefixed %[efgaEFGA] format specifier, or returns false otherwise. The format specifier detection is not complete printf-syntax detection, but it should catch most common cases. If true is returned, those arguments B in theory be processed with quadmath_snprintf(), but in case there is more than one such format specifier (see L), and if there is anything else beyond that one (even just a single byte), they B be processed because quadmath_snprintf() is very strict, accepting only one format spec, and nothing else. In this case, the code should probably fail. bool quadmath_format_needed(const char* format) =for hackers Found in file util.c =item quadmath_format_single X quadmath_snprintf() is very strict about its format string and will fail, returning -1, if the format is invalid. It acccepts exactly one format spec. quadmath_format_single() checks that the intended single spec looks sane: begins with C<%>, has only one C<%>, ends with C<[efgaEFGA]>, and has C before it. This is not a full "printf syntax check", just the basics. Returns the format if it is valid, NULL if not. quadmath_format_single() can and will actually patch in the missing C, if necessary. In this case it will return the modified copy of the format, B See also L. const char* quadmath_format_single(const char* format) =for hackers Found in file util.c =item READ_XDIGIT X Returns the value of an ASCII-range hex digit and advances the string pointer. Behaviour is only well defined when isXDIGIT(*str) is true. U8 READ_XDIGIT(char str*) =for hackers Found in file handy.h =item strEQ X Test two strings to see if they are equal. Returns true or false. bool strEQ(char* s1, char* s2) =for hackers Found in file handy.h =item strGE X Test two strings to see if the first, C, is greater than or equal to the second, C. Returns true or false. bool strGE(char* s1, char* s2) =for hackers Found in file handy.h =item strGT X Test two strings to see if the first, C, is greater than the second, C. Returns true or false. bool strGT(char* s1, char* s2) =for hackers Found in file handy.h =item strLE X Test two strings to see if the first, C, is less than or equal to the second, C. Returns true or false. bool strLE(char* s1, char* s2) =for hackers Found in file handy.h =item strLT X Test two strings to see if the first, C, is less than the second, C. Returns true or false. bool strLT(char* s1, char* s2) =for hackers Found in file handy.h =item strNE X Test two strings to see if they are different. Returns true or false. bool strNE(char* s1, char* s2) =for hackers Found in file handy.h =item strnEQ X Test two strings to see if they are equal. The C parameter indicates the number of bytes to compare. Returns true or false. (A wrapper for C). bool strnEQ(char* s1, char* s2, STRLEN len) =for hackers Found in file handy.h =item strnNE X Test two strings to see if they are different. The C parameter indicates the number of bytes to compare. Returns true or false. (A wrapper for C). bool strnNE(char* s1, char* s2, STRLEN len) =for hackers Found in file handy.h =item sv_destroyable X Dummy routine which reports that object can be destroyed when there is no sharing module present. It ignores its single SV argument, and returns 'true'. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness. bool sv_destroyable(SV *sv) =for hackers Found in file util.c =item sv_nosharing X Dummy routine which "shares" an SV when there is no sharing module present. Or "locks" it. Or "unlocks" it. In other words, ignores its single SV argument. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness. void sv_nosharing(SV *sv) =for hackers Found in file util.c =item vmess X C and C 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. 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 =back =head1 MRO Functions These functions are related to the method resolution order of perl classes =over 8 =item mro_get_linear_isa X Returns the mro linearisation for the given stash. By default, this will be whatever C returns unless some other MRO is in effect for the stash. The return value is a read-only AV*. You are responsible for C on the return value if you plan to store it anywhere semi-permanently (otherwise it might be deleted out from under you the next time the cache is invalidated). AV* mro_get_linear_isa(HV* stash) =for hackers Found in file mro_core.c =item mro_method_changed_in X Invalidates method caching on any child classes of the given stash, so that they might notice the changes in this one. Ideally, all instances of C in perl source outside of F should be replaced by calls to this. Perl automatically handles most of the common ways a method might be redefined. However, there are a few ways you could change a method in a stash without the cache code noticing, in which case you need to call this method afterwards: 1) Directly manipulating the stash HV entries from XS code. 2) Assigning a reference to a readonly scalar constant into a stash entry in order to create a constant subroutine (like constant.pm does). This same method is available from pure perl via, C. void mro_method_changed_in(HV* stash) =for hackers Found in file mro_core.c =item mro_register X Registers a custom mro plugin. See L for details. void mro_register(const struct mro_alg *mro) =for hackers Found in file mro_core.c =back =head1 Multicall Functions =over 8 =item dMULTICALL X Declare local variables for a multicall. See L. dMULTICALL; =for hackers Found in file cop.h =item MULTICALL X Make a lightweight callback. See L. MULTICALL; =for hackers Found in file cop.h =item POP_MULTICALL X Closing bracket for a lightweight callback. See L. POP_MULTICALL; =for hackers Found in file cop.h =item PUSH_MULTICALL X Opening bracket for a lightweight callback. See L. PUSH_MULTICALL; =for hackers Found in file cop.h =back =head1 Numeric functions =over 8 =item grok_bin X converts a string representing a binary number to numeric form. On entry I and I<*len> give the string to scan, I<*flags> gives conversion flags, and I 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 is set in I<*flags>, encountering an invalid character will also trigger a warning. On return I<*len> is set to the length of the scanned string, and I<*flags> gives output flags. If the value is <= C it is returned as a UV, the output flags are clear, and nothing is written to I<*result>. If the value is > UV_MAX C returns UV_MAX, sets C in the output flags, and writes the value to I<*result> (or the value is discarded if I is NULL). The binary number may optionally be prefixed with "0b" or "b" unless C is set in I<*flags> on entry. If C is set in I<*flags> then the binary number may use '_' characters to separate digits. UV grok_bin(const char* start, STRLEN* len_p, I32* flags, NV *result) =for hackers Found in file numeric.c =item grok_hex X converts a string representing a hex number to numeric form. On entry I and I<*len_p> give the string to scan, I<*flags> gives conversion flags, and I 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 is set in I<*flags>, encountering an invalid character will also trigger a warning. On return I<*len> is set to the length of the scanned string, and I<*flags> gives output flags. If the value is <= UV_MAX it is returned as a UV, the output flags are clear, and nothing is written to I<*result>. If the value is > UV_MAX C returns UV_MAX, sets C in the output flags, and writes the value to I<*result> (or the value is discarded if I is NULL). The hex number may optionally be prefixed with "0x" or "x" unless C is set in I<*flags> on entry. If C is set in I<*flags> then the hex number may use '_' characters to separate digits. UV grok_hex(const char* start, STRLEN* len_p, I32* flags, NV *result) =for hackers Found in file numeric.c =item grok_infnan X Helper for grok_number(), accepts various ways of spelling "infinity" or "not a number", and returns one of the following flag combinations: IS_NUMBER_INFINITE IS_NUMBER_NAN IS_NUMBER_INFINITE | IS_NUMBER_NEG IS_NUMBER_NAN | IS_NUMBER_NEG 0 possibly |-ed with IS_NUMBER_TRAILING. If an infinity or a not-a-number is recognized, the *sp will point to one byte past the end of the recognized string. If the recognition fails, zero is returned, and the *sp will not move. int grok_infnan(const char** sp, const char *send) =for hackers Found in file numeric.c =item grok_number X Identical to grok_number_flags() with flags set to zero. int grok_number(const char *pv, STRLEN len, UV *valuep) =for hackers Found in file numeric.c =item grok_number_flags X Recognise (or not) a number. The type of the number is returned (0 if unrecognised), otherwise it is a bit-ORed combination of IS_NUMBER_IN_UV, IS_NUMBER_GREATER_THAN_UV_MAX, IS_NUMBER_NOT_INT, IS_NUMBER_NEG, IS_NUMBER_INFINITY, IS_NUMBER_NAN (defined in perl.h). If the value of the number can fit in a UV, it is returned in the *valuep IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV will never be set unless *valuep is valid, but *valuep may have been assigned to during processing even though IS_NUMBER_IN_UV is not set on return. If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when valuep is non-NULL, but no actual assignment (or SEGV) will occur. IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were seen (in which case *valuep gives the true value truncated to an integer), and IS_NUMBER_NEG if the number is negative (in which case *valuep holds the absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the number is larger than a UV. C allows only C, which allows for trailing non-numeric text on an otherwise successful I, setting C on the result. int grok_number_flags(const char *pv, STRLEN len, UV *valuep, U32 flags) =for hackers Found in file numeric.c =item grok_numeric_radix X Scan and skip for a numeric decimal separator (radix). bool grok_numeric_radix(const char **sp, const char *send) =for hackers Found in file numeric.c =item grok_oct X converts a string representing an octal number to numeric form. On entry I and I<*len> give the string to scan, I<*flags> gives conversion flags, and I 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 is set in I<*flags>, encountering an 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. If the value is <= UV_MAX it is returned as a UV, the output flags are clear, and nothing is written to I<*result>. If the value is > UV_MAX C returns UV_MAX, sets C in the output flags, and writes the value to I<*result> (or the value is discarded if I is NULL). If C is set in I<*flags> then the octal number may use '_' characters to separate digits. UV grok_oct(const char* start, STRLEN* len_p, I32* flags, NV *result) =for hackers Found in file numeric.c =item isinfnan X Perl_isinfnan() is utility function that returns true if the NV argument is either an infinity or a NaN, false otherwise. To test in more detail, use Perl_isinf() and Perl_isnan(). This is also the logical inverse of Perl_isfinite(). bool isinfnan(NV nv) =for hackers Found in file numeric.c =item Perl_signbit X NOTE: this function is experimental and may change or be removed without notice. Return a non-zero integer if the sign bit on an NV is set, and 0 if it is not. If Configure detects this system has a signbit() that will work with our NVs, then we just use it via the #define in perl.h. Otherwise, fall back on this implementation. The main use of this function is catching -0.0. Configure notes: This function is called 'Perl_signbit' instead of a plain 'signbit' because it is easy to imagine a system having a signbit() function or macro that doesn't happen to work with our particular choice of NVs. We shouldn't just re-#define signbit as Perl_signbit and expect the standard system headers to be happy. Also, this is a no-context function (no pTHX_) because Perl_signbit() is usually re-#defined in perl.h as a simple macro call to the system's signbit(). Users should just always call Perl_signbit(). int Perl_signbit(NV f) =for hackers Found in file numeric.c =item scan_bin X For backwards compatibility. Use C instead. NV scan_bin(const char* start, STRLEN len, STRLEN* retlen) =for hackers Found in file numeric.c =item scan_hex X For backwards compatibility. Use C instead. NV scan_hex(const char* start, STRLEN len, STRLEN* retlen) =for hackers Found in file numeric.c =item scan_oct X For backwards compatibility. Use C instead. NV scan_oct(const char* start, STRLEN len, STRLEN* retlen) =for hackers Found in file numeric.c =back =head1 Obsolete backwards compatibility functions Some of these are also deprecated. You can exclude these from your compiled Perl by adding this option to Configure: C<-Accflags='-DNO_MATHOMS'> =over 8 =item custom_op_desc X 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 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 See L. GV* gv_fetchmethod(HV* stash, const char* name) =for hackers Found in file mathoms.c =item is_utf8_char X DEPRECATED! It is planned to remove this function from a future release of Perl. Do not use it for new code; remove it from existing code. Tests if some arbitrary number of bytes begins in a valid UTF-8 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC machines) character is a valid UTF-8 character. The actual number of bytes in the UTF-8 character will be returned if it is valid, otherwise 0. This function is deprecated due to the possibility that malformed input could cause reading beyond the end of the input buffer. Use L instead. STRLEN is_utf8_char(const U8 *s) =for hackers Found in file mathoms.c =item is_utf8_char_buf X This is identical to the macro L. STRLEN is_utf8_char_buf(const U8 *buf, const U8 *buf_end) =for hackers Found in file mathoms.c =item pack_cat X The engine implementing pack() Perl function. Note: parameters next_in_list and flags are not used. This call should not be used; use packlist instead. void pack_cat(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags) =for hackers Found in file mathoms.c =item pad_compname_type X Looks up the type of the lexical variable at position I in the currently-compiling pad. If the variable is typed, the stash of the class to which it is typed is returned. If not, C is returned. HV * pad_compname_type(PADOFFSET po) =for hackers Found in file mathoms.c =item sv_2pvbyte_nolen X Return a pointer to the byte-encoded representation of the SV. May cause the SV to be downgraded from UTF-8 as a side-effect. Usually accessed via the C macro. char* sv_2pvbyte_nolen(SV* sv) =for hackers Found in file mathoms.c =item sv_2pvutf8_nolen X Return a pointer to the UTF-8-encoded representation of the SV. May cause the SV to be upgraded to UTF-8 as a side-effect. Usually accessed via the C macro. char* sv_2pvutf8_nolen(SV* sv) =for hackers Found in file mathoms.c =item sv_2pv_nolen X Like C, but doesn't return the length too. You should usually use the macro wrapper C instead. char* sv_2pv_nolen(SV* sv) =for hackers Found in file mathoms.c =item sv_catpvn_mg X Like C, but also handles 'set' magic. void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len) =for hackers Found in file mathoms.c =item sv_catsv_mg X Like C, but also handles 'set' magic. void sv_catsv_mg(SV *dsv, SV *ssv) =for hackers Found in file mathoms.c =item sv_force_normal X Undo various types of fakery on an SV: if the PV is a shared string, make a private copy; if we're a ref, stop refing; if we're a glob, downgrade to an xpvmg. See also C. void sv_force_normal(SV *sv) =for hackers Found in file mathoms.c =item sv_iv X A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. IV sv_iv(SV* sv) =for hackers Found in file mathoms.c =item sv_nolocking X Dummy routine which "locks" an SV when there is no locking module present. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness. "Superseded" by sv_nosharing(). void sv_nolocking(SV *sv) =for hackers Found in file mathoms.c =item sv_nounlocking X Dummy routine which "unlocks" an SV when there is no locking module present. Exists to avoid test for a NULL function pointer and because it could potentially warn under some level of strict-ness. "Superseded" by sv_nosharing(). void sv_nounlocking(SV *sv) =for hackers Found in file mathoms.c =item sv_nv X A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. NV sv_nv(SV* sv) =for hackers Found in file mathoms.c =item sv_pv X Use the C macro instead char* sv_pv(SV *sv) =for hackers Found in file mathoms.c =item sv_pvbyte X Use C instead. char* sv_pvbyte(SV *sv) =for hackers Found in file mathoms.c =item sv_pvbyten X A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. char* sv_pvbyten(SV *sv, STRLEN *lp) =for hackers Found in file mathoms.c =item sv_pvn X A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. char* sv_pvn(SV *sv, STRLEN *lp) =for hackers Found in file mathoms.c =item sv_pvutf8 X Use the C macro instead char* sv_pvutf8(SV *sv) =for hackers Found in file mathoms.c =item sv_pvutf8n X A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. char* sv_pvutf8n(SV *sv, STRLEN *lp) =for hackers Found in file mathoms.c =item sv_taint X Taint an SV. Use C instead. void sv_taint(SV* sv) =for hackers Found in file mathoms.c =item sv_unref X Unsets the RV status of the SV, and decrements the reference count of whatever was being referenced by the RV. This can almost be thought of as a reversal of C. This is C with the C being zero. See C. void sv_unref(SV* sv) =for hackers Found in file mathoms.c =item sv_usepvn X Tells an SV to use C to find its string value. Implemented by calling C with C of 0, hence does not handle 'set' magic. See C. void sv_usepvn(SV* sv, char* ptr, STRLEN len) =for hackers Found in file mathoms.c =item sv_usepvn_mg X Like C, but also handles 'set' magic. void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len) =for hackers Found in file mathoms.c =item sv_uv X A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. UV sv_uv(SV* sv) =for hackers Found in file mathoms.c =item unpack_str X The engine implementing unpack() Perl function. Note: parameters strbeg, new_s and ocnt are not used. This call should not be used, use unpackstring instead. I32 unpack_str(const char *pat, const char *patend, const char *s, const char *strbeg, const char *strend, char **new_s, I32 ocnt, U32 flags) =for hackers Found in file mathoms.c =item utf8_to_uvchr X DEPRECATED! It is planned to remove this function from a future release of Perl. Do not use it for new code; remove it from existing code. Returns the native code point of the first character in the string C which is assumed to be in UTF-8 encoding; C will be set to the length, in bytes, of that character. Some, but not all, UTF-8 malformations are detected, and in fact, some malformed input could cause reading beyond the end of the input buffer, which is why this function is deprecated. Use L instead. If C points to one of the detected malformations, and UTF8 warnings are enabled, zero is returned and C<*retlen> is set (if C isn't NULL) to -1. If those warnings are off, the computed value if well-defined (or the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen> is set (if C isn't NULL) so that (S + C<*retlen>>) is the next possible position in C that could begin a non-malformed character. See L for details on when the REPLACEMENT CHARACTER is returned. UV utf8_to_uvchr(const U8 *s, STRLEN *retlen) =for hackers Found in file mathoms.c =item utf8_to_uvuni X DEPRECATED! It is planned to remove this function from a future release of Perl. Do not use it for new code; remove it from existing code. Returns the Unicode code point of the first character in the string C which is assumed to be in UTF-8 encoding; C will be set to the length, in bytes, of that character. Some, but not all, UTF-8 malformations are detected, and in fact, some malformed input could cause reading beyond the end of the input buffer, which is one reason why this function is deprecated. The other is that only in extremely limited circumstances should the Unicode versus native code point be of any interest to you. See L for alternatives. If C points to one of the detected malformations, and UTF8 warnings are enabled, zero is returned and C<*retlen> is set (if C doesn't point to NULL) to -1. If those warnings are off, the computed value if well-defined (or the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen> is set (if C isn't NULL) so that (S + C<*retlen>>) is the next possible position in C that could begin a non-malformed character. See L for details on when the REPLACEMENT CHARACTER is returned. UV utf8_to_uvuni(const U8 *s, STRLEN *retlen) =for hackers Found in file mathoms.c =back =head1 Optree construction =over 8 =item newASSIGNOP X Constructs, checks, and returns an assignment op. I and I supply the parameters of the assignment; they are consumed by this function and become part of the constructed op tree. If I is C, C, or C, then a suitable conditional optree is constructed. If I is the opcode of a binary operator, such as C, then an op is constructed that performs the binary operation and assigns the result to the left argument. Either way, if I is non-zero then I has no effect. If I is zero, then a plain scalar or list assignment is constructed. Which type of assignment it is is automatically determined. I gives the eight bits of C, except that C will be set automatically, and, shifted up eight bits, the eight bits of C, 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 Constructs, checks, and returns an op of any binary type. I is the opcode. I gives the eight bits of C, except that C will be set automatically, and, shifted up eight bits, the eight bits of C, except that the bit with value 1 or 2 is automatically set as required. I and I 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 Constructs, checks, and returns a conditional-expression (C) op. I gives the eight bits of C, except that C will be set automatically, and, shifted up eight bits, the eight bits of C, except that the bit with value 1 is automatically set. I supplies the expression selecting between the two branches, and I and I 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 newDEFSVOP X Constructs and returns an op to access C<$_>, either as a lexical variable (if declared as C) in the current scope, or the global C<$_>. OP * newDEFSVOP() =for hackers Found in file op.c =item newFOROP X Constructs, checks, and returns an op tree expressing a C loop (iteration through a list of values). This is a heavyweight loop, with structure that allows exiting the loop by C and suchlike. I optionally supplies the variable that will be aliased to each item in turn; if null, it defaults to C<$_> (either lexical or global). I supplies the list of values to iterate over. I supplies the main body of the loop, and I optionally supplies a C 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 gives the eight bits of C for the C op and, shifted up eight bits, the eight bits of C for the C 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 Constructs, checks, and returns an op tree expressing a C block. I supplies the expression that will be locally assigned to a lexical variable, and I supplies the body of the C construct; they are consumed by this function and become part of the constructed op tree. I is the pad offset of the scalar lexical variable that will be affected. If it is 0, the global $_ will be used. OP * newGIVENOP(OP *cond, OP *block, PADOFFSET defsv_off) =for hackers Found in file op.c =item newGVOP X Constructs, checks, and returns an op of any type that involves an embedded reference to a GV. I is the opcode. I gives the eight bits of C. I 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 Constructs, checks, and returns an op of any list type. I is the opcode. I gives the eight bits of C, except that C will be set automatically if required. I and I 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. For most list operators, the check function expects all the kid ops to be present already, so calling C (e.g.) is not appropriate. What you want to do in that case is create an op of type OP_LIST, append more children to it, and then call L. See L for more information. OP * newLISTOP(I32 type, I32 flags, OP *first, OP *last) =for hackers Found in file op.c =item newLOGOP X Constructs, checks, and returns a logical (flow control) op. I is the opcode. I gives the eight bits of C, except that C will be set automatically, and, shifted up eight bits, the eight bits of C, except that the bit with value 1 is automatically set. I supplies the expression controlling the flow, and I 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 Constructs, checks, and returns a loop-exiting op (such as C or C). I is the opcode. I or L or L. Set the value of the PV pointer in C to the Perl allocated C-terminated string C. See also C. Remember to free the previous PV buffer. There are many things to check. Beware that the existing pointer may be involved in copy-on-write or other mischief, so do C and use C or C (or check the SvIsCOW flag) first to make sure this modification is safe. Then finally, if it is not a COW, call C to free the previous PV buffer. void SvPV_set(SV* sv, char* val) =for hackers Found in file sv.h =item SvREFCNT X Returns the value of the object's reference count. U32 SvREFCNT(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_dec X Decrements the reference count of the given SV. I may be NULL. void SvREFCNT_dec(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_dec_NN X Same as SvREFCNT_dec, but can only be used if you know I is not NULL. Since we don't have to check the NULLness, it's faster and smaller. void SvREFCNT_dec_NN(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc X Increments the reference count of the given SV, returning the SV. All of the following SvREFCNT_inc* macros are optimized versions of SvREFCNT_inc, and can be replaced with SvREFCNT_inc. SV* SvREFCNT_inc(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_NN X Same as SvREFCNT_inc, but can only be used if you know I is not NULL. Since we don't have to check the NULLness, it's faster and smaller. SV* SvREFCNT_inc_NN(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_simple X Same as SvREFCNT_inc, but can only be used with expressions without side effects. Since we don't have to store a temporary value, it's faster. SV* SvREFCNT_inc_simple(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_simple_NN X Same as SvREFCNT_inc_simple, but can only be used if you know I is not NULL. Since we don't have to check the NULLness, it's faster and smaller. SV* SvREFCNT_inc_simple_NN(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_simple_void X Same as SvREFCNT_inc_simple, but can only be used if you don't need the return value. The macro doesn't need to return a meaningful value. void SvREFCNT_inc_simple_void(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_simple_void_NN X Same as SvREFCNT_inc, but can only be used if you don't need the return value, and you know that I is not NULL. The macro doesn't need to return a meaningful value, or check for NULLness, so it's smaller and faster. void SvREFCNT_inc_simple_void_NN(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_void X Same as SvREFCNT_inc, but can only be used if you don't need the return value. The macro doesn't need to return a meaningful value. void SvREFCNT_inc_void(SV* sv) =for hackers Found in file sv.h =item SvREFCNT_inc_void_NN X Same as SvREFCNT_inc, but can only be used if you don't need the return value, and you know that I is not NULL. The macro doesn't need to return a meaningful value, or check for NULLness, so it's smaller and faster. void SvREFCNT_inc_void_NN(SV* sv) =for hackers Found in file sv.h =item SvROK X Tests if the SV is an RV. U32 SvROK(SV* sv) =for hackers Found in file sv.h =item SvROK_off X Unsets the RV status of an SV. void SvROK_off(SV* sv) =for hackers Found in file sv.h =item SvROK_on X Tells an SV that it is an RV. void SvROK_on(SV* sv) =for hackers Found in file sv.h =item SvRV X Dereferences an RV to return the SV. SV* SvRV(SV* sv) =for hackers Found in file sv.h =item SvRV_set X Set the value of the RV pointer in sv to val. See C. void SvRV_set(SV* sv, SV* val) =for hackers Found in file sv.h =item SvSTASH X Returns the stash of the SV. HV* SvSTASH(SV* sv) =for hackers Found in file sv.h =item SvSTASH_set X Set the value of the STASH pointer in sv to val. See C. void SvSTASH_set(SV* sv, HV* val) =for hackers Found in file sv.h =item SvTAINT X Taints an SV if tainting is enabled, and if some input to the current expression is tainted--usually a variable, but possibly also implicit inputs such as locale settings. C propagates that taintedness to the outputs of an expression in a pessimistic fashion; i.e., without paying attention to precisely which outputs are influenced by which inputs. void SvTAINT(SV* sv) =for hackers Found in file sv.h =item SvTAINTED X Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if not. bool SvTAINTED(SV* sv) =for hackers Found in file sv.h =item SvTAINTED_off X Untaints an SV. Be I careful with this routine, as it short-circuits some of Perl's fundamental security features. XS module authors should not use this function unless they fully understand all the implications of unconditionally untainting the value. Untainting should be done in the standard perl fashion, via a carefully crafted regexp, rather than directly untainting variables. void SvTAINTED_off(SV* sv) =for hackers Found in file sv.h =item SvTAINTED_on X Marks an SV as tainted if tainting is enabled. void SvTAINTED_on(SV* sv) =for hackers Found in file sv.h =item SvTRUE X Returns a boolean indicating whether Perl would evaluate the SV as true or 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 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 Returns the type of the SV. See C. svtype SvTYPE(SV* sv) =for hackers Found in file sv.h =item SvUOK X Returns a boolean indicating whether the SV contains an integer that must be interpreted as unsigned. A non-negative integer whose value is within the range of both an IV and a UV may be be flagged as either SvUOK or SVIOK. bool SvUOK(SV* sv) =for hackers Found in file sv.h =item SvUPGRADE X Used to upgrade an SV to a more complex form. Uses C to perform the upgrade if necessary. See C. void SvUPGRADE(SV* sv, svtype type) =for hackers Found in file sv.h =item SvUTF8 X Returns a U32 value indicating the UTF-8 status of an SV. If things are set-up properly, this indicates whether or not the SV contains UTF-8 encoded data. You should use this I a call to SvPV() or one of its variants, in case any call to string overloading updates the internal flag. If you want to take into account the L pragma, use C> instead. U32 SvUTF8(SV* sv) =for hackers Found in file sv.h =item SvUTF8_off X Unsets the UTF-8 status of an SV (the data is not changed, just the flag). Do not use frivolously. void SvUTF8_off(SV *sv) =for hackers Found in file sv.h =item SvUTF8_on X Turn on the UTF-8 status of an SV (the data is not changed, just the flag). Do not use frivolously. void SvUTF8_on(SV *sv) =for hackers Found in file sv.h =item SvUV X Coerces the given SV to an unsigned integer and returns it. See C for a version which guarantees to evaluate sv only once. UV SvUV(SV* sv) =for hackers Found in file sv.h =item SvUVX X Returns the raw value in the SV's UV slot, without checks or conversions. Only use when you are sure SvIOK is true. See also C. UV SvUVX(SV* sv) =for hackers Found in file sv.h =item SvUVx X Coerces the given SV to an unsigned integer and returns it. Guarantees to evaluate C only once. Only use this if C is an expression with side effects, otherwise use the more efficient C. UV SvUVx(SV* sv) =for hackers Found in file sv.h =item SvUV_nomg X Like C but doesn't process magic. UV SvUV_nomg(SV* sv) =for hackers Found in file sv.h =item SvUV_set X Set the value of the UV pointer in sv to val. See C. void SvUV_set(SV* sv, UV val) =for hackers Found in file sv.h =item SvVOK X Returns a boolean indicating whether the SV contains a v-string. bool SvVOK(SV* sv) =for hackers Found in file sv.h =item sv_catpvn_nomg X Like C but doesn't process magic. void sv_catpvn_nomg(SV* sv, const char* ptr, STRLEN len) =for hackers Found in file sv.h =item sv_catpv_nomg X Like C 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 Like C but doesn't process magic. void sv_catsv_nomg(SV* dsv, SV* ssv) =for hackers Found in file sv.h =item sv_derived_from X Exactly like L, but doesn't take a C parameter. bool sv_derived_from(SV* sv, const char *const name) =for hackers Found in file universal.c =item sv_derived_from_pv X Exactly like L, but takes a nul-terminated string instead of a string/length pair. bool sv_derived_from_pv(SV* sv, const char *const name, U32 flags) =for hackers Found in file universal.c =item sv_derived_from_pvn X Returns a boolean indicating whether the SV is derived from the specified class I. To check derivation at the Perl level, call C as a normal Perl method. Currently, the only significant value for C is SVf_UTF8. bool sv_derived_from_pvn(SV* sv, const char *const name, const STRLEN len, U32 flags) =for hackers Found in file universal.c =item sv_derived_from_sv X Exactly like L, but takes the name string in the form of an SV instead of a string/length pair. bool sv_derived_from_sv(SV* sv, SV *namesv, U32 flags) =for hackers Found in file universal.c =item sv_does X Like L, but doesn't take a C parameter. bool sv_does(SV* sv, const char *const name) =for hackers Found in file universal.c =item sv_does_pv X Like L, but takes a nul-terminated string instead of an SV. bool sv_does_pv(SV* sv, const char *const name, U32 flags) =for hackers Found in file universal.c =item sv_does_pvn X Like L, but takes a string/length pair instead of an SV. bool sv_does_pvn(SV* sv, const char *const name, const STRLEN len, U32 flags) =for hackers Found in file universal.c =item sv_does_sv X Returns a boolean indicating whether the SV performs a specific, named role. The SV can be a Perl object or the name of a Perl class. bool sv_does_sv(SV* sv, SV* namesv, U32 flags) =for hackers Found in file universal.c =item sv_report_used X Dump the contents of all SVs not yet freed (debugging aid). void sv_report_used() =for hackers Found in file sv.c =item sv_setsv_nomg X Like C but doesn't process magic. void sv_setsv_nomg(SV* dsv, SV* ssv) =for hackers Found in file sv.h =item sv_utf8_upgrade_nomg X Like sv_utf8_upgrade, but doesn't do magic on C. STRLEN sv_utf8_upgrade_nomg(NN SV *sv) =for hackers Found in file sv.h =back =head1 SV-Body Allocation =over 8 =item looks_like_number X Test if the content of an SV looks like a number (or is a number). C and C are treated as numbers (so will not issue a non-numeric warning), even if your atof() doesn't grok them. Get-magic is ignored. I32 looks_like_number(SV *const sv) =for hackers Found in file sv.c =item newRV_noinc X Creates an RV wrapper for an SV. The reference count for the original SV is B incremented. SV* newRV_noinc(SV *const tmpRef) =for hackers Found in file sv.c =item newSV X Creates a new SV. A non-zero C parameter indicates the number of bytes of preallocated string space the SV should have. An extra byte for a trailing C is also reserved. (SvPOK is not set for the SV even if string space is allocated.) The reference count for the new SV is set to 1. In 5.9.3, newSV() replaces the older NEWSV() API, and drops the first parameter, I, a debug aid which allowed callers to identify themselves. This aid has been superseded by a new build option, PERL_MEM_LOG (see L). The older API is still there for use in XS modules supporting older perls. SV* newSV(const STRLEN len) =for hackers Found in file sv.c =item newSVhek X Creates a new SV from the hash key structure. It will generate scalars that point to the shared string table where possible. Returns a new (undefined) SV if the hek is NULL. SV* newSVhek(const HEK *const hek) =for hackers Found in file sv.c =item newSViv X Creates a new SV and copies an integer into it. The reference count for the SV is set to 1. SV* newSViv(const IV i) =for hackers Found in file sv.c =item newSVnv X Creates a new SV and copies a floating point value into it. The reference count for the SV is set to 1. SV* newSVnv(const NV n) =for hackers Found in file sv.c =item newSVpv X Creates a new SV and copies a string (which may contain C (C<\0>) characters) into it. The reference count for the SV is set to 1. If C is zero, Perl will compute the length using strlen(), (which means if you use this option, that C can't have embedded C characters and has to have a terminating C byte). For efficiency, consider using C instead. SV* newSVpv(const char *const s, const STRLEN len) =for hackers Found in file sv.c =item newSVpvf X Creates a new SV and initializes it with the string formatted like C. SV* newSVpvf(const char *const pat, ...) =for hackers Found in file sv.c =item newSVpvn X Creates a new SV and copies a string into it, which may contain C characters (C<\0>) and other binary data. The reference count for the SV is set to 1. Note that if C is zero, Perl will create a zero length (Perl) string. You are responsible for ensuring that the source buffer is at least C bytes long. If the C argument is NULL the new SV will be undefined. SV* newSVpvn(const char *const s, const STRLEN len) =for hackers Found in file sv.c =item newSVpvn_flags X Creates a new SV and copies a string (which may contain C (C<\0>) characters) into it. The reference count for the SV is set to 1. Note that if C is zero, Perl will create a zero length string. You are responsible for ensuring that the source string is at least C bytes long. If the C argument is NULL the new SV will be undefined. Currently the only flag bits accepted are C and C. If C is set, then C is called on the result before returning. If C is set, C is considered to be in UTF-8 and the C flag will be set on the new SV. C is a convenience wrapper for this function, defined as #define newSVpvn_utf8(s, len, u) \ newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) SV* newSVpvn_flags(const char *const s, const STRLEN len, const U32 flags) =for hackers Found in file sv.c =item newSVpvn_share X Creates a new SV with its SvPVX_const pointing to a shared string in the string table. If the string does not already exist in the table, it is created first. Turns on the SvIsCOW flag (or READONLY and FAKE in 5.16 and earlier). If the C parameter is non-zero, that value is used; otherwise the hash is computed. The string's hash can later be retrieved from the SV with the C macro. The idea here is that as the string table is used for shared hash keys these strings will have SvPVX_const == HeKEY and hash lookup will avoid string compare. SV* newSVpvn_share(const char* s, I32 len, U32 hash) =for hackers Found in file sv.c =item newSVpvs X Like C, but takes a literal C-terminated string instead of a string/length pair. SV* newSVpvs(const char* s) =for hackers Found in file handy.h =item newSVpvs_flags X Like C, but takes a literal C-terminated string instead of a string/length pair. SV* newSVpvs_flags(const char* s, U32 flags) =for hackers Found in file handy.h =item newSVpvs_share X Like C, but takes a literal C-terminated string instead of a string/length pair and omits the hash parameter. SV* newSVpvs_share(const char* s) =for hackers Found in file handy.h =item newSVpv_share X Like C, but takes a C-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 Creates a new SV for the existing RV, C, to point to. If C is not an RV then it will be upgraded to one. If C is non-null then the new SV will be blessed in the specified package. The new SV is returned and its reference count is 1. The reference count 1 is owned by C. SV* newSVrv(SV *const rv, const char *const classname) =for hackers Found in file sv.c =item newSVsv X Creates a new SV which is an exact duplicate of the original SV. (Uses C.) SV* newSVsv(SV *const old) =for hackers Found in file sv.c =item newSVuv X Creates a new SV and copies an unsigned integer into it. The reference count for the SV is set to 1. SV* newSVuv(const UV u) =for hackers Found in file sv.c =item newSV_type X Creates a new SV, of the type specified. The reference count for the new SV is set to 1. SV* newSV_type(const svtype type) =for hackers Found in file sv.c =item sv_2bool X 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 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 *sv, I32 flags) =for hackers Found in file sv.c =item sv_2cv X Using various gambits, try to get a CV from an SV; in addition, try if possible to set C<*st> and C<*gvp> to the stash and GV associated with it. The flags in C are passed to gv_fetchsv. CV* sv_2cv(SV* sv, HV **const st, GV **const gvp, const I32 lref) =for hackers Found in file sv.c =item sv_2io X Using various gambits, try to get an IO from an SV: the IO slot if its a GV; or the recursive result if we're an RV; or the IO slot of the symbol named after the PV if we're a string. 'Get' magic is ignored on the sv passed in, but will be called on C if sv is an RV. IO* sv_2io(SV *const sv) =for hackers Found in file sv.c =item sv_2iv_flags X Return the integer value of an SV, doing any necessary string conversion. If flags includes SV_GMAGIC, does an mg_get() first. Normally used via the C and C macros. IV sv_2iv_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c =item sv_2mortal X Marks an existing SV as mortal. The SV will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. SvTEMP() is turned on which means that the SV's string buffer can be "stolen" if this SV is copied. See also C and C. SV* sv_2mortal(SV *const sv) =for hackers Found in file sv.c =item sv_2nv_flags X Return the num value of an SV, doing any necessary string or integer conversion. If flags includes SV_GMAGIC, does an mg_get() first. Normally used via the C and C macros. NV sv_2nv_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c =item sv_2pvbyte X Return a pointer to the byte-encoded representation of the SV, and set *lp to its length. May cause the SV to be downgraded from UTF-8 as a side-effect. Usually accessed via the C macro. char* sv_2pvbyte(SV *sv, STRLEN *const lp) =for hackers Found in file sv.c =item sv_2pvutf8 X Return a pointer to the UTF-8-encoded representation of the SV, and set *lp to its length. May cause the SV to be upgraded to UTF-8 as a side-effect. Usually accessed via the C macro. char* sv_2pvutf8(SV *sv, STRLEN *const lp) =for hackers Found in file sv.c =item sv_2pv_flags X Returns a pointer to the string value of an SV, and sets *lp to its length. If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string if necessary. Normally invoked via the C macro. C and C usually end up here too. char* sv_2pv_flags(SV *const sv, STRLEN *const lp, const I32 flags) =for hackers Found in file sv.c =item sv_2uv_flags X Return the unsigned integer value of an SV, doing any necessary string conversion. If flags includes SV_GMAGIC, does an mg_get() first. Normally used via the C and C macros. UV sv_2uv_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c =item sv_backoff X Remove any string offset. You should normally use the C macro wrapper instead. int sv_backoff(SV *const sv) =for hackers Found in file sv.c =item sv_bless X Blesses an SV into a specified package. The SV must be an RV. The package must be designated by its stash (see C). The reference count of the SV is unaffected. SV* sv_bless(SV *const sv, HV *const stash) =for hackers Found in file sv.c =item sv_catpv X Concatenates the C-terminated 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. Handles 'get' magic, but not 'set' magic. See C. void sv_catpv(SV *const sv, const char* ptr) =for hackers Found in file sv.c =item sv_catpvf X Processes its arguments like C and appends the formatted output to an SV. If the appended data contains "wide" characters (including, but not limited to, SVs with a UTF-8 PV formatted with %s, and characters >255 formatted with %c), the original SV might get upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. See C. If the original SV was UTF-8, the pattern should be valid UTF-8; if the original SV was bytes, the pattern should be too. void sv_catpvf(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c =item sv_catpvf_mg X Like C, but also handles 'set' magic. void sv_catpvf_mg(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c =item sv_catpvn X Concatenates the string onto the end of the string which is in the SV. The C indicates number of bytes to copy. If the SV has the UTF-8 status set, then the bytes appended should be valid UTF-8. Handles 'get' magic, but not 'set' magic. See C. void sv_catpvn(SV *dsv, const char *sstr, STRLEN len) =for hackers Found in file sv.c =item sv_catpvn_flags X Concatenates the string onto the end of the string which is in the SV. The C indicates number of bytes to copy. By default, the string appended is assumed to be valid UTF-8 if the SV has the UTF-8 status set, and a string of bytes otherwise. One can force the appended string to be interpreted as UTF-8 by supplying the C flag, and as bytes by supplying the C flag; the SV or the string appended will be upgraded to UTF-8 if necessary. If C has the C bit set, will C on C afterwards if appropriate. C and C are implemented in terms of this function. void sv_catpvn_flags(SV *const dstr, const char *sstr, const STRLEN len, const I32 flags) =for hackers Found in file sv.c =item sv_catpvs X Like C, but takes a literal string instead of a string/length pair. void sv_catpvs(SV* sv, const char* s) =for hackers Found in file handy.h =item sv_catpvs_flags X Like C, but takes a literal C-terminated 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 Like C, 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 Like C, 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 Concatenates the C-terminated 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 has the C bit set, will C on the modified SV if appropriate. void sv_catpv_flags(SV *dstr, const char *sstr, const I32 flags) =for hackers Found in file sv.c =item sv_catpv_mg X Like C, but also handles 'set' magic. void sv_catpv_mg(SV *const sv, const char *const ptr) =for hackers Found in file sv.c =item sv_catsv X Concatenates the string from SV C onto the end of the string in SV C. If C is null, does nothing; otherwise modifies only C. Handles 'get' magic on both SVs, but no 'set' magic. See C and C. void sv_catsv(SV *dstr, SV *sstr) =for hackers Found in file sv.c =item sv_catsv_flags X Concatenates the string from SV C onto the end of the string in SV C. If C is null, does nothing; otherwise modifies only C. If C include C bit set, will call C on both SVs if appropriate. If C include C, C will be called on the modified SV afterward, if appropriate. C, C, and C are implemented in terms of this function. void sv_catsv_flags(SV *const dsv, SV *const ssv, const I32 flags) =for hackers Found in file sv.c =item sv_chop X Efficient removal of characters from the beginning of the string buffer. SvPOK(sv), or at least SvPOKp(sv), must be true and the C must be a pointer to somewhere inside the string buffer. The C becomes the first character of the adjusted string. Uses the "OOK hack". On return, only SvPOK(sv) and SvPOKp(sv) among the OK flags will be true. Beware: after this function returns, C and SvPVX_const(sv) may no longer refer to the same chunk of data. The unfortunate similarity of this function's name to that of Perl's C operator is strictly coincidental. This function works from the left; C works from the right. void sv_chop(SV *const sv, const char *const ptr) =for hackers Found in file sv.c =item sv_clear X Clear an SV: call any destructors, free up any memory used by the body, and free the body itself. The SV's head is I freed, although its type is set to all 1's so that it won't inadvertently be assumed to be live during global destruction etc. This function should only be called when REFCNT is zero. Most of the time you'll want to call C (or its macro wrapper C) instead. void sv_clear(SV *const orig_sv) =for hackers Found in file sv.c =item sv_cmp X Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the string in C is less than, equal to, or greater than the string in C. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. See also C. I32 sv_cmp(SV *const sv1, SV *const sv2) =for hackers Found in file sv.c =item sv_cmp_flags X Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the string in C is less than, equal to, or greater than the string in C. 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. 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 Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. See also C. I32 sv_cmp_locale(SV *const sv1, SV *const sv2) =for hackers Found in file sv.c =item sv_cmp_locale_flags X 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. 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 This calls C with the SV_GMAGIC flag. See C. char* sv_collxfrm(SV *const sv, STRLEN *const nxp) =for hackers Found in file sv.c =item sv_collxfrm_flags X 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_flags(SV *const sv, STRLEN *const nxp, I32 const flags) =for hackers Found in file sv.c =item sv_copypv_flags X Implementation of sv_copypv and sv_copypv_nomg. Calls get magic iff flags include SV_GMAGIC. void sv_copypv_flags(SV *const dsv, SV *const ssv, const I32 flags) =for hackers Found in file sv.c =item sv_copypv_nomg X Like sv_copypv, but doesn't invoke get magic first. void sv_copypv_nomg(SV *const dsv, SV *const ssv) =for hackers Found in file sv.c =item sv_dec X Auto-decrement of the value in the SV, doing string to numeric conversion 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 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 Returns a boolean indicating whether the strings in the two SVs are identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. I32 sv_eq(SV* sv1, SV* sv2) =for hackers Found in file sv.c =item sv_eq_flags X 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 Undo various types of fakery on an SV, where fakery means "more than" a string: if the PV is a shared string, make a private copy; if we're a ref, stop refing; if we're a glob, downgrade to an xpvmg; if we're a copy-on-write scalar, this is the on-write time when we do the copy, and is also used locally; if this is a vstring, drop the vstring magic. If C 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 parameter gets passed to C when unreffing. C calls this function with flags set to 0. This function is expected to be used to signal to perl that this SV is about to be written to, and any extra book-keeping needs to be taken care of. Hence, it croaks on read-only values. void sv_force_normal_flags(SV *const sv, const U32 flags) =for hackers Found in file sv.c =item sv_free X Decrement an SV's reference count, and if it drops to zero, call C to invoke destructors and free up any memory used by the body; finally, deallocate the SV's head itself. Normally called via a wrapper macro C. void sv_free(SV *const sv) =for hackers Found in file sv.c =item sv_gets X Get a line from the filehandle and store it into the SV, optionally appending to the currently-stored string. If C is not 0, the line is appended to the SV instead of overwriting it. C should be set to the byte offset that the appended string should start at in the SV (typically, C is a suitable choice). char* sv_gets(SV *const sv, PerlIO *const fp, I32 append) =for hackers Found in file sv.c =item sv_get_backrefs X NOTE: this function is experimental and may change or be removed without notice. If the sv is the target of a weak reference then it returns the back references structure associated with the sv; otherwise return NULL. When returning a non-null result the type of the return is relevant. If it is an AV then the elements of the AV are the weak reference RVs which point at this item. If it is any other type then the item itself is the weak reference. See also Perl_sv_add_backref(), Perl_sv_del_backref(), Perl_sv_kill_backrefs() SV* sv_get_backrefs(SV *const sv) =for hackers Found in file sv.c =item sv_grow X Expands the character buffer in the SV. If necessary, uses C and upgrades the SV to C. Returns a pointer to the character buffer. Use the C wrapper instead. char* sv_grow(SV *const sv, STRLEN newlen) =for hackers Found in file sv.c =item sv_inc X Auto-increment of the value in the SV, doing string to numeric conversion 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 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 Inserts a string at the specified offset/length within the SV. Similar to the Perl substr() function. Handles get magic. void sv_insert(SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen) =for hackers Found in file sv.c =item sv_insert_flags X Same as C, but the extra C are passed to the C that applies to C. void sv_insert_flags(SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen, const U32 flags) =for hackers Found in file sv.c =item sv_isa X Returns a boolean indicating whether the SV is blessed into the specified class. This does not check for subtypes; use C to verify an inheritance relationship. int sv_isa(SV* sv, const char *const name) =for hackers Found in file sv.c =item sv_isobject X Returns a boolean indicating whether the SV is an RV pointing to a blessed object. If the SV is not an RV, or if the object is not blessed, then this will return false. int sv_isobject(SV* sv) =for hackers Found in file sv.c =item sv_len X Returns the length of the string in the SV. Handles magic and type coercion and sets the UTF8 flag appropriately. See also C, which gives raw access to the xpv_cur slot. STRLEN sv_len(SV *const sv) =for hackers Found in file sv.c =item sv_len_utf8 X Returns the number of characters in the string in an SV, counting wide UTF-8 bytes as a single character. Handles magic and type coercion. STRLEN sv_len_utf8(SV *const sv) =for hackers Found in file sv.c =item sv_magic X Adds magic to an SV. First upgrades C to type C if necessary, then adds a new magic item of type C to the head of the magic list. See C (which C now calls) for a description of the handling of the C and C arguments. You need to use C to add magic to SvREADONLY SVs and also to add more than one instance of the same 'how'. void sv_magic(SV *const sv, SV *const obj, const int how, const char *const name, const I32 namlen) =for hackers Found in file sv.c =item sv_magicext X Adds magic to an SV, upgrading it if necessary. Applies the supplied vtable and returns a pointer to the magic added. Note that C will allow things that C will not. In particular, you can add magic to SvREADONLY SVs, and add more than one instance of the same 'how'. If C is greater than zero then a C I of C is stored, if C is zero then C is stored as-is and - as another special case - if C<(name && namlen == HEf_SVKEY)> then C is assumed to contain an C and is stored as-is with its REFCNT incremented. (This is now used as a subroutine by C.) MAGIC * sv_magicext(SV *const sv, SV *const obj, const int how, const MGVTBL *const vtbl, const char *const name, const I32 namlen) =for hackers Found in file sv.c =item sv_mortalcopy X Creates a new SV which is a copy of the original SV (using C). The new SV is marked as mortal. It will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. See also C and C. SV* sv_mortalcopy(SV *const oldsv) =for hackers Found in file sv.c =item sv_newmortal X Creates a new null SV which is mortal. The reference count of the SV is set to 1. It will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. See also C and C. SV* sv_newmortal() =for hackers Found in file sv.c =item sv_newref X Increment an SV's reference count. Use the C wrapper instead. SV* sv_newref(SV *const sv) =for hackers Found in file sv.c =item sv_pos_b2u X Converts the value pointed to by offsetp from a count of bytes from the start of the string, to a count of the equivalent number of UTF-8 chars. Handles magic and type coercion. Use C in preference, which correctly handles strings longer than 2Gb. void sv_pos_b2u(SV *const sv, I32 *const offsetp) =for hackers Found in file sv.c =item sv_pos_b2u_flags X Converts the offset from a count of bytes from the start of the string, to a count of the equivalent number of UTF-8 chars. Handles type coercion. I is passed to C, and usually should be C to handle magic. STRLEN sv_pos_b2u_flags(SV *const sv, STRLEN const offset, U32 flags) =for hackers Found in file sv.c =item sv_pos_u2b X Converts the value pointed to by offsetp from a count of UTF-8 chars from the start of the string, to a count of the equivalent number of bytes; if lenp is non-zero, it does the same to lenp, but this time starting from the offset, rather than from the start of the string. Handles magic and type coercion. Use C in preference, which correctly handles strings longer than 2Gb. void sv_pos_u2b(SV *const sv, I32 *const offsetp, I32 *const lenp) =for hackers Found in file sv.c =item sv_pos_u2b_flags X Converts the offset from a count of UTF-8 chars from the start of the string, to a count of the equivalent number of bytes; if lenp is non-zero, it does the same to lenp, but this time starting from the offset, rather than from the start of the string. Handles type coercion. I is passed to C, and usually should be C to handle magic. STRLEN sv_pos_u2b_flags(SV *const sv, STRLEN uoffset, STRLEN *const lenp, U32 flags) =for hackers Found in file sv.c =item sv_pvbyten_force X The backend for the C macro. Always use the macro instead. char* sv_pvbyten_force(SV *const sv, STRLEN *const lp) =for hackers Found in file sv.c =item sv_pvn_force X Get a sensible string out of the SV somehow. A private implementation of the C macro for compilers which can't cope with complex macro expressions. Always use the macro instead. char* sv_pvn_force(SV* sv, STRLEN* lp) =for hackers Found in file sv.c =item sv_pvn_force_flags X Get a sensible string out of the SV somehow. If C has C bit set, will C on C if appropriate, else not. C and C are implemented in terms of this function. You normally want to use the various wrapper macros instead: see C and C char* sv_pvn_force_flags(SV *const sv, STRLEN *const lp, const I32 flags) =for hackers Found in file sv.c =item sv_pvutf8n_force X The backend for the C macro. Always use the macro instead. char* sv_pvutf8n_force(SV *const sv, STRLEN *const lp) =for hackers Found in file sv.c =item sv_reftype X Returns a string describing what the SV is a reference to. const char* sv_reftype(const SV *const sv, const int ob) =for hackers Found in file sv.c =item sv_replace X Make the first argument a copy of the second, then delete the original. The target SV physically takes over ownership of the body of the source SV and inherits its flags; however, the target keeps any magic it owns, and any magic in the source is discarded. Note that this is a rather specialist SV copying operation; most of the time you'll want to use C or one of its many macro front-ends. void sv_replace(SV *const sv, SV *const nsv) =for hackers Found in file sv.c =item sv_reset X Underlying implementation for the C Perl function. Note that the perl-level function is vaguely deprecated. void sv_reset(const char* s, HV *const stash) =for hackers Found in file sv.c =item sv_rvweaken X Weaken a reference: set the C flag on this RV; give the referred-to SV C magic if it hasn't already; and push a back-reference to this RV onto the array of backreferences associated with that magic. If the RV is magical, set magic will be called after the RV is cleared. SV* sv_rvweaken(SV *const sv) =for hackers Found in file sv.c =item sv_setiv X Copies an integer into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also C. void sv_setiv(SV *const sv, const IV num) =for hackers Found in file sv.c =item sv_setiv_mg X Like C, but also handles 'set' magic. void sv_setiv_mg(SV *const sv, const IV i) =for hackers Found in file sv.c =item sv_setnv X Copies a double into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also C. void sv_setnv(SV *const sv, const NV num) =for hackers Found in file sv.c =item sv_setnv_mg X Like C, but also handles 'set' magic. void sv_setnv_mg(SV *const sv, const NV num) =for hackers Found in file sv.c =item sv_setpv X Copies a string into an SV. The string must be terminated with a C character. Does not handle 'set' magic. See C. void sv_setpv(SV *const sv, const char *const ptr) =for hackers Found in file sv.c =item sv_setpvf X Works like C but copies the text into the SV instead of appending it. Does not handle 'set' magic. See C. void sv_setpvf(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c =item sv_setpvf_mg X Like C, but also handles 'set' magic. void sv_setpvf_mg(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c =item sv_setpviv X Copies an integer into the given SV, also updating its string value. Does not handle 'set' magic. See C. void sv_setpviv(SV *const sv, const IV num) =for hackers Found in file sv.c =item sv_setpviv_mg X Like C, but also handles 'set' magic. void sv_setpviv_mg(SV *const sv, const IV iv) =for hackers Found in file sv.c =item sv_setpvn X Copies a string (possibly containing embedded C characters) into an SV. The C parameter indicates the number of bytes to be copied. If the C argument is NULL the SV will become undefined. Does not handle 'set' magic. See C. void sv_setpvn(SV *const sv, const char *const ptr, const STRLEN len) =for hackers Found in file sv.c =item sv_setpvn_mg X Like C, but also handles 'set' magic. void sv_setpvn_mg(SV *const sv, const char *const ptr, const STRLEN len) =for hackers Found in file sv.c =item sv_setpvs X Like C, but takes a literal string instead of a string/length pair. void sv_setpvs(SV* sv, const char* s) =for hackers Found in file handy.h =item sv_setpvs_mg X Like C, 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 Like C, but also handles 'set' magic. void sv_setpv_mg(SV *const sv, const char *const ptr) =for hackers Found in file sv.c =item sv_setref_iv X Copies an integer into a new SV, optionally blessing the SV. The C argument will be upgraded to an RV. That RV will be modified to point to the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. SV* sv_setref_iv(SV *const rv, const char *const classname, const IV iv) =for hackers Found in file sv.c =item sv_setref_nv X Copies a double into a new SV, optionally blessing the SV. The C argument will be upgraded to an RV. That RV will be modified to point to the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. SV* sv_setref_nv(SV *const rv, const char *const classname, const NV nv) =for hackers Found in file sv.c =item sv_setref_pv X Copies a pointer into a new SV, optionally blessing the SV. The C argument will be upgraded to an RV. That RV will be modified to point to the new SV. If the C argument is NULL then C will be placed into the SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. Do not use with other Perl types such as HV, AV, SV, CV, because those objects will become corrupted by the pointer copy process. Note that C copies the string while this copies the pointer. SV* sv_setref_pv(SV *const rv, const char *const classname, void *const pv) =for hackers Found in file sv.c =item sv_setref_pvn X Copies a string into a new SV, optionally blessing the SV. The length of the string must be specified with C. The C argument will be upgraded to an RV. That RV will be modified to point to the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. Note that C copies the pointer while this copies the string. SV* sv_setref_pvn(SV *const rv, const char *const classname, const char *const pv, const STRLEN n) =for hackers Found in file sv.c =item sv_setref_pvs X Like C, 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 Copies an unsigned integer into a new SV, optionally blessing the SV. The C argument will be upgraded to an RV. That RV will be modified to point to the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. SV* sv_setref_uv(SV *const rv, const char *const classname, const UV uv) =for hackers Found in file sv.c =item sv_setsv X Copies the contents of the source SV C into the destination SV C. The source SV may be destroyed if it is mortal, so don't use this function if the source SV needs to be reused. Does not handle 'set' magic on destination SV. Calls 'get' magic on source SV. Loosely speaking, it performs a copy-by-value, obliterating any previous content of the destination. You probably want to use one of the assortment of wrappers, such as C, C, C and C. void sv_setsv(SV *dstr, SV *sstr) =for hackers Found in file sv.c =item sv_setsv_flags X Copies the contents of the source SV C into the destination SV C. The source SV may be destroyed if it is mortal, so don't use this function if the source SV needs to be reused. Does not handle 'set' magic. Loosely speaking, it performs a copy-by-value, obliterating any previous content of the destination. If the C parameter has the C bit set, will C on C if appropriate, else not. If the C parameter has the C bit set then the buffers of temps will not be stolen. and C are implemented in terms of this function. You probably want to use one of the assortment of wrappers, such as C, C, C and C. This is the primary function for copying scalars, and most other copy-ish functions and macros use this underneath. void sv_setsv_flags(SV *dstr, SV *sstr, const I32 flags) =for hackers Found in file sv.c =item sv_setsv_mg X Like C, but also handles 'set' magic. void sv_setsv_mg(SV *const dstr, SV *const sstr) =for hackers Found in file sv.c =item sv_setuv X Copies an unsigned integer into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also C. void sv_setuv(SV *const sv, const UV num) =for hackers Found in file sv.c =item sv_setuv_mg X Like C, but also handles 'set' magic. void sv_setuv_mg(SV *const sv, const UV u) =for hackers Found in file sv.c =item sv_tainted X Test an SV for taintedness. Use C instead. bool sv_tainted(SV *const sv) =for hackers Found in file sv.c =item sv_true X Returns true if the SV has a true value by Perl's rules. Use the C macro instead, which may call C or may instead use an in-line version. I32 sv_true(SV *const sv) =for hackers Found in file sv.c =item sv_unmagic X Removes all magic of type C from an SV. int sv_unmagic(SV *const sv, const int type) =for hackers Found in file sv.c =item sv_unmagicext X Removes all magic of type C with the specified C 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 Unsets the RV status of the SV, and decrements the reference count of whatever was being referenced by the RV. This can almost be thought of as a reversal of C. The C argument can contain C to force the reference count to be decremented (otherwise the decrementing is conditional on the reference count being different from one or the reference being a readonly SV). See C. void sv_unref_flags(SV *const ref, const U32 flags) =for hackers Found in file sv.c =item sv_untaint X Untaint an SV. Use C instead. void sv_untaint(SV *const sv) =for hackers Found in file sv.c =item sv_upgrade X Upgrade an SV to a more complex form. Generally adds a new body type to the SV, then copies across as much information as possible from the old body. It croaks if the SV is already in a more complex form than requested. You generally want to use the C macro wrapper, which checks the type before calling C, and hence does not croak. See also C. void sv_upgrade(SV *const sv, svtype new_type) =for hackers Found in file sv.c =item sv_usepvn_flags X Tells an SV to use C to find its string value. Normally the string is stored inside the SV, but sv_usepvn allows the SV to use an outside string. The C should point to memory that was allocated by L. It must be the start of a Newx-ed block of memory, and not a pointer to the middle of it (beware of L and copy-on-write), and not be from a non-Newx memory allocator like C. The string length, C, must be supplied. By default this function will C (i.e. realloc, move) the memory pointed to by C, so that pointer should not be freed or used by the programmer after giving it to sv_usepvn, and neither should any pointers from "behind" that pointer (e.g. ptr + 1) be used. If C & SV_SMAGIC is true, will call SvSETMAGIC. If C & SV_HAS_TRAILING_NUL is true, then C must be C, and the realloc will be skipped (i.e. the buffer is actually at least 1 byte longer than C, and already meets the requirements for storing in C). void sv_usepvn_flags(SV *const sv, char* ptr, const STRLEN len, const U32 flags) =for hackers Found in file sv.c =item sv_utf8_decode X NOTE: this function is experimental and may change or be removed without notice. If the PV of the SV is an octet sequence in UTF-8 and contains a multiple-byte character, the C flag is turned on so that it looks like a character. If the PV contains only single-byte characters, the C flag stays off. Scans PV for validity and returns false if the PV is invalid UTF-8. bool sv_utf8_decode(SV *const sv) =for hackers Found in file sv.c =item sv_utf8_downgrade X NOTE: this function is experimental and may change or be removed without notice. Attempts to convert the PV of an SV from characters to bytes. If the PV contains a character that cannot fit in a byte, this conversion will fail; in this case, either returns false or, if C is not true, croaks. This is not a general purpose Unicode to byte encoding interface: use the Encode extension for that. bool sv_utf8_downgrade(SV *const sv, const bool fail_ok) =for hackers Found in file sv.c =item sv_utf8_encode X Converts the PV of an SV to UTF-8, but then turns the C flag off so that it looks like octets again. void sv_utf8_encode(SV *const sv) =for hackers Found in file sv.c =item sv_utf8_upgrade X Converts the PV of an SV to its UTF-8-encoded form. Forces the SV to string form if it is not already. Will C on C if appropriate. Always sets the SvUTF8 flag to avoid future validity checks even if the whole string is the same in UTF-8 as not. Returns the number of bytes in the converted string This is not a general purpose byte encoding to Unicode interface: use the Encode extension for that. STRLEN sv_utf8_upgrade(SV *sv) =for hackers Found in file sv.c =item sv_utf8_upgrade_flags X Converts the PV of an SV to its UTF-8-encoded form. Forces the SV to string form if it is not already. Always sets the SvUTF8 flag to avoid future validity checks even if all the bytes are invariant in UTF-8. If C has C bit set, will C on C if appropriate, else not. If C has SV_FORCE_UTF8_UPGRADE set, this function assumes that the PV will expand when converted to UTF-8, and skips the extra work of checking for that. Typically this flag is used by a routine that has already parsed the string and found such characters, and passes this information on so that the work doesn't have to be repeated. Returns the number of bytes in the converted string. This is not a general purpose byte encoding to Unicode interface: use the Encode extension for that. STRLEN sv_utf8_upgrade_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c =item sv_utf8_upgrade_flags_grow X Like sv_utf8_upgrade_flags, but has an additional parameter C, which is the number of unused bytes the string of 'sv' is guaranteed to have free after it upon return. This allows the caller to reserve extra space that it intends to fill, to avoid extra grows. C, C, and C are implemented in terms of this function. Returns the number of bytes in the converted string (not including the spares). STRLEN sv_utf8_upgrade_flags_grow(SV *const sv, const I32 flags, STRLEN extra) =for hackers Found in file sv.c =item sv_utf8_upgrade_nomg X Like sv_utf8_upgrade, but doesn't do magic on C. STRLEN sv_utf8_upgrade_nomg(SV *sv) =for hackers Found in file sv.c =item sv_vcatpvf X Processes its arguments like C and appends the formatted output to an SV. Does not handle 'set' magic. See C. Usually used via its frontend C. void sv_vcatpvf(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c =item sv_vcatpvfn X void sv_vcatpvfn(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) =for hackers Found in file sv.c =item sv_vcatpvfn_flags X Processes its arguments like C and appends the formatted output to an SV. Uses an array of SVs if the C style variable argument list is missing (NULL). When running with taint checks enabled, indicates via C if results are untrustworthy (often due to the use of locales). If called as C or flags include C, calls get magic. Usually used via one of its frontends C and C. void sv_vcatpvfn_flags(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted, const U32 flags) =for hackers Found in file sv.c =item sv_vcatpvf_mg X Like C, but also handles 'set' magic. Usually used via its frontend C. void sv_vcatpvf_mg(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c =item sv_vsetpvf X Works like C but copies the text into the SV instead of appending it. Does not handle 'set' magic. See C. Usually used via its frontend C. void sv_vsetpvf(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c =item sv_vsetpvfn X Works like C but copies the text into the SV instead of appending it. Usually used via one of its frontends C and C. void sv_vsetpvfn(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) =for hackers Found in file sv.c =item sv_vsetpvf_mg X Like C, but also handles 'set' magic. Usually used via its frontend C. void sv_vsetpvf_mg(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c =back =head1 Unicode Support L has an introduction to this API. See also L, and L. Various functions outside this section also work specially with Unicode. Search for the string "utf8" in this document. =over 8 =item bytes_cmp_utf8 X Compares the sequence of characters (stored as octets) in C, C with the sequence of characters (stored as UTF-8) in C, C. 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 there 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 NOTE: this function is experimental and may change or be removed without notice. Converts a string C of length C from UTF-8 into native byte encoding. Unlike L but like L, returns a pointer to the newly-created string, and updates C to contain the new length. Returns the original string if no conversion occurs, C is unchanged. Do nothing if C points to 0. Sets C to 0 if C is converted or consisted entirely of characters that are invariant in utf8 (i.e., US-ASCII on non-EBCDIC machines). U8* bytes_from_utf8(const U8 *s, STRLEN *len, bool *is_utf8) =for hackers Found in file utf8.c =item bytes_to_utf8 X NOTE: this function is experimental and may change or be removed without notice. Converts a string C of length C bytes from the native encoding into UTF-8. Returns a pointer to the newly-created string, and sets C to reflect the new length in bytes. A C character will be written after the end of the string. If you want to convert to UTF-8 from encodings other than the native (Latin1 or EBCDIC), see L(). U8* bytes_to_utf8(const U8 *s, STRLEN *len) =for hackers Found in file utf8.c =item DO_UTF8 X Returns a bool giving whether or not the PV in C is to be treated as being encoded in UTF-8. You should use this I a call to C or one of its variants, in case any call to string overloading updates the internal UTF-8 encoding flag. bool DO_UTF8(SV* sv) =for hackers Found in file utf8.h =item foldEQ_utf8 X Returns true if the leading portions of the strings C and C (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 C is true, the string C is assumed to be in UTF-8-encoded Unicode; otherwise it is assumed to be in native 8-bit encoding. Correspondingly for C with respect to C. If the byte length C is non-zero, it says how far into C to check for fold equality. In other words, C+C 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 C with respect to C. If C is non-NULL and the pointer it points to is not NULL, that pointer is considered an end pointer to the position 1 byte past the maximum point in C beyond which scanning will not continue under any circumstances. (This routine assumes that UTF-8 encoded input strings are not malformed; malformed input can cause it to read past C). This means that if both C and C are specified, and C is less than C+C, the match will never be successful because it can never get as far as its goal (and in fact is asserted against). Correspondingly for C with respect to C. At least one of C and C must have a goal (at least one of C and C 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 C is non-NULL, it will be set to point to the beginning of the I character of C beyond what was matched. Correspondingly for C and C. For case-insensitiveness, the "casefolding" of Unicode is used instead of upper/lowercasing both the characters, see L (Case Mappings). 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 =item isUTF8_CHAR X Returns the number of bytes beginning at C which form a legal UTF-8 (or UTF-EBCDIC) encoded character, looking no further than C bytes into C. Returns 0 if the sequence starting at C through C is not well-formed UTF-8 Note that an INVARIANT character (i.e. ASCII on non-EBCDIC machines) is a valid UTF-8 character. STRLEN isUTF8_CHAR(const U8 *s, const U8 *e) =for hackers Found in file utf8.h =item is_ascii_string X This is a misleadingly-named synonym for L. On ASCII-ish platforms, the name isn't misleading: the ASCII-range characters are exactly the UTF-8 invariants. But EBCDIC machines have more invariants than just the ASCII characters, so C is preferred. bool is_ascii_string(const U8 *s, STRLEN len) =for hackers Found in file utf8.h =item is_invariant_string X Returns true iff the first C bytes of the string C are the same regardless of the UTF-8 encoding of the string (or UTF-EBCDIC encoding on EBCDIC machines). That is, if they are UTF-8 invariant. On ASCII-ish machines, all the ASCII characters and only the ASCII characters fit this definition. On EBCDIC machines, the ASCII-range characters are invariant, but so also are the C1 controls and C<\c?> (which isn't in the ASCII range on EBCDIC). If C is 0, it will be calculated using C, (which means if you use this option, that C can't have embedded C characters and has to have a terminating C byte). See also L(), L(), and L(). bool is_invariant_string(const U8 *s, STRLEN len) =for hackers Found in file utf8.c =item is_utf8_string X Returns true if the first C bytes of string C form a valid UTF-8 string, false otherwise. If C is 0, it will be calculated using C (which means if you use this option, that C can't have embedded C characters and has to have a terminating C byte). Note that all characters being ASCII constitute 'a valid UTF-8 string'. See also L(), L(), and L(). bool is_utf8_string(const U8 *s, STRLEN len) =for hackers Found in file utf8.c =item is_utf8_string_loc X Like L but stores the location of the failure (in the case of "utf8ness failure") or the location C+C (in the case of "utf8ness success") in the C. See also L() and L(). bool is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **ep) =for hackers Found in file utf8.c =item is_utf8_string_loclen X Like L() but stores the location of the failure (in the case of "utf8ness failure") or the location C+C (in the case of "utf8ness success") in the C, and the number of UTF-8 encoded characters in the C. See also L() and L(). bool is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el) =for hackers Found in file utf8.c =item pv_uni_display X Build to the scalar C a displayable version of the string C, length C, the displayable version being at most C bytes long (if longer, the rest is truncated and "..." will be appended). The C argument can have UNI_DISPLAY_ISPRINT set to display isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH to display the \\[nrfta\\] as the backslashed versions (like '\n') (UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\). UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on. The pointer to the PV of the C is returned. See also L. char* pv_uni_display(SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim, UV flags) =for hackers Found in file utf8.c =item sv_cat_decode X The encoding is assumed to be an Encode object, the PV of the ssv is assumed to be octets in that encoding and decoding the input starts from the position which (PV + *offset) pointed to. The dsv will be concatenated the decoded UTF-8 string from ssv. Decoding will terminate when the string tstr appears in decoding output or the input ends on the PV of the ssv. The value which the offset points will be modified to the last input position on the ssv. Returns TRUE if the terminator was found, else returns FALSE. bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen) =for hackers Found in file sv.c =item sv_recode_to_utf8 X The encoding is assumed to be an Encode object, on entry the PV of the sv is assumed to be octets in that encoding, and the sv will be converted into Unicode (and UTF-8). If the sv already is UTF-8 (or if it is not POK), or if the encoding is not a reference, nothing is done to the sv. If the encoding is not an C Encoding object, bad things will happen. (See F and L.) The PV of the sv is returned. char* sv_recode_to_utf8(SV* sv, SV *encoding) =for hackers Found in file sv.c =item sv_uni_display X Build to the scalar C a displayable version of the scalar C, the displayable version being at most C bytes long (if longer, the rest is truncated and "..." will be appended). The C argument is as in L(). The pointer to the PV of the C is returned. char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags) =for hackers Found in file utf8.c =item to_utf8_case X C

contains the pointer to the UTF-8 string encoding the character that is being converted. This routine assumes that the character at C

is well-formed. C is a pointer to the character buffer to put the conversion result to. C is a pointer to the length of the result. C is a pointer to the swash to use. Both the special and normal mappings are stored in F, and loaded by SWASHNEW, using F. C (usually, but not always, a multicharacter mapping), is tried first. C is a string, normally C or C<"">. C means to not use any special mappings; C<""> means to use the special mappings. Values other than these two are treated as the name of the hash containing the special mappings, like C<"utf8::ToSpecLower">. C is a string like "ToLower" which means the swash %utf8::ToLower. UV to_utf8_case(const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special) =for hackers Found in file utf8.c =item to_utf8_fold X Instead use L. UV to_utf8_fold(const U8 *p, U8* ustrp, STRLEN *lenp) =for hackers Found in file utf8.c =item to_utf8_lower X Instead use L. UV to_utf8_lower(const U8 *p, U8* ustrp, STRLEN *lenp) =for hackers Found in file utf8.c =item to_utf8_title X Instead use L. UV to_utf8_title(const U8 *p, U8* ustrp, STRLEN *lenp) =for hackers Found in file utf8.c =item to_utf8_upper X Instead use L. UV to_utf8_upper(const U8 *p, U8* ustrp, STRLEN *lenp) =for hackers Found in file utf8.c =item utf8n_to_uvchr X THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES. Most code should use L() rather than call this directly. Bottom level UTF-8 decode routine. Returns the native code point value of the first character in the string C, which is assumed to be in UTF-8 (or UTF-EBCDIC) encoding, and no longer than C bytes; C<*retlen> (if C isn't NULL) will be set to the length, in bytes, of that character. The value of C determines the behavior when C does not point to a well-formed UTF-8 character. If C is 0, when a malformation is found, zero is returned and C<*retlen> is set so that (S + C<*retlen>>) is the next possible position in C that could begin a non-malformed character. Also, if UTF-8 warnings haven't been lexically disabled, a warning is raised. Various ALLOW flags can be set in C 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 for the list of such flags. For allowed 0 length strings, this function returns 0; for allowed overlong sequences, the computed code point is returned; for all other allowed malformations, the Unicode REPLACEMENT CHARACTER is returned, as these have no determinable reasonable value. The UTF8_CHECK_ONLY flag overrides the behavior when a non-allowed (by other flags) malformation is found. If this flag is set, the routine assumes that the caller will raise a warning, and this function will silently just set C to C<-1> (cast to C) and return zero. Note that this API requires disambiguation between successful decoding a C character, and an error return (unless the UTF8_CHECK_ONLY flag is set), as in both cases, 0 is returned. To disambiguate, upon a zero return, see if the first byte of C is 0 as well. If so, the input was a C; if not, the input had an error. Certain code points are considered problematic. These are Unicode surrogates, Unicode non-characters, and code points above the Unicode maximum of 0x10FFFF. By default these are considered regular code points, but certain situations warrant special handling for them. If C 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: they requre at least 32 bits to represent them on ASCII platforms, are not representable at all on EBCDIC platforms, and the original UTF-8 specification never went above this number (the current 0x10FFFF limit was imposed later). (The smaller ones, those that fit into 32 bits, are representable by a UV on ASCII platforms, but not by an IV, which means that the number of operations that can be performed on them is quite restricted.) The UTF-8 encoding on ASCII platforms for these large code points begins with a byte containing 0xFE or 0xFF. The UTF8_DISALLOW_FE_FF flag will cause them to be treated as malformations, while allowing smaller above-Unicode code points. (Of course UTF8_DISALLOW_SUPER will treat all above-Unicode code points, including these, as malformations.) Similarly, UTF8_WARN_FE_FF acts just like the other WARN flags, but applies just to these code points. All other code points corresponding to Unicode characters, including private use and those yet to be assigned, are never considered malformed and never warn. UV utf8n_to_uvchr(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags) =for hackers Found in file utf8.c =item utf8n_to_uvuni X Instead use L, or rarely, L. This function was useful for code that wanted to handle both EBCDIC and ASCII platforms with Unicode properties, but starting in Perl v5.20, the distinctions between the platforms have mostly been made invisible to most code, so this function is quite unlikely to be what you want. If you do need this precise functionality, use instead C> or C>. UV utf8n_to_uvuni(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags) =for hackers Found in file utf8.c =item UTF8SKIP X returns the number of bytes in the UTF-8 encoded character whose first (perhaps only) byte is pointed to by C. STRLEN UTF8SKIP(char* s) =for hackers Found in file utf8.h =item utf8_distance X Returns the number of UTF-8 characters between the UTF-8 pointers C and C. WARNING: use only if you *know* that the pointers point inside the same UTF-8 buffer. IV utf8_distance(const U8 *a, const U8 *b) =for hackers Found in file utf8.c =item utf8_hop X Return the UTF-8 pointer C displaced by C characters, either forward or backward. WARNING: do not use the following unless you *know* C is within the UTF-8 data pointed to by C *and* that on entry C is aligned on the first byte of character or just after the last byte of a character. U8* utf8_hop(const U8 *s, I32 off) =for hackers Found in file utf8.c =item utf8_length X Return the length of the UTF-8 char encoded string C in characters. Stops at C (inclusive). If C s> or if the scan would end up past C, croaks. STRLEN utf8_length(const U8* s, const U8 *e) =for hackers Found in file utf8.c =item utf8_to_bytes X NOTE: this function is experimental and may change or be removed without notice. Converts a string C of length C from UTF-8 into native byte encoding. Unlike L, this over-writes the original string, and updates C to contain the new length. Returns zero on failure, setting C to -1. If you need a copy of the string, see L. U8* utf8_to_bytes(U8 *s, STRLEN *len) =for hackers Found in file utf8.c =item utf8_to_uvchr_buf X Returns the native code point of the first character in the string C which is assumed to be in UTF-8 encoding; C points to 1 beyond the end of C. C<*retlen> will be set to the length, in bytes, of that character. If C does not point to a well-formed UTF-8 character and UTF8 warnings are enabled, zero is returned and C<*retlen> is set (if C isn't NULL) to -1. If those warnings are off, the computed value, if well-defined (or the Unicode REPLACEMENT CHARACTER if not), is silently returned, and C<*retlen> is set (if C isn't NULL) so that (S + C<*retlen>>) is the next possible position in C that could begin a non-malformed character. See L for details on when the REPLACEMENT CHARACTER is returned. UV utf8_to_uvchr_buf(const U8 *s, const U8 *send, STRLEN *retlen) =for hackers Found in file utf8.c =item utf8_to_uvuni_buf X DEPRECATED! It is planned to remove this function from a future release of Perl. Do not use it for new code; remove it from existing code. Only in very rare circumstances should code need to be dealing in Unicode (as opposed to native) code points. In those few cases, use C> instead. Returns the Unicode (not-native) code point of the first character in the string C which is assumed to be in UTF-8 encoding; C points to 1 beyond the end of C. C will be set to the length, in bytes, of that character. If C does not point to a well-formed UTF-8 character and UTF8 warnings are enabled, zero is returned and C<*retlen> is set (if C isn't NULL) to -1. If those warnings are off, the computed value if well-defined (or the Unicode REPLACEMENT CHARACTER, if not) is silently returned, and C<*retlen> is set (if C isn't NULL) so that (S + C<*retlen>>) is the next possible position in C that could begin a non-malformed character. See L for details on when the REPLACEMENT CHARACTER is returned. UV utf8_to_uvuni_buf(const U8 *s, const U8 *send, STRLEN *retlen) =for hackers Found in file utf8.c =item UVCHR_SKIP X returns the number of bytes required to represent the code point C when encoded as UTF-8. C is a native (ASCII or EBCDIC) code point if less than 255; a Unicode code point otherwise. STRLEN UVCHR_SKIP(UV cp) =for hackers Found in file utf8.h =item uvchr_to_utf8 X Adds the UTF-8 representation of the native code point C to the end of the string C; C should have at least C (up to C) free bytes available. The return value is the pointer to the byte after the end of the new character. In other words, d = uvchr_to_utf8(d, uv); is the recommended wide native character-aware way of saying *(d++) = uv; This function accepts any UV as input. To forbid or warn on non-Unicode code points, or those that may be problematic, see L. U8* uvchr_to_utf8(U8 *d, UV uv) =for hackers Found in file utf8.c =item uvchr_to_utf8_flags X Adds the UTF-8 representation of the native code point C to the end of the string C; C should have at least C (up to C) free bytes available. The return value is the pointer to the byte after the end of the new character. In other words, d = uvchr_to_utf8_flags(d, uv, flags); or, in most cases, d = uvchr_to_utf8_flags(d, uv, 0); This is the 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 contains one or more of the following flags: If C 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 affect how the function handles a Unicode non-character. And likewise, the UNICODE_WARN_SUPER and UNICODE_DISALLOW_SUPER flags affect the handling of 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* uvchr_to_utf8_flags(U8 *d, UV uv, UV flags) =for hackers Found in file utf8.c =item uvoffuni_to_utf8_flags X THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES. Instead, B or L>. This function is like them, but the input is a strict Unicode (as opposed to native) code point. Only in very rare circumstances should code not be using the native code point. For details, see the description for L. U8* uvoffuni_to_utf8_flags(U8 *d, UV uv, UV flags) =for hackers Found in file utf8.c =item uvuni_to_utf8_flags X Instead you almost certainly want to use L or L. This function is a deprecated synonym for L, which itself, while not deprecated, should be used only in isolated circumstances. These functions were useful for code that wanted to handle both EBCDIC and ASCII platforms with Unicode properties, but starting in Perl v5.20, the distinctions between the platforms have mostly been made invisible to most code, so this function is quite unlikely to be what you want. U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags) =for hackers Found in file utf8.c =back =head1 Variables created by C and C internal functions =over 8 =item newXSproto X Used by C to hook up XSUBs as Perl subs. Adds Perl prototypes to the subs. =for hackers Found in file XSUB.h =item XS_APIVERSION_BOOTCHECK X 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 The version identifier for an XS module. This is usually handled automatically by C. See C. =for hackers Found in file XSUB.h =item XS_VERSION_BOOTCHECK X Macro to verify that a PM module's $VERSION variable matches the XS module's C variable. This is usually handled automatically by C. See L. XS_VERSION_BOOTCHECK; =for hackers Found in file XSUB.h =back =head1 Versioning =over 8 =item new_version X Returns a new version object based on the passed in SV: SV *sv = new_version(SV *ver); Does not alter the passed in ver SV. See "upg_version" if you want to upgrade the SV. SV* new_version(SV *ver) =for hackers Found in file vutil.c =item prescan_version X 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 Found in file vutil.c =item scan_version X Returns a pointer to the next character after the parsed version string, as well as upgrading the passed in SV to an RV. Function must be called with an already existing SV like sv = newSV(0); s = scan_version(s, SV *sv, bool qv); Performs some preprocessing to the string to ensure that it has the correct characteristics of a version. Flags the object if it contains an underscore (which denotes this is an alpha version). The boolean qv denotes that the version should be interpreted as if it had multiple decimals, even if it doesn't. const char* scan_version(const char *s, SV *rv, bool qv) =for hackers Found in file vutil.c =item upg_version X In-place upgrade of the supplied SV to a version object. SV *sv = upg_version(SV *sv, bool qv); Returns a pointer to the upgraded SV. Set the boolean qv if you want to force this SV to be interpreted as an "extended" version. SV* upg_version(SV *ver, bool qv) =for hackers Found in file vutil.c =item vcmp X Version object aware cmp. Both operands must already have been converted into version objects. int vcmp(SV *lhv, SV *rhv) =for hackers Found in file vutil.c =item vnormal X Accepts a version object and returns the normalized string representation. Call like: sv = vnormal(rv); 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 Found in file vutil.c =item vnumify X Accepts a version object and returns the normalized floating point representation. Call like: sv = vnumify(rv); 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 Found in file vutil.c =item vstringify X 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 SV returned has a refcount of 1. SV* vstringify(SV *vs) =for hackers Found in file vutil.c =item vverify X 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. 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): SV* vverify(SV *vs) =for hackers Found in file vutil.c =back =head1 Warning and Dieing =over 8 =item croak X This is an XS interface to Perl's C 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. The error message will be used as an exception, by default returning control to the nearest enclosing C, but subject to modification by a C<$SIG{__DIE__}> handler. In any case, the C function never returns normally. For historical reasons, if C is null then the contents of C (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 function, which does not involve clobbering C. void croak(const char *pat, ...) =for hackers Found in file util.c =item croak_no_modify X Exactly equivalent to C, but generates terser object code than using C. 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 This is an XS interface to Perl's C function. C 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. The error message or object will be used as an exception, by default returning control to the nearest enclosing C, but subject to modification by a C<$SIG{__DIE__}> handler. In any case, the C function never returns normally. To die with a simple string message, the L function may be more convenient. void croak_sv(SV *baseex) =for hackers Found in file util.c =item die X Behaves the same as L, except for the return type. It should be used only where the C return type is required. The function never actually returns. OP * die(const char *pat, ...) =for hackers Found in file util.c =item die_sv X Behaves the same as L, except for the return type. It should be used only where the C return type is required. The function never actually returns. OP * die_sv(SV *baseex) =for hackers Found in file util.c =item vcroak X This is an XS interface to Perl's C function. C and C 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. The error message will be used as an exception, by default returning control to the nearest enclosing C, but subject to modification by a C<$SIG{__DIE__}> handler. In any case, the C function never returns normally. For historical reasons, if C is null then the contents of C (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 function, which does not involve clobbering C. void vcroak(const char *pat, va_list *args) =for hackers Found in file util.c =item vwarn X This is an XS interface to Perl's C function. C and C 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. 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, C is not permitted to be null. void vwarn(const char *pat, va_list *args) =for hackers Found in file util.c =item warn X This is an XS interface to Perl's C 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. 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, C is not permitted to be null. void warn(const char *pat, ...) =for hackers Found in file util.c =item warn_sv X This is an XS interface to Perl's C function. C 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. 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 function may be more convenient. void warn_sv(SV *baseex) =for hackers Found in file util.c =back =head1 Undocumented functions 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. Functions that are not listed in this document are not intended for public use, and should NOT be used under any circumstances. If you use one of the undocumented functions below, 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 =item GetVars X =item Gv_AMupdate X =item PerlIO_clearerr X =item PerlIO_close X =item PerlIO_context_layers X =item PerlIO_eof X =item PerlIO_error X =item PerlIO_fileno X =item PerlIO_fill X =item PerlIO_flush X =item PerlIO_get_base X =item PerlIO_get_bufsiz X =item PerlIO_get_cnt X =item PerlIO_get_ptr X =item PerlIO_read X =item PerlIO_seek X =item PerlIO_set_cnt X =item PerlIO_set_ptrcnt X =item PerlIO_setlinebuf X =item PerlIO_stderr X =item PerlIO_stdin X =item PerlIO_stdout X =item PerlIO_tell X =item PerlIO_unread X =item PerlIO_write X =item amagic_call X =item amagic_deref_call X =item any_dup X =item atfork_lock X =item atfork_unlock X =item av_arylen_p X =item av_iter_p X =item block_gimme X =item call_atexit X =item call_list X =item calloc X =item cast_i32 X =item cast_iv X =item cast_ulong X =item cast_uv X =item ck_warner X =item ck_warner_d X =item ckwarn X =item ckwarn_d X =item clone_params_del X =item clone_params_new X =item croak_memory_wrap X =item croak_nocontext X =item csighandler X =item cx_dump X =item cx_dup X =item cxinc X =item deb X =item deb_nocontext X =item debop X =item debprofdump X =item debstack X =item debstackptrs X =item delimcpy X =item despatch_signals X =item die_nocontext X =item dirp_dup X =item do_aspawn X =item do_binmode X =item do_close X =item do_gv_dump X =item do_gvgv_dump X =item do_hv_dump X =item do_join X =item do_magic_dump X =item do_op_dump X =item do_open X =item do_open9 X =item do_openn X =item do_pmop_dump X =item do_spawn X =item do_spawn_nowait X =item do_sprintf X =item do_sv_dump X =item doing_taint X =item doref X =item dounwind X =item dowantarray X =item dump_eval X =item dump_form X =item dump_indent X =item dump_mstats X =item dump_sub X =item dump_vindent X =item filter_add X =item filter_del X =item filter_read X =item foldEQ_latin1 X =item form_nocontext X =item fp_dup X =item fprintf_nocontext X =item free_global_struct X =item free_tmps X =item get_context X =item get_mstats X =item get_op_descs X =item get_op_names X =item get_ppaddr X =item get_vtbl X =item gp_dup X =item gp_free X =item gp_ref X =item gv_AVadd X =item gv_HVadd X =item gv_IOadd X =item gv_SVadd X =item gv_add_by_type X =item gv_autoload4 X =item gv_autoload_pv X =item gv_autoload_pvn X =item gv_autoload_sv X =item gv_check X =item gv_dump X =item gv_efullname X =item gv_efullname3 X =item gv_efullname4 X =item gv_fetchfile X =item gv_fetchfile_flags X =item gv_fetchpv X =item gv_fetchpvn_flags X =item gv_fetchsv X =item gv_fullname X =item gv_fullname3 X =item gv_fullname4 X =item gv_handler X =item gv_name_set X =item he_dup X =item hek_dup X =item hv_common X =item hv_common_key_len X =item hv_delayfree_ent X =item hv_eiter_p X =item hv_eiter_set X =item hv_free_ent X =item hv_ksplit X =item hv_name_set X =item hv_placeholders_get X =item hv_placeholders_set X =item hv_rand_set X =item hv_riter_p X =item hv_riter_set X =item ibcmp_utf8 X =item init_global_struct X =item init_stacks X =item init_tm X =item instr X =item is_lvalue_sub X =item leave_scope X =item load_module_nocontext X =item magic_dump X =item malloc X =item markstack_grow X =item mess_nocontext X =item mfree X =item mg_dup X =item mg_size X =item mini_mktime X =item moreswitches X =item mro_get_from_name X =item mro_get_private_data X =item mro_set_mro X =item mro_set_private_data X =item my_atof X =item my_atof2 X =item my_bcopy X =item my_bzero X =item my_chsize X =item my_cxt_index X =item my_cxt_init X =item my_dirfd X =item my_exit X =item my_failure_exit X =item my_fflush_all X =item my_fork X =item my_lstat X =item my_memcmp X =item my_memset X =item my_pclose X =item my_popen X =item my_popen_list X =item my_setenv X =item my_socketpair X =item my_stat X =item my_strftime X =item newANONATTRSUB X =item newANONHASH X =item newANONLIST X =item newANONSUB X =item newATTRSUB X =item newAVREF X =item newCVREF X =item newFORM X =item newGVREF X =item newGVgen X =item newGVgen_flags X =item newHVREF X =item newHVhv X =item newIO X =item newMYSUB X =item newPROG X =item newRV X =item newSUB X =item newSVREF X =item newSVpvf_nocontext X =item new_stackinfo X =item ninstr X =item op_refcnt_lock X =item op_refcnt_unlock X =item parser_dup X =item perl_alloc_using X =item perl_clone_using X =item pmop_dump X =item pop_scope X =item pregcomp X =item pregexec X =item pregfree X =item pregfree2 X =item printf_nocontext X =item ptr_table_fetch X =item ptr_table_free X =item ptr_table_new X =item ptr_table_split X =item ptr_table_store X =item push_scope X =item re_compile X =item re_dup_guts X =item re_intuit_start X =item re_intuit_string X =item realloc X =item reentrant_free X =item reentrant_init X =item reentrant_retry X =item reentrant_size X =item ref X =item reg_named_buff_all X =item reg_named_buff_exists X =item reg_named_buff_fetch X =item reg_named_buff_firstkey X =item reg_named_buff_nextkey X =item reg_named_buff_scalar X =item regclass_swash X =item regdump X =item regdupe_internal X =item regexec_flags X =item regfree_internal X =item reginitcolors X =item regnext X =item repeatcpy X =item rninstr X =item rsignal X =item rsignal_state X =item runops_debug X =item runops_standard X =item rvpv_dup X =item safesyscalloc X =item safesysfree X =item safesysmalloc X =item safesysrealloc X =item save_I16 X =item save_I32 X =item save_I8 X =item save_adelete X =item save_aelem X =item save_aelem_flags X =item save_alloc X =item save_aptr X =item save_ary X =item save_bool X =item save_clearsv X =item save_delete X =item save_destructor X =item save_destructor_x X =item save_freeop X =item save_freepv X =item save_freesv X =item save_generic_pvref X =item save_generic_svref X =item save_gp X =item save_hash X =item save_hdelete X =item save_helem X =item save_helem_flags X =item save_hints X =item save_hptr X =item save_int X =item save_item X =item save_iv X =item save_list X =item save_long X =item save_mortalizesv X =item save_nogv X =item save_op X =item save_padsv_and_mortalize X =item save_pptr X =item save_pushi32ptr X =item save_pushptr X =item save_pushptrptr X =item save_re_context X =item save_scalar X =item save_set_svflags X =item save_shared_pvref X =item save_sptr X =item save_svref X =item save_vptr X =item savestack_grow X =item savestack_grow_cnt X =item scan_num X =item scan_vstring X =item seed X =item set_context X =item set_numeric_local X =item set_numeric_radix X =item set_numeric_standard X =item share_hek X =item si_dup X =item ss_dup X =item stack_grow X =item start_subparse X =item str_to_version X =item sv_2iv X =item sv_2pv X =item sv_2uv X =item sv_catpvf_mg_nocontext X =item sv_catpvf_nocontext X =item sv_dup X =item sv_dup_inc X =item sv_peek X =item sv_pvn_nomg X =item sv_setpvf_mg_nocontext X =item sv_setpvf_nocontext X =item swash_fetch X =item swash_init X =item sys_init X =item sys_init3 X =item sys_intern_clear X =item sys_intern_dup X =item sys_intern_init X =item sys_term X =item taint_env X =item taint_proper X =item unlnk X =item unsharepvn X =item utf16_to_utf8 X =item utf16_to_utf8_reversed X =item uvuni_to_utf8 X =item vdeb X =item vform X =item vload_module X =item vnewSVpvf X =item vwarner X =item warn_nocontext X =item warner X =item warner_nocontext X =item whichsig X =item whichsig_pv X =item whichsig_pvn X =item whichsig_sv X =back =head1 AUTHORS Until May 1997, this document was maintained by Jeff Okamoto . It is now maintained as part of Perl itself. With lots of help and suggestions from Dean Roehrich, Malcolm Beattie, Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer, Stephen McCamant, and Gurusamy Sarathy. API Listing originally by Dean Roehrich . Updated to be autogenerated from comments in the source by Benjamin Stuhl. =head1 SEE ALSO L, L, L, L =cut ex: set ro: