.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "PERLAPI 1" .TH PERLAPI 1 "2021-09-24" "perl v5.32.1" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" perlapi \- autogenerated documentation for the perl public API .SH "DESCRIPTION" .IX Xref "Perl API API api" .IX Header "DESCRIPTION" This file contains most of the documentation of the perl public \s-1API,\s0 as generated by \fIembed.pl\fR. Specifically, it is a listing of functions, macros, flags, and variables that may be used by extension writers. Some specialized items are instead documented in \fIconfig.h\fR, perlapio, perlcall, perlclib, perlfilter, perlguts, perlmroapi, perlxs, perlxstut, and warnings. .PP At the end is a list of functions which have yet to be documented. Patches welcome! The interfaces of these are subject to change without notice. .PP Anything not listed here is not part of the public \s-1API,\s0 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. .PP In Perl, unlike C, a string of characters may generally contain embedded \&\f(CW\*(C`NUL\*(C'\fR characters. Sometimes in the documentation a Perl string is referred to as a \*(L"buffer\*(R" to distinguish it from a C string, but sometimes they are both just referred to as strings. .PP Note that all Perl \s-1API\s0 global variables must be referenced with the \f(CW\*(C`PL_\*(C'\fR 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. .PP 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 \s-1ASCII,\s0 when sometimes in fact the entire range from 0 \- 255 is meant. .PP The non-ASCII characters below 256 can have various meanings, depending on various things. (See, most notably, perllocale.) But usually the whole range can be referred to as \s-1ISO\-8859\-1.\s0 Often, the term \*(L"Latin\-1\*(R" (or \&\*(L"Latin1\*(R") is used as an equivalent for \s-1ISO\-8859\-1.\s0 But some people treat \&\*(L"Latin1\*(R" as referring just to the characters in the range 128 through 255, or somethimes from 160 through 255. This documentation uses \*(L"Latin1\*(R" and \*(L"Latin\-1\*(R" to refer to all 256 characters. .PP Note that Perl can be compiled and run under either \s-1ASCII\s0 or \s-1EBCDIC\s0 (See perlebcdic). Most of the documentation (and even comments in the code) ignore the \s-1EBCDIC\s0 possibility. For almost all purposes the differences are transparent. As an example, under \s-1EBCDIC,\s0 instead of \s-1UTF\-8,\s0 UTF-EBCDIC is used to encode Unicode strings, and so whenever this documentation refers to \f(CW\*(C`utf8\*(C'\fR (and variants of that name, including in function names), it also (essentially transparently) means \f(CW\*(C`UTF\-EBCDIC\*(C'\fR. But the ordinals of characters differ between \s-1ASCII, EBCDIC,\s0 and the \s-1UTF\-\s0 encodings, and a string encoded in UTF-EBCDIC may occupy a different number of bytes than in \s-1UTF\-8.\s0 .PP The listing below is alphabetical, case insensitive. .SH "Array Manipulation Functions" .IX Header "Array Manipulation Functions" .IP "av_clear" 8 .IX Xref "av_clear" .IX Item "av_clear" Frees the all the elements of an array, leaving it empty. The \s-1XS\s0 equivalent of \f(CW\*(C`@array = ()\*(C'\fR. See also \*(L"av_undef\*(R". .Sp 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 \s-1AV\s0 could have been freed (or even reallocated) on return from the call unless you hold a reference to it. .Sp .Vb 1 \& void av_clear(AV *av) .Ve .IP "av_create_and_push" 8 .IX Xref "av_create_and_push" .IX Item "av_create_and_push" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Push an \s-1SV\s0 onto the end of the array, creating the array if necessary. A small internal helper function to remove a commonly duplicated idiom. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_av_create_and_push with an aTHX_ parameter. .Sp .Vb 2 \& void Perl_av_create_and_push(pTHX_ AV **const avp, \& SV *const val) .Ve .IP "av_create_and_unshift_one" 8 .IX Xref "av_create_and_unshift_one" .IX Item "av_create_and_unshift_one" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Unshifts an \s-1SV\s0 onto the beginning of the array, creating the array if necessary. A small internal helper function to remove a commonly duplicated idiom. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_av_create_and_unshift_one with an aTHX_ parameter. .Sp .Vb 3 \& SV** Perl_av_create_and_unshift_one(pTHX_ \& AV **const avp, \& SV *const val) .Ve .IP "av_delete" 8 .IX Xref "av_delete" .IX Item "av_delete" Deletes the element indexed by \f(CW\*(C`key\*(C'\fR from the array, makes the element mortal, and returns it. If \f(CW\*(C`flags\*(C'\fR equals \f(CW\*(C`G_DISCARD\*(C'\fR, the element is freed and \s-1NULL\s0 is returned. \s-1NULL\s0 is also returned if \f(CW\*(C`key\*(C'\fR is out of range. .Sp Perl equivalent: \f(CW\*(C`splice(@myarray, $key, 1, undef)\*(C'\fR (with the \&\f(CW\*(C`splice\*(C'\fR in void context if \f(CW\*(C`G_DISCARD\*(C'\fR is present). .Sp .Vb 1 \& SV* av_delete(AV *av, SSize_t key, I32 flags) .Ve .IP "av_exists" 8 .IX Xref "av_exists" .IX Item "av_exists" Returns true if the element indexed by \f(CW\*(C`key\*(C'\fR has been initialized. .Sp This relies on the fact that uninitialized array elements are set to \&\f(CW\*(C`NULL\*(C'\fR. .Sp Perl equivalent: \f(CW\*(C`exists($myarray[$key])\*(C'\fR. .Sp .Vb 1 \& bool av_exists(AV *av, SSize_t key) .Ve .IP "av_extend" 8 .IX Xref "av_extend" .IX Item "av_extend" Pre-extend an array so that it is capable of storing values at indexes \&\f(CW\*(C`0..key\*(C'\fR. Thus \f(CW\*(C`av_extend(av,99)\*(C'\fR guarantees that the array can store 100 elements, i.e. that \f(CW\*(C`av_store(av, 0, sv)\*(C'\fR through \f(CW\*(C`av_store(av, 99, sv)\*(C'\fR on a plain array will work without any further memory allocation. .Sp If the av argument is a tied array then will call the \f(CW\*(C`EXTEND\*(C'\fR tied array method with an argument of \f(CW\*(C`(key+1)\*(C'\fR. .Sp .Vb 1 \& void av_extend(AV *av, SSize_t key) .Ve .IP "av_fetch" 8 .IX Xref "av_fetch" .IX Item "av_fetch" Returns the \s-1SV\s0 at the specified index in the array. The \f(CW\*(C`key\*(C'\fR is the index. If lval is true, you are guaranteed to get a real \s-1SV\s0 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 \f(CW\*(C`SV*\*(C'\fR. .Sp See \*(L"Understanding the Magic of Tied Hashes and Arrays\*(R" in perlguts for more information on how to use this function on tied arrays. .Sp The rough perl equivalent is \f(CW$myarray[$key]\fR. .Sp .Vb 1 \& SV** av_fetch(AV *av, SSize_t key, I32 lval) .Ve .IP "AvFILL" 8 .IX Xref "AvFILL" .IX Item "AvFILL" Same as \f(CW\*(C`av_top_index()\*(C'\fR or \f(CW\*(C`av_tindex()\*(C'\fR. .Sp .Vb 1 \& int AvFILL(AV* av) .Ve .IP "av_fill" 8 .IX Xref "av_fill" .IX Item "av_fill" Set the highest index in the array to the given number, equivalent to Perl's \f(CW\*(C`$#array = $fill;\*(C'\fR. .Sp The number of elements in the array will be \f(CW\*(C`fill + 1\*(C'\fR after \&\f(CW\*(C`av_fill()\*(C'\fR returns. If the array was previously shorter, then the additional elements appended are set to \s-1NULL.\s0 If the array was longer, then the excess elements are freed. \f(CW\*(C`av_fill(av, \-1)\*(C'\fR is the same as \f(CW\*(C`av_clear(av)\*(C'\fR. .Sp .Vb 1 \& void av_fill(AV *av, SSize_t fill) .Ve .IP "av_len" 8 .IX Xref "av_len" .IX Item "av_len" Same as \*(L"av_top_index\*(R". 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 \&\f(CW\*(C`av_len(av) + 1\*(C'\fR. This is unlike \*(L"sv_len\*(R", which returns what you would expect. .Sp .Vb 1 \& SSize_t av_len(AV *av) .Ve .IP "av_make" 8 .IX Xref "av_make" .IX Item "av_make" Creates a new \s-1AV\s0 and populates it with a list of SVs. The SVs are copied into the array, so they may be freed after the call to \f(CW\*(C`av_make\*(C'\fR. The new \s-1AV\s0 will have a reference count of 1. .Sp Perl equivalent: \f(CW\*(C`my @new_array = ($scalar1, $scalar2, $scalar3...);\*(C'\fR .Sp .Vb 1 \& AV* av_make(SSize_t size, SV **strp) .Ve .IP "av_pop" 8 .IX Xref "av_pop" .IX Item "av_pop" Removes one \s-1SV\s0 from the end of the array, reducing its size by one and returning the \s-1SV\s0 (transferring control of one reference count) to the caller. Returns \f(CW&PL_sv_undef\fR if the array is empty. .Sp Perl equivalent: \f(CW\*(C`pop(@myarray);\*(C'\fR .Sp .Vb 1 \& SV* av_pop(AV *av) .Ve .IP "av_push" 8 .IX Xref "av_push" .IX Item "av_push" Pushes an \s-1SV\s0 (transferring control of one reference count) onto the end of the array. The array will grow automatically to accommodate the addition. .Sp Perl equivalent: \f(CW\*(C`push @myarray, $val;\*(C'\fR. .Sp .Vb 1 \& void av_push(AV *av, SV *val) .Ve .IP "av_shift" 8 .IX Xref "av_shift" .IX Item "av_shift" Removes one \s-1SV\s0 from the start of the array, reducing its size by one and returning the \s-1SV\s0 (transferring control of one reference count) to the caller. Returns \f(CW&PL_sv_undef\fR if the array is empty. .Sp Perl equivalent: \f(CW\*(C`shift(@myarray);\*(C'\fR .Sp .Vb 1 \& SV* av_shift(AV *av) .Ve .IP "av_store" 8 .IX Xref "av_store" .IX Item "av_store" Stores an \s-1SV\s0 in an array. The array index is specified as \f(CW\*(C`key\*(C'\fR. The return value will be \f(CW\*(C`NULL\*(C'\fR 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 \f(CW\*(C`SV*\*(C'\fR that was stored there (= \f(CW\*(C`val\*(C'\fR)). .Sp Note that the caller is responsible for suitably incrementing the reference count of \f(CW\*(C`val\*(C'\fR before the call, and decrementing it if the function returned \f(CW\*(C`NULL\*(C'\fR. .Sp Approximate Perl equivalent: \f(CW\*(C`splice(@myarray, $key, 1, $val)\*(C'\fR. .Sp See \*(L"Understanding the Magic of Tied Hashes and Arrays\*(R" in perlguts for more information on how to use this function on tied arrays. .Sp .Vb 1 \& SV** av_store(AV *av, SSize_t key, SV *val) .Ve .IP "av_tindex" 8 .IX Xref "av_tindex" .IX Item "av_tindex" Same as \f(CW\*(C`av_top_index()\*(C'\fR. .Sp .Vb 1 \& SSize_t av_tindex(AV *av) .Ve .IP "av_top_index" 8 .IX Xref "av_top_index" .IX Item "av_top_index" Returns the highest index in the array. The number of elements in the array is \f(CW\*(C`av_top_index(av) + 1\*(C'\fR. Returns \-1 if the array is empty. .Sp The Perl equivalent for this is \f(CW$#myarray\fR. .Sp (A slightly shorter form is \f(CW\*(C`av_tindex\*(C'\fR.) .Sp .Vb 1 \& SSize_t av_top_index(AV *av) .Ve .IP "av_undef" 8 .IX Xref "av_undef" .IX Item "av_undef" Undefines the array. The \s-1XS\s0 equivalent of \f(CW\*(C`undef(@array)\*(C'\fR. .Sp As well as freeing all the elements of the array (like \f(CW\*(C`av_clear()\*(C'\fR), this also frees the memory used by the av to store its list of scalars. .Sp See \*(L"av_clear\*(R" for a note about the array possibly being invalid on return. .Sp .Vb 1 \& void av_undef(AV *av) .Ve .IP "av_unshift" 8 .IX Xref "av_unshift" .IX Item "av_unshift" Unshift the given number of \f(CW\*(C`undef\*(C'\fR values onto the beginning of the array. The array will grow automatically to accommodate the addition. .Sp Perl equivalent: \f(CW\*(C`unshift @myarray, ((undef) x $num);\*(C'\fR .Sp .Vb 1 \& void av_unshift(AV *av, SSize_t num) .Ve .IP "get_av" 8 .IX Xref "get_av" .IX Item "get_av" Returns the \s-1AV\s0 of the specified Perl global or package array with the given name (so it won't work on lexical variables). \f(CW\*(C`flags\*(C'\fR are passed to \f(CW\*(C`gv_fetchpv\*(C'\fR. If \f(CW\*(C`GV_ADD\*(C'\fR is set and the Perl variable does not exist then it will be created. If \f(CW\*(C`flags\*(C'\fR is zero and the variable does not exist then \s-1NULL\s0 is returned. .Sp Perl equivalent: \f(CW\*(C`@{"$name"}\*(C'\fR. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& AV* get_av(const char *name, I32 flags) .Ve .IP "newAV" 8 .IX Xref "newAV" .IX Item "newAV" Creates a new \s-1AV.\s0 The reference count is set to 1. .Sp Perl equivalent: \f(CW\*(C`my @array;\*(C'\fR. .Sp .Vb 1 \& AV* newAV() .Ve .IP "sortsv" 8 .IX Xref "sortsv" .IX Item "sortsv" In-place sort an array of \s-1SV\s0 pointers with the given comparison routine. .Sp Currently this always uses mergesort. See \f(CW"sortsv_flags"\fR for a more flexible routine. .Sp .Vb 2 \& void sortsv(SV** array, size_t num_elts, \& SVCOMPARE_t cmp) .Ve .SH "Callback Functions" .IX Header "Callback Functions" .IP "call_argv" 8 .IX Xref "call_argv" .IX Item "call_argv" Performs a callback to the specified named and package-scoped Perl subroutine with \f(CW\*(C`argv\*(C'\fR (a \f(CW\*(C`NULL\*(C'\fR\-terminated array of strings) as arguments. See perlcall. .Sp Approximate Perl equivalent: \f(CW\*(C`&{"$sub_name"}(@$argv)\*(C'\fR. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 2 \& I32 call_argv(const char* sub_name, I32 flags, \& char** argv) .Ve .IP "call_method" 8 .IX Xref "call_method" .IX Item "call_method" Performs a callback to the specified Perl method. The blessed object must be on the stack. See perlcall. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& I32 call_method(const char* methname, I32 flags) .Ve .IP "call_pv" 8 .IX Xref "call_pv" .IX Item "call_pv" Performs a callback to the specified Perl sub. See perlcall. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& I32 call_pv(const char* sub_name, I32 flags) .Ve .IP "call_sv" 8 .IX Xref "call_sv" .IX Item "call_sv" Performs a callback to the Perl sub specified by the \s-1SV.\s0 .Sp If neither the \f(CW\*(C`G_METHOD\*(C'\fR nor \f(CW\*(C`G_METHOD_NAMED\*(C'\fR flag is supplied, the \&\s-1SV\s0 may be any of a \s-1CV,\s0 a \s-1GV,\s0 a reference to a \s-1CV,\s0 a reference to a \s-1GV\s0 or \f(CW\*(C`SvPV(sv)\*(C'\fR will be used as the name of the sub to call. .Sp If the \f(CW\*(C`G_METHOD\*(C'\fR flag is supplied, the \s-1SV\s0 may be a reference to a \s-1CV\s0 or \&\f(CW\*(C`SvPV(sv)\*(C'\fR will be used as the name of the method to call. .Sp If the \f(CW\*(C`G_METHOD_NAMED\*(C'\fR flag is supplied, \f(CW\*(C`SvPV(sv)\*(C'\fR will be used as the name of the method to call. .Sp Some other values are treated specially for internal use and should not be depended on. .Sp See perlcall. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& I32 call_sv(SV* sv, volatile I32 flags) .Ve .IP "\s-1ENTER\s0" 8 .IX Xref "ENTER" .IX Item "ENTER" Opening bracket on a callback. See \f(CW"LEAVE"\fR and perlcall. .Sp .Vb 1 \& ENTER; .Ve .IP "ENTER_with_name" 8 .IX Xref "ENTER_with_name" .IX Item "ENTER_with_name" Same as \f(CW"ENTER"\fR, but when debugging is enabled it also associates the given literal string with the new scope. .Sp .Vb 1 \& ENTER_with_name("name"); .Ve .IP "eval_pv" 8 .IX Xref "eval_pv" .IX Item "eval_pv" Tells Perl to \f(CW\*(C`eval\*(C'\fR the given string in scalar context and return an SV* result. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& SV* eval_pv(const char* p, I32 croak_on_error) .Ve .IP "eval_sv" 8 .IX Xref "eval_sv" .IX Item "eval_sv" Tells Perl to \f(CW\*(C`eval\*(C'\fR the string in the \s-1SV.\s0 It supports the same flags as \f(CW\*(C`call_sv\*(C'\fR, with the obvious exception of \f(CW\*(C`G_EVAL\*(C'\fR. See perlcall. .Sp The \f(CW\*(C`G_RETHROW\*(C'\fR flag can be used if you only need \fBeval_sv()\fR to execute code specified by a string, but not catch any errors. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& I32 eval_sv(SV* sv, I32 flags) .Ve .IP "\s-1FREETMPS\s0" 8 .IX Xref "FREETMPS" .IX Item "FREETMPS" Closing bracket for temporaries on a callback. See \f(CW"SAVETMPS"\fR and perlcall. .Sp .Vb 1 \& FREETMPS; .Ve .IP "\s-1LEAVE\s0" 8 .IX Xref "LEAVE" .IX Item "LEAVE" Closing bracket on a callback. See \f(CW"ENTER"\fR and perlcall. .Sp .Vb 1 \& LEAVE; .Ve .IP "LEAVE_with_name" 8 .IX Xref "LEAVE_with_name" .IX Item "LEAVE_with_name" Same as \f(CW"LEAVE"\fR, but when debugging is enabled it first checks that the scope has the given name. \f(CW\*(C`name\*(C'\fR must be a literal string. .Sp .Vb 1 \& LEAVE_with_name("name"); .Ve .IP "\s-1SAVETMPS\s0" 8 .IX Xref "SAVETMPS" .IX Item "SAVETMPS" Opening bracket for temporaries on a callback. See \f(CW"FREETMPS"\fR and perlcall. .Sp .Vb 1 \& SAVETMPS; .Ve .SH "Character case changing" .IX Header "Character case changing" Perl uses \*(L"full\*(R" Unicode case mappings. This means that converting a single character to another case may result in a sequence of more than one character. For example, the uppercase of \f(CW\*(C`ß\*(C'\fR (\s-1LATIN SMALL LETTER SHARP S\s0) is the two character sequence \f(CW\*(C`SS\*(C'\fR. This presents some complications The lowercase of all characters in the range 0..255 is a single character, and thus \&\f(CW"toLOWER_L1"\fR is furnished. But, \f(CW\*(C`toUPPER_L1\*(C'\fR can't exist, as it couldn't return a valid result for all legal inputs. Instead \f(CW"toUPPER_uvchr"\fR has an \s-1API\s0 that does allow every possible legal result to be returned.) Likewise no other function that is crippled by not being able to give the correct results for the full range of possible inputs has been implemented here. .IP "toFOLD" 8 .IX Xref "toFOLD" .IX Item "toFOLD" Converts the specified character to foldcase. If the input is anything but an \&\s-1ASCII\s0 uppercase character, that input character itself is returned. Variant \&\f(CW\*(C`toFOLD_A\*(C'\fR is equivalent. (There is no equivalent \f(CW\*(C`to_FOLD_L1\*(C'\fR for the full Latin1 range, as the full generality of \*(L"toFOLD_uvchr\*(R" is needed there.) .Sp .Vb 1 \& U8 toFOLD(U8 ch) .Ve .IP "toFOLD_utf8" 8 .IX Xref "toFOLD_utf8" .IX Item "toFOLD_utf8" Converts the first \s-1UTF\-8\s0 encoded character in the sequence starting at \f(CW\*(C`p\*(C'\fR and extending no further than \f(CW\*(C`e \- 1\*(C'\fR to its foldcase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the foldcase version may be longer than the original character. .Sp The first code point of the foldcased version is returned (but note, as explained at the top of this section, that there may be more). .Sp It will not attempt to read beyond \f(CW\*(C`e \- 1\*(C'\fR, provided that the constraint \f(CW\*(C`s < e\*(C'\fR is true (this is asserted for in \f(CW\*(C`\-DDEBUGGING\*(C'\fR builds). If the \s-1UTF\-8\s0 for the input character is malformed in some way, the program may croak, or the function may return the \s-1REPLACEMENT CHARACTER,\s0 at the discretion of the implementation, and subject to change in future releases. .Sp .Vb 1 \& UV toFOLD_utf8(U8* p, U8* e, U8* s, STRLEN* lenp) .Ve .IP "toFOLD_utf8_safe" 8 .IX Xref "toFOLD_utf8_safe" .IX Item "toFOLD_utf8_safe" Same as \*(L"toFOLD_utf8\*(R". .Sp .Vb 2 \& UV toFOLD_utf8_safe(U8* p, U8* e, U8* s, \& STRLEN* lenp) .Ve .IP "toFOLD_uvchr" 8 .IX Xref "toFOLD_uvchr" .IX Item "toFOLD_uvchr" Converts the code point \f(CW\*(C`cp\*(C'\fR to its foldcase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. The code point is interpreted as native if less than 256; otherwise as Unicode. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the foldcase version may be longer than the original character. .Sp The first code point of the foldcased version is returned (but note, as explained at the top of this section, that there may be more). .Sp .Vb 1 \& UV toFOLD_uvchr(UV cp, U8* s, STRLEN* lenp) .Ve .IP "toLOWER" 8 .IX Xref "toLOWER" .IX Item "toLOWER" Converts the specified character to lowercase. If the input is anything but an \&\s-1ASCII\s0 uppercase character, that input character itself is returned. Variant \&\f(CW\*(C`toLOWER_A\*(C'\fR is equivalent. .Sp .Vb 1 \& U8 toLOWER(U8 ch) .Ve .IP "toLOWER_L1" 8 .IX Xref "toLOWER_L1" .IX Item "toLOWER_L1" Converts the specified Latin1 character to lowercase. The results are undefined if the input doesn't fit in a byte. .Sp .Vb 1 \& U8 toLOWER_L1(U8 ch) .Ve .IP "toLOWER_LC" 8 .IX Xref "toLOWER_LC" .IX Item "toLOWER_LC" Converts the specified character to lowercase using the current locale's rules, if possible; otherwise returns the input character itself. .Sp .Vb 1 \& U8 toLOWER_LC(U8 ch) .Ve .IP "toLOWER_utf8" 8 .IX Xref "toLOWER_utf8" .IX Item "toLOWER_utf8" Converts the first \s-1UTF\-8\s0 encoded character in the sequence starting at \f(CW\*(C`p\*(C'\fR and extending no further than \f(CW\*(C`e \- 1\*(C'\fR to its lowercase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the lowercase version may be longer than the original character. .Sp The first code point of the lowercased version is returned (but note, as explained at the top of this section, that there may be more). It will not attempt to read beyond \f(CW\*(C`e \- 1\*(C'\fR, provided that the constraint \&\f(CW\*(C`s < e\*(C'\fR is true (this is asserted for in \f(CW\*(C`\-DDEBUGGING\*(C'\fR builds). If the \s-1UTF\-8\s0 for the input character is malformed in some way, the program may croak, or the function may return the \s-1REPLACEMENT CHARACTER,\s0 at the discretion of the implementation, and subject to change in future releases. .Sp .Vb 1 \& UV toLOWER_utf8(U8* p, U8* e, U8* s, STRLEN* lenp) .Ve .IP "toLOWER_utf8_safe" 8 .IX Xref "toLOWER_utf8_safe" .IX Item "toLOWER_utf8_safe" Same as \*(L"toLOWER_utf8\*(R". .Sp .Vb 2 \& UV toLOWER_utf8_safe(U8* p, U8* e, U8* s, \& STRLEN* lenp) .Ve .IP "toLOWER_uvchr" 8 .IX Xref "toLOWER_uvchr" .IX Item "toLOWER_uvchr" Converts the code point \f(CW\*(C`cp\*(C'\fR to its lowercase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. The code point is interpreted as native if less than 256; otherwise as Unicode. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the lowercase version may be longer than the original character. .Sp The first code point of the lowercased version is returned (but note, as explained at the top of this section, that there may be more). .Sp .Vb 1 \& UV toLOWER_uvchr(UV cp, U8* s, STRLEN* lenp) .Ve .IP "toTITLE" 8 .IX Xref "toTITLE" .IX Item "toTITLE" Converts the specified character to titlecase. If the input is anything but an \&\s-1ASCII\s0 lowercase character, that input character itself is returned. Variant \&\f(CW\*(C`toTITLE_A\*(C'\fR is equivalent. (There is no \f(CW\*(C`toTITLE_L1\*(C'\fR for the full Latin1 range, as the full generality of \*(L"toTITLE_uvchr\*(R" is needed there. Titlecase is not a concept used in locale handling, so there is no functionality for that.) .Sp .Vb 1 \& U8 toTITLE(U8 ch) .Ve .IP "toTITLE_utf8" 8 .IX Xref "toTITLE_utf8" .IX Item "toTITLE_utf8" Converts the first \s-1UTF\-8\s0 encoded character in the sequence starting at \f(CW\*(C`p\*(C'\fR and extending no further than \f(CW\*(C`e \- 1\*(C'\fR to its titlecase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the titlecase version may be longer than the original character. .Sp The first code point of the titlecased version is returned (but note, as explained at the top of this section, that there may be more). .Sp It will not attempt to read beyond \f(CW\*(C`e \- 1\*(C'\fR, provided that the constraint \f(CW\*(C`s < e\*(C'\fR is true (this is asserted for in \f(CW\*(C`\-DDEBUGGING\*(C'\fR builds). If the \s-1UTF\-8\s0 for the input character is malformed in some way, the program may croak, or the function may return the \s-1REPLACEMENT CHARACTER,\s0 at the discretion of the implementation, and subject to change in future releases. .Sp .Vb 1 \& UV toTITLE_utf8(U8* p, U8* e, U8* s, STRLEN* lenp) .Ve .IP "toTITLE_utf8_safe" 8 .IX Xref "toTITLE_utf8_safe" .IX Item "toTITLE_utf8_safe" Same as \*(L"toTITLE_utf8\*(R". .Sp .Vb 2 \& UV toTITLE_utf8_safe(U8* p, U8* e, U8* s, \& STRLEN* lenp) .Ve .IP "toTITLE_uvchr" 8 .IX Xref "toTITLE_uvchr" .IX Item "toTITLE_uvchr" Converts the code point \f(CW\*(C`cp\*(C'\fR to its titlecase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. The code point is interpreted as native if less than 256; otherwise as Unicode. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the titlecase version may be longer than the original character. .Sp The first code point of the titlecased version is returned (but note, as explained at the top of this section, that there may be more). .Sp .Vb 1 \& UV toTITLE_uvchr(UV cp, U8* s, STRLEN* lenp) .Ve .IP "toUPPER" 8 .IX Xref "toUPPER" .IX Item "toUPPER" Converts the specified character to uppercase. If the input is anything but an \&\s-1ASCII\s0 lowercase character, that input character itself is returned. Variant \&\f(CW\*(C`toUPPER_A\*(C'\fR is equivalent. .Sp .Vb 1 \& U8 toUPPER(int ch) .Ve .IP "toUPPER_utf8" 8 .IX Xref "toUPPER_utf8" .IX Item "toUPPER_utf8" Converts the first \s-1UTF\-8\s0 encoded character in the sequence starting at \f(CW\*(C`p\*(C'\fR and extending no further than \f(CW\*(C`e \- 1\*(C'\fR to its uppercase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the uppercase version may be longer than the original character. .Sp The first code point of the uppercased version is returned (but note, as explained at the top of this section, that there may be more). .Sp It will not attempt to read beyond \f(CW\*(C`e \- 1\*(C'\fR, provided that the constraint \&\f(CW\*(C`s < e\*(C'\fR is true (this is asserted for in \f(CW\*(C`\-DDEBUGGING\*(C'\fR builds). If the \s-1UTF\-8\s0 for the input character is malformed in some way, the program may croak, or the function may return the \s-1REPLACEMENT CHARACTER,\s0 at the discretion of the implementation, and subject to change in future releases. .Sp .Vb 1 \& UV toUPPER_utf8(U8* p, U8* e, U8* s, STRLEN* lenp) .Ve .IP "toUPPER_utf8_safe" 8 .IX Xref "toUPPER_utf8_safe" .IX Item "toUPPER_utf8_safe" Same as \*(L"toUPPER_utf8\*(R". .Sp .Vb 2 \& UV toUPPER_utf8_safe(U8* p, U8* e, U8* s, \& STRLEN* lenp) .Ve .IP "toUPPER_uvchr" 8 .IX Xref "toUPPER_uvchr" .IX Item "toUPPER_uvchr" Converts the code point \f(CW\*(C`cp\*(C'\fR to its uppercase version, and stores that in \s-1UTF\-8\s0 in \f(CW\*(C`s\*(C'\fR, and its length in bytes in \f(CW\*(C`lenp\*(C'\fR. The code point is interpreted as native if less than 256; otherwise as Unicode. Note that the buffer pointed to by \f(CW\*(C`s\*(C'\fR needs to be at least \f(CW\*(C`UTF8_MAXBYTES_CASE+1\*(C'\fR bytes since the uppercase version may be longer than the original character. .Sp The first code point of the uppercased version is returned (but note, as explained at the top of this section, that there may be more.) .Sp .Vb 1 \& UV toUPPER_uvchr(UV cp, U8* s, STRLEN* lenp) .Ve .IP "\s-1WIDEST_UTYPE\s0" 8 .IX Xref "WIDEST_UTYPE" .IX Item "WIDEST_UTYPE" Yields the widest unsigned integer type on the platform, currently either \&\f(CW\*(C`U32\*(C'\fR or \f(CW64\fR. This can be used in declarations such as .Sp .Vb 1 \& WIDEST_UTYPE my_uv; .Ve .Sp or casts .Sp .Vb 1 \& my_uv = (WIDEST_UTYPE) val; .Ve .SH "Character classification" .IX Header "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"\s-1POSIX\s0 Character Classes\*(R" in perlrecharclass.) 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 \f(CW\*(C`use bytes\*(C'\fR, and only the ones with \f(CW\*(C`LC\*(C'\fR in the name are affected by the current locale. .PP The base function, e.g., \f(CW\*(C`isALPHA()\*(C'\fR, takes any signed or unsigned value, treating it as a code point, and returns a boolean as to whether or not the character represented by it is (or on non-ASCII platforms, corresponds to) an \&\s-1ASCII\s0 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, \s-1FALSE\s0 is returned. .PP Variant \f(CW\*(C`is\f(CIFOO\f(CW_A\*(C'\fR (e.g., \f(CW\*(C`isALPHA_A()\*(C'\fR) is identical to the base function with no suffix \f(CW"_A"\fR. This variant is used to emphasize by its name that only ASCII-range characters can return \s-1TRUE.\s0 .PP Variant \f(CW\*(C`is\f(CIFOO\f(CW_L1\*(C'\fR imposes the Latin\-1 (or \s-1EBCDIC\s0 equivalent) character set onto the platform. That is, the code points that are \s-1ASCII\s0 are unaffected, since \s-1ASCII\s0 is a subset of Latin\-1. But the non-ASCII code points are treated as if they are Latin\-1 characters. For example, \f(CW\*(C`isWORDCHAR_L1()\*(C'\fR will return true when called with the code point 0xDF, which is a word character in both \&\s-1ASCII\s0 and \s-1EBCDIC\s0 (though it represents different characters in each). If the input is a number that doesn't fit in an octet, \s-1FALSE\s0 is returned. (Perl's documentation uses a colloquial definition of Latin\-1, to include all code points below 256.) .PP Variant \f(CW\*(C`is\f(CIFOO\f(CW_uvchr\*(C'\fR is exactly like the \f(CW\*(C`is\f(CIFOO\f(CW_L1\*(C'\fR variant, for inputs below 256, but if the code point is larger than 255, Unicode rules are used to determine if it is in the character class. For example, \&\f(CW\*(C`isWORDCHAR_uvchr(0x100)\*(C'\fR returns \s-1TRUE,\s0 since 0x100 is \s-1LATIN CAPITAL LETTER A WITH MACRON\s0 in Unicode, and is a word character. .PP Variants \f(CW\*(C`is\f(CIFOO\f(CW_utf8\*(C'\fR and \f(CW\*(C`is\f(CIFOO\f(CW_utf8_safe\*(C'\fR are like \f(CW\*(C`is\f(CIFOO\f(CW_uvchr\*(C'\fR, but are used for \s-1UTF\-8\s0 encoded strings. The two forms are different names for the same thing. Each call to one of these classifies the first character of the string starting at \f(CW\*(C`p\*(C'\fR. The second parameter, \f(CW\*(C`e\*(C'\fR, points to anywhere in the string beyond the first character, up to one byte past the end of the entire string. Although both variants are identical, the suffix \f(CW\*(C`_safe\*(C'\fR in one name emphasizes that it will not attempt to read beyond \f(CW\*(C`e \- 1\*(C'\fR, provided that the constraint \f(CW\*(C`s < e\*(C'\fR is true (this is asserted for in \&\f(CW\*(C`\-DDEBUGGING\*(C'\fR builds). If the \s-1UTF\-8\s0 for the input character is malformed in some way, the program may croak, or the function may return \s-1FALSE,\s0 at the discretion of the implementation, and subject to change in future releases. .PP Variant \f(CW\*(C`is\f(CIFOO\f(CW_LC\*(C'\fR is like the \f(CW\*(C`is\f(CIFOO\f(CW_A\*(C'\fR and \f(CW\*(C`is\f(CIFOO\f(CW_L1\*(C'\fR variants, but the result is based on the current locale, which is what \f(CW\*(C`LC\*(C'\fR in the name stands for. If Perl can determine that the current locale is a \s-1UTF\-8\s0 locale, it uses the published Unicode rules; otherwise, it uses the C library function that gives the named classification. For example, \f(CW\*(C`isDIGIT_LC()\*(C'\fR when not in a \s-1UTF\-8\s0 locale returns the result of calling \f(CW\*(C`isdigit()\*(C'\fR. \s-1FALSE\s0 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 \s-1POSIX\s0 standard's rules. .PP Variant \f(CW\*(C`is\f(CIFOO\f(CW_LC_uvchr\*(C'\fR acts exactly like \f(CW\*(C`is\f(CIFOO\f(CW_LC\*(C'\fR for inputs less than 256, but for larger ones it returns the Unicode classification of the code point. .PP Variants \f(CW\*(C`is\f(CIFOO\f(CW_LC_utf8\*(C'\fR and \f(CW\*(C`is\f(CIFOO\f(CW_LC_utf8_safe\*(C'\fR are like \&\f(CW\*(C`is\f(CIFOO\f(CW_LC_uvchr\*(C'\fR, but are used for \s-1UTF\-8\s0 encoded strings. The two forms are different names for the same thing. Each call to one of these classifies the first character of the string starting at \f(CW\*(C`p\*(C'\fR. The second parameter, \&\f(CW\*(C`e\*(C'\fR, points to anywhere in the string beyond the first character, up to one byte past the end of the entire string. Although both variants are identical, the suffix \f(CW\*(C`_safe\*(C'\fR in one name emphasizes that it will not attempt to read beyond \f(CW\*(C`e \- 1\*(C'\fR, provided that the constraint \f(CW\*(C`s < e\*(C'\fR is true (this is asserted for in \f(CW\*(C`\-DDEBUGGING\*(C'\fR builds). If the \s-1UTF\-8\s0 for the input character is malformed in some way, the program may croak, or the function may return \s-1FALSE,\s0 at the discretion of the implementation, and subject to change in future releases. .IP "isALPHA" 8 .IX Xref "isALPHA" .IX Item "isALPHA" Returns a boolean indicating whether the specified input is one of \f(CW\*(C`[A\-Za\-z]\*(C'\fR, analogous to \f(CW\*(C`m/[[:alpha:]]/\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isALPHA_A\*(C'\fR, \f(CW\*(C`isALPHA_L1\*(C'\fR, \f(CW\*(C`isALPHA_uvchr\*(C'\fR, \f(CW\*(C`isALPHA_utf8\*(C'\fR, \&\f(CW\*(C`isALPHA_utf8_safe\*(C'\fR, \f(CW\*(C`isALPHA_LC\*(C'\fR, \f(CW\*(C`isALPHA_LC_uvchr\*(C'\fR, \f(CW\*(C`isALPHA_LC_utf8\*(C'\fR, and \f(CW\*(C`isALPHA_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isALPHA(int ch) .Ve .IP "isALPHANUMERIC" 8 .IX Xref "isALPHANUMERIC" .IX Item "isALPHANUMERIC" Returns a boolean indicating whether the specified character is one of \&\f(CW\*(C`[A\-Za\-z0\-9]\*(C'\fR, analogous to \f(CW\*(C`m/[[:alnum:]]/\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isALPHANUMERIC_A\*(C'\fR, \f(CW\*(C`isALPHANUMERIC_L1\*(C'\fR, \f(CW\*(C`isALPHANUMERIC_uvchr\*(C'\fR, \&\f(CW\*(C`isALPHANUMERIC_utf8\*(C'\fR, \f(CW\*(C`isALPHANUMERIC_utf8_safe\*(C'\fR, \f(CW\*(C`isALPHANUMERIC_LC\*(C'\fR, \&\f(CW\*(C`isALPHANUMERIC_LC_uvchr\*(C'\fR, \f(CW\*(C`isALPHANUMERIC_LC_utf8\*(C'\fR, and \&\f(CW\*(C`isALPHANUMERIC_LC_utf8_safe\*(C'\fR. .Sp A (discouraged from use) synonym is \f(CW\*(C`isALNUMC\*(C'\fR (where the \f(CW\*(C`C\*(C'\fR suffix means this corresponds to the C language alphanumeric definition). Also there are the variants \&\f(CW\*(C`isALNUMC_A\*(C'\fR, \f(CW\*(C`isALNUMC_L1\*(C'\fR \&\f(CW\*(C`isALNUMC_LC\*(C'\fR, and \f(CW\*(C`isALNUMC_LC_uvchr\*(C'\fR. .Sp .Vb 1 \& bool isALPHANUMERIC(int ch) .Ve .IP "isASCII" 8 .IX Xref "isASCII" .IX Item "isASCII" Returns a boolean indicating whether the specified character is one of the 128 characters in the \s-1ASCII\s0 character set, analogous to \f(CW\*(C`m/[[:ascii:]]/\*(C'\fR. On non-ASCII platforms, it returns \s-1TRUE\s0 iff this character corresponds to an \s-1ASCII\s0 character. Variants \f(CW\*(C`isASCII_A()\*(C'\fR and \&\f(CW\*(C`isASCII_L1()\*(C'\fR are identical to \f(CW\*(C`isASCII()\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isASCII_uvchr\*(C'\fR, \f(CW\*(C`isASCII_utf8\*(C'\fR, \f(CW\*(C`isASCII_utf8_safe\*(C'\fR, \f(CW\*(C`isASCII_LC\*(C'\fR, \&\f(CW\*(C`isASCII_LC_uvchr\*(C'\fR, \f(CW\*(C`isASCII_LC_utf8\*(C'\fR, and \f(CW\*(C`isASCII_LC_utf8_safe\*(C'\fR. Note, however, that some platforms do not have the C library routine \&\f(CW\*(C`isascii()\*(C'\fR. In these cases, the variants whose names contain \f(CW\*(C`LC\*(C'\fR are the same as the corresponding ones without. .Sp .Vb 1 \& bool isASCII(int ch) .Ve .IP "isBLANK" 8 .IX Xref "isBLANK" .IX Item "isBLANK" Returns a boolean indicating whether the specified character is a character considered to be a blank, analogous to \f(CW\*(C`m/[[:blank:]]/\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isBLANK_A\*(C'\fR, \f(CW\*(C`isBLANK_L1\*(C'\fR, \f(CW\*(C`isBLANK_uvchr\*(C'\fR, \f(CW\*(C`isBLANK_utf8\*(C'\fR, \&\f(CW\*(C`isBLANK_utf8_safe\*(C'\fR, \f(CW\*(C`isBLANK_LC\*(C'\fR, \f(CW\*(C`isBLANK_LC_uvchr\*(C'\fR, \f(CW\*(C`isBLANK_LC_utf8\*(C'\fR, and \f(CW\*(C`isBLANK_LC_utf8_safe\*(C'\fR. Note, however, that some platforms do not have the C library routine \&\f(CW\*(C`isblank()\*(C'\fR. In these cases, the variants whose names contain \f(CW\*(C`LC\*(C'\fR are the same as the corresponding ones without. .Sp .Vb 1 \& bool isBLANK(char ch) .Ve .IP "isCNTRL" 8 .IX Xref "isCNTRL" .IX Item "isCNTRL" Returns a boolean indicating whether the specified character is a control character, analogous to \f(CW\*(C`m/[[:cntrl:]]/\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isCNTRL_A\*(C'\fR, \f(CW\*(C`isCNTRL_L1\*(C'\fR, \f(CW\*(C`isCNTRL_uvchr\*(C'\fR, \f(CW\*(C`isCNTRL_utf8\*(C'\fR, \&\f(CW\*(C`isCNTRL_utf8_safe\*(C'\fR, \f(CW\*(C`isCNTRL_LC\*(C'\fR, \f(CW\*(C`isCNTRL_LC_uvchr\*(C'\fR, \f(CW\*(C`isCNTRL_LC_utf8\*(C'\fR and \f(CW\*(C`isCNTRL_LC_utf8_safe\*(C'\fR. On \s-1EBCDIC\s0 platforms, you almost always want to use the \f(CW\*(C`isCNTRL_L1\*(C'\fR variant. .Sp .Vb 1 \& bool isCNTRL(char ch) .Ve .IP "isDIGIT" 8 .IX Xref "isDIGIT" .IX Item "isDIGIT" Returns a boolean indicating whether the specified character is a digit, analogous to \f(CW\*(C`m/[[:digit:]]/\*(C'\fR. Variants \f(CW\*(C`isDIGIT_A\*(C'\fR and \f(CW\*(C`isDIGIT_L1\*(C'\fR are identical to \f(CW\*(C`isDIGIT\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isDIGIT_uvchr\*(C'\fR, \f(CW\*(C`isDIGIT_utf8\*(C'\fR, \f(CW\*(C`isDIGIT_utf8_safe\*(C'\fR, \f(CW\*(C`isDIGIT_LC\*(C'\fR, \&\f(CW\*(C`isDIGIT_LC_uvchr\*(C'\fR, \f(CW\*(C`isDIGIT_LC_utf8\*(C'\fR, and \f(CW\*(C`isDIGIT_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isDIGIT(char ch) .Ve .IP "isGRAPH" 8 .IX Xref "isGRAPH" .IX Item "isGRAPH" Returns a boolean indicating whether the specified character is a graphic character, analogous to \f(CW\*(C`m/[[:graph:]]/\*(C'\fR. See the top of this section for an explanation of variants \f(CW\*(C`isGRAPH_A\*(C'\fR, \f(CW\*(C`isGRAPH_L1\*(C'\fR, \f(CW\*(C`isGRAPH_uvchr\*(C'\fR, \f(CW\*(C`isGRAPH_utf8\*(C'\fR, \&\f(CW\*(C`isGRAPH_utf8_safe\*(C'\fR, \f(CW\*(C`isGRAPH_LC\*(C'\fR, \f(CW\*(C`isGRAPH_LC_uvchr\*(C'\fR, \&\f(CW\*(C`isGRAPH_LC_utf8_safe\*(C'\fR, and \f(CW\*(C`isGRAPH_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isGRAPH(char ch) .Ve .IP "isIDCONT" 8 .IX Xref "isIDCONT" .IX Item "isIDCONT" 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 \f(CW\*(C`XID_Continue\*(C'\fR. The difference is that this returns true only if the input character also matches \&\*(L"isWORDCHAR\*(R". See the top of this section for an explanation of variants \f(CW\*(C`isIDCONT_A\*(C'\fR, \f(CW\*(C`isIDCONT_L1\*(C'\fR, \f(CW\*(C`isIDCONT_uvchr\*(C'\fR, \&\f(CW\*(C`isIDCONT_utf8\*(C'\fR, \f(CW\*(C`isIDCONT_utf8_safe\*(C'\fR, \f(CW\*(C`isIDCONT_LC\*(C'\fR, \f(CW\*(C`isIDCONT_LC_uvchr\*(C'\fR, \&\f(CW\*(C`isIDCONT_LC_utf8\*(C'\fR, and \f(CW\*(C`isIDCONT_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isIDCONT(char ch) .Ve .IP "isIDFIRST" 8 .IX Xref "isIDFIRST" .IX Item "isIDFIRST" 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 \f(CW\*(C`XID_Start\*(C'\fR. The difference is that this returns true only if the input character also matches \*(L"isWORDCHAR\*(R". See the top of this section for an explanation of variants \&\f(CW\*(C`isIDFIRST_A\*(C'\fR, \f(CW\*(C`isIDFIRST_L1\*(C'\fR, \f(CW\*(C`isIDFIRST_uvchr\*(C'\fR, \f(CW\*(C`isIDFIRST_utf8\*(C'\fR, \&\f(CW\*(C`isIDFIRST_utf8_safe\*(C'\fR, \f(CW\*(C`isIDFIRST_LC\*(C'\fR, \f(CW\*(C`isIDFIRST_LC_uvchr\*(C'\fR, \&\f(CW\*(C`isIDFIRST_LC_utf8\*(C'\fR, and \f(CW\*(C`isIDFIRST_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isIDFIRST(char ch) .Ve .IP "isLOWER" 8 .IX Xref "isLOWER" .IX Item "isLOWER" Returns a boolean indicating whether the specified character is a lowercase character, analogous to \f(CW\*(C`m/[[:lower:]]/\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isLOWER_A\*(C'\fR, \f(CW\*(C`isLOWER_L1\*(C'\fR, \f(CW\*(C`isLOWER_uvchr\*(C'\fR, \f(CW\*(C`isLOWER_utf8\*(C'\fR, \&\f(CW\*(C`isLOWER_utf8_safe\*(C'\fR, \f(CW\*(C`isLOWER_LC\*(C'\fR, \f(CW\*(C`isLOWER_LC_uvchr\*(C'\fR, \f(CW\*(C`isLOWER_LC_utf8\*(C'\fR, and \f(CW\*(C`isLOWER_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isLOWER(char ch) .Ve .IP "isOCTAL" 8 .IX Xref "isOCTAL" .IX Item "isOCTAL" Returns a boolean indicating whether the specified character is an octal digit, [0\-7]. The only two variants are \f(CW\*(C`isOCTAL_A\*(C'\fR and \f(CW\*(C`isOCTAL_L1\*(C'\fR; each is identical to \&\f(CW\*(C`isOCTAL\*(C'\fR. .Sp .Vb 1 \& bool isOCTAL(char ch) .Ve .IP "isPRINT" 8 .IX Xref "isPRINT" .IX Item "isPRINT" Returns a boolean indicating whether the specified character is a printable character, analogous to \f(CW\*(C`m/[[:print:]]/\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isPRINT_A\*(C'\fR, \f(CW\*(C`isPRINT_L1\*(C'\fR, \f(CW\*(C`isPRINT_uvchr\*(C'\fR, \f(CW\*(C`isPRINT_utf8\*(C'\fR, \&\f(CW\*(C`isPRINT_utf8_safe\*(C'\fR, \f(CW\*(C`isPRINT_LC\*(C'\fR, \f(CW\*(C`isPRINT_LC_uvchr\*(C'\fR, \f(CW\*(C`isPRINT_LC_utf8\*(C'\fR, and \f(CW\*(C`isPRINT_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isPRINT(char ch) .Ve .IP "isPSXSPC" 8 .IX Xref "isPSXSPC" .IX Item "isPSXSPC" (short for Posix Space) Starting in 5.18, this is identical in all its forms to the corresponding \f(CW\*(C`isSPACE()\*(C'\fR macros. The locale forms of this macro are identical to their corresponding \&\f(CW\*(C`isSPACE()\*(C'\fR forms in all Perl releases. In releases prior to 5.18, the non-locale forms differ from their \f(CW\*(C`isSPACE()\*(C'\fR forms only in that the \&\f(CW\*(C`isSPACE()\*(C'\fR forms don't match a Vertical Tab, and the \f(CW\*(C`isPSXSPC()\*(C'\fR forms do. Otherwise they are identical. Thus this macro is analogous to what \&\f(CW\*(C`m/[[:space:]]/\*(C'\fR matches in a regular expression. See the top of this section for an explanation of variants \f(CW\*(C`isPSXSPC_A\*(C'\fR, \f(CW\*(C`isPSXSPC_L1\*(C'\fR, \f(CW\*(C`isPSXSPC_uvchr\*(C'\fR, \f(CW\*(C`isPSXSPC_utf8\*(C'\fR, \&\f(CW\*(C`isPSXSPC_utf8_safe\*(C'\fR, \f(CW\*(C`isPSXSPC_LC\*(C'\fR, \f(CW\*(C`isPSXSPC_LC_uvchr\*(C'\fR, \&\f(CW\*(C`isPSXSPC_LC_utf8\*(C'\fR, and \f(CW\*(C`isPSXSPC_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isPSXSPC(char ch) .Ve .IP "isPUNCT" 8 .IX Xref "isPUNCT" .IX Item "isPUNCT" Returns a boolean indicating whether the specified character is a punctuation character, analogous to \f(CW\*(C`m/[[:punct:]]/\*(C'\fR. Note that the definition of what is punctuation isn't as straightforward as one might desire. See \*(L"\s-1POSIX\s0 Character Classes\*(R" in perlrecharclass for details. See the top of this section for an explanation of variants \f(CW\*(C`isPUNCT_A\*(C'\fR, \f(CW\*(C`isPUNCT_L1\*(C'\fR, \f(CW\*(C`isPUNCT_uvchr\*(C'\fR, \f(CW\*(C`isPUNCT_utf8\*(C'\fR, \&\f(CW\*(C`isPUNCT_utf8_safe\*(C'\fR, \f(CW\*(C`isPUNCT_LC\*(C'\fR, \f(CW\*(C`isPUNCT_LC_uvchr\*(C'\fR, \f(CW\*(C`isPUNCT_LC_utf8\*(C'\fR, and \f(CW\*(C`isPUNCT_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isPUNCT(char ch) .Ve .IP "isSPACE" 8 .IX Xref "isSPACE" .IX Item "isSPACE" Returns a boolean indicating whether the specified character is a whitespace character. This is analogous to what \f(CW\*(C`m/\es/\*(C'\fR matches in a regular expression. Starting in Perl 5.18 this also matches what \f(CW\*(C`m/[[:space:]]/\*(C'\fR does. Prior to 5.18, only the locale forms of this macro (the ones with \f(CW\*(C`LC\*(C'\fR in their names) matched precisely what \f(CW\*(C`m/[[:space:]]/\*(C'\fR does. In those releases, the only difference, in the non-locale variants, was that \f(CW\*(C`isSPACE()\*(C'\fR did not match a vertical tab. (See \*(L"isPSXSPC\*(R" for a macro that matches a vertical tab in all releases.) See the top of this section for an explanation of variants \&\f(CW\*(C`isSPACE_A\*(C'\fR, \f(CW\*(C`isSPACE_L1\*(C'\fR, \f(CW\*(C`isSPACE_uvchr\*(C'\fR, \f(CW\*(C`isSPACE_utf8\*(C'\fR, \&\f(CW\*(C`isSPACE_utf8_safe\*(C'\fR, \f(CW\*(C`isSPACE_LC\*(C'\fR, \f(CW\*(C`isSPACE_LC_uvchr\*(C'\fR, \f(CW\*(C`isSPACE_LC_utf8\*(C'\fR, and \f(CW\*(C`isSPACE_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isSPACE(char ch) .Ve .IP "isUPPER" 8 .IX Xref "isUPPER" .IX Item "isUPPER" Returns a boolean indicating whether the specified character is an uppercase character, analogous to \f(CW\*(C`m/[[:upper:]]/\*(C'\fR. See the top of this section for an explanation of variants \f(CW\*(C`isUPPER_A\*(C'\fR, \f(CW\*(C`isUPPER_L1\*(C'\fR, \f(CW\*(C`isUPPER_uvchr\*(C'\fR, \f(CW\*(C`isUPPER_utf8\*(C'\fR, \&\f(CW\*(C`isUPPER_utf8_safe\*(C'\fR, \f(CW\*(C`isUPPER_LC\*(C'\fR, \f(CW\*(C`isUPPER_LC_uvchr\*(C'\fR, \f(CW\*(C`isUPPER_LC_utf8\*(C'\fR, and \f(CW\*(C`isUPPER_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isUPPER(char ch) .Ve .IP "isWORDCHAR" 8 .IX Xref "isWORDCHAR" .IX Item "isWORDCHAR" Returns a boolean indicating whether the specified character is a character that is a word character, analogous to what \f(CW\*(C`m/\ew/\*(C'\fR and \f(CW\*(C`m/[[:word:]]/\*(C'\fR 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 \*(L"mark\*(R" character that attaches to one of those (like some sort of accent). \&\f(CW\*(C`isALNUM()\*(C'\fR is a synonym provided for backward compatibility, even though a word character includes more than the standard C language meaning of alphanumeric. See the top of this section for an explanation of variants \f(CW\*(C`isWORDCHAR_A\*(C'\fR, \f(CW\*(C`isWORDCHAR_L1\*(C'\fR, \f(CW\*(C`isWORDCHAR_uvchr\*(C'\fR, \&\f(CW\*(C`isWORDCHAR_utf8\*(C'\fR, and \f(CW\*(C`isWORDCHAR_utf8_safe\*(C'\fR. \f(CW\*(C`isWORDCHAR_LC\*(C'\fR, \&\f(CW\*(C`isWORDCHAR_LC_uvchr\*(C'\fR, \f(CW\*(C`isWORDCHAR_LC_utf8\*(C'\fR, and \f(CW\*(C`isWORDCHAR_LC_utf8_safe\*(C'\fR are also as described there, but additionally include the platform's native underscore. .Sp .Vb 1 \& bool isWORDCHAR(char ch) .Ve .IP "isXDIGIT" 8 .IX Xref "isXDIGIT" .IX Item "isXDIGIT" Returns a boolean indicating whether the specified character is a hexadecimal digit. In the \s-1ASCII\s0 range these are \f(CW\*(C`[0\-9A\-Fa\-f]\*(C'\fR. Variants \f(CW\*(C`isXDIGIT_A()\*(C'\fR and \f(CW\*(C`isXDIGIT_L1()\*(C'\fR are identical to \f(CW\*(C`isXDIGIT()\*(C'\fR. See the top of this section for an explanation of variants \&\f(CW\*(C`isXDIGIT_uvchr\*(C'\fR, \f(CW\*(C`isXDIGIT_utf8\*(C'\fR, \f(CW\*(C`isXDIGIT_utf8_safe\*(C'\fR, \f(CW\*(C`isXDIGIT_LC\*(C'\fR, \&\f(CW\*(C`isXDIGIT_LC_uvchr\*(C'\fR, \f(CW\*(C`isXDIGIT_LC_utf8\*(C'\fR, and \f(CW\*(C`isXDIGIT_LC_utf8_safe\*(C'\fR. .Sp .Vb 1 \& bool isXDIGIT(char ch) .Ve .SH "Cloning an interpreter" .IX Header "Cloning an interpreter" .IP "perl_clone" 8 .IX Xref "perl_clone" .IX Item "perl_clone" Create and return a new interpreter by cloning the current one. .Sp \&\f(CW\*(C`perl_clone\*(C'\fR takes these flags as parameters: .Sp \&\f(CW\*(C`CLONEf_COPY_STACKS\*(C'\fR \- 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 \f(CW\*(C`COPY_STACKS\*(C'\fR while the threads\->create doesn't. .Sp \&\f(CW\*(C`CLONEf_KEEP_PTR_TABLE\*(C'\fR \- \&\f(CW\*(C`perl_clone\*(C'\fR 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 \f(CW\*(C`KEEP_PTR_TABLE\*(C'\fR is not set then \f(CW\*(C`perl_clone\*(C'\fR will kill the ptr_table using the function \f(CW\*(C`ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;\*(C'\fR. A reason to keep it around is if you want to dup some of your own variables which are outside the graph that perl scans. .Sp \&\f(CW\*(C`CLONEf_CLONE_HOST\*(C'\fR \- This is a win32 thing, it is ignored on unix, it tells perl's 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. .Sp .Vb 4 \& PerlInterpreter* perl_clone( \& PerlInterpreter *proto_perl, \& UV flags \& ) .Ve .SH "Compile-time scope hooks" .IX Header "Compile-time scope hooks" .IP "BhkDISABLE" 8 .IX Xref "BhkDISABLE" .IX Item "BhkDISABLE" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Temporarily disable an entry in this \s-1BHK\s0 structure, by clearing the appropriate flag. \f(CW\*(C`which\*(C'\fR is a preprocessor token indicating which entry to disable. .Sp .Vb 1 \& void BhkDISABLE(BHK *hk, which) .Ve .IP "BhkENABLE" 8 .IX Xref "BhkENABLE" .IX Item "BhkENABLE" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Re-enable an entry in this \s-1BHK\s0 structure, by setting the appropriate flag. \f(CW\*(C`which\*(C'\fR is a preprocessor token indicating which entry to enable. This will assert (under \-DDEBUGGING) if the entry doesn't contain a valid pointer. .Sp .Vb 1 \& void BhkENABLE(BHK *hk, which) .Ve .IP "BhkENTRY_set" 8 .IX Xref "BhkENTRY_set" .IX Item "BhkENTRY_set" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Set an entry in the \s-1BHK\s0 structure, and set the flags to indicate it is valid. \f(CW\*(C`which\*(C'\fR is a preprocessing token indicating which entry to set. The type of \f(CW\*(C`ptr\*(C'\fR depends on the entry. .Sp .Vb 1 \& void BhkENTRY_set(BHK *hk, which, void *ptr) .Ve .IP "blockhook_register" 8 .IX Xref "blockhook_register" .IX Item "blockhook_register" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Register a set of hooks to be called when the Perl lexical scope changes at compile time. See \*(L"Compile-time scope hooks\*(R" in perlguts. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_blockhook_register with an aTHX_ parameter. .Sp .Vb 1 \& void Perl_blockhook_register(pTHX_ BHK *hk) .Ve .SH "COP Hint Hashes" .IX Header "COP Hint Hashes" .IP "cophh_2hv" 8 .IX Xref "cophh_2hv" .IX Item "cophh_2hv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Generates and returns a standard Perl hash representing the full set of key/value pairs in the cop hints hash \f(CW\*(C`cophh\*(C'\fR. \f(CW\*(C`flags\*(C'\fR is currently unused and must be zero. .Sp .Vb 1 \& HV * cophh_2hv(const COPHH *cophh, U32 flags) .Ve .IP "cophh_copy" 8 .IX Xref "cophh_copy" .IX Item "cophh_copy" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Make and return a complete copy of the cop hints hash \f(CW\*(C`cophh\*(C'\fR. .Sp .Vb 1 \& COPHH * cophh_copy(COPHH *cophh) .Ve .IP "cophh_delete_pv" 8 .IX Xref "cophh_delete_pv" .IX Item "cophh_delete_pv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_delete_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& COPHH * cophh_delete_pv(const COPHH *cophh, \& const char *key, U32 hash, \& U32 flags) .Ve .IP "cophh_delete_pvn" 8 .IX Xref "cophh_delete_pvn" .IX Item "cophh_delete_pvn" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Delete a key and its associated value from the cop hints hash \f(CW\*(C`cophh\*(C'\fR, and returns the modified hash. The returned hash pointer is in general not the same as the hash pointer that was passed in. The input hash is consumed by the function, and the pointer to it must not be subsequently used. Use \*(L"cophh_copy\*(R" if you need both hashes. .Sp The key is specified by \f(CW\*(C`keypv\*(C'\fR and \f(CW\*(C`keylen\*(C'\fR. If \f(CW\*(C`flags\*(C'\fR has the \&\f(CW\*(C`COPHH_KEY_UTF8\*(C'\fR bit set, the key octets are interpreted as \s-1UTF\-8,\s0 otherwise they are interpreted as Latin\-1. \f(CW\*(C`hash\*(C'\fR is a precomputed hash of the key string, or zero if it has not been precomputed. .Sp .Vb 4 \& COPHH * cophh_delete_pvn(COPHH *cophh, \& const char *keypv, \& STRLEN keylen, U32 hash, \& U32 flags) .Ve .IP "cophh_delete_pvs" 8 .IX Xref "cophh_delete_pvs" .IX Item "cophh_delete_pvs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_delete_pvn\*(R", but takes a literal string instead of a string/length pair, and no precomputed hash. .Sp .Vb 2 \& COPHH * cophh_delete_pvs(const COPHH *cophh, "key", \& U32 flags) .Ve .IP "cophh_delete_sv" 8 .IX Xref "cophh_delete_sv" .IX Item "cophh_delete_sv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_delete_pvn\*(R", but takes a Perl scalar instead of a string/length pair. .Sp .Vb 2 \& COPHH * cophh_delete_sv(const COPHH *cophh, SV *key, \& U32 hash, U32 flags) .Ve .IP "cophh_fetch_pv" 8 .IX Xref "cophh_fetch_pv" .IX Item "cophh_fetch_pv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_fetch_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& SV * cophh_fetch_pv(const COPHH *cophh, \& const char *key, U32 hash, \& U32 flags) .Ve .IP "cophh_fetch_pvn" 8 .IX Xref "cophh_fetch_pvn" .IX Item "cophh_fetch_pvn" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Look up the entry in the cop hints hash \f(CW\*(C`cophh\*(C'\fR with the key specified by \&\f(CW\*(C`keypv\*(C'\fR and \f(CW\*(C`keylen\*(C'\fR. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`COPHH_KEY_UTF8\*(C'\fR bit set, the key octets are interpreted as \s-1UTF\-8,\s0 otherwise they are interpreted as Latin\-1. \f(CW\*(C`hash\*(C'\fR 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 \f(CW&PL_sv_placeholder\fR if there is no value associated with the key. .Sp .Vb 4 \& SV * cophh_fetch_pvn(const COPHH *cophh, \& const char *keypv, \& STRLEN keylen, U32 hash, \& U32 flags) .Ve .IP "cophh_fetch_pvs" 8 .IX Xref "cophh_fetch_pvs" .IX Item "cophh_fetch_pvs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_fetch_pvn\*(R", but takes a literal string instead of a string/length pair, and no precomputed hash. .Sp .Vb 2 \& SV * cophh_fetch_pvs(const COPHH *cophh, "key", \& U32 flags) .Ve .IP "cophh_fetch_sv" 8 .IX Xref "cophh_fetch_sv" .IX Item "cophh_fetch_sv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_fetch_pvn\*(R", but takes a Perl scalar instead of a string/length pair. .Sp .Vb 2 \& SV * cophh_fetch_sv(const COPHH *cophh, SV *key, \& U32 hash, U32 flags) .Ve .IP "cophh_free" 8 .IX Xref "cophh_free" .IX Item "cophh_free" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Discard the cop hints hash \f(CW\*(C`cophh\*(C'\fR, freeing all resources associated with it. .Sp .Vb 1 \& void cophh_free(COPHH *cophh) .Ve .IP "cophh_new_empty" 8 .IX Xref "cophh_new_empty" .IX Item "cophh_new_empty" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Generate and return a fresh cop hints hash containing no entries. .Sp .Vb 1 \& COPHH * cophh_new_empty() .Ve .IP "cophh_store_pv" 8 .IX Xref "cophh_store_pv" .IX Item "cophh_store_pv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_store_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& COPHH * cophh_store_pv(const COPHH *cophh, \& const char *key, U32 hash, \& SV *value, U32 flags) .Ve .IP "cophh_store_pvn" 8 .IX Xref "cophh_store_pvn" .IX Item "cophh_store_pvn" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Stores a value, associated with a key, in the cop hints hash \f(CW\*(C`cophh\*(C'\fR, and returns the modified hash. The returned hash pointer is in general not the same as the hash pointer that was passed in. The input hash is consumed by the function, and the pointer to it must not be subsequently used. Use \*(L"cophh_copy\*(R" if you need both hashes. .Sp The key is specified by \f(CW\*(C`keypv\*(C'\fR and \f(CW\*(C`keylen\*(C'\fR. If \f(CW\*(C`flags\*(C'\fR has the \&\f(CW\*(C`COPHH_KEY_UTF8\*(C'\fR bit set, the key octets are interpreted as \s-1UTF\-8,\s0 otherwise they are interpreted as Latin\-1. \f(CW\*(C`hash\*(C'\fR is a precomputed hash of the key string, or zero if it has not been precomputed. .Sp \&\f(CW\*(C`value\*(C'\fR is the scalar value to store for this key. \f(CW\*(C`value\*(C'\fR 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. .Sp .Vb 3 \& COPHH * cophh_store_pvn(COPHH *cophh, const char *keypv, \& STRLEN keylen, U32 hash, \& SV *value, U32 flags) .Ve .IP "cophh_store_pvs" 8 .IX Xref "cophh_store_pvs" .IX Item "cophh_store_pvs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_store_pvn\*(R", but takes a literal string instead of a string/length pair, and no precomputed hash. .Sp .Vb 2 \& COPHH * cophh_store_pvs(const COPHH *cophh, "key", \& SV *value, U32 flags) .Ve .IP "cophh_store_sv" 8 .IX Xref "cophh_store_sv" .IX Item "cophh_store_sv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"cophh_store_pvn\*(R", but takes a Perl scalar instead of a string/length pair. .Sp .Vb 2 \& COPHH * cophh_store_sv(const COPHH *cophh, SV *key, \& U32 hash, SV *value, U32 flags) .Ve .SH "COP Hint Reading" .IX Header "COP Hint Reading" .IP "cop_hints_2hv" 8 .IX Xref "cop_hints_2hv" .IX Item "cop_hints_2hv" Generates and returns a standard Perl hash representing the full set of hint entries in the cop \f(CW\*(C`cop\*(C'\fR. \f(CW\*(C`flags\*(C'\fR is currently unused and must be zero. .Sp .Vb 1 \& HV * cop_hints_2hv(const COP *cop, U32 flags) .Ve .IP "cop_hints_fetch_pv" 8 .IX Xref "cop_hints_fetch_pv" .IX Item "cop_hints_fetch_pv" Like \*(L"cop_hints_fetch_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& SV * cop_hints_fetch_pv(const COP *cop, \& const char *key, U32 hash, \& U32 flags) .Ve .IP "cop_hints_fetch_pvn" 8 .IX Xref "cop_hints_fetch_pvn" .IX Item "cop_hints_fetch_pvn" Look up the hint entry in the cop \f(CW\*(C`cop\*(C'\fR with the key specified by \&\f(CW\*(C`keypv\*(C'\fR and \f(CW\*(C`keylen\*(C'\fR. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`COPHH_KEY_UTF8\*(C'\fR bit set, the key octets are interpreted as \s-1UTF\-8,\s0 otherwise they are interpreted as Latin\-1. \f(CW\*(C`hash\*(C'\fR 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 \f(CW&PL_sv_placeholder\fR if there is no value associated with the key. .Sp .Vb 4 \& SV * cop_hints_fetch_pvn(const COP *cop, \& const char *keypv, \& STRLEN keylen, U32 hash, \& U32 flags) .Ve .IP "cop_hints_fetch_pvs" 8 .IX Xref "cop_hints_fetch_pvs" .IX Item "cop_hints_fetch_pvs" Like \*(L"cop_hints_fetch_pvn\*(R", but takes a literal string instead of a string/length pair, and no precomputed hash. .Sp .Vb 2 \& SV * cop_hints_fetch_pvs(const COP *cop, "key", \& U32 flags) .Ve .IP "cop_hints_fetch_sv" 8 .IX Xref "cop_hints_fetch_sv" .IX Item "cop_hints_fetch_sv" Like \*(L"cop_hints_fetch_pvn\*(R", but takes a Perl scalar instead of a string/length pair. .Sp .Vb 2 \& SV * cop_hints_fetch_sv(const COP *cop, SV *key, \& U32 hash, U32 flags) .Ve .IP "CopLABEL" 8 .IX Xref "CopLABEL" .IX Item "CopLABEL" Returns the label attached to a cop. .Sp .Vb 1 \& const char * CopLABEL(COP *const cop) .Ve .IP "CopLABEL_len" 8 .IX Xref "CopLABEL_len" .IX Item "CopLABEL_len" Returns the label attached to a cop, and stores its length in bytes into \&\f(CW*len\fR. .Sp .Vb 1 \& const char * CopLABEL_len(COP *const cop, STRLEN *len) .Ve .IP "CopLABEL_len_flags" 8 .IX Xref "CopLABEL_len_flags" .IX Item "CopLABEL_len_flags" Returns the label attached to a cop, and stores its length in bytes into \&\f(CW*len\fR. Upon return, \f(CW*flags\fR will be set to either \f(CW\*(C`SVf_UTF8\*(C'\fR or 0. .Sp .Vb 2 \& const char * CopLABEL_len_flags(COP *const cop, \& STRLEN *len, U32 *flags) .Ve .SH "Custom Operators" .IX Header "Custom Operators" .IP "custom_op_register" 8 .IX Xref "custom_op_register" .IX Item "custom_op_register" Register a custom op. See \*(L"Custom Operators\*(R" in perlguts. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_custom_op_register with an aTHX_ parameter. .Sp .Vb 3 \& void Perl_custom_op_register(pTHX_ \& Perl_ppaddr_t ppaddr, \& const XOP *xop) .Ve .IP "Perl_custom_op_xop" 8 .IX Xref "Perl_custom_op_xop" .IX Item "Perl_custom_op_xop" Return the \s-1XOP\s0 structure for a given custom op. This macro should be considered internal to \f(CW\*(C`OP_NAME\*(C'\fR 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. .Sp .Vb 1 \& const XOP * Perl_custom_op_xop(pTHX_ const OP *o) .Ve .IP "XopDISABLE" 8 .IX Xref "XopDISABLE" .IX Item "XopDISABLE" Temporarily disable a member of the \s-1XOP,\s0 by clearing the appropriate flag. .Sp .Vb 1 \& void XopDISABLE(XOP *xop, which) .Ve .IP "XopENABLE" 8 .IX Xref "XopENABLE" .IX Item "XopENABLE" Reenable a member of the \s-1XOP\s0 which has been disabled. .Sp .Vb 1 \& void XopENABLE(XOP *xop, which) .Ve .IP "XopENTRY" 8 .IX Xref "XopENTRY" .IX Item "XopENTRY" Return a member of the \s-1XOP\s0 structure. \f(CW\*(C`which\*(C'\fR 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 \f(CW\*(C`which\*(C'\fR. This macro evaluates its arguments more than once. If you are using \f(CW\*(C`Perl_custom_op_xop\*(C'\fR to retreive a \&\f(CW\*(C`XOP *\*(C'\fR from a \f(CW\*(C`OP *\*(C'\fR, use the more efficient \*(L"XopENTRYCUSTOM\*(R" instead. .Sp .Vb 1 \& XopENTRY(XOP *xop, which) .Ve .IP "XopENTRYCUSTOM" 8 .IX Xref "XopENTRYCUSTOM" .IX Item "XopENTRYCUSTOM" Exactly like \f(CW\*(C`XopENTRY(XopENTRY(Perl_custom_op_xop(aTHX_ o), which)\*(C'\fR but more efficient. The \f(CW\*(C`which\*(C'\fR parameter is identical to \*(L"XopENTRY\*(R". .Sp .Vb 1 \& XopENTRYCUSTOM(const OP *o, which) .Ve .IP "XopENTRY_set" 8 .IX Xref "XopENTRY_set" .IX Item "XopENTRY_set" Set a member of the \s-1XOP\s0 structure. \f(CW\*(C`which\*(C'\fR is a cpp token indicating which entry to set. See \*(L"Custom Operators\*(R" in perlguts for details about the available members and how they are used. This macro evaluates its argument more than once. .Sp .Vb 1 \& void XopENTRY_set(XOP *xop, which, value) .Ve .IP "XopFLAGS" 8 .IX Xref "XopFLAGS" .IX Item "XopFLAGS" Return the \s-1XOP\s0's flags. .Sp .Vb 1 \& U32 XopFLAGS(XOP *xop) .Ve .SH "CV Manipulation Functions" .IX Header "CV Manipulation Functions" This section documents functions to manipulate CVs which are code-values, or subroutines. For more information, see perlguts. .IP "caller_cx" 8 .IX Xref "caller_cx" .IX Item "caller_cx" The XSUB-writer's equivalent of \fBcaller()\fR. The returned \f(CW\*(C`PERL_CONTEXT\*(C'\fR structure can be interrogated to find all the information returned to Perl by \f(CW\*(C`caller\*(C'\fR. Note that XSUBs don't get a stack frame, so \f(CW\*(C`caller_cx(0, NULL)\*(C'\fR will return information for the immediately-surrounding Perl code. .Sp This function skips over the automatic calls to \f(CW&DB::sub\fR made on the behalf of the debugger. If the stack frame requested was a sub called by \&\f(CW\*(C`DB::sub\*(C'\fR, the return value will be the frame for the call to \&\f(CW\*(C`DB::sub\*(C'\fR, since that has the correct line number/etc. for the call site. If \fIdbcxp\fR is non\-\f(CW\*(C`NULL\*(C'\fR, it will be set to a pointer to the frame for the sub call itself. .Sp .Vb 4 \& const PERL_CONTEXT * caller_cx( \& I32 level, \& const PERL_CONTEXT **dbcxp \& ) .Ve .IP "CvSTASH" 8 .IX Xref "CvSTASH" .IX Item "CvSTASH" Returns the stash of the \s-1CV.\s0 A stash is the symbol table hash, containing the package-scoped variables in the package where the subroutine was defined. For more information, see perlguts. .Sp This also has a special use with \s-1XS AUTOLOAD\s0 subs. See \*(L"Autoloading with XSUBs\*(R" in perlguts. .Sp .Vb 1 \& HV* CvSTASH(CV* cv) .Ve .IP "find_runcv" 8 .IX Xref "find_runcv" .IX Item "find_runcv" Locate the \s-1CV\s0 corresponding to the currently executing sub or eval. If \f(CW\*(C`db_seqp\*(C'\fR is non_null, skip CVs that are in the \s-1DB\s0 package and populate \&\f(CW*db_seqp\fR with the cop sequence number at the point that the \s-1DB::\s0 code was entered. (This allows debuggers to eval in the scope of the breakpoint rather than in the scope of the debugger itself.) .Sp .Vb 1 \& CV* find_runcv(U32 *db_seqp) .Ve .IP "get_cv" 8 .IX Xref "get_cv" .IX Item "get_cv" Uses \f(CW\*(C`strlen\*(C'\fR to get the length of \f(CW\*(C`name\*(C'\fR, then calls \f(CW\*(C`get_cvn_flags\*(C'\fR. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& CV* get_cv(const char* name, I32 flags) .Ve .IP "get_cvn_flags" 8 .IX Xref "get_cvn_flags" .IX Item "get_cvn_flags" Returns the \s-1CV\s0 of the specified Perl subroutine. \f(CW\*(C`flags\*(C'\fR are passed to \&\f(CW\*(C`gv_fetchpvn_flags\*(C'\fR. If \f(CW\*(C`GV_ADD\*(C'\fR is set and the Perl subroutine does not exist then it will be declared (which has the same effect as saying \&\f(CW\*(C`sub name;\*(C'\fR). If \f(CW\*(C`GV_ADD\*(C'\fR is not set and the subroutine does not exist then \s-1NULL\s0 is returned. .Sp .Vb 2 \& CV* get_cvn_flags(const char* name, STRLEN len, \& I32 flags) .Ve .ie n .SH """xsubpp"" variables and internal functions" .el .SH "\f(CWxsubpp\fP variables and internal functions" .IX Header "xsubpp variables and internal functions" .IP "ax" 8 .IX Xref "ax" .IX Item "ax" Variable which is setup by \f(CW\*(C`xsubpp\*(C'\fR to indicate the stack base offset, used by the \f(CW\*(C`ST\*(C'\fR, \f(CW\*(C`XSprePUSH\*(C'\fR and \f(CW\*(C`XSRETURN\*(C'\fR macros. The \f(CW\*(C`dMARK\*(C'\fR macro must be called prior to setup the \f(CW\*(C`MARK\*(C'\fR variable. .Sp .Vb 1 \& I32 ax .Ve .IP "\s-1CLASS\s0" 8 .IX Xref "CLASS" .IX Item "CLASS" Variable which is setup by \f(CW\*(C`xsubpp\*(C'\fR to indicate the class name for a \*(C+ \s-1XS\s0 constructor. This is always a \f(CW\*(C`char*\*(C'\fR. See \&\f(CW"THIS"\fR. .Sp .Vb 1 \& char* CLASS .Ve .IP "dAX" 8 .IX Xref "dAX" .IX Item "dAX" Sets up the \f(CW\*(C`ax\*(C'\fR variable. This is usually handled automatically by \f(CW\*(C`xsubpp\*(C'\fR by calling \f(CW\*(C`dXSARGS\*(C'\fR. .Sp .Vb 1 \& dAX; .Ve .IP "dAXMARK" 8 .IX Xref "dAXMARK" .IX Item "dAXMARK" Sets up the \f(CW\*(C`ax\*(C'\fR variable and stack marker variable \f(CW\*(C`mark\*(C'\fR. This is usually handled automatically by \f(CW\*(C`xsubpp\*(C'\fR by calling \f(CW\*(C`dXSARGS\*(C'\fR. .Sp .Vb 1 \& dAXMARK; .Ve .IP "dITEMS" 8 .IX Xref "dITEMS" .IX Item "dITEMS" Sets up the \f(CW\*(C`items\*(C'\fR variable. This is usually handled automatically by \f(CW\*(C`xsubpp\*(C'\fR by calling \f(CW\*(C`dXSARGS\*(C'\fR. .Sp .Vb 1 \& dITEMS; .Ve .IP "dUNDERBAR" 8 .IX Xref "dUNDERBAR" .IX Item "dUNDERBAR" Sets up any variable needed by the \f(CW\*(C`UNDERBAR\*(C'\fR macro. It used to define \&\f(CW\*(C`padoff_du\*(C'\fR, but it is currently a noop. However, it is strongly advised to still use it for ensuring past and future compatibility. .Sp .Vb 1 \& dUNDERBAR; .Ve .IP "dXSARGS" 8 .IX Xref "dXSARGS" .IX Item "dXSARGS" Sets up stack and mark pointers for an \s-1XSUB,\s0 calling \f(CW\*(C`dSP\*(C'\fR and \f(CW\*(C`dMARK\*(C'\fR. Sets up the \f(CW\*(C`ax\*(C'\fR and \f(CW\*(C`items\*(C'\fR variables by calling \f(CW\*(C`dAX\*(C'\fR and \f(CW\*(C`dITEMS\*(C'\fR. This is usually handled automatically by \f(CW\*(C`xsubpp\*(C'\fR. .Sp .Vb 1 \& dXSARGS; .Ve .IP "dXSI32" 8 .IX Xref "dXSI32" .IX Item "dXSI32" Sets up the \f(CW\*(C`ix\*(C'\fR variable for an \s-1XSUB\s0 which has aliases. This is usually handled automatically by \f(CW\*(C`xsubpp\*(C'\fR. .Sp .Vb 1 \& dXSI32; .Ve .IP "items" 8 .IX Xref "items" .IX Item "items" Variable which is setup by \f(CW\*(C`xsubpp\*(C'\fR to indicate the number of items on the stack. See \*(L"Variable-length Parameter Lists\*(R" in perlxs. .Sp .Vb 1 \& I32 items .Ve .IP "ix" 8 .IX Xref "ix" .IX Item "ix" Variable which is setup by \f(CW\*(C`xsubpp\*(C'\fR to indicate which of an \&\s-1XSUB\s0's aliases was used to invoke it. See \*(L"The \s-1ALIAS:\s0 Keyword\*(R" in perlxs. .Sp .Vb 1 \& I32 ix .Ve .IP "\s-1RETVAL\s0" 8 .IX Xref "RETVAL" .IX Item "RETVAL" Variable which is setup by \f(CW\*(C`xsubpp\*(C'\fR to hold the return value for an \&\s-1XSUB.\s0 This is always the proper type for the \s-1XSUB.\s0 See \&\*(L"The \s-1RETVAL\s0 Variable\*(R" in perlxs. .Sp .Vb 1 \& (whatever) RETVAL .Ve .IP "\s-1ST\s0" 8 .IX Xref "ST" .IX Item "ST" Used to access elements on the \s-1XSUB\s0's stack. .Sp .Vb 1 \& SV* ST(int ix) .Ve .IP "\s-1THIS\s0" 8 .IX Xref "THIS" .IX Item "THIS" Variable which is setup by \f(CW\*(C`xsubpp\*(C'\fR to designate the object in a \*(C+ \&\s-1XSUB.\s0 This is always the proper type for the \*(C+ object. See \f(CW"CLASS"\fR and \&\*(L"Using \s-1XS\s0 With \*(C+\*(R" in perlxs. .Sp .Vb 1 \& (whatever) THIS .Ve .IP "\s-1UNDERBAR\s0" 8 .IX Xref "UNDERBAR" .IX Item "UNDERBAR" The SV* corresponding to the \f(CW$_\fR variable. Works even if there is a lexical \f(CW$_\fR in scope. .IP "\s-1XS\s0" 8 .IX Xref "XS" .IX Item "XS" Macro to declare an \s-1XSUB\s0 and its C parameter list. This is handled by \&\f(CW\*(C`xsubpp\*(C'\fR. It is the same as using the more explicit \f(CW\*(C`XS_EXTERNAL\*(C'\fR macro. .IP "\s-1XS_EXTERNAL\s0" 8 .IX Xref "XS_EXTERNAL" .IX Item "XS_EXTERNAL" Macro to declare an \s-1XSUB\s0 and its C parameter list explicitly exporting the symbols. .IP "\s-1XS_INTERNAL\s0" 8 .IX Xref "XS_INTERNAL" .IX Item "XS_INTERNAL" Macro to declare an \s-1XSUB\s0 and its C parameter list without exporting the symbols. This is handled by \f(CW\*(C`xsubpp\*(C'\fR and generally preferable over exporting the \s-1XSUB\s0 symbols unnecessarily. .SH "Debugging Utilities" .IX Header "Debugging Utilities" .IP "dump_all" 8 .IX Xref "dump_all" .IX Item "dump_all" Dumps the entire optree of the current program starting at \f(CW\*(C`PL_main_root\*(C'\fR to \&\f(CW\*(C`STDERR\*(C'\fR. Also dumps the optrees for all visible subroutines in \&\f(CW\*(C`PL_defstash\*(C'\fR. .Sp .Vb 1 \& void dump_all() .Ve .IP "dump_packsubs" 8 .IX Xref "dump_packsubs" .IX Item "dump_packsubs" Dumps the optrees for all visible subroutines in \f(CW\*(C`stash\*(C'\fR. .Sp .Vb 1 \& void dump_packsubs(const HV* stash) .Ve .IP "op_class" 8 .IX Xref "op_class" .IX Item "op_class" Given an op, determine what type of struct it has been allocated as. Returns one of the OPclass enums, such as OPclass_LISTOP. .Sp .Vb 1 \& OPclass op_class(const OP *o) .Ve .IP "op_dump" 8 .IX Xref "op_dump" .IX Item "op_dump" Dumps the optree starting at \s-1OP\s0 \f(CW\*(C`o\*(C'\fR to \f(CW\*(C`STDERR\*(C'\fR. .Sp .Vb 1 \& void op_dump(const OP *o) .Ve .IP "sv_dump" 8 .IX Xref "sv_dump" .IX Item "sv_dump" Dumps the contents of an \s-1SV\s0 to the \f(CW\*(C`STDERR\*(C'\fR filehandle. .Sp For an example of its output, see Devel::Peek. .Sp .Vb 1 \& void sv_dump(SV* sv) .Ve .SH "Display and Dump functions" .IX Header "Display and Dump functions" .IP "pv_display" 8 .IX Xref "pv_display" .IX Item "pv_display" Similar to .Sp .Vb 1 \& pv_escape(dsv,pv,cur,pvlim,PERL_PV_ESCAPE_QUOTE); .Ve .Sp except that an additional \*(L"\e0\*(R" will be appended to the string when len > cur and pv[cur] is \*(L"\e0\*(R". .Sp Note that the final string may be up to 7 chars longer than pvlim. .Sp .Vb 2 \& char* pv_display(SV *dsv, const char *pv, STRLEN cur, \& STRLEN len, STRLEN pvlim) .Ve .IP "pv_escape" 8 .IX Xref "pv_escape" .IX Item "pv_escape" Escapes at most the first \f(CW\*(C`count\*(C'\fR chars of \f(CW\*(C`pv\*(C'\fR and puts the results into \&\f(CW\*(C`dsv\*(C'\fR such that the size of the escaped string will not exceed \f(CW\*(C`max\*(C'\fR chars and will not contain any incomplete escape sequences. The number of bytes escaped will be returned in the \f(CW\*(C`STRLEN *escaped\*(C'\fR parameter if it is not null. When the \f(CW\*(C`dsv\*(C'\fR parameter is null no escaping actually occurs, but the number of bytes that would be escaped were it not null will be calculated. .Sp If flags contains \f(CW\*(C`PERL_PV_ESCAPE_QUOTE\*(C'\fR then any double quotes in the string will also be escaped. .Sp Normally the \s-1SV\s0 will be cleared before the escaped string is prepared, but when \f(CW\*(C`PERL_PV_ESCAPE_NOCLEAR\*(C'\fR is set this will not occur. .Sp If \f(CW\*(C`PERL_PV_ESCAPE_UNI\*(C'\fR is set then the input string is treated as \s-1UTF\-8\s0 if \f(CW\*(C`PERL_PV_ESCAPE_UNI_DETECT\*(C'\fR is set then the input string is scanned using \f(CW\*(C`is_utf8_string()\*(C'\fR to determine if it is \s-1UTF\-8.\s0 .Sp If \f(CW\*(C`PERL_PV_ESCAPE_ALL\*(C'\fR is set then all input chars will be output using \f(CW\*(C`\ex01F1\*(C'\fR style escapes, otherwise if \f(CW\*(C`PERL_PV_ESCAPE_NONASCII\*(C'\fR 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 \f(CW\*(C`\en\*(C'\fR. Otherwise, if \f(CW\*(C`PERL_PV_ESCAPE_NOBACKSLASH\*(C'\fR then all chars below 255 will be treated as printable and will be output as literals. .Sp If \f(CW\*(C`PERL_PV_ESCAPE_FIRSTCHAR\*(C'\fR 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 \f(CW\*(C`\en\*(C'\fR or a hex value. .Sp If \f(CW\*(C`PERL_PV_ESCAPE_RE\*(C'\fR is set then the escape char used will be a \f(CW"%"\fR and not a \f(CW"\e\e"\fR. This is because regexes very often contain backslashed sequences, whereas \f(CW"%"\fR is not a particularly common character in patterns. .Sp Returns a pointer to the escaped text as held by \f(CW\*(C`dsv\*(C'\fR. .Sp .Vb 4 \& char* pv_escape(SV *dsv, char const * const str, \& const STRLEN count, const STRLEN max, \& STRLEN * const escaped, \& const U32 flags) .Ve .IP "pv_pretty" 8 .IX Xref "pv_pretty" .IX Item "pv_pretty" Converts a string into something presentable, handling escaping via \&\f(CW\*(C`pv_escape()\*(C'\fR and supporting quoting and ellipses. .Sp If the \f(CW\*(C`PERL_PV_PRETTY_QUOTE\*(C'\fR flag is set then the result will be double quoted with any double quotes in the string escaped. Otherwise if the \f(CW\*(C`PERL_PV_PRETTY_LTGT\*(C'\fR flag is set then the result be wrapped in angle brackets. .Sp If the \f(CW\*(C`PERL_PV_PRETTY_ELLIPSES\*(C'\fR flag is set and not all characters in string were output then an ellipsis \f(CW\*(C`...\*(C'\fR will be appended to the string. Note that this happens \s-1AFTER\s0 it has been quoted. .Sp If \f(CW\*(C`start_color\*(C'\fR is non-null then it will be inserted after the opening quote (if there is one) but before the escaped text. If \f(CW\*(C`end_color\*(C'\fR is non-null then it will be inserted after the escaped text but before any quotes or ellipses. .Sp Returns a pointer to the prettified text as held by \f(CW\*(C`dsv\*(C'\fR. .Sp .Vb 5 \& 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) .Ve .SH "Embedding Functions" .IX Header "Embedding Functions" .IP "cv_clone" 8 .IX Xref "cv_clone" .IX Item "cv_clone" Clone a \s-1CV,\s0 making a lexical closure. \f(CW\*(C`proto\*(C'\fR 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. .Sp .Vb 1 \& CV* cv_clone(CV* proto) .Ve .IP "cv_name" 8 .IX Xref "cv_name" .IX Item "cv_name" Returns an \s-1SV\s0 containing the name of the \s-1CV,\s0 mainly for use in error reporting. The \s-1CV\s0 may actually be a \s-1GV\s0 instead, in which case the returned \&\s-1SV\s0 holds the \s-1GV\s0's name. Anything other than a \s-1GV\s0 or \s-1CV\s0 is treated as a string already holding the sub name, but this could change in the future. .Sp An \s-1SV\s0 may be passed as a second argument. If so, the name will be assigned to it and it will be returned. Otherwise the returned \s-1SV\s0 will be a new mortal. .Sp If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`CV_NAME_NOTQUAL\*(C'\fR bit set, then the package name will not be included. If the first argument is neither a \s-1CV\s0 nor a \s-1GV,\s0 this flag is ignored (subject to change). .Sp .Vb 1 \& SV * cv_name(CV *cv, SV *sv, U32 flags) .Ve .IP "cv_undef" 8 .IX Xref "cv_undef" .IX Item "cv_undef" Clear out all the active components of a \s-1CV.\s0 This can happen either by an explicit \f(CW\*(C`undef &foo\*(C'\fR, or by the reference count going to zero. In the former case, we keep the \f(CW\*(C`CvOUTSIDE\*(C'\fR pointer, so that any anonymous children can still follow the full lexical scope chain. .Sp .Vb 1 \& void cv_undef(CV* cv) .Ve .IP "find_rundefsv" 8 .IX Xref "find_rundefsv" .IX Item "find_rundefsv" Returns the global variable \f(CW$_\fR. .Sp .Vb 1 \& SV* find_rundefsv() .Ve .IP "find_rundefsvoffset" 8 .IX Xref "find_rundefsvoffset" .IX Item "find_rundefsvoffset" \&\s-1DEPRECATED\s0! 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. .Sp Until the lexical \f(CW$_\fR feature was removed, this function would find the position of the lexical \f(CW$_\fR in the pad of the currently-executing function and return the offset in the current pad, or \f(CW\*(C`NOT_IN_PAD\*(C'\fR. .Sp Now it always returns \f(CW\*(C`NOT_IN_PAD\*(C'\fR. .Sp .Vb 1 \& PADOFFSET find_rundefsvoffset() .Ve .IP "intro_my" 8 .IX Xref "intro_my" .IX Item "intro_my" \&\*(L"Introduce\*(R" \f(CW\*(C`my\*(C'\fR variables to visible status. This is called during parsing at the end of each statement to make lexical variables visible to subsequent statements. .Sp .Vb 1 \& U32 intro_my() .Ve .IP "load_module" 8 .IX Xref "load_module" .IX Item "load_module" Loads the module whose name is pointed to by the string part of \f(CW\*(C`name\*(C'\fR. Note that the actual module name, not its filename, should be given. Eg, \*(L"Foo::Bar\*(R" instead of \*(L"Foo/Bar.pm\*(R". ver, if specified and not \s-1NULL,\s0 provides version semantics similar to \f(CW\*(C`use Foo::Bar VERSION\*(C'\fR. The optional trailing arguments can be used to specify arguments to the module's \f(CW\*(C`import()\*(C'\fR method, similar to \f(CW\*(C`use Foo::Bar VERSION LIST\*(C'\fR; their precise handling depends on the flags. The flags argument is a bitwise-ORed collection of any of \&\f(CW\*(C`PERL_LOADMOD_DENY\*(C'\fR, \f(CW\*(C`PERL_LOADMOD_NOIMPORT\*(C'\fR, or \f(CW\*(C`PERL_LOADMOD_IMPORT_OPS\*(C'\fR (or 0 for no flags). .Sp If \f(CW\*(C`PERL_LOADMOD_NOIMPORT\*(C'\fR is set, the module is loaded as if with an empty import list, as in \f(CW\*(C`use Foo::Bar ()\*(C'\fR; this is the only circumstance in which the trailing optional arguments may be omitted entirely. Otherwise, if \&\f(CW\*(C`PERL_LOADMOD_IMPORT_OPS\*(C'\fR is set, the trailing arguments must consist of exactly one \f(CW\*(C`OP*\*(C'\fR, containing the op tree that produces the relevant import arguments. Otherwise, the trailing arguments must all be \f(CW\*(C`SV*\*(C'\fR values that will be used as import arguments; and the list must be terminated with \f(CW\*(C`(SV*) NULL\*(C'\fR. If neither \f(CW\*(C`PERL_LOADMOD_NOIMPORT\*(C'\fR nor \f(CW\*(C`PERL_LOADMOD_IMPORT_OPS\*(C'\fR is set, the trailing \f(CW\*(C`NULL\*(C'\fR pointer is needed even if no import arguments are desired. The reference count for each specified \f(CW\*(C`SV*\*(C'\fR argument is decremented. In addition, the \f(CW\*(C`name\*(C'\fR argument is modified. .Sp If \f(CW\*(C`PERL_LOADMOD_DENY\*(C'\fR is set, the module is loaded as if with \f(CW\*(C`no\*(C'\fR rather than \f(CW\*(C`use\*(C'\fR. .Sp .Vb 1 \& void load_module(U32 flags, SV* name, SV* ver, ...) .Ve .IP "my_exit" 8 .IX Xref "my_exit" .IX Item "my_exit" A wrapper for the C library \fBexit\fR\|(3), honoring what \*(L"PL_exit_flags\*(R" in perlapi say to do. .Sp .Vb 1 \& void my_exit(U32 status) .Ve .IP "newPADNAMELIST" 8 .IX Xref "newPADNAMELIST" .IX Item "newPADNAMELIST" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Creates a new pad name list. \f(CW\*(C`max\*(C'\fR is the highest index for which space is allocated. .Sp .Vb 1 \& PADNAMELIST * newPADNAMELIST(size_t max) .Ve .IP "newPADNAMEouter" 8 .IX Xref "newPADNAMEouter" .IX Item "newPADNAMEouter" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Constructs and returns a new pad name. Only use this function for names that refer to outer lexicals. (See also \*(L"newPADNAMEpvn\*(R".) \f(CW\*(C`outer\*(C'\fR is the outer pad name that this one mirrors. The returned pad name has the \&\f(CW\*(C`PADNAMEt_OUTER\*(C'\fR flag already set. .Sp .Vb 1 \& PADNAME * newPADNAMEouter(PADNAME *outer) .Ve .IP "newPADNAMEpvn" 8 .IX Xref "newPADNAMEpvn" .IX Item "newPADNAMEpvn" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Constructs and returns a new pad name. \f(CW\*(C`s\*(C'\fR must be a \s-1UTF\-8\s0 string. Do not use this for pad names that point to outer lexicals. See \&\f(CW"newPADNAMEouter"\fR. .Sp .Vb 1 \& PADNAME * newPADNAMEpvn(const char *s, STRLEN len) .Ve .IP "nothreadhook" 8 .IX Xref "nothreadhook" .IX Item "nothreadhook" Stub that provides thread hook for perl_destruct when there are no threads. .Sp .Vb 1 \& int nothreadhook() .Ve .IP "pad_add_anon" 8 .IX Xref "pad_add_anon" .IX Item "pad_add_anon" Allocates a place in the currently-compiling pad (via \*(L"pad_alloc\*(R") for an anonymous function that is lexically scoped inside the currently-compiling function. The function \f(CW\*(C`func\*(C'\fR is linked into the pad, and its \f(CW\*(C`CvOUTSIDE\*(C'\fR link to the outer scope is weakened to avoid a reference loop. .Sp One reference count is stolen, so you may need to do \f(CW\*(C`SvREFCNT_inc(func)\*(C'\fR. .Sp \&\f(CW\*(C`optype\*(C'\fR 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. .Sp .Vb 1 \& PADOFFSET pad_add_anon(CV* func, I32 optype) .Ve .IP "pad_add_name_pv" 8 .IX Xref "pad_add_name_pv" .IX Item "pad_add_name_pv" Exactly like \*(L"pad_add_name_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& PADOFFSET pad_add_name_pv(const char *name, \& const U32 flags, \& HV *typestash, HV *ourstash) .Ve .IP "pad_add_name_pvn" 8 .IX Xref "pad_add_name_pvn" .IX Item "pad_add_name_pvn" Allocates a place in the currently-compiling pad for a named lexical variable. Stores the name and other metadata in the name part of the pad, and makes preparations to manage the variable's lexical scoping. Returns the offset of the allocated pad slot. .Sp \&\f(CW\*(C`namepv\*(C'\fR/\f(CW\*(C`namelen\*(C'\fR specify the variable's name, including leading sigil. If \f(CW\*(C`typestash\*(C'\fR is non-null, the name is for a typed lexical, and this identifies the type. If \f(CW\*(C`ourstash\*(C'\fR is non-null, it's a lexical reference to a package variable, and this identifies the package. The following flags can be \s-1OR\s0'ed together: .Sp .Vb 3 \& padadd_OUR redundantly specifies if it\*(Aqs 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) .Ve .IP "pad_add_name_sv" 8 .IX Xref "pad_add_name_sv" .IX Item "pad_add_name_sv" Exactly like \*(L"pad_add_name_pvn\*(R", but takes the name string in the form of an \s-1SV\s0 instead of a string/length pair. .Sp .Vb 2 \& PADOFFSET pad_add_name_sv(SV *name, U32 flags, \& HV *typestash, HV *ourstash) .Ve .IP "pad_alloc" 8 .IX Xref "pad_alloc" .IX Item "pad_alloc" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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. \&\f(CW\*(C`tmptype\*(C'\fR is a set of flags indicating the kind of pad entry required, which will be set in the value \s-1SV\s0 for the allocated pad entry: .Sp .Vb 3 \& SVs_PADMY named lexical variable ("my", "our", "state") \& SVs_PADTMP unnamed temporary store \& SVf_READONLY constant shared between recursion levels .Ve .Sp \&\f(CW\*(C`SVf_READONLY\*(C'\fR has been supported here only since perl 5.20. To work with earlier versions as well, use \f(CW\*(C`SVf_READONLY|SVs_PADTMP\*(C'\fR. \f(CW\*(C`SVf_READONLY\*(C'\fR does not cause the \s-1SV\s0 in the pad slot to be marked read-only, but simply tells \f(CW\*(C`pad_alloc\*(C'\fR that it \fIwill\fR be made read-only (by the caller), or at least should be treated as such. .Sp \&\f(CW\*(C`optype\*(C'\fR 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. .Sp .Vb 1 \& PADOFFSET pad_alloc(I32 optype, U32 tmptype) .Ve .IP "pad_findmy_pv" 8 .IX Xref "pad_findmy_pv" .IX Item "pad_findmy_pv" Exactly like \*(L"pad_findmy_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 1 \& PADOFFSET pad_findmy_pv(const char* name, U32 flags) .Ve .IP "pad_findmy_pvn" 8 .IX Xref "pad_findmy_pvn" .IX Item "pad_findmy_pvn" Given the name of a lexical variable, find its position in the currently-compiling pad. \&\f(CW\*(C`namepv\*(C'\fR/\f(CW\*(C`namelen\*(C'\fR specify the variable's name, including leading sigil. \&\f(CW\*(C`flags\*(C'\fR 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 \f(CW\*(C`NOT_IN_PAD\*(C'\fR if no such lexical is in scope. .Sp .Vb 2 \& PADOFFSET pad_findmy_pvn(const char* namepv, \& STRLEN namelen, U32 flags) .Ve .IP "pad_findmy_sv" 8 .IX Xref "pad_findmy_sv" .IX Item "pad_findmy_sv" Exactly like \*(L"pad_findmy_pvn\*(R", but takes the name string in the form of an \s-1SV\s0 instead of a string/length pair. .Sp .Vb 1 \& PADOFFSET pad_findmy_sv(SV* name, U32 flags) .Ve .IP "padnamelist_fetch" 8 .IX Xref "padnamelist_fetch" .IX Item "padnamelist_fetch" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Fetches the pad name from the given index. .Sp .Vb 2 \& PADNAME * padnamelist_fetch(PADNAMELIST *pnl, \& SSize_t key) .Ve .IP "padnamelist_store" 8 .IX Xref "padnamelist_store" .IX Item "padnamelist_store" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Stores the pad name (which may be null) at the given index, freeing any existing pad name in that slot. .Sp .Vb 2 \& PADNAME ** padnamelist_store(PADNAMELIST *pnl, \& SSize_t key, PADNAME *val) .Ve .IP "pad_setsv" 8 .IX Xref "pad_setsv" .IX Item "pad_setsv" Set the value at offset \f(CW\*(C`po\*(C'\fR in the current (compiling or executing) pad. Use the macro \f(CW\*(C`PAD_SETSV()\*(C'\fR rather than calling this function directly. .Sp .Vb 1 \& void pad_setsv(PADOFFSET po, SV* sv) .Ve .IP "pad_sv" 8 .IX Xref "pad_sv" .IX Item "pad_sv" Get the value at offset \f(CW\*(C`po\*(C'\fR in the current (compiling or executing) pad. Use macro \f(CW\*(C`PAD_SV\*(C'\fR instead of calling this function directly. .Sp .Vb 1 \& SV* pad_sv(PADOFFSET po) .Ve .IP "pad_tidy" 8 .IX Xref "pad_tidy" .IX Item "pad_tidy" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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 \f(CW@_\fR; mark temporaries as such. \f(CW\*(C`type\*(C'\fR indicates the kind of subroutine: .Sp .Vb 3 \& padtidy_SUB ordinary subroutine \& padtidy_SUBCLONE prototype for lexical closure \& padtidy_FORMAT format \& \& void pad_tidy(padtidy_type type) .Ve .IP "perl_alloc" 8 .IX Xref "perl_alloc" .IX Item "perl_alloc" Allocates a new Perl interpreter. See perlembed. .Sp .Vb 1 \& PerlInterpreter* perl_alloc() .Ve .IP "perl_construct" 8 .IX Xref "perl_construct" .IX Item "perl_construct" Initializes a new Perl interpreter. See perlembed. .Sp .Vb 1 \& void perl_construct(PerlInterpreter *my_perl) .Ve .IP "perl_destruct" 8 .IX Xref "perl_destruct" .IX Item "perl_destruct" Shuts down a Perl interpreter. See perlembed for a tutorial. .Sp \&\f(CW\*(C`my_perl\*(C'\fR points to the Perl interpreter. It must have been previously created through the use of \*(L"perl_alloc\*(R" and \*(L"perl_construct\*(R". It may have been initialised through \*(L"perl_parse\*(R", and may have been used through \*(L"perl_run\*(R" and other means. This function should be called for any Perl interpreter that has been constructed with \*(L"perl_construct\*(R", even if subsequent operations on it failed, for example if \*(L"perl_parse\*(R" returned a non-zero value. .Sp If the interpreter's \f(CW\*(C`PL_exit_flags\*(C'\fR word has the \&\f(CW\*(C`PERL_EXIT_DESTRUCT_END\*(C'\fR flag set, then this function will execute code in \f(CW\*(C`END\*(C'\fR blocks before performing the rest of destruction. If it is desired to make any use of the interpreter between \*(L"perl_parse\*(R" and \&\*(L"perl_destruct\*(R" other than just calling \*(L"perl_run\*(R", then this flag should be set early on. This matters if \*(L"perl_run\*(R" will not be called, or if anything else will be done in addition to calling \*(L"perl_run\*(R". .Sp Returns a value be a suitable value to pass to the C library function \&\f(CW\*(C`exit\*(C'\fR (or to return from \f(CW\*(C`main\*(C'\fR), to serve as an exit code indicating the nature of the way the interpreter terminated. This takes into account any failure of \*(L"perl_parse\*(R" and any early exit from \*(L"perl_run\*(R". The exit code is of the type required by the host operating system, so because of differing exit code conventions it is not portable to interpret specific numeric values as having specific meanings. .Sp .Vb 1 \& int perl_destruct(PerlInterpreter *my_perl) .Ve .IP "perl_free" 8 .IX Xref "perl_free" .IX Item "perl_free" Releases a Perl interpreter. See perlembed. .Sp .Vb 1 \& void perl_free(PerlInterpreter *my_perl) .Ve .IP "perl_parse" 8 .IX Xref "perl_parse" .IX Item "perl_parse" Tells a Perl interpreter to parse a Perl script. This performs most of the initialisation of a Perl interpreter. See perlembed for a tutorial. .Sp \&\f(CW\*(C`my_perl\*(C'\fR points to the Perl interpreter that is to parse the script. It must have been previously created through the use of \*(L"perl_alloc\*(R" and \*(L"perl_construct\*(R". \f(CW\*(C`xsinit\*(C'\fR points to a callback function that will be called to set up the ability for this Perl interpreter to load \&\s-1XS\s0 extensions, or may be null to perform no such setup. .Sp \&\f(CW\*(C`argc\*(C'\fR and \f(CW\*(C`argv\*(C'\fR supply a set of command-line arguments to the Perl interpreter, as would normally be passed to the \f(CW\*(C`main\*(C'\fR function of a C program. \f(CW\*(C`argv[argc]\*(C'\fR must be null. These arguments are where the script to parse is specified, either by naming a script file or by providing a script in a \f(CW\*(C`\-e\*(C'\fR option. If \f(CW$0\fR will be written to in the Perl interpreter, then the argument strings must be in writable memory, and so mustn't just be string constants. .Sp \&\f(CW\*(C`env\*(C'\fR specifies a set of environment variables that will be used by this Perl interpreter. If non-null, it must point to a null-terminated array of environment strings. If null, the Perl interpreter will use the environment supplied by the \f(CW\*(C`environ\*(C'\fR global variable. .Sp This function initialises the interpreter, and parses and compiles the script specified by the command-line arguments. This includes executing code in \f(CW\*(C`BEGIN\*(C'\fR, \f(CW\*(C`UNITCHECK\*(C'\fR, and \f(CW\*(C`CHECK\*(C'\fR blocks. It does not execute \&\f(CW\*(C`INIT\*(C'\fR blocks or the main program. .Sp Returns an integer of slightly tricky interpretation. The correct use of the return value is as a truth value indicating whether there was a failure in initialisation. If zero is returned, this indicates that initialisation was successful, and it is safe to proceed to call \&\*(L"perl_run\*(R" and make other use of it. If a non-zero value is returned, this indicates some problem that means the interpreter wants to terminate. The interpreter should not be just abandoned upon such failure; the caller should proceed to shut the interpreter down cleanly with \*(L"perl_destruct\*(R" and free it with \*(L"perl_free\*(R". .Sp For historical reasons, the non-zero return value also attempts to be a suitable value to pass to the C library function \f(CW\*(C`exit\*(C'\fR (or to return from \f(CW\*(C`main\*(C'\fR), to serve as an exit code indicating the nature of the way initialisation terminated. However, this isn't portable, due to differing exit code conventions. A historical bug is preserved for the time being: if the Perl built-in \f(CW\*(C`exit\*(C'\fR is called during this function's execution, with a type of exit entailing a zero exit code under the host operating system's conventions, then this function returns zero rather than a non-zero value. This bug, [perl #2754], leads to \f(CW\*(C`perl_run\*(C'\fR being called (and therefore \f(CW\*(C`INIT\*(C'\fR blocks and the main program running) despite a call to \f(CW\*(C`exit\*(C'\fR. It has been preserved because a popular module-installing module has come to rely on it and needs time to be fixed. This issue is [perl #132577], and the original bug is due to be fixed in Perl 5.30. .Sp .Vb 3 \& int perl_parse(PerlInterpreter *my_perl, \& XSINIT_t xsinit, int argc, \& char** argv, char** env) .Ve .IP "perl_run" 8 .IX Xref "perl_run" .IX Item "perl_run" Tells a Perl interpreter to run its main program. See perlembed for a tutorial. .Sp \&\f(CW\*(C`my_perl\*(C'\fR points to the Perl interpreter. It must have been previously created through the use of \*(L"perl_alloc\*(R" and \*(L"perl_construct\*(R", and initialised through \*(L"perl_parse\*(R". This function should not be called if \*(L"perl_parse\*(R" returned a non-zero value, indicating a failure in initialisation or compilation. .Sp This function executes code in \f(CW\*(C`INIT\*(C'\fR blocks, and then executes the main program. The code to be executed is that established by the prior call to \*(L"perl_parse\*(R". If the interpreter's \f(CW\*(C`PL_exit_flags\*(C'\fR word does not have the \f(CW\*(C`PERL_EXIT_DESTRUCT_END\*(C'\fR flag set, then this function will also execute code in \f(CW\*(C`END\*(C'\fR blocks. If it is desired to make any further use of the interpreter after calling this function, then \f(CW\*(C`END\*(C'\fR blocks should be postponed to \*(L"perl_destruct\*(R" time by setting that flag. .Sp Returns an integer of slightly tricky interpretation. The correct use of the return value is as a truth value indicating whether the program terminated non-locally. If zero is returned, this indicates that the program ran to completion, and it is safe to make other use of the interpreter (provided that the \f(CW\*(C`PERL_EXIT_DESTRUCT_END\*(C'\fR flag was set as described above). If a non-zero value is returned, this indicates that the interpreter wants to terminate early. The interpreter should not be just abandoned because of this desire to terminate; the caller should proceed to shut the interpreter down cleanly with \*(L"perl_destruct\*(R" and free it with \*(L"perl_free\*(R". .Sp For historical reasons, the non-zero return value also attempts to be a suitable value to pass to the C library function \f(CW\*(C`exit\*(C'\fR (or to return from \f(CW\*(C`main\*(C'\fR), to serve as an exit code indicating the nature of the way the program terminated. However, this isn't portable, due to differing exit code conventions. An attempt is made to return an exit code of the type required by the host operating system, but because it is constrained to be non-zero, it is not necessarily possible to indicate every type of exit. It is only reliable on Unix, where a zero exit code can be augmented with a set bit that will be ignored. In any case, this function is not the correct place to acquire an exit code: one should get that from \*(L"perl_destruct\*(R". .Sp .Vb 1 \& int perl_run(PerlInterpreter *my_perl) .Ve .IP "require_pv" 8 .IX Xref "require_pv" .IX Item "require_pv" Tells Perl to \f(CW\*(C`require\*(C'\fR the file named by the string argument. It is analogous to the Perl code \f(CW\*(C`eval "require \*(Aq$file\*(Aq"\*(C'\fR. It's even implemented that way; consider using load_module instead. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& void require_pv(const char* pv) .Ve .SH "Exception Handling (simple) Macros" .IX Header "Exception Handling (simple) Macros" .IP "dXCPT" 8 .IX Xref "dXCPT" .IX Item "dXCPT" Set up necessary local variables for exception handling. See \*(L"Exception Handling\*(R" in perlguts. .Sp .Vb 1 \& dXCPT; .Ve .IP "\s-1XCPT_CATCH\s0" 8 .IX Xref "XCPT_CATCH" .IX Item "XCPT_CATCH" Introduces a catch block. See \*(L"Exception Handling\*(R" in perlguts. .IP "\s-1XCPT_RETHROW\s0" 8 .IX Xref "XCPT_RETHROW" .IX Item "XCPT_RETHROW" Rethrows a previously caught exception. See \*(L"Exception Handling\*(R" in perlguts. .Sp .Vb 1 \& XCPT_RETHROW; .Ve .IP "\s-1XCPT_TRY_END\s0" 8 .IX Xref "XCPT_TRY_END" .IX Item "XCPT_TRY_END" Ends a try block. See \*(L"Exception Handling\*(R" in perlguts. .IP "\s-1XCPT_TRY_START\s0" 8 .IX Xref "XCPT_TRY_START" .IX Item "XCPT_TRY_START" Starts a try block. See \*(L"Exception Handling\*(R" in perlguts. .SH "Functions in file vutil.c" .IX Header "Functions in file vutil.c" .IP "new_version" 8 .IX Xref "new_version" .IX Item "new_version" Returns a new version object based on the passed in \s-1SV:\s0 .Sp .Vb 1 \& SV *sv = new_version(SV *ver); .Ve .Sp Does not alter the passed in ver \s-1SV.\s0 See \*(L"upg_version\*(R" if you want to upgrade the \s-1SV.\s0 .Sp .Vb 1 \& SV* new_version(SV *ver) .Ve .IP "prescan_version" 8 .IX Xref "prescan_version" .IX Item "prescan_version" Validate that a given string can be parsed as a version object, but doesn't actually perform the parsing. Can use either strict or lax validation rules. Can optionally set a number of hint variables to save the parsing code some time when tokenizing. .Sp .Vb 5 \& const char* prescan_version(const char *s, bool strict, \& const char** errstr, \& bool *sqv, \& int *ssaw_decimal, \& int *swidth, bool *salpha) .Ve .IP "scan_version" 8 .IX Xref "scan_version" .IX Item "scan_version" Returns a pointer to the next character after the parsed version string, as well as upgrading the passed in \s-1SV\s0 to an \s-1RV.\s0 .Sp Function must be called with an already existing \s-1SV\s0 like .Sp .Vb 2 \& sv = newSV(0); \& s = scan_version(s, SV *sv, bool qv); .Ve .Sp 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. .Sp .Vb 1 \& const char* scan_version(const char *s, SV *rv, bool qv) .Ve .IP "upg_version" 8 .IX Xref "upg_version" .IX Item "upg_version" In-place upgrade of the supplied \s-1SV\s0 to a version object. .Sp .Vb 1 \& SV *sv = upg_version(SV *sv, bool qv); .Ve .Sp Returns a pointer to the upgraded \s-1SV.\s0 Set the boolean qv if you want to force this \s-1SV\s0 to be interpreted as an \*(L"extended\*(R" version. .Sp .Vb 1 \& SV* upg_version(SV *ver, bool qv) .Ve .IP "vcmp" 8 .IX Xref "vcmp" .IX Item "vcmp" Version object aware cmp. Both operands must already have been converted into version objects. .Sp .Vb 1 \& int vcmp(SV *lhv, SV *rhv) .Ve .IP "vnormal" 8 .IX Xref "vnormal" .IX Item "vnormal" Accepts a version object and returns the normalized string representation. Call like: .Sp .Vb 1 \& sv = vnormal(rv); .Ve .Sp \&\s-1NOTE:\s0 you can pass either the object directly or the \s-1SV\s0 contained within the \s-1RV.\s0 .Sp The \s-1SV\s0 returned has a refcount of 1. .Sp .Vb 1 \& SV* vnormal(SV *vs) .Ve .IP "vnumify" 8 .IX Xref "vnumify" .IX Item "vnumify" Accepts a version object and returns the normalized floating point representation. Call like: .Sp .Vb 1 \& sv = vnumify(rv); .Ve .Sp \&\s-1NOTE:\s0 you can pass either the object directly or the \s-1SV\s0 contained within the \s-1RV.\s0 .Sp The \s-1SV\s0 returned has a refcount of 1. .Sp .Vb 1 \& SV* vnumify(SV *vs) .Ve .IP "vstringify" 8 .IX Xref "vstringify" .IX Item "vstringify" In order to maintain maximum compatibility with earlier versions of Perl, this function will return either the floating point notation or the multiple dotted notation, depending on whether the original version contained 1 or more dots, respectively. .Sp The \s-1SV\s0 returned has a refcount of 1. .Sp .Vb 1 \& SV* vstringify(SV *vs) .Ve .IP "vverify" 8 .IX Xref "vverify" .IX Item "vverify" Validates that the \s-1SV\s0 contains valid internal structure for a version object. It may be passed either the version object (\s-1RV\s0) or the hash itself (\s-1HV\s0). If the structure is valid, it returns the \s-1HV.\s0 If the structure is invalid, it returns \s-1NULL.\s0 .Sp .Vb 1 \& SV *hv = vverify(sv); .Ve .Sp Note that it only confirms the bare minimum structure (so as not to get confused by derived classes which may contain additional hash entries): .RS 8 .IP "\(bu" 4 The \s-1SV\s0 is an \s-1HV\s0 or a reference to an \s-1HV\s0 .IP "\(bu" 4 The hash contains a \*(L"version\*(R" key .IP "\(bu" 4 The \*(L"version\*(R" key has a reference to an \s-1AV\s0 as its value .RE .RS 8 .Sp .Vb 1 \& SV* vverify(SV *vs) .Ve .RE .ie n .SH """Gimme"" Values" .el .SH "``Gimme'' Values" .IX Header "Gimme Values" .IP "G_ARRAY" 8 .IX Xref "G_ARRAY" .IX Item "G_ARRAY" Used to indicate list context. See \f(CW"GIMME_V"\fR, \f(CW"GIMME"\fR and perlcall. .IP "G_DISCARD" 8 .IX Xref "G_DISCARD" .IX Item "G_DISCARD" Indicates that arguments returned from a callback should be discarded. See perlcall. .IP "G_EVAL" 8 .IX Xref "G_EVAL" .IX Item "G_EVAL" Used to force a Perl \f(CW\*(C`eval\*(C'\fR wrapper around a callback. See perlcall. .IP "\s-1GIMME\s0" 8 .IX Xref "GIMME" .IX Item "GIMME" A backward-compatible version of \f(CW\*(C`GIMME_V\*(C'\fR which can only return \&\f(CW\*(C`G_SCALAR\*(C'\fR or \f(CW\*(C`G_ARRAY\*(C'\fR; in a void context, it returns \f(CW\*(C`G_SCALAR\*(C'\fR. Deprecated. Use \f(CW\*(C`GIMME_V\*(C'\fR instead. .Sp .Vb 1 \& U32 GIMME .Ve .IP "\s-1GIMME_V\s0" 8 .IX Xref "GIMME_V" .IX Item "GIMME_V" The XSUB-writer's equivalent to Perl's \f(CW\*(C`wantarray\*(C'\fR. Returns \f(CW\*(C`G_VOID\*(C'\fR, \&\f(CW\*(C`G_SCALAR\*(C'\fR or \f(CW\*(C`G_ARRAY\*(C'\fR for void, scalar or list context, respectively. See perlcall for a usage example. .Sp .Vb 1 \& U32 GIMME_V .Ve .IP "G_NOARGS" 8 .IX Xref "G_NOARGS" .IX Item "G_NOARGS" Indicates that no arguments are being sent to a callback. See perlcall. .IP "G_SCALAR" 8 .IX Xref "G_SCALAR" .IX Item "G_SCALAR" Used to indicate scalar context. See \f(CW"GIMME_V"\fR, \f(CW"GIMME"\fR, and perlcall. .IP "G_VOID" 8 .IX Xref "G_VOID" .IX Item "G_VOID" Used to indicate void context. See \f(CW"GIMME_V"\fR and perlcall. .SH "Global Variables" .IX Header "Global Variables" These variables are global to an entire process. They are shared between all interpreters and all threads in a process. Any variables not documented here may be changed or removed without notice, so don't use them! If you feel you really do need to use an unlisted variable, first send email to perl5\-porters@perl.org . It may be that someone there will point out a way to accomplish what you need without using an internal variable. But if not, you should get a go-ahead to document and then use the variable. .IP "PL_check" 8 .IX Xref "PL_check" .IX Item "PL_check" Array, indexed by opcode, of functions that will be called for the \*(L"check\*(R" 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. .Sp This array of function pointers is a convenient place to hook into the compilation process. An \s-1XS\s0 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 \fBwrap\fR 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. .Sp For thread safety, modules should not write directly to this array. Instead, use the function \*(L"wrap_op_checker\*(R". .IP "PL_keyword_plugin" 8 .IX Xref "PL_keyword_plugin" .IX Item "PL_keyword_plugin" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Function pointer, pointing at a function used to handle extended keywords. The function should be declared as .Sp .Vb 3 \& int keyword_plugin_function(pTHX_ \& char *keyword_ptr, STRLEN keyword_len, \& OP **op_ptr) .Ve .Sp The function is called from the tokeniser, whenever a possible keyword is seen. \f(CW\*(C`keyword_ptr\*(C'\fR points at the word in the parser's input buffer, and \f(CW\*(C`keyword_len\*(C'\fR gives its length; it is not null-terminated. The function is expected to examine the word, and possibly other state such as %^H, to decide whether it wants to handle it as an extended keyword. If it does not, the function should return \&\f(CW\*(C`KEYWORD_PLUGIN_DECLINE\*(C'\fR, and the normal parser process will continue. .Sp 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"Lexer interface\*(R" for details. .Sp When a keyword is being handled, the plugin function must build a tree of \f(CW\*(C`OP\*(C'\fR structures, representing the code that was parsed. The root of the tree must be stored in \f(CW*op_ptr\fR. The function then returns a constant indicating the syntactic role of the construct that it has parsed: \f(CW\*(C`KEYWORD_PLUGIN_STMT\*(C'\fR if it is a complete statement, or \&\f(CW\*(C`KEYWORD_PLUGIN_EXPR\*(C'\fR if it is an expression. Note that a statement construct cannot be used inside an expression (except via \f(CW\*(C`do BLOCK\*(C'\fR and similar), and an expression is not a complete statement (it requires at least a terminating semicolon). .Sp When a keyword is handled, the plugin function may also have (compile-time) side effects. It may modify \f(CW\*(C`%^H\*(C'\fR, 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. .Sp That's how the \f(CW*PL_keyword_plugin\fR function needs to behave overall. Conventionally, however, one does not completely replace the existing handler function. Instead, take a copy of \f(CW\*(C`PL_keyword_plugin\*(C'\fR 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 \f(CW\*(C`PL_keyword_plugin\*(C'\fR 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 \f(CW\*(C`KEYWORD_PLUGIN_DECLINE\*(C'\fR. .Sp For thread safety, modules should not set this variable directly. Instead, use the function \*(L"wrap_keyword_plugin\*(R". .IP "PL_phase" 8 .IX Xref "PL_phase" .IX Item "PL_phase" A value that indicates the current Perl interpreter's phase. Possible values include \f(CW\*(C`PERL_PHASE_CONSTRUCT\*(C'\fR, \f(CW\*(C`PERL_PHASE_START\*(C'\fR, \f(CW\*(C`PERL_PHASE_CHECK\*(C'\fR, \&\f(CW\*(C`PERL_PHASE_INIT\*(C'\fR, \f(CW\*(C`PERL_PHASE_RUN\*(C'\fR, \f(CW\*(C`PERL_PHASE_END\*(C'\fR, and \&\f(CW\*(C`PERL_PHASE_DESTRUCT\*(C'\fR. .Sp For example, the following determines whether the interpreter is in global destruction: .Sp .Vb 3 \& if (PL_phase == PERL_PHASE_DESTRUCT) { \& // we are in global destruction \& } .Ve .Sp \&\f(CW\*(C`PL_phase\*(C'\fR was introduced in Perl 5.14; in prior perls you can use \&\f(CW\*(C`PL_dirty\*(C'\fR (boolean) to determine whether the interpreter is in global destruction. (Use of \f(CW\*(C`PL_dirty\*(C'\fR is discouraged since 5.14.) .Sp .Vb 1 \& enum perl_phase PL_phase .Ve .SH "GV Functions" .IX Header "GV Functions" A \s-1GV\s0 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 \f(CW$foo\fR, \f(CW@foo\fR, \f(CW%foo\fR. .PP GVs are usually found as values in stashes (symbol table hashes) where Perl stores its global variables. .IP "GvAV" 8 .IX Xref "GvAV" .IX Item "GvAV" Return the \s-1AV\s0 from the \s-1GV.\s0 .Sp .Vb 1 \& AV* GvAV(GV* gv) .Ve .IP "gv_const_sv" 8 .IX Xref "gv_const_sv" .IX Item "gv_const_sv" If \f(CW\*(C`gv\*(C'\fR is a typeglob whose subroutine entry is a constant sub eligible for inlining, or \f(CW\*(C`gv\*(C'\fR is a placeholder reference that would be promoted to such a typeglob, then returns the value returned by the sub. Otherwise, returns \&\f(CW\*(C`NULL\*(C'\fR. .Sp .Vb 1 \& SV* gv_const_sv(GV* gv) .Ve .IP "GvCV" 8 .IX Xref "GvCV" .IX Item "GvCV" Return the \s-1CV\s0 from the \s-1GV.\s0 .Sp .Vb 1 \& CV* GvCV(GV* gv) .Ve .IP "gv_fetchmeth" 8 .IX Xref "gv_fetchmeth" .IX Item "gv_fetchmeth" Like \*(L"gv_fetchmeth_pvn\*(R", but lacks a flags parameter. .Sp .Vb 2 \& GV* gv_fetchmeth(HV* stash, const char* name, \& STRLEN len, I32 level) .Ve .IP "gv_fetchmethod_autoload" 8 .IX Xref "gv_fetchmethod_autoload" .IX Item "gv_fetchmethod_autoload" Returns the glob which contains the subroutine to call to invoke the method on the \f(CW\*(C`stash\*(C'\fR. In fact in the presence of autoloading this may be the glob for \*(L"\s-1AUTOLOAD\*(R".\s0 In this case the corresponding variable \f(CW$AUTOLOAD\fR is already setup. .Sp The third parameter of \f(CW\*(C`gv_fetchmethod_autoload\*(C'\fR determines whether \&\s-1AUTOLOAD\s0 lookup is performed if the given method is not present: non-zero means yes, look for \s-1AUTOLOAD\s0; zero means no, don't look for \s-1AUTOLOAD.\s0 Calling \f(CW\*(C`gv_fetchmethod\*(C'\fR is equivalent to calling \f(CW\*(C`gv_fetchmethod_autoload\*(C'\fR with a non-zero \f(CW\*(C`autoload\*(C'\fR parameter. .Sp These functions grant \f(CW"SUPER"\fR 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 \*(L"\s-1AUTOLOAD\*(R",\s0 since at the later time the call may load a different subroutine due to \f(CW$AUTOLOAD\fR changing its value. Use the glob created as a side effect to do this. .Sp These functions have the same side-effects as \f(CW\*(C`gv_fetchmeth\*(C'\fR with \&\f(CW\*(C`level==0\*(C'\fR. The warning against passing the \s-1GV\s0 returned by \&\f(CW\*(C`gv_fetchmeth\*(C'\fR to \f(CW\*(C`call_sv\*(C'\fR applies equally to these functions. .Sp .Vb 3 \& GV* gv_fetchmethod_autoload(HV* stash, \& const char* name, \& I32 autoload) .Ve .IP "gv_fetchmeth_autoload" 8 .IX Xref "gv_fetchmeth_autoload" .IX Item "gv_fetchmeth_autoload" This is the old form of \*(L"gv_fetchmeth_pvn_autoload\*(R", which has no flags parameter. .Sp .Vb 3 \& GV* gv_fetchmeth_autoload(HV* stash, \& const char* name, \& STRLEN len, I32 level) .Ve .IP "gv_fetchmeth_pv" 8 .IX Xref "gv_fetchmeth_pv" .IX Item "gv_fetchmeth_pv" Exactly like \*(L"gv_fetchmeth_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 2 \& GV* gv_fetchmeth_pv(HV* stash, const char* name, \& I32 level, U32 flags) .Ve .IP "gv_fetchmeth_pvn" 8 .IX Xref "gv_fetchmeth_pvn" .IX Item "gv_fetchmeth_pvn" Returns the glob with the given \f(CW\*(C`name\*(C'\fR and a defined subroutine or \&\f(CW\*(C`NULL\*(C'\fR. The glob lives in the given \f(CW\*(C`stash\*(C'\fR, or in the stashes accessible via \f(CW@ISA\fR and \f(CW\*(C`UNIVERSAL::\*(C'\fR. .Sp The argument \f(CW\*(C`level\*(C'\fR should be either 0 or \-1. If \f(CW\*(C`level==0\*(C'\fR, as a side-effect creates a glob with the given \f(CW\*(C`name\*(C'\fR in the given \f(CW\*(C`stash\*(C'\fR which in the case of success contains an alias for the subroutine, and sets up caching info for this glob. .Sp The only significant values for \f(CW\*(C`flags\*(C'\fR are \f(CW\*(C`GV_SUPER\*(C'\fR and \f(CW\*(C`SVf_UTF8\*(C'\fR. .Sp \&\f(CW\*(C`GV_SUPER\*(C'\fR indicates that we want to look up the method in the superclasses of the \f(CW\*(C`stash\*(C'\fR. .Sp The \&\s-1GV\s0 returned from \f(CW\*(C`gv_fetchmeth\*(C'\fR may be a method cache entry, which is not visible to Perl code. So when calling \f(CW\*(C`call_sv\*(C'\fR, you should not use the \s-1GV\s0 directly; instead, you should use the method's \s-1CV,\s0 which can be obtained from the \s-1GV\s0 with the \f(CW\*(C`GvCV\*(C'\fR macro. .Sp .Vb 3 \& GV* gv_fetchmeth_pvn(HV* stash, const char* name, \& STRLEN len, I32 level, \& U32 flags) .Ve .IP "gv_fetchmeth_pvn_autoload" 8 .IX Xref "gv_fetchmeth_pvn_autoload" .IX Item "gv_fetchmeth_pvn_autoload" Same as \f(CW\*(C`gv_fetchmeth_pvn()\*(C'\fR, but looks for autoloaded subroutines too. Returns a glob for the subroutine. .Sp For an autoloaded subroutine without a \s-1GV,\s0 will create a \s-1GV\s0 even if \f(CW\*(C`level < 0\*(C'\fR. For an autoloaded subroutine without a stub, \f(CW\*(C`GvCV()\*(C'\fR of the result may be zero. .Sp Currently, the only significant value for \f(CW\*(C`flags\*(C'\fR is \f(CW\*(C`SVf_UTF8\*(C'\fR. .Sp .Vb 4 \& GV* gv_fetchmeth_pvn_autoload(HV* stash, \& const char* name, \& STRLEN len, I32 level, \& U32 flags) .Ve .IP "gv_fetchmeth_pv_autoload" 8 .IX Xref "gv_fetchmeth_pv_autoload" .IX Item "gv_fetchmeth_pv_autoload" Exactly like \*(L"gv_fetchmeth_pvn_autoload\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& GV* gv_fetchmeth_pv_autoload(HV* stash, \& const char* name, \& I32 level, U32 flags) .Ve .IP "gv_fetchmeth_sv" 8 .IX Xref "gv_fetchmeth_sv" .IX Item "gv_fetchmeth_sv" Exactly like \*(L"gv_fetchmeth_pvn\*(R", but takes the name string in the form of an \s-1SV\s0 instead of a string/length pair. .Sp .Vb 2 \& GV* gv_fetchmeth_sv(HV* stash, SV* namesv, \& I32 level, U32 flags) .Ve .IP "gv_fetchmeth_sv_autoload" 8 .IX Xref "gv_fetchmeth_sv_autoload" .IX Item "gv_fetchmeth_sv_autoload" Exactly like \*(L"gv_fetchmeth_pvn_autoload\*(R", but takes the name string in the form of an \s-1SV\s0 instead of a string/length pair. .Sp .Vb 2 \& GV* gv_fetchmeth_sv_autoload(HV* stash, SV* namesv, \& I32 level, U32 flags) .Ve .IP "GvHV" 8 .IX Xref "GvHV" .IX Item "GvHV" Return the \s-1HV\s0 from the \s-1GV.\s0 .Sp .Vb 1 \& HV* GvHV(GV* gv) .Ve .IP "gv_init" 8 .IX Xref "gv_init" .IX Item "gv_init" The old form of \f(CW\*(C`gv_init_pvn()\*(C'\fR. It does not work with \s-1UTF\-8\s0 strings, as it has no flags parameter. If the \f(CW\*(C`multi\*(C'\fR parameter is set, the \&\f(CW\*(C`GV_ADDMULTI\*(C'\fR flag will be passed to \f(CW\*(C`gv_init_pvn()\*(C'\fR. .Sp .Vb 2 \& void gv_init(GV* gv, HV* stash, const char* name, \& STRLEN len, int multi) .Ve .IP "gv_init_pv" 8 .IX Xref "gv_init_pv" .IX Item "gv_init_pv" Same as \f(CW\*(C`gv_init_pvn()\*(C'\fR, but takes a nul-terminated string for the name instead of separate char * and length parameters. .Sp .Vb 2 \& void gv_init_pv(GV* gv, HV* stash, const char* name, \& U32 flags) .Ve .IP "gv_init_pvn" 8 .IX Xref "gv_init_pvn" .IX Item "gv_init_pvn" Converts a scalar into a typeglob. This is an incoercible typeglob; assigning a reference to it will assign to one of its slots, instead of overwriting it as happens with typeglobs created by \f(CW\*(C`SvSetSV\*(C'\fR. Converting any scalar that is \f(CW\*(C`SvOK()\*(C'\fR may produce unpredictable results and is reserved for perl's internal use. .Sp \&\f(CW\*(C`gv\*(C'\fR is the scalar to be converted. .Sp \&\f(CW\*(C`stash\*(C'\fR is the parent stash/package, if any. .Sp \&\f(CW\*(C`name\*(C'\fR and \f(CW\*(C`len\*(C'\fR give the name. The name must be unqualified; that is, it must not include the package name. If \f(CW\*(C`gv\*(C'\fR 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. .Sp \&\f(CW\*(C`flags\*(C'\fR can be set to \f(CW\*(C`SVf_UTF8\*(C'\fR if \f(CW\*(C`name\*(C'\fR is a \s-1UTF\-8\s0 string, or the return value of SvUTF8(sv). It can also take the \&\f(CW\*(C`GV_ADDMULTI\*(C'\fR flag, which means to pretend that the \s-1GV\s0 has been seen before (i.e., suppress \*(L"Used once\*(R" warnings). .Sp .Vb 2 \& void gv_init_pvn(GV* gv, HV* stash, const char* name, \& STRLEN len, U32 flags) .Ve .IP "gv_init_sv" 8 .IX Xref "gv_init_sv" .IX Item "gv_init_sv" Same as \f(CW\*(C`gv_init_pvn()\*(C'\fR, but takes an \s-1SV\s0 * for the name instead of separate char * and length parameters. \f(CW\*(C`flags\*(C'\fR is currently unused. .Sp .Vb 2 \& void gv_init_sv(GV* gv, HV* stash, SV* namesv, \& U32 flags) .Ve .IP "gv_stashpv" 8 .IX Xref "gv_stashpv" .IX Item "gv_stashpv" Returns a pointer to the stash for a specified package. Uses \f(CW\*(C`strlen\*(C'\fR to determine the length of \f(CW\*(C`name\*(C'\fR, then calls \f(CW\*(C`gv_stashpvn()\*(C'\fR. .Sp .Vb 1 \& HV* gv_stashpv(const char* name, I32 flags) .Ve .IP "gv_stashpvn" 8 .IX Xref "gv_stashpvn" .IX Item "gv_stashpvn" Returns a pointer to the stash for a specified package. The \f(CW\*(C`namelen\*(C'\fR parameter indicates the length of the \f(CW\*(C`name\*(C'\fR, in bytes. \f(CW\*(C`flags\*(C'\fR is passed to \f(CW\*(C`gv_fetchpvn_flags()\*(C'\fR, so if set to \f(CW\*(C`GV_ADD\*(C'\fR then the package will be created if it does not already exist. If the package does not exist and \&\f(CW\*(C`flags\*(C'\fR is 0 (or any other setting that does not create packages) then \f(CW\*(C`NULL\*(C'\fR is returned. .Sp Flags may be one of: .Sp .Vb 6 \& GV_ADD \& SVf_UTF8 \& GV_NOADD_NOINIT \& GV_NOINIT \& GV_NOEXPAND \& GV_ADDMG .Ve .Sp The most important of which are probably \f(CW\*(C`GV_ADD\*(C'\fR and \f(CW\*(C`SVf_UTF8\*(C'\fR. .Sp Note, use of \f(CW\*(C`gv_stashsv\*(C'\fR instead of \f(CW\*(C`gv_stashpvn\*(C'\fR where possible is strongly recommended for performance reasons. .Sp .Vb 2 \& HV* gv_stashpvn(const char* name, U32 namelen, \& I32 flags) .Ve .IP "gv_stashpvs" 8 .IX Xref "gv_stashpvs" .IX Item "gv_stashpvs" Like \f(CW\*(C`gv_stashpvn\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& HV* gv_stashpvs("name", I32 create) .Ve .IP "gv_stashsv" 8 .IX Xref "gv_stashsv" .IX Item "gv_stashsv" Returns a pointer to the stash for a specified package. See \&\f(CW"gv_stashpvn"\fR. .Sp Note this interface is strongly preferred over \f(CW\*(C`gv_stashpvn\*(C'\fR for performance reasons. .Sp .Vb 1 \& HV* gv_stashsv(SV* sv, I32 flags) .Ve .IP "GvSV" 8 .IX Xref "GvSV" .IX Item "GvSV" Return the \s-1SV\s0 from the \s-1GV.\s0 .Sp .Vb 1 \& SV* GvSV(GV* gv) .Ve .IP "save_gp" 8 .IX Xref "save_gp" .IX Item "save_gp" Saves the current \s-1GP\s0 of gv on the save stack to be restored on scope exit. .Sp If empty is true, replace the \s-1GP\s0 with a new \s-1GP.\s0 .Sp If empty is false, mark gv with GVf_INTRO so the next reference assigned is localized, which is how \f(CW\*(C` local *foo = $someref; \*(C'\fR works. .Sp .Vb 1 \& void save_gp(GV* gv, I32 empty) .Ve .IP "setdefout" 8 .IX Xref "setdefout" .IX Item "setdefout" Sets \f(CW\*(C`PL_defoutgv\*(C'\fR, the default file handle for output, to the passed in typeglob. As \f(CW\*(C`PL_defoutgv\*(C'\fR \*(L"owns\*(R" 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 \f(CW\*(C`PL_defoutgv\*(C'\fR points to is decreased by one. .Sp .Vb 1 \& void setdefout(GV* gv) .Ve .SH "Handy Values" .IX Header "Handy Values" .IP "C_ARRAY_END" 8 .IX Xref "C_ARRAY_END" .IX Item "C_ARRAY_END" Returns a pointer to one element past the final element of the input C array. .Sp .Vb 1 \& void * C_ARRAY_END(void *a) .Ve .IP "C_ARRAY_LENGTH" 8 .IX Xref "C_ARRAY_LENGTH" .IX Item "C_ARRAY_LENGTH" Returns the number of elements in the input C array (so you want your zero-based indices to be less than but not equal to). .Sp .Vb 1 \& STRLEN C_ARRAY_LENGTH(void *a) .Ve .IP "cBOOL" 8 .IX Xref "cBOOL" .IX Item "cBOOL" Cast-to-bool. A simple \f(CW\*(C`(bool) \f(CIexpr\f(CW\*(C'\fR cast may not do the right thing: if \f(CW\*(C`bool\*(C'\fR is defined as \f(CW\*(C`char\*(C'\fR, for example, then the cast from \f(CW\*(C`int\*(C'\fR is implementation-defined. .Sp \&\f(CW\*(C`(bool)!!(cbool)\*(C'\fR in a ternary triggers a bug in xlc on \s-1AIX\s0 .Sp .Vb 1 \& bool cBOOL(bool expr) .Ve .IP "Nullav" 8 .IX Xref "Nullav" .IX Item "Nullav" \&\s-1DEPRECATED\s0! 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. .Sp Null \s-1AV\s0 pointer. .Sp (deprecated \- use \f(CW\*(C`(AV *)NULL\*(C'\fR instead) .IP "Nullch" 8 .IX Xref "Nullch" .IX Item "Nullch" Null character pointer. (No longer available when \f(CW\*(C`PERL_CORE\*(C'\fR is defined.) .IP "Nullcv" 8 .IX Xref "Nullcv" .IX Item "Nullcv" \&\s-1DEPRECATED\s0! 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. .Sp Null \s-1CV\s0 pointer. .Sp (deprecated \- use \f(CW\*(C`(CV *)NULL\*(C'\fR instead) .IP "Nullhv" 8 .IX Xref "Nullhv" .IX Item "Nullhv" \&\s-1DEPRECATED\s0! 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. .Sp Null \s-1HV\s0 pointer. .Sp (deprecated \- use \f(CW\*(C`(HV *)NULL\*(C'\fR instead) .IP "Nullsv" 8 .IX Xref "Nullsv" .IX Item "Nullsv" Null \s-1SV\s0 pointer. (No longer available when \f(CW\*(C`PERL_CORE\*(C'\fR is defined.) .IP "\s-1STR_WITH_LEN\s0" 8 .IX Xref "STR_WITH_LEN" .IX Item "STR_WITH_LEN" Returns two comma separated tokens of the input literal string, and its length. This is convenience macro which helps out in some \s-1API\s0 calls. Note that it can't be used as an argument to macros or functions that under some configurations might be macros, which means that it requires the full Perl_xxx(aTHX_ ...) form for any \s-1API\s0 calls where it's used. .Sp .Vb 1 \& pair STR_WITH_LEN("literal string") .Ve .IP "_\|_ASSERT_" 8 .IX Xref "__ASSERT_" .IX Item "__ASSERT_" This is a helper macro to avoid preprocessor issues, replaced by nothing unless under \s-1DEBUGGING,\s0 where it expands to an assert of its argument, followed by a comma (hence the comma operator). If we just used a straight \&\fBassert()\fR, we would get a comma with nothing before it when not \s-1DEBUGGING.\s0 .Sp .Vb 1 \& void _\|_ASSERT_(bool expr) .Ve .SH "Hash Manipulation Functions" .IX Header "Hash Manipulation Functions" A \s-1HV\s0 structure represents a Perl hash. It consists mainly of an array of pointers, each of which points to a linked list of \s-1HE\s0 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 \s-1HE\s0 contains a pointer to the actual value, plus a pointer to a \s-1HEK\s0 structure which holds the key and hash value. .IP "cop_fetch_label" 8 .IX Xref "cop_fetch_label" .IX Item "cop_fetch_label" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Returns the label attached to a cop, and stores its length in bytes into \&\f(CW*len\fR. Upon return, \f(CW*flags\fR will be set to either \f(CW\*(C`SVf_UTF8\*(C'\fR or 0. .Sp Alternatively, use the macro "\f(CW\*(C`CopLABEL_len_flags\*(C'\fR"; or if you don't need to know if the label is \s-1UTF\-8\s0 or not, the macro "\f(CW\*(C`CopLABEL_len\*(C'\fR"; or if you additionally dont need to know the length, "\f(CW\*(C`CopLABEL\*(C'\fR". .Sp .Vb 2 \& const char * cop_fetch_label(COP *const cop, \& STRLEN *len, U32 *flags) .Ve .IP "cop_store_label" 8 .IX Xref "cop_store_label" .IX Item "cop_store_label" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Save a label into a \f(CW\*(C`cop_hints_hash\*(C'\fR. You need to set flags to \f(CW\*(C`SVf_UTF8\*(C'\fR for a \s-1UTF\-8\s0 label. Any other flag is ignored. .Sp .Vb 3 \& void cop_store_label(COP *const cop, \& const char *label, STRLEN len, \& U32 flags) .Ve .IP "get_hv" 8 .IX Xref "get_hv" .IX Item "get_hv" Returns the \s-1HV\s0 of the specified Perl hash. \f(CW\*(C`flags\*(C'\fR are passed to \&\f(CW\*(C`gv_fetchpv\*(C'\fR. If \f(CW\*(C`GV_ADD\*(C'\fR is set and the Perl variable does not exist then it will be created. If \f(CW\*(C`flags\*(C'\fR is zero and the variable does not exist then \f(CW\*(C`NULL\*(C'\fR is returned. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& HV* get_hv(const char *name, I32 flags) .Ve .IP "HEf_SVKEY" 8 .IX Xref "HEf_SVKEY" .IX Item "HEf_SVKEY" This flag, used in the length slot of hash entries and magic structures, specifies the structure contains an \f(CW\*(C`SV*\*(C'\fR pointer where a \f(CW\*(C`char*\*(C'\fR pointer is to be expected. (For information only\*(--not to be used). .IP "HeHASH" 8 .IX Xref "HeHASH" .IX Item "HeHASH" Returns the computed hash stored in the hash entry. .Sp .Vb 1 \& U32 HeHASH(HE* he) .Ve .IP "HeKEY" 8 .IX Xref "HeKEY" .IX Item "HeKEY" Returns the actual pointer stored in the key slot of the hash entry. The pointer may be either \f(CW\*(C`char*\*(C'\fR or \f(CW\*(C`SV*\*(C'\fR, depending on the value of \&\f(CW\*(C`HeKLEN()\*(C'\fR. Can be assigned to. The \f(CW\*(C`HePV()\*(C'\fR or \f(CW\*(C`HeSVKEY()\*(C'\fR macros are usually preferable for finding the value of a key. .Sp .Vb 1 \& void* HeKEY(HE* he) .Ve .IP "HeKLEN" 8 .IX Xref "HeKLEN" .IX Item "HeKLEN" If this is negative, and amounts to \f(CW\*(C`HEf_SVKEY\*(C'\fR, it indicates the entry holds an \f(CW\*(C`SV*\*(C'\fR key. Otherwise, holds the actual length of the key. Can be assigned to. The \f(CW\*(C`HePV()\*(C'\fR macro is usually preferable for finding key lengths. .Sp .Vb 1 \& STRLEN HeKLEN(HE* he) .Ve .IP "HePV" 8 .IX Xref "HePV" .IX Item "HePV" Returns the key slot of the hash entry as a \f(CW\*(C`char*\*(C'\fR value, doing any necessary dereferencing of possibly \f(CW\*(C`SV*\*(C'\fR keys. The length of the string is placed in \f(CW\*(C`len\*(C'\fR (this is a macro, so do \fInot\fR use \f(CW&len\fR). If you do not care about what the length of the key is, you may use the global variable \f(CW\*(C`PL_na\*(C'\fR, 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 \f(CW\*(C`strlen()\*(C'\fR or similar is not a good way to find the length of hash keys. This is very similar to the \f(CW\*(C`SvPV()\*(C'\fR macro described elsewhere in this document. See also \f(CW"HeUTF8"\fR. .Sp If you are using \f(CW\*(C`HePV\*(C'\fR to get values to pass to \f(CW\*(C`newSVpvn()\*(C'\fR to create a new \s-1SV,\s0 you should consider using \f(CW\*(C`newSVhek(HeKEY_hek(he))\*(C'\fR as it is more efficient. .Sp .Vb 1 \& char* HePV(HE* he, STRLEN len) .Ve .IP "HeSVKEY" 8 .IX Xref "HeSVKEY" .IX Item "HeSVKEY" Returns the key as an \f(CW\*(C`SV*\*(C'\fR, or \f(CW\*(C`NULL\*(C'\fR if the hash entry does not contain an \f(CW\*(C`SV*\*(C'\fR key. .Sp .Vb 1 \& SV* HeSVKEY(HE* he) .Ve .IP "HeSVKEY_force" 8 .IX Xref "HeSVKEY_force" .IX Item "HeSVKEY_force" Returns the key as an \f(CW\*(C`SV*\*(C'\fR. Will create and return a temporary mortal \&\f(CW\*(C`SV*\*(C'\fR if the hash entry contains only a \f(CW\*(C`char*\*(C'\fR key. .Sp .Vb 1 \& SV* HeSVKEY_force(HE* he) .Ve .IP "HeSVKEY_set" 8 .IX Xref "HeSVKEY_set" .IX Item "HeSVKEY_set" Sets the key to a given \f(CW\*(C`SV*\*(C'\fR, taking care to set the appropriate flags to indicate the presence of an \f(CW\*(C`SV*\*(C'\fR key, and returns the same \&\f(CW\*(C`SV*\*(C'\fR. .Sp .Vb 1 \& SV* HeSVKEY_set(HE* he, SV* sv) .Ve .IP "HeUTF8" 8 .IX Xref "HeUTF8" .IX Item "HeUTF8" Returns whether the \f(CW\*(C`char *\*(C'\fR value returned by \f(CW\*(C`HePV\*(C'\fR is encoded in \s-1UTF\-8,\s0 doing any necessary dereferencing of possibly \f(CW\*(C`SV*\*(C'\fR keys. The value returned will be 0 or non\-0, not necessarily 1 (or even a value with any low bits set), so \fBdo not\fR blindly assign this to a \f(CW\*(C`bool\*(C'\fR variable, as \f(CW\*(C`bool\*(C'\fR may be a typedef for \f(CW\*(C`char\*(C'\fR. .Sp .Vb 1 \& U32 HeUTF8(HE* he) .Ve .IP "HeVAL" 8 .IX Xref "HeVAL" .IX Item "HeVAL" Returns the value slot (type \f(CW\*(C`SV*\*(C'\fR) stored in the hash entry. Can be assigned to. .Sp .Vb 2 \& SV *foo= HeVAL(hv); \& HeVAL(hv)= sv; \& \& \& SV* HeVAL(HE* he) .Ve .IP "hv_assert" 8 .IX Xref "hv_assert" .IX Item "hv_assert" Check that a hash is in an internally consistent state. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_hv_assert with an aTHX_ parameter. .Sp .Vb 1 \& void Perl_hv_assert(pTHX_ HV *hv) .Ve .IP "hv_bucket_ratio" 8 .IX Xref "hv_bucket_ratio" .IX Item "hv_bucket_ratio" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp If the hash is tied dispatches through to the \s-1SCALAR\s0 tied method, otherwise if the hash contains no keys returns 0, otherwise returns a mortal sv containing a string specifying the number of used buckets, followed by a slash, followed by the number of available buckets. .Sp This function is expensive, it must scan all of the buckets to determine which are used, and the count is \s-1NOT\s0 cached. In a large hash this could be a lot of buckets. .Sp .Vb 1 \& SV* hv_bucket_ratio(HV *hv) .Ve .IP "hv_clear" 8 .IX Xref "hv_clear" .IX Item "hv_clear" Frees the all the elements of a hash, leaving it empty. The \s-1XS\s0 equivalent of \f(CW\*(C`%hash = ()\*(C'\fR. See also \*(L"hv_undef\*(R". .Sp See \*(L"av_clear\*(R" for a note about the hash possibly being invalid on return. .Sp .Vb 1 \& void hv_clear(HV *hv) .Ve .IP "hv_clear_placeholders" 8 .IX Xref "hv_clear_placeholders" .IX Item "hv_clear_placeholders" 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 \f(CW&PL_sv_placeholder\fR. 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 \f(CW\*(C`Hash::Util::lock_keys()\*(C'\fR for an example of its use. .Sp .Vb 1 \& void hv_clear_placeholders(HV *hv) .Ve .IP "hv_copy_hints_hv" 8 .IX Xref "hv_copy_hints_hv" .IX Item "hv_copy_hints_hv" A specialised version of \*(L"newHVhv\*(R" for copying \f(CW\*(C`%^H\*(C'\fR. \f(CW\*(C`ohv\*(C'\fR must be a pointer to a hash (which may have \f(CW\*(C`%^H\*(C'\fR magic, but should be generally non-magical), or \f(CW\*(C`NULL\*(C'\fR (interpreted as an empty hash). The content of \f(CW\*(C`ohv\*(C'\fR is copied to a new hash, which has the \f(CW\*(C`%^H\*(C'\fR\-specific magic added to it. A pointer to the new hash is returned. .Sp .Vb 1 \& HV * hv_copy_hints_hv(HV *const ohv) .Ve .IP "hv_delete" 8 .IX Xref "hv_delete" .IX Item "hv_delete" Deletes a key/value pair in the hash. The value's \s-1SV\s0 is removed from the hash, made mortal, and returned to the caller. The absolute value of \f(CW\*(C`klen\*(C'\fR is the length of the key. If \f(CW\*(C`klen\*(C'\fR is negative the key is assumed to be in UTF\-8\-encoded Unicode. The \f(CW\*(C`flags\*(C'\fR value will normally be zero; if set to \f(CW\*(C`G_DISCARD\*(C'\fR then \f(CW\*(C`NULL\*(C'\fR will be returned. \&\f(CW\*(C`NULL\*(C'\fR will also be returned if the key is not found. .Sp .Vb 2 \& SV* hv_delete(HV *hv, const char *key, I32 klen, \& I32 flags) .Ve .IP "hv_delete_ent" 8 .IX Xref "hv_delete_ent" .IX Item "hv_delete_ent" Deletes a key/value pair in the hash. The value \s-1SV\s0 is removed from the hash, made mortal, and returned to the caller. The \f(CW\*(C`flags\*(C'\fR value will normally be zero; if set to \f(CW\*(C`G_DISCARD\*(C'\fR then \f(CW\*(C`NULL\*(C'\fR will be returned. \f(CW\*(C`NULL\*(C'\fR will also be returned if the key is not found. \f(CW\*(C`hash\*(C'\fR can be a valid precomputed hash value, or 0 to ask for it to be computed. .Sp .Vb 2 \& SV* hv_delete_ent(HV *hv, SV *keysv, I32 flags, \& U32 hash) .Ve .IP "HvENAME" 8 .IX Xref "HvENAME" .IX Item "HvENAME" Returns the effective name of a stash, or \s-1NULL\s0 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 \f(CW\*(C`HvNAME\*(C'\fR for use in \s-1MRO\s0 linearisations and isa caches. .Sp .Vb 1 \& char* HvENAME(HV* stash) .Ve .IP "HvENAMELEN" 8 .IX Xref "HvENAMELEN" .IX Item "HvENAMELEN" Returns the length of the stash's effective name. .Sp .Vb 1 \& STRLEN HvENAMELEN(HV *stash) .Ve .IP "HvENAMEUTF8" 8 .IX Xref "HvENAMEUTF8" .IX Item "HvENAMEUTF8" Returns true if the effective name is in \s-1UTF\-8\s0 encoding. .Sp .Vb 1 \& unsigned char HvENAMEUTF8(HV *stash) .Ve .IP "hv_exists" 8 .IX Xref "hv_exists" .IX Item "hv_exists" Returns a boolean indicating whether the specified hash key exists. The absolute value of \f(CW\*(C`klen\*(C'\fR is the length of the key. If \f(CW\*(C`klen\*(C'\fR is negative the key is assumed to be in UTF\-8\-encoded Unicode. .Sp .Vb 1 \& bool hv_exists(HV *hv, const char *key, I32 klen) .Ve .IP "hv_exists_ent" 8 .IX Xref "hv_exists_ent" .IX Item "hv_exists_ent" Returns a boolean indicating whether the specified hash key exists. \f(CW\*(C`hash\*(C'\fR can be a valid precomputed hash value, or 0 to ask for it to be computed. .Sp .Vb 1 \& bool hv_exists_ent(HV *hv, SV *keysv, U32 hash) .Ve .IP "hv_fetch" 8 .IX Xref "hv_fetch" .IX Item "hv_fetch" Returns the \s-1SV\s0 which corresponds to the specified key in the hash. The absolute value of \f(CW\*(C`klen\*(C'\fR is the length of the key. If \f(CW\*(C`klen\*(C'\fR is negative the key is assumed to be in UTF\-8\-encoded Unicode. If \&\f(CW\*(C`lval\*(C'\fR 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 \f(CW\*(C`SV*\*(C'\fR it points to can be assigned to. But always check that the return value is non-null before dereferencing it to an \f(CW\*(C`SV*\*(C'\fR. .Sp See \*(L"Understanding the Magic of Tied Hashes and Arrays\*(R" in perlguts for more information on how to use this function on tied hashes. .Sp .Vb 2 \& SV** hv_fetch(HV *hv, const char *key, I32 klen, \& I32 lval) .Ve .IP "hv_fetchs" 8 .IX Xref "hv_fetchs" .IX Item "hv_fetchs" Like \f(CW\*(C`hv_fetch\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& SV** hv_fetchs(HV* tb, "key", I32 lval) .Ve .IP "hv_fetch_ent" 8 .IX Xref "hv_fetch_ent" .IX Item "hv_fetch_ent" Returns the hash entry which corresponds to the specified key in the hash. \&\f(CW\*(C`hash\*(C'\fR must be a valid precomputed hash number for the given \f(CW\*(C`key\*(C'\fR, or 0 if you want the function to compute it. \s-1IF\s0 \f(CW\*(C`lval\*(C'\fR 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 \f(CW\*(C`hv\*(C'\fR 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. .Sp See \*(L"Understanding the Magic of Tied Hashes and Arrays\*(R" in perlguts for more information on how to use this function on tied hashes. .Sp .Vb 2 \& HE* hv_fetch_ent(HV *hv, SV *keysv, I32 lval, \& U32 hash) .Ve .IP "HvFILL" 8 .IX Xref "HvFILL" .IX Item "HvFILL" See \*(L"hv_fill\*(R". .Sp .Vb 1 \& STRLEN HvFILL(HV *const hv) .Ve .IP "hv_fill" 8 .IX Xref "hv_fill" .IX Item "hv_fill" Returns the number of hash buckets that happen to be in use. .Sp This function is wrapped by the macro \f(CW\*(C`HvFILL\*(C'\fR. .Sp As of perl 5.25 this function is used only for debugging purposes, and the number of used hash buckets is not in any way cached, thus this function can be costly to execute as it must iterate over all the buckets in the hash. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_hv_fill with an aTHX_ parameter. .Sp .Vb 1 \& STRLEN Perl_hv_fill(pTHX_ HV *const hv) .Ve .IP "hv_iterinit" 8 .IX Xref "hv_iterinit" .IX Item "hv_iterinit" Prepares a starting point to traverse a hash table. Returns the number of keys in the hash, including placeholders (i.e. the same as \f(CW\*(C`HvTOTALKEYS(hv)\*(C'\fR). The return value is currently only meaningful for hashes without tie magic. .Sp \&\s-1NOTE:\s0 Before version 5.004_65, \f(CW\*(C`hv_iterinit\*(C'\fR 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 \f(CW\*(C`HvFILL(hv)\*(C'\fR. .Sp .Vb 1 \& I32 hv_iterinit(HV *hv) .Ve .IP "hv_iterkey" 8 .IX Xref "hv_iterkey" .IX Item "hv_iterkey" Returns the key from the current position of the hash iterator. See \&\f(CW"hv_iterinit"\fR. .Sp .Vb 1 \& char* hv_iterkey(HE* entry, I32* retlen) .Ve .IP "hv_iterkeysv" 8 .IX Xref "hv_iterkeysv" .IX Item "hv_iterkeysv" Returns the key as an \f(CW\*(C`SV*\*(C'\fR from the current position of the hash iterator. The return value will always be a mortal copy of the key. Also see \f(CW"hv_iterinit"\fR. .Sp .Vb 1 \& SV* hv_iterkeysv(HE* entry) .Ve .IP "hv_iternext" 8 .IX Xref "hv_iternext" .IX Item "hv_iternext" Returns entries from a hash iterator. See \f(CW"hv_iterinit"\fR. .Sp You may call \f(CW\*(C`hv_delete\*(C'\fR or \f(CW\*(C`hv_delete_ent\*(C'\fR 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 \f(CW\*(C`hv_iternext\*(C'\fR, so you must not discard your iterator immediately else the entry will leak \- call \f(CW\*(C`hv_iternext\*(C'\fR to trigger the resource deallocation. .Sp .Vb 1 \& HE* hv_iternext(HV *hv) .Ve .IP "hv_iternextsv" 8 .IX Xref "hv_iternextsv" .IX Item "hv_iternextsv" Performs an \f(CW\*(C`hv_iternext\*(C'\fR, \f(CW\*(C`hv_iterkey\*(C'\fR, and \f(CW\*(C`hv_iterval\*(C'\fR in one operation. .Sp .Vb 1 \& SV* hv_iternextsv(HV *hv, char **key, I32 *retlen) .Ve .IP "hv_iternext_flags" 8 .IX Xref "hv_iternext_flags" .IX Item "hv_iternext_flags" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Returns entries from a hash iterator. See \f(CW"hv_iterinit"\fR and \&\f(CW"hv_iternext"\fR. The \f(CW\*(C`flags\*(C'\fR value will normally be zero; if \f(CW\*(C`HV_ITERNEXT_WANTPLACEHOLDERS\*(C'\fR 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 \&\f(CW&PL_sv_placeholder\fR. Note that the implementation of placeholders and restricted hashes may change, and the implementation currently is insufficiently abstracted for any change to be tidy. .Sp .Vb 1 \& HE* hv_iternext_flags(HV *hv, I32 flags) .Ve .IP "hv_iterval" 8 .IX Xref "hv_iterval" .IX Item "hv_iterval" Returns the value from the current position of the hash iterator. See \&\f(CW"hv_iterkey"\fR. .Sp .Vb 1 \& SV* hv_iterval(HV *hv, HE *entry) .Ve .IP "hv_magic" 8 .IX Xref "hv_magic" .IX Item "hv_magic" Adds magic to a hash. See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& void hv_magic(HV *hv, GV *gv, int how) .Ve .IP "HvNAME" 8 .IX Xref "HvNAME" .IX Item "HvNAME" Returns the package name of a stash, or \f(CW\*(C`NULL\*(C'\fR if \f(CW\*(C`stash\*(C'\fR isn't a stash. See \f(CW"SvSTASH"\fR, \f(CW"CvSTASH"\fR. .Sp .Vb 1 \& char* HvNAME(HV* stash) .Ve .IP "HvNAMELEN" 8 .IX Xref "HvNAMELEN" .IX Item "HvNAMELEN" Returns the length of the stash's name. .Sp .Vb 1 \& STRLEN HvNAMELEN(HV *stash) .Ve .IP "HvNAMEUTF8" 8 .IX Xref "HvNAMEUTF8" .IX Item "HvNAMEUTF8" Returns true if the name is in \s-1UTF\-8\s0 encoding. .Sp .Vb 1 \& unsigned char HvNAMEUTF8(HV *stash) .Ve .IP "hv_scalar" 8 .IX Xref "hv_scalar" .IX Item "hv_scalar" Evaluates the hash in scalar context and returns the result. .Sp When the hash is tied dispatches through to the \s-1SCALAR\s0 method, otherwise returns a mortal \s-1SV\s0 containing the number of keys in the hash. .Sp Note, prior to 5.25 this function returned what is now returned by the \fBhv_bucket_ratio()\fR function. .Sp .Vb 1 \& SV* hv_scalar(HV *hv) .Ve .IP "hv_store" 8 .IX Xref "hv_store" .IX Item "hv_store" Stores an \s-1SV\s0 in a hash. The hash key is specified as \f(CW\*(C`key\*(C'\fR and the absolute value of \f(CW\*(C`klen\*(C'\fR is the length of the key. If \f(CW\*(C`klen\*(C'\fR is negative the key is assumed to be in UTF\-8\-encoded Unicode. The \&\f(CW\*(C`hash\*(C'\fR parameter is the precomputed hash value; if it is zero then Perl will compute it. .Sp The return value will be \&\f(CW\*(C`NULL\*(C'\fR 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 \f(CW\*(C`SV*\*(C'\fR. Note that the caller is responsible for suitably incrementing the reference count of \f(CW\*(C`val\*(C'\fR before the call, and decrementing it if the function returned \f(CW\*(C`NULL\*(C'\fR. Effectively a successful \f(CW\*(C`hv_store\*(C'\fR takes ownership of one reference to \f(CW\*(C`val\*(C'\fR. This is usually what you want; a newly created \s-1SV\s0 has a reference count of one, so if all your code does is create SVs then store them in a hash, \f(CW\*(C`hv_store\*(C'\fR will own the only reference to the new \s-1SV,\s0 and your code doesn't need to do anything further to tidy up. \f(CW\*(C`hv_store\*(C'\fR is not implemented as a call to \&\f(CW\*(C`hv_store_ent\*(C'\fR, and does not create a temporary \s-1SV\s0 for the key, so if your key data is not already in \s-1SV\s0 form then use \f(CW\*(C`hv_store\*(C'\fR in preference to \&\f(CW\*(C`hv_store_ent\*(C'\fR. .Sp See \*(L"Understanding the Magic of Tied Hashes and Arrays\*(R" in perlguts for more information on how to use this function on tied hashes. .Sp .Vb 2 \& SV** hv_store(HV *hv, const char *key, I32 klen, \& SV *val, U32 hash) .Ve .IP "hv_stores" 8 .IX Xref "hv_stores" .IX Item "hv_stores" Like \f(CW\*(C`hv_store\*(C'\fR, but takes a literal string instead of a string/length pair and omits the hash parameter. .Sp .Vb 1 \& SV** hv_stores(HV* tb, "key", SV* val) .Ve .IP "hv_store_ent" 8 .IX Xref "hv_store_ent" .IX Item "hv_store_ent" Stores \f(CW\*(C`val\*(C'\fR in a hash. The hash key is specified as \f(CW\*(C`key\*(C'\fR. The \f(CW\*(C`hash\*(C'\fR 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 \&\f(CW\*(C`NULL\*(C'\fR 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 \f(CW\*(C`He?\*(C'\fR macros described here. Note that the caller is responsible for suitably incrementing the reference count of \f(CW\*(C`val\*(C'\fR before the call, and decrementing it if the function returned \s-1NULL.\s0 Effectively a successful \&\f(CW\*(C`hv_store_ent\*(C'\fR takes ownership of one reference to \f(CW\*(C`val\*(C'\fR. This is usually what you want; a newly created \s-1SV\s0 has a reference count of one, so if all your code does is create SVs then store them in a hash, \f(CW\*(C`hv_store\*(C'\fR will own the only reference to the new \s-1SV,\s0 and your code doesn't need to do anything further to tidy up. Note that \f(CW\*(C`hv_store_ent\*(C'\fR only reads the \f(CW\*(C`key\*(C'\fR; unlike \f(CW\*(C`val\*(C'\fR it does not take ownership of it, so maintaining the correct reference count on \f(CW\*(C`key\*(C'\fR is entirely the caller's responsibility. The reason it does not take ownership, is that \f(CW\*(C`key\*(C'\fR is not used after this function returns, and so can be freed immediately. \f(CW\*(C`hv_store\*(C'\fR is not implemented as a call to \f(CW\*(C`hv_store_ent\*(C'\fR, and does not create a temporary \&\s-1SV\s0 for the key, so if your key data is not already in \s-1SV\s0 form then use \&\f(CW\*(C`hv_store\*(C'\fR in preference to \f(CW\*(C`hv_store_ent\*(C'\fR. .Sp See \*(L"Understanding the Magic of Tied Hashes and Arrays\*(R" in perlguts for more information on how to use this function on tied hashes. .Sp .Vb 1 \& HE* hv_store_ent(HV *hv, SV *key, SV *val, U32 hash) .Ve .IP "hv_undef" 8 .IX Xref "hv_undef" .IX Item "hv_undef" Undefines the hash. The \s-1XS\s0 equivalent of \f(CW\*(C`undef(%hash)\*(C'\fR. .Sp As well as freeing all the elements of the hash (like \f(CW\*(C`hv_clear()\*(C'\fR), this also frees any auxiliary data and storage associated with the hash. .Sp See \*(L"av_clear\*(R" for a note about the hash possibly being invalid on return. .Sp .Vb 1 \& void hv_undef(HV *hv) .Ve .IP "newHV" 8 .IX Xref "newHV" .IX Item "newHV" Creates a new \s-1HV.\s0 The reference count is set to 1. .Sp .Vb 1 \& HV* newHV() .Ve .SH "Hook manipulation" .IX Header "Hook manipulation" These functions provide convenient and thread-safe means of manipulating hook variables. .IP "wrap_op_checker" 8 .IX Xref "wrap_op_checker" .IX Item "wrap_op_checker" Puts a C function into the chain of check functions for a specified op type. This is the preferred way to manipulate the \*(L"PL_check\*(R" array. \&\f(CW\*(C`opcode\*(C'\fR specifies which type of op is to be affected. \f(CW\*(C`new_checker\*(C'\fR is a pointer to the C function that is to be added to that opcode's check chain, and \f(CW\*(C`old_checker_p\*(C'\fR points to the storage location where a pointer to the next function in the chain will be stored. The value of \&\f(CW\*(C`new_checker\*(C'\fR is written into the \*(L"PL_check\*(R" array, while the value previously stored there is written to \f(CW*old_checker_p\fR. .Sp \&\*(L"PL_check\*(R" 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 \f(CW*old_checker_p\fR must initially (once per process) contain a null pointer. A C variable of static duration (declared at file scope, typically also marked \f(CW\*(C`static\*(C'\fR 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 \f(CW*old_checker_p\fR to be null. This function is also thread safe on the small scale. It uses appropriate locking to avoid race conditions in accessing \*(L"PL_check\*(R". .Sp When this function is called, the function referenced by \f(CW\*(C`new_checker\*(C'\fR must be ready to be called, except for \f(CW*old_checker_p\fR being unfilled. In a threading situation, \f(CW\*(C`new_checker\*(C'\fR may be called immediately, even before this function has returned. \f(CW*old_checker_p\fR will always be appropriately set before \f(CW\*(C`new_checker\*(C'\fR is called. If \f(CW\*(C`new_checker\*(C'\fR 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 \f(CW*old_checker_p\fR. .Sp Taken all together, \s-1XS\s0 code to hook an op checker should typically look something like this: .Sp .Vb 9 \& static Perl_check_t nxck_frob; \& static OP *myck_frob(pTHX_ OP *op) { \& ... \& op = nxck_frob(aTHX_ op); \& ... \& return op; \& } \& BOOT: \& wrap_op_checker(OP_FROB, myck_frob, &nxck_frob); .Ve .Sp If you want to influence compilation of calls to a specific subroutine, then use \*(L"cv_set_call_checker_flags\*(R" rather than hooking checking of all \f(CW\*(C`entersub\*(C'\fR ops. .Sp .Vb 3 \& void wrap_op_checker(Optype opcode, \& Perl_check_t new_checker, \& Perl_check_t *old_checker_p) .Ve .SH "Lexer interface" .IX Header "Lexer interface" This is the lower layer of the Perl parser, managing characters and tokens. .IP "lex_bufutf8" 8 .IX Xref "lex_bufutf8" .IX Item "lex_bufutf8" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Indicates whether the octets in the lexer buffer (\*(L"PL_parser\->linestr\*(R") should be interpreted as the \s-1UTF\-8\s0 encoding of Unicode characters. If not, they should be interpreted as Latin\-1 characters. This is analogous to the \f(CW\*(C`SvUTF8\*(C'\fR flag for scalars. .Sp In \s-1UTF\-8\s0 mode, it is not guaranteed that the lexer buffer actually contains valid \s-1UTF\-8.\s0 Lexing code must be robust in the face of invalid encoding. .Sp The actual \f(CW\*(C`SvUTF8\*(C'\fR flag of the \*(L"PL_parser\->linestr\*(R" 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 \f(CW\*(C`SvUTF8\*(C'\fR flag is off, but the octets should be interpreted as \&\s-1UTF\-8\s0 if the \f(CW\*(C`use utf8\*(C'\fR pragma is in effect. During a string eval, however, the scalar may have the \f(CW\*(C`SvUTF8\*(C'\fR flag on, and in this case its octets should be interpreted as \s-1UTF\-8\s0 unless the \f(CW\*(C`use bytes\*(C'\fR pragma is in effect. This logic may change in the future; use this function instead of implementing the logic yourself. .Sp .Vb 1 \& bool lex_bufutf8() .Ve .IP "lex_discard_to" 8 .IX Xref "lex_discard_to" .IX Item "lex_discard_to" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Discards the first part of the \*(L"PL_parser\->linestr\*(R" buffer, up to \f(CW\*(C`ptr\*(C'\fR. The remaining content of the buffer will be moved, and all pointers into the buffer updated appropriately. \f(CW\*(C`ptr\*(C'\fR must not be later in the buffer than the position of \*(L"PL_parser\->bufptr\*(R": it is not permitted to discard text that has yet to be lexed. .Sp Normally it is not necessarily to do this directly, because it suffices to use the implicit discarding behaviour of \*(L"lex_next_chunk\*(R" 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. .Sp .Vb 1 \& void lex_discard_to(char* ptr) .Ve .IP "lex_grow_linestr" 8 .IX Xref "lex_grow_linestr" .IX Item "lex_grow_linestr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Reallocates the lexer buffer (\*(L"PL_parser\->linestr\*(R") to accommodate at least \f(CW\*(C`len\*(C'\fR octets (including terminating \f(CW\*(C`NUL\*(C'\fR). Returns a pointer to the reallocated buffer. This is necessary before making any direct modification of the buffer that would increase its length. \&\*(L"lex_stuff_pvn\*(R" provides a more convenient way to insert text into the buffer. .Sp Do not use \f(CW\*(C`SvGROW\*(C'\fR or \f(CW\*(C`sv_grow\*(C'\fR directly on \f(CW\*(C`PL_parser\->linestr\*(C'\fR; this function updates all of the lexer's variables that point directly into the buffer. .Sp .Vb 1 \& char* lex_grow_linestr(STRLEN len) .Ve .IP "lex_next_chunk" 8 .IX Xref "lex_next_chunk" .IX Item "lex_next_chunk" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Reads in the next chunk of text to be lexed, appending it to \&\*(L"PL_parser\->linestr\*(R". 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. .Sp If \*(L"PL_parser\->bufptr\*(R" 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 \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`LEX_KEEP_PREVIOUS\*(C'\fR bit set, 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. .Sp Returns true if some new text was added to the buffer, or false if the buffer has reached the end of the input text. .Sp .Vb 1 \& bool lex_next_chunk(U32 flags) .Ve .IP "lex_peek_unichar" 8 .IX Xref "lex_peek_unichar" .IX Item "lex_peek_unichar" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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"lex_read_unichar\*(R". .Sp 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 \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`LEX_KEEP_PREVIOUS\*(C'\fR bit set, then the current chunk will not be discarded. .Sp If the input is being interpreted as \s-1UTF\-8\s0 and a \s-1UTF\-8\s0 encoding error is encountered, an exception is generated. .Sp .Vb 1 \& I32 lex_peek_unichar(U32 flags) .Ve .IP "lex_read_space" 8 .IX Xref "lex_read_space" .IX Item "lex_read_space" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Reads optional spaces, in Perl style, in the text currently being lexed. The spaces may include ordinary whitespace characters and Perl-style comments. \f(CW\*(C`#line\*(C'\fR directives are processed if encountered. \&\*(L"PL_parser\->bufptr\*(R" is moved past the spaces, so that it points at a non-space character (or the end of the input text). .Sp 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 \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`LEX_KEEP_PREVIOUS\*(C'\fR bit set, then the current chunk will not be discarded. .Sp .Vb 1 \& void lex_read_space(U32 flags) .Ve .IP "lex_read_to" 8 .IX Xref "lex_read_to" .IX Item "lex_read_to" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Consume text in the lexer buffer, from \*(L"PL_parser\->bufptr\*(R" up to \f(CW\*(C`ptr\*(C'\fR. This advances \*(L"PL_parser\->bufptr\*(R" to match \f(CW\*(C`ptr\*(C'\fR, performing the correct bookkeeping whenever a newline character is passed. This is the normal way to consume lexed text. .Sp Interpretation of the buffer's octets can be abstracted out by using the slightly higher-level functions \*(L"lex_peek_unichar\*(R" and \&\*(L"lex_read_unichar\*(R". .Sp .Vb 1 \& void lex_read_to(char* ptr) .Ve .IP "lex_read_unichar" 8 .IX Xref "lex_read_unichar" .IX Item "lex_read_unichar" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Reads the next (Unicode) character in the text currently being lexed. Returns the codepoint (unsigned integer value) of the character read, and moves \*(L"PL_parser\->bufptr\*(R" 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"lex_peek_unichar\*(R" instead. .Sp 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 \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`LEX_KEEP_PREVIOUS\*(C'\fR bit set, then the current chunk will not be discarded. .Sp If the input is being interpreted as \s-1UTF\-8\s0 and a \s-1UTF\-8\s0 encoding error is encountered, an exception is generated. .Sp .Vb 1 \& I32 lex_read_unichar(U32 flags) .Ve .IP "lex_start" 8 .IX Xref "lex_start" .IX Item "lex_start" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Creates and initialises a new lexer/parser state object, supplying a context in which to lex and parse from a new source of Perl code. A pointer to the new state object is placed in \*(L"PL_parser\*(R". An entry is made on the save stack so that upon unwinding, the new state object will be destroyed and the former value of \*(L"PL_parser\*(R" will be restored. Nothing else need be done to clean up the parsing context. .Sp The code to be parsed comes from \f(CW\*(C`line\*(C'\fR and \f(CW\*(C`rsfp\*(C'\fR. \f(CW\*(C`line\*(C'\fR, if non-null, provides a string (in \s-1SV\s0 form) containing code to be parsed. A copy of the string is made, so subsequent modification of \f(CW\*(C`line\*(C'\fR does not affect parsing. \f(CW\*(C`rsfp\*(C'\fR, if non-null, provides an input stream from which code will be read to be parsed. If both are non-null, the code in \f(CW\*(C`line\*(C'\fR comes first and must consist of complete lines of input, and \f(CW\*(C`rsfp\*(C'\fR supplies the remainder of the source. .Sp The \f(CW\*(C`flags\*(C'\fR parameter is reserved for future use. Currently it is only used by perl internally, so extensions should always pass zero. .Sp .Vb 1 \& void lex_start(SV* line, PerlIO *rsfp, U32 flags) .Ve .IP "lex_stuff_pv" 8 .IX Xref "lex_stuff_pv" .IX Item "lex_stuff_pv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Insert characters into the lexer buffer (\*(L"PL_parser\->linestr\*(R"), immediately after the current lexing point (\*(L"PL_parser\->bufptr\*(R"), 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. .Sp The string to be inserted is represented by octets starting at \f(CW\*(C`pv\*(C'\fR and continuing to the first nul. These octets are interpreted as either \&\s-1UTF\-8\s0 or Latin\-1, according to whether the \f(CW\*(C`LEX_STUFF_UTF8\*(C'\fR flag is set in \f(CW\*(C`flags\*(C'\fR. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (\*(L"lex_bufutf8\*(R"). If it is not convenient to nul-terminate a string to be inserted, the \&\*(L"lex_stuff_pvn\*(R" function is more appropriate. .Sp .Vb 1 \& void lex_stuff_pv(const char* pv, U32 flags) .Ve .IP "lex_stuff_pvn" 8 .IX Xref "lex_stuff_pvn" .IX Item "lex_stuff_pvn" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Insert characters into the lexer buffer (\*(L"PL_parser\->linestr\*(R"), immediately after the current lexing point (\*(L"PL_parser\->bufptr\*(R"), 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. .Sp The string to be inserted is represented by \f(CW\*(C`len\*(C'\fR octets starting at \f(CW\*(C`pv\*(C'\fR. These octets are interpreted as either \s-1UTF\-8\s0 or Latin\-1, according to whether the \f(CW\*(C`LEX_STUFF_UTF8\*(C'\fR flag is set in \f(CW\*(C`flags\*(C'\fR. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (\*(L"lex_bufutf8\*(R"). If a string to be inserted is available as a Perl scalar, the \*(L"lex_stuff_sv\*(R" function is more convenient. .Sp .Vb 2 \& void lex_stuff_pvn(const char* pv, STRLEN len, \& U32 flags) .Ve .IP "lex_stuff_pvs" 8 .IX Xref "lex_stuff_pvs" .IX Item "lex_stuff_pvs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Like \*(L"lex_stuff_pvn\*(R", but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& void lex_stuff_pvs("pv", U32 flags) .Ve .IP "lex_stuff_sv" 8 .IX Xref "lex_stuff_sv" .IX Item "lex_stuff_sv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Insert characters into the lexer buffer (\*(L"PL_parser\->linestr\*(R"), immediately after the current lexing point (\*(L"PL_parser\->bufptr\*(R"), 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. .Sp The string to be inserted is the string value of \f(CW\*(C`sv\*(C'\fR. The characters are recoded for the lexer buffer, according to how the buffer is currently being interpreted (\*(L"lex_bufutf8\*(R"). If a string to be inserted is not already a Perl scalar, the \*(L"lex_stuff_pvn\*(R" function avoids the need to construct a scalar. .Sp .Vb 1 \& void lex_stuff_sv(SV* sv, U32 flags) .Ve .IP "lex_unstuff" 8 .IX Xref "lex_unstuff" .IX Item "lex_unstuff" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Discards text about to be lexed, from \*(L"PL_parser\->bufptr\*(R" up to \&\f(CW\*(C`ptr\*(C'\fR. Text following \f(CW\*(C`ptr\*(C'\fR 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. .Sp This is not the normal way to consume lexed text. For that, use \&\*(L"lex_read_to\*(R". .Sp .Vb 1 \& void lex_unstuff(char* ptr) .Ve .IP "parse_arithexpr" 8 .IX Xref "parse_arithexpr" .IX Item "parse_arithexpr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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 \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`PARSE_OPTIONAL\*(C'\fR bit set, then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the expression. .Sp 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. .Sp 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. .Sp .Vb 1 \& OP* parse_arithexpr(U32 flags) .Ve .IP "parse_barestmt" 8 .IX Xref "parse_barestmt" .IX Item "parse_barestmt" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Parse a single unadorned Perl statement. This may be a normal imperative statement or a declaration that has compile-time effect. It does not include any label or other affixture. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the statement. .Sp The op tree representing the statement is returned. This may be a null pointer if the statement is null, for example if it was actually a subroutine definition (which has compile-time side effects). If not null, it will be ops directly implementing the statement, suitable to pass to \*(L"newSTATEOP\*(R". It will not normally include a \f(CW\*(C`nextstate\*(C'\fR or equivalent op (except for those embedded in a scope contained entirely within the statement). .Sp 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. .Sp The \f(CW\*(C`flags\*(C'\fR parameter is reserved for future use, and must always be zero. .Sp .Vb 1 \& OP* parse_barestmt(U32 flags) .Ve .IP "parse_block" 8 .IX Xref "parse_block" .IX Item "parse_block" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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 \f(CW\*(C`my\*(C'\fR variables and various compile-time effects can be contained within it. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the statement. .Sp The op tree representing the code block is returned. This is always a real op, never a null pointer. It will normally be a \f(CW\*(C`lineseq\*(C'\fR list, including \f(CW\*(C`nextstate\*(C'\fR or equivalent ops. No ops to construct any kind of runtime scope are included by virtue of it being a block. .Sp 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. .Sp The \f(CW\*(C`flags\*(C'\fR parameter is reserved for future use, and must always be zero. .Sp .Vb 1 \& OP* parse_block(U32 flags) .Ve .IP "parse_fullexpr" 8 .IX Xref "parse_fullexpr" .IX Item "parse_fullexpr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Parse a single complete Perl expression. This allows the full expression grammar, including the lowest-precedence operators such as \f(CW\*(C`or\*(C'\fR. 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 \f(CW\*(C`flags\*(C'\fR has the \&\f(CW\*(C`PARSE_OPTIONAL\*(C'\fR bit set, then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the expression. .Sp 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. .Sp 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. .Sp .Vb 1 \& OP* parse_fullexpr(U32 flags) .Ve .IP "parse_fullstmt" 8 .IX Xref "parse_fullstmt" .IX Item "parse_fullstmt" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Parse a single complete Perl statement. This may be a normal imperative statement or a declaration that has compile-time effect, and may include optional labels. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the statement. .Sp The op tree representing the statement is returned. This may be a null pointer if the statement is null, for example if it was actually a subroutine definition (which has compile-time side effects). If not null, it will be the result of a \*(L"newSTATEOP\*(R" call, normally including a \f(CW\*(C`nextstate\*(C'\fR or equivalent op. .Sp 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. .Sp The \f(CW\*(C`flags\*(C'\fR parameter is reserved for future use, and must always be zero. .Sp .Vb 1 \& OP* parse_fullstmt(U32 flags) .Ve .IP "parse_label" 8 .IX Xref "parse_label" .IX Item "parse_label" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Parse a single label, possibly optional, of the type that may prefix a Perl statement. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`PARSE_OPTIONAL\*(C'\fR bit set, then the label is optional, otherwise it is mandatory. .Sp 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. .Sp 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. .Sp .Vb 1 \& SV* parse_label(U32 flags) .Ve .IP "parse_listexpr" 8 .IX Xref "parse_listexpr" .IX Item "parse_listexpr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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 \f(CW\*(C`or\*(C'\fR or by something that would normally terminate an expression such as semicolon. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`PARSE_OPTIONAL\*(C'\fR bit set, then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the expression. .Sp 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. .Sp 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. .Sp .Vb 1 \& OP* parse_listexpr(U32 flags) .Ve .IP "parse_stmtseq" 8 .IX Xref "parse_stmtseq" .IX Item "parse_stmtseq" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Parse a sequence of zero or more Perl statements. These may be normal imperative statements, including optional labels, or declarations that have compile-time effect, or any mixture thereof. The statement sequence ends when a closing brace or end-of-file is encountered in a place where a new statement could have validly started. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the statements. .Sp 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 \f(CW\*(C`lineseq\*(C'\fR list, normally including \f(CW\*(C`nextstate\*(C'\fR or equivalent ops. .Sp 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. .Sp The \f(CW\*(C`flags\*(C'\fR parameter is reserved for future use, and must always be zero. .Sp .Vb 1 \& OP* parse_stmtseq(U32 flags) .Ve .IP "parse_subsignature" 8 .IX Xref "parse_subsignature" .IX Item "parse_subsignature" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Parse a subroutine signature declaration. This is the contents of the parentheses following a named or anonymous subroutine declaration when the \&\f(CW\*(C`signatures\*(C'\fR feature is enabled. Note that this function neither expects nor consumes the opening and closing parentheses around the signature; it is the caller's job to handle these. .Sp This function must only be called during parsing of a subroutine; after \&\*(L"start_subparse\*(R" has been called. It might allocate lexical variables on the pad for the current subroutine. .Sp The op tree to unpack the arguments from the stack at runtime is returned. This op tree should appear at the beginning of the compiled function. The caller may wish to use \*(L"op_append_list\*(R" to build their function body after it, or splice it together with the body before calling \*(L"newATTRSUB\*(R". .Sp The \f(CW\*(C`flags\*(C'\fR parameter is reserved for future use, and must always be zero. .Sp .Vb 1 \& OP* parse_subsignature(U32 flags) .Ve .IP "parse_termexpr" 8 .IX Xref "parse_termexpr" .IX Item "parse_termexpr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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 \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`PARSE_OPTIONAL\*(C'\fR bit set, then the expression is optional, otherwise it is mandatory. It is up to the caller to ensure that the dynamic parser state (\*(L"PL_parser\*(R" et al) is correctly set to reflect the source of the code to be parsed and the lexical context for the expression. .Sp 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. .Sp 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. .Sp .Vb 1 \& OP* parse_termexpr(U32 flags) .Ve .IP "PL_parser" 8 .IX Xref "PL_parser" .IX Item "PL_parser" 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 \f(CW\*(C`PL_parser\*(C'\fR have their own documentation. .IP "PL_parser\->bufend" 8 .IX Xref "PL_parser->bufend" .IX Item "PL_parser->bufend" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Direct pointer to the end of the chunk of text currently being lexed, the end of the lexer buffer. This is equal to \f(CW\*(C`SvPVX(PL_parser\->linestr) + SvCUR(PL_parser\->linestr)\*(C'\fR. A \f(CW\*(C`NUL\*(C'\fR character (zero octet) is always located at the end of the buffer, and does not count as part of the buffer's contents. .IP "PL_parser\->bufptr" 8 .IX Xref "PL_parser->bufptr" .IX Item "PL_parser->bufptr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Points to the current position of lexing inside the lexer buffer. Characters around this point may be freely examined, within the range delimited by \f(CW\*(C`SvPVX("PL_parser\->linestr")\*(C'\fR and \&\*(L"PL_parser\->bufend\*(R". The octets of the buffer may be intended to be interpreted as either \s-1UTF\-8\s0 or Latin\-1, as indicated by \*(L"lex_bufutf8\*(R". .Sp 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"lex_read_to\*(R", which handles newlines appropriately. .Sp Interpretation of the buffer's octets can be abstracted out by using the slightly higher-level functions \*(L"lex_peek_unichar\*(R" and \&\*(L"lex_read_unichar\*(R". .IP "PL_parser\->linestart" 8 .IX Xref "PL_parser->linestart" .IX Item "PL_parser->linestart" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp 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"lex_read_to\*(R" handles this detail. .IP "PL_parser\->linestr" 8 .IX Xref "PL_parser->linestr" .IX Item "PL_parser->linestr" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Buffer scalar containing the chunk currently under consideration of the text currently being lexed. This is always a plain string scalar (for which \f(CW\*(C`SvPOK\*(C'\fR 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. .Sp The lexer maintains various \f(CW\*(C`char*\*(C'\fR pointers to things in the \&\f(CW\*(C`PL_parser\->linestr\*(C'\fR buffer. If \f(CW\*(C`PL_parser\->linestr\*(C'\fR is ever reallocated, all of these pointers must be updated. Don't attempt to do this manually, but rather use \*(L"lex_grow_linestr\*(R" if you need to reallocate the buffer. .Sp 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 \s-1UTF\-8\s0 or Latin\-1. The function \*(L"lex_bufutf8\*(R" tells you which. Do not use the \f(CW\*(C`SvUTF8\*(C'\fR flag on this scalar, which may disagree with it. .Sp For direct examination of the buffer, the variable \&\*(L"PL_parser\->bufend\*(R" points to the end of the buffer. The current lexing position is pointed to by \*(L"PL_parser\->bufptr\*(R". Direct use of these pointers is usually preferable to examination of the scalar through normal scalar means. .IP "wrap_keyword_plugin" 8 .IX Xref "wrap_keyword_plugin" .IX Item "wrap_keyword_plugin" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Puts a C function into the chain of keyword plugins. This is the preferred way to manipulate the \*(L"PL_keyword_plugin\*(R" variable. \&\f(CW\*(C`new_plugin\*(C'\fR is a pointer to the C function that is to be added to the keyword plugin chain, and \f(CW\*(C`old_plugin_p\*(C'\fR points to the storage location where a pointer to the next function in the chain will be stored. The value of \f(CW\*(C`new_plugin\*(C'\fR is written into the \*(L"PL_keyword_plugin\*(R" variable, while the value previously stored there is written to \f(CW*old_plugin_p\fR. .Sp \&\*(L"PL_keyword_plugin\*(R" is global to an entire process, and a module wishing to hook keyword parsing may find itself invoked more than once per process, typically in different threads. To handle that situation, this function is idempotent. The location \f(CW*old_plugin_p\fR must initially (once per process) contain a null pointer. A C variable of static duration (declared at file scope, typically also marked \f(CW\*(C`static\*(C'\fR 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 plugin chain if it finds \f(CW*old_plugin_p\fR to be null. This function is also thread safe on the small scale. It uses appropriate locking to avoid race conditions in accessing \*(L"PL_keyword_plugin\*(R". .Sp When this function is called, the function referenced by \f(CW\*(C`new_plugin\*(C'\fR must be ready to be called, except for \f(CW*old_plugin_p\fR being unfilled. In a threading situation, \f(CW\*(C`new_plugin\*(C'\fR may be called immediately, even before this function has returned. \f(CW*old_plugin_p\fR will always be appropriately set before \f(CW\*(C`new_plugin\*(C'\fR is called. If \f(CW\*(C`new_plugin\*(C'\fR decides not to do anything special with the identifier that it is given (which is the usual case for most calls to a keyword plugin), it must chain the plugin function referenced by \f(CW*old_plugin_p\fR. .Sp Taken all together, \s-1XS\s0 code to install a keyword plugin should typically look something like this: .Sp .Vb 10 \& static Perl_keyword_plugin_t next_keyword_plugin; \& static OP *my_keyword_plugin(pTHX_ \& char *keyword_ptr, STRLEN keyword_len, OP **op_ptr) \& { \& if (memEQs(keyword_ptr, keyword_len, \& "my_new_keyword")) { \& ... \& } else { \& return next_keyword_plugin(aTHX_ \& keyword_ptr, keyword_len, op_ptr); \& } \& } \& BOOT: \& wrap_keyword_plugin(my_keyword_plugin, \& &next_keyword_plugin); .Ve .Sp Direct access to \*(L"PL_keyword_plugin\*(R" should be avoided. .Sp .Vb 4 \& void wrap_keyword_plugin( \& Perl_keyword_plugin_t new_plugin, \& Perl_keyword_plugin_t *old_plugin_p \& ) .Ve .SH "Locale-related functions and macros" .IX Header "Locale-related functions and macros" .IP "\s-1DECLARATION_FOR_LC_NUMERIC_MANIPULATION\s0" 8 .IX Xref "DECLARATION_FOR_LC_NUMERIC_MANIPULATION" .IX Item "DECLARATION_FOR_LC_NUMERIC_MANIPULATION" 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. .Sp .Vb 1 \& void DECLARATION_FOR_LC_NUMERIC_MANIPULATION .Ve .IP "\s-1IN_LOCALE\s0" 8 .IX Xref "IN_LOCALE" .IX Item "IN_LOCALE" Evaluates to \s-1TRUE\s0 if the plain locale pragma without a parameter (\f(CW\*(C`use locale\*(C'\fR) is in effect. .Sp .Vb 1 \& bool IN_LOCALE .Ve .IP "\s-1IN_LOCALE_COMPILETIME\s0" 8 .IX Xref "IN_LOCALE_COMPILETIME" .IX Item "IN_LOCALE_COMPILETIME" Evaluates to \s-1TRUE\s0 if, when compiling a perl program (including an \f(CW\*(C`eval\*(C'\fR) if the plain locale pragma without a parameter (\f(CW\*(C`use locale\*(C'\fR) is in effect. .Sp .Vb 1 \& bool IN_LOCALE_COMPILETIME .Ve .IP "\s-1IN_LOCALE_RUNTIME\s0" 8 .IX Xref "IN_LOCALE_RUNTIME" .IX Item "IN_LOCALE_RUNTIME" Evaluates to \s-1TRUE\s0 if, when executing a perl program (including an \f(CW\*(C`eval\*(C'\fR) if the plain locale pragma without a parameter (\f(CW\*(C`use locale\*(C'\fR) is in effect. .Sp .Vb 1 \& bool IN_LOCALE_RUNTIME .Ve .IP "Perl_langinfo" 8 .IX Xref "Perl_langinfo" .IX Item "Perl_langinfo" This is an (almost) drop-in replacement for the system \f(CWnl_langinfo(3)\fR, taking the same \f(CW\*(C`item\*(C'\fR parameter values, and returning the same information. But it is more thread-safe than regular \f(CW\*(C`nl_langinfo()\*(C'\fR, and hides the quirks of Perl's locale handling from your code, and can be used on systems that lack a native \f(CW\*(C`nl_langinfo\*(C'\fR. .Sp Expanding on these: .RS 8 .IP "\(bu" 4 The reason it isn't quite a drop-in replacement is actually an advantage. The only difference is that it returns \f(CW\*(C`const char *\*(C'\fR, whereas plain \&\f(CW\*(C`nl_langinfo()\*(C'\fR returns \f(CW\*(C`char *\*(C'\fR, but you are (only by documentation) forbidden to write into the buffer. By declaring this \f(CW\*(C`const\*(C'\fR, the compiler enforces this restriction, so if it is violated, you know at compilation time, rather than getting segfaults at runtime. .IP "\(bu" 4 It delivers the correct results for the \f(CW\*(C`RADIXCHAR\*(C'\fR and \f(CW\*(C`THOUSEP\*(C'\fR items, without you having to write extra code. The reason for the extra code would be because these are from the \f(CW\*(C`LC_NUMERIC\*(C'\fR locale category, which is normally kept set by Perl so that the radix is a dot, and the separator is the empty string, no matter what the underlying locale is supposed to be, and so to get the expected results, you have to temporarily toggle into the underlying locale, and later toggle back. (You could use plain \f(CW\*(C`nl_langinfo\*(C'\fR and \&\f(CW"STORE_LC_NUMERIC_FORCE_TO_UNDERLYING"\fR for this but then you wouldn't get the other advantages of \f(CW\*(C`Perl_langinfo()\*(C'\fR; not keeping \f(CW\*(C`LC_NUMERIC\*(C'\fR in the C (or equivalent) locale would break a lot of \s-1CPAN,\s0 which is expecting the radix (decimal point) character to be a dot.) .IP "\(bu" 4 The system function it replaces can have its static return buffer trashed, not only by a subesequent call to that function, but by a \f(CW\*(C`freelocale\*(C'\fR, \&\f(CW\*(C`setlocale\*(C'\fR, or other locale change. The returned buffer of this function is not changed until the next call to it, so the buffer is never in a trashed state. .IP "\(bu" 4 Its return buffer is per-thread, so it also is never overwritten by a call to this function from another thread; unlike the function it replaces. .IP "\(bu" 4 But most importantly, it works on systems that don't have \f(CW\*(C`nl_langinfo\*(C'\fR, such as Windows, hence makes your code more portable. Of the fifty-some possible items specified by the \s-1POSIX 2008\s0 standard, , only one is completely unimplemented, though on non-Windows platforms, another significant one is also not implemented). It uses various techniques to recover the other items, including calling \f(CWlocaleconv(3)\fR, and \&\f(CWstrftime(3)\fR, both of which are specified in C89, so should be always be available. Later \f(CW\*(C`strftime()\*(C'\fR versions have additional capabilities; \f(CW""\fR is returned for those not available on your system. .Sp It is important to note that when called with an item that is recovered by using \f(CW\*(C`localeconv\*(C'\fR, the buffer from any previous explicit call to \&\f(CW\*(C`localeconv\*(C'\fR will be overwritten. This means you must save that buffer's contents if you need to access them after a call to this function. (But note that you might not want to be using \f(CW\*(C`localeconv()\*(C'\fR directly anyway, because of issues like the ones listed in the second item of this list (above) for \&\f(CW\*(C`RADIXCHAR\*(C'\fR and \f(CW\*(C`THOUSEP\*(C'\fR. You can use the methods given in perlcall to call \*(L"localeconv\*(R" in \s-1POSIX\s0 and avoid all the issues, but then you have a hash to unpack). .Sp The details for those items which may deviate from what this emulation returns and what a native \f(CW\*(C`nl_langinfo()\*(C'\fR would return are specified in I18N::Langinfo. .RE .RS 8 .Sp When using \f(CW\*(C`Perl_langinfo\*(C'\fR on systems that don't have a native \&\f(CW\*(C`nl_langinfo()\*(C'\fR, you must .Sp .Vb 1 \& #include "perl_langinfo.h" .Ve .Sp before the \f(CW\*(C`perl.h\*(C'\fR \f(CW\*(C`#include\*(C'\fR. You can replace your \f(CW\*(C`langinfo.h\*(C'\fR \&\f(CW\*(C`#include\*(C'\fR with this one. (Doing it this way keeps out the symbols that plain \&\f(CW\*(C`langinfo.h\*(C'\fR would try to import into the namespace for code that doesn't need it.) .Sp The original impetus for \f(CW\*(C`Perl_langinfo()\*(C'\fR was so that code that needs to find out the current currency symbol, floating point radix character, or digit grouping separator can use, on all systems, the simpler and more thread-friendly \f(CW\*(C`nl_langinfo\*(C'\fR \s-1API\s0 instead of \f(CWlocaleconv(3)\fR which is a pain to make thread-friendly. For other fields returned by \f(CW\*(C`localeconv\*(C'\fR, it is better to use the methods given in perlcall to call \&\f(CW\*(C`POSIX::localeconv()\*(C'\fR, which is thread-friendly. .Sp .Vb 1 \& const char* Perl_langinfo(const nl_item item) .Ve .RE .IP "Perl_setlocale" 8 .IX Xref "Perl_setlocale" .IX Item "Perl_setlocale" This is an (almost) drop-in replacement for the system \f(CWsetlocale(3)\fR, taking the same parameters, and returning the same information, except that it returns the correct underlying \f(CW\*(C`LC_NUMERIC\*(C'\fR locale. Regular \f(CW\*(C`setlocale\*(C'\fR will instead return \f(CW\*(C`C\*(C'\fR if the underlying locale has a non-dot decimal point character, or a non-empty thousands separator for displaying floating point numbers. This is because perl keeps that locale category such that it has a dot and empty separator, changing the locale briefly during the operations where the underlying one is required. \f(CW\*(C`Perl_setlocale\*(C'\fR knows about this, and compensates; regular \f(CW\*(C`setlocale\*(C'\fR doesn't. .Sp Another reason it isn't completely a drop-in replacement is that it is declared to return \f(CW\*(C`const char *\*(C'\fR, whereas the system setlocale omits the \&\f(CW\*(C`const\*(C'\fR (presumably because its \s-1API\s0 was specified long ago, and can't be updated; it is illegal to change the information \f(CW\*(C`setlocale\*(C'\fR returns; doing so leads to segfaults.) .Sp Finally, \f(CW\*(C`Perl_setlocale\*(C'\fR works under all circumstances, whereas plain \&\f(CW\*(C`setlocale\*(C'\fR can be completely ineffective on some platforms under some configurations. .Sp \&\f(CW\*(C`Perl_setlocale\*(C'\fR should not be used to change the locale except on systems where the predefined variable \f(CW\*(C`${^SAFE_LOCALES}\*(C'\fR is 1. On some such systems, the system \f(CW\*(C`setlocale()\*(C'\fR is ineffective, returning the wrong information, and failing to actually change the locale. \f(CW\*(C`Perl_setlocale\*(C'\fR, however works properly in all circumstances. .Sp The return points to a per-thread static buffer, which is overwritten the next time \f(CW\*(C`Perl_setlocale\*(C'\fR is called from the same thread. .Sp .Vb 2 \& const char* Perl_setlocale(const int category, \& const char* locale) .Ve .IP "\s-1RESTORE_LC_NUMERIC\s0" 8 .IX Xref "RESTORE_LC_NUMERIC" .IX Item "RESTORE_LC_NUMERIC" This is used in conjunction with one of the macros \&\*(L"\s-1STORE_LC_NUMERIC_SET_TO_NEEDED\*(R"\s0 and \*(L"\s-1STORE_LC_NUMERIC_FORCE_TO_UNDERLYING\*(R"\s0 to properly restore the \&\f(CW\*(C`LC_NUMERIC\*(C'\fR state. .Sp A call to \*(L"\s-1DECLARATION_FOR_LC_NUMERIC_MANIPULATION\*(R"\s0 must have been made to declare at compile time a private variable used by this macro and the two \&\f(CW\*(C`STORE\*(C'\fR ones. This macro should be called as a single statement, not an expression, but with an empty argument list, like this: .Sp .Vb 6 \& { \& DECLARATION_FOR_LC_NUMERIC_MANIPULATION; \& ... \& RESTORE_LC_NUMERIC(); \& ... \& } \& \& void RESTORE_LC_NUMERIC() .Ve .IP "\s-1STORE_LC_NUMERIC_FORCE_TO_UNDERLYING\s0" 8 .IX Xref "STORE_LC_NUMERIC_FORCE_TO_UNDERLYING" .IX Item "STORE_LC_NUMERIC_FORCE_TO_UNDERLYING" This is used by \s-1XS\s0 code that is \f(CW\*(C`LC_NUMERIC\*(C'\fR locale-aware to force the locale for category \f(CW\*(C`LC_NUMERIC\*(C'\fR 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 \s-1XS\s0 code has called the C library function \fBsetlocale\fR\|(3) behind its back; calling \*(L"sync_locale\*(R" before calling this macro will update perl's records.) .Sp A call to \*(L"\s-1DECLARATION_FOR_LC_NUMERIC_MANIPULATION\*(R"\s0 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: .Sp .Vb 8 \& { \& DECLARATION_FOR_LC_NUMERIC_MANIPULATION; \& ... \& STORE_LC_NUMERIC_FORCE_TO_UNDERLYING(); \& ... \& RESTORE_LC_NUMERIC(); \& ... \& } .Ve .Sp The private variable is used to save the current locale state, so that the requisite matching call to \*(L"\s-1RESTORE_LC_NUMERIC\*(R"\s0 can restore it. .Sp On threaded perls not operating with thread-safe functionality, this macro uses a mutex to force a critical section. Therefore the matching \s-1RESTORE\s0 should be close by, and guaranteed to be called. .Sp .Vb 1 \& void STORE_LC_NUMERIC_FORCE_TO_UNDERLYING() .Ve .IP "\s-1STORE_LC_NUMERIC_SET_TO_NEEDED\s0" 8 .IX Xref "STORE_LC_NUMERIC_SET_TO_NEEDED" .IX Item "STORE_LC_NUMERIC_SET_TO_NEEDED" This is used to help wrap \s-1XS\s0 or C code that is \f(CW\*(C`LC_NUMERIC\*(C'\fR locale-aware. This locale category is generally kept set to a locale where the decimal radix character is a dot, and the separator between groups of digits is empty. This is because most \s-1XS\s0 code that reads floating point numbers is expecting them to have this syntax. .Sp This macro makes sure the current \f(CW\*(C`LC_NUMERIC\*(C'\fR state is set properly, to be aware of locale if the call to the \s-1XS\s0 or C code from the Perl program is from within the scope of a \f(CW\*(C`use locale\*(C'\fR; or to ignore locale if the call is instead from outside such scope. .Sp This macro is the start of wrapping the C or \s-1XS\s0 code; the wrap ending is done by calling the \*(L"\s-1RESTORE_LC_NUMERIC\*(R"\s0 macro after the operation. Otherwise the state can be changed that will adversely affect other \s-1XS\s0 code. .Sp A call to \*(L"\s-1DECLARATION_FOR_LC_NUMERIC_MANIPULATION\*(R"\s0 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: .Sp .Vb 8 \& { \& DECLARATION_FOR_LC_NUMERIC_MANIPULATION; \& ... \& STORE_LC_NUMERIC_SET_TO_NEEDED(); \& ... \& RESTORE_LC_NUMERIC(); \& ... \& } .Ve .Sp On threaded perls not operating with thread-safe functionality, this macro uses a mutex to force a critical section. Therefore the matching \s-1RESTORE\s0 should be close by, and guaranteed to be called; see \*(L"\s-1WITH_LC_NUMERIC_SET_TO_NEEDED\*(R"\s0 for a more contained way to ensure that. .Sp .Vb 1 \& void STORE_LC_NUMERIC_SET_TO_NEEDED() .Ve .IP "\s-1STORE_LC_NUMERIC_SET_TO_NEEDED_IN\s0" 8 .IX Xref "STORE_LC_NUMERIC_SET_TO_NEEDED_IN" .IX Item "STORE_LC_NUMERIC_SET_TO_NEEDED_IN" Same as \*(L"\s-1STORE_LC_NUMERIC_SET_TO_NEEDED\*(R"\s0 with in_lc_numeric provided as the precalculated value of \f(CW\*(C`IN_LC(LC_NUMERIC)\*(C'\fR. It is the caller's responsibility to ensure that the status of \f(CW\*(C`PL_compiling\*(C'\fR and \f(CW\*(C`PL_hints\*(C'\fR cannot have changed since the precalculation. .Sp .Vb 3 \& void STORE_LC_NUMERIC_SET_TO_NEEDED_IN( \& bool in_lc_numeric \& ) .Ve .IP "switch_to_global_locale" 8 .IX Xref "switch_to_global_locale" .IX Item "switch_to_global_locale" On systems without locale support, or on typical single-threaded builds, or on platforms that do not support per-thread locale operations, this function does nothing. On such systems that do have locale support, only a locale global to the whole program is available. .Sp On multi-threaded builds on systems that do have per-thread locale operations, this function converts the thread it is running in to use the global locale. This is for code that has not yet or cannot be updated to handle multi-threaded locale operation. As long as only a single thread is so-converted, everything works fine, as all the other threads continue to ignore the global one, so only this thread looks at it. .Sp However, on Windows systems this isn't quite true prior to Visual Studio 15, at which point Microsoft fixed a bug. A race can occur if you use the following operations on earlier Windows platforms: .RS 8 .IP "POSIX::localeconv" 4 .IX Item "POSIX::localeconv" .PD 0 .ie n .IP "I18N::Langinfo, items ""CRNCYSTR"" and ""THOUSEP""" 4 .el .IP "I18N::Langinfo, items \f(CWCRNCYSTR\fR and \f(CWTHOUSEP\fR" 4 .IX Item "I18N::Langinfo, items CRNCYSTR and THOUSEP" .ie n .IP """Perl_langinfo"" in perlapi, items ""CRNCYSTR"" and ""THOUSEP""" 4 .el .IP "``Perl_langinfo'' in perlapi, items \f(CWCRNCYSTR\fR and \f(CWTHOUSEP\fR" 4 .IX Item "Perl_langinfo in perlapi, items CRNCYSTR and THOUSEP" .RE .RS 8 .PD .Sp The first item is not fixable (except by upgrading to a later Visual Studio release), but it would be possible to work around the latter two items by using the Windows \s-1API\s0 functions \f(CW\*(C`GetNumberFormat\*(C'\fR and \f(CW\*(C`GetCurrencyFormat\*(C'\fR; patches welcome. .Sp Without this function call, threads that use the \f(CWsetlocale(3)\fR system function will not work properly, as all the locale-sensitive functions will look at the per-thread locale, and \f(CW\*(C`setlocale\*(C'\fR will have no effect on this thread. .Sp Perl code should convert to either call \&\f(CW\*(C`Perl_setlocale\*(C'\fR (which is a drop-in for the system \&\f(CW\*(C`setlocale\*(C'\fR) or use the methods given in perlcall to call \&\f(CW\*(C`POSIX::setlocale\*(C'\fR. Either one will transparently properly handle all cases of single\- vs multi-thread, \s-1POSIX\s0 2008\-supported or not. .Sp Non-Perl libraries, such as \f(CW\*(C`gtk\*(C'\fR, that call the system \f(CW\*(C`setlocale\*(C'\fR can continue to work if this function is called before transferring control to the library. .Sp Upon return from the code that needs to use the global locale, \&\f(CW\*(C`sync_locale()\*(C'\fR should be called to restore the safe multi-thread operation. .Sp .Vb 1 \& void switch_to_global_locale() .Ve .RE .IP "sync_locale" 8 .IX Xref "sync_locale" .IX Item "sync_locale" \&\f(CW\*(C`Perl_setlocale\*(C'\fR can be used at any time to query or change the locale (though changing the locale is antisocial and dangerous on multi-threaded systems that don't have multi-thread safe locale operations. (See \*(L"Multi-threaded operation\*(R" in perllocale). Using the system \&\f(CWsetlocale(3)\fR should be avoided. Nevertheless, certain non-Perl libraries called from \s-1XS,\s0 such as \f(CW\*(C`Gtk\*(C'\fR do so, and this can't be changed. When the locale is changed by \s-1XS\s0 code that didn't use \&\f(CW\*(C`Perl_setlocale\*(C'\fR, Perl needs to be told that the locale has changed. Use this function to do so, before returning to Perl. .Sp The return value is a boolean: \s-1TRUE\s0 if the global locale at the time of call was in effect; and \s-1FALSE\s0 if a per-thread locale was in effect. This can be used by the caller that needs to restore things as-they-were to decide whether or not to call \&\f(CW\*(C`Perl_switch_to_global_locale\*(C'\fR. .Sp .Vb 1 \& bool sync_locale() .Ve .IP "\s-1WITH_LC_NUMERIC_SET_TO_NEEDED\s0" 8 .IX Xref "WITH_LC_NUMERIC_SET_TO_NEEDED" .IX Item "WITH_LC_NUMERIC_SET_TO_NEEDED" This macro invokes the supplied statement or block within the context of a \*(L"\s-1STORE_LC_NUMERIC_SET_TO_NEEDED\*(R"\s0 .. \*(L"\s-1RESTORE_LC_NUMERIC\*(R"\s0 pair if required, so eg: .Sp .Vb 3 \& WITH_LC_NUMERIC_SET_TO_NEEDED( \& SNPRINTF_G(fv, ebuf, sizeof(ebuf), precis) \& ); .Ve .Sp is equivalent to: .Sp .Vb 10 \& { \&#ifdef USE_LOCALE_NUMERIC \& DECLARATION_FOR_LC_NUMERIC_MANIPULATION; \& STORE_LC_NUMERIC_SET_TO_NEEDED(); \&#endif \& SNPRINTF_G(fv, ebuf, sizeof(ebuf), precis); \&#ifdef USE_LOCALE_NUMERIC \& RESTORE_LC_NUMERIC(); \&#endif \& } \& \& void WITH_LC_NUMERIC_SET_TO_NEEDED(block) .Ve .IP "\s-1WITH_LC_NUMERIC_SET_TO_NEEDED_IN\s0" 8 .IX Xref "WITH_LC_NUMERIC_SET_TO_NEEDED_IN" .IX Item "WITH_LC_NUMERIC_SET_TO_NEEDED_IN" Same as \*(L"\s-1WITH_LC_NUMERIC_SET_TO_NEEDED\*(R"\s0 with in_lc_numeric provided as the precalculated value of \f(CW\*(C`IN_LC(LC_NUMERIC)\*(C'\fR. It is the caller's responsibility to ensure that the status of \f(CW\*(C`PL_compiling\*(C'\fR and \f(CW\*(C`PL_hints\*(C'\fR cannot have changed since the precalculation. .Sp .Vb 3 \& void WITH_LC_NUMERIC_SET_TO_NEEDED_IN( \& bool in_lc_numeric, block \& ) .Ve .SH "Magical Functions" .IX Header "Magical Functions" .IP "mg_clear" 8 .IX Xref "mg_clear" .IX Item "mg_clear" Clear something magical that the \s-1SV\s0 represents. See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& int mg_clear(SV* sv) .Ve .IP "mg_copy" 8 .IX Xref "mg_copy" .IX Item "mg_copy" Copies the magic from one \s-1SV\s0 to another. See \f(CW"sv_magic"\fR. .Sp .Vb 2 \& int mg_copy(SV *sv, SV *nsv, const char *key, \& I32 klen) .Ve .IP "mg_find" 8 .IX Xref "mg_find" .IX Item "mg_find" Finds the magic pointer for \f(CW\*(C`type\*(C'\fR matching the \s-1SV.\s0 See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& MAGIC* mg_find(const SV* sv, int type) .Ve .IP "mg_findext" 8 .IX Xref "mg_findext" .IX Item "mg_findext" Finds the magic pointer of \f(CW\*(C`type\*(C'\fR with the given \f(CW\*(C`vtbl\*(C'\fR for the \f(CW\*(C`SV\*(C'\fR. See \&\f(CW"sv_magicext"\fR. .Sp .Vb 2 \& MAGIC* mg_findext(const SV* sv, int type, \& const MGVTBL *vtbl) .Ve .IP "mg_free" 8 .IX Xref "mg_free" .IX Item "mg_free" Free any magic storage used by the \s-1SV.\s0 See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& int mg_free(SV* sv) .Ve .IP "mg_freeext" 8 .IX Xref "mg_freeext" .IX Item "mg_freeext" Remove any magic of type \f(CW\*(C`how\*(C'\fR using virtual table \f(CW\*(C`vtbl\*(C'\fR from the \&\s-1SV\s0 \f(CW\*(C`sv\*(C'\fR. See \*(L"sv_magic\*(R". .Sp \&\f(CW\*(C`mg_freeext(sv, how, NULL)\*(C'\fR is equivalent to \f(CW\*(C`mg_free_type(sv, how)\*(C'\fR. .Sp .Vb 1 \& void mg_freeext(SV* sv, int how, const MGVTBL *vtbl) .Ve .IP "mg_free_type" 8 .IX Xref "mg_free_type" .IX Item "mg_free_type" Remove any magic of type \f(CW\*(C`how\*(C'\fR from the \s-1SV\s0 \f(CW\*(C`sv\*(C'\fR. See \*(L"sv_magic\*(R". .Sp .Vb 1 \& void mg_free_type(SV* sv, int how) .Ve .IP "mg_get" 8 .IX Xref "mg_get" .IX Item "mg_get" Do magic before a value is retrieved from the \s-1SV.\s0 The type of \s-1SV\s0 must be >= \f(CW\*(C`SVt_PVMG\*(C'\fR. See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& int mg_get(SV* sv) .Ve .IP "mg_length" 8 .IX Xref "mg_length" .IX Item "mg_length" \&\s-1DEPRECATED\s0! 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. .Sp Reports on the \s-1SV\s0's length in bytes, calling length magic if available, but does not set the \s-1UTF8\s0 flag on \f(CW\*(C`sv\*(C'\fR. 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 \f(CW\*(C`sv\*(C'\fR is a \f(CW\*(C`PVMG\*(C'\fR or higher. Use \f(CW\*(C`sv_len()\*(C'\fR instead. .Sp .Vb 1 \& U32 mg_length(SV* sv) .Ve .IP "mg_magical" 8 .IX Xref "mg_magical" .IX Item "mg_magical" Turns on the magical status of an \s-1SV.\s0 See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& void mg_magical(SV* sv) .Ve .IP "mg_set" 8 .IX Xref "mg_set" .IX Item "mg_set" Do magic after a value is assigned to the \s-1SV.\s0 See \f(CW"sv_magic"\fR. .Sp .Vb 1 \& int mg_set(SV* sv) .Ve .IP "SvGETMAGIC" 8 .IX Xref "SvGETMAGIC" .IX Item "SvGETMAGIC" Invokes \f(CW\*(C`mg_get\*(C'\fR on an \s-1SV\s0 if it has 'get' magic. For example, this will call \f(CW\*(C`FETCH\*(C'\fR on a tied variable. This macro evaluates its argument more than once. .Sp .Vb 1 \& void SvGETMAGIC(SV* sv) .Ve .IP "SvLOCK" 8 .IX Xref "SvLOCK" .IX Item "SvLOCK" Arranges for a mutual exclusion lock to be obtained on \f(CW\*(C`sv\*(C'\fR if a suitable module has been loaded. .Sp .Vb 1 \& void SvLOCK(SV* sv) .Ve .IP "SvSETMAGIC" 8 .IX Xref "SvSETMAGIC" .IX Item "SvSETMAGIC" Invokes \f(CW\*(C`mg_set\*(C'\fR on an \s-1SV\s0 if it has 'set' magic. This is necessary after modifying a scalar, in case it is a magical variable like \f(CW$|\fR or a tied variable (it calls \f(CW\*(C`STORE\*(C'\fR). This macro evaluates its argument more than once. .Sp .Vb 1 \& void SvSETMAGIC(SV* sv) .Ve .IP "SvSetMagicSV" 8 .IX Xref "SvSetMagicSV" .IX Item "SvSetMagicSV" Like \f(CW\*(C`SvSetSV\*(C'\fR, but does any set magic required afterwards. .Sp .Vb 1 \& void SvSetMagicSV(SV* dsv, SV* ssv) .Ve .IP "SvSetMagicSV_nosteal" 8 .IX Xref "SvSetMagicSV_nosteal" .IX Item "SvSetMagicSV_nosteal" Like \f(CW\*(C`SvSetSV_nosteal\*(C'\fR, but does any set magic required afterwards. .Sp .Vb 1 \& void SvSetMagicSV_nosteal(SV* dsv, SV* ssv) .Ve .IP "SvSetSV" 8 .IX Xref "SvSetSV" .IX Item "SvSetSV" Calls \f(CW\*(C`sv_setsv\*(C'\fR if \f(CW\*(C`dsv\*(C'\fR is not the same as \f(CW\*(C`ssv\*(C'\fR. May evaluate arguments more than once. Does not handle 'set' magic on the destination \s-1SV.\s0 .Sp .Vb 1 \& void SvSetSV(SV* dsv, SV* ssv) .Ve .IP "SvSetSV_nosteal" 8 .IX Xref "SvSetSV_nosteal" .IX Item "SvSetSV_nosteal" Calls a non-destructive version of \f(CW\*(C`sv_setsv\*(C'\fR if \f(CW\*(C`dsv\*(C'\fR is not the same as \&\f(CW\*(C`ssv\*(C'\fR. May evaluate arguments more than once. .Sp .Vb 1 \& void SvSetSV_nosteal(SV* dsv, SV* ssv) .Ve .IP "SvSHARE" 8 .IX Xref "SvSHARE" .IX Item "SvSHARE" Arranges for \f(CW\*(C`sv\*(C'\fR to be shared between threads if a suitable module has been loaded. .Sp .Vb 1 \& void SvSHARE(SV* sv) .Ve .IP "sv_string_from_errnum" 8 .IX Xref "sv_string_from_errnum" .IX Item "sv_string_from_errnum" Generates the message string describing an \s-1OS\s0 error and returns it as an \s-1SV.\s0 \f(CW\*(C`errnum\*(C'\fR must be a value that \f(CW\*(C`errno\*(C'\fR could take, identifying the type of error. .Sp If \f(CW\*(C`tgtsv\*(C'\fR is non-null then the string will be written into that \s-1SV\s0 (overwriting existing content) and it will be returned. If \f(CW\*(C`tgtsv\*(C'\fR is a null pointer then the string will be written into a new mortal \s-1SV\s0 which will be returned. .Sp The message will be taken from whatever locale would be used by \f(CW$!\fR, and will be encoded in the \s-1SV\s0 in whatever manner would be used by \f(CW$!\fR. The details of this process are subject to future change. Currently, the message is taken from the C locale by default (usually producing an English message), and from the currently selected locale when in the scope of the \f(CW\*(C`use locale\*(C'\fR pragma. A heuristic attempt is made to decode the message from the locale's character encoding, but it will only be decoded as either \s-1UTF\-8\s0 or \s-1ISO\-8859\-1.\s0 It is always correctly decoded in a \s-1UTF\-8\s0 locale, usually in an \s-1ISO\-8859\-1\s0 locale, and never in any other locale. .Sp The \s-1SV\s0 is always returned containing an actual string, and with no other \&\s-1OK\s0 bits set. Unlike \f(CW$!\fR, a message is even yielded for \f(CW\*(C`errnum\*(C'\fR zero (meaning success), and if no useful message is available then a useless string (currently empty) is returned. .Sp .Vb 1 \& SV* sv_string_from_errnum(int errnum, SV* tgtsv) .Ve .IP "SvUNLOCK" 8 .IX Xref "SvUNLOCK" .IX Item "SvUNLOCK" Releases a mutual exclusion lock on \f(CW\*(C`sv\*(C'\fR if a suitable module has been loaded. .Sp .Vb 1 \& void SvUNLOCK(SV* sv) .Ve .SH "Memory Management" .IX Header "Memory Management" .IP "Copy" 8 .IX Xref "Copy" .IX Item "Copy" The XSUB-writer's interface to the C \f(CW\*(C`memcpy\*(C'\fR function. The \f(CW\*(C`src\*(C'\fR is the source, \f(CW\*(C`dest\*(C'\fR is the destination, \f(CW\*(C`nitems\*(C'\fR is the number of items, and \&\f(CW\*(C`type\*(C'\fR is the type. May fail on overlapping copies. See also \f(CW"Move"\fR. .Sp .Vb 1 \& void Copy(void* src, void* dest, int nitems, type) .Ve .IP "CopyD" 8 .IX Xref "CopyD" .IX Item "CopyD" Like \f(CW\*(C`Copy\*(C'\fR but returns \f(CW\*(C`dest\*(C'\fR. Useful for encouraging compilers to tail-call optimise. .Sp .Vb 1 \& void * CopyD(void* src, void* dest, int nitems, type) .Ve .IP "Move" 8 .IX Xref "Move" .IX Item "Move" The XSUB-writer's interface to the C \f(CW\*(C`memmove\*(C'\fR function. The \f(CW\*(C`src\*(C'\fR is the source, \f(CW\*(C`dest\*(C'\fR is the destination, \f(CW\*(C`nitems\*(C'\fR is the number of items, and \&\f(CW\*(C`type\*(C'\fR is the type. Can do overlapping moves. See also \f(CW"Copy"\fR. .Sp .Vb 1 \& void Move(void* src, void* dest, int nitems, type) .Ve .IP "MoveD" 8 .IX Xref "MoveD" .IX Item "MoveD" Like \f(CW\*(C`Move\*(C'\fR but returns \f(CW\*(C`dest\*(C'\fR. Useful for encouraging compilers to tail-call optimise. .Sp .Vb 1 \& void * MoveD(void* src, void* dest, int nitems, type) .Ve .IP "Newx" 8 .IX Xref "Newx" .IX Item "Newx" The XSUB-writer's interface to the C \f(CW\*(C`malloc\*(C'\fR function. .Sp Memory obtained by this should \fB\s-1ONLY\s0\fR be freed with \*(L"Safefree\*(R". .Sp In 5.9.3, \fBNewx()\fR and friends replace the older \fBNew()\fR \s-1API,\s0 and drops the first parameter, \fIx\fR, a debug aid which allowed callers to identify themselves. This aid has been superseded by a new build option, \&\s-1PERL_MEM_LOG\s0 (see \*(L"\s-1PERL_MEM_LOG\*(R"\s0 in perlhacktips). The older \s-1API\s0 is still there for use in \s-1XS\s0 modules supporting older perls. .Sp .Vb 1 \& void Newx(void* ptr, int nitems, type) .Ve .IP "Newxc" 8 .IX Xref "Newxc" .IX Item "Newxc" The XSUB-writer's interface to the C \f(CW\*(C`malloc\*(C'\fR function, with cast. See also \f(CW"Newx"\fR. .Sp Memory obtained by this should \fB\s-1ONLY\s0\fR be freed with \*(L"Safefree\*(R". .Sp .Vb 1 \& void Newxc(void* ptr, int nitems, type, cast) .Ve .IP "Newxz" 8 .IX Xref "Newxz" .IX Item "Newxz" The XSUB-writer's interface to the C \f(CW\*(C`malloc\*(C'\fR function. The allocated memory is zeroed with \f(CW\*(C`memzero\*(C'\fR. See also \f(CW"Newx"\fR. .Sp Memory obtained by this should \fB\s-1ONLY\s0\fR be freed with \*(L"Safefree\*(R". .Sp .Vb 1 \& void Newxz(void* ptr, int nitems, type) .Ve .IP "Poison" 8 .IX Xref "Poison" .IX Item "Poison" PoisonWith(0xEF) for catching access to freed memory. .Sp .Vb 1 \& void Poison(void* dest, int nitems, type) .Ve .IP "PoisonFree" 8 .IX Xref "PoisonFree" .IX Item "PoisonFree" PoisonWith(0xEF) for catching access to freed memory. .Sp .Vb 1 \& void PoisonFree(void* dest, int nitems, type) .Ve .IP "PoisonNew" 8 .IX Xref "PoisonNew" .IX Item "PoisonNew" PoisonWith(0xAB) for catching access to allocated but uninitialized memory. .Sp .Vb 1 \& void PoisonNew(void* dest, int nitems, type) .Ve .IP "PoisonWith" 8 .IX Xref "PoisonWith" .IX Item "PoisonWith" Fill up memory with a byte pattern (a byte repeated over and over again) that hopefully catches attempts to access uninitialized memory. .Sp .Vb 2 \& void PoisonWith(void* dest, int nitems, type, \& U8 byte) .Ve .IP "Renew" 8 .IX Xref "Renew" .IX Item "Renew" The XSUB-writer's interface to the C \f(CW\*(C`realloc\*(C'\fR function. .Sp Memory obtained by this should \fB\s-1ONLY\s0\fR be freed with \*(L"Safefree\*(R". .Sp .Vb 1 \& void Renew(void* ptr, int nitems, type) .Ve .IP "Renewc" 8 .IX Xref "Renewc" .IX Item "Renewc" The XSUB-writer's interface to the C \f(CW\*(C`realloc\*(C'\fR function, with cast. .Sp Memory obtained by this should \fB\s-1ONLY\s0\fR be freed with \*(L"Safefree\*(R". .Sp .Vb 1 \& void Renewc(void* ptr, int nitems, type, cast) .Ve .IP "Safefree" 8 .IX Xref "Safefree" .IX Item "Safefree" The XSUB-writer's interface to the C \f(CW\*(C`free\*(C'\fR function. .Sp This should \fB\s-1ONLY\s0\fR be used on memory obtained using \*(L"Newx\*(R" and friends. .Sp .Vb 1 \& void Safefree(void* ptr) .Ve .IP "savepv" 8 .IX Xref "savepv" .IX Item "savepv" Perl's version of \f(CW\*(C`strdup()\*(C'\fR. Returns a pointer to a newly allocated string which is a duplicate of \f(CW\*(C`pv\*(C'\fR. The size of the string is determined by \f(CW\*(C`strlen()\*(C'\fR, which means it may not contain embedded \f(CW\*(C`NUL\*(C'\fR characters and must have a trailing \f(CW\*(C`NUL\*(C'\fR. To prevent memory leaks, the memory allocated for the new string needs to be freed when no longer needed. This can be done with the "\f(CW\*(C`Safefree\*(C'\fR" function, or \&\f(CW\*(C`SAVEFREEPV\*(C'\fR. .Sp 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 \f(CW"savesharedpv"\fR. .Sp .Vb 1 \& char* savepv(const char* pv) .Ve .IP "savepvn" 8 .IX Xref "savepvn" .IX Item "savepvn" Perl's version of what \f(CW\*(C`strndup()\*(C'\fR would be if it existed. Returns a pointer to a newly allocated string which is a duplicate of the first \&\f(CW\*(C`len\*(C'\fR bytes from \f(CW\*(C`pv\*(C'\fR, plus a trailing \&\f(CW\*(C`NUL\*(C'\fR byte. The memory allocated for the new string can be freed with the \f(CW\*(C`Safefree()\*(C'\fR function. .Sp 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 \f(CW"savesharedpvn"\fR. .Sp .Vb 1 \& char* savepvn(const char* pv, Size_t len) .Ve .IP "savepvs" 8 .IX Xref "savepvs" .IX Item "savepvs" Like \f(CW\*(C`savepvn\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& char* savepvs("literal string") .Ve .IP "savesharedpv" 8 .IX Xref "savesharedpv" .IX Item "savesharedpv" A version of \f(CW\*(C`savepv()\*(C'\fR which allocates the duplicate string in memory which is shared between threads. .Sp .Vb 1 \& char* savesharedpv(const char* pv) .Ve .IP "savesharedpvn" 8 .IX Xref "savesharedpvn" .IX Item "savesharedpvn" A version of \f(CW\*(C`savepvn()\*(C'\fR which allocates the duplicate string in memory which is shared between threads. (With the specific difference that a \f(CW\*(C`NULL\*(C'\fR pointer is not acceptable) .Sp .Vb 2 \& char* savesharedpvn(const char *const pv, \& const STRLEN len) .Ve .IP "savesharedpvs" 8 .IX Xref "savesharedpvs" .IX Item "savesharedpvs" A version of \f(CW\*(C`savepvs()\*(C'\fR which allocates the duplicate string in memory which is shared between threads. .Sp .Vb 1 \& char* savesharedpvs("literal string") .Ve .IP "savesharedsvpv" 8 .IX Xref "savesharedsvpv" .IX Item "savesharedsvpv" A version of \f(CW\*(C`savesharedpv()\*(C'\fR which allocates the duplicate string in memory which is shared between threads. .Sp .Vb 1 \& char* savesharedsvpv(SV *sv) .Ve .IP "savesvpv" 8 .IX Xref "savesvpv" .IX Item "savesvpv" A version of \f(CW\*(C`savepv()\*(C'\fR/\f(CW\*(C`savepvn()\*(C'\fR which gets the string to duplicate from the passed in \s-1SV\s0 using \f(CW\*(C`SvPV()\*(C'\fR .Sp 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 \f(CW"savesharedsvpv"\fR. .Sp .Vb 1 \& char* savesvpv(SV* sv) .Ve .IP "StructCopy" 8 .IX Xref "StructCopy" .IX Item "StructCopy" This is an architecture-independent macro to copy one structure to another. .Sp .Vb 1 \& void StructCopy(type *src, type *dest, type) .Ve .IP "Zero" 8 .IX Xref "Zero" .IX Item "Zero" The XSUB-writer's interface to the C \f(CW\*(C`memzero\*(C'\fR function. The \f(CW\*(C`dest\*(C'\fR is the destination, \f(CW\*(C`nitems\*(C'\fR is the number of items, and \f(CW\*(C`type\*(C'\fR is the type. .Sp .Vb 1 \& void Zero(void* dest, int nitems, type) .Ve .IP "ZeroD" 8 .IX Xref "ZeroD" .IX Item "ZeroD" Like \f(CW\*(C`Zero\*(C'\fR but returns dest. Useful for encouraging compilers to tail-call optimise. .Sp .Vb 1 \& void * ZeroD(void* dest, int nitems, type) .Ve .SH "Miscellaneous Functions" .IX Header "Miscellaneous Functions" .IP "dump_c_backtrace" 8 .IX Xref "dump_c_backtrace" .IX Item "dump_c_backtrace" Dumps the C backtrace to the given \f(CW\*(C`fp\*(C'\fR. .Sp Returns true if a backtrace could be retrieved, false if not. .Sp .Vb 2 \& bool dump_c_backtrace(PerlIO* fp, int max_depth, \& int skip) .Ve .IP "fbm_compile" 8 .IX Xref "fbm_compile" .IX Item "fbm_compile" Analyzes the string in order to make fast searches on it using \f(CW\*(C`fbm_instr()\*(C'\fR \&\*(-- the Boyer-Moore algorithm. .Sp .Vb 1 \& void fbm_compile(SV* sv, U32 flags) .Ve .IP "fbm_instr" 8 .IX Xref "fbm_instr" .IX Item "fbm_instr" Returns the location of the \s-1SV\s0 in the string delimited by \f(CW\*(C`big\*(C'\fR and \&\f(CW\*(C`bigend\*(C'\fR (\f(CW\*(C`bigend\*(C'\fR) is the char following the last char). It returns \f(CW\*(C`NULL\*(C'\fR if the string can't be found. The \f(CW\*(C`sv\*(C'\fR does not have to be \f(CW\*(C`fbm_compiled\*(C'\fR, but the search will not be as fast then. .Sp .Vb 3 \& char* fbm_instr(unsigned char* big, \& unsigned char* bigend, SV* littlestr, \& U32 flags) .Ve .IP "foldEQ" 8 .IX Xref "foldEQ" .IX Item "foldEQ" Returns true if the leading \f(CW\*(C`len\*(C'\fR bytes of the strings \f(CW\*(C`s1\*(C'\fR and \f(CW\*(C`s2\*(C'\fR are the same case-insensitively; false otherwise. Uppercase and lowercase \s-1ASCII\s0 range bytes match themselves and their opposite case counterparts. Non-cased and non-ASCII range bytes match only themselves. .Sp .Vb 1 \& I32 foldEQ(const char* a, const char* b, I32 len) .Ve .IP "foldEQ_locale" 8 .IX Xref "foldEQ_locale" .IX Item "foldEQ_locale" Returns true if the leading \f(CW\*(C`len\*(C'\fR bytes of the strings \f(CW\*(C`s1\*(C'\fR and \f(CW\*(C`s2\*(C'\fR are the same case-insensitively in the current locale; false otherwise. .Sp .Vb 2 \& I32 foldEQ_locale(const char* a, const char* b, \& I32 len) .Ve .IP "form" 8 .IX Xref "form" .IX Item "form" Takes a sprintf-style format pattern and conventional (non-SV) arguments and returns the formatted string. .Sp .Vb 1 \& (char *) Perl_form(pTHX_ const char* pat, ...) .Ve .Sp can be used any place a string (char *) is required: .Sp .Vb 1 \& char * s = Perl_form("%d.%d",major,minor); .Ve .Sp 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). .Sp .Vb 1 \& char* form(const char* pat, ...) .Ve .IP "getcwd_sv" 8 .IX Xref "getcwd_sv" .IX Item "getcwd_sv" Fill \f(CW\*(C`sv\*(C'\fR with current working directory .Sp .Vb 1 \& int getcwd_sv(SV* sv) .Ve .IP "get_c_backtrace_dump" 8 .IX Xref "get_c_backtrace_dump" .IX Item "get_c_backtrace_dump" Returns a \s-1SV\s0 containing a dump of \f(CW\*(C`depth\*(C'\fR frames of the call stack, skipping the \f(CW\*(C`skip\*(C'\fR innermost ones. \f(CW\*(C`depth\*(C'\fR of 20 is usually enough. .Sp The appended output looks like: .Sp \&... 1 10e004812:0082 Perl_croak util.c:1716 /usr/bin/perl 2 10df8d6d2:1d72 perl_parse perl.c:3975 /usr/bin/perl \&... .Sp 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 \f(CW\*(C`S_parse_body\*(C'\fR, and the :offset (might be missing) tells how much inside the \f(CW\*(C`S_parse_body\*(C'\fR the program counter was. .Sp The \f(CW\*(C`util.c:1716\*(C'\fR is the source code file and line number. .Sp The \fI/usr/bin/perl\fR is obvious (hopefully). .Sp Unknowns are \f(CW"\-"\fR. 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. .Sp .Vb 1 \& SV* get_c_backtrace_dump(int max_depth, int skip) .Ve .IP "ibcmp" 8 .IX Xref "ibcmp" .IX Item "ibcmp" This is a synonym for \f(CW\*(C`(! foldEQ())\*(C'\fR .Sp .Vb 1 \& I32 ibcmp(const char* a, const char* b, I32 len) .Ve .IP "ibcmp_locale" 8 .IX Xref "ibcmp_locale" .IX Item "ibcmp_locale" This is a synonym for \f(CW\*(C`(! foldEQ_locale())\*(C'\fR .Sp .Vb 2 \& I32 ibcmp_locale(const char* a, const char* b, \& I32 len) .Ve .IP "instr" 8 .IX Xref "instr" .IX Item "instr" Same as \fBstrstr\fR\|(3), which finds and returns a pointer to the first occurrence of the NUL-terminated substring \f(CW\*(C`little\*(C'\fR in the NUL-terminated string \f(CW\*(C`big\*(C'\fR, returning \s-1NULL\s0 if not found. The terminating \s-1NUL\s0 bytes are not compared. .Sp .Vb 1 \& char* instr(const char* big, const char* little) .Ve .IP "\s-1IS_SAFE_SYSCALL\s0" 8 .IX Xref "IS_SAFE_SYSCALL" .IX Item "IS_SAFE_SYSCALL" Same as \*(L"is_safe_syscall\*(R". .Sp .Vb 3 \& bool IS_SAFE_SYSCALL(NN const char *pv, STRLEN len, \& NN const char *what, \& NN const char *op_name) .Ve .IP "is_safe_syscall" 8 .IX Xref "is_safe_syscall" .IX Item "is_safe_syscall" Test that the given \f(CW\*(C`pv\*(C'\fR (with length \f(CW\*(C`len\*(C'\fR) doesn't contain any internal \&\f(CW\*(C`NUL\*(C'\fR characters. If it does, set \f(CW\*(C`errno\*(C'\fR to \f(CW\*(C`ENOENT\*(C'\fR, optionally warn using the \f(CW\*(C`syscalls\*(C'\fR category, and return \s-1FALSE.\s0 .Sp Return \s-1TRUE\s0 if the name is safe. .Sp \&\f(CW\*(C`what\*(C'\fR and \f(CW\*(C`op_name\*(C'\fR are used in any warning. .Sp Used by the \f(CW\*(C`IS_SAFE_SYSCALL()\*(C'\fR macro. .Sp .Vb 3 \& bool is_safe_syscall(const char *pv, STRLEN len, \& const char *what, \& const char *op_name) .Ve .IP "\s-1LIKELY\s0" 8 .IX Xref "LIKELY" .IX Item "LIKELY" Returns the input unchanged, but at the same time it gives a branch prediction hint to the compiler that this condition is likely to be true. .IP "memCHRs" 8 .IX Xref "memCHRs" .IX Item "memCHRs" Returns the position of the first occurence of the byte \f(CW\*(C`c\*(C'\fR in the literal string \f(CW"list"\fR, or \s-1NULL\s0 if \f(CW\*(C`c\*(C'\fR doesn't appear in \f(CW"list"\fR. All bytes are treated as unsigned char. Thus this macro can be used to determine if \f(CW\*(C`c\*(C'\fR is in a set of particular characters. Unlike \fBstrchr\fR\|(3), it works even if \f(CW\*(C`c\*(C'\fR is \f(CW\*(C`NUL\*(C'\fR (and the set doesn't include \f(CW\*(C`NUL\*(C'\fR). .Sp .Vb 1 \& bool memCHRs("list", char c) .Ve .IP "memEQ" 8 .IX Xref "memEQ" .IX Item "memEQ" Test two buffers (which may contain embedded \f(CW\*(C`NUL\*(C'\fR characters, to see if they are equal. The \f(CW\*(C`len\*(C'\fR parameter indicates the number of bytes to compare. Returns zero if equal, or non-zero if non-equal. .Sp .Vb 1 \& bool memEQ(char* s1, char* s2, STRLEN len) .Ve .IP "memEQs" 8 .IX Xref "memEQs" .IX Item "memEQs" Like \*(L"memEQ\*(R", but the second string is a literal enclosed in double quotes, \&\f(CW\*(C`l1\*(C'\fR gives the number of bytes in \f(CW\*(C`s1\*(C'\fR. Returns zero if equal, or non-zero if non-equal. .Sp .Vb 1 \& bool memEQs(char* s1, STRLEN l1, "s2") .Ve .IP "memNE" 8 .IX Xref "memNE" .IX Item "memNE" Test two buffers (which may contain embedded \f(CW\*(C`NUL\*(C'\fR characters, to see if they are not equal. The \f(CW\*(C`len\*(C'\fR parameter indicates the number of bytes to compare. Returns zero if non-equal, or non-zero if equal. .Sp .Vb 1 \& bool memNE(char* s1, char* s2, STRLEN len) .Ve .IP "memNEs" 8 .IX Xref "memNEs" .IX Item "memNEs" Like \*(L"memNE\*(R", but the second string is a literal enclosed in double quotes, \&\f(CW\*(C`l1\*(C'\fR gives the number of bytes in \f(CW\*(C`s1\*(C'\fR. Returns zero if non-equal, or zero if non-equal. .Sp .Vb 1 \& bool memNEs(char* s1, STRLEN l1, "s2") .Ve .IP "mess" 8 .IX Xref "mess" .IX Item "mess" Take a sprintf-style format pattern and argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for \*(L"mess_sv\*(R". .Sp Normally, the resulting message is returned in a new mortal \s-1SV.\s0 During global destruction a single \s-1SV\s0 may be shared between uses of this function. .Sp .Vb 1 \& SV* mess(const char* pat, ...) .Ve .IP "mess_sv" 8 .IX Xref "mess_sv" .IX Item "mess_sv" Expands a message, intended for the user, to include an indication of the current location in the code, if the message does not already appear to be complete. .Sp \&\f(CW\*(C`basemsg\*(C'\fR 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 \f(CW\*(C`at foo.pl line 37\*(C'\fR will be appended, and possibly other clauses indicating the current state of execution. The resulting message will end with a dot and a newline. .Sp Normally, the resulting message is returned in a new mortal \s-1SV.\s0 During global destruction a single \s-1SV\s0 may be shared between uses of this function. If \f(CW\*(C`consume\*(C'\fR is true, then the function is permitted (but not required) to modify and return \f(CW\*(C`basemsg\*(C'\fR instead of allocating a new \s-1SV.\s0 .Sp .Vb 1 \& SV* mess_sv(SV* basemsg, bool consume) .Ve .IP "my_snprintf" 8 .IX Xref "my_snprintf" .IX Item "my_snprintf" The C library \f(CW\*(C`snprintf\*(C'\fR functionality, if available and standards-compliant (uses \f(CW\*(C`vsnprintf\*(C'\fR, actually). However, if the \&\f(CW\*(C`vsnprintf\*(C'\fR is not available, will unfortunately use the unsafe \&\f(CW\*(C`vsprintf\*(C'\fR which can overrun the buffer (there is an overrun check, but that may be too late). Consider using \f(CW\*(C`sv_vcatpvf\*(C'\fR instead, or getting \f(CW\*(C`vsnprintf\*(C'\fR. .Sp .Vb 2 \& int my_snprintf(char *buffer, const Size_t len, \& const char *format, ...) .Ve .IP "my_sprintf" 8 .IX Xref "my_sprintf" .IX Item "my_sprintf" \&\s-1DEPRECATED\s0! 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. .Sp Do \s-1NOT\s0 use this due to the possibility of overflowing \f(CW\*(C`buffer\*(C'\fR. Instead use \&\fBmy_snprintf()\fR .Sp .Vb 2 \& int my_sprintf(NN char *buffer, NN const char *pat, \& ...) .Ve .IP "my_strlcat" 8 .IX Xref "my_strlcat" .IX Item "my_strlcat" The C library \f(CW\*(C`strlcat\*(C'\fR if available, or a Perl implementation of it. This operates on C \f(CW\*(C`NUL\*(C'\fR\-terminated strings. .Sp \&\f(CW\*(C`my_strlcat()\*(C'\fR appends string \f(CW\*(C`src\*(C'\fR to the end of \f(CW\*(C`dst\*(C'\fR. It will append at most \f(CW\*(C`size \- strlen(dst) \- 1\*(C'\fR characters. It will then \f(CW\*(C`NUL\*(C'\fR\-terminate, unless \f(CW\*(C`size\*(C'\fR is 0 or the original \f(CW\*(C`dst\*(C'\fR string was longer than \f(CW\*(C`size\*(C'\fR (in practice this should not happen as it means that either \f(CW\*(C`size\*(C'\fR is incorrect or that \f(CW\*(C`dst\*(C'\fR is not a proper \f(CW\*(C`NUL\*(C'\fR\-terminated string). .Sp Note that \f(CW\*(C`size\*(C'\fR is the full size of the destination buffer and the result is guaranteed to be \f(CW\*(C`NUL\*(C'\fR\-terminated if there is room. Note that room for the \f(CW\*(C`NUL\*(C'\fR should be included in \f(CW\*(C`size\*(C'\fR. .Sp The return value is the total length that \f(CW\*(C`dst\*(C'\fR would have if \f(CW\*(C`size\*(C'\fR is sufficiently large. Thus it is the initial length of \f(CW\*(C`dst\*(C'\fR plus the length of \&\f(CW\*(C`src\*(C'\fR. If \f(CW\*(C`size\*(C'\fR is smaller than the return, the excess was not appended. .Sp .Vb 2 \& Size_t my_strlcat(char *dst, const char *src, \& Size_t size) .Ve .IP "my_strlcpy" 8 .IX Xref "my_strlcpy" .IX Item "my_strlcpy" The C library \f(CW\*(C`strlcpy\*(C'\fR if available, or a Perl implementation of it. This operates on C \f(CW\*(C`NUL\*(C'\fR\-terminated strings. .Sp \&\f(CW\*(C`my_strlcpy()\*(C'\fR copies up to \f(CW\*(C`size \- 1\*(C'\fR characters from the string \f(CW\*(C`src\*(C'\fR to \f(CW\*(C`dst\*(C'\fR, \f(CW\*(C`NUL\*(C'\fR\-terminating the result if \f(CW\*(C`size\*(C'\fR is not 0. .Sp The return value is the total length \f(CW\*(C`src\*(C'\fR would be if the copy completely succeeded. If it is larger than \f(CW\*(C`size\*(C'\fR, the excess was not copied. .Sp .Vb 2 \& Size_t my_strlcpy(char *dst, const char *src, \& Size_t size) .Ve .IP "my_strnlen" 8 .IX Xref "my_strnlen" .IX Item "my_strnlen" The C library \f(CW\*(C`strnlen\*(C'\fR if available, or a Perl implementation of it. .Sp \&\f(CW\*(C`my_strnlen()\*(C'\fR computes the length of the string, up to \f(CW\*(C`maxlen\*(C'\fR characters. It will never attempt to address more than \f(CW\*(C`maxlen\*(C'\fR characters, making it suitable for use with strings that are not guaranteed to be NUL-terminated. .Sp .Vb 1 \& Size_t my_strnlen(const char *str, Size_t maxlen) .Ve .IP "my_vsnprintf" 8 .IX Xref "my_vsnprintf" .IX Item "my_vsnprintf" The C library \f(CW\*(C`vsnprintf\*(C'\fR if available and standards-compliant. However, if the \f(CW\*(C`vsnprintf\*(C'\fR is not available, will unfortunately use the unsafe \f(CW\*(C`vsprintf\*(C'\fR which can overrun the buffer (there is an overrun check, but that may be too late). Consider using \&\f(CW\*(C`sv_vcatpvf\*(C'\fR instead, or getting \f(CW\*(C`vsnprintf\*(C'\fR. .Sp .Vb 2 \& int my_vsnprintf(char *buffer, const Size_t len, \& const char *format, va_list ap) .Ve .IP "ninstr" 8 .IX Xref "ninstr" .IX Item "ninstr" Find the first (leftmost) occurrence of a sequence of bytes within another sequence. This is the Perl version of \f(CW\*(C`strstr()\*(C'\fR, extended to handle arbitrary sequences, potentially containing embedded \f(CW\*(C`NUL\*(C'\fR characters (\f(CW\*(C`NUL\*(C'\fR is what the initial \f(CW\*(C`n\*(C'\fR in the function name stands for; some systems have an equivalent, \f(CW\*(C`memmem()\*(C'\fR, but with a somewhat different \s-1API\s0). .Sp Another way of thinking about this function is finding a needle in a haystack. \&\f(CW\*(C`big\*(C'\fR points to the first byte in the haystack. \f(CW\*(C`big_end\*(C'\fR points to one byte beyond the final byte in the haystack. \f(CW\*(C`little\*(C'\fR points to the first byte in the needle. \f(CW\*(C`little_end\*(C'\fR points to one byte beyond the final byte in the needle. All the parameters must be non\-\f(CW\*(C`NULL\*(C'\fR. .Sp The function returns \f(CW\*(C`NULL\*(C'\fR if there is no occurrence of \f(CW\*(C`little\*(C'\fR within \&\f(CW\*(C`big\*(C'\fR. If \f(CW\*(C`little\*(C'\fR is the empty string, \f(CW\*(C`big\*(C'\fR is returned. .Sp Because this function operates at the byte level, and because of the inherent characteristics of \s-1UTF\-8\s0 (or UTF-EBCDIC), it will work properly if both the needle and the haystack are strings with the same UTF\-8ness, but not if the UTF\-8ness differs. .Sp .Vb 2 \& char* ninstr(const char* big, const char* bigend, \& const char* little, const char* lend) .Ve .IP "\s-1PERL_SYS_INIT\s0" 8 .IX Xref "PERL_SYS_INIT" .IX Item "PERL_SYS_INIT" 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. .Sp .Vb 1 \& void PERL_SYS_INIT(int *argc, char*** argv) .Ve .IP "\s-1PERL_SYS_INIT3\s0" 8 .IX Xref "PERL_SYS_INIT3" .IX Item "PERL_SYS_INIT3" 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. .Sp .Vb 2 \& void PERL_SYS_INIT3(int *argc, char*** argv, \& char*** env) .Ve .IP "\s-1PERL_SYS_TERM\s0" 8 .IX Xref "PERL_SYS_TERM" .IX Item "PERL_SYS_TERM" 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. .Sp .Vb 1 \& void PERL_SYS_TERM() .Ve .IP "\s-1READ_XDIGIT\s0" 8 .IX Xref "READ_XDIGIT" .IX Item "READ_XDIGIT" Returns the value of an ASCII-range hex digit and advances the string pointer. Behaviour is only well defined when isXDIGIT(*str) is true. .Sp .Vb 1 \& U8 READ_XDIGIT(char str*) .Ve .IP "rninstr" 8 .IX Xref "rninstr" .IX Item "rninstr" Like \f(CW"ninstr"\fR, but instead finds the final (rightmost) occurrence of a sequence of bytes within another sequence, returning \f(CW\*(C`NULL\*(C'\fR if there is no such occurrence. .Sp .Vb 2 \& char* rninstr(const char* big, const char* bigend, \& const char* little, const char* lend) .Ve .IP "\s-1STMT_START\s0" 8 .IX Xref "STMT_START" .IX Item "STMT_START" .Vb 1 \& STMT_START { statements; } STMT_END; .Ve .Sp can be used as a single statement, as in .Sp .Vb 1 \& if (x) STMT_START { ... } STMT_END; else ... .Ve .Sp These are often used in macro definitions. Note that you can't return a value out of them. .IP "strEQ" 8 .IX Xref "strEQ" .IX Item "strEQ" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if they are equal. Returns true or false. .Sp .Vb 1 \& bool strEQ(char* s1, char* s2) .Ve .IP "strGE" 8 .IX Xref "strGE" .IX Item "strGE" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if the first, \f(CW\*(C`s1\*(C'\fR, is greater than or equal to the second, \f(CW\*(C`s2\*(C'\fR. Returns true or false. .Sp .Vb 1 \& bool strGE(char* s1, char* s2) .Ve .IP "strGT" 8 .IX Xref "strGT" .IX Item "strGT" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if the first, \f(CW\*(C`s1\*(C'\fR, is greater than the second, \f(CW\*(C`s2\*(C'\fR. Returns true or false. .Sp .Vb 1 \& bool strGT(char* s1, char* s2) .Ve .IP "strLE" 8 .IX Xref "strLE" .IX Item "strLE" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if the first, \f(CW\*(C`s1\*(C'\fR, is less than or equal to the second, \f(CW\*(C`s2\*(C'\fR. Returns true or false. .Sp .Vb 1 \& bool strLE(char* s1, char* s2) .Ve .IP "strLT" 8 .IX Xref "strLT" .IX Item "strLT" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if the first, \f(CW\*(C`s1\*(C'\fR, is less than the second, \f(CW\*(C`s2\*(C'\fR. Returns true or false. .Sp .Vb 1 \& bool strLT(char* s1, char* s2) .Ve .IP "strNE" 8 .IX Xref "strNE" .IX Item "strNE" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if they are different. Returns true or false. .Sp .Vb 1 \& bool strNE(char* s1, char* s2) .Ve .IP "strnEQ" 8 .IX Xref "strnEQ" .IX Item "strnEQ" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if they are equal. The \f(CW\*(C`len\*(C'\fR parameter indicates the number of bytes to compare. Returns true or false. (A wrapper for \f(CW\*(C`strncmp\*(C'\fR). .Sp .Vb 1 \& bool strnEQ(char* s1, char* s2, STRLEN len) .Ve .IP "strnNE" 8 .IX Xref "strnNE" .IX Item "strnNE" Test two \f(CW\*(C`NUL\*(C'\fR\-terminated strings to see if they are different. The \f(CW\*(C`len\*(C'\fR parameter indicates the number of bytes to compare. Returns true or false. (A wrapper for \f(CW\*(C`strncmp\*(C'\fR). .Sp .Vb 1 \& bool strnNE(char* s1, char* s2, STRLEN len) .Ve .IP "sv_destroyable" 8 .IX Xref "sv_destroyable" .IX Item "sv_destroyable" Dummy routine which reports that object can be destroyed when there is no sharing module present. It ignores its single \s-1SV\s0 argument, and returns \&'true'. Exists to avoid test for a \f(CW\*(C`NULL\*(C'\fR function pointer and because it could potentially warn under some level of strict-ness. .Sp .Vb 1 \& bool sv_destroyable(SV *sv) .Ve .IP "sv_nosharing" 8 .IX Xref "sv_nosharing" .IX Item "sv_nosharing" Dummy routine which \*(L"shares\*(R" an \s-1SV\s0 when there is no sharing module present. Or \*(L"locks\*(R" it. Or \*(L"unlocks\*(R" it. In other words, ignores its single \s-1SV\s0 argument. Exists to avoid test for a \f(CW\*(C`NULL\*(C'\fR function pointer and because it could potentially warn under some level of strict-ness. .Sp .Vb 1 \& void sv_nosharing(SV *sv) .Ve .IP "\s-1UNLIKELY\s0" 8 .IX Xref "UNLIKELY" .IX Item "UNLIKELY" Returns the input unchanged, but at the same time it gives a branch prediction hint to the compiler that this condition is likely to be false. .IP "vmess" 8 .IX Xref "vmess" .IX Item "vmess" \&\f(CW\*(C`pat\*(C'\fR and \f(CW\*(C`args\*(C'\fR are a sprintf-style format pattern and encapsulated argument list, respectively. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for \&\*(L"mess_sv\*(R". .Sp Normally, the resulting message is returned in a new mortal \s-1SV.\s0 During global destruction a single \s-1SV\s0 may be shared between uses of this function. .Sp .Vb 1 \& SV* vmess(const char* pat, va_list* args) .Ve .SH "MRO Functions" .IX Header "MRO Functions" These functions are related to the method resolution order of perl classes Also see perlmroapi. .IP "mro_get_linear_isa" 8 .IX Xref "mro_get_linear_isa" .IX Item "mro_get_linear_isa" Returns the mro linearisation for the given stash. By default, this will be whatever \f(CW\*(C`mro_get_linear_isa_dfs\*(C'\fR returns unless some other \s-1MRO\s0 is in effect for the stash. The return value is a read-only AV*. .Sp You are responsible for \f(CW\*(C`SvREFCNT_inc()\*(C'\fR 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). .Sp .Vb 1 \& AV* mro_get_linear_isa(HV* stash) .Ve .IP "mro_method_changed_in" 8 .IX Xref "mro_method_changed_in" .IX Item "mro_method_changed_in" Invalidates method caching on any child classes of the given stash, so that they might notice the changes in this one. .Sp Ideally, all instances of \f(CW\*(C`PL_sub_generation++\*(C'\fR in perl source outside of \fImro.c\fR should be replaced by calls to this. .Sp 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: .Sp 1) Directly manipulating the stash \s-1HV\s0 entries from \&\s-1XS\s0 code. .Sp 2) Assigning a reference to a readonly scalar constant into a stash entry in order to create a constant subroutine (like \fIconstant.pm\fR does). .Sp This same method is available from pure perl via, \f(CW\*(C`mro::method_changed_in(classname)\*(C'\fR. .Sp .Vb 1 \& void mro_method_changed_in(HV* stash) .Ve .IP "mro_register" 8 .IX Xref "mro_register" .IX Item "mro_register" Registers a custom mro plugin. See perlmroapi for details on this and other mro functions. .Sp \&\s-1NOTE:\s0 this function must be explicitly called as Perl_mro_register with an aTHX_ parameter. .Sp .Vb 2 \& void Perl_mro_register(pTHX_ \& const struct mro_alg *mro) .Ve .SH "Multicall Functions" .IX Header "Multicall Functions" .IP "dMULTICALL" 8 .IX Xref "dMULTICALL" .IX Item "dMULTICALL" Declare local variables for a multicall. See \*(L"\s-1LIGHTWEIGHT CALLBACKS\*(R"\s0 in perlcall. .Sp .Vb 1 \& dMULTICALL; .Ve .IP "\s-1MULTICALL\s0" 8 .IX Xref "MULTICALL" .IX Item "MULTICALL" Make a lightweight callback. See \*(L"\s-1LIGHTWEIGHT CALLBACKS\*(R"\s0 in perlcall. .Sp .Vb 1 \& MULTICALL; .Ve .IP "\s-1POP_MULTICALL\s0" 8 .IX Xref "POP_MULTICALL" .IX Item "POP_MULTICALL" Closing bracket for a lightweight callback. See \*(L"\s-1LIGHTWEIGHT CALLBACKS\*(R"\s0 in perlcall. .Sp .Vb 1 \& POP_MULTICALL; .Ve .IP "\s-1PUSH_MULTICALL\s0" 8 .IX Xref "PUSH_MULTICALL" .IX Item "PUSH_MULTICALL" Opening bracket for a lightweight callback. See \*(L"\s-1LIGHTWEIGHT CALLBACKS\*(R"\s0 in perlcall. .Sp .Vb 1 \& PUSH_MULTICALL(CV* the_cv); .Ve .SH "Numeric functions" .IX Header "Numeric functions" .IP "grok_bin" 8 .IX Xref "grok_bin" .IX Item "grok_bin" converts a string representing a binary number to numeric form. .Sp On entry \f(CW\*(C`start\*(C'\fR and \f(CW*len_p\fR give the string to scan, \f(CW*flags\fR gives conversion flags, and \f(CW\*(C`result\*(C'\fR should be \f(CW\*(C`NULL\*(C'\fR or a pointer to an \s-1NV.\s0 The scan stops at the end of the string, or at just before the first invalid character. Unless \f(CW\*(C`PERL_SCAN_SILENT_ILLDIGIT\*(C'\fR is set in \f(CW*flags\fR, encountering an invalid character (except \s-1NUL\s0) will also trigger a warning. On return \f(CW*len_p\fR is set to the length of the scanned string, and \f(CW*flags\fR gives output flags. .Sp If the value is <= \f(CW\*(C`UV_MAX\*(C'\fR it is returned as a \s-1UV,\s0 the output flags are clear, and nothing is written to \f(CW*result\fR. If the value is > \f(CW\*(C`UV_MAX\*(C'\fR, \f(CW\*(C`grok_bin\*(C'\fR returns \f(CW\*(C`UV_MAX\*(C'\fR, sets \f(CW\*(C`PERL_SCAN_GREATER_THAN_UV_MAX\*(C'\fR in the output flags, and writes an approximation of the correct value into \f(CW*result\fR (which is an \&\s-1NV\s0; or the approximation is discarded if \f(CW\*(C`result\*(C'\fR is \s-1NULL\s0). .Sp The binary number may optionally be prefixed with \f(CW"0b"\fR or \f(CW"b"\fR unless \&\f(CW\*(C`PERL_SCAN_DISALLOW_PREFIX\*(C'\fR is set in \f(CW*flags\fR on entry. .Sp If \f(CW\*(C`PERL_SCAN_ALLOW_UNDERSCORES\*(C'\fR is set in \f(CW*flags\fR then any or all pairs of digits may be separated from each other by a single underscore; also a single leading underscore is accepted. .Sp .Vb 2 \& UV grok_bin(const char* start, STRLEN* len_p, \& I32* flags, NV *result) .Ve .IP "grok_hex" 8 .IX Xref "grok_hex" .IX Item "grok_hex" converts a string representing a hex number to numeric form. .Sp On entry \f(CW\*(C`start\*(C'\fR and \f(CW*len_p\fR give the string to scan, \f(CW*flags\fR gives conversion flags, and \f(CW\*(C`result\*(C'\fR should be \f(CW\*(C`NULL\*(C'\fR or a pointer to an \s-1NV.\s0 The scan stops at the end of the string, or at just before the first invalid character. Unless \f(CW\*(C`PERL_SCAN_SILENT_ILLDIGIT\*(C'\fR is set in \f(CW*flags\fR, encountering an invalid character (except \s-1NUL\s0) will also trigger a warning. On return \f(CW*len_p\fR is set to the length of the scanned string, and \f(CW*flags\fR gives output flags. .Sp If the value is <= \f(CW\*(C`UV_MAX\*(C'\fR it is returned as a \s-1UV,\s0 the output flags are clear, and nothing is written to \f(CW*result\fR. If the value is > \f(CW\*(C`UV_MAX\*(C'\fR, \f(CW\*(C`grok_hex\*(C'\fR returns \f(CW\*(C`UV_MAX\*(C'\fR, sets \f(CW\*(C`PERL_SCAN_GREATER_THAN_UV_MAX\*(C'\fR in the output flags, and writes an approximation of the correct value into \f(CW*result\fR (which is an \&\s-1NV\s0; or the approximation is discarded if \f(CW\*(C`result\*(C'\fR is \s-1NULL\s0). .Sp The hex number may optionally be prefixed with \f(CW"0x"\fR or \f(CW"x"\fR unless \&\f(CW\*(C`PERL_SCAN_DISALLOW_PREFIX\*(C'\fR is set in \f(CW*flags\fR on entry. .Sp If \f(CW\*(C`PERL_SCAN_ALLOW_UNDERSCORES\*(C'\fR is set in \f(CW*flags\fR then any or all pairs of digits may be separated from each other by a single underscore; also a single leading underscore is accepted. .Sp .Vb 2 \& UV grok_hex(const char* start, STRLEN* len_p, \& I32* flags, NV *result) .Ve .IP "grok_infnan" 8 .IX Xref "grok_infnan" .IX Item "grok_infnan" Helper for \f(CW\*(C`grok_number()\*(C'\fR, accepts various ways of spelling \*(L"infinity\*(R" or \*(L"not a number\*(R", and returns one of the following flag combinations: .Sp .Vb 5 \& IS_NUMBER_INFINITY \& IS_NUMBER_NAN \& IS_NUMBER_INFINITY | IS_NUMBER_NEG \& IS_NUMBER_NAN | IS_NUMBER_NEG \& 0 .Ve .Sp possibly |\-ed with \f(CW\*(C`IS_NUMBER_TRAILING\*(C'\fR. .Sp If an infinity or a not-a-number is recognized, \f(CW*sp\fR will point to one byte past the end of the recognized string. If the recognition fails, zero is returned, and \f(CW*sp\fR will not move. .Sp .Vb 1 \& int grok_infnan(const char** sp, const char *send) .Ve .IP "grok_number" 8 .IX Xref "grok_number" .IX Item "grok_number" Identical to \f(CW\*(C`grok_number_flags()\*(C'\fR with \f(CW\*(C`flags\*(C'\fR set to zero. .Sp .Vb 2 \& int grok_number(const char *pv, STRLEN len, \& UV *valuep) .Ve .IP "grok_number_flags" 8 .IX Xref "grok_number_flags" .IX Item "grok_number_flags" Recognise (or not) a number. The type of the number is returned (0 if unrecognised), otherwise it is a bit-ORed combination of \&\f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR, \f(CW\*(C`IS_NUMBER_GREATER_THAN_UV_MAX\*(C'\fR, \f(CW\*(C`IS_NUMBER_NOT_INT\*(C'\fR, \&\f(CW\*(C`IS_NUMBER_NEG\*(C'\fR, \f(CW\*(C`IS_NUMBER_INFINITY\*(C'\fR, \f(CW\*(C`IS_NUMBER_NAN\*(C'\fR (defined in perl.h). .Sp If the value of the number can fit in a \s-1UV,\s0 it is returned in \f(CW*valuep\fR. \&\f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR will be set to indicate that \f(CW*valuep\fR is valid, \f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR will never be set unless \f(CW*valuep\fR is valid, but \f(CW*valuep\fR may have been assigned to during processing even though \f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR is not set on return. If \f(CW\*(C`valuep\*(C'\fR is \f(CW\*(C`NULL\*(C'\fR, \f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR will be set for the same cases as when \&\f(CW\*(C`valuep\*(C'\fR is non\-\f(CW\*(C`NULL\*(C'\fR, but no actual assignment (or \s-1SEGV\s0) will occur. .Sp \&\f(CW\*(C`IS_NUMBER_NOT_INT\*(C'\fR will be set with \f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR if trailing decimals were seen (in which case \f(CW*valuep\fR gives the true value truncated to an integer), and \&\f(CW\*(C`IS_NUMBER_NEG\*(C'\fR if the number is negative (in which case \f(CW*valuep\fR holds the absolute value). \f(CW\*(C`IS_NUMBER_IN_UV\*(C'\fR is not set if e notation was used or the number is larger than a \s-1UV.\s0 .Sp \&\f(CW\*(C`flags\*(C'\fR allows only \f(CW\*(C`PERL_SCAN_TRAILING\*(C'\fR, which allows for trailing non-numeric text on an otherwise successful \fIgrok\fR, setting \&\f(CW\*(C`IS_NUMBER_TRAILING\*(C'\fR on the result. .Sp .Vb 2 \& int grok_number_flags(const char *pv, STRLEN len, \& UV *valuep, U32 flags) .Ve .IP "\s-1GROK_NUMERIC_RADIX\s0" 8 .IX Xref "GROK_NUMERIC_RADIX" .IX Item "GROK_NUMERIC_RADIX" A synonym for \*(L"grok_numeric_radix\*(R" .Sp .Vb 2 \& bool GROK_NUMERIC_RADIX(NN const char **sp, \& NN const char *send) .Ve .IP "grok_numeric_radix" 8 .IX Xref "grok_numeric_radix" .IX Item "grok_numeric_radix" Scan and skip for a numeric decimal separator (radix). .Sp .Vb 2 \& bool grok_numeric_radix(const char **sp, \& const char *send) .Ve .IP "grok_oct" 8 .IX Xref "grok_oct" .IX Item "grok_oct" converts a string representing an octal number to numeric form. .Sp On entry \f(CW\*(C`start\*(C'\fR and \f(CW*len_p\fR give the string to scan, \f(CW*flags\fR gives conversion flags, and \f(CW\*(C`result\*(C'\fR should be \f(CW\*(C`NULL\*(C'\fR or a pointer to an \s-1NV.\s0 The scan stops at the end of the string, or at just before the first invalid character. Unless \f(CW\*(C`PERL_SCAN_SILENT_ILLDIGIT\*(C'\fR is set in \f(CW*flags\fR, encountering an invalid character (except \s-1NUL\s0) will also trigger a warning. On return \f(CW*len_p\fR is set to the length of the scanned string, and \f(CW*flags\fR gives output flags. .Sp If the value is <= \f(CW\*(C`UV_MAX\*(C'\fR it is returned as a \s-1UV,\s0 the output flags are clear, and nothing is written to \f(CW*result\fR. If the value is > \f(CW\*(C`UV_MAX\*(C'\fR, \f(CW\*(C`grok_oct\*(C'\fR returns \f(CW\*(C`UV_MAX\*(C'\fR, sets \f(CW\*(C`PERL_SCAN_GREATER_THAN_UV_MAX\*(C'\fR in the output flags, and writes an approximation of the correct value into \f(CW*result\fR (which is an \&\s-1NV\s0; or the approximation is discarded if \f(CW\*(C`result\*(C'\fR is \s-1NULL\s0). .Sp If \f(CW\*(C`PERL_SCAN_ALLOW_UNDERSCORES\*(C'\fR is set in \f(CW*flags\fR then any or all pairs of digits may be separated from each other by a single underscore; also a single leading underscore is accepted. .Sp The \f(CW\*(C`PERL_SCAN_DISALLOW_PREFIX\*(C'\fR flag is always treated as being set for this function. .Sp .Vb 2 \& UV grok_oct(const char* start, STRLEN* len_p, \& I32* flags, NV *result) .Ve .IP "isinfnan" 8 .IX Xref "isinfnan" .IX Item "isinfnan" \&\f(CW\*(C`Perl_isinfnan()\*(C'\fR is a utility function that returns true if the \s-1NV\s0 argument is either an infinity or a \f(CW\*(C`NaN\*(C'\fR, false otherwise. To test in more detail, use \f(CW\*(C`Perl_isinf()\*(C'\fR and \f(CW\*(C`Perl_isnan()\*(C'\fR. .Sp This is also the logical inverse of \fBPerl_isfinite()\fR. .Sp .Vb 1 \& bool isinfnan(NV nv) .Ve .IP "\s-1IS_NUMBER_GREATER_THAN_UV_MAX\s0 bool \s-1IS_NUMBER_GREATER_THAN_UV_MAX\s0" 8 .IX Xref "IS_NUMBER_GREATER_THAN_UV_MAX" .IX Item "IS_NUMBER_GREATER_THAN_UV_MAX bool IS_NUMBER_GREATER_THAN_UV_MAX" .PD 0 .IP "\s-1IS_NUMBER_INFINITY\s0 bool \s-1IS_NUMBER_INFINITY\s0" 8 .IX Xref "IS_NUMBER_INFINITY" .IX Item "IS_NUMBER_INFINITY bool IS_NUMBER_INFINITY" .IP "\s-1IS_NUMBER_IN_UV\s0 bool \s-1IS_NUMBER_IN_UV\s0" 8 .IX Xref "IS_NUMBER_IN_UV" .IX Item "IS_NUMBER_IN_UV bool IS_NUMBER_IN_UV" .IP "\s-1IS_NUMBER_NAN\s0 bool \s-1IS_NUMBER_NAN\s0" 8 .IX Xref "IS_NUMBER_NAN" .IX Item "IS_NUMBER_NAN bool IS_NUMBER_NAN" .IP "\s-1IS_NUMBER_NEG\s0 bool \s-1IS_NUMBER_NEG\s0" 8 .IX Xref "IS_NUMBER_NEG" .IX Item "IS_NUMBER_NEG bool IS_NUMBER_NEG" .IP "\s-1IS_NUMBER_NOT_INT\s0" 8 .IX Xref "IS_NUMBER_NOT_INT" .IX Item "IS_NUMBER_NOT_INT" .PD .Vb 1 \& bool IS_NUMBER_NOT_INT .Ve .IP "my_strtod" 8 .IX Xref "my_strtod" .IX Item "my_strtod" This function is equivalent to the libc \fBstrtod()\fR function, and is available even on platforms that lack plain \fBstrtod()\fR. Its return value is the best available precision depending on platform capabilities and \fIConfigure\fR options. .Sp It properly handles the locale radix character, meaning it expects a dot except when called from within the scope of \f(CW\*(C`use locale\*(C'\fR, in which case the radix character should be that specified by the current locale. .Sp The synonym \fBStrtod()\fR may be used instead. .Sp .Vb 1 \& NV my_strtod(const char * const s, char ** e) .Ve .IP "\s-1PERL_ABS\s0" 8 .IX Xref "PERL_ABS" .IX Item "PERL_ABS" Typeless \f(CW\*(C`abs\*(C'\fR or \f(CW\*(C`fabs\*(C'\fR, \fIetc\fR. (The usage below indicates it is for integers, but it works for any type.) Use instead of these, since the C library ones force their argument to be what it is expecting, potentially leading to disaster. But also beware that this evaluates its argument twice, so no \f(CW\*(C`x++\*(C'\fR. .Sp .Vb 1 \& int PERL_ABS(int) .Ve .IP "\s-1PERL_INT_MAX\s0" 8 .IX Xref "PERL_INT_MAX" .IX Item "PERL_INT_MAX" This and \&\f(CW\*(C`PERL_INT_MIN\*(C'\fR, \&\f(CW\*(C`PERL_LONG_MAX\*(C'\fR, \&\f(CW\*(C`PERL_LONG_MIN\*(C'\fR, \&\f(CW\*(C`PERL_QUAD_MAX\*(C'\fR, \&\f(CW\*(C`PERL_SHORT_MAX\*(C'\fR, \&\f(CW\*(C`PERL_SHORT_MIN\*(C'\fR, \&\f(CW\*(C`PERL_UCHAR_MAX\*(C'\fR, \&\f(CW\*(C`PERL_UCHAR_MIN\*(C'\fR, \&\f(CW\*(C`PERL_UINT_MAX\*(C'\fR, \&\f(CW\*(C`PERL_ULONG_MAX\*(C'\fR, \&\f(CW\*(C`PERL_ULONG_MIN\*(C'\fR, \&\f(CW\*(C`PERL_UQUAD_MAX\*(C'\fR, \&\f(CW\*(C`PERL_UQUAD_MIN\*(C'\fR, \&\f(CW\*(C`PERL_USHORT_MAX\*(C'\fR, \&\f(CW\*(C`PERL_USHORT_MIN\*(C'\fR, \&\f(CW\*(C`PERL_QUAD_MIN\*(C'\fR give the largest and smallest number representable in the current platform in variables of the corresponding types. .Sp For signed types, the smallest representable number is the most negative number, the one furthest away from zero. .Sp For C99 and later compilers, these correspond to things like \f(CW\*(C`INT_MAX\*(C'\fR, which are available to the C code. But these constants, furnished by Perl, allow code compiled on earlier compilers to portably have access to the same constants. .IP "Perl_signbit" 8 .IX Xref "Perl_signbit" .IX Item "Perl_signbit" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Return a non-zero integer if the sign bit on an \s-1NV\s0 is set, and 0 if it is not. .Sp If \fIConfigure\fR detects this system has a \f(CW\*(C`signbit()\*(C'\fR that will work with our NVs, then we just use it via the \f(CW\*(C`#define\*(C'\fR in \fIperl.h\fR. Otherwise, fall back on this implementation. The main use of this function is catching \f(CW\*(C`\-0.0\*(C'\fR. .Sp \&\f(CW\*(C`Configure\*(C'\fR notes: This function is called \f(CW\*(AqPerl_signbit\*(Aq\fR instead of a plain \f(CW\*(Aqsignbit\*(Aq\fR because it is easy to imagine a system having a \f(CW\*(C`signbit()\*(C'\fR function or macro that doesn't happen to work with our particular choice of NVs. We shouldn't just re\-\f(CW\*(C`#define\*(C'\fR \f(CW\*(C`signbit\*(C'\fR as \f(CW\*(C`Perl_signbit\*(C'\fR and expect the standard system headers to be happy. Also, this is a no-context function (no \f(CW\*(C`pTHX_\*(C'\fR) because \f(CW\*(C`Perl_signbit()\*(C'\fR is usually re\-\f(CW\*(C`#defined\*(C'\fR in \&\fIperl.h\fR as a simple macro call to the system's \f(CW\*(C`signbit()\*(C'\fR. Users should just always call \f(CW\*(C`Perl_signbit()\*(C'\fR. .Sp .Vb 1 \& int Perl_signbit(NV f) .Ve .IP "scan_bin" 8 .IX Xref "scan_bin" .IX Item "scan_bin" For backwards compatibility. Use \f(CW\*(C`grok_bin\*(C'\fR instead. .Sp .Vb 2 \& NV scan_bin(const char* start, STRLEN len, \& STRLEN* retlen) .Ve .IP "scan_hex" 8 .IX Xref "scan_hex" .IX Item "scan_hex" For backwards compatibility. Use \f(CW\*(C`grok_hex\*(C'\fR instead. .Sp .Vb 2 \& NV scan_hex(const char* start, STRLEN len, \& STRLEN* retlen) .Ve .IP "scan_oct" 8 .IX Xref "scan_oct" .IX Item "scan_oct" For backwards compatibility. Use \f(CW\*(C`grok_oct\*(C'\fR instead. .Sp .Vb 2 \& NV scan_oct(const char* start, STRLEN len, \& STRLEN* retlen) .Ve .IP "Strtod" 8 .IX Xref "Strtod" .IX Item "Strtod" This is a synonym for \*(L"my_strtod\*(R". .Sp .Vb 2 \& NV Strtod(NN const char * const s, \& NULLOK char ** e) .Ve .IP "Strtol" 8 .IX Xref "Strtol" .IX Item "Strtol" Platform and configuration independent \f(CW\*(C`strtol\*(C'\fR. This expands to the appropriate \f(CW\*(C`strotol\*(C'\fR\-like function based on the platform and \fIConfigure\fR options>. For example it could expand to \f(CW\*(C`strtoll\*(C'\fR or \f(CW\*(C`strtoq\*(C'\fR instead of \&\f(CW\*(C`strtol\*(C'\fR. .Sp .Vb 2 \& NV Strtol(NN const char * const s, \& NULLOK char ** e, int base) .Ve .IP "Strtoul" 8 .IX Xref "Strtoul" .IX Item "Strtoul" Platform and configuration independent \f(CW\*(C`strtoul\*(C'\fR. This expands to the appropriate \f(CW\*(C`strotoul\*(C'\fR\-like function based on the platform and \fIConfigure\fR options>. For example it could expand to \f(CW\*(C`strtoull\*(C'\fR or \f(CW\*(C`strtouq\*(C'\fR instead of \&\f(CW\*(C`strtoul\*(C'\fR. .Sp .Vb 2 \& NV Strtoul(NN const char * const s, \& NULLOK char ** e, int base) .Ve .SH "Obsolete backwards compatibility functions" .IX Header "Obsolete backwards compatibility functions" Some of these are also deprecated. You can exclude these from your compiled Perl by adding this option to Configure: \&\f(CW\*(C`\-Accflags=\*(Aq\-DNO_MATHOMS\*(Aq\*(C'\fR .IP "custom_op_desc" 8 .IX Xref "custom_op_desc" .IX Item "custom_op_desc" \&\s-1DEPRECATED\s0! 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. .Sp Return the description of a given custom op. This was once used by the \&\f(CW\*(C`OP_DESC\*(C'\fR macro, but is no longer: it has only been kept for compatibility, and should not be used. .Sp .Vb 1 \& const char * custom_op_desc(const OP *o) .Ve .IP "custom_op_name" 8 .IX Xref "custom_op_name" .IX Item "custom_op_name" \&\s-1DEPRECATED\s0! 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. .Sp Return the name for a given custom op. This was once used by the \f(CW\*(C`OP_NAME\*(C'\fR macro, but is no longer: it has only been kept for compatibility, and should not be used. .Sp .Vb 1 \& const char * custom_op_name(const OP *o) .Ve .IP "gv_fetchmethod" 8 .IX Xref "gv_fetchmethod" .IX Item "gv_fetchmethod" See \*(L"gv_fetchmethod_autoload\*(R". .Sp .Vb 1 \& GV* gv_fetchmethod(HV* stash, const char* name) .Ve .IP "is_utf8_char" 8 .IX Xref "is_utf8_char" .IX Item "is_utf8_char" \&\s-1DEPRECATED\s0! 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. .Sp Tests if some arbitrary number of bytes begins in a valid \s-1UTF\-8\s0 character. Note that an \s-1INVARIANT\s0 (i.e. \s-1ASCII\s0 on non-EBCDIC machines) character is a valid \s-1UTF\-8\s0 character. The actual number of bytes in the \s-1UTF\-8\s0 character will be returned if it is valid, otherwise 0. .Sp This function is deprecated due to the possibility that malformed input could cause reading beyond the end of the input buffer. Use \*(L"isUTF8_CHAR\*(R" instead. .Sp .Vb 1 \& STRLEN is_utf8_char(const U8 *s) .Ve .IP "is_utf8_char_buf" 8 .IX Xref "is_utf8_char_buf" .IX Item "is_utf8_char_buf" This is identical to the macro \*(L"isUTF8_CHAR\*(R" in perlapi. .Sp .Vb 2 \& STRLEN is_utf8_char_buf(const U8 *buf, \& const U8 *buf_end) .Ve .IP "pack_cat" 8 .IX Xref "pack_cat" .IX Item "pack_cat" The engine implementing \f(CW\*(C`pack()\*(C'\fR Perl function. Note: parameters \&\f(CW\*(C`next_in_list\*(C'\fR and \f(CW\*(C`flags\*(C'\fR are not used. This call should not be used; use \&\f(CW\*(C`packlist\*(C'\fR instead. .Sp .Vb 4 \& void pack_cat(SV *cat, const char *pat, \& const char *patend, SV **beglist, \& SV **endlist, SV ***next_in_list, \& U32 flags) .Ve .IP "pad_compname_type" 8 .IX Xref "pad_compname_type" .IX Item "pad_compname_type" Looks up the type of the lexical variable at position \f(CW\*(C`po\*(C'\fR in the currently-compiling pad. If the variable is typed, the stash of the class to which it is typed is returned. If not, \f(CW\*(C`NULL\*(C'\fR is returned. .Sp .Vb 1 \& HV* pad_compname_type(const PADOFFSET po) .Ve .IP "sv_2pvbyte_nolen" 8 .IX Xref "sv_2pvbyte_nolen" .IX Item "sv_2pvbyte_nolen" Return a pointer to the byte-encoded representation of the \s-1SV.\s0 May cause the \s-1SV\s0 to be downgraded from \s-1UTF\-8\s0 as a side-effect. .Sp Usually accessed via the \f(CW\*(C`SvPVbyte_nolen\*(C'\fR macro. .Sp .Vb 1 \& char* sv_2pvbyte_nolen(SV* sv) .Ve .IP "sv_2pvutf8_nolen" 8 .IX Xref "sv_2pvutf8_nolen" .IX Item "sv_2pvutf8_nolen" Return a pointer to the UTF\-8\-encoded representation of the \s-1SV.\s0 May cause the \s-1SV\s0 to be upgraded to \s-1UTF\-8\s0 as a side-effect. .Sp Usually accessed via the \f(CW\*(C`SvPVutf8_nolen\*(C'\fR macro. .Sp .Vb 1 \& char* sv_2pvutf8_nolen(SV* sv) .Ve .IP "sv_2pv_nolen" 8 .IX Xref "sv_2pv_nolen" .IX Item "sv_2pv_nolen" Like \f(CW\*(C`sv_2pv()\*(C'\fR, but doesn't return the length too. You should usually use the macro wrapper \f(CW\*(C`SvPV_nolen(sv)\*(C'\fR instead. .Sp .Vb 1 \& char* sv_2pv_nolen(SV* sv) .Ve .IP "sv_catpvn_mg" 8 .IX Xref "sv_catpvn_mg" .IX Item "sv_catpvn_mg" Like \f(CW\*(C`sv_catpvn\*(C'\fR, but also handles 'set' magic. .Sp .Vb 2 \& void sv_catpvn_mg(SV *sv, const char *ptr, \& STRLEN len) .Ve .IP "sv_catsv_mg" 8 .IX Xref "sv_catsv_mg" .IX Item "sv_catsv_mg" Like \f(CW\*(C`sv_catsv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_catsv_mg(SV *dsv, SV *ssv) .Ve .IP "sv_force_normal" 8 .IX Xref "sv_force_normal" .IX Item "sv_force_normal" Undo various types of fakery on an \s-1SV:\s0 if the \s-1PV\s0 is a shared string, make a private copy; if we're a ref, stop refing; if we're a glob, downgrade to an \f(CW\*(C`xpvmg\*(C'\fR. See also \f(CW"sv_force_normal_flags"\fR. .Sp .Vb 1 \& void sv_force_normal(SV *sv) .Ve .IP "sv_iv" 8 .IX Xref "sv_iv" .IX Item "sv_iv" \&\s-1DEPRECATED\s0! 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. .Sp A private implementation of the \f(CW\*(C`SvIVx\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& IV sv_iv(SV* sv) .Ve .IP "sv_nolocking" 8 .IX Xref "sv_nolocking" .IX Item "sv_nolocking" \&\s-1DEPRECATED\s0! 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. .Sp Dummy routine which \*(L"locks\*(R" an \s-1SV\s0 when there is no locking module present. Exists to avoid test for a \f(CW\*(C`NULL\*(C'\fR function pointer and because it could potentially warn under some level of strict-ness. .Sp \&\*(L"Superseded\*(R" by \f(CW\*(C`sv_nosharing()\*(C'\fR. .Sp .Vb 1 \& void sv_nolocking(SV *sv) .Ve .IP "sv_nounlocking" 8 .IX Xref "sv_nounlocking" .IX Item "sv_nounlocking" \&\s-1DEPRECATED\s0! 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. .Sp Dummy routine which \*(L"unlocks\*(R" an \s-1SV\s0 when there is no locking module present. Exists to avoid test for a \f(CW\*(C`NULL\*(C'\fR function pointer and because it could potentially warn under some level of strict-ness. .Sp \&\*(L"Superseded\*(R" by \f(CW\*(C`sv_nosharing()\*(C'\fR. .Sp .Vb 1 \& void sv_nounlocking(SV *sv) .Ve .IP "sv_nv" 8 .IX Xref "sv_nv" .IX Item "sv_nv" \&\s-1DEPRECATED\s0! 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. .Sp A private implementation of the \f(CW\*(C`SvNVx\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& NV sv_nv(SV* sv) .Ve .IP "sv_pv" 8 .IX Xref "sv_pv" .IX Item "sv_pv" Use the \f(CW\*(C`SvPV_nolen\*(C'\fR macro instead .Sp .Vb 1 \& char* sv_pv(SV *sv) .Ve .IP "sv_pvbyte" 8 .IX Xref "sv_pvbyte" .IX Item "sv_pvbyte" Use \f(CW\*(C`SvPVbyte_nolen\*(C'\fR instead. .Sp .Vb 1 \& char* sv_pvbyte(SV *sv) .Ve .IP "sv_pvbyten" 8 .IX Xref "sv_pvbyten" .IX Item "sv_pvbyten" \&\s-1DEPRECATED\s0! 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. .Sp A private implementation of the \f(CW\*(C`SvPVbyte\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& char* sv_pvbyten(SV *sv, STRLEN *lp) .Ve .IP "sv_pvn" 8 .IX Xref "sv_pvn" .IX Item "sv_pvn" \&\s-1DEPRECATED\s0! 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. .Sp A private implementation of the \f(CW\*(C`SvPV\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& char* sv_pvn(SV *sv, STRLEN *lp) .Ve .IP "sv_pvutf8" 8 .IX Xref "sv_pvutf8" .IX Item "sv_pvutf8" Use the \f(CW\*(C`SvPVutf8_nolen\*(C'\fR macro instead .Sp .Vb 1 \& char* sv_pvutf8(SV *sv) .Ve .IP "sv_pvutf8n" 8 .IX Xref "sv_pvutf8n" .IX Item "sv_pvutf8n" \&\s-1DEPRECATED\s0! 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. .Sp A private implementation of the \f(CW\*(C`SvPVutf8\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& char* sv_pvutf8n(SV *sv, STRLEN *lp) .Ve .IP "sv_taint" 8 .IX Xref "sv_taint" .IX Item "sv_taint" Taint an \s-1SV.\s0 Use \f(CW\*(C`SvTAINTED_on\*(C'\fR instead. .Sp .Vb 1 \& void sv_taint(SV* sv) .Ve .IP "sv_unref" 8 .IX Xref "sv_unref" .IX Item "sv_unref" Unsets the \s-1RV\s0 status of the \s-1SV,\s0 and decrements the reference count of whatever was being referenced by the \s-1RV.\s0 This can almost be thought of as a reversal of \f(CW\*(C`newSVrv\*(C'\fR. This is \f(CW\*(C`sv_unref_flags\*(C'\fR with the \f(CW\*(C`flag\*(C'\fR being zero. See \f(CW"SvROK_off"\fR. .Sp .Vb 1 \& void sv_unref(SV* sv) .Ve .IP "sv_usepvn" 8 .IX Xref "sv_usepvn" .IX Item "sv_usepvn" Tells an \s-1SV\s0 to use \f(CW\*(C`ptr\*(C'\fR to find its string value. Implemented by calling \f(CW\*(C`sv_usepvn_flags\*(C'\fR with \f(CW\*(C`flags\*(C'\fR of 0, hence does not handle 'set' magic. See \f(CW"sv_usepvn_flags"\fR. .Sp .Vb 1 \& void sv_usepvn(SV* sv, char* ptr, STRLEN len) .Ve .IP "sv_usepvn_mg" 8 .IX Xref "sv_usepvn_mg" .IX Item "sv_usepvn_mg" Like \f(CW\*(C`sv_usepvn\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len) .Ve .IP "sv_uv" 8 .IX Xref "sv_uv" .IX Item "sv_uv" \&\s-1DEPRECATED\s0! 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. .Sp A private implementation of the \f(CW\*(C`SvUVx\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& UV sv_uv(SV* sv) .Ve .IP "unpack_str" 8 .IX Xref "unpack_str" .IX Item "unpack_str" \&\s-1DEPRECATED\s0! 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. .Sp The engine implementing \f(CW\*(C`unpack()\*(C'\fR Perl function. Note: parameters \f(CW\*(C`strbeg\*(C'\fR, \&\f(CW\*(C`new_s\*(C'\fR and \f(CW\*(C`ocnt\*(C'\fR are not used. This call should not be used, use \&\f(CW\*(C`unpackstring\*(C'\fR instead. .Sp .Vb 4 \& SSize_t unpack_str(const char *pat, const char *patend, \& const char *s, const char *strbeg, \& const char *strend, char **new_s, \& I32 ocnt, U32 flags) .Ve .IP "utf8_to_uvchr" 8 .IX Xref "utf8_to_uvchr" .IX Item "utf8_to_uvchr" \&\s-1DEPRECATED\s0! 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. .Sp Returns the native code point of the first character in the string \f(CW\*(C`s\*(C'\fR which is assumed to be in \s-1UTF\-8\s0 encoding; \f(CW\*(C`retlen\*(C'\fR will be set to the length, in bytes, of that character. .Sp Some, but not all, \s-1UTF\-8\s0 malformations are detected, and in fact, some malformed input could cause reading beyond the end of the input buffer, which is why this function is deprecated. Use \*(L"utf8_to_uvchr_buf\*(R" instead. .Sp If \f(CW\*(C`s\*(C'\fR points to one of the detected malformations, and \s-1UTF8\s0 warnings are enabled, zero is returned and \f(CW*retlen\fR is set (if \f(CW\*(C`retlen\*(C'\fR isn't \&\f(CW\*(C`NULL\*(C'\fR) to \-1. If those warnings are off, the computed value if well-defined (or the Unicode \s-1REPLACEMENT CHARACTER,\s0 if not) is silently returned, and \f(CW*retlen\fR is set (if \f(CW\*(C`retlen\*(C'\fR isn't \s-1NULL\s0) so that (\f(CW\*(C`s\*(C'\fR + \f(CW*retlen\fR) is the next possible position in \f(CW\*(C`s\*(C'\fR that could begin a non-malformed character. See \*(L"utf8n_to_uvchr\*(R" for details on when the \s-1REPLACEMENT CHARACTER\s0 is returned. .Sp .Vb 1 \& UV utf8_to_uvchr(const U8 *s, STRLEN *retlen) .Ve .SH "Optree construction" .IX Header "Optree construction" .IP "newASSIGNOP" 8 .IX Xref "newASSIGNOP" .IX Item "newASSIGNOP" Constructs, checks, and returns an assignment op. \f(CW\*(C`left\*(C'\fR and \f(CW\*(C`right\*(C'\fR supply the parameters of the assignment; they are consumed by this function and become part of the constructed op tree. .Sp If \f(CW\*(C`optype\*(C'\fR is \f(CW\*(C`OP_ANDASSIGN\*(C'\fR, \f(CW\*(C`OP_ORASSIGN\*(C'\fR, or \f(CW\*(C`OP_DORASSIGN\*(C'\fR, then a suitable conditional optree is constructed. If \f(CW\*(C`optype\*(C'\fR is the opcode of a binary operator, such as \f(CW\*(C`OP_BIT_OR\*(C'\fR, then an op is constructed that performs the binary operation and assigns the result to the left argument. Either way, if \f(CW\*(C`optype\*(C'\fR is non-zero then \f(CW\*(C`flags\*(C'\fR has no effect. .Sp If \f(CW\*(C`optype\*(C'\fR is zero, then a plain scalar or list assignment is constructed. Which type of assignment it is is automatically determined. \&\f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically, and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 or 2 is automatically set as required. .Sp .Vb 2 \& OP* newASSIGNOP(I32 flags, OP* left, I32 optype, \& OP* right) .Ve .IP "newBINOP" 8 .IX Xref "newBINOP" .IX Item "newBINOP" Constructs, checks, and returns an op of any binary type. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically, and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 or 2 is automatically set as required. \f(CW\*(C`first\*(C'\fR and \f(CW\*(C`last\*(C'\fR 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. .Sp .Vb 2 \& OP* newBINOP(I32 type, I32 flags, OP* first, \& OP* last) .Ve .IP "newCONDOP" 8 .IX Xref "newCONDOP" .IX Item "newCONDOP" Constructs, checks, and returns a conditional-expression (\f(CW\*(C`cond_expr\*(C'\fR) op. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically, and, shifted up eight bits, the eight bits of \&\f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 is automatically set. \&\f(CW\*(C`first\*(C'\fR supplies the expression selecting between the two branches, and \f(CW\*(C`trueop\*(C'\fR and \f(CW\*(C`falseop\*(C'\fR supply the branches; they are consumed by this function and become part of the constructed op tree. .Sp .Vb 2 \& OP* newCONDOP(I32 flags, OP* first, OP* trueop, \& OP* falseop) .Ve .IP "newDEFSVOP" 8 .IX Xref "newDEFSVOP" .IX Item "newDEFSVOP" Constructs and returns an op to access \f(CW$_\fR. .Sp .Vb 1 \& OP* newDEFSVOP() .Ve .IP "newFOROP" 8 .IX Xref "newFOROP" .IX Item "newFOROP" Constructs, checks, and returns an op tree expressing a \f(CW\*(C`foreach\*(C'\fR loop (iteration through a list of values). This is a heavyweight loop, with structure that allows exiting the loop by \f(CW\*(C`last\*(C'\fR and suchlike. .Sp \&\f(CW\*(C`sv\*(C'\fR optionally supplies the variable that will be aliased to each item in turn; if null, it defaults to \f(CW$_\fR. \&\f(CW\*(C`expr\*(C'\fR supplies the list of values to iterate over. \f(CW\*(C`block\*(C'\fR supplies the main body of the loop, and \f(CW\*(C`cont\*(C'\fR optionally supplies a \f(CW\*(C`continue\*(C'\fR 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. .Sp \&\f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR for the \f(CW\*(C`leaveloop\*(C'\fR op and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR for the \f(CW\*(C`leaveloop\*(C'\fR op, except that (in both cases) some bits will be set automatically. .Sp .Vb 2 \& OP* newFOROP(I32 flags, OP* sv, OP* expr, OP* block, \& OP* cont) .Ve .IP "newGIVENOP" 8 .IX Xref "newGIVENOP" .IX Item "newGIVENOP" Constructs, checks, and returns an op tree expressing a \f(CW\*(C`given\*(C'\fR block. \&\f(CW\*(C`cond\*(C'\fR supplies the expression to whose value \f(CW$_\fR will be locally aliased, and \f(CW\*(C`block\*(C'\fR supplies the body of the \f(CW\*(C`given\*(C'\fR construct; they are consumed by this function and become part of the constructed op tree. \&\f(CW\*(C`defsv_off\*(C'\fR must be zero (it used to identity the pad slot of lexical \f(CW$_\fR). .Sp .Vb 2 \& OP* newGIVENOP(OP* cond, OP* block, \& PADOFFSET defsv_off) .Ve .IP "newGVOP" 8 .IX Xref "newGVOP" .IX Item "newGVOP" Constructs, checks, and returns an op of any type that involves an embedded reference to a \s-1GV.\s0 \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR. \f(CW\*(C`gv\*(C'\fR identifies the \s-1GV\s0 that the op should reference; calling this function does not transfer ownership of any reference to it. .Sp .Vb 1 \& OP* newGVOP(I32 type, I32 flags, GV* gv) .Ve .IP "newLISTOP" 8 .IX Xref "newLISTOP" .IX Item "newLISTOP" Constructs, checks, and returns an op of any list type. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \&\f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically if required. \f(CW\*(C`first\*(C'\fR and \f(CW\*(C`last\*(C'\fR 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. .Sp For most list operators, the check function expects all the kid ops to be present already, so calling \f(CW\*(C`newLISTOP(OP_JOIN, ...)\*(C'\fR (e.g.) is not appropriate. What you want to do in that case is create an op of type \&\f(CW\*(C`OP_LIST\*(C'\fR, append more children to it, and then call \*(L"op_convert_list\*(R". See \*(L"op_convert_list\*(R" for more information. .Sp .Vb 2 \& OP* newLISTOP(I32 type, I32 flags, OP* first, \& OP* last) .Ve .IP "newLOGOP" 8 .IX Xref "newLOGOP" .IX Item "newLOGOP" Constructs, checks, and returns a logical (flow control) op. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically, and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 is automatically set. \f(CW\*(C`first\*(C'\fR supplies the expression controlling the flow, and \f(CW\*(C`other\*(C'\fR supplies the side (alternate) chain of ops; they are consumed by this function and become part of the constructed op tree. .Sp .Vb 2 \& OP* newLOGOP(I32 optype, I32 flags, OP *first, \& OP *other) .Ve .IP "newLOOPEX" 8 .IX Xref "newLOOPEX" .IX Item "newLOOPEX" Constructs, checks, and returns a loop-exiting op (such as \f(CW\*(C`goto\*(C'\fR or \f(CW\*(C`last\*(C'\fR). \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`label\*(C'\fR supplies the parameter determining the target of the op; it is consumed by this function and becomes part of the constructed op tree. .Sp .Vb 1 \& OP* newLOOPEX(I32 type, OP* label) .Ve .IP "newLOOPOP" 8 .IX Xref "newLOOPOP" .IX Item "newLOOPOP" Constructs, checks, and returns an op tree expressing a loop. This is only a loop in the control flow through the op tree; it does not have the heavyweight loop structure that allows exiting the loop by \f(CW\*(C`last\*(C'\fR and suchlike. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR for the top-level op, except that some bits will be set automatically as required. \&\f(CW\*(C`expr\*(C'\fR supplies the expression controlling loop iteration, and \f(CW\*(C`block\*(C'\fR supplies the body of the loop; they are consumed by this function and become part of the constructed op tree. \f(CW\*(C`debuggable\*(C'\fR is currently unused and should always be 1. .Sp .Vb 2 \& OP* newLOOPOP(I32 flags, I32 debuggable, OP* expr, \& OP* block) .Ve .IP "newMETHOP" 8 .IX Xref "newMETHOP" .IX Item "newMETHOP" Constructs, checks, and returns an op of method type with a method name evaluated at runtime. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically, and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 is automatically set. \f(CW\*(C`dynamic_meth\*(C'\fR supplies an op which evaluates method name; it is consumed by this function and become part of the constructed op tree. Supported optypes: \f(CW\*(C`OP_METHOD\*(C'\fR. .Sp .Vb 1 \& OP* newMETHOP(I32 type, I32 flags, OP* dynamic_meth) .Ve .IP "newMETHOP_named" 8 .IX Xref "newMETHOP_named" .IX Item "newMETHOP_named" Constructs, checks, and returns an op of method type with a constant method name. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \&\f(CW\*(C`op_flags\*(C'\fR, and, shifted up eight bits, the eight bits of \&\f(CW\*(C`op_private\*(C'\fR. \f(CW\*(C`const_meth\*(C'\fR supplies a constant method name; it must be a shared \s-1COW\s0 string. Supported optypes: \f(CW\*(C`OP_METHOD_NAMED\*(C'\fR. .Sp .Vb 2 \& OP* newMETHOP_named(I32 type, I32 flags, \& SV* const_meth) .Ve .IP "newNULLLIST" 8 .IX Xref "newNULLLIST" .IX Item "newNULLLIST" Constructs, checks, and returns a new \f(CW\*(C`stub\*(C'\fR op, which represents an empty list expression. .Sp .Vb 1 \& OP* newNULLLIST() .Ve .IP "newOP" 8 .IX Xref "newOP" .IX Item "newOP" Constructs, checks, and returns an op of any base type (any type that has no extra fields). \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR. .Sp .Vb 1 \& OP* newOP(I32 optype, I32 flags) .Ve .IP "newPADOP" 8 .IX Xref "newPADOP" .IX Item "newPADOP" Constructs, checks, and returns an op of any type that involves a reference to a pad element. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR. A pad slot is automatically allocated, and is populated with \f(CW\*(C`sv\*(C'\fR; this function takes ownership of one reference to it. .Sp This function only exists if Perl has been compiled to use ithreads. .Sp .Vb 1 \& OP* newPADOP(I32 type, I32 flags, SV* sv) .Ve .IP "newPMOP" 8 .IX Xref "newPMOP" .IX Item "newPMOP" Constructs, checks, and returns an op of any pattern matching type. \&\f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR. .Sp .Vb 1 \& OP* newPMOP(I32 type, I32 flags) .Ve .IP "newPVOP" 8 .IX Xref "newPVOP" .IX Item "newPVOP" Constructs, checks, and returns an op of any type that involves an embedded C\-level pointer (\s-1PV\s0). \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR. \f(CW\*(C`pv\*(C'\fR supplies the C\-level pointer. Depending on the op type, the memory referenced by \f(CW\*(C`pv\*(C'\fR may be freed when the op is destroyed. If the op is of a freeing type, \f(CW\*(C`pv\*(C'\fR must have been allocated using \f(CW\*(C`PerlMemShared_malloc\*(C'\fR. .Sp .Vb 1 \& OP* newPVOP(I32 type, I32 flags, char* pv) .Ve .IP "newRANGE" 8 .IX Xref "newRANGE" .IX Item "newRANGE" Constructs and returns a \f(CW\*(C`range\*(C'\fR op, with subordinate \f(CW\*(C`flip\*(C'\fR and \&\f(CW\*(C`flop\*(C'\fR ops. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR for the \&\f(CW\*(C`flip\*(C'\fR op and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR for both the \f(CW\*(C`flip\*(C'\fR and \f(CW\*(C`range\*(C'\fR ops, except that the bit with value 1 is automatically set. \f(CW\*(C`left\*(C'\fR and \f(CW\*(C`right\*(C'\fR supply the expressions controlling the endpoints of the range; they are consumed by this function and become part of the constructed op tree. .Sp .Vb 1 \& OP* newRANGE(I32 flags, OP* left, OP* right) .Ve .IP "newSLICEOP" 8 .IX Xref "newSLICEOP" .IX Item "newSLICEOP" Constructs, checks, and returns an \f(CW\*(C`lslice\*(C'\fR (list slice) op. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically, and, shifted up eight bits, the eight bits of \&\f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 or 2 is automatically set as required. \f(CW\*(C`listval\*(C'\fR and \f(CW\*(C`subscript\*(C'\fR supply the parameters of the slice; they are consumed by this function and become part of the constructed op tree. .Sp .Vb 1 \& OP* newSLICEOP(I32 flags, OP* subscript, OP* listop) .Ve .IP "newSTATEOP" 8 .IX Xref "newSTATEOP" .IX Item "newSTATEOP" Constructs a state op (\s-1COP\s0). The state op is normally a \f(CW\*(C`nextstate\*(C'\fR op, but will be a \f(CW\*(C`dbstate\*(C'\fR op if debugging is enabled for currently-compiled code. The state op is populated from \f(CW\*(C`PL_curcop\*(C'\fR (or \f(CW\*(C`PL_compiling\*(C'\fR). If \f(CW\*(C`label\*(C'\fR is non-null, it supplies the name of a label to attach to the state op; this function takes ownership of the memory pointed at by \&\f(CW\*(C`label\*(C'\fR, and will free it. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR for the state op. .Sp If \f(CW\*(C`o\*(C'\fR is null, the state op is returned. Otherwise the state op is combined with \f(CW\*(C`o\*(C'\fR into a \f(CW\*(C`lineseq\*(C'\fR list op, which is returned. \f(CW\*(C`o\*(C'\fR is consumed by this function and becomes part of the returned op tree. .Sp .Vb 1 \& OP* newSTATEOP(I32 flags, char* label, OP* o) .Ve .IP "newSVOP" 8 .IX Xref "newSVOP" .IX Item "newSVOP" Constructs, checks, and returns an op of any type that involves an embedded \s-1SV.\s0 \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR. \f(CW\*(C`sv\*(C'\fR gives the \s-1SV\s0 to embed in the op; this function takes ownership of one reference to it. .Sp .Vb 1 \& OP* newSVOP(I32 type, I32 flags, SV* sv) .Ve .IP "newUNOP" 8 .IX Xref "newUNOP" .IX Item "newUNOP" Constructs, checks, and returns an op of any unary type. \f(CW\*(C`type\*(C'\fR is the opcode. \f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR, except that \&\f(CW\*(C`OPf_KIDS\*(C'\fR will be set automatically if required, and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR, except that the bit with value 1 is automatically set. \f(CW\*(C`first\*(C'\fR supplies an optional op to be the direct child of the unary op; it is consumed by this function and become part of the constructed op tree. .Sp .Vb 1 \& OP* newUNOP(I32 type, I32 flags, OP* first) .Ve .IP "newUNOP_AUX" 8 .IX Xref "newUNOP_AUX" .IX Item "newUNOP_AUX" Similar to \f(CW\*(C`newUNOP\*(C'\fR, but creates an \f(CW\*(C`UNOP_AUX\*(C'\fR struct instead, with \f(CW\*(C`op_aux\*(C'\fR initialised to \f(CW\*(C`aux\*(C'\fR .Sp .Vb 2 \& OP* newUNOP_AUX(I32 type, I32 flags, OP* first, \& UNOP_AUX_item *aux) .Ve .IP "newWHENOP" 8 .IX Xref "newWHENOP" .IX Item "newWHENOP" Constructs, checks, and returns an op tree expressing a \f(CW\*(C`when\*(C'\fR block. \&\f(CW\*(C`cond\*(C'\fR supplies the test expression, and \f(CW\*(C`block\*(C'\fR supplies the block that will be executed if the test evaluates to true; they are consumed by this function and become part of the constructed op tree. \f(CW\*(C`cond\*(C'\fR will be interpreted DWIMically, often as a comparison against \f(CW$_\fR, and may be null to generate a \f(CW\*(C`default\*(C'\fR block. .Sp .Vb 1 \& OP* newWHENOP(OP* cond, OP* block) .Ve .IP "newWHILEOP" 8 .IX Xref "newWHILEOP" .IX Item "newWHILEOP" Constructs, checks, and returns an op tree expressing a \f(CW\*(C`while\*(C'\fR loop. This is a heavyweight loop, with structure that allows exiting the loop by \f(CW\*(C`last\*(C'\fR and suchlike. .Sp \&\f(CW\*(C`loop\*(C'\fR is an optional preconstructed \f(CW\*(C`enterloop\*(C'\fR op to use in the loop; if it is null then a suitable op will be constructed automatically. \&\f(CW\*(C`expr\*(C'\fR supplies the loop's controlling expression. \f(CW\*(C`block\*(C'\fR supplies the main body of the loop, and \f(CW\*(C`cont\*(C'\fR optionally supplies a \f(CW\*(C`continue\*(C'\fR 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. .Sp \&\f(CW\*(C`flags\*(C'\fR gives the eight bits of \f(CW\*(C`op_flags\*(C'\fR for the \f(CW\*(C`leaveloop\*(C'\fR op and, shifted up eight bits, the eight bits of \f(CW\*(C`op_private\*(C'\fR for the \f(CW\*(C`leaveloop\*(C'\fR op, except that (in both cases) some bits will be set automatically. \f(CW\*(C`debuggable\*(C'\fR is currently unused and should always be 1. \&\f(CW\*(C`has_my\*(C'\fR can be supplied as true to force the loop body to be enclosed in its own scope. .Sp .Vb 3 \& OP* newWHILEOP(I32 flags, I32 debuggable, \& LOOP* loop, OP* expr, OP* block, \& OP* cont, I32 has_my) .Ve .SH "Optree Manipulation Functions" .IX Header "Optree Manipulation Functions" .IP "alloccopstash" 8 .IX Xref "alloccopstash" .IX Item "alloccopstash" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Available only under threaded builds, this function allocates an entry in \&\f(CW\*(C`PL_stashpad\*(C'\fR for the stash passed to it. .Sp .Vb 1 \& PADOFFSET alloccopstash(HV *hv) .Ve .IP "block_end" 8 .IX Xref "block_end" .IX Item "block_end" Handles compile-time scope exit. \f(CW\*(C`floor\*(C'\fR is the savestack index returned by \&\f(CW\*(C`block_start\*(C'\fR, and \f(CW\*(C`seq\*(C'\fR is the body of the block. Returns the block, possibly modified. .Sp .Vb 1 \& OP* block_end(I32 floor, OP* seq) .Ve .IP "block_start" 8 .IX Xref "block_start" .IX Item "block_start" Handles compile-time scope entry. Arranges for hints to be restored on block exit and also handles pad sequence numbers to make lexical variables scope right. Returns a savestack index for use with \f(CW\*(C`block_end\*(C'\fR. .Sp .Vb 1 \& int block_start(int full) .Ve .IP "ck_entersub_args_list" 8 .IX Xref "ck_entersub_args_list" .IX Item "ck_entersub_args_list" Performs the default fixup of the arguments part of an \f(CW\*(C`entersub\*(C'\fR op tree. This consists of applying list context to each of the argument ops. This is the standard treatment used on a call marked with \f(CW\*(C`&\*(C'\fR, or a method call, or a call through a subroutine reference, or any other call where the callee can't be identified at compile time, or a call where the callee has no prototype. .Sp .Vb 1 \& OP* ck_entersub_args_list(OP *entersubop) .Ve .IP "ck_entersub_args_proto" 8 .IX Xref "ck_entersub_args_proto" .IX Item "ck_entersub_args_proto" Performs the fixup of the arguments part of an \f(CW\*(C`entersub\*(C'\fR op tree based on a subroutine prototype. This makes various modifications to the argument ops, from applying context up to inserting \f(CW\*(C`refgen\*(C'\fR ops, and checking the number and syntactic types of arguments, as directed by the prototype. This is the standard treatment used on a subroutine call, not marked with \f(CW\*(C`&\*(C'\fR, where the callee can be identified at compile time and has a prototype. .Sp \&\f(CW\*(C`protosv\*(C'\fR supplies the subroutine prototype to be applied to the call. It may be a normal defined scalar, of which the string value will be used. Alternatively, for convenience, it may be a subroutine object (a \f(CW\*(C`CV*\*(C'\fR that has been cast to \f(CW\*(C`SV*\*(C'\fR) which has a prototype. The prototype supplied, in whichever form, does not need to match the actual callee referenced by the op tree. .Sp If the argument ops disagree with the prototype, for example by having an unacceptable number of arguments, a valid op tree is returned anyway. The error is reflected in the parser state, normally resulting in a single exception at the top level of parsing which covers all the compilation errors that occurred. In the error message, the callee is referred to by the name defined by the \f(CW\*(C`namegv\*(C'\fR parameter. .Sp .Vb 2 \& OP* ck_entersub_args_proto(OP *entersubop, \& GV *namegv, SV *protosv) .Ve .IP "ck_entersub_args_proto_or_list" 8 .IX Xref "ck_entersub_args_proto_or_list" .IX Item "ck_entersub_args_proto_or_list" Performs the fixup of the arguments part of an \f(CW\*(C`entersub\*(C'\fR op tree either based on a subroutine prototype or using default list-context processing. This is the standard treatment used on a subroutine call, not marked with \f(CW\*(C`&\*(C'\fR, where the callee can be identified at compile time. .Sp \&\f(CW\*(C`protosv\*(C'\fR supplies the subroutine prototype to be applied to the call, or indicates that there is no prototype. It may be a normal scalar, in which case if it is defined then the string value will be used as a prototype, and if it is undefined then there is no prototype. Alternatively, for convenience, it may be a subroutine object (a \f(CW\*(C`CV*\*(C'\fR that has been cast to \f(CW\*(C`SV*\*(C'\fR), of which the prototype will be used if it has one. The prototype (or lack thereof) supplied, in whichever form, does not need to match the actual callee referenced by the op tree. .Sp If the argument ops disagree with the prototype, for example by having an unacceptable number of arguments, a valid op tree is returned anyway. The error is reflected in the parser state, normally resulting in a single exception at the top level of parsing which covers all the compilation errors that occurred. In the error message, the callee is referred to by the name defined by the \f(CW\*(C`namegv\*(C'\fR parameter. .Sp .Vb 3 \& OP* ck_entersub_args_proto_or_list(OP *entersubop, \& GV *namegv, \& SV *protosv) .Ve .IP "cv_const_sv" 8 .IX Xref "cv_const_sv" .IX Item "cv_const_sv" If \f(CW\*(C`cv\*(C'\fR is a constant sub eligible for inlining, returns the constant value returned by the sub. Otherwise, returns \f(CW\*(C`NULL\*(C'\fR. .Sp Constant subs can be created with \f(CW\*(C`newCONSTSUB\*(C'\fR or as described in \&\*(L"Constant Functions\*(R" in perlsub. .Sp .Vb 1 \& SV* cv_const_sv(const CV *const cv) .Ve .IP "cv_get_call_checker" 8 .IX Xref "cv_get_call_checker" .IX Item "cv_get_call_checker" The original form of \*(L"cv_get_call_checker_flags\*(R", which does not return checker flags. When using a checker function returned by this function, it is only safe to call it with a genuine \s-1GV\s0 as its \f(CW\*(C`namegv\*(C'\fR argument. .Sp .Vb 3 \& void cv_get_call_checker(CV *cv, \& Perl_call_checker *ckfun_p, \& SV **ckobj_p) .Ve .IP "cv_get_call_checker_flags" 8 .IX Xref "cv_get_call_checker_flags" .IX Item "cv_get_call_checker_flags" Retrieves the function that will be used to fix up a call to \f(CW\*(C`cv\*(C'\fR. Specifically, the function is applied to an \f(CW\*(C`entersub\*(C'\fR op tree for a subroutine call, not marked with \f(CW\*(C`&\*(C'\fR, where the callee can be identified at compile time as \f(CW\*(C`cv\*(C'\fR. .Sp The C\-level function pointer is returned in \f(CW*ckfun_p\fR, an \s-1SV\s0 argument for it is returned in \f(CW*ckobj_p\fR, and control flags are returned in \&\f(CW*ckflags_p\fR. The function is intended to be called in this manner: .Sp .Vb 1 \& entersubop = (*ckfun_p)(aTHX_ entersubop, namegv, (*ckobj_p)); .Ve .Sp In this call, \f(CW\*(C`entersubop\*(C'\fR is a pointer to the \f(CW\*(C`entersub\*(C'\fR op, which may be replaced by the check function, and \f(CW\*(C`namegv\*(C'\fR supplies the name that should be used by the check function to refer to the callee of the \f(CW\*(C`entersub\*(C'\fR op if it needs to emit any diagnostics. It is permitted to apply the check function in non-standard situations, such as to a call to a different subroutine or to a method call. .Sp \&\f(CW\*(C`namegv\*(C'\fR may not actually be a \s-1GV.\s0 If the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR bit is clear in \f(CW*ckflags_p\fR, it is permitted to pass a \s-1CV\s0 or other \s-1SV\s0 instead, anything that can be used as the first argument to \*(L"cv_name\*(R". If the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR bit is set in \f(CW*ckflags_p\fR then the check function requires \f(CW\*(C`namegv\*(C'\fR to be a genuine \s-1GV.\s0 .Sp By default, the check function is Perl_ck_entersub_args_proto_or_list, the \s-1SV\s0 parameter is \f(CW\*(C`cv\*(C'\fR itself, and the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR flag is clear. This implements standard prototype processing. It can be changed, for a particular subroutine, by \*(L"cv_set_call_checker_flags\*(R". .Sp If the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR bit is set in \f(CW\*(C`gflags\*(C'\fR then it indicates that the caller only knows about the genuine \s-1GV\s0 version of \&\f(CW\*(C`namegv\*(C'\fR, and accordingly the corresponding bit will always be set in \&\f(CW*ckflags_p\fR, regardless of the check function's recorded requirements. If the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR bit is clear in \f(CW\*(C`gflags\*(C'\fR then it indicates the caller knows about the possibility of passing something other than a \s-1GV\s0 as \f(CW\*(C`namegv\*(C'\fR, and accordingly the corresponding bit may be either set or clear in \f(CW*ckflags_p\fR, indicating the check function's recorded requirements. .Sp \&\f(CW\*(C`gflags\*(C'\fR is a bitset passed into \f(CW\*(C`cv_get_call_checker_flags\*(C'\fR, in which only the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR bit currently has a defined meaning (for which see above). All other bits should be clear. .Sp .Vb 5 \& void cv_get_call_checker_flags( \& CV *cv, U32 gflags, \& Perl_call_checker *ckfun_p, SV **ckobj_p, \& U32 *ckflags_p \& ) .Ve .IP "cv_set_call_checker" 8 .IX Xref "cv_set_call_checker" .IX Item "cv_set_call_checker" The original form of \*(L"cv_set_call_checker_flags\*(R", which passes it the \&\f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR flag for backward-compatibility. The effect of that flag setting is that the check function is guaranteed to get a genuine \s-1GV\s0 as its \f(CW\*(C`namegv\*(C'\fR argument. .Sp .Vb 3 \& void cv_set_call_checker(CV *cv, \& Perl_call_checker ckfun, \& SV *ckobj) .Ve .IP "cv_set_call_checker_flags" 8 .IX Xref "cv_set_call_checker_flags" .IX Item "cv_set_call_checker_flags" Sets the function that will be used to fix up a call to \f(CW\*(C`cv\*(C'\fR. Specifically, the function is applied to an \f(CW\*(C`entersub\*(C'\fR op tree for a subroutine call, not marked with \f(CW\*(C`&\*(C'\fR, where the callee can be identified at compile time as \f(CW\*(C`cv\*(C'\fR. .Sp The C\-level function pointer is supplied in \f(CW\*(C`ckfun\*(C'\fR, an \s-1SV\s0 argument for it is supplied in \f(CW\*(C`ckobj\*(C'\fR, and control flags are supplied in \f(CW\*(C`ckflags\*(C'\fR. The function should be defined like this: .Sp .Vb 1 \& STATIC OP * ckfun(pTHX_ OP *op, GV *namegv, SV *ckobj) .Ve .Sp It is intended to be called in this manner: .Sp .Vb 1 \& entersubop = ckfun(aTHX_ entersubop, namegv, ckobj); .Ve .Sp In this call, \f(CW\*(C`entersubop\*(C'\fR is a pointer to the \f(CW\*(C`entersub\*(C'\fR op, which may be replaced by the check function, and \f(CW\*(C`namegv\*(C'\fR supplies the name that should be used by the check function to refer to the callee of the \f(CW\*(C`entersub\*(C'\fR op if it needs to emit any diagnostics. It is permitted to apply the check function in non-standard situations, such as to a call to a different subroutine or to a method call. .Sp \&\f(CW\*(C`namegv\*(C'\fR may not actually be a \s-1GV.\s0 For efficiency, perl may pass a \&\s-1CV\s0 or other \s-1SV\s0 instead. Whatever is passed can be used as the first argument to \*(L"cv_name\*(R". You can force perl to pass a \s-1GV\s0 by including \&\f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR in the \f(CW\*(C`ckflags\*(C'\fR. .Sp \&\f(CW\*(C`ckflags\*(C'\fR is a bitset, in which only the \f(CW\*(C`CALL_CHECKER_REQUIRE_GV\*(C'\fR bit currently has a defined meaning (for which see above). All other bits should be clear. .Sp The current setting for a particular \s-1CV\s0 can be retrieved by \&\*(L"cv_get_call_checker_flags\*(R". .Sp .Vb 4 \& void cv_set_call_checker_flags( \& CV *cv, Perl_call_checker ckfun, SV *ckobj, \& U32 ckflags \& ) .Ve .IP "\s-1LINKLIST\s0" 8 .IX Xref "LINKLIST" .IX Item "LINKLIST" Given the root of an optree, link the tree in execution order using the \&\f(CW\*(C`op_next\*(C'\fR pointers and return the first op executed. If this has already been done, it will not be redone, and \f(CW\*(C`o\->op_next\*(C'\fR will be returned. If \f(CW\*(C`o\->op_next\*(C'\fR is not already set, \f(CW\*(C`o\*(C'\fR should be at least an \f(CW\*(C`UNOP\*(C'\fR. .Sp .Vb 1 \& OP* LINKLIST(OP *o) .Ve .IP "newCONSTSUB" 8 .IX Xref "newCONSTSUB" .IX Item "newCONSTSUB" Behaves like \*(L"newCONSTSUB_flags\*(R", except that \f(CW\*(C`name\*(C'\fR is nul-terminated rather than of counted length, and no flags are set. (This means that \&\f(CW\*(C`name\*(C'\fR is always interpreted as Latin\-1.) .Sp .Vb 1 \& CV* newCONSTSUB(HV* stash, const char* name, SV* sv) .Ve .IP "newCONSTSUB_flags" 8 .IX Xref "newCONSTSUB_flags" .IX Item "newCONSTSUB_flags" Construct a constant subroutine, also performing some surrounding jobs. A scalar constant-valued subroutine is eligible for inlining at compile-time, and in Perl code can be created by \f(CW\*(C`sub FOO () { 123 }\*(C'\fR. Other kinds of constant subroutine have other treatment. .Sp The subroutine will have an empty prototype and will ignore any arguments when called. Its constant behaviour is determined by \f(CW\*(C`sv\*(C'\fR. If \f(CW\*(C`sv\*(C'\fR is null, the subroutine will yield an empty list. If \f(CW\*(C`sv\*(C'\fR points to a scalar, the subroutine will always yield that scalar. If \f(CW\*(C`sv\*(C'\fR points to an array, the subroutine will always yield a list of the elements of that array in list context, or the number of elements in the array in scalar context. This function takes ownership of one counted reference to the scalar or array, and will arrange for the object to live as long as the subroutine does. If \f(CW\*(C`sv\*(C'\fR points to a scalar then the inlining assumes that the value of the scalar will never change, so the caller must ensure that the scalar is not subsequently written to. If \f(CW\*(C`sv\*(C'\fR points to an array then no such assumption is made, so it is ostensibly safe to mutate the array or its elements, but whether this is really supported has not been determined. .Sp The subroutine will have \f(CW\*(C`CvFILE\*(C'\fR set according to \f(CW\*(C`PL_curcop\*(C'\fR. Other aspects of the subroutine will be left in their default state. The caller is free to mutate the subroutine beyond its initial state after this function has returned. .Sp If \f(CW\*(C`name\*(C'\fR is null then the subroutine will be anonymous, with its \&\f(CW\*(C`CvGV\*(C'\fR referring to an \f(CW\*(C`_\|_ANON_\|_\*(C'\fR glob. If \f(CW\*(C`name\*(C'\fR is non-null then the subroutine will be named accordingly, referenced by the appropriate glob. \&\f(CW\*(C`name\*(C'\fR is a string of length \f(CW\*(C`len\*(C'\fR bytes giving a sigilless symbol name, in \s-1UTF\-8\s0 if \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SVf_UTF8\*(C'\fR bit set and in Latin\-1 otherwise. The name may be either qualified or unqualified. If the name is unqualified then it defaults to being in the stash specified by \&\f(CW\*(C`stash\*(C'\fR if that is non-null, or to \f(CW\*(C`PL_curstash\*(C'\fR if \f(CW\*(C`stash\*(C'\fR is null. The symbol is always added to the stash if necessary, with \f(CW\*(C`GV_ADDMULTI\*(C'\fR semantics. .Sp \&\f(CW\*(C`flags\*(C'\fR should not have bits set other than \f(CW\*(C`SVf_UTF8\*(C'\fR. .Sp If there is already a subroutine of the specified name, then the new sub will replace the existing one in the glob. A warning may be generated about the redefinition. .Sp If the subroutine has one of a few special names, such as \f(CW\*(C`BEGIN\*(C'\fR or \&\f(CW\*(C`END\*(C'\fR, then it will be claimed by the appropriate queue for automatic running of phase-related subroutines. In this case the relevant glob will be left not containing any subroutine, even if it did contain one before. Execution of the subroutine will likely be a no-op, unless \f(CW\*(C`sv\*(C'\fR was a tied array or the caller modified the subroutine in some interesting way before it was executed. In the case of \f(CW\*(C`BEGIN\*(C'\fR, the treatment is buggy: the sub will be executed when only half built, and may be deleted prematurely, possibly causing a crash. .Sp The function returns a pointer to the constructed subroutine. If the sub is anonymous then ownership of one counted reference to the subroutine is transferred to the caller. If the sub is named then the caller does not get ownership of a reference. In most such cases, where the sub has a non-phase name, the sub will be alive at the point it is returned by virtue of being contained in the glob that names it. A phase-named subroutine will usually be alive by virtue of the reference owned by the phase's automatic run queue. A \f(CW\*(C`BEGIN\*(C'\fR subroutine may have been destroyed already by the time this function returns, but currently bugs occur in that case before the caller gets control. It is the caller's responsibility to ensure that it knows which of these situations applies. .Sp .Vb 2 \& CV* newCONSTSUB_flags(HV* stash, const char* name, \& STRLEN len, U32 flags, SV* sv) .Ve .IP "newXS" 8 .IX Xref "newXS" .IX Item "newXS" Used by \f(CW\*(C`xsubpp\*(C'\fR to hook up XSUBs as Perl subs. \f(CW\*(C`filename\*(C'\fR needs to be static storage, as it is used directly as \fBCvFILE()\fR, without a copy being made. .IP "op_append_elem" 8 .IX Xref "op_append_elem" .IX Item "op_append_elem" Append an item to the list of ops contained directly within a list-type op, returning the lengthened list. \f(CW\*(C`first\*(C'\fR is the list-type op, and \f(CW\*(C`last\*(C'\fR is the op to append to the list. \f(CW\*(C`optype\*(C'\fR specifies the intended opcode for the list. If \f(CW\*(C`first\*(C'\fR is not already a list of the right type, it will be upgraded into one. If either \f(CW\*(C`first\*(C'\fR or \f(CW\*(C`last\*(C'\fR is null, the other is returned unchanged. .Sp .Vb 1 \& OP* op_append_elem(I32 optype, OP* first, OP* last) .Ve .IP "op_append_list" 8 .IX Xref "op_append_list" .IX Item "op_append_list" Concatenate the lists of ops contained directly within two list-type ops, returning the combined list. \f(CW\*(C`first\*(C'\fR and \f(CW\*(C`last\*(C'\fR are the list-type ops to concatenate. \f(CW\*(C`optype\*(C'\fR specifies the intended opcode for the list. If either \f(CW\*(C`first\*(C'\fR or \f(CW\*(C`last\*(C'\fR is not already a list of the right type, it will be upgraded into one. If either \f(CW\*(C`first\*(C'\fR or \f(CW\*(C`last\*(C'\fR is null, the other is returned unchanged. .Sp .Vb 1 \& OP* op_append_list(I32 optype, OP* first, OP* last) .Ve .IP "\s-1OP_CLASS\s0" 8 .IX Xref "OP_CLASS" .IX Item "OP_CLASS" Return the class of the provided \s-1OP:\s0 that is, which of the *OP structures it uses. For core ops this currently gets the information out of \f(CW\*(C`PL_opargs\*(C'\fR, which does not always accurately reflect the type used; in v5.26 onwards, see also the function \f(CW"op_class"\fR which can do a better job of determining the used type. .Sp For custom ops the type is returned from the registration, and it is up to the registree to ensure it is accurate. The value returned will be one of the \f(CW\*(C`OA_\*(C'\fR* constants from \fIop.h\fR. .Sp .Vb 1 \& U32 OP_CLASS(OP *o) .Ve .IP "op_contextualize" 8 .IX Xref "op_contextualize" .IX Item "op_contextualize" Applies a syntactic context to an op tree representing an expression. \&\f(CW\*(C`o\*(C'\fR is the op tree, and \f(CW\*(C`context\*(C'\fR must be \f(CW\*(C`G_SCALAR\*(C'\fR, \f(CW\*(C`G_ARRAY\*(C'\fR, or \f(CW\*(C`G_VOID\*(C'\fR to specify the context to apply. The modified op tree is returned. .Sp .Vb 1 \& OP* op_contextualize(OP* o, I32 context) .Ve .IP "op_convert_list" 8 .IX Xref "op_convert_list" .IX Item "op_convert_list" Converts \f(CW\*(C`o\*(C'\fR into a list op if it is not one already, and then converts it into the specified \f(CW\*(C`type\*(C'\fR, calling its check function, allocating a target if it needs one, and folding constants. .Sp A list-type op is usually constructed one kid at a time via \f(CW\*(C`newLISTOP\*(C'\fR, \&\f(CW\*(C`op_prepend_elem\*(C'\fR and \f(CW\*(C`op_append_elem\*(C'\fR. Then finally it is passed to \&\f(CW\*(C`op_convert_list\*(C'\fR to make it the right type. .Sp .Vb 1 \& OP* op_convert_list(I32 optype, I32 flags, OP* o) .Ve .IP "\s-1OP_DESC\s0" 8 .IX Xref "OP_DESC" .IX Item "OP_DESC" Return a short description of the provided \s-1OP.\s0 .Sp .Vb 1 \& const char * OP_DESC(OP *o) .Ve .IP "op_free" 8 .IX Xref "op_free" .IX Item "op_free" Free an op and its children. Only use this when an op is no longer linked to from any optree. .Sp .Vb 1 \& void op_free(OP* arg) .Ve .IP "OpHAS_SIBLING" 8 .IX Xref "OpHAS_SIBLING" .IX Item "OpHAS_SIBLING" Returns true if \f(CW\*(C`o\*(C'\fR has a sibling .Sp .Vb 1 \& bool OpHAS_SIBLING(OP *o) .Ve .IP "OpLASTSIB_set" 8 .IX Xref "OpLASTSIB_set" .IX Item "OpLASTSIB_set" Marks \f(CW\*(C`o\*(C'\fR as having no further siblings and marks o as having the specified parent. See also \f(CW"OpMORESIB_set"\fR and \&\f(CW\*(C`OpMAYBESIB_set\*(C'\fR. For a higher-level interface, see \&\f(CW"op_sibling_splice"\fR. .Sp .Vb 1 \& void OpLASTSIB_set(OP *o, OP *parent) .Ve .IP "op_linklist" 8 .IX Xref "op_linklist" .IX Item "op_linklist" This function is the implementation of the \*(L"\s-1LINKLIST\*(R"\s0 macro. It should not be called directly. .Sp .Vb 1 \& OP* op_linklist(OP *o) .Ve .IP "op_lvalue" 8 .IX Xref "op_lvalue" .IX Item "op_lvalue" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Propagate lvalue (\*(L"modifiable\*(R") context to an op and its children. \&\f(CW\*(C`type\*(C'\fR represents the context type, roughly based on the type of op that would do the modifying, although \f(CW\*(C`local()\*(C'\fR is represented by \f(CW\*(C`OP_NULL\*(C'\fR, because it has no op type of its own (it is signalled by a flag on the lvalue op). .Sp This function detects things that can't be modified, such as \f(CW\*(C`$x+1\*(C'\fR, and generates errors for them. For example, \f(CW\*(C`$x+1 = 2\*(C'\fR would cause it to be called with an op of type \f(CW\*(C`OP_ADD\*(C'\fR and a \f(CW\*(C`type\*(C'\fR argument of \f(CW\*(C`OP_SASSIGN\*(C'\fR. .Sp It also flags things that need to behave specially in an lvalue context, such as \f(CW\*(C`$$x = 5\*(C'\fR which might have to vivify a reference in \f(CW$x\fR. .Sp .Vb 1 \& OP* op_lvalue(OP* o, I32 type) .Ve .IP "OpMAYBESIB_set" 8 .IX Xref "OpMAYBESIB_set" .IX Item "OpMAYBESIB_set" Conditionally does \f(CW\*(C`OpMORESIB_set\*(C'\fR or \f(CW\*(C`OpLASTSIB_set\*(C'\fR depending on whether \&\f(CW\*(C`sib\*(C'\fR is non-null. For a higher-level interface, see \f(CW"op_sibling_splice"\fR. .Sp .Vb 1 \& void OpMAYBESIB_set(OP *o, OP *sib, OP *parent) .Ve .IP "OpMORESIB_set" 8 .IX Xref "OpMORESIB_set" .IX Item "OpMORESIB_set" Sets the sibling of \f(CW\*(C`o\*(C'\fR to the non-zero value \f(CW\*(C`sib\*(C'\fR. See also \f(CW"OpLASTSIB_set"\fR and \f(CW"OpMAYBESIB_set"\fR. For a higher-level interface, see \&\f(CW"op_sibling_splice"\fR. .Sp .Vb 1 \& void OpMORESIB_set(OP *o, OP *sib) .Ve .IP "\s-1OP_NAME\s0" 8 .IX Xref "OP_NAME" .IX Item "OP_NAME" Return the name of the provided \s-1OP.\s0 For core ops this looks up the name from the op_type; for custom ops from the op_ppaddr. .Sp .Vb 1 \& const char * OP_NAME(OP *o) .Ve .IP "op_null" 8 .IX Xref "op_null" .IX Item "op_null" Neutralizes an op when it is no longer needed, but is still linked to from other ops. .Sp .Vb 1 \& void op_null(OP* o) .Ve .IP "op_parent" 8 .IX Xref "op_parent" .IX Item "op_parent" Returns the parent \s-1OP\s0 of \f(CW\*(C`o\*(C'\fR, if it has a parent. Returns \f(CW\*(C`NULL\*(C'\fR otherwise. .Sp .Vb 1 \& OP* op_parent(OP *o) .Ve .IP "op_prepend_elem" 8 .IX Xref "op_prepend_elem" .IX Item "op_prepend_elem" Prepend an item to the list of ops contained directly within a list-type op, returning the lengthened list. \f(CW\*(C`first\*(C'\fR is the op to prepend to the list, and \f(CW\*(C`last\*(C'\fR is the list-type op. \f(CW\*(C`optype\*(C'\fR specifies the intended opcode for the list. If \f(CW\*(C`last\*(C'\fR is not already a list of the right type, it will be upgraded into one. If either \f(CW\*(C`first\*(C'\fR or \f(CW\*(C`last\*(C'\fR is null, the other is returned unchanged. .Sp .Vb 1 \& OP* op_prepend_elem(I32 optype, OP* first, OP* last) .Ve .IP "op_scope" 8 .IX Xref "op_scope" .IX Item "op_scope" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Wraps up an op tree with some additional ops so that at runtime a dynamic scope will be created. The original ops run in the new dynamic scope, and then, provided that they exit normally, the scope will be unwound. The additional ops used to create and unwind the dynamic scope will normally be an \f(CW\*(C`enter\*(C'\fR/\f(CW\*(C`leave\*(C'\fR pair, but a \f(CW\*(C`scope\*(C'\fR op may be used instead if the ops are simple enough to not need the full dynamic scope structure. .Sp .Vb 1 \& OP* op_scope(OP* o) .Ve .IP "OpSIBLING" 8 .IX Xref "OpSIBLING" .IX Item "OpSIBLING" Returns the sibling of \f(CW\*(C`o\*(C'\fR, or \f(CW\*(C`NULL\*(C'\fR if there is no sibling .Sp .Vb 1 \& OP* OpSIBLING(OP *o) .Ve .IP "op_sibling_splice" 8 .IX Xref "op_sibling_splice" .IX Item "op_sibling_splice" A general function for editing the structure of an existing chain of op_sibling nodes. By analogy with the perl-level \f(CW\*(C`splice()\*(C'\fR function, allows you to delete zero or more sequential nodes, replacing them with zero or more different nodes. Performs the necessary op_first/op_last housekeeping on the parent node and op_sibling manipulation on the children. The last deleted node will be marked as the last node by updating the op_sibling/op_sibparent or op_moresib field as appropriate. .Sp Note that op_next is not manipulated, and nodes are not freed; that is the responsibility of the caller. It also won't create a new list op for an empty list etc; use higher-level functions like \fBop_append_elem()\fR for that. .Sp \&\f(CW\*(C`parent\*(C'\fR is the parent node of the sibling chain. It may passed as \f(CW\*(C`NULL\*(C'\fR if the splicing doesn't affect the first or last op in the chain. .Sp \&\f(CW\*(C`start\*(C'\fR is the node preceding the first node to be spliced. Node(s) following it will be deleted, and ops will be inserted after it. If it is \&\f(CW\*(C`NULL\*(C'\fR, the first node onwards is deleted, and nodes are inserted at the beginning. .Sp \&\f(CW\*(C`del_count\*(C'\fR is the number of nodes to delete. If zero, no nodes are deleted. If \-1 or greater than or equal to the number of remaining kids, all remaining kids are deleted. .Sp \&\f(CW\*(C`insert\*(C'\fR is the first of a chain of nodes to be inserted in place of the nodes. If \f(CW\*(C`NULL\*(C'\fR, no nodes are inserted. .Sp The head of the chain of deleted ops is returned, or \f(CW\*(C`NULL\*(C'\fR if no ops were deleted. .Sp For example: .Sp .Vb 2 \& action before after returns \& \-\-\-\-\-\- \-\-\-\-\- \-\-\-\-\- \-\-\-\-\-\-\- \& \& P P \& splice(P, A, 2, X\-Y\-Z) | | B\-C \& A\-B\-C\-D A\-X\-Y\-Z\-D \& \& P P \& splice(P, NULL, 1, X\-Y) | | A \& A\-B\-C\-D X\-Y\-B\-C\-D \& \& P P \& splice(P, NULL, 3, NULL) | | A\-B\-C \& A\-B\-C\-D D \& \& P P \& splice(P, B, 0, X\-Y) | | NULL \& A\-B\-C\-D A\-B\-X\-Y\-C\-D .Ve .Sp For lower-level direct manipulation of \f(CW\*(C`op_sibparent\*(C'\fR and \f(CW\*(C`op_moresib\*(C'\fR, see \f(CW"OpMORESIB_set"\fR, \f(CW"OpLASTSIB_set"\fR, \f(CW"OpMAYBESIB_set"\fR. .Sp .Vb 2 \& OP* op_sibling_splice(OP *parent, OP *start, \& int del_count, OP* insert) .Ve .IP "\s-1OP_TYPE_IS\s0" 8 .IX Xref "OP_TYPE_IS" .IX Item "OP_TYPE_IS" Returns true if the given \s-1OP\s0 is not a \f(CW\*(C`NULL\*(C'\fR pointer and if it is of the given type. .Sp The negation of this macro, \f(CW\*(C`OP_TYPE_ISNT\*(C'\fR is also available as well as \f(CW\*(C`OP_TYPE_IS_NN\*(C'\fR and \f(CW\*(C`OP_TYPE_ISNT_NN\*(C'\fR which elide the \s-1NULL\s0 pointer check. .Sp .Vb 1 \& bool OP_TYPE_IS(OP *o, Optype type) .Ve .IP "\s-1OP_TYPE_IS_OR_WAS\s0" 8 .IX Xref "OP_TYPE_IS_OR_WAS" .IX Item "OP_TYPE_IS_OR_WAS" Returns true if the given \s-1OP\s0 is not a \s-1NULL\s0 pointer and if it is of the given type or used to be before being replaced by an \s-1OP\s0 of type \s-1OP_NULL.\s0 .Sp The negation of this macro, \f(CW\*(C`OP_TYPE_ISNT_AND_WASNT\*(C'\fR is also available as well as \f(CW\*(C`OP_TYPE_IS_OR_WAS_NN\*(C'\fR and \f(CW\*(C`OP_TYPE_ISNT_AND_WASNT_NN\*(C'\fR which elide the \f(CW\*(C`NULL\*(C'\fR pointer check. .Sp .Vb 1 \& bool OP_TYPE_IS_OR_WAS(OP *o, Optype type) .Ve .IP "rv2cv_op_cv" 8 .IX Xref "rv2cv_op_cv" .IX Item "rv2cv_op_cv" Examines an op, which is expected to identify a subroutine at runtime, and attempts to determine at compile time which subroutine it identifies. This is normally used during Perl compilation to determine whether a prototype can be applied to a function call. \f(CW\*(C`cvop\*(C'\fR is the op being considered, normally an \f(CW\*(C`rv2cv\*(C'\fR op. A pointer to the identified subroutine is returned, if it could be determined statically, and a null pointer is returned if it was not possible to determine statically. .Sp Currently, the subroutine can be identified statically if the \s-1RV\s0 that the \&\f(CW\*(C`rv2cv\*(C'\fR is to operate on is provided by a suitable \f(CW\*(C`gv\*(C'\fR or \f(CW\*(C`const\*(C'\fR op. A \f(CW\*(C`gv\*(C'\fR op is suitable if the \s-1GV\s0's \s-1CV\s0 slot is populated. A \f(CW\*(C`const\*(C'\fR op is suitable if the constant value must be an \s-1RV\s0 pointing to a \s-1CV.\s0 Details of this process may change in future versions of Perl. If the \f(CW\*(C`rv2cv\*(C'\fR op has the \f(CW\*(C`OPpENTERSUB_AMPER\*(C'\fR flag set then no attempt is made to identify the subroutine statically: this flag is used to suppress compile-time magic on a subroutine call, forcing it to use default runtime behaviour. .Sp If \f(CW\*(C`flags\*(C'\fR has the bit \f(CW\*(C`RV2CVOPCV_MARK_EARLY\*(C'\fR set, then the handling of a \s-1GV\s0 reference is modified. If a \s-1GV\s0 was examined and its \s-1CV\s0 slot was found to be empty, then the \f(CW\*(C`gv\*(C'\fR op has the \f(CW\*(C`OPpEARLY_CV\*(C'\fR flag set. If the op is not optimised away, and the \s-1CV\s0 slot is later populated with a subroutine having a prototype, that flag eventually triggers the warning \&\*(L"called too early to check prototype\*(R". .Sp If \f(CW\*(C`flags\*(C'\fR has the bit \f(CW\*(C`RV2CVOPCV_RETURN_NAME_GV\*(C'\fR set, then instead of returning a pointer to the subroutine it returns a pointer to the \&\s-1GV\s0 giving the most appropriate name for the subroutine in this context. Normally this is just the \f(CW\*(C`CvGV\*(C'\fR of the subroutine, but for an anonymous (\f(CW\*(C`CvANON\*(C'\fR) subroutine that is referenced through a \s-1GV\s0 it will be the referencing \s-1GV.\s0 The resulting \f(CW\*(C`GV*\*(C'\fR is cast to \f(CW\*(C`CV*\*(C'\fR to be returned. A null pointer is returned as usual if there is no statically-determinable subroutine. .Sp .Vb 1 \& CV* rv2cv_op_cv(OP *cvop, U32 flags) .Ve .SH "Pack and Unpack" .IX Header "Pack and Unpack" .IP "packlist" 8 .IX Xref "packlist" .IX Item "packlist" The engine implementing \f(CW\*(C`pack()\*(C'\fR Perl function. .Sp .Vb 3 \& void packlist(SV *cat, const char *pat, \& const char *patend, SV **beglist, \& SV **endlist) .Ve .IP "unpackstring" 8 .IX Xref "unpackstring" .IX Item "unpackstring" The engine implementing the \f(CW\*(C`unpack()\*(C'\fR Perl function. .Sp Using the template \f(CW\*(C`pat..patend\*(C'\fR, this function unpacks the string \&\f(CW\*(C`s..strend\*(C'\fR into a number of mortal SVs, which it pushes onto the perl argument (\f(CW@_\fR) stack (so you will need to issue a \f(CW\*(C`PUTBACK\*(C'\fR before and \&\f(CW\*(C`SPAGAIN\*(C'\fR after the call to this function). It returns the number of pushed elements. .Sp The \f(CW\*(C`strend\*(C'\fR and \f(CW\*(C`patend\*(C'\fR pointers should point to the byte following the last character of each string. .Sp Although this function returns its values on the perl argument stack, it doesn't take any parameters from that stack (and thus in particular there's no need to do a \f(CW\*(C`PUSHMARK\*(C'\fR before calling it, unlike \*(L"call_pv\*(R" for example). .Sp .Vb 3 \& SSize_t unpackstring(const char *pat, \& const char *patend, const char *s, \& const char *strend, U32 flags) .Ve .SH "Pad Data Structures" .IX Header "Pad Data Structures" .IP "CvPADLIST" 8 .IX Xref "CvPADLIST" .IX Item "CvPADLIST" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp \&\s-1CV\s0's can have CvPADLIST(cv) set to point to a \s-1PADLIST.\s0 This is the \s-1CV\s0's scratchpad, which stores lexical variables and opcode temporary and per-thread values. .Sp For these purposes \*(L"formats\*(R" are a kind-of \s-1CV\s0; eval"\*(L"s are too (except they're not callable at will and are always thrown away after the eval\*(R"" is done executing). Require'd files are simply evals without any outer lexical scope. .Sp XSUBs do not have a \f(CW\*(C`CvPADLIST\*(C'\fR. \f(CW\*(C`dXSTARG\*(C'\fR fetches values from \f(CW\*(C`PL_curpad\*(C'\fR, but that is really the callers pad (a slot of which is allocated by every entersub). Do not get or set \f(CW\*(C`CvPADLIST\*(C'\fR if a \s-1CV\s0 is an \s-1XSUB\s0 (as determined by \f(CW\*(C`CvISXSUB()\*(C'\fR), \f(CW\*(C`CvPADLIST\*(C'\fR slot is reused for a different internal purpose in XSUBs. .Sp The \s-1PADLIST\s0 has a C array where pads are stored. .Sp The 0th entry of the \s-1PADLIST\s0 is a \s-1PADNAMELIST\s0 which represents the \*(L"names\*(R" or rather the \*(L"static type information\*(R" for lexicals. The individual elements of a \&\s-1PADNAMELIST\s0 are PADNAMEs. Future refactorings might stop the \s-1PADNAMELIST\s0 from being stored in the \s-1PADLIST\s0's array, so don't rely on it. See \*(L"PadlistNAMES\*(R". .Sp The CvDEPTH'th entry of a \s-1PADLIST\s0 is a \s-1PAD\s0 (an \s-1AV\s0) which is the stack frame at that depth of recursion into the \s-1CV.\s0 The 0th slot of a frame \s-1AV\s0 is an \&\s-1AV\s0 which is \f(CW@_\fR. Other entries are storage for variables and op targets. .Sp Iterating over the \s-1PADNAMELIST\s0 iterates over all possible pad items. Pad slots for targets (\f(CW\*(C`SVs_PADTMP\*(C'\fR) and GVs end up having &PL_padname_undef \*(L"names\*(R", while slots for constants have \f(CW&PL_padname_const\fR \*(L"names\*(R" (see \f(CW"pad_alloc"\fR). That \&\f(CW&PL_padname_undef\fR and \f(CW&PL_padname_const\fR are used is an implementation detail subject to change. To test for them, use \f(CW\*(C`!PadnamePV(name)\*(C'\fR and \&\f(CW\*(C`PadnamePV(name) && !PadnameLEN(name)\*(C'\fR, respectively. .Sp Only \f(CW\*(C`my\*(C'\fR/\f(CW\*(C`our\*(C'\fR variable slots get valid names. The rest are op targets/GVs/constants which are statically allocated or resolved at compile time. These don't have names by which they can be looked up from Perl code at run time through eval"" the way \&\f(CW\*(C`my\*(C'\fR/\f(CW\*(C`our\*(C'\fR variables can be. Since they can't be looked up by \*(L"name\*(R" but only by their index allocated at compile time (which is usually in \f(CW\*(C`PL_op\->op_targ\*(C'\fR), wasting a name \s-1SV\s0 for them doesn't make sense. .Sp The pad names in the \s-1PADNAMELIST\s0 have their \s-1PV\s0 holding the name of the variable. The \f(CW\*(C`COP_SEQ_RANGE_LOW\*(C'\fR and \f(CW\*(C`_HIGH\*(C'\fR fields form a range (low+1..high inclusive) of cop_seq numbers for which the name is valid. During compilation, these fields may hold the special value \&\s-1PERL_PADSEQ_INTRO\s0 to indicate various stages: .Sp .Vb 8 \& COP_SEQ_RANGE_LOW _HIGH \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\- \& PERL_PADSEQ_INTRO 0 variable not yet introduced: \& { my ($x \& valid\-seq# PERL_PADSEQ_INTRO variable in scope: \& { my ($x); \& valid\-seq# valid\-seq# compilation of scope complete: \& { my ($x); .... } .Ve .Sp When a lexical var hasn't yet been introduced, it already exists from the perspective of duplicate declarations, but not for variable lookups, e.g. .Sp .Vb 2 \& my ($x, $x); # \*(Aq"my" variable $x masks earlier declaration\*(Aq \& my $x = $x; # equal to my $x = $::x; .Ve .Sp For typed lexicals \f(CW\*(C`PadnameTYPE\*(C'\fR points at the type stash. For \f(CW\*(C`our\*(C'\fR lexicals, \f(CW\*(C`PadnameOURSTASH\*(C'\fR points at the stash of the associated global (so that duplicate \f(CW\*(C`our\*(C'\fR declarations in the same package can be detected). \&\f(CW\*(C`PadnameGEN\*(C'\fR is sometimes used to store the generation number during compilation. .Sp If \f(CW\*(C`PadnameOUTER\*(C'\fR is set on the pad name, then that slot in the frame \s-1AV\s0 is a \s-1REFCNT\s0'ed reference to a lexical from \*(L"outside\*(R". Such entries are sometimes referred to as 'fake'. In this case, the name does not use 'low' and 'high' to store a cop_seq range, since it is in scope throughout. Instead 'high' stores some flags containing info about the real lexical (is it declared in an anon, and is it capable of being instantiated multiple times?), and for fake ANONs, 'low' contains the index within the parent's pad where the lexical's value is stored, to make cloning quicker. .Sp If the 'name' is \f(CW\*(C`&\*(C'\fR the corresponding entry in the \s-1PAD\s0 is a \s-1CV\s0 representing a possible closure. .Sp Note that formats are treated as anon subs, and are cloned each time write is called (if necessary). .Sp The flag \f(CW\*(C`SVs_PADSTALE\*(C'\fR is cleared on lexicals each time the \f(CW\*(C`my()\*(C'\fR is executed, and set on scope exit. This allows the \&\f(CW"Variable $x is not available"\fR warning to be generated in evals, such as .Sp .Vb 1 \& { my $x = 1; sub f { eval \*(Aq$x\*(Aq} } f(); .Ve .Sp For state vars, \f(CW\*(C`SVs_PADSTALE\*(C'\fR is overloaded to mean 'not yet initialised', but this internal state is stored in a separate pad entry. .Sp .Vb 1 \& PADLIST * CvPADLIST(CV *cv) .Ve .IP "pad_add_name_pvs" 8 .IX Xref "pad_add_name_pvs" .IX Item "pad_add_name_pvs" Exactly like \*(L"pad_add_name_pvn\*(R", but takes a literal string instead of a string/length pair. .Sp .Vb 2 \& PADOFFSET pad_add_name_pvs("name", U32 flags, \& HV *typestash, HV *ourstash) .Ve .IP "PadARRAY" 8 .IX Xref "PadARRAY" .IX Item "PadARRAY" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The C array of pad entries. .Sp .Vb 1 \& SV ** PadARRAY(PAD * pad) .Ve .IP "pad_findmy_pvs" 8 .IX Xref "pad_findmy_pvs" .IX Item "pad_findmy_pvs" Exactly like \*(L"pad_findmy_pvn\*(R", but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& PADOFFSET pad_findmy_pvs("name", U32 flags) .Ve .IP "PadlistARRAY" 8 .IX Xref "PadlistARRAY" .IX Item "PadlistARRAY" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The C array of a padlist, containing the pads. Only subscript it with numbers >= 1, as the 0th entry is not guaranteed to remain usable. .Sp .Vb 1 \& PAD ** PadlistARRAY(PADLIST * padlist) .Ve .IP "PadlistMAX" 8 .IX Xref "PadlistMAX" .IX Item "PadlistMAX" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The index of the last allocated space in the padlist. Note that the last pad may be in an earlier slot. Any entries following it will be \f(CW\*(C`NULL\*(C'\fR in that case. .Sp .Vb 1 \& SSize_t PadlistMAX(PADLIST * padlist) .Ve .IP "PadlistNAMES" 8 .IX Xref "PadlistNAMES" .IX Item "PadlistNAMES" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The names associated with pad entries. .Sp .Vb 1 \& PADNAMELIST * PadlistNAMES(PADLIST * padlist) .Ve .IP "PadlistNAMESARRAY" 8 .IX Xref "PadlistNAMESARRAY" .IX Item "PadlistNAMESARRAY" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The C array of pad names. .Sp .Vb 1 \& PADNAME ** PadlistNAMESARRAY(PADLIST * padlist) .Ve .IP "PadlistNAMESMAX" 8 .IX Xref "PadlistNAMESMAX" .IX Item "PadlistNAMESMAX" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The index of the last pad name. .Sp .Vb 1 \& SSize_t PadlistNAMESMAX(PADLIST * padlist) .Ve .IP "PadlistREFCNT" 8 .IX Xref "PadlistREFCNT" .IX Item "PadlistREFCNT" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The reference count of the padlist. Currently this is always 1. .Sp .Vb 1 \& U32 PadlistREFCNT(PADLIST * padlist) .Ve .IP "PadMAX" 8 .IX Xref "PadMAX" .IX Item "PadMAX" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The index of the last pad entry. .Sp .Vb 1 \& SSize_t PadMAX(PAD * pad) .Ve .IP "PadnameLEN" 8 .IX Xref "PadnameLEN" .IX Item "PadnameLEN" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The length of the name. .Sp .Vb 1 \& STRLEN PadnameLEN(PADNAME * pn) .Ve .IP "PadnamelistARRAY" 8 .IX Xref "PadnamelistARRAY" .IX Item "PadnamelistARRAY" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The C array of pad names. .Sp .Vb 1 \& PADNAME ** PadnamelistARRAY(PADNAMELIST * pnl) .Ve .IP "PadnamelistMAX" 8 .IX Xref "PadnamelistMAX" .IX Item "PadnamelistMAX" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The index of the last pad name. .Sp .Vb 1 \& SSize_t PadnamelistMAX(PADNAMELIST * pnl) .Ve .IP "PadnamelistREFCNT" 8 .IX Xref "PadnamelistREFCNT" .IX Item "PadnamelistREFCNT" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The reference count of the pad name list. .Sp .Vb 1 \& SSize_t PadnamelistREFCNT(PADNAMELIST * pnl) .Ve .IP "PadnamelistREFCNT_dec" 8 .IX Xref "PadnamelistREFCNT_dec" .IX Item "PadnamelistREFCNT_dec" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Lowers the reference count of the pad name list. .Sp .Vb 1 \& void PadnamelistREFCNT_dec(PADNAMELIST * pnl) .Ve .IP "PadnamePV" 8 .IX Xref "PadnamePV" .IX Item "PadnamePV" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The name stored in the pad name struct. This returns \f(CW\*(C`NULL\*(C'\fR for a target slot. .Sp .Vb 1 \& char * PadnamePV(PADNAME * pn) .Ve .IP "PadnameREFCNT" 8 .IX Xref "PadnameREFCNT" .IX Item "PadnameREFCNT" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp The reference count of the pad name. .Sp .Vb 1 \& SSize_t PadnameREFCNT(PADNAME * pn) .Ve .IP "PadnameREFCNT_dec" 8 .IX Xref "PadnameREFCNT_dec" .IX Item "PadnameREFCNT_dec" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Lowers the reference count of the pad name. .Sp .Vb 1 \& void PadnameREFCNT_dec(PADNAME * pn) .Ve .IP "PadnameSV" 8 .IX Xref "PadnameSV" .IX Item "PadnameSV" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Returns the pad name as a mortal \s-1SV.\s0 .Sp .Vb 1 \& SV * PadnameSV(PADNAME * pn) .Ve .IP "PadnameUTF8" 8 .IX Xref "PadnameUTF8" .IX Item "PadnameUTF8" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Whether PadnamePV is in \s-1UTF\-8.\s0 Currently, this is always true. .Sp .Vb 1 \& bool PadnameUTF8(PADNAME * pn) .Ve .IP "pad_new" 8 .IX Xref "pad_new" .IX Item "pad_new" Create a new padlist, updating the global variables for the currently-compiling padlist to point to the new padlist. The following flags can be \s-1OR\s0'ed together: .Sp .Vb 3 \& padnew_CLONE this pad is for a cloned CV \& padnew_SAVE save old globals on the save stack \& padnew_SAVESUB also save extra stuff for start of sub \& \& PADLIST* pad_new(int flags) .Ve .IP "PL_comppad" 8 .IX Xref "PL_comppad" .IX Item "PL_comppad" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp During compilation, this points to the array containing the values part of the pad for the currently-compiling code. (At runtime a \s-1CV\s0 may have many such value arrays; at compile time just one is constructed.) At runtime, this points to the array containing the currently-relevant values for the pad for the currently-executing code. .IP "PL_comppad_name" 8 .IX Xref "PL_comppad_name" .IX Item "PL_comppad_name" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp During compilation, this points to the array containing the names part of the pad for the currently-compiling code. .IP "PL_curpad" 8 .IX Xref "PL_curpad" .IX Item "PL_curpad" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Points directly to the body of the \*(L"PL_comppad\*(R" array. (I.e., this is \f(CW\*(C`PadARRAY(PL_comppad)\*(C'\fR.) .SH "Per-Interpreter Variables" .IX Header "Per-Interpreter Variables" .IP "PL_curcop" 8 .IX Xref "PL_curcop" .IX Item "PL_curcop" The currently active \s-1COP\s0 (control op) roughly representing the current statement in the source. .Sp .Vb 1 \& COP* PL_curcop .Ve .IP "PL_curstash" 8 .IX Xref "PL_curstash" .IX Item "PL_curstash" The stash for the package code will be compiled into. .Sp .Vb 1 \& HV* PL_curstash .Ve .IP "PL_defgv" 8 .IX Xref "PL_defgv" .IX Item "PL_defgv" The \s-1GV\s0 representing \f(CW*_\fR. Useful for access to \f(CW$_\fR. .Sp .Vb 1 \& GV * PL_defgv .Ve .IP "PL_exit_flags" 8 .IX Xref "PL_exit_flags" .IX Item "PL_exit_flags" Contains flags controlling perl's behaviour on \fBexit()\fR: .RS 8 .IP "\(bu" 4 \&\f(CW\*(C`PERL_EXIT_DESTRUCT_END\*(C'\fR .Sp If set, \s-1END\s0 blocks are executed when the interpreter is destroyed. This is normally set by perl itself after the interpreter is constructed. .IP "\(bu" 4 \&\f(CW\*(C`PERL_EXIT_ABORT\*(C'\fR .Sp Call \f(CW\*(C`abort()\*(C'\fR on exit. This is used internally by perl itself to abort if exit is called while processing exit. .IP "\(bu" 4 \&\f(CW\*(C`PERL_EXIT_WARN\*(C'\fR .Sp Warn on exit. .IP "\(bu" 4 \&\f(CW\*(C`PERL_EXIT_EXPECTED\*(C'\fR .Sp Set by the \*(L"exit\*(R" in perlfunc operator. .RE .RS 8 .Sp .Vb 1 \& U8 PL_exit_flags .Ve .RE .IP "PL_modglobal" 8 .IX Xref "PL_modglobal" .IX Item "PL_modglobal" \&\f(CW\*(C`PL_modglobal\*(C'\fR is a general purpose, interpreter global \s-1HV\s0 for use by extensions that need to keep information on a per-interpreter basis. In a pinch, it can also be used as a symbol table for extensions to share data among each other. It is a good idea to use keys prefixed by the package name of the extension that owns the data. .Sp .Vb 1 \& HV* PL_modglobal .Ve .IP "PL_na" 8 .IX Xref "PL_na" .IX Item "PL_na" A convenience variable which is typically used with \f(CW\*(C`SvPV\*(C'\fR when one doesn't care about the length of the string. It is usually more efficient to either declare a local variable and use that instead or to use the \&\f(CW\*(C`SvPV_nolen\*(C'\fR macro. .Sp .Vb 1 \& STRLEN PL_na .Ve .IP "PL_opfreehook" 8 .IX Xref "PL_opfreehook" .IX Item "PL_opfreehook" When non\-\f(CW\*(C`NULL\*(C'\fR, the function pointed by this variable will be called each time an \s-1OP\s0 is freed with the corresponding \s-1OP\s0 as the argument. This allows extensions to free any extra attribute they have locally attached to an \s-1OP.\s0 It is also assured to first fire for the parent \s-1OP\s0 and then for its kids. .Sp When you replace this variable, it is considered a good practice to store the possibly previously installed hook and that you recall it inside your own. .Sp .Vb 1 \& Perl_ophook_t PL_opfreehook .Ve .IP "PL_peepp" 8 .IX Xref "PL_peepp" .IX Item "PL_peepp" Pointer to the per-subroutine peephole optimiser. This is a function that gets called at the end of compilation of a Perl subroutine (or equivalently independent piece of Perl code) to perform fixups of some ops and to perform small-scale optimisations. The function is called once for each subroutine that is compiled, and is passed, as sole parameter, a pointer to the op that is the entry point to the subroutine. It modifies the op tree in place. .Sp The peephole optimiser should never be completely replaced. Rather, add code to it by wrapping the existing optimiser. The basic way to do this can be seen in \*(L"Compile pass 3: peephole optimization\*(R" in perlguts. If the new code wishes to operate on ops throughout the subroutine's structure, rather than just at the top level, it is likely to be more convenient to wrap the \*(L"PL_rpeepp\*(R" hook. .Sp .Vb 1 \& peep_t PL_peepp .Ve .IP "PL_perl_destruct_level" 8 .IX Xref "PL_perl_destruct_level" .IX Item "PL_perl_destruct_level" This value may be set when embedding for full cleanup. .Sp Possible values: .RS 8 .IP "\(bu" 4 0 \- none .IP "\(bu" 4 1 \- full .IP "\(bu" 4 2 or greater \- full with checks. .RE .RS 8 .Sp If \f(CW$ENV{PERL_DESTRUCT_LEVEL}\fR is set to an integer greater than the value of \f(CW\*(C`PL_perl_destruct_level\*(C'\fR its value is used instead. .Sp .Vb 1 \& signed char PL_perl_destruct_level .Ve .RE .IP "PL_rpeepp" 8 .IX Xref "PL_rpeepp" .IX Item "PL_rpeepp" Pointer to the recursive peephole optimiser. This is a function that gets called at the end of compilation of a Perl subroutine (or equivalently independent piece of Perl code) to perform fixups of some ops and to perform small-scale optimisations. The function is called once for each chain of ops linked through their \f(CW\*(C`op_next\*(C'\fR fields; it is recursively called to handle each side chain. It is passed, as sole parameter, a pointer to the op that is at the head of the chain. It modifies the op tree in place. .Sp The peephole optimiser should never be completely replaced. Rather, add code to it by wrapping the existing optimiser. The basic way to do this can be seen in \*(L"Compile pass 3: peephole optimization\*(R" in perlguts. If the new code wishes to operate only on ops at a subroutine's top level, rather than throughout the structure, it is likely to be more convenient to wrap the \*(L"PL_peepp\*(R" hook. .Sp .Vb 1 \& peep_t PL_rpeepp .Ve .IP "PL_runops" 8 .IX Xref "PL_runops" .IX Item "PL_runops" See \*(L"Pluggable runops\*(R" in perlguts. .Sp .Vb 1 \& runops_proc_t PL_runops .Ve .IP "PL_sv_no" 8 .IX Xref "PL_sv_no" .IX Item "PL_sv_no" This is the \f(CW\*(C`false\*(C'\fR \s-1SV.\s0 See \f(CW"PL_sv_yes"\fR. Always refer to this as \&\f(CW&PL_sv_no\fR. .Sp .Vb 1 \& SV PL_sv_no .Ve .IP "PL_sv_undef" 8 .IX Xref "PL_sv_undef" .IX Item "PL_sv_undef" This is the \f(CW\*(C`undef\*(C'\fR \s-1SV.\s0 Always refer to this as \f(CW&PL_sv_undef\fR. .Sp .Vb 1 \& SV PL_sv_undef .Ve .IP "PL_sv_yes" 8 .IX Xref "PL_sv_yes" .IX Item "PL_sv_yes" This is the \f(CW\*(C`true\*(C'\fR \s-1SV.\s0 See \f(CW"PL_sv_no"\fR. Always refer to this as \&\f(CW&PL_sv_yes\fR. .Sp .Vb 1 \& SV PL_sv_yes .Ve .IP "PL_sv_zero" 8 .IX Xref "PL_sv_zero" .IX Item "PL_sv_zero" This readonly \s-1SV\s0 has a zero numeric value and a \f(CW"0"\fR string value. It's similar to \f(CW"PL_sv_no"\fR except for its string value. Can be used as a cheap alternative to \f(CWmXPUSHi(0)\fR for example. Always refer to this as \&\f(CW&PL_sv_zero\fR. Introduced in 5.28. .Sp .Vb 1 \& SV PL_sv_zero .Ve .SH "REGEXP Functions" .IX Header "REGEXP Functions" .IP "SvRX" 8 .IX Xref "SvRX" .IX Item "SvRX" Convenience macro to get the \s-1REGEXP\s0 from a \s-1SV.\s0 This is approximately equivalent to the following snippet: .Sp .Vb 6 \& if (SvMAGICAL(sv)) \& mg_get(sv); \& if (SvROK(sv)) \& sv = MUTABLE_SV(SvRV(sv)); \& if (SvTYPE(sv) == SVt_REGEXP) \& return (REGEXP*) sv; .Ve .Sp \&\f(CW\*(C`NULL\*(C'\fR will be returned if a REGEXP* is not found. .Sp .Vb 1 \& REGEXP * SvRX(SV *sv) .Ve .IP "SvRXOK" 8 .IX Xref "SvRXOK" .IX Item "SvRXOK" Returns a boolean indicating whether the \s-1SV\s0 (or the one it references) is a \s-1REGEXP.\s0 .Sp If you want to do something with the REGEXP* later use SvRX instead and check for \s-1NULL.\s0 .Sp .Vb 1 \& bool SvRXOK(SV* sv) .Ve .SH "Stack Manipulation Macros" .IX Header "Stack Manipulation Macros" .IP "dMARK" 8 .IX Xref "dMARK" .IX Item "dMARK" Declare a stack marker variable, \f(CW\*(C`mark\*(C'\fR, for the \s-1XSUB.\s0 See \f(CW"MARK"\fR and \&\f(CW"dORIGMARK"\fR. .Sp .Vb 1 \& dMARK; .Ve .IP "dORIGMARK" 8 .IX Xref "dORIGMARK" .IX Item "dORIGMARK" Saves the original stack mark for the \s-1XSUB.\s0 See \f(CW"ORIGMARK"\fR. .Sp .Vb 1 \& dORIGMARK; .Ve .IP "dSP" 8 .IX Xref "dSP" .IX Item "dSP" Declares a local copy of perl's stack pointer for the \s-1XSUB,\s0 available via the \f(CW\*(C`SP\*(C'\fR macro. See \f(CW"SP"\fR. .Sp .Vb 1 \& dSP; .Ve .IP "\s-1EXTEND\s0" 8 .IX Xref "EXTEND" .IX Item "EXTEND" Used to extend the argument stack for an \s-1XSUB\s0's return values. Once used, guarantees that there is room for at least \f(CW\*(C`nitems\*(C'\fR to be pushed onto the stack. .Sp .Vb 1 \& void EXTEND(SP, SSize_t nitems) .Ve .IP "\s-1MARK\s0" 8 .IX Xref "MARK" .IX Item "MARK" Stack marker variable for the \s-1XSUB.\s0 See \f(CW"dMARK"\fR. .IP "mPUSHi" 8 .IX Xref "mPUSHi" .IX Item "mPUSHi" Push an integer onto the stack. The stack must have room for this element. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"PUSHi"\fR, \f(CW"mXPUSHi"\fR and \f(CW"XPUSHi"\fR. .Sp .Vb 1 \& void mPUSHi(IV iv) .Ve .IP "mPUSHn" 8 .IX Xref "mPUSHn" .IX Item "mPUSHn" Push a double onto the stack. The stack must have room for this element. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"PUSHn"\fR, \f(CW"mXPUSHn"\fR and \f(CW"XPUSHn"\fR. .Sp .Vb 1 \& void mPUSHn(NV nv) .Ve .IP "mPUSHp" 8 .IX Xref "mPUSHp" .IX Item "mPUSHp" Push a string onto the stack. The stack must have room for this element. The \f(CW\*(C`len\*(C'\fR indicates the length of the string. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"PUSHp"\fR, \f(CW"mXPUSHp"\fR and \f(CW"XPUSHp"\fR. .Sp .Vb 1 \& void mPUSHp(char* str, STRLEN len) .Ve .IP "mPUSHs" 8 .IX Xref "mPUSHs" .IX Item "mPUSHs" Push an \s-1SV\s0 onto the stack and mortalizes the \s-1SV.\s0 The stack must have room for this element. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"PUSHs"\fR and \&\f(CW"mXPUSHs"\fR. .Sp .Vb 1 \& void mPUSHs(SV* sv) .Ve .IP "mPUSHu" 8 .IX Xref "mPUSHu" .IX Item "mPUSHu" Push an unsigned integer onto the stack. The stack must have room for this element. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"PUSHu"\fR, \f(CW"mXPUSHu"\fR and \&\f(CW"XPUSHu"\fR. .Sp .Vb 1 \& void mPUSHu(UV uv) .Ve .IP "mXPUSHi" 8 .IX Xref "mXPUSHi" .IX Item "mXPUSHi" Push an integer onto the stack, extending the stack if necessary. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"XPUSHi"\fR, \f(CW"mPUSHi"\fR and \f(CW"PUSHi"\fR. .Sp .Vb 1 \& void mXPUSHi(IV iv) .Ve .IP "mXPUSHn" 8 .IX Xref "mXPUSHn" .IX Item "mXPUSHn" Push a double onto the stack, extending the stack if necessary. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"XPUSHn"\fR, \f(CW"mPUSHn"\fR and \f(CW"PUSHn"\fR. .Sp .Vb 1 \& void mXPUSHn(NV nv) .Ve .IP "mXPUSHp" 8 .IX Xref "mXPUSHp" .IX Item "mXPUSHp" Push a string onto the stack, extending the stack if necessary. The \f(CW\*(C`len\*(C'\fR indicates the length of the string. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \&\f(CW"XPUSHp"\fR, \f(CW\*(C`mPUSHp\*(C'\fR and \f(CW\*(C`PUSHp\*(C'\fR. .Sp .Vb 1 \& void mXPUSHp(char* str, STRLEN len) .Ve .IP "mXPUSHs" 8 .IX Xref "mXPUSHs" .IX Item "mXPUSHs" Push an \s-1SV\s0 onto the stack, extending the stack if necessary and mortalizes the \s-1SV.\s0 Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"XPUSHs"\fR and \f(CW"mPUSHs"\fR. .Sp .Vb 1 \& void mXPUSHs(SV* sv) .Ve .IP "mXPUSHu" 8 .IX Xref "mXPUSHu" .IX Item "mXPUSHu" Push an unsigned integer onto the stack, extending the stack if necessary. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"XPUSHu"\fR, \f(CW"mPUSHu"\fR and \f(CW"PUSHu"\fR. .Sp .Vb 1 \& void mXPUSHu(UV uv) .Ve .IP "\s-1ORIGMARK\s0" 8 .IX Xref "ORIGMARK" .IX Item "ORIGMARK" The original stack mark for the \s-1XSUB.\s0 See \f(CW"dORIGMARK"\fR. .IP "POPi" 8 .IX Xref "POPi" .IX Item "POPi" Pops an integer off the stack. .Sp .Vb 1 \& IV POPi .Ve .IP "POPl" 8 .IX Xref "POPl" .IX Item "POPl" Pops a long off the stack. .Sp .Vb 1 \& long POPl .Ve .IP "POPn" 8 .IX Xref "POPn" .IX Item "POPn" Pops a double off the stack. .Sp .Vb 1 \& NV POPn .Ve .IP "POPp" 8 .IX Xref "POPp" .IX Item "POPp" Pops a string off the stack. .Sp .Vb 1 \& char* POPp .Ve .IP "POPpbytex" 8 .IX Xref "POPpbytex" .IX Item "POPpbytex" Pops a string off the stack which must consist of bytes i.e. characters < 256. .Sp .Vb 1 \& char* POPpbytex .Ve .IP "POPpx" 8 .IX Xref "POPpx" .IX Item "POPpx" Pops a string off the stack. Identical to POPp. There are two names for historical reasons. .Sp .Vb 1 \& char* POPpx .Ve .IP "POPs" 8 .IX Xref "POPs" .IX Item "POPs" Pops an \s-1SV\s0 off the stack. .Sp .Vb 1 \& SV* POPs .Ve .IP "POPu" 8 .IX Xref "POPu" .IX Item "POPu" Pops an unsigned integer off the stack. .Sp .Vb 1 \& UV POPu .Ve .IP "POPul" 8 .IX Xref "POPul" .IX Item "POPul" Pops an unsigned long off the stack. .Sp .Vb 1 \& long POPul .Ve .IP "PUSHi" 8 .IX Xref "PUSHi" .IX Item "PUSHi" Push an integer onto the stack. The stack must have room for this element. Handles 'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \f(CW"mPUSHi"\fR instead. See also \f(CW"XPUSHi"\fR and \f(CW"mXPUSHi"\fR. .Sp .Vb 1 \& void PUSHi(IV iv) .Ve .IP "\s-1PUSHMARK\s0" 8 .IX Xref "PUSHMARK" .IX Item "PUSHMARK" Opening bracket for arguments on a callback. See \f(CW"PUTBACK"\fR and perlcall. .Sp .Vb 1 \& void PUSHMARK(SP) .Ve .IP "PUSHmortal" 8 .IX Xref "PUSHmortal" .IX Item "PUSHmortal" Push a new mortal \s-1SV\s0 onto the stack. The stack must have room for this element. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"PUSHs"\fR, \f(CW"XPUSHmortal"\fR and \&\f(CW"XPUSHs"\fR. .Sp .Vb 1 \& void PUSHmortal .Ve .IP "PUSHn" 8 .IX Xref "PUSHn" .IX Item "PUSHn" Push a double onto the stack. The stack must have room for this element. Handles 'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \f(CW"mPUSHn"\fR instead. See also \f(CW"XPUSHn"\fR and \f(CW"mXPUSHn"\fR. .Sp .Vb 1 \& void PUSHn(NV nv) .Ve .IP "PUSHp" 8 .IX Xref "PUSHp" .IX Item "PUSHp" Push a string onto the stack. The stack must have room for this element. The \f(CW\*(C`len\*(C'\fR indicates the length of the string. Handles 'set' magic. Uses \&\f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \&\f(CW"mPUSHp"\fR instead. See also \f(CW"XPUSHp"\fR and \f(CW"mXPUSHp"\fR. .Sp .Vb 1 \& void PUSHp(char* str, STRLEN len) .Ve .IP "PUSHs" 8 .IX Xref "PUSHs" .IX Item "PUSHs" Push an \s-1SV\s0 onto the stack. The stack must have room for this element. Does not handle 'set' magic. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \&\f(CW"PUSHmortal"\fR, \f(CW"XPUSHs"\fR, and \f(CW"XPUSHmortal"\fR. .Sp .Vb 1 \& void PUSHs(SV* sv) .Ve .IP "PUSHu" 8 .IX Xref "PUSHu" .IX Item "PUSHu" Push an unsigned integer onto the stack. The stack must have room for this element. Handles 'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \f(CW"mPUSHu"\fR instead. See also \&\f(CW"XPUSHu"\fR and \f(CW"mXPUSHu"\fR. .Sp .Vb 1 \& void PUSHu(UV uv) .Ve .IP "\s-1PUTBACK\s0" 8 .IX Xref "PUTBACK" .IX Item "PUTBACK" Closing bracket for \s-1XSUB\s0 arguments. This is usually handled by \f(CW\*(C`xsubpp\*(C'\fR. See \f(CW"PUSHMARK"\fR and perlcall for other uses. .Sp .Vb 1 \& PUTBACK; .Ve .IP "\s-1SP\s0" 8 .IX Xref "SP" .IX Item "SP" Stack pointer. This is usually handled by \f(CW\*(C`xsubpp\*(C'\fR. See \f(CW"dSP"\fR and \&\f(CW\*(C`SPAGAIN\*(C'\fR. .IP "\s-1SPAGAIN\s0" 8 .IX Xref "SPAGAIN" .IX Item "SPAGAIN" Refetch the stack pointer. Used after a callback. See perlcall. .Sp .Vb 1 \& SPAGAIN; .Ve .IP "XPUSHi" 8 .IX Xref "XPUSHi" .IX Item "XPUSHi" Push an integer onto the stack, extending the stack if necessary. Handles \&'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \f(CW"mXPUSHi"\fR instead. See also \f(CW"PUSHi"\fR and \&\f(CW"mPUSHi"\fR. .Sp .Vb 1 \& void XPUSHi(IV iv) .Ve .IP "XPUSHmortal" 8 .IX Xref "XPUSHmortal" .IX Item "XPUSHmortal" Push a new mortal \s-1SV\s0 onto the stack, extending the stack if necessary. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"XPUSHs"\fR, \f(CW"PUSHmortal"\fR and \&\f(CW"PUSHs"\fR. .Sp .Vb 1 \& void XPUSHmortal .Ve .IP "XPUSHn" 8 .IX Xref "XPUSHn" .IX Item "XPUSHn" Push a double onto the stack, extending the stack if necessary. Handles \&'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \f(CW"mXPUSHn"\fR instead. See also \f(CW"PUSHn"\fR and \&\f(CW"mPUSHn"\fR. .Sp .Vb 1 \& void XPUSHn(NV nv) .Ve .IP "XPUSHp" 8 .IX Xref "XPUSHp" .IX Item "XPUSHp" Push a string onto the stack, extending the stack if necessary. The \f(CW\*(C`len\*(C'\fR indicates the length of the string. Handles 'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \&\f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \&\f(CW"mXPUSHp"\fR instead. See also \f(CW"PUSHp"\fR and \f(CW"mPUSHp"\fR. .Sp .Vb 1 \& void XPUSHp(char* str, STRLEN len) .Ve .IP "XPUSHs" 8 .IX Xref "XPUSHs" .IX Item "XPUSHs" Push an \s-1SV\s0 onto the stack, extending the stack if necessary. Does not handle 'set' magic. Does not use \f(CW\*(C`TARG\*(C'\fR. See also \f(CW"XPUSHmortal"\fR, \&\f(CW\*(C`PUSHs\*(C'\fR and \f(CW\*(C`PUSHmortal\*(C'\fR. .Sp .Vb 1 \& void XPUSHs(SV* sv) .Ve .IP "XPUSHu" 8 .IX Xref "XPUSHu" .IX Item "XPUSHu" Push an unsigned integer onto the stack, extending the stack if necessary. Handles 'set' magic. Uses \f(CW\*(C`TARG\*(C'\fR, so \f(CW\*(C`dTARGET\*(C'\fR or \f(CW\*(C`dXSTARG\*(C'\fR should be called to declare it. Do not call multiple \f(CW\*(C`TARG\*(C'\fR\-oriented macros to return lists from \s-1XSUB\s0's \- see \f(CW"mXPUSHu"\fR instead. See also \f(CW"PUSHu"\fR and \&\f(CW"mPUSHu"\fR. .Sp .Vb 1 \& void XPUSHu(UV uv) .Ve .IP "\s-1XSRETURN\s0" 8 .IX Xref "XSRETURN" .IX Item "XSRETURN" Return from \s-1XSUB,\s0 indicating number of items on the stack. This is usually handled by \f(CW\*(C`xsubpp\*(C'\fR. .Sp .Vb 1 \& void XSRETURN(int nitems) .Ve .IP "\s-1XSRETURN_EMPTY\s0" 8 .IX Xref "XSRETURN_EMPTY" .IX Item "XSRETURN_EMPTY" Return an empty list from an \s-1XSUB\s0 immediately. .Sp .Vb 1 \& XSRETURN_EMPTY; .Ve .IP "\s-1XSRETURN_IV\s0" 8 .IX Xref "XSRETURN_IV" .IX Item "XSRETURN_IV" Return an integer from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mIV\*(C'\fR. .Sp .Vb 1 \& void XSRETURN_IV(IV iv) .Ve .IP "\s-1XSRETURN_NO\s0" 8 .IX Xref "XSRETURN_NO" .IX Item "XSRETURN_NO" Return \f(CW&PL_sv_no\fR from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mNO\*(C'\fR. .Sp .Vb 1 \& XSRETURN_NO; .Ve .IP "\s-1XSRETURN_NV\s0" 8 .IX Xref "XSRETURN_NV" .IX Item "XSRETURN_NV" Return a double from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mNV\*(C'\fR. .Sp .Vb 1 \& void XSRETURN_NV(NV nv) .Ve .IP "\s-1XSRETURN_PV\s0" 8 .IX Xref "XSRETURN_PV" .IX Item "XSRETURN_PV" Return a copy of a string from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mPV\*(C'\fR. .Sp .Vb 1 \& void XSRETURN_PV(char* str) .Ve .IP "\s-1XSRETURN_UNDEF\s0" 8 .IX Xref "XSRETURN_UNDEF" .IX Item "XSRETURN_UNDEF" Return \f(CW&PL_sv_undef\fR from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mUNDEF\*(C'\fR. .Sp .Vb 1 \& XSRETURN_UNDEF; .Ve .IP "\s-1XSRETURN_UV\s0" 8 .IX Xref "XSRETURN_UV" .IX Item "XSRETURN_UV" Return an integer from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mUV\*(C'\fR. .Sp .Vb 1 \& void XSRETURN_UV(IV uv) .Ve .IP "\s-1XSRETURN_YES\s0" 8 .IX Xref "XSRETURN_YES" .IX Item "XSRETURN_YES" Return \f(CW&PL_sv_yes\fR from an \s-1XSUB\s0 immediately. Uses \f(CW\*(C`XST_mYES\*(C'\fR. .Sp .Vb 1 \& XSRETURN_YES; .Ve .IP "XST_mIV" 8 .IX Xref "XST_mIV" .IX Item "XST_mIV" Place an integer into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. The value is stored in a new mortal \s-1SV.\s0 .Sp .Vb 1 \& void XST_mIV(int pos, IV iv) .Ve .IP "XST_mNO" 8 .IX Xref "XST_mNO" .IX Item "XST_mNO" Place \f(CW&PL_sv_no\fR into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. .Sp .Vb 1 \& void XST_mNO(int pos) .Ve .IP "XST_mNV" 8 .IX Xref "XST_mNV" .IX Item "XST_mNV" Place a double into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. The value is stored in a new mortal \s-1SV.\s0 .Sp .Vb 1 \& void XST_mNV(int pos, NV nv) .Ve .IP "XST_mPV" 8 .IX Xref "XST_mPV" .IX Item "XST_mPV" Place a copy of a string into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. The value is stored in a new mortal \s-1SV.\s0 .Sp .Vb 1 \& void XST_mPV(int pos, char* str) .Ve .IP "XST_mUNDEF" 8 .IX Xref "XST_mUNDEF" .IX Item "XST_mUNDEF" Place \f(CW&PL_sv_undef\fR into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. .Sp .Vb 1 \& void XST_mUNDEF(int pos) .Ve .IP "XST_mUV" 8 .IX Xref "XST_mUV" .IX Item "XST_mUV" Place an unsigned integer into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. The value is stored in a new mortal \s-1SV.\s0 .Sp .Vb 1 \& void XST_mUV(int pos, UV uv) .Ve .IP "XST_mYES" 8 .IX Xref "XST_mYES" .IX Item "XST_mYES" Place \f(CW&PL_sv_yes\fR into the specified position \f(CW\*(C`pos\*(C'\fR on the stack. .Sp .Vb 1 \& void XST_mYES(int pos) .Ve .SH "SV Flags" .IX Header "SV Flags" .IP "SVt_IV" 8 .IX Xref "SVt_IV" .IX Item "SVt_IV" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_NULL" 8 .IX Xref "SVt_NULL" .IX Item "SVt_NULL" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_NV" 8 .IX Xref "SVt_NV" .IX Item "SVt_NV" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_PV" 8 .IX Xref "SVt_PV" .IX Item "SVt_PV" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_PVAV" 8 .IX Xref "SVt_PVAV" .IX Item "SVt_PVAV" Type flag for arrays. See \*(L"svtype\*(R". .IP "SVt_PVCV" 8 .IX Xref "SVt_PVCV" .IX Item "SVt_PVCV" Type flag for subroutines. See \*(L"svtype\*(R". .IP "SVt_PVFM" 8 .IX Xref "SVt_PVFM" .IX Item "SVt_PVFM" Type flag for formats. See \*(L"svtype\*(R". .IP "SVt_PVGV" 8 .IX Xref "SVt_PVGV" .IX Item "SVt_PVGV" Type flag for typeglobs. See \*(L"svtype\*(R". .IP "SVt_PVHV" 8 .IX Xref "SVt_PVHV" .IX Item "SVt_PVHV" Type flag for hashes. See \*(L"svtype\*(R". .IP "SVt_PVIO" 8 .IX Xref "SVt_PVIO" .IX Item "SVt_PVIO" Type flag for I/O objects. See \*(L"svtype\*(R". .IP "SVt_PVIV" 8 .IX Xref "SVt_PVIV" .IX Item "SVt_PVIV" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_PVLV" 8 .IX Xref "SVt_PVLV" .IX Item "SVt_PVLV" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_PVMG" 8 .IX Xref "SVt_PVMG" .IX Item "SVt_PVMG" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_PVNV" 8 .IX Xref "SVt_PVNV" .IX Item "SVt_PVNV" Type flag for scalars. See \*(L"svtype\*(R". .IP "SVt_REGEXP" 8 .IX Xref "SVt_REGEXP" .IX Item "SVt_REGEXP" Type flag for regular expressions. See \*(L"svtype\*(R". .IP "svtype" 8 .IX Xref "svtype" .IX Item "svtype" An enum of flags for Perl types. These are found in the file \fIsv.h\fR in the \f(CW\*(C`svtype\*(C'\fR enum. Test these flags with the \f(CW\*(C`SvTYPE\*(C'\fR macro. .Sp The types are: .Sp .Vb 10 \& SVt_NULL \& SVt_IV \& SVt_NV \& SVt_RV \& SVt_PV \& SVt_PVIV \& SVt_PVNV \& SVt_PVMG \& SVt_INVLIST \& SVt_REGEXP \& SVt_PVGV \& SVt_PVLV \& SVt_PVAV \& SVt_PVHV \& SVt_PVCV \& SVt_PVFM \& SVt_PVIO .Ve .Sp These are most easily explained from the bottom up. .Sp \&\f(CW\*(C`SVt_PVIO\*(C'\fR is for I/O objects, \f(CW\*(C`SVt_PVFM\*(C'\fR for formats, \f(CW\*(C`SVt_PVCV\*(C'\fR for subroutines, \f(CW\*(C`SVt_PVHV\*(C'\fR for hashes and \f(CW\*(C`SVt_PVAV\*(C'\fR for arrays. .Sp All the others are scalar types, that is, things that can be bound to a \&\f(CW\*(C`$\*(C'\fR variable. For these, the internal types are mostly orthogonal to types in the Perl language. .Sp Hence, checking \f(CW\*(C`SvTYPE(sv) < SVt_PVAV\*(C'\fR is the best way to see whether something is a scalar. .Sp \&\f(CW\*(C`SVt_PVGV\*(C'\fR represents a typeglob. If \f(CW\*(C`!SvFAKE(sv)\*(C'\fR, then it is a real, incoercible typeglob. If \f(CW\*(C`SvFAKE(sv)\*(C'\fR, then it is a scalar to which a typeglob has been assigned. Assigning to it again will stop it from being a typeglob. \f(CW\*(C`SVt_PVLV\*(C'\fR represents a scalar that delegates to another scalar behind the scenes. It is used, e.g., for the return value of \f(CW\*(C`substr\*(C'\fR and for tied hash and array elements. It can hold any scalar value, including a typeglob. \f(CW\*(C`SVt_REGEXP\*(C'\fR is for regular expressions. \f(CW\*(C`SVt_INVLIST\*(C'\fR is for Perl core internal use only. .Sp \&\f(CW\*(C`SVt_PVMG\*(C'\fR represents a \*(L"normal\*(R" scalar (not a typeglob, regular expression, or delegate). Since most scalars do not need all the internal fields of a \&\s-1PVMG,\s0 we save memory by allocating smaller structs when possible. All the other types are just simpler forms of \f(CW\*(C`SVt_PVMG\*(C'\fR, with fewer internal fields. \&\f(CW\*(C`SVt_NULL\*(C'\fR can only hold undef. \f(CW\*(C`SVt_IV\*(C'\fR can hold undef, an integer, or a reference. (\f(CW\*(C`SVt_RV\*(C'\fR is an alias for \f(CW\*(C`SVt_IV\*(C'\fR, which exists for backward compatibility.) \f(CW\*(C`SVt_NV\*(C'\fR can hold any of those or a double. \f(CW\*(C`SVt_PV\*(C'\fR can only hold \f(CW\*(C`undef\*(C'\fR or a string. \f(CW\*(C`SVt_PVIV\*(C'\fR is a superset of \f(CW\*(C`SVt_PV\*(C'\fR and \f(CW\*(C`SVt_IV\*(C'\fR. \&\f(CW\*(C`SVt_PVNV\*(C'\fR is similar. \f(CW\*(C`SVt_PVMG\*(C'\fR can hold anything \f(CW\*(C`SVt_PVNV\*(C'\fR can hold, but it can, but does not have to, be blessed or magical. .SH "SV Manipulation Functions" .IX Header "SV Manipulation Functions" .IP "boolSV" 8 .IX Xref "boolSV" .IX Item "boolSV" Returns a true \s-1SV\s0 if \f(CW\*(C`b\*(C'\fR is a true value, or a false \s-1SV\s0 if \f(CW\*(C`b\*(C'\fR is 0. .Sp See also \f(CW"PL_sv_yes"\fR and \f(CW"PL_sv_no"\fR. .Sp .Vb 1 \& SV * boolSV(bool b) .Ve .IP "croak_xs_usage" 8 .IX Xref "croak_xs_usage" .IX Item "croak_xs_usage" A specialised variant of \f(CW\*(C`croak()\*(C'\fR for emitting the usage message for xsubs .Sp .Vb 1 \& croak_xs_usage(cv, "eee_yow"); .Ve .Sp works out the package name and subroutine name from \f(CW\*(C`cv\*(C'\fR, and then calls \&\f(CW\*(C`croak()\*(C'\fR. Hence if \f(CW\*(C`cv\*(C'\fR is \f(CW&ouch::awk\fR, it would call \f(CW\*(C`croak\*(C'\fR as: .Sp .Vb 2 \& Perl_croak(aTHX_ "Usage: %" SVf "::%" SVf "(%s)", "ouch" "awk", \& "eee_yow"); \& \& void croak_xs_usage(const CV *const cv, \& const char *const params) .Ve .IP "get_sv" 8 .IX Xref "get_sv" .IX Item "get_sv" Returns the \s-1SV\s0 of the specified Perl scalar. \f(CW\*(C`flags\*(C'\fR are passed to \&\f(CW\*(C`gv_fetchpv\*(C'\fR. If \f(CW\*(C`GV_ADD\*(C'\fR is set and the Perl variable does not exist then it will be created. If \f(CW\*(C`flags\*(C'\fR is zero and the variable does not exist then \s-1NULL\s0 is returned. .Sp \&\s-1NOTE:\s0 the perl_ form of this function is deprecated. .Sp .Vb 1 \& SV* get_sv(const char *name, I32 flags) .Ve .IP "looks_like_number" 8 .IX Xref "looks_like_number" .IX Item "looks_like_number" Test if the content of an \s-1SV\s0 looks like a number (or is a number). \&\f(CW\*(C`Inf\*(C'\fR and \f(CW\*(C`Infinity\*(C'\fR are treated as numbers (so will not issue a non-numeric warning), even if your \f(CW\*(C`atof()\*(C'\fR doesn't grok them. Get-magic is ignored. .Sp .Vb 1 \& I32 looks_like_number(SV *const sv) .Ve .IP "newRV_inc" 8 .IX Xref "newRV_inc" .IX Item "newRV_inc" Creates an \s-1RV\s0 wrapper for an \s-1SV.\s0 The reference count for the original \s-1SV\s0 is incremented. .Sp .Vb 1 \& SV* newRV_inc(SV* sv) .Ve .IP "newRV_noinc" 8 .IX Xref "newRV_noinc" .IX Item "newRV_noinc" Creates an \s-1RV\s0 wrapper for an \s-1SV.\s0 The reference count for the original \&\s-1SV\s0 is \fBnot\fR incremented. .Sp .Vb 1 \& SV* newRV_noinc(SV *const tmpRef) .Ve .IP "newSV" 8 .IX Xref "newSV" .IX Item "newSV" Creates a new \s-1SV.\s0 A non-zero \f(CW\*(C`len\*(C'\fR parameter indicates the number of bytes of preallocated string space the \s-1SV\s0 should have. An extra byte for a trailing \f(CW\*(C`NUL\*(C'\fR is also reserved. (\f(CW\*(C`SvPOK\*(C'\fR is not set for the \s-1SV\s0 even if string space is allocated.) The reference count for the new \s-1SV\s0 is set to 1. .Sp In 5.9.3, \f(CW\*(C`newSV()\*(C'\fR replaces the older \f(CW\*(C`NEWSV()\*(C'\fR \s-1API,\s0 and drops the first parameter, \fIx\fR, a debug aid which allowed callers to identify themselves. This aid has been superseded by a new build option, \f(CW\*(C`PERL_MEM_LOG\*(C'\fR (see \&\*(L"\s-1PERL_MEM_LOG\*(R"\s0 in perlhacktips). The older \s-1API\s0 is still there for use in \s-1XS\s0 modules supporting older perls. .Sp .Vb 1 \& SV* newSV(const STRLEN len) .Ve .IP "newSVhek" 8 .IX Xref "newSVhek" .IX Item "newSVhek" Creates a new \s-1SV\s0 from the hash key structure. It will generate scalars that point to the shared string table where possible. Returns a new (undefined) \&\s-1SV\s0 if \f(CW\*(C`hek\*(C'\fR is \s-1NULL.\s0 .Sp .Vb 1 \& SV* newSVhek(const HEK *const hek) .Ve .IP "newSViv" 8 .IX Xref "newSViv" .IX Item "newSViv" Creates a new \s-1SV\s0 and copies an integer into it. The reference count for the \&\s-1SV\s0 is set to 1. .Sp .Vb 1 \& SV* newSViv(const IV i) .Ve .IP "newSVnv" 8 .IX Xref "newSVnv" .IX Item "newSVnv" Creates a new \s-1SV\s0 and copies a floating point value into it. The reference count for the \s-1SV\s0 is set to 1. .Sp .Vb 1 \& SV* newSVnv(const NV n) .Ve .IP "newSVpadname" 8 .IX Xref "newSVpadname" .IX Item "newSVpadname" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Creates a new \s-1SV\s0 containing the pad name. .Sp .Vb 1 \& SV* newSVpadname(PADNAME *pn) .Ve .IP "newSVpv" 8 .IX Xref "newSVpv" .IX Item "newSVpv" Creates a new \s-1SV\s0 and copies a string (which may contain \f(CW\*(C`NUL\*(C'\fR (\f(CW\*(C`\e0\*(C'\fR) characters) into it. The reference count for the \&\s-1SV\s0 is set to 1. If \f(CW\*(C`len\*(C'\fR is zero, Perl will compute the length using \&\f(CW\*(C`strlen()\*(C'\fR, (which means if you use this option, that \f(CW\*(C`s\*(C'\fR can't have embedded \&\f(CW\*(C`NUL\*(C'\fR characters and has to have a terminating \f(CW\*(C`NUL\*(C'\fR byte). .Sp This function can cause reliability issues if you are likely to pass in empty strings that are not null terminated, because it will run strlen on the string and potentially run past valid memory. .Sp Using \*(L"newSVpvn\*(R" is a safer alternative for non \f(CW\*(C`NUL\*(C'\fR terminated strings. For string literals use \*(L"newSVpvs\*(R" instead. This function will work fine for \&\f(CW\*(C`NUL\*(C'\fR terminated strings, but if you want to avoid the if statement on whether to call \f(CW\*(C`strlen\*(C'\fR use \f(CW\*(C`newSVpvn\*(C'\fR instead (calling \f(CW\*(C`strlen\*(C'\fR yourself). .Sp .Vb 1 \& SV* newSVpv(const char *const s, const STRLEN len) .Ve .IP "newSVpvf" 8 .IX Xref "newSVpvf" .IX Item "newSVpvf" Creates a new \s-1SV\s0 and initializes it with the string formatted like \&\f(CW\*(C`sv_catpvf\*(C'\fR. .Sp .Vb 1 \& SV* newSVpvf(const char *const pat, ...) .Ve .IP "newSVpvn" 8 .IX Xref "newSVpvn" .IX Item "newSVpvn" Creates a new \s-1SV\s0 and copies a string into it, which may contain \f(CW\*(C`NUL\*(C'\fR characters (\f(CW\*(C`\e0\*(C'\fR) and other binary data. The reference count for the \s-1SV\s0 is set to 1. Note that if \f(CW\*(C`len\*(C'\fR is zero, Perl will create a zero length (Perl) string. You are responsible for ensuring that the source buffer is at least \&\f(CW\*(C`len\*(C'\fR bytes long. If the \f(CW\*(C`buffer\*(C'\fR argument is \s-1NULL\s0 the new \s-1SV\s0 will be undefined. .Sp .Vb 2 \& SV* newSVpvn(const char *const buffer, \& const STRLEN len) .Ve .IP "newSVpvn_flags" 8 .IX Xref "newSVpvn_flags" .IX Item "newSVpvn_flags" Creates a new \s-1SV\s0 and copies a string (which may contain \f(CW\*(C`NUL\*(C'\fR (\f(CW\*(C`\e0\*(C'\fR) characters) into it. The reference count for the \&\s-1SV\s0 is set to 1. Note that if \f(CW\*(C`len\*(C'\fR is zero, Perl will create a zero length string. You are responsible for ensuring that the source string is at least \&\f(CW\*(C`len\*(C'\fR bytes long. If the \f(CW\*(C`s\*(C'\fR argument is \s-1NULL\s0 the new \s-1SV\s0 will be undefined. Currently the only flag bits accepted are \f(CW\*(C`SVf_UTF8\*(C'\fR and \f(CW\*(C`SVs_TEMP\*(C'\fR. If \f(CW\*(C`SVs_TEMP\*(C'\fR is set, then \f(CW\*(C`sv_2mortal()\*(C'\fR is called on the result before returning. If \f(CW\*(C`SVf_UTF8\*(C'\fR is set, \f(CW\*(C`s\*(C'\fR is considered to be in \s-1UTF\-8\s0 and the \&\f(CW\*(C`SVf_UTF8\*(C'\fR flag will be set on the new \s-1SV.\s0 \&\f(CW\*(C`newSVpvn_utf8()\*(C'\fR is a convenience wrapper for this function, defined as .Sp .Vb 2 \& #define newSVpvn_utf8(s, len, u) \e \& newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) \& \& SV* newSVpvn_flags(const char *const s, \& const STRLEN len, \& const U32 flags) .Ve .IP "newSVpvn_share" 8 .IX Xref "newSVpvn_share" .IX Item "newSVpvn_share" Creates a new \s-1SV\s0 with its \f(CW\*(C`SvPVX_const\*(C'\fR 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 \f(CW\*(C`SvIsCOW\*(C'\fR flag (or \f(CW\*(C`READONLY\*(C'\fR and \f(CW\*(C`FAKE\*(C'\fR in 5.16 and earlier). If the \f(CW\*(C`hash\*(C'\fR parameter is non-zero, that value is used; otherwise the hash is computed. The string's hash can later be retrieved from the \s-1SV\s0 with the \f(CW\*(C`SvSHARED_HASH()\*(C'\fR macro. The idea here is that as the string table is used for shared hash keys these strings will have \&\f(CW\*(C`SvPVX_const == HeKEY\*(C'\fR and hash lookup will avoid string compare. .Sp .Vb 1 \& SV* newSVpvn_share(const char* s, I32 len, U32 hash) .Ve .IP "newSVpvn_utf8" 8 .IX Xref "newSVpvn_utf8" .IX Item "newSVpvn_utf8" Creates a new \s-1SV\s0 and copies a string (which may contain \f(CW\*(C`NUL\*(C'\fR (\f(CW\*(C`\e0\*(C'\fR) characters) into it. If \f(CW\*(C`utf8\*(C'\fR is true, calls \&\f(CW\*(C`SvUTF8_on\*(C'\fR on the new \s-1SV.\s0 Implemented as a wrapper around \f(CW\*(C`newSVpvn_flags\*(C'\fR. .Sp .Vb 2 \& SV* newSVpvn_utf8(const char* s, STRLEN len, \& U32 utf8) .Ve .IP "newSVpvs" 8 .IX Xref "newSVpvs" .IX Item "newSVpvs" Like \f(CW\*(C`newSVpvn\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& SV* newSVpvs("literal string") .Ve .IP "newSVpvs_flags" 8 .IX Xref "newSVpvs_flags" .IX Item "newSVpvs_flags" Like \f(CW\*(C`newSVpvn_flags\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& SV* newSVpvs_flags("literal string", U32 flags) .Ve .IP "newSVpv_share" 8 .IX Xref "newSVpv_share" .IX Item "newSVpv_share" Like \f(CW\*(C`newSVpvn_share\*(C'\fR, but takes a \f(CW\*(C`NUL\*(C'\fR\-terminated string instead of a string/length pair. .Sp .Vb 1 \& SV* newSVpv_share(const char* s, U32 hash) .Ve .IP "newSVpvs_share" 8 .IX Xref "newSVpvs_share" .IX Item "newSVpvs_share" Like \f(CW\*(C`newSVpvn_share\*(C'\fR, but takes a literal string instead of a string/length pair and omits the hash parameter. .Sp .Vb 1 \& SV* newSVpvs_share("literal string") .Ve .IP "newSVrv" 8 .IX Xref "newSVrv" .IX Item "newSVrv" Creates a new \s-1SV\s0 for the existing \s-1RV,\s0 \f(CW\*(C`rv\*(C'\fR, to point to. If \f(CW\*(C`rv\*(C'\fR is not an \&\s-1RV\s0 then it will be upgraded to one. If \f(CW\*(C`classname\*(C'\fR is non-null then the new \&\s-1SV\s0 will be blessed in the specified package. The new \s-1SV\s0 is returned and its reference count is 1. The reference count 1 is owned by \f(CW\*(C`rv\*(C'\fR. See also \&\fBnewRV_inc()\fR and \fBnewRV_noinc()\fR for creating a new \s-1RV\s0 properly. .Sp .Vb 2 \& SV* newSVrv(SV *const rv, \& const char *const classname) .Ve .IP "newSVsv" 8 .IX Xref "newSVsv" .IX Item "newSVsv" Creates a new \s-1SV\s0 which is an exact duplicate of the original \s-1SV.\s0 (Uses \f(CW\*(C`sv_setsv\*(C'\fR.) .Sp .Vb 1 \& SV* newSVsv(SV *const old) .Ve .IP "newSVsv_nomg" 8 .IX Xref "newSVsv_nomg" .IX Item "newSVsv_nomg" Like \f(CW\*(C`newSVsv\*(C'\fR but does not process get magic. .Sp .Vb 1 \& SV* newSVsv_nomg(SV *const old) .Ve .IP "newSV_type" 8 .IX Xref "newSV_type" .IX Item "newSV_type" Creates a new \s-1SV,\s0 of the type specified. The reference count for the new \s-1SV\s0 is set to 1. .Sp .Vb 1 \& SV* newSV_type(const svtype type) .Ve .IP "newSVuv" 8 .IX Xref "newSVuv" .IX Item "newSVuv" Creates a new \s-1SV\s0 and copies an unsigned integer into it. The reference count for the \s-1SV\s0 is set to 1. .Sp .Vb 1 \& SV* newSVuv(const UV u) .Ve .IP "sortsv_flags" 8 .IX Xref "sortsv_flags" .IX Item "sortsv_flags" In-place sort an array of \s-1SV\s0 pointers with the given comparison routine, with various SORTf_* flag options. .Sp .Vb 2 \& void sortsv_flags(SV** array, size_t num_elts, \& SVCOMPARE_t cmp, U32 flags) .Ve .IP "sv_2bool" 8 .IX Xref "sv_2bool" .IX Item "sv_2bool" This macro is only used by \f(CW\*(C`sv_true()\*(C'\fR or its macro equivalent, and only if the latter's argument is neither \f(CW\*(C`SvPOK\*(C'\fR, \f(CW\*(C`SvIOK\*(C'\fR nor \f(CW\*(C`SvNOK\*(C'\fR. It calls \f(CW\*(C`sv_2bool_flags\*(C'\fR with the \f(CW\*(C`SV_GMAGIC\*(C'\fR flag. .Sp .Vb 1 \& bool sv_2bool(SV *const sv) .Ve .IP "sv_2bool_flags" 8 .IX Xref "sv_2bool_flags" .IX Item "sv_2bool_flags" This function is only used by \f(CW\*(C`sv_true()\*(C'\fR and friends, and only if the latter's argument is neither \f(CW\*(C`SvPOK\*(C'\fR, \f(CW\*(C`SvIOK\*(C'\fR nor \f(CW\*(C`SvNOK\*(C'\fR. If the flags contain \f(CW\*(C`SV_GMAGIC\*(C'\fR, then it does an \f(CW\*(C`mg_get()\*(C'\fR first. .Sp .Vb 1 \& bool sv_2bool_flags(SV *sv, I32 flags) .Ve .IP "sv_2cv" 8 .IX Xref "sv_2cv" .IX Item "sv_2cv" Using various gambits, try to get a \s-1CV\s0 from an \s-1SV\s0; in addition, try if possible to set \f(CW*st\fR and \f(CW*gvp\fR to the stash and \s-1GV\s0 associated with it. The flags in \f(CW\*(C`lref\*(C'\fR are passed to \f(CW\*(C`gv_fetchsv\*(C'\fR. .Sp .Vb 2 \& CV* sv_2cv(SV* sv, HV **const st, GV **const gvp, \& const I32 lref) .Ve .IP "sv_2io" 8 .IX Xref "sv_2io" .IX Item "sv_2io" Using various gambits, try to get an \s-1IO\s0 from an \s-1SV:\s0 the \s-1IO\s0 slot if its a \&\s-1GV\s0; or the recursive result if we're an \s-1RV\s0; or the \s-1IO\s0 slot of the symbol named after the \s-1PV\s0 if we're a string. .Sp \&'Get' magic is ignored on the \f(CW\*(C`sv\*(C'\fR passed in, but will be called on \&\f(CW\*(C`SvRV(sv)\*(C'\fR if \f(CW\*(C`sv\*(C'\fR is an \s-1RV.\s0 .Sp .Vb 1 \& IO* sv_2io(SV *const sv) .Ve .IP "sv_2iv_flags" 8 .IX Xref "sv_2iv_flags" .IX Item "sv_2iv_flags" Return the integer value of an \s-1SV,\s0 doing any necessary string conversion. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, does an \f(CW\*(C`mg_get()\*(C'\fR first. Normally used via the \f(CW\*(C`SvIV(sv)\*(C'\fR and \f(CW\*(C`SvIVx(sv)\*(C'\fR macros. .Sp .Vb 1 \& IV sv_2iv_flags(SV *const sv, const I32 flags) .Ve .IP "sv_2mortal" 8 .IX Xref "sv_2mortal" .IX Item "sv_2mortal" Marks an existing \s-1SV\s0 as mortal. The \s-1SV\s0 will be destroyed \*(L"soon\*(R", either by an explicit call to \f(CW\*(C`FREETMPS\*(C'\fR, or by an implicit call at places such as statement boundaries. \f(CW\*(C`SvTEMP()\*(C'\fR is turned on which means that the \s-1SV\s0's string buffer can be \*(L"stolen\*(R" if this \s-1SV\s0 is copied. See also \&\f(CW"sv_newmortal"\fR and \f(CW"sv_mortalcopy"\fR. .Sp .Vb 1 \& SV* sv_2mortal(SV *const sv) .Ve .IP "sv_2nv_flags" 8 .IX Xref "sv_2nv_flags" .IX Item "sv_2nv_flags" Return the num value of an \s-1SV,\s0 doing any necessary string or integer conversion. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, does an \f(CW\*(C`mg_get()\*(C'\fR first. Normally used via the \f(CW\*(C`SvNV(sv)\*(C'\fR and \f(CW\*(C`SvNVx(sv)\*(C'\fR macros. .Sp .Vb 1 \& NV sv_2nv_flags(SV *const sv, const I32 flags) .Ve .IP "sv_2pvbyte" 8 .IX Xref "sv_2pvbyte" .IX Item "sv_2pvbyte" Return a pointer to the byte-encoded representation of the \s-1SV,\s0 and set \f(CW*lp\fR to its length. If the \s-1SV\s0 is marked as being encoded as \s-1UTF\-8,\s0 it will downgrade it to a byte string as a side-effect, if possible. If the \s-1SV\s0 cannot be downgraded, this croaks. .Sp Usually accessed via the \f(CW\*(C`SvPVbyte\*(C'\fR macro. .Sp .Vb 1 \& char* sv_2pvbyte(SV *sv, STRLEN *const lp) .Ve .IP "sv_2pvutf8" 8 .IX Xref "sv_2pvutf8" .IX Item "sv_2pvutf8" Return a pointer to the UTF\-8\-encoded representation of the \s-1SV,\s0 and set \f(CW*lp\fR to its length. May cause the \s-1SV\s0 to be upgraded to \s-1UTF\-8\s0 as a side-effect. .Sp Usually accessed via the \f(CW\*(C`SvPVutf8\*(C'\fR macro. .Sp .Vb 1 \& char* sv_2pvutf8(SV *sv, STRLEN *const lp) .Ve .IP "sv_2pv_flags" 8 .IX Xref "sv_2pv_flags" .IX Item "sv_2pv_flags" Returns a pointer to the string value of an \s-1SV,\s0 and sets \f(CW*lp\fR to its length. If flags has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, does an \f(CW\*(C`mg_get()\*(C'\fR first. Coerces \f(CW\*(C`sv\*(C'\fR to a string if necessary. Normally invoked via the \f(CW\*(C`SvPV_flags\*(C'\fR macro. \&\f(CW\*(C`sv_2pv()\*(C'\fR and \f(CW\*(C`sv_2pv_nomg\*(C'\fR usually end up here too. .Sp .Vb 2 \& char* sv_2pv_flags(SV *const sv, STRLEN *const lp, \& const I32 flags) .Ve .IP "sv_2uv_flags" 8 .IX Xref "sv_2uv_flags" .IX Item "sv_2uv_flags" Return the unsigned integer value of an \s-1SV,\s0 doing any necessary string conversion. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, does an \f(CW\*(C`mg_get()\*(C'\fR first. Normally used via the \f(CW\*(C`SvUV(sv)\*(C'\fR and \f(CW\*(C`SvUVx(sv)\*(C'\fR macros. .Sp .Vb 1 \& UV sv_2uv_flags(SV *const sv, const I32 flags) .Ve .IP "sv_backoff" 8 .IX Xref "sv_backoff" .IX Item "sv_backoff" Remove any string offset. You should normally use the \f(CW\*(C`SvOOK_off\*(C'\fR macro wrapper instead. .Sp .Vb 1 \& void sv_backoff(SV *const sv) .Ve .IP "sv_bless" 8 .IX Xref "sv_bless" .IX Item "sv_bless" Blesses an \s-1SV\s0 into a specified package. The \s-1SV\s0 must be an \s-1RV.\s0 The package must be designated by its stash (see \f(CW"gv_stashpv"\fR). The reference count of the \s-1SV\s0 is unaffected. .Sp .Vb 1 \& SV* sv_bless(SV *const sv, HV *const stash) .Ve .IP "sv_catpv" 8 .IX Xref "sv_catpv" .IX Item "sv_catpv" Concatenates the \f(CW\*(C`NUL\*(C'\fR\-terminated string onto the end of the string which is in the \s-1SV.\s0 If the \s-1SV\s0 has the \s-1UTF\-8\s0 status set, then the bytes appended should be valid \s-1UTF\-8.\s0 Handles 'get' magic, but not 'set' magic. See \&\f(CW"sv_catpv_mg"\fR. .Sp .Vb 1 \& void sv_catpv(SV *const sv, const char* ptr) .Ve .IP "sv_catpvf" 8 .IX Xref "sv_catpvf" .IX Item "sv_catpvf" Processes its arguments like \f(CW\*(C`sprintf\*(C'\fR, and appends the formatted output to an \s-1SV.\s0 As with \f(CW\*(C`sv_vcatpvfn\*(C'\fR called with a non-null C\-style variable argument list, argument reordering is not supported. If the appended data contains \*(L"wide\*(R" characters (including, but not limited to, SVs with a \s-1UTF\-8 PV\s0 formatted with \f(CW%s\fR, and characters >255 formatted with \f(CW%c\fR), the original \s-1SV\s0 might get upgraded to \s-1UTF\-8.\s0 Handles 'get' magic, but not 'set' magic. See \&\f(CW"sv_catpvf_mg"\fR. If the original \s-1SV\s0 was \s-1UTF\-8,\s0 the pattern should be valid \s-1UTF\-8\s0; if the original \s-1SV\s0 was bytes, the pattern should be too. .Sp .Vb 2 \& void sv_catpvf(SV *const sv, const char *const pat, \& ...) .Ve .IP "sv_catpvf_mg" 8 .IX Xref "sv_catpvf_mg" .IX Item "sv_catpvf_mg" Like \f(CW\*(C`sv_catpvf\*(C'\fR, but also handles 'set' magic. .Sp .Vb 2 \& void sv_catpvf_mg(SV *const sv, \& const char *const pat, ...) .Ve .IP "sv_catpvn" 8 .IX Xref "sv_catpvn" .IX Item "sv_catpvn" Concatenates the string onto the end of the string which is in the \s-1SV.\s0 \&\f(CW\*(C`len\*(C'\fR indicates number of bytes to copy. If the \s-1SV\s0 has the \s-1UTF\-8\s0 status set, then the bytes appended should be valid \s-1UTF\-8.\s0 Handles 'get' magic, but not 'set' magic. See \f(CW"sv_catpvn_mg"\fR. .Sp .Vb 1 \& void sv_catpvn(SV *dsv, const char *sstr, STRLEN len) .Ve .IP "sv_catpvn_flags" 8 .IX Xref "sv_catpvn_flags" .IX Item "sv_catpvn_flags" Concatenates the string onto the end of the string which is in the \s-1SV.\s0 The \&\f(CW\*(C`len\*(C'\fR indicates number of bytes to copy. .Sp By default, the string appended is assumed to be valid \s-1UTF\-8\s0 if the \s-1SV\s0 has the \s-1UTF\-8\s0 status set, and a string of bytes otherwise. One can force the appended string to be interpreted as \s-1UTF\-8\s0 by supplying the \f(CW\*(C`SV_CATUTF8\*(C'\fR flag, and as bytes by supplying the \f(CW\*(C`SV_CATBYTES\*(C'\fR flag; the \s-1SV\s0 or the string appended will be upgraded to \s-1UTF\-8\s0 if necessary. .Sp If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_SMAGIC\*(C'\fR bit set, will \&\f(CW\*(C`mg_set\*(C'\fR on \f(CW\*(C`dsv\*(C'\fR afterwards if appropriate. \&\f(CW\*(C`sv_catpvn\*(C'\fR and \f(CW\*(C`sv_catpvn_nomg\*(C'\fR are implemented in terms of this function. .Sp .Vb 4 \& void sv_catpvn_flags(SV *const dstr, \& const char *sstr, \& const STRLEN len, \& const I32 flags) .Ve .IP "sv_catpvn_nomg" 8 .IX Xref "sv_catpvn_nomg" .IX Item "sv_catpvn_nomg" Like \f(CW\*(C`sv_catpvn\*(C'\fR but doesn't process magic. .Sp .Vb 2 \& void sv_catpvn_nomg(SV* sv, const char* ptr, \& STRLEN len) .Ve .IP "sv_catpvs" 8 .IX Xref "sv_catpvs" .IX Item "sv_catpvs" Like \f(CW\*(C`sv_catpvn\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& void sv_catpvs(SV* sv, "literal string") .Ve .IP "sv_catpvs_flags" 8 .IX Xref "sv_catpvs_flags" .IX Item "sv_catpvs_flags" Like \f(CW\*(C`sv_catpvn_flags\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 2 \& void sv_catpvs_flags(SV* sv, "literal string", \& I32 flags) .Ve .IP "sv_catpvs_mg" 8 .IX Xref "sv_catpvs_mg" .IX Item "sv_catpvs_mg" Like \f(CW\*(C`sv_catpvn_mg\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& void sv_catpvs_mg(SV* sv, "literal string") .Ve .IP "sv_catpvs_nomg" 8 .IX Xref "sv_catpvs_nomg" .IX Item "sv_catpvs_nomg" Like \f(CW\*(C`sv_catpvn_nomg\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& void sv_catpvs_nomg(SV* sv, "literal string") .Ve .IP "sv_catpv_flags" 8 .IX Xref "sv_catpv_flags" .IX Item "sv_catpv_flags" Concatenates the \f(CW\*(C`NUL\*(C'\fR\-terminated string onto the end of the string which is in the \s-1SV.\s0 If the \s-1SV\s0 has the \s-1UTF\-8\s0 status set, then the bytes appended should be valid \s-1UTF\-8.\s0 If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_SMAGIC\*(C'\fR bit set, will \f(CW\*(C`mg_set\*(C'\fR on the modified \s-1SV\s0 if appropriate. .Sp .Vb 2 \& void sv_catpv_flags(SV *dstr, const char *sstr, \& const I32 flags) .Ve .IP "sv_catpv_mg" 8 .IX Xref "sv_catpv_mg" .IX Item "sv_catpv_mg" Like \f(CW\*(C`sv_catpv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_catpv_mg(SV *const sv, const char *const ptr) .Ve .IP "sv_catpv_nomg" 8 .IX Xref "sv_catpv_nomg" .IX Item "sv_catpv_nomg" Like \f(CW\*(C`sv_catpv\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& void sv_catpv_nomg(SV* sv, const char* ptr) .Ve .IP "sv_catsv" 8 .IX Xref "sv_catsv" .IX Item "sv_catsv" Concatenates the string from \s-1SV\s0 \f(CW\*(C`ssv\*(C'\fR onto the end of the string in \s-1SV\s0 \&\f(CW\*(C`dsv\*(C'\fR. If \f(CW\*(C`ssv\*(C'\fR is null, does nothing; otherwise modifies only \f(CW\*(C`dsv\*(C'\fR. Handles 'get' magic on both SVs, but no 'set' magic. See \f(CW"sv_catsv_mg"\fR and \f(CW"sv_catsv_nomg"\fR. .Sp .Vb 1 \& void sv_catsv(SV *dstr, SV *sstr) .Ve .IP "sv_catsv_flags" 8 .IX Xref "sv_catsv_flags" .IX Item "sv_catsv_flags" Concatenates the string from \s-1SV\s0 \f(CW\*(C`ssv\*(C'\fR onto the end of the string in \s-1SV\s0 \&\f(CW\*(C`dsv\*(C'\fR. If \f(CW\*(C`ssv\*(C'\fR is null, does nothing; otherwise modifies only \f(CW\*(C`dsv\*(C'\fR. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, will call \f(CW\*(C`mg_get\*(C'\fR on both SVs if appropriate. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_SMAGIC\*(C'\fR bit set, \f(CW\*(C`mg_set\*(C'\fR will be called on the modified \s-1SV\s0 afterward, if appropriate. \f(CW\*(C`sv_catsv\*(C'\fR, \f(CW\*(C`sv_catsv_nomg\*(C'\fR, and \f(CW\*(C`sv_catsv_mg\*(C'\fR are implemented in terms of this function. .Sp .Vb 2 \& void sv_catsv_flags(SV *const dsv, SV *const ssv, \& const I32 flags) .Ve .IP "sv_catsv_nomg" 8 .IX Xref "sv_catsv_nomg" .IX Item "sv_catsv_nomg" Like \f(CW\*(C`sv_catsv\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& void sv_catsv_nomg(SV* dsv, SV* ssv) .Ve .IP "sv_chop" 8 .IX Xref "sv_chop" .IX Item "sv_chop" Efficient removal of characters from the beginning of the string buffer. \&\f(CW\*(C`SvPOK(sv)\*(C'\fR, or at least \f(CW\*(C`SvPOKp(sv)\*(C'\fR, must be true and \f(CW\*(C`ptr\*(C'\fR must be a pointer to somewhere inside the string buffer. \f(CW\*(C`ptr\*(C'\fR becomes the first character of the adjusted string. Uses the \f(CW\*(C`OOK\*(C'\fR hack. On return, only \&\f(CW\*(C`SvPOK(sv)\*(C'\fR and \f(CW\*(C`SvPOKp(sv)\*(C'\fR among the \f(CW\*(C`OK\*(C'\fR flags will be true. .Sp Beware: after this function returns, \f(CW\*(C`ptr\*(C'\fR and SvPVX_const(sv) may no longer refer to the same chunk of data. .Sp The unfortunate similarity of this function's name to that of Perl's \f(CW\*(C`chop\*(C'\fR operator is strictly coincidental. This function works from the left; \&\f(CW\*(C`chop\*(C'\fR works from the right. .Sp .Vb 1 \& void sv_chop(SV *const sv, const char *const ptr) .Ve .IP "sv_clear" 8 .IX Xref "sv_clear" .IX Item "sv_clear" Clear an \s-1SV:\s0 call any destructors, free up any memory used by the body, and free the body itself. The \s-1SV\s0's head is \fInot\fR 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 \f(CW\*(C`REFCNT\*(C'\fR is zero. Most of the time you'll want to call \f(CW\*(C`sv_free()\*(C'\fR (or its macro wrapper \f(CW\*(C`SvREFCNT_dec\*(C'\fR) instead. .Sp .Vb 1 \& void sv_clear(SV *const orig_sv) .Ve .IP "sv_cmp" 8 .IX Xref "sv_cmp" .IX Item "sv_cmp" Compares the strings in two SVs. Returns \-1, 0, or 1 indicating whether the string in \f(CW\*(C`sv1\*(C'\fR is less than, equal to, or greater than the string in \&\f(CW\*(C`sv2\*(C'\fR. Is \s-1UTF\-8\s0 and \f(CW\*(Aquse bytes\*(Aq\fR aware, handles get magic, and will coerce its args to strings if necessary. See also \f(CW"sv_cmp_locale"\fR. .Sp .Vb 1 \& I32 sv_cmp(SV *const sv1, SV *const sv2) .Ve .IP "sv_cmp_flags" 8 .IX Xref "sv_cmp_flags" .IX Item "sv_cmp_flags" Compares the strings in two SVs. Returns \-1, 0, or 1 indicating whether the string in \f(CW\*(C`sv1\*(C'\fR is less than, equal to, or greater than the string in \&\f(CW\*(C`sv2\*(C'\fR. Is \s-1UTF\-8\s0 and \f(CW\*(Aquse bytes\*(Aq\fR aware and will coerce its args to strings if necessary. If the flags has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, it handles get magic. See also \f(CW"sv_cmp_locale_flags"\fR. .Sp .Vb 2 \& I32 sv_cmp_flags(SV *const sv1, SV *const sv2, \& const U32 flags) .Ve .IP "sv_cmp_locale" 8 .IX Xref "sv_cmp_locale" .IX Item "sv_cmp_locale" Compares the strings in two SVs in a locale-aware manner. Is \s-1UTF\-8\s0 and \&\f(CW\*(Aquse bytes\*(Aq\fR aware, handles get magic, and will coerce its args to strings if necessary. See also \f(CW"sv_cmp"\fR. .Sp .Vb 1 \& I32 sv_cmp_locale(SV *const sv1, SV *const sv2) .Ve .IP "sv_cmp_locale_flags" 8 .IX Xref "sv_cmp_locale_flags" .IX Item "sv_cmp_locale_flags" Compares the strings in two SVs in a locale-aware manner. Is \s-1UTF\-8\s0 and \&\f(CW\*(Aquse bytes\*(Aq\fR aware and will coerce its args to strings if necessary. If the flags contain \f(CW\*(C`SV_GMAGIC\*(C'\fR, it handles get magic. See also \&\f(CW"sv_cmp_flags"\fR. .Sp .Vb 3 \& I32 sv_cmp_locale_flags(SV *const sv1, \& SV *const sv2, \& const U32 flags) .Ve .IP "sv_collxfrm" 8 .IX Xref "sv_collxfrm" .IX Item "sv_collxfrm" This calls \f(CW\*(C`sv_collxfrm_flags\*(C'\fR with the \s-1SV_GMAGIC\s0 flag. See \&\f(CW"sv_collxfrm_flags"\fR. .Sp .Vb 1 \& char* sv_collxfrm(SV *const sv, STRLEN *const nxp) .Ve .IP "sv_collxfrm_flags" 8 .IX Xref "sv_collxfrm_flags" .IX Item "sv_collxfrm_flags" Add Collate Transform magic to an \s-1SV\s0 if it doesn't already have it. If the flags contain \f(CW\*(C`SV_GMAGIC\*(C'\fR, it handles get-magic. .Sp Any scalar variable may carry \f(CW\*(C`PERL_MAGIC_collxfrm\*(C'\fR 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. .Sp .Vb 3 \& char* sv_collxfrm_flags(SV *const sv, \& STRLEN *const nxp, \& I32 const flags) .Ve .IP "sv_copypv" 8 .IX Xref "sv_copypv" .IX Item "sv_copypv" Copies a stringified representation of the source \s-1SV\s0 into the destination \s-1SV.\s0 Automatically performs any necessary \f(CW\*(C`mg_get\*(C'\fR and coercion of numeric values into strings. Guaranteed to preserve \&\f(CW\*(C`UTF8\*(C'\fR flag even from overloaded objects. Similar in nature to \&\f(CW\*(C`sv_2pv[_flags]\*(C'\fR but operates directly on an \s-1SV\s0 instead of just the string. Mostly uses \f(CW\*(C`sv_2pv_flags\*(C'\fR to do its work, except when that would lose the \s-1UTF\-8\s0'ness of the \s-1PV.\s0 .Sp .Vb 1 \& void sv_copypv(SV *const dsv, SV *const ssv) .Ve .IP "sv_copypv_flags" 8 .IX Xref "sv_copypv_flags" .IX Item "sv_copypv_flags" Implementation of \f(CW\*(C`sv_copypv\*(C'\fR and \f(CW\*(C`sv_copypv_nomg\*(C'\fR. Calls get magic iff flags has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set. .Sp .Vb 2 \& void sv_copypv_flags(SV *const dsv, SV *const ssv, \& const I32 flags) .Ve .IP "sv_copypv_nomg" 8 .IX Xref "sv_copypv_nomg" .IX Item "sv_copypv_nomg" Like \f(CW\*(C`sv_copypv\*(C'\fR, but doesn't invoke get magic first. .Sp .Vb 1 \& void sv_copypv_nomg(SV *const dsv, SV *const ssv) .Ve .IP "SvCUR" 8 .IX Xref "SvCUR" .IX Item "SvCUR" Returns the length of the string which is in the \s-1SV.\s0 See \f(CW"SvLEN"\fR. .Sp .Vb 1 \& STRLEN SvCUR(SV* sv) .Ve .IP "SvCUR_set" 8 .IX Xref "SvCUR_set" .IX Item "SvCUR_set" Set the current length of the string which is in the \s-1SV.\s0 See \f(CW"SvCUR"\fR and \f(CW\*(C`SvIV_set\*(C'\fR>. .Sp .Vb 1 \& void SvCUR_set(SV* sv, STRLEN len) .Ve .IP "sv_dec" 8 .IX Xref "sv_dec" .IX Item "sv_dec" Auto-decrement of the value in the \s-1SV,\s0 doing string to numeric conversion if necessary. Handles 'get' magic and operator overloading. .Sp .Vb 1 \& void sv_dec(SV *const sv) .Ve .IP "sv_dec_nomg" 8 .IX Xref "sv_dec_nomg" .IX Item "sv_dec_nomg" Auto-decrement of the value in the \s-1SV,\s0 doing string to numeric conversion if necessary. Handles operator overloading. Skips handling 'get' magic. .Sp .Vb 1 \& void sv_dec_nomg(SV *const sv) .Ve .IP "sv_derived_from" 8 .IX Xref "sv_derived_from" .IX Item "sv_derived_from" Exactly like \*(L"sv_derived_from_pv\*(R", but doesn't take a \f(CW\*(C`flags\*(C'\fR parameter. .Sp .Vb 1 \& bool sv_derived_from(SV* sv, const char *const name) .Ve .IP "sv_derived_from_pv" 8 .IX Xref "sv_derived_from_pv" .IX Item "sv_derived_from_pv" Exactly like \*(L"sv_derived_from_pvn\*(R", but takes a nul-terminated string instead of a string/length pair. .Sp .Vb 3 \& bool sv_derived_from_pv(SV* sv, \& const char *const name, \& U32 flags) .Ve .IP "sv_derived_from_pvn" 8 .IX Xref "sv_derived_from_pvn" .IX Item "sv_derived_from_pvn" Returns a boolean indicating whether the \s-1SV\s0 is derived from the specified class \&\fIat the C level\fR. To check derivation at the Perl level, call \f(CW\*(C`isa()\*(C'\fR as a normal Perl method. .Sp Currently, the only significant value for \f(CW\*(C`flags\*(C'\fR is SVf_UTF8. .Sp .Vb 3 \& bool sv_derived_from_pvn(SV* sv, \& const char *const name, \& const STRLEN len, U32 flags) .Ve .IP "sv_derived_from_sv" 8 .IX Xref "sv_derived_from_sv" .IX Item "sv_derived_from_sv" Exactly like \*(L"sv_derived_from_pvn\*(R", but takes the name string in the form of an \s-1SV\s0 instead of a string/length pair. This is the advised form. .Sp .Vb 2 \& bool sv_derived_from_sv(SV* sv, SV *namesv, \& U32 flags) .Ve .IP "sv_does" 8 .IX Xref "sv_does" .IX Item "sv_does" Like \*(L"sv_does_pv\*(R", but doesn't take a \f(CW\*(C`flags\*(C'\fR parameter. .Sp .Vb 1 \& bool sv_does(SV* sv, const char *const name) .Ve .IP "sv_does_pv" 8 .IX Xref "sv_does_pv" .IX Item "sv_does_pv" Like \*(L"sv_does_sv\*(R", but takes a nul-terminated string instead of an \s-1SV.\s0 .Sp .Vb 2 \& bool sv_does_pv(SV* sv, const char *const name, \& U32 flags) .Ve .IP "sv_does_pvn" 8 .IX Xref "sv_does_pvn" .IX Item "sv_does_pvn" Like \*(L"sv_does_sv\*(R", but takes a string/length pair instead of an \s-1SV.\s0 .Sp .Vb 2 \& bool sv_does_pvn(SV* sv, const char *const name, \& const STRLEN len, U32 flags) .Ve .IP "sv_does_sv" 8 .IX Xref "sv_does_sv" .IX Item "sv_does_sv" Returns a boolean indicating whether the \s-1SV\s0 performs a specific, named role. The \s-1SV\s0 can be a Perl object or the name of a Perl class. .Sp .Vb 1 \& bool sv_does_sv(SV* sv, SV* namesv, U32 flags) .Ve .IP "SvEND" 8 .IX Xref "SvEND" .IX Item "SvEND" Returns a pointer to the spot just after the last character in the string which is in the \s-1SV,\s0 where there is usually a trailing \&\f(CW\*(C`NUL\*(C'\fR character (even though Perl scalars do not strictly require it). See \f(CW"SvCUR"\fR. Access the character as \f(CW\*(C`*(SvEND(sv))\*(C'\fR. .Sp Warning: If \f(CW\*(C`SvCUR\*(C'\fR is equal to \f(CW\*(C`SvLEN\*(C'\fR, then \f(CW\*(C`SvEND\*(C'\fR points to unallocated memory. .Sp .Vb 1 \& char* SvEND(SV* sv) .Ve .IP "sv_eq" 8 .IX Xref "sv_eq" .IX Item "sv_eq" Returns a boolean indicating whether the strings in the two SVs are identical. Is \s-1UTF\-8\s0 and \f(CW\*(Aquse bytes\*(Aq\fR aware, handles get magic, and will coerce its args to strings if necessary. .Sp .Vb 1 \& I32 sv_eq(SV* sv1, SV* sv2) .Ve .IP "sv_eq_flags" 8 .IX Xref "sv_eq_flags" .IX Item "sv_eq_flags" Returns a boolean indicating whether the strings in the two SVs are identical. Is \s-1UTF\-8\s0 and \f(CW\*(Aquse bytes\*(Aq\fR aware and coerces its args to strings if necessary. If the flags has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, it handles get-magic, too. .Sp .Vb 1 \& I32 sv_eq_flags(SV* sv1, SV* sv2, const U32 flags) .Ve .IP "sv_force_normal_flags" 8 .IX Xref "sv_force_normal_flags" .IX Item "sv_force_normal_flags" Undo various types of fakery on an \s-1SV,\s0 where fakery means \&\*(L"more than\*(R" a string: if the \s-1PV\s0 is a shared string, make a private copy; if we're a ref, stop refing; if we're a glob, downgrade to an \f(CW\*(C`xpvmg\*(C'\fR; 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 \f(CW\*(C`SV_COW_DROP_PV\*(C'\fR is set then a copy-on-write scalar drops its \s-1PV\s0 buffer (if any) and becomes \&\f(CW\*(C`SvPOK_off\*(C'\fR rather than making a copy. (Used where this scalar is about to be set to some other value.) In addition, the \f(CW\*(C`flags\*(C'\fR parameter gets passed to \f(CW\*(C`sv_unref_flags()\*(C'\fR when unreffing. \f(CW\*(C`sv_force_normal\*(C'\fR calls this function with flags set to 0. .Sp This function is expected to be used to signal to perl that this \s-1SV\s0 is about to be written to, and any extra book-keeping needs to be taken care of. Hence, it croaks on read-only values. .Sp .Vb 2 \& void sv_force_normal_flags(SV *const sv, \& const U32 flags) .Ve .IP "sv_free" 8 .IX Xref "sv_free" .IX Item "sv_free" Decrement an \s-1SV\s0's reference count, and if it drops to zero, call \&\f(CW\*(C`sv_clear\*(C'\fR to invoke destructors and free up any memory used by the body; finally, deallocating the \s-1SV\s0's head itself. Normally called via a wrapper macro \f(CW\*(C`SvREFCNT_dec\*(C'\fR. .Sp .Vb 1 \& void sv_free(SV *const sv) .Ve .IP "SvGAMAGIC" 8 .IX Xref "SvGAMAGIC" .IX Item "SvGAMAGIC" Returns true if the \s-1SV\s0 has get magic or overloading. If either is true then the scalar is active data, and has the potential to return a new value every time it is accessed. Hence you must be careful to only read it once per user logical operation and work with that returned value. If neither is true then the scalar's value cannot change unless written to. .Sp .Vb 1 \& U32 SvGAMAGIC(SV* sv) .Ve .IP "sv_gets" 8 .IX Xref "sv_gets" .IX Item "sv_gets" Get a line from the filehandle and store it into the \s-1SV,\s0 optionally appending to the currently-stored string. If \f(CW\*(C`append\*(C'\fR is not 0, the line is appended to the \s-1SV\s0 instead of overwriting it. \f(CW\*(C`append\*(C'\fR should be set to the byte offset that the appended string should start at in the \s-1SV\s0 (typically, \f(CW\*(C`SvCUR(sv)\*(C'\fR is a suitable choice). .Sp .Vb 2 \& char* sv_gets(SV *const sv, PerlIO *const fp, \& I32 append) .Ve .IP "sv_get_backrefs" 8 .IX Xref "sv_get_backrefs" .IX Item "sv_get_backrefs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp If \f(CW\*(C`sv\*(C'\fR is the target of a weak reference then it returns the back references structure associated with the sv; otherwise return \f(CW\*(C`NULL\*(C'\fR. .Sp When returning a non-null result the type of the return is relevant. If it is an \s-1AV\s0 then the elements of the \s-1AV\s0 are the weak reference RVs which point at this item. If it is any other type then the item itself is the weak reference. .Sp See also \f(CW\*(C`Perl_sv_add_backref()\*(C'\fR, \f(CW\*(C`Perl_sv_del_backref()\*(C'\fR, \&\f(CW\*(C`Perl_sv_kill_backrefs()\*(C'\fR .Sp .Vb 1 \& SV* sv_get_backrefs(SV *const sv) .Ve .IP "SvGROW" 8 .IX Xref "SvGROW" .IX Item "SvGROW" Expands the character buffer in the \s-1SV\s0 so that it has room for the indicated number of bytes (remember to reserve space for an extra trailing \&\f(CW\*(C`NUL\*(C'\fR character). Calls \f(CW\*(C`sv_grow\*(C'\fR to perform the expansion if necessary. Returns a pointer to the character buffer. \s-1SV\s0 must be of type >= \f(CW\*(C`SVt_PV\*(C'\fR. One alternative is to call \f(CW\*(C`sv_grow\*(C'\fR if you are not sure of the type of \s-1SV.\s0 .Sp You might mistakenly think that \f(CW\*(C`len\*(C'\fR is the number of bytes to add to the existing size, but instead it is the total size \f(CW\*(C`sv\*(C'\fR should be. .Sp .Vb 1 \& char * SvGROW(SV* sv, STRLEN len) .Ve .IP "sv_grow" 8 .IX Xref "sv_grow" .IX Item "sv_grow" Expands the character buffer in the \s-1SV.\s0 If necessary, uses \f(CW\*(C`sv_unref\*(C'\fR and upgrades the \s-1SV\s0 to \f(CW\*(C`SVt_PV\*(C'\fR. Returns a pointer to the character buffer. Use the \f(CW\*(C`SvGROW\*(C'\fR wrapper instead. .Sp .Vb 1 \& char* sv_grow(SV *const sv, STRLEN newlen) .Ve .IP "sv_inc" 8 .IX Xref "sv_inc" .IX Item "sv_inc" Auto-increment of the value in the \s-1SV,\s0 doing string to numeric conversion if necessary. Handles 'get' magic and operator overloading. .Sp .Vb 1 \& void sv_inc(SV *const sv) .Ve .IP "sv_inc_nomg" 8 .IX Xref "sv_inc_nomg" .IX Item "sv_inc_nomg" Auto-increment of the value in the \s-1SV,\s0 doing string to numeric conversion if necessary. Handles operator overloading. Skips handling 'get' magic. .Sp .Vb 1 \& void sv_inc_nomg(SV *const sv) .Ve .IP "sv_insert" 8 .IX Xref "sv_insert" .IX Item "sv_insert" Inserts and/or replaces a string at the specified offset/length within the \s-1SV.\s0 Similar to the Perl \f(CW\*(C`substr()\*(C'\fR function, with \f(CW\*(C`littlelen\*(C'\fR bytes starting at \&\f(CW\*(C`little\*(C'\fR replacing \f(CW\*(C`len\*(C'\fR bytes of the string in \f(CW\*(C`bigstr\*(C'\fR starting at \&\f(CW\*(C`offset\*(C'\fR. Handles get magic. .Sp .Vb 4 \& void sv_insert(SV *const bigstr, const STRLEN offset, \& const STRLEN len, \& const char *const little, \& const STRLEN littlelen) .Ve .IP "sv_insert_flags" 8 .IX Xref "sv_insert_flags" .IX Item "sv_insert_flags" Same as \f(CW\*(C`sv_insert\*(C'\fR, but the extra \f(CW\*(C`flags\*(C'\fR are passed to the \&\f(CW\*(C`SvPV_force_flags\*(C'\fR that applies to \f(CW\*(C`bigstr\*(C'\fR. .Sp .Vb 6 \& void sv_insert_flags(SV *const bigstr, \& const STRLEN offset, \& const STRLEN len, \& const char *little, \& const STRLEN littlelen, \& const U32 flags) .Ve .IP "SvIOK" 8 .IX Xref "SvIOK" .IX Item "SvIOK" Returns a U32 value indicating whether the \s-1SV\s0 contains an integer. .Sp .Vb 1 \& U32 SvIOK(SV* sv) .Ve .IP "SvIOK_notUV" 8 .IX Xref "SvIOK_notUV" .IX Item "SvIOK_notUV" Returns a boolean indicating whether the \s-1SV\s0 contains a signed integer. .Sp .Vb 1 \& bool SvIOK_notUV(SV* sv) .Ve .IP "SvIOK_off" 8 .IX Xref "SvIOK_off" .IX Item "SvIOK_off" Unsets the \s-1IV\s0 status of an \s-1SV.\s0 .Sp .Vb 1 \& void SvIOK_off(SV* sv) .Ve .IP "SvIOK_on" 8 .IX Xref "SvIOK_on" .IX Item "SvIOK_on" Tells an \s-1SV\s0 that it is an integer. .Sp .Vb 1 \& void SvIOK_on(SV* sv) .Ve .IP "SvIOK_only" 8 .IX Xref "SvIOK_only" .IX Item "SvIOK_only" Tells an \s-1SV\s0 that it is an integer and disables all other \f(CW\*(C`OK\*(C'\fR bits. .Sp .Vb 1 \& void SvIOK_only(SV* sv) .Ve .IP "SvIOK_only_UV" 8 .IX Xref "SvIOK_only_UV" .IX Item "SvIOK_only_UV" Tells an \s-1SV\s0 that it is an unsigned integer and disables all other \f(CW\*(C`OK\*(C'\fR bits. .Sp .Vb 1 \& void SvIOK_only_UV(SV* sv) .Ve .IP "SvIOKp" 8 .IX Xref "SvIOKp" .IX Item "SvIOKp" Returns a U32 value indicating whether the \s-1SV\s0 contains an integer. Checks the \fBprivate\fR setting. Use \f(CW\*(C`SvIOK\*(C'\fR instead. .Sp .Vb 1 \& U32 SvIOKp(SV* sv) .Ve .IP "SvIOK_UV" 8 .IX Xref "SvIOK_UV" .IX Item "SvIOK_UV" Returns a boolean indicating whether the \s-1SV\s0 contains an integer that must be interpreted as unsigned. A non-negative integer whose value is within the range of both an \s-1IV\s0 and a \s-1UV\s0 may be flagged as either \f(CW\*(C`SvUOK\*(C'\fR or \f(CW\*(C`SvIOK\*(C'\fR. .Sp .Vb 1 \& bool SvIOK_UV(SV* sv) .Ve .IP "sv_isa" 8 .IX Xref "sv_isa" .IX Item "sv_isa" Returns a boolean indicating whether the \s-1SV\s0 is blessed into the specified class. .Sp This does not check for subtypes or method overloading. Use \f(CW\*(C`sv_isa_sv\*(C'\fR to verify an inheritance relationship in the same way as the \f(CW\*(C`isa\*(C'\fR operator by respecting any \f(CW\*(C`isa()\*(C'\fR method overloading; or \f(CW\*(C`sv_derived_from_sv\*(C'\fR to test directly on the actual object type. .Sp .Vb 1 \& int sv_isa(SV* sv, const char *const name) .Ve .IP "sv_isa_sv" 8 .IX Xref "sv_isa_sv" .IX Item "sv_isa_sv" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Returns a boolean indicating whether the \s-1SV\s0 is an object reference and is derived from the specified class, respecting any \f(CW\*(C`isa()\*(C'\fR method overloading it may have. Returns false if \f(CW\*(C`sv\*(C'\fR is not a reference to an object, or is not derived from the specified class. .Sp This is the function used to implement the behaviour of the \f(CW\*(C`isa\*(C'\fR operator. .Sp Does not invoke magic on \f(CW\*(C`sv\*(C'\fR. .Sp Not to be confused with the older \f(CW\*(C`sv_isa\*(C'\fR function, which does not use an overloaded \f(CW\*(C`isa()\*(C'\fR method, nor will check subclassing. .Sp .Vb 1 \& bool sv_isa_sv(SV* sv, SV* namesv) .Ve .IP "SvIsCOW" 8 .IX Xref "SvIsCOW" .IX Item "SvIsCOW" Returns a U32 value indicating whether the \s-1SV\s0 is Copy-On-Write (either shared hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for \&\s-1COW\s0). .Sp .Vb 1 \& U32 SvIsCOW(SV* sv) .Ve .IP "SvIsCOW_shared_hash" 8 .IX Xref "SvIsCOW_shared_hash" .IX Item "SvIsCOW_shared_hash" Returns a boolean indicating whether the \s-1SV\s0 is Copy-On-Write shared hash key scalar. .Sp .Vb 1 \& bool SvIsCOW_shared_hash(SV* sv) .Ve .IP "sv_isobject" 8 .IX Xref "sv_isobject" .IX Item "sv_isobject" Returns a boolean indicating whether the \s-1SV\s0 is an \s-1RV\s0 pointing to a blessed object. If the \s-1SV\s0 is not an \s-1RV,\s0 or if the object is not blessed, then this will return false. .Sp .Vb 1 \& int sv_isobject(SV* sv) .Ve .IP "SvIV" 8 .IX Xref "SvIV" .IX Item "SvIV" Coerces the given \s-1SV\s0 to \s-1IV\s0 and returns it. The returned value in many circumstances will get stored in \f(CW\*(C`sv\*(C'\fR's \s-1IV\s0 slot, but not in all cases. (Use \&\f(CW"sv_setiv"\fR to make sure it does). .Sp See \f(CW"SvIVx"\fR for a version which guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. .Sp .Vb 1 \& IV SvIV(SV* sv) .Ve .IP "SvIV_nomg" 8 .IX Xref "SvIV_nomg" .IX Item "SvIV_nomg" Like \f(CW\*(C`SvIV\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& IV SvIV_nomg(SV* sv) .Ve .IP "SvIV_set" 8 .IX Xref "SvIV_set" .IX Item "SvIV_set" Set the value of the \s-1IV\s0 pointer in sv to val. It is possible to perform the same function of this macro with an lvalue assignment to \f(CW\*(C`SvIVX\*(C'\fR. With future Perls, however, it will be more efficient to use \&\f(CW\*(C`SvIV_set\*(C'\fR instead of the lvalue assignment to \f(CW\*(C`SvIVX\*(C'\fR. .Sp .Vb 1 \& void SvIV_set(SV* sv, IV val) .Ve .IP "SvIVX" 8 .IX Xref "SvIVX" .IX Item "SvIVX" Returns the raw value in the \s-1SV\s0's \s-1IV\s0 slot, without checks or conversions. Only use when you are sure \f(CW\*(C`SvIOK\*(C'\fR is true. See also \f(CW"SvIV"\fR. .Sp .Vb 1 \& IV SvIVX(SV* sv) .Ve .IP "SvIVx" 8 .IX Xref "SvIVx" .IX Item "SvIVx" Coerces the given \s-1SV\s0 to \s-1IV\s0 and returns it. The returned value in many circumstances will get stored in \f(CW\*(C`sv\*(C'\fR's \s-1IV\s0 slot, but not in all cases. (Use \&\f(CW"sv_setiv"\fR to make sure it does). .Sp This form guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. Only use this if \f(CW\*(C`sv\*(C'\fR is an expression with side effects, otherwise use the more efficient \f(CW\*(C`SvIV\*(C'\fR. .Sp .Vb 1 \& IV SvIVx(SV* sv) .Ve .IP "SvLEN" 8 .IX Xref "SvLEN" .IX Item "SvLEN" Returns the size of the string buffer in the \s-1SV,\s0 not including any part attributable to \f(CW\*(C`SvOOK\*(C'\fR. See \f(CW"SvCUR"\fR. .Sp .Vb 1 \& STRLEN SvLEN(SV* sv) .Ve .IP "sv_len" 8 .IX Xref "sv_len" .IX Item "sv_len" Returns the length of the string in the \s-1SV.\s0 Handles magic and type coercion and sets the \s-1UTF8\s0 flag appropriately. See also \f(CW"SvCUR"\fR, which gives raw access to the \f(CW\*(C`xpv_cur\*(C'\fR slot. .Sp .Vb 1 \& STRLEN sv_len(SV *const sv) .Ve .IP "SvLEN_set" 8 .IX Xref "SvLEN_set" .IX Item "SvLEN_set" Set the size of the string buffer for the \s-1SV.\s0 See \f(CW"SvLEN"\fR. .Sp .Vb 1 \& void SvLEN_set(SV* sv, STRLEN len) .Ve .IP "sv_len_utf8" 8 .IX Xref "sv_len_utf8" .IX Item "sv_len_utf8" Returns the number of characters in the string in an \s-1SV,\s0 counting wide \&\s-1UTF\-8\s0 bytes as a single character. Handles magic and type coercion. .Sp .Vb 1 \& STRLEN sv_len_utf8(SV *const sv) .Ve .IP "sv_magic" 8 .IX Xref "sv_magic" .IX Item "sv_magic" Adds magic to an \s-1SV.\s0 First upgrades \f(CW\*(C`sv\*(C'\fR to type \f(CW\*(C`SVt_PVMG\*(C'\fR if necessary, then adds a new magic item of type \f(CW\*(C`how\*(C'\fR to the head of the magic list. .Sp See \f(CW"sv_magicext"\fR (which \f(CW\*(C`sv_magic\*(C'\fR now calls) for a description of the handling of the \f(CW\*(C`name\*(C'\fR and \f(CW\*(C`namlen\*(C'\fR arguments. .Sp You need to use \f(CW\*(C`sv_magicext\*(C'\fR to add magic to \f(CW\*(C`SvREADONLY\*(C'\fR SVs and also to add more than one instance of the same \f(CW\*(C`how\*(C'\fR. .Sp .Vb 3 \& void sv_magic(SV *const sv, SV *const obj, \& const int how, const char *const name, \& const I32 namlen) .Ve .IP "sv_magicext" 8 .IX Xref "sv_magicext" .IX Item "sv_magicext" Adds magic to an \s-1SV,\s0 upgrading it if necessary. Applies the supplied \f(CW\*(C`vtable\*(C'\fR and returns a pointer to the magic added. .Sp Note that \f(CW\*(C`sv_magicext\*(C'\fR will allow things that \f(CW\*(C`sv_magic\*(C'\fR will not. In particular, you can add magic to \f(CW\*(C`SvREADONLY\*(C'\fR SVs, and add more than one instance of the same \f(CW\*(C`how\*(C'\fR. .Sp If \f(CW\*(C`namlen\*(C'\fR is greater than zero then a \f(CW\*(C`savepvn\*(C'\fR \fIcopy\fR of \f(CW\*(C`name\*(C'\fR is stored, if \f(CW\*(C`namlen\*(C'\fR is zero then \f(CW\*(C`name\*(C'\fR is stored as-is and \- as another special case \- if \f(CW\*(C`(name && namlen == HEf_SVKEY)\*(C'\fR then \f(CW\*(C`name\*(C'\fR is assumed to contain an SV* and is stored as-is with its \f(CW\*(C`REFCNT\*(C'\fR incremented. .Sp (This is now used as a subroutine by \f(CW\*(C`sv_magic\*(C'\fR.) .Sp .Vb 5 \& MAGIC * sv_magicext(SV *const sv, SV *const obj, \& const int how, \& const MGVTBL *const vtbl, \& const char *const name, \& const I32 namlen) .Ve .IP "SvMAGIC_set" 8 .IX Xref "SvMAGIC_set" .IX Item "SvMAGIC_set" Set the value of the \s-1MAGIC\s0 pointer in \f(CW\*(C`sv\*(C'\fR to val. See \f(CW"SvIV_set"\fR. .Sp .Vb 1 \& void SvMAGIC_set(SV* sv, MAGIC* val) .Ve .IP "sv_mortalcopy" 8 .IX Xref "sv_mortalcopy" .IX Item "sv_mortalcopy" Creates a new \s-1SV\s0 which is a copy of the original \s-1SV\s0 (using \f(CW\*(C`sv_setsv\*(C'\fR). The new \s-1SV\s0 is marked as mortal. It will be destroyed \*(L"soon\*(R", either by an explicit call to \f(CW\*(C`FREETMPS\*(C'\fR, or by an implicit call at places such as statement boundaries. See also \f(CW"sv_newmortal"\fR and \f(CW"sv_2mortal"\fR. .Sp .Vb 1 \& SV* sv_mortalcopy(SV *const oldsv) .Ve .IP "sv_mortalcopy_flags" 8 .IX Xref "sv_mortalcopy_flags" .IX Item "sv_mortalcopy_flags" Like \f(CW\*(C`sv_mortalcopy\*(C'\fR, but the extra \f(CW\*(C`flags\*(C'\fR are passed to the \&\f(CW\*(C`sv_setsv_flags\*(C'\fR. .Sp .Vb 1 \& SV* sv_mortalcopy_flags(SV *const oldsv, U32 flags) .Ve .IP "sv_newmortal" 8 .IX Xref "sv_newmortal" .IX Item "sv_newmortal" Creates a new null \s-1SV\s0 which is mortal. The reference count of the \s-1SV\s0 is set to 1. It will be destroyed \*(L"soon\*(R", either by an explicit call to \&\f(CW\*(C`FREETMPS\*(C'\fR, or by an implicit call at places such as statement boundaries. See also \f(CW"sv_mortalcopy"\fR and \f(CW"sv_2mortal"\fR. .Sp .Vb 1 \& SV* sv_newmortal() .Ve .IP "sv_newref" 8 .IX Xref "sv_newref" .IX Item "sv_newref" Increment an \s-1SV\s0's reference count. Use the \f(CW\*(C`SvREFCNT_inc()\*(C'\fR wrapper instead. .Sp .Vb 1 \& SV* sv_newref(SV *const sv) .Ve .IP "SvNIOK" 8 .IX Xref "SvNIOK" .IX Item "SvNIOK" Returns a U32 value indicating whether the \s-1SV\s0 contains a number, integer or double. .Sp .Vb 1 \& U32 SvNIOK(SV* sv) .Ve .IP "SvNIOK_off" 8 .IX Xref "SvNIOK_off" .IX Item "SvNIOK_off" Unsets the \s-1NV/IV\s0 status of an \s-1SV.\s0 .Sp .Vb 1 \& void SvNIOK_off(SV* sv) .Ve .IP "SvNIOKp" 8 .IX Xref "SvNIOKp" .IX Item "SvNIOKp" Returns a U32 value indicating whether the \s-1SV\s0 contains a number, integer or double. Checks the \fBprivate\fR setting. Use \f(CW\*(C`SvNIOK\*(C'\fR instead. .Sp .Vb 1 \& U32 SvNIOKp(SV* sv) .Ve .IP "SvNOK" 8 .IX Xref "SvNOK" .IX Item "SvNOK" Returns a U32 value indicating whether the \s-1SV\s0 contains a double. .Sp .Vb 1 \& U32 SvNOK(SV* sv) .Ve .IP "SvNOK_off" 8 .IX Xref "SvNOK_off" .IX Item "SvNOK_off" Unsets the \s-1NV\s0 status of an \s-1SV.\s0 .Sp .Vb 1 \& void SvNOK_off(SV* sv) .Ve .IP "SvNOK_on" 8 .IX Xref "SvNOK_on" .IX Item "SvNOK_on" Tells an \s-1SV\s0 that it is a double. .Sp .Vb 1 \& void SvNOK_on(SV* sv) .Ve .IP "SvNOK_only" 8 .IX Xref "SvNOK_only" .IX Item "SvNOK_only" Tells an \s-1SV\s0 that it is a double and disables all other \s-1OK\s0 bits. .Sp .Vb 1 \& void SvNOK_only(SV* sv) .Ve .IP "SvNOKp" 8 .IX Xref "SvNOKp" .IX Item "SvNOKp" Returns a U32 value indicating whether the \s-1SV\s0 contains a double. Checks the \&\fBprivate\fR setting. Use \f(CW\*(C`SvNOK\*(C'\fR instead. .Sp .Vb 1 \& U32 SvNOKp(SV* sv) .Ve .IP "SvNV" 8 .IX Xref "SvNV" .IX Item "SvNV" Coerces the given \s-1SV\s0 to \s-1NV\s0 and returns it. The returned value in many circumstances will get stored in \f(CW\*(C`sv\*(C'\fR's \s-1NV\s0 slot, but not in all cases. (Use \&\f(CW"sv_setnv"\fR to make sure it does). .Sp See \f(CW"SvNVx"\fR for a version which guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. .Sp .Vb 1 \& NV SvNV(SV* sv) .Ve .IP "SvNV_nomg" 8 .IX Xref "SvNV_nomg" .IX Item "SvNV_nomg" Like \f(CW\*(C`SvNV\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& NV SvNV_nomg(SV* sv) .Ve .IP "SvNV_set" 8 .IX Xref "SvNV_set" .IX Item "SvNV_set" Set the value of the \s-1NV\s0 pointer in \f(CW\*(C`sv\*(C'\fR to val. See \f(CW"SvIV_set"\fR. .Sp .Vb 1 \& void SvNV_set(SV* sv, NV val) .Ve .IP "SvNVX" 8 .IX Xref "SvNVX" .IX Item "SvNVX" Returns the raw value in the \s-1SV\s0's \s-1NV\s0 slot, without checks or conversions. Only use when you are sure \f(CW\*(C`SvNOK\*(C'\fR is true. See also \f(CW"SvNV"\fR. .Sp .Vb 1 \& NV SvNVX(SV* sv) .Ve .IP "SvNVx" 8 .IX Xref "SvNVx" .IX Item "SvNVx" Coerces the given \s-1SV\s0 to \s-1NV\s0 and returns it. The returned value in many circumstances will get stored in \f(CW\*(C`sv\*(C'\fR's \s-1NV\s0 slot, but not in all cases. (Use \&\f(CW"sv_setnv"\fR to make sure it does). .Sp This form guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. Only use this if \f(CW\*(C`sv\*(C'\fR is an expression with side effects, otherwise use the more efficient \f(CW\*(C`SvNV\*(C'\fR. .Sp .Vb 1 \& NV SvNVx(SV* sv) .Ve .IP "SvOK" 8 .IX Xref "SvOK" .IX Item "SvOK" Returns a U32 value indicating whether the value is defined. This is only meaningful for scalars. .Sp .Vb 1 \& U32 SvOK(SV* sv) .Ve .IP "SvOOK" 8 .IX Xref "SvOOK" .IX Item "SvOOK" Returns a U32 indicating whether the pointer to the string buffer is offset. This hack is used internally to speed up removal of characters from the beginning of a \f(CW\*(C`SvPV\*(C'\fR. When \f(CW\*(C`SvOOK\*(C'\fR is true, then the start of the allocated string buffer is actually \f(CW\*(C`SvOOK_offset()\*(C'\fR bytes before \f(CW\*(C`SvPVX\*(C'\fR. This offset used to be stored in \f(CW\*(C`SvIVX\*(C'\fR, but is now stored within the spare part of the buffer. .Sp .Vb 1 \& U32 SvOOK(SV* sv) .Ve .IP "SvOOK_offset" 8 .IX Xref "SvOOK_offset" .IX Item "SvOOK_offset" Reads into \f(CW\*(C`len\*(C'\fR the offset from \f(CW\*(C`SvPVX\*(C'\fR back to the true start of the allocated buffer, which will be non-zero if \f(CW\*(C`sv_chop\*(C'\fR has been used to efficiently remove characters from start of the buffer. Implemented as a macro, which takes the address of \f(CW\*(C`len\*(C'\fR, which must be of type \f(CW\*(C`STRLEN\*(C'\fR. Evaluates \f(CW\*(C`sv\*(C'\fR more than once. Sets \f(CW\*(C`len\*(C'\fR to 0 if \f(CW\*(C`SvOOK(sv)\*(C'\fR is false. .Sp .Vb 1 \& void SvOOK_offset(SV*sv, STRLEN len) .Ve .IP "SvPOK" 8 .IX Xref "SvPOK" .IX Item "SvPOK" Returns a U32 value indicating whether the \s-1SV\s0 contains a character string. .Sp .Vb 1 \& U32 SvPOK(SV* sv) .Ve .IP "SvPOK_off" 8 .IX Xref "SvPOK_off" .IX Item "SvPOK_off" Unsets the \s-1PV\s0 status of an \s-1SV.\s0 .Sp .Vb 1 \& void SvPOK_off(SV* sv) .Ve .IP "SvPOK_on" 8 .IX Xref "SvPOK_on" .IX Item "SvPOK_on" Tells an \s-1SV\s0 that it is a string. .Sp .Vb 1 \& void SvPOK_on(SV* sv) .Ve .IP "SvPOK_only" 8 .IX Xref "SvPOK_only" .IX Item "SvPOK_only" Tells an \s-1SV\s0 that it is a string and disables all other \f(CW\*(C`OK\*(C'\fR bits. Will also turn off the \s-1UTF\-8\s0 status. .Sp .Vb 1 \& void SvPOK_only(SV* sv) .Ve .IP "SvPOK_only_UTF8" 8 .IX Xref "SvPOK_only_UTF8" .IX Item "SvPOK_only_UTF8" Tells an \s-1SV\s0 that it is a string and disables all other \f(CW\*(C`OK\*(C'\fR bits, and leaves the \s-1UTF\-8\s0 status as it was. .Sp .Vb 1 \& void SvPOK_only_UTF8(SV* sv) .Ve .IP "SvPOKp" 8 .IX Xref "SvPOKp" .IX Item "SvPOKp" Returns a U32 value indicating whether the \s-1SV\s0 contains a character string. Checks the \fBprivate\fR setting. Use \f(CW\*(C`SvPOK\*(C'\fR instead. .Sp .Vb 1 \& U32 SvPOKp(SV* sv) .Ve .IP "sv_pos_b2u" 8 .IX Xref "sv_pos_b2u" .IX Item "sv_pos_b2u" Converts the value pointed to by \f(CW\*(C`offsetp\*(C'\fR from a count of bytes from the start of the string, to a count of the equivalent number of \s-1UTF\-8\s0 chars. Handles magic and type coercion. .Sp Use \f(CW\*(C`sv_pos_b2u_flags\*(C'\fR in preference, which correctly handles strings longer than 2Gb. .Sp .Vb 1 \& void sv_pos_b2u(SV *const sv, I32 *const offsetp) .Ve .IP "sv_pos_b2u_flags" 8 .IX Xref "sv_pos_b2u_flags" .IX Item "sv_pos_b2u_flags" Converts \f(CW\*(C`offset\*(C'\fR from a count of bytes from the start of the string, to a count of the equivalent number of \s-1UTF\-8\s0 chars. Handles type coercion. \&\f(CW\*(C`flags\*(C'\fR is passed to \f(CW\*(C`SvPV_flags\*(C'\fR, and usually should be \&\f(CW\*(C`SV_GMAGIC|SV_CONST_RETURN\*(C'\fR to handle magic. .Sp .Vb 2 \& STRLEN sv_pos_b2u_flags(SV *const sv, \& STRLEN const offset, U32 flags) .Ve .IP "sv_pos_u2b" 8 .IX Xref "sv_pos_u2b" .IX Item "sv_pos_u2b" Converts the value pointed to by \f(CW\*(C`offsetp\*(C'\fR from a count of \s-1UTF\-8\s0 chars from the start of the string, to a count of the equivalent number of bytes; if \&\f(CW\*(C`lenp\*(C'\fR is non-zero, it does the same to \f(CW\*(C`lenp\*(C'\fR, but this time starting from the offset, rather than from the start of the string. Handles magic and type coercion. .Sp Use \f(CW\*(C`sv_pos_u2b_flags\*(C'\fR in preference, which correctly handles strings longer than 2Gb. .Sp .Vb 2 \& void sv_pos_u2b(SV *const sv, I32 *const offsetp, \& I32 *const lenp) .Ve .IP "sv_pos_u2b_flags" 8 .IX Xref "sv_pos_u2b_flags" .IX Item "sv_pos_u2b_flags" Converts the offset from a count of \s-1UTF\-8\s0 chars from the start of the string, to a count of the equivalent number of bytes; if \&\f(CW\*(C`lenp\*(C'\fR is non-zero, it does the same to \f(CW\*(C`lenp\*(C'\fR, but this time starting from \&\f(CW\*(C`offset\*(C'\fR, rather than from the start of the string. Handles type coercion. \&\f(CW\*(C`flags\*(C'\fR is passed to \f(CW\*(C`SvPV_flags\*(C'\fR, and usually should be \&\f(CW\*(C`SV_GMAGIC|SV_CONST_RETURN\*(C'\fR to handle magic. .Sp .Vb 2 \& STRLEN sv_pos_u2b_flags(SV *const sv, STRLEN uoffset, \& STRLEN *const lenp, U32 flags) .Ve .IP "SvPV" 8 .IX Xref "SvPV" .IX Item "SvPV" Returns a pointer to the string in the \s-1SV,\s0 or a stringified form of the \s-1SV\s0 if the \s-1SV\s0 does not contain a string. The \s-1SV\s0 may cache the stringified version becoming \f(CW\*(C`SvPOK\*(C'\fR. Handles 'get' magic. The \&\f(CW\*(C`len\*(C'\fR variable will be set to the length of the string (this is a macro, so don't use \f(CW&len\fR). See also \f(CW"SvPVx"\fR for a version which guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. .Sp Note that there is no guarantee that the return value of \f(CW\*(C`SvPV()\*(C'\fR is equal to \f(CW\*(C`SvPVX(sv)\*(C'\fR, or that \f(CW\*(C`SvPVX(sv)\*(C'\fR contains valid data, or that successive calls to \f(CW\*(C`SvPV(sv)\*(C'\fR will return the same pointer value each time. This is due to the way that things like overloading and Copy-On-Write are handled. In these cases, the return value may point to a temporary buffer or similar. If you absolutely need the \f(CW\*(C`SvPVX\*(C'\fR field to be valid (for example, if you intend to write to it), then see \&\f(CW"SvPV_force"\fR. .Sp .Vb 1 \& char* SvPV(SV* sv, STRLEN len) .Ve .IP "SvPVbyte" 8 .IX Xref "SvPVbyte" .IX Item "SvPVbyte" Like \f(CW\*(C`SvPV\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to byte representation first if necessary. If the \s-1SV\s0 cannot be downgraded from \s-1UTF\-8,\s0 this croaks. .Sp .Vb 1 \& char* SvPVbyte(SV* sv, STRLEN len) .Ve .IP "SvPVbyte_force" 8 .IX Xref "SvPVbyte_force" .IX Item "SvPVbyte_force" Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to byte representation first if necessary. If the \s-1SV\s0 cannot be downgraded from \s-1UTF\-8,\s0 this croaks. .Sp .Vb 1 \& char* SvPVbyte_force(SV* sv, STRLEN len) .Ve .IP "SvPVbyte_nolen" 8 .IX Xref "SvPVbyte_nolen" .IX Item "SvPVbyte_nolen" Like \f(CW\*(C`SvPV_nolen\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to byte representation first if necessary. If the \s-1SV\s0 cannot be downgraded from \s-1UTF\-8,\s0 this croaks. .Sp .Vb 1 \& char* SvPVbyte_nolen(SV* sv) .Ve .IP "SvPVbyte_nomg" 8 .IX Xref "SvPVbyte_nomg" .IX Item "SvPVbyte_nomg" Like \f(CW\*(C`SvPVbyte\*(C'\fR, but does not process get magic. .Sp .Vb 1 \& char* SvPVbyte_nomg(SV* sv, STRLEN len) .Ve .IP "sv_pvbyten_force" 8 .IX Xref "sv_pvbyten_force" .IX Item "sv_pvbyten_force" The backend for the \f(CW\*(C`SvPVbytex_force\*(C'\fR macro. Always use the macro instead. If the \s-1SV\s0 cannot be downgraded from \s-1UTF\-8,\s0 this croaks. .Sp .Vb 1 \& char* sv_pvbyten_force(SV *const sv, STRLEN *const lp) .Ve .IP "SvPVbyte_or_null" 8 .IX Xref "SvPVbyte_or_null" .IX Item "SvPVbyte_or_null" Like \f(CW\*(C`SvPVbyte\*(C'\fR, but when \f(CW\*(C`sv\*(C'\fR is undef, returns \f(CW\*(C`NULL\*(C'\fR. .Sp .Vb 1 \& char* SvPVbyte_or_null(SV* sv, STRLEN len) .Ve .IP "SvPVbyte_or_null_nomg" 8 .IX Xref "SvPVbyte_or_null_nomg" .IX Item "SvPVbyte_or_null_nomg" Like \f(CW\*(C`SvPVbyte_or_null\*(C'\fR, but does not process get magic. .Sp .Vb 1 \& char* SvPVbyte_or_null_nomg(SV* sv, STRLEN len) .Ve .IP "SvPVbytex" 8 .IX Xref "SvPVbytex" .IX Item "SvPVbytex" Like \f(CW\*(C`SvPV\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to byte representation first if necessary. Guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once; use the more efficient \f(CW\*(C`SvPVbyte\*(C'\fR otherwise. If the \s-1SV\s0 cannot be downgraded from \s-1UTF\-8,\s0 this croaks. .Sp .Vb 1 \& char* SvPVbytex(SV* sv, STRLEN len) .Ve .IP "SvPVbytex_force" 8 .IX Xref "SvPVbytex_force" .IX Item "SvPVbytex_force" Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to byte representation first if necessary. Guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once; use the more efficient \f(CW\*(C`SvPVbyte_force\*(C'\fR otherwise. If the \s-1SV\s0 cannot be downgraded from \s-1UTF\-8,\s0 this croaks. .Sp .Vb 1 \& char* SvPVbytex_force(SV* sv, STRLEN len) .Ve .IP "SvPVCLEAR" 8 .IX Xref "SvPVCLEAR" .IX Item "SvPVCLEAR" Ensures that sv is a SVt_PV and that its SvCUR is 0, and that it is properly null terminated. Equivalent to sv_setpvs(""), but more efficient. .Sp .Vb 1 \& char * SvPVCLEAR(SV* sv) .Ve .IP "SvPV_force" 8 .IX Xref "SvPV_force" .IX Item "SvPV_force" Like \f(CW\*(C`SvPV\*(C'\fR but will force the \s-1SV\s0 into containing a string (\f(CW\*(C`SvPOK\*(C'\fR), and only a string (\f(CW\*(C`SvPOK_only\*(C'\fR), by hook or by crook. You need force if you are going to update the \f(CW\*(C`SvPVX\*(C'\fR directly. Processes get magic. .Sp Note that coercing an arbitrary scalar into a plain \s-1PV\s0 will potentially strip useful data from it. For example if the \s-1SV\s0 was \f(CW\*(C`SvROK\*(C'\fR, then the referent will have its reference count decremented, and the \s-1SV\s0 itself may be converted to an \f(CW\*(C`SvPOK\*(C'\fR scalar with a string buffer containing a value such as \f(CW"ARRAY(0x1234)"\fR. .Sp .Vb 1 \& char* SvPV_force(SV* sv, STRLEN len) .Ve .IP "SvPV_force_nomg" 8 .IX Xref "SvPV_force_nomg" .IX Item "SvPV_force_nomg" Like \f(CW\*(C`SvPV_force\*(C'\fR, but doesn't process get magic. .Sp .Vb 1 \& char* SvPV_force_nomg(SV* sv, STRLEN len) .Ve .IP "SvPV_nolen" 8 .IX Xref "SvPV_nolen" .IX Item "SvPV_nolen" Like \f(CW\*(C`SvPV\*(C'\fR but doesn't set a length variable. .Sp .Vb 1 \& char* SvPV_nolen(SV* sv) .Ve .IP "SvPV_nomg" 8 .IX Xref "SvPV_nomg" .IX Item "SvPV_nomg" Like \f(CW\*(C`SvPV\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& char* SvPV_nomg(SV* sv, STRLEN len) .Ve .IP "SvPV_nomg_nolen" 8 .IX Xref "SvPV_nomg_nolen" .IX Item "SvPV_nomg_nolen" Like \f(CW\*(C`SvPV_nolen\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& char* SvPV_nomg_nolen(SV* sv) .Ve .IP "sv_pvn_force" 8 .IX Xref "sv_pvn_force" .IX Item "sv_pvn_force" Get a sensible string out of the \s-1SV\s0 somehow. A private implementation of the \f(CW\*(C`SvPV_force\*(C'\fR macro for compilers which can't cope with complex macro expressions. Always use the macro instead. .Sp .Vb 1 \& char* sv_pvn_force(SV* sv, STRLEN* lp) .Ve .IP "sv_pvn_force_flags" 8 .IX Xref "sv_pvn_force_flags" .IX Item "sv_pvn_force_flags" Get a sensible string out of the \s-1SV\s0 somehow. If \f(CW\*(C`flags\*(C'\fR has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, will \f(CW\*(C`mg_get\*(C'\fR on \f(CW\*(C`sv\*(C'\fR if appropriate, else not. \f(CW\*(C`sv_pvn_force\*(C'\fR and \f(CW\*(C`sv_pvn_force_nomg\*(C'\fR are implemented in terms of this function. You normally want to use the various wrapper macros instead: see \&\f(CW"SvPV_force"\fR and \f(CW"SvPV_force_nomg"\fR. .Sp .Vb 3 \& char* sv_pvn_force_flags(SV *const sv, \& STRLEN *const lp, \& const I32 flags) .Ve .IP "SvPV_set" 8 .IX Xref "SvPV_set" .IX Item "SvPV_set" This is probably not what you want to use, you probably wanted \&\*(L"sv_usepvn_flags\*(R" or \*(L"sv_setpvn\*(R" or \*(L"sv_setpvs\*(R". .Sp Set the value of the \s-1PV\s0 pointer in \f(CW\*(C`sv\*(C'\fR to the Perl allocated \&\f(CW\*(C`NUL\*(C'\fR\-terminated string \f(CW\*(C`val\*(C'\fR. See also \f(CW"SvIV_set"\fR. .Sp Remember to free the previous \s-1PV\s0 buffer. There are many things to check. Beware that the existing pointer may be involved in copy-on-write or other mischief, so do \f(CW\*(C`SvOOK_off(sv)\*(C'\fR and use \f(CW\*(C`sv_force_normal\*(C'\fR or \&\f(CW\*(C`SvPV_force\*(C'\fR (or check the \f(CW\*(C`SvIsCOW\*(C'\fR flag) first to make sure this modification is safe. Then finally, if it is not a \s-1COW,\s0 call \f(CW\*(C`SvPV_free\*(C'\fR to free the previous \s-1PV\s0 buffer. .Sp .Vb 1 \& void SvPV_set(SV* sv, char* val) .Ve .IP "SvPVutf8" 8 .IX Xref "SvPVutf8" .IX Item "SvPVutf8" Like \f(CW\*(C`SvPV\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to \s-1UTF\-8\s0 first if necessary. .Sp .Vb 1 \& char* SvPVutf8(SV* sv, STRLEN len) .Ve .IP "sv_pvutf8n_force" 8 .IX Xref "sv_pvutf8n_force" .IX Item "sv_pvutf8n_force" The backend for the \f(CW\*(C`SvPVutf8x_force\*(C'\fR macro. Always use the macro instead. .Sp .Vb 1 \& char* sv_pvutf8n_force(SV *const sv, STRLEN *const lp) .Ve .IP "SvPVutf8x" 8 .IX Xref "SvPVutf8x" .IX Item "SvPVutf8x" Like \f(CW\*(C`SvPV\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to \s-1UTF\-8\s0 first if necessary. Guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once; use the more efficient \f(CW\*(C`SvPVutf8\*(C'\fR otherwise. .Sp .Vb 1 \& char* SvPVutf8x(SV* sv, STRLEN len) .Ve .IP "SvPVutf8x_force" 8 .IX Xref "SvPVutf8x_force" .IX Item "SvPVutf8x_force" Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to \s-1UTF\-8\s0 first if necessary. Guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once; use the more efficient \f(CW\*(C`SvPVutf8_force\*(C'\fR otherwise. .Sp .Vb 1 \& char* SvPVutf8x_force(SV* sv, STRLEN len) .Ve .IP "SvPVutf8_force" 8 .IX Xref "SvPVutf8_force" .IX Item "SvPVutf8_force" Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to \s-1UTF\-8\s0 first if necessary. .Sp .Vb 1 \& char* SvPVutf8_force(SV* sv, STRLEN len) .Ve .IP "SvPVutf8_nolen" 8 .IX Xref "SvPVutf8_nolen" .IX Item "SvPVutf8_nolen" Like \f(CW\*(C`SvPV_nolen\*(C'\fR, but converts \f(CW\*(C`sv\*(C'\fR to \s-1UTF\-8\s0 first if necessary. .Sp .Vb 1 \& char* SvPVutf8_nolen(SV* sv) .Ve .IP "SvPVutf8_nomg" 8 .IX Xref "SvPVutf8_nomg" .IX Item "SvPVutf8_nomg" Like \f(CW\*(C`SvPVutf8\*(C'\fR, but does not process get magic. .Sp .Vb 1 \& char* SvPVutf8_nomg(SV* sv, STRLEN len) .Ve .IP "SvPVutf8_or_null" 8 .IX Xref "SvPVutf8_or_null" .IX Item "SvPVutf8_or_null" Like \f(CW\*(C`SvPVutf8\*(C'\fR, but when \f(CW\*(C`sv\*(C'\fR is undef, returns \f(CW\*(C`NULL\*(C'\fR. .Sp .Vb 1 \& char* SvPVutf8_or_null(SV* sv, STRLEN len) .Ve .IP "SvPVutf8_or_null_nomg" 8 .IX Xref "SvPVutf8_or_null_nomg" .IX Item "SvPVutf8_or_null_nomg" Like \f(CW\*(C`SvPVutf8_or_null\*(C'\fR, but does not process get magic. .Sp .Vb 1 \& char* SvPVutf8_or_null_nomg(SV* sv, STRLEN len) .Ve .IP "SvPVX" 8 .IX Xref "SvPVX" .IX Item "SvPVX" Returns a pointer to the physical string in the \s-1SV.\s0 The \s-1SV\s0 must contain a string. Prior to 5.9.3 it is not safe to execute this macro unless the \s-1SV\s0's type >= \f(CW\*(C`SVt_PV\*(C'\fR. .Sp This is also used to store the name of an autoloaded subroutine in an \s-1XS AUTOLOAD\s0 routine. See \*(L"Autoloading with XSUBs\*(R" in perlguts. .Sp .Vb 1 \& char* SvPVX(SV* sv) .Ve .IP "SvPVx" 8 .IX Xref "SvPVx" .IX Item "SvPVx" A version of \f(CW\*(C`SvPV\*(C'\fR which guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. Only use this if \f(CW\*(C`sv\*(C'\fR is an expression with side effects, otherwise use the more efficient \f(CW\*(C`SvPV\*(C'\fR. .Sp .Vb 1 \& char* SvPVx(SV* sv, STRLEN len) .Ve .IP "SvREADONLY" 8 .IX Xref "SvREADONLY" .IX Item "SvREADONLY" Returns true if the argument is readonly, otherwise returns false. Exposed to perl code via \fBInternals::SvREADONLY()\fR. .Sp .Vb 1 \& U32 SvREADONLY(SV* sv) .Ve .IP "SvREADONLY_off" 8 .IX Xref "SvREADONLY_off" .IX Item "SvREADONLY_off" Mark an object as not-readonly. Exactly what this mean depends on the object type. Exposed to perl code via \fBInternals::SvREADONLY()\fR. .Sp .Vb 1 \& U32 SvREADONLY_off(SV* sv) .Ve .IP "SvREADONLY_on" 8 .IX Xref "SvREADONLY_on" .IX Item "SvREADONLY_on" Mark an object as readonly. Exactly what this means depends on the object type. Exposed to perl code via \fBInternals::SvREADONLY()\fR. .Sp .Vb 1 \& U32 SvREADONLY_on(SV* sv) .Ve .IP "sv_ref" 8 .IX Xref "sv_ref" .IX Item "sv_ref" Returns a \s-1SV\s0 describing what the \s-1SV\s0 passed in is a reference to. .Sp dst can be a \s-1SV\s0 to be set to the description or \s-1NULL,\s0 in which case a mortal \s-1SV\s0 is returned. .Sp If ob is true and the \s-1SV\s0 is blessed, the description is the class name, otherwise it is the type of the \s-1SV, \*(L"SCALAR\*(R", \*(L"ARRAY\*(R"\s0 etc. .Sp .Vb 2 \& SV* sv_ref(SV *dst, const SV *const sv, \& const int ob) .Ve .IP "SvREFCNT" 8 .IX Xref "SvREFCNT" .IX Item "SvREFCNT" Returns the value of the object's reference count. Exposed to perl code via \fBInternals::SvREFCNT()\fR. .Sp .Vb 1 \& U32 SvREFCNT(SV* sv) .Ve .IP "SvREFCNT_dec" 8 .IX Xref "SvREFCNT_dec" .IX Item "SvREFCNT_dec" Decrements the reference count of the given \s-1SV.\s0 \f(CW\*(C`sv\*(C'\fR may be \f(CW\*(C`NULL\*(C'\fR. .Sp .Vb 1 \& void SvREFCNT_dec(SV *sv) .Ve .IP "SvREFCNT_dec_NN" 8 .IX Xref "SvREFCNT_dec_NN" .IX Item "SvREFCNT_dec_NN" Same as \f(CW\*(C`SvREFCNT_dec\*(C'\fR, but can only be used if you know \f(CW\*(C`sv\*(C'\fR is not \f(CW\*(C`NULL\*(C'\fR. Since we don't have to check the NULLness, it's faster and smaller. .Sp .Vb 1 \& void SvREFCNT_dec_NN(SV *sv) .Ve .IP "SvREFCNT_inc" 8 .IX Xref "SvREFCNT_inc" .IX Item "SvREFCNT_inc" Increments the reference count of the given \s-1SV,\s0 returning the \s-1SV.\s0 .Sp All of the following \f(CW\*(C`SvREFCNT_inc\*(C'\fR* are optimized versions of \&\f(CW\*(C`SvREFCNT_inc\*(C'\fR, and can be replaced with \f(CW\*(C`SvREFCNT_inc\*(C'\fR. .Sp .Vb 1 \& SV * SvREFCNT_inc(SV *sv) .Ve .IP "SvREFCNT_inc_NN" 8 .IX Xref "SvREFCNT_inc_NN" .IX Item "SvREFCNT_inc_NN" Same as \f(CW\*(C`SvREFCNT_inc\*(C'\fR, but can only be used if you know \f(CW\*(C`sv\*(C'\fR is not \f(CW\*(C`NULL\*(C'\fR. Since we don't have to check the NULLness, it's faster and smaller. .Sp .Vb 1 \& SV * SvREFCNT_inc_NN(SV *sv) .Ve .IP "SvREFCNT_inc_simple" 8 .IX Xref "SvREFCNT_inc_simple" .IX Item "SvREFCNT_inc_simple" Same as \f(CW\*(C`SvREFCNT_inc\*(C'\fR, but can only be used with expressions without side effects. Since we don't have to store a temporary value, it's faster. .Sp .Vb 1 \& SV* SvREFCNT_inc_simple(SV* sv) .Ve .IP "SvREFCNT_inc_simple_NN" 8 .IX Xref "SvREFCNT_inc_simple_NN" .IX Item "SvREFCNT_inc_simple_NN" Same as \f(CW\*(C`SvREFCNT_inc_simple\*(C'\fR, but can only be used if you know \f(CW\*(C`sv\*(C'\fR is not \f(CW\*(C`NULL\*(C'\fR. Since we don't have to check the NULLness, it's faster and smaller. .Sp .Vb 1 \& SV* SvREFCNT_inc_simple_NN(SV* sv) .Ve .IP "SvREFCNT_inc_simple_void" 8 .IX Xref "SvREFCNT_inc_simple_void" .IX Item "SvREFCNT_inc_simple_void" Same as \f(CW\*(C`SvREFCNT_inc_simple\*(C'\fR, but can only be used if you don't need the return value. The macro doesn't need to return a meaningful value. .Sp .Vb 1 \& void SvREFCNT_inc_simple_void(SV* sv) .Ve .IP "SvREFCNT_inc_simple_void_NN" 8 .IX Xref "SvREFCNT_inc_simple_void_NN" .IX Item "SvREFCNT_inc_simple_void_NN" Same as \f(CW\*(C`SvREFCNT_inc\*(C'\fR, but can only be used if you don't need the return value, and you know that \f(CW\*(C`sv\*(C'\fR is not \f(CW\*(C`NULL\*(C'\fR. The macro doesn't need to return a meaningful value, or check for NULLness, so it's smaller and faster. .Sp .Vb 1 \& void SvREFCNT_inc_simple_void_NN(SV* sv) .Ve .IP "SvREFCNT_inc_void" 8 .IX Xref "SvREFCNT_inc_void" .IX Item "SvREFCNT_inc_void" Same as \f(CW\*(C`SvREFCNT_inc\*(C'\fR, but can only be used if you don't need the return value. The macro doesn't need to return a meaningful value. .Sp .Vb 1 \& void SvREFCNT_inc_void(SV *sv) .Ve .IP "SvREFCNT_inc_void_NN" 8 .IX Xref "SvREFCNT_inc_void_NN" .IX Item "SvREFCNT_inc_void_NN" Same as \f(CW\*(C`SvREFCNT_inc\*(C'\fR, but can only be used if you don't need the return value, and you know that \f(CW\*(C`sv\*(C'\fR is not \f(CW\*(C`NULL\*(C'\fR. The macro doesn't need to return a meaningful value, or check for NULLness, so it's smaller and faster. .Sp .Vb 1 \& void SvREFCNT_inc_void_NN(SV* sv) .Ve .IP "sv_reftype" 8 .IX Xref "sv_reftype" .IX Item "sv_reftype" Returns a string describing what the \s-1SV\s0 is a reference to. .Sp If ob is true and the \s-1SV\s0 is blessed, the string is the class name, otherwise it is the type of the \s-1SV, \*(L"SCALAR\*(R", \*(L"ARRAY\*(R"\s0 etc. .Sp .Vb 1 \& const char* sv_reftype(const SV *const sv, const int ob) .Ve .IP "sv_replace" 8 .IX Xref "sv_replace" .IX Item "sv_replace" Make the first argument a copy of the second, then delete the original. The target \s-1SV\s0 physically takes over ownership of the body of the source \s-1SV\s0 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 \s-1SV\s0 copying operation; most of the time you'll want to use \f(CW\*(C`sv_setsv\*(C'\fR or one of its many macro front-ends. .Sp .Vb 1 \& void sv_replace(SV *const sv, SV *const nsv) .Ve .IP "sv_report_used" 8 .IX Xref "sv_report_used" .IX Item "sv_report_used" Dump the contents of all SVs not yet freed (debugging aid). .Sp .Vb 1 \& void sv_report_used() .Ve .IP "sv_reset" 8 .IX Xref "sv_reset" .IX Item "sv_reset" Underlying implementation for the \f(CW\*(C`reset\*(C'\fR Perl function. Note that the perl-level function is vaguely deprecated. .Sp .Vb 1 \& void sv_reset(const char* s, HV *const stash) .Ve .IP "SvROK" 8 .IX Xref "SvROK" .IX Item "SvROK" Tests if the \s-1SV\s0 is an \s-1RV.\s0 .Sp .Vb 1 \& U32 SvROK(SV* sv) .Ve .IP "SvROK_off" 8 .IX Xref "SvROK_off" .IX Item "SvROK_off" Unsets the \s-1RV\s0 status of an \s-1SV.\s0 .Sp .Vb 1 \& void SvROK_off(SV* sv) .Ve .IP "SvROK_on" 8 .IX Xref "SvROK_on" .IX Item "SvROK_on" Tells an \s-1SV\s0 that it is an \s-1RV.\s0 .Sp .Vb 1 \& void SvROK_on(SV* sv) .Ve .IP "SvRV" 8 .IX Xref "SvRV" .IX Item "SvRV" Dereferences an \s-1RV\s0 to return the \s-1SV.\s0 .Sp .Vb 1 \& SV* SvRV(SV* sv) .Ve .IP "SvRV_set" 8 .IX Xref "SvRV_set" .IX Item "SvRV_set" Set the value of the \s-1RV\s0 pointer in \f(CW\*(C`sv\*(C'\fR to val. See \f(CW"SvIV_set"\fR. .Sp .Vb 1 \& void SvRV_set(SV* sv, SV* val) .Ve .IP "sv_rvunweaken" 8 .IX Xref "sv_rvunweaken" .IX Item "sv_rvunweaken" Unweaken a reference: Clear the \f(CW\*(C`SvWEAKREF\*(C'\fR flag on this \s-1RV\s0; remove the backreference to this \s-1RV\s0 from the array of backreferences associated with the target \s-1SV,\s0 increment the refcount of the target. Silently ignores \f(CW\*(C`undef\*(C'\fR and warns on non-weak references. .Sp .Vb 1 \& SV* sv_rvunweaken(SV *const sv) .Ve .IP "sv_rvweaken" 8 .IX Xref "sv_rvweaken" .IX Item "sv_rvweaken" Weaken a reference: set the \f(CW\*(C`SvWEAKREF\*(C'\fR flag on this \s-1RV\s0; give the referred-to \s-1SV\s0 \f(CW\*(C`PERL_MAGIC_backref\*(C'\fR magic if it hasn't already; and push a back-reference to this \s-1RV\s0 onto the array of backreferences associated with that magic. If the \s-1RV\s0 is magical, set magic will be called after the \s-1RV\s0 is cleared. Silently ignores \f(CW\*(C`undef\*(C'\fR and warns on already-weak references. .Sp .Vb 1 \& SV* sv_rvweaken(SV *const sv) .Ve .IP "sv_setiv" 8 .IX Xref "sv_setiv" .IX Item "sv_setiv" Copies an integer into the given \s-1SV,\s0 upgrading first if necessary. Does not handle 'set' magic. See also \f(CW"sv_setiv_mg"\fR. .Sp .Vb 1 \& void sv_setiv(SV *const sv, const IV num) .Ve .IP "sv_setiv_mg" 8 .IX Xref "sv_setiv_mg" .IX Item "sv_setiv_mg" Like \f(CW\*(C`sv_setiv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_setiv_mg(SV *const sv, const IV i) .Ve .IP "sv_setnv" 8 .IX Xref "sv_setnv" .IX Item "sv_setnv" Copies a double into the given \s-1SV,\s0 upgrading first if necessary. Does not handle 'set' magic. See also \f(CW"sv_setnv_mg"\fR. .Sp .Vb 1 \& void sv_setnv(SV *const sv, const NV num) .Ve .IP "sv_setnv_mg" 8 .IX Xref "sv_setnv_mg" .IX Item "sv_setnv_mg" Like \f(CW\*(C`sv_setnv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_setnv_mg(SV *const sv, const NV num) .Ve .IP "sv_setpv" 8 .IX Xref "sv_setpv" .IX Item "sv_setpv" Copies a string into an \s-1SV.\s0 The string must be terminated with a \f(CW\*(C`NUL\*(C'\fR character, and not contain embeded \f(CW\*(C`NUL\*(C'\fR's. Does not handle 'set' magic. See \f(CW"sv_setpv_mg"\fR. .Sp .Vb 1 \& void sv_setpv(SV *const sv, const char *const ptr) .Ve .IP "sv_setpvf" 8 .IX Xref "sv_setpvf" .IX Item "sv_setpvf" Works like \f(CW\*(C`sv_catpvf\*(C'\fR but copies the text into the \s-1SV\s0 instead of appending it. Does not handle 'set' magic. See \f(CW"sv_setpvf_mg"\fR. .Sp .Vb 2 \& void sv_setpvf(SV *const sv, const char *const pat, \& ...) .Ve .IP "sv_setpvf_mg" 8 .IX Xref "sv_setpvf_mg" .IX Item "sv_setpvf_mg" Like \f(CW\*(C`sv_setpvf\*(C'\fR, but also handles 'set' magic. .Sp .Vb 2 \& void sv_setpvf_mg(SV *const sv, \& const char *const pat, ...) .Ve .IP "sv_setpviv" 8 .IX Xref "sv_setpviv" .IX Item "sv_setpviv" \&\s-1DEPRECATED\s0! 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. .Sp Copies an integer into the given \s-1SV,\s0 also updating its string value. Does not handle 'set' magic. See \f(CW"sv_setpviv_mg"\fR. .Sp .Vb 1 \& void sv_setpviv(SV *const sv, const IV num) .Ve .IP "sv_setpviv_mg" 8 .IX Xref "sv_setpviv_mg" .IX Item "sv_setpviv_mg" \&\s-1DEPRECATED\s0! 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. .Sp Like \f(CW\*(C`sv_setpviv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_setpviv_mg(SV *const sv, const IV iv) .Ve .IP "sv_setpvn" 8 .IX Xref "sv_setpvn" .IX Item "sv_setpvn" Copies a string (possibly containing embedded \f(CW\*(C`NUL\*(C'\fR characters) into an \s-1SV.\s0 The \f(CW\*(C`len\*(C'\fR parameter indicates the number of bytes to be copied. If the \f(CW\*(C`ptr\*(C'\fR argument is \s-1NULL\s0 the \s-1SV\s0 will become undefined. Does not handle 'set' magic. See \f(CW"sv_setpvn_mg"\fR. .Sp The \s-1UTF\-8\s0 flag is not changed by this function. A terminating \s-1NUL\s0 byte is guaranteed. .Sp .Vb 2 \& void sv_setpvn(SV *const sv, const char *const ptr, \& const STRLEN len) .Ve .IP "sv_setpvn_mg" 8 .IX Xref "sv_setpvn_mg" .IX Item "sv_setpvn_mg" Like \f(CW\*(C`sv_setpvn\*(C'\fR, but also handles 'set' magic. .Sp .Vb 3 \& void sv_setpvn_mg(SV *const sv, \& const char *const ptr, \& const STRLEN len) .Ve .IP "sv_setpvs" 8 .IX Xref "sv_setpvs" .IX Item "sv_setpvs" Like \f(CW\*(C`sv_setpvn\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& void sv_setpvs(SV* sv, "literal string") .Ve .IP "sv_setpvs_mg" 8 .IX Xref "sv_setpvs_mg" .IX Item "sv_setpvs_mg" Like \f(CW\*(C`sv_setpvn_mg\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 1 \& void sv_setpvs_mg(SV* sv, "literal string") .Ve .IP "sv_setpv_bufsize" 8 .IX Xref "sv_setpv_bufsize" .IX Item "sv_setpv_bufsize" Sets the \s-1SV\s0 to be a string of cur bytes length, with at least len bytes available. Ensures that there is a null byte at SvEND. Returns a char * pointer to the SvPV buffer. .Sp .Vb 2 \& char * sv_setpv_bufsize(SV *const sv, const STRLEN cur, \& const STRLEN len) .Ve .IP "sv_setpv_mg" 8 .IX Xref "sv_setpv_mg" .IX Item "sv_setpv_mg" Like \f(CW\*(C`sv_setpv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_setpv_mg(SV *const sv, const char *const ptr) .Ve .IP "sv_setref_iv" 8 .IX Xref "sv_setref_iv" .IX Item "sv_setref_iv" Copies an integer into a new \s-1SV,\s0 optionally blessing the \s-1SV.\s0 The \f(CW\*(C`rv\*(C'\fR argument will be upgraded to an \s-1RV.\s0 That \s-1RV\s0 will be modified to point to the new \s-1SV.\s0 The \f(CW\*(C`classname\*(C'\fR argument indicates the package for the blessing. Set \f(CW\*(C`classname\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR to avoid the blessing. The new \s-1SV\s0 will have a reference count of 1, and the \s-1RV\s0 will be returned. .Sp .Vb 3 \& SV* sv_setref_iv(SV *const rv, \& const char *const classname, \& const IV iv) .Ve .IP "sv_setref_nv" 8 .IX Xref "sv_setref_nv" .IX Item "sv_setref_nv" Copies a double into a new \s-1SV,\s0 optionally blessing the \s-1SV.\s0 The \f(CW\*(C`rv\*(C'\fR argument will be upgraded to an \s-1RV.\s0 That \s-1RV\s0 will be modified to point to the new \s-1SV.\s0 The \f(CW\*(C`classname\*(C'\fR argument indicates the package for the blessing. Set \f(CW\*(C`classname\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR to avoid the blessing. The new \s-1SV\s0 will have a reference count of 1, and the \s-1RV\s0 will be returned. .Sp .Vb 3 \& SV* sv_setref_nv(SV *const rv, \& const char *const classname, \& const NV nv) .Ve .IP "sv_setref_pv" 8 .IX Xref "sv_setref_pv" .IX Item "sv_setref_pv" Copies a pointer into a new \s-1SV,\s0 optionally blessing the \s-1SV.\s0 The \f(CW\*(C`rv\*(C'\fR argument will be upgraded to an \s-1RV.\s0 That \s-1RV\s0 will be modified to point to the new \s-1SV.\s0 If the \f(CW\*(C`pv\*(C'\fR argument is \f(CW\*(C`NULL\*(C'\fR, then \f(CW\*(C`PL_sv_undef\*(C'\fR will be placed into the \s-1SV.\s0 The \f(CW\*(C`classname\*(C'\fR argument indicates the package for the blessing. Set \f(CW\*(C`classname\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR to avoid the blessing. The new \s-1SV\s0 will have a reference count of 1, and the \s-1RV\s0 will be returned. .Sp Do not use with other Perl types such as \s-1HV, AV, SV, CV,\s0 because those objects will become corrupted by the pointer copy process. .Sp Note that \f(CW\*(C`sv_setref_pvn\*(C'\fR copies the string while this copies the pointer. .Sp .Vb 3 \& SV* sv_setref_pv(SV *const rv, \& const char *const classname, \& void *const pv) .Ve .IP "sv_setref_pvn" 8 .IX Xref "sv_setref_pvn" .IX Item "sv_setref_pvn" Copies a string into a new \s-1SV,\s0 optionally blessing the \s-1SV.\s0 The length of the string must be specified with \f(CW\*(C`n\*(C'\fR. The \f(CW\*(C`rv\*(C'\fR argument will be upgraded to an \s-1RV.\s0 That \s-1RV\s0 will be modified to point to the new \s-1SV.\s0 The \f(CW\*(C`classname\*(C'\fR argument indicates the package for the blessing. Set \f(CW\*(C`classname\*(C'\fR to \&\f(CW\*(C`NULL\*(C'\fR to avoid the blessing. The new \s-1SV\s0 will have a reference count of 1, and the \s-1RV\s0 will be returned. .Sp Note that \f(CW\*(C`sv_setref_pv\*(C'\fR copies the pointer while this copies the string. .Sp .Vb 4 \& SV* sv_setref_pvn(SV *const rv, \& const char *const classname, \& const char *const pv, \& const STRLEN n) .Ve .IP "sv_setref_pvs" 8 .IX Xref "sv_setref_pvs" .IX Item "sv_setref_pvs" Like \f(CW\*(C`sv_setref_pvn\*(C'\fR, but takes a literal string instead of a string/length pair. .Sp .Vb 3 \& SV * sv_setref_pvs(SV *const rv, \& const char *const classname, \& "literal string") .Ve .IP "sv_setref_uv" 8 .IX Xref "sv_setref_uv" .IX Item "sv_setref_uv" Copies an unsigned integer into a new \s-1SV,\s0 optionally blessing the \s-1SV.\s0 The \f(CW\*(C`rv\*(C'\fR argument will be upgraded to an \s-1RV.\s0 That \s-1RV\s0 will be modified to point to the new \s-1SV.\s0 The \f(CW\*(C`classname\*(C'\fR argument indicates the package for the blessing. Set \f(CW\*(C`classname\*(C'\fR to \f(CW\*(C`NULL\*(C'\fR to avoid the blessing. The new \s-1SV\s0 will have a reference count of 1, and the \s-1RV\s0 will be returned. .Sp .Vb 3 \& SV* sv_setref_uv(SV *const rv, \& const char *const classname, \& const UV uv) .Ve .IP "sv_setsv" 8 .IX Xref "sv_setsv" .IX Item "sv_setsv" Copies the contents of the source \s-1SV\s0 \f(CW\*(C`ssv\*(C'\fR into the destination \s-1SV\s0 \&\f(CW\*(C`dsv\*(C'\fR. The source \s-1SV\s0 may be destroyed if it is mortal, so don't use this function if the source \s-1SV\s0 needs to be reused. Does not handle 'set' magic on destination \s-1SV.\s0 Calls 'get' magic on source \s-1SV.\s0 Loosely speaking, it performs a copy-by-value, obliterating any previous content of the destination. .Sp You probably want to use one of the assortment of wrappers, such as \&\f(CW\*(C`SvSetSV\*(C'\fR, \f(CW\*(C`SvSetSV_nosteal\*(C'\fR, \f(CW\*(C`SvSetMagicSV\*(C'\fR and \&\f(CW\*(C`SvSetMagicSV_nosteal\*(C'\fR. .Sp .Vb 1 \& void sv_setsv(SV *dstr, SV *sstr) .Ve .IP "sv_setsv_flags" 8 .IX Xref "sv_setsv_flags" .IX Item "sv_setsv_flags" Copies the contents of the source \s-1SV\s0 \f(CW\*(C`ssv\*(C'\fR into the destination \s-1SV\s0 \&\f(CW\*(C`dsv\*(C'\fR. The source \s-1SV\s0 may be destroyed if it is mortal, so don't use this function if the source \s-1SV\s0 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 \f(CW\*(C`flags\*(C'\fR parameter has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, will \f(CW\*(C`mg_get\*(C'\fR on \&\f(CW\*(C`ssv\*(C'\fR if appropriate, else not. If the \f(CW\*(C`flags\*(C'\fR parameter has the \f(CW\*(C`SV_NOSTEAL\*(C'\fR bit set then the buffers of temps will not be stolen. \f(CW\*(C`sv_setsv\*(C'\fR and \f(CW\*(C`sv_setsv_nomg\*(C'\fR are implemented in terms of this function. .Sp You probably want to use one of the assortment of wrappers, such as \&\f(CW\*(C`SvSetSV\*(C'\fR, \f(CW\*(C`SvSetSV_nosteal\*(C'\fR, \f(CW\*(C`SvSetMagicSV\*(C'\fR and \&\f(CW\*(C`SvSetMagicSV_nosteal\*(C'\fR. .Sp This is the primary function for copying scalars, and most other copy-ish functions and macros use this underneath. .Sp .Vb 2 \& void sv_setsv_flags(SV *dstr, SV *sstr, \& const I32 flags) .Ve .IP "sv_setsv_mg" 8 .IX Xref "sv_setsv_mg" .IX Item "sv_setsv_mg" Like \f(CW\*(C`sv_setsv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_setsv_mg(SV *const dstr, SV *const sstr) .Ve .IP "sv_setsv_nomg" 8 .IX Xref "sv_setsv_nomg" .IX Item "sv_setsv_nomg" Like \f(CW\*(C`sv_setsv\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& void sv_setsv_nomg(SV* dsv, SV* ssv) .Ve .IP "sv_setuv" 8 .IX Xref "sv_setuv" .IX Item "sv_setuv" Copies an unsigned integer into the given \s-1SV,\s0 upgrading first if necessary. Does not handle 'set' magic. See also \f(CW"sv_setuv_mg"\fR. .Sp .Vb 1 \& void sv_setuv(SV *const sv, const UV num) .Ve .IP "sv_setuv_mg" 8 .IX Xref "sv_setuv_mg" .IX Item "sv_setuv_mg" Like \f(CW\*(C`sv_setuv\*(C'\fR, but also handles 'set' magic. .Sp .Vb 1 \& void sv_setuv_mg(SV *const sv, const UV u) .Ve .IP "sv_set_undef" 8 .IX Xref "sv_set_undef" .IX Item "sv_set_undef" Equivalent to \f(CW\*(C`sv_setsv(sv, &PL_sv_undef)\*(C'\fR, but more efficient. Doesn't handle set magic. .Sp The perl equivalent is \f(CW\*(C`$sv = undef;\*(C'\fR. Note that it doesn't free any string buffer, unlike \f(CW\*(C`undef $sv\*(C'\fR. .Sp Introduced in perl 5.25.12. .Sp .Vb 1 \& void sv_set_undef(SV *sv) .Ve .IP "SvSTASH" 8 .IX Xref "SvSTASH" .IX Item "SvSTASH" Returns the stash of the \s-1SV.\s0 .Sp .Vb 1 \& HV* SvSTASH(SV* sv) .Ve .IP "SvSTASH_set" 8 .IX Xref "SvSTASH_set" .IX Item "SvSTASH_set" Set the value of the \s-1STASH\s0 pointer in \f(CW\*(C`sv\*(C'\fR to val. See \f(CW"SvIV_set"\fR. .Sp .Vb 1 \& void SvSTASH_set(SV* sv, HV* val) .Ve .IP "SvTAINT" 8 .IX Xref "SvTAINT" .IX Item "SvTAINT" Taints an \s-1SV\s0 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. \f(CW\*(C`SvTAINT\*(C'\fR 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. .Sp .Vb 1 \& void SvTAINT(SV* sv) .Ve .IP "SvTAINTED" 8 .IX Xref "SvTAINTED" .IX Item "SvTAINTED" Checks to see if an \s-1SV\s0 is tainted. Returns \s-1TRUE\s0 if it is, \s-1FALSE\s0 if not. .Sp .Vb 1 \& bool SvTAINTED(SV* sv) .Ve .IP "sv_tainted" 8 .IX Xref "sv_tainted" .IX Item "sv_tainted" Test an \s-1SV\s0 for taintedness. Use \f(CW\*(C`SvTAINTED\*(C'\fR instead. .Sp .Vb 1 \& bool sv_tainted(SV *const sv) .Ve .IP "SvTAINTED_off" 8 .IX Xref "SvTAINTED_off" .IX Item "SvTAINTED_off" Untaints an \s-1SV.\s0 Be \fIvery\fR careful with this routine, as it short-circuits some of Perl's fundamental security features. \s-1XS\s0 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. .Sp .Vb 1 \& void SvTAINTED_off(SV* sv) .Ve .IP "SvTAINTED_on" 8 .IX Xref "SvTAINTED_on" .IX Item "SvTAINTED_on" Marks an \s-1SV\s0 as tainted if tainting is enabled. .Sp .Vb 1 \& void SvTAINTED_on(SV* sv) .Ve .IP "SvTRUE" 8 .IX Xref "SvTRUE" .IX Item "SvTRUE" Returns a boolean indicating whether Perl would evaluate the \s-1SV\s0 as true or false. See \f(CW"SvOK"\fR for a defined/undefined test. Handles 'get' magic unless the scalar is already \f(CW\*(C`SvPOK\*(C'\fR, \f(CW\*(C`SvIOK\*(C'\fR or \f(CW\*(C`SvNOK\*(C'\fR (the public, not the private flags). .Sp See \f(CW"SvTRUEx"\fR for a version which guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. .Sp .Vb 1 \& bool SvTRUE(SV* sv) .Ve .IP "sv_true" 8 .IX Xref "sv_true" .IX Item "sv_true" Returns true if the \s-1SV\s0 has a true value by Perl's rules. Use the \f(CW\*(C`SvTRUE\*(C'\fR macro instead, which may call \f(CW\*(C`sv_true()\*(C'\fR or may instead use an in-line version. .Sp .Vb 1 \& I32 sv_true(SV *const sv) .Ve .IP "SvTRUE_nomg" 8 .IX Xref "SvTRUE_nomg" .IX Item "SvTRUE_nomg" Returns a boolean indicating whether Perl would evaluate the \s-1SV\s0 as true or false. See \f(CW"SvOK"\fR for a defined/undefined test. Does not handle 'get' magic. .Sp .Vb 1 \& bool SvTRUE_nomg(SV* sv) .Ve .IP "SvTRUEx" 8 .IX Xref "SvTRUEx" .IX Item "SvTRUEx" Returns a boolean indicating whether Perl would evaluate the \s-1SV\s0 as true or false. See \f(CW"SvOK"\fR for a defined/undefined test. Handles 'get' magic unless the scalar is already \f(CW\*(C`SvPOK\*(C'\fR, \f(CW\*(C`SvIOK\*(C'\fR or \f(CW\*(C`SvNOK\*(C'\fR (the public, not the private flags). .Sp This form guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. Only use this if \f(CW\*(C`sv\*(C'\fR is an expression with side effects, otherwise use the more efficient \f(CW\*(C`SvTRUE\*(C'\fR. .Sp .Vb 1 \& bool SvTRUEx(SV* sv) .Ve .IP "SvTYPE" 8 .IX Xref "SvTYPE" .IX Item "SvTYPE" Returns the type of the \s-1SV.\s0 See \f(CW"svtype"\fR. .Sp .Vb 1 \& svtype SvTYPE(SV* sv) .Ve .IP "sv_unmagic" 8 .IX Xref "sv_unmagic" .IX Item "sv_unmagic" Removes all magic of type \f(CW\*(C`type\*(C'\fR from an \s-1SV.\s0 .Sp .Vb 1 \& int sv_unmagic(SV *const sv, const int type) .Ve .IP "sv_unmagicext" 8 .IX Xref "sv_unmagicext" .IX Item "sv_unmagicext" Removes all magic of type \f(CW\*(C`type\*(C'\fR with the specified \f(CW\*(C`vtbl\*(C'\fR from an \s-1SV.\s0 .Sp .Vb 2 \& int sv_unmagicext(SV *const sv, const int type, \& MGVTBL *vtbl) .Ve .IP "sv_unref_flags" 8 .IX Xref "sv_unref_flags" .IX Item "sv_unref_flags" Unsets the \s-1RV\s0 status of the \s-1SV,\s0 and decrements the reference count of whatever was being referenced by the \s-1RV.\s0 This can almost be thought of as a reversal of \f(CW\*(C`newSVrv\*(C'\fR. The \f(CW\*(C`cflags\*(C'\fR argument can contain \&\f(CW\*(C`SV_IMMEDIATE_UNREF\*(C'\fR 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 \s-1SV\s0). See \f(CW"SvROK_off"\fR. .Sp .Vb 1 \& void sv_unref_flags(SV *const ref, const U32 flags) .Ve .IP "sv_untaint" 8 .IX Xref "sv_untaint" .IX Item "sv_untaint" Untaint an \s-1SV.\s0 Use \f(CW\*(C`SvTAINTED_off\*(C'\fR instead. .Sp .Vb 1 \& void sv_untaint(SV *const sv) .Ve .IP "SvUOK" 8 .IX Xref "SvUOK" .IX Item "SvUOK" Returns a boolean indicating whether the \s-1SV\s0 contains an integer that must be interpreted as unsigned. A non-negative integer whose value is within the range of both an \s-1IV\s0 and a \s-1UV\s0 may be flagged as either \f(CW\*(C`SvUOK\*(C'\fR or \f(CW\*(C`SvIOK\*(C'\fR. .Sp .Vb 1 \& bool SvUOK(SV* sv) .Ve .IP "SvUPGRADE" 8 .IX Xref "SvUPGRADE" .IX Item "SvUPGRADE" Used to upgrade an \s-1SV\s0 to a more complex form. Uses \f(CW\*(C`sv_upgrade\*(C'\fR to perform the upgrade if necessary. See \f(CW"svtype"\fR. .Sp .Vb 1 \& void SvUPGRADE(SV* sv, svtype type) .Ve .IP "sv_upgrade" 8 .IX Xref "sv_upgrade" .IX Item "sv_upgrade" Upgrade an \s-1SV\s0 to a more complex form. Generally adds a new body type to the \&\s-1SV,\s0 then copies across as much information as possible from the old body. It croaks if the \s-1SV\s0 is already in a more complex form than requested. You generally want to use the \f(CW\*(C`SvUPGRADE\*(C'\fR macro wrapper, which checks the type before calling \f(CW\*(C`sv_upgrade\*(C'\fR, and hence does not croak. See also \&\f(CW"svtype"\fR. .Sp .Vb 1 \& void sv_upgrade(SV *const sv, svtype new_type) .Ve .IP "sv_usepvn_flags" 8 .IX Xref "sv_usepvn_flags" .IX Item "sv_usepvn_flags" Tells an \s-1SV\s0 to use \f(CW\*(C`ptr\*(C'\fR to find its string value. Normally the string is stored inside the \s-1SV,\s0 but sv_usepvn allows the \s-1SV\s0 to use an outside string. \f(CW\*(C`ptr\*(C'\fR should point to memory that was allocated by \f(CW\*(C`Newx\*(C'\fR. It must be the start of a \f(CW\*(C`Newx\*(C'\fR\-ed block of memory, and not a pointer to the middle of it (beware of \f(CW\*(C`OOK\*(C'\fR and copy-on-write), and not be from a non\-\f(CW\*(C`Newx\*(C'\fR memory allocator like \f(CW\*(C`malloc\*(C'\fR. The string length, \f(CW\*(C`len\*(C'\fR, must be supplied. By default this function will \f(CW\*(C`Renew\*(C'\fR (i.e. realloc, move) the memory pointed to by \f(CW\*(C`ptr\*(C'\fR, so that pointer should not be freed or used by the programmer after giving it to \f(CW\*(C`sv_usepvn\*(C'\fR, and neither should any pointers from \*(L"behind\*(R" that pointer (e.g. ptr + 1) be used. .Sp If \f(CW\*(C`flags & SV_SMAGIC\*(C'\fR is true, will call \f(CW\*(C`SvSETMAGIC\*(C'\fR. If \&\f(CW\*(C`flags & SV_HAS_TRAILING_NUL\*(C'\fR is true, then \f(CW\*(C`ptr[len]\*(C'\fR must be \f(CW\*(C`NUL\*(C'\fR, and the realloc will be skipped (i.e. the buffer is actually at least 1 byte longer than \&\f(CW\*(C`len\*(C'\fR, and already meets the requirements for storing in \f(CW\*(C`SvPVX\*(C'\fR). .Sp .Vb 3 \& void sv_usepvn_flags(SV *const sv, char* ptr, \& const STRLEN len, \& const U32 flags) .Ve .IP "SvUTF8" 8 .IX Xref "SvUTF8" .IX Item "SvUTF8" Returns a U32 value indicating the \s-1UTF\-8\s0 status of an \s-1SV.\s0 If things are set-up properly, this indicates whether or not the \s-1SV\s0 contains \s-1UTF\-8\s0 encoded data. You should use this \fIafter\fR a call to \f(CW\*(C`SvPV()\*(C'\fR or one of its variants, in case any call to string overloading updates the internal flag. .Sp If you want to take into account the bytes pragma, use \f(CW"DO_UTF8"\fR instead. .Sp .Vb 1 \& U32 SvUTF8(SV* sv) .Ve .IP "sv_utf8_decode" 8 .IX Xref "sv_utf8_decode" .IX Item "sv_utf8_decode" If the \s-1PV\s0 of the \s-1SV\s0 is an octet sequence in Perl's extended \s-1UTF\-8\s0 and contains a multiple-byte character, the \f(CW\*(C`SvUTF8\*(C'\fR flag is turned on so that it looks like a character. If the \s-1PV\s0 contains only single-byte characters, the \f(CW\*(C`SvUTF8\*(C'\fR flag stays off. Scans \s-1PV\s0 for validity and returns \s-1FALSE\s0 if the \s-1PV\s0 is invalid \s-1UTF\-8.\s0 .Sp .Vb 1 \& bool sv_utf8_decode(SV *const sv) .Ve .IP "sv_utf8_downgrade" 8 .IX Xref "sv_utf8_downgrade" .IX Item "sv_utf8_downgrade" Attempts to convert the \s-1PV\s0 of an \s-1SV\s0 from characters to bytes. If the \s-1PV\s0 contains a character that cannot fit in a byte, this conversion will fail; in this case, either returns false or, if \f(CW\*(C`fail_ok\*(C'\fR is not true, croaks. .Sp This is not a general purpose Unicode to byte encoding interface: use the \f(CW\*(C`Encode\*(C'\fR extension for that. .Sp This function process get magic on \f(CW\*(C`sv\*(C'\fR. .Sp .Vb 2 \& bool sv_utf8_downgrade(SV *const sv, \& const bool fail_ok) .Ve .IP "sv_utf8_downgrade_flags" 8 .IX Xref "sv_utf8_downgrade_flags" .IX Item "sv_utf8_downgrade_flags" Like \f(CW\*(C`sv_utf8_downgrade\*(C'\fR, but with additional \f(CW\*(C`flags\*(C'\fR. If \f(CW\*(C`flags\*(C'\fR has \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, processes get magic on \f(CW\*(C`sv\*(C'\fR. .Sp .Vb 3 \& bool sv_utf8_downgrade_flags(SV *const sv, \& const bool fail_ok, \& const U32 flags) .Ve .IP "sv_utf8_downgrade_nomg" 8 .IX Xref "sv_utf8_downgrade_nomg" .IX Item "sv_utf8_downgrade_nomg" Like \f(CW\*(C`sv_utf8_downgrade\*(C'\fR, but does not process get magic on \f(CW\*(C`sv\*(C'\fR. .Sp .Vb 2 \& bool sv_utf8_downgrade_nomg(SV *const sv, \& const bool fail_ok) .Ve .IP "sv_utf8_encode" 8 .IX Xref "sv_utf8_encode" .IX Item "sv_utf8_encode" Converts the \s-1PV\s0 of an \s-1SV\s0 to \s-1UTF\-8,\s0 but then turns the \f(CW\*(C`SvUTF8\*(C'\fR flag off so that it looks like octets again. .Sp .Vb 1 \& void sv_utf8_encode(SV *const sv) .Ve .IP "sv_utf8_upgrade" 8 .IX Xref "sv_utf8_upgrade" .IX Item "sv_utf8_upgrade" Converts the \s-1PV\s0 of an \s-1SV\s0 to its UTF\-8\-encoded form. Forces the \s-1SV\s0 to string form if it is not already. Will \f(CW\*(C`mg_get\*(C'\fR on \f(CW\*(C`sv\*(C'\fR if appropriate. Always sets the \f(CW\*(C`SvUTF8\*(C'\fR flag to avoid future validity checks even if the whole string is the same in \s-1UTF\-8\s0 as not. Returns the number of bytes in the converted string .Sp This is not a general purpose byte encoding to Unicode interface: use the Encode extension for that. .Sp .Vb 1 \& STRLEN sv_utf8_upgrade(SV *sv) .Ve .IP "sv_utf8_upgrade_flags" 8 .IX Xref "sv_utf8_upgrade_flags" .IX Item "sv_utf8_upgrade_flags" Converts the \s-1PV\s0 of an \s-1SV\s0 to its UTF\-8\-encoded form. Forces the \s-1SV\s0 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 \s-1UTF\-8.\s0 If \f(CW\*(C`flags\*(C'\fR has \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, will \f(CW\*(C`mg_get\*(C'\fR on \f(CW\*(C`sv\*(C'\fR if appropriate, else not. .Sp The \f(CW\*(C`SV_FORCE_UTF8_UPGRADE\*(C'\fR flag is now ignored. .Sp Returns the number of bytes in the converted string. .Sp This is not a general purpose byte encoding to Unicode interface: use the Encode extension for that. .Sp .Vb 2 \& STRLEN sv_utf8_upgrade_flags(SV *const sv, \& const I32 flags) .Ve .IP "sv_utf8_upgrade_flags_grow" 8 .IX Xref "sv_utf8_upgrade_flags_grow" .IX Item "sv_utf8_upgrade_flags_grow" Like \f(CW\*(C`sv_utf8_upgrade_flags\*(C'\fR, but has an additional parameter \f(CW\*(C`extra\*(C'\fR, which is the number of unused bytes the string of \f(CW\*(C`sv\*(C'\fR 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. .Sp \&\f(CW\*(C`sv_utf8_upgrade\*(C'\fR, \f(CW\*(C`sv_utf8_upgrade_nomg\*(C'\fR, and \f(CW\*(C`sv_utf8_upgrade_flags\*(C'\fR are implemented in terms of this function. .Sp Returns the number of bytes in the converted string (not including the spares). .Sp .Vb 3 \& STRLEN sv_utf8_upgrade_flags_grow(SV *const sv, \& const I32 flags, \& STRLEN extra) .Ve .IP "sv_utf8_upgrade_nomg" 8 .IX Xref "sv_utf8_upgrade_nomg" .IX Item "sv_utf8_upgrade_nomg" Like \f(CW\*(C`sv_utf8_upgrade\*(C'\fR, but doesn't do magic on \f(CW\*(C`sv\*(C'\fR. .Sp .Vb 1 \& STRLEN sv_utf8_upgrade_nomg(SV *sv) .Ve .IP "SvUTF8_off" 8 .IX Xref "SvUTF8_off" .IX Item "SvUTF8_off" Unsets the \s-1UTF\-8\s0 status of an \s-1SV\s0 (the data is not changed, just the flag). Do not use frivolously. .Sp .Vb 1 \& void SvUTF8_off(SV *sv) .Ve .IP "SvUTF8_on" 8 .IX Xref "SvUTF8_on" .IX Item "SvUTF8_on" Turn on the \s-1UTF\-8\s0 status of an \s-1SV\s0 (the data is not changed, just the flag). Do not use frivolously. .Sp .Vb 1 \& void SvUTF8_on(SV *sv) .Ve .IP "SvUV" 8 .IX Xref "SvUV" .IX Item "SvUV" Coerces the given \s-1SV\s0 to \s-1UV\s0 and returns it. The returned value in many circumstances will get stored in \f(CW\*(C`sv\*(C'\fR's \s-1UV\s0 slot, but not in all cases. (Use \&\f(CW"sv_setuv"\fR to make sure it does). .Sp See \f(CW"SvUVx"\fR for a version which guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. .Sp .Vb 1 \& UV SvUV(SV* sv) .Ve .IP "SvUV_nomg" 8 .IX Xref "SvUV_nomg" .IX Item "SvUV_nomg" Like \f(CW\*(C`SvUV\*(C'\fR but doesn't process magic. .Sp .Vb 1 \& UV SvUV_nomg(SV* sv) .Ve .IP "SvUV_set" 8 .IX Xref "SvUV_set" .IX Item "SvUV_set" Set the value of the \s-1UV\s0 pointer in \f(CW\*(C`sv\*(C'\fR to val. See \f(CW"SvIV_set"\fR. .Sp .Vb 1 \& void SvUV_set(SV* sv, UV val) .Ve .IP "SvUVX" 8 .IX Xref "SvUVX" .IX Item "SvUVX" Returns the raw value in the \s-1SV\s0's \s-1UV\s0 slot, without checks or conversions. Only use when you are sure \f(CW\*(C`SvIOK\*(C'\fR is true. See also \f(CW"SvUV"\fR. .Sp .Vb 1 \& UV SvUVX(SV* sv) .Ve .IP "SvUVx" 8 .IX Xref "SvUVx" .IX Item "SvUVx" Coerces the given \s-1SV\s0 to \s-1UV\s0 and returns it. The returned value in many circumstances will get stored in \f(CW\*(C`sv\*(C'\fR's \s-1UV\s0 slot, but not in all cases. (Use \&\f(CW"sv_setuv"\fR to make sure it does). .Sp This form guarantees to evaluate \f(CW\*(C`sv\*(C'\fR only once. Only use this if \f(CW\*(C`sv\*(C'\fR is an expression with side effects, otherwise use the more efficient \f(CW\*(C`SvUV\*(C'\fR. .Sp .Vb 1 \& UV SvUVx(SV* sv) .Ve .IP "SvUVXx" 8 .IX Xref "SvUVXx" .IX Item "SvUVXx" \&\s-1DEPRECATED\s0! 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. .Sp This is an unnecessary synonym for \*(L"SvUVX\*(R" .Sp .Vb 1 \& UV SvUVXx(SV* sv) .Ve .IP "sv_vcatpvf" 8 .IX Xref "sv_vcatpvf" .IX Item "sv_vcatpvf" Processes its arguments like \f(CW\*(C`sv_vcatpvfn\*(C'\fR called with a non-null C\-style variable argument list, and appends the formatted output to an \s-1SV.\s0 Does not handle 'set' magic. See \f(CW"sv_vcatpvf_mg"\fR. .Sp Usually used via its frontend \f(CW\*(C`sv_catpvf\*(C'\fR. .Sp .Vb 2 \& void sv_vcatpvf(SV *const sv, const char *const pat, \& va_list *const args) .Ve .IP "sv_vcatpvfn" 8 .IX Xref "sv_vcatpvfn" .IX Item "sv_vcatpvfn" .Vb 6 \& void sv_vcatpvfn(SV *const sv, const char *const pat, \& const STRLEN patlen, \& va_list *const args, \& SV **const svargs, \& const Size_t sv_count, \& bool *const maybe_tainted) .Ve .IP "sv_vcatpvfn_flags" 8 .IX Xref "sv_vcatpvfn_flags" .IX Item "sv_vcatpvfn_flags" Processes its arguments like \f(CW\*(C`vsprintf\*(C'\fR and appends the formatted output to an \s-1SV.\s0 Uses an array of SVs if the C\-style variable argument list is missing (\f(CW\*(C`NULL\*(C'\fR). Argument reordering (using format specifiers like \f(CW\*(C`%2$d\*(C'\fR or \f(CW\*(C`%*2$d\*(C'\fR) is supported only when using an array of SVs; using a C\-style \&\f(CW\*(C`va_list\*(C'\fR argument list with a format string that uses argument reordering will yield an exception. .Sp When running with taint checks enabled, indicates via \&\f(CW\*(C`maybe_tainted\*(C'\fR if results are untrustworthy (often due to the use of locales). .Sp If called as \f(CW\*(C`sv_vcatpvfn\*(C'\fR or flags has the \f(CW\*(C`SV_GMAGIC\*(C'\fR bit set, calls get magic. .Sp It assumes that pat has the same utf8\-ness as sv. It's the caller's responsibility to ensure that this is so. .Sp Usually used via one of its frontends \f(CW\*(C`sv_vcatpvf\*(C'\fR and \f(CW\*(C`sv_vcatpvf_mg\*(C'\fR. .Sp .Vb 8 \& void sv_vcatpvfn_flags(SV *const sv, \& const char *const pat, \& const STRLEN patlen, \& va_list *const args, \& SV **const svargs, \& const Size_t sv_count, \& bool *const maybe_tainted, \& const U32 flags) .Ve .IP "sv_vcatpvf_mg" 8 .IX Xref "sv_vcatpvf_mg" .IX Item "sv_vcatpvf_mg" Like \f(CW\*(C`sv_vcatpvf\*(C'\fR, but also handles 'set' magic. .Sp Usually used via its frontend \f(CW\*(C`sv_catpvf_mg\*(C'\fR. .Sp .Vb 3 \& void sv_vcatpvf_mg(SV *const sv, \& const char *const pat, \& va_list *const args) .Ve .IP "SvVOK" 8 .IX Xref "SvVOK" .IX Item "SvVOK" Returns a boolean indicating whether the \s-1SV\s0 contains a v\-string. .Sp .Vb 1 \& bool SvVOK(SV* sv) .Ve .IP "sv_vsetpvf" 8 .IX Xref "sv_vsetpvf" .IX Item "sv_vsetpvf" Works like \f(CW\*(C`sv_vcatpvf\*(C'\fR but copies the text into the \s-1SV\s0 instead of appending it. Does not handle 'set' magic. See \f(CW"sv_vsetpvf_mg"\fR. .Sp Usually used via its frontend \f(CW\*(C`sv_setpvf\*(C'\fR. .Sp .Vb 2 \& void sv_vsetpvf(SV *const sv, const char *const pat, \& va_list *const args) .Ve .IP "sv_vsetpvfn" 8 .IX Xref "sv_vsetpvfn" .IX Item "sv_vsetpvfn" Works like \f(CW\*(C`sv_vcatpvfn\*(C'\fR but copies the text into the \s-1SV\s0 instead of appending it. .Sp Usually used via one of its frontends \f(CW\*(C`sv_vsetpvf\*(C'\fR and \f(CW\*(C`sv_vsetpvf_mg\*(C'\fR. .Sp .Vb 6 \& void sv_vsetpvfn(SV *const sv, const char *const pat, \& const STRLEN patlen, \& va_list *const args, \& SV **const svargs, \& const Size_t sv_count, \& bool *const maybe_tainted) .Ve .IP "sv_vsetpvf_mg" 8 .IX Xref "sv_vsetpvf_mg" .IX Item "sv_vsetpvf_mg" Like \f(CW\*(C`sv_vsetpvf\*(C'\fR, but also handles 'set' magic. .Sp Usually used via its frontend \f(CW\*(C`sv_setpvf_mg\*(C'\fR. .Sp .Vb 3 \& void sv_vsetpvf_mg(SV *const sv, \& const char *const pat, \& va_list *const args) .Ve .SH "Unicode Support" .IX Header "Unicode Support" \&\*(L"Unicode Support\*(R" in perlguts has an introduction to this \s-1API.\s0 .PP See also \*(L"Character classification\*(R", and \*(L"Character case changing\*(R". Various functions outside this section also work specially with Unicode. Search for the string \*(L"utf8\*(R" in this document. .IP "\s-1BOM_UTF8\s0" 8 .IX Xref "BOM_UTF8" .IX Item "BOM_UTF8" This is a macro that evaluates to a string constant of the \s-1UTF\-8\s0 bytes that define the Unicode \s-1BYTE ORDER MARK\s0 (U+FEFF) for the platform that perl is compiled on. This allows code to use a mnemonic for this character that works on both \s-1ASCII\s0 and \s-1EBCDIC\s0 platforms. \&\f(CW\*(C`sizeof(BOM_UTF8) \- 1\*(C'\fR can be used to get its length in bytes. .IP "bytes_cmp_utf8" 8 .IX Xref "bytes_cmp_utf8" .IX Item "bytes_cmp_utf8" Compares the sequence of characters (stored as octets) in \f(CW\*(C`b\*(C'\fR, \f(CW\*(C`blen\*(C'\fR with the sequence of characters (stored as \s-1UTF\-8\s0) in \f(CW\*(C`u\*(C'\fR, \f(CW\*(C`ulen\*(C'\fR. 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. .Sp \&\-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. .Sp .Vb 2 \& int bytes_cmp_utf8(const U8 *b, STRLEN blen, \& const U8 *u, STRLEN ulen) .Ve .IP "bytes_from_utf8" 8 .IX Xref "bytes_from_utf8" .IX Item "bytes_from_utf8" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Converts a potentially \s-1UTF\-8\s0 encoded string \f(CW\*(C`s\*(C'\fR of length \f(CW*lenp\fR into native byte encoding. On input, the boolean \f(CW*is_utf8p\fR gives whether or not \f(CW\*(C`s\*(C'\fR is actually encoded in \s-1UTF\-8.\s0 .Sp Unlike \*(L"utf8_to_bytes\*(R" but like \*(L"bytes_to_utf8\*(R", this is non-destructive of the input string. .Sp Do nothing if \f(CW*is_utf8p\fR is 0, or if there are code points in the string not expressible in native byte encoding. In these cases, \f(CW*is_utf8p\fR and \&\f(CW*lenp\fR are unchanged, and the return value is the original \f(CW\*(C`s\*(C'\fR. .Sp Otherwise, \f(CW*is_utf8p\fR is set to 0, and the return value is a pointer to a newly created string containing a downgraded copy of \f(CW\*(C`s\*(C'\fR, and whose length is returned in \f(CW*lenp\fR, updated. The new string is \f(CW\*(C`NUL\*(C'\fR\-terminated. The caller is responsible for arranging for the memory used by this string to get freed. .Sp Upon successful return, the number of variants in the string can be computed by having saved the value of \f(CW*lenp\fR before the call, and subtracting the after-call value of \f(CW*lenp\fR from it. .Sp .Vb 2 \& U8* bytes_from_utf8(const U8 *s, STRLEN *lenp, \& bool *is_utf8p) .Ve .IP "bytes_to_utf8" 8 .IX Xref "bytes_to_utf8" .IX Item "bytes_to_utf8" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Converts a string \f(CW\*(C`s\*(C'\fR of length \f(CW*lenp\fR bytes from the native encoding into \&\s-1UTF\-8.\s0 Returns a pointer to the newly-created string, and sets \f(CW*lenp\fR to reflect the new length in bytes. The caller is responsible for arranging for the memory used by this string to get freed. .Sp Upon successful return, the number of variants in the string can be computed by having saved the value of \f(CW*lenp\fR before the call, and subtracting it from the after-call value of \f(CW*lenp\fR. .Sp A \f(CW\*(C`NUL\*(C'\fR character will be written after the end of the string. .Sp If you want to convert to \s-1UTF\-8\s0 from encodings other than the native (Latin1 or \s-1EBCDIC\s0), see \*(L"sv_recode_to_utf8\*(R"(). .Sp .Vb 1 \& U8* bytes_to_utf8(const U8 *s, STRLEN *lenp) .Ve .IP "\s-1DO_UTF8\s0" 8 .IX Xref "DO_UTF8" .IX Item "DO_UTF8" Returns a bool giving whether or not the \s-1PV\s0 in \f(CW\*(C`sv\*(C'\fR is to be treated as being encoded in \s-1UTF\-8.\s0 .Sp You should use this \fIafter\fR a call to \f(CW\*(C`SvPV()\*(C'\fR or one of its variants, in case any call to string overloading updates the internal \s-1UTF\-8\s0 encoding flag. .Sp .Vb 1 \& bool DO_UTF8(SV* sv) .Ve .IP "foldEQ_utf8" 8 .IX Xref "foldEQ_utf8" .IX Item "foldEQ_utf8" Returns true if the leading portions of the strings \f(CW\*(C`s1\*(C'\fR and \f(CW\*(C`s2\*(C'\fR (either or both of which may be in \s-1UTF\-8\s0) are the same case-insensitively; false otherwise. How far into the strings to compare is determined by other input parameters. .Sp If \f(CW\*(C`u1\*(C'\fR is true, the string \f(CW\*(C`s1\*(C'\fR is assumed to be in UTF\-8\-encoded Unicode; otherwise it is assumed to be in native 8\-bit encoding. Correspondingly for \&\f(CW\*(C`u2\*(C'\fR with respect to \f(CW\*(C`s2\*(C'\fR. .Sp If the byte length \f(CW\*(C`l1\*(C'\fR is non-zero, it says how far into \f(CW\*(C`s1\*(C'\fR to check for fold equality. In other words, \f(CW\*(C`s1\*(C'\fR+\f(CW\*(C`l1\*(C'\fR 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 \f(CW\*(C`l2\*(C'\fR with respect to \f(CW\*(C`s2\*(C'\fR. .Sp If \f(CW\*(C`pe1\*(C'\fR is non\-\f(CW\*(C`NULL\*(C'\fR and the pointer it points to is not \f(CW\*(C`NULL\*(C'\fR, that pointer is considered an end pointer to the position 1 byte past the maximum point in \f(CW\*(C`s1\*(C'\fR beyond which scanning will not continue under any circumstances. (This routine assumes that \s-1UTF\-8\s0 encoded input strings are not malformed; malformed input can cause it to read past \f(CW\*(C`pe1\*(C'\fR). This means that if both \&\f(CW\*(C`l1\*(C'\fR and \f(CW\*(C`pe1\*(C'\fR are specified, and \f(CW\*(C`pe1\*(C'\fR is less than \f(CW\*(C`s1\*(C'\fR+\f(CW\*(C`l1\*(C'\fR, the match will never be successful because it can never get as far as its goal (and in fact is asserted against). Correspondingly for \&\f(CW\*(C`pe2\*(C'\fR with respect to \f(CW\*(C`s2\*(C'\fR. .Sp At least one of \f(CW\*(C`s1\*(C'\fR and \f(CW\*(C`s2\*(C'\fR must have a goal (at least one of \f(CW\*(C`l1\*(C'\fR and \&\f(CW\*(C`l2\*(C'\fR 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'). .Sp Upon a successful match, if \f(CW\*(C`pe1\*(C'\fR is non\-\f(CW\*(C`NULL\*(C'\fR, it will be set to point to the beginning of the \fInext\fR character of \f(CW\*(C`s1\*(C'\fR beyond what was matched. Correspondingly for \f(CW\*(C`pe2\*(C'\fR and \f(CW\*(C`s2\*(C'\fR. .Sp For case-insensitiveness, the \*(L"casefolding\*(R" of Unicode is used instead of upper/lowercasing both the characters, see (Case Mappings). .Sp .Vb 3 \& I32 foldEQ_utf8(const char *s1, char **pe1, UV l1, \& bool u1, const char *s2, char **pe2, \& UV l2, bool u2) .Ve .IP "is_ascii_string" 8 .IX Xref "is_ascii_string" .IX Item "is_ascii_string" This is a misleadingly-named synonym for \*(L"is_utf8_invariant_string\*(R". On ASCII-ish platforms, the name isn't misleading: the ASCII-range characters are exactly the \s-1UTF\-8\s0 invariants. But \s-1EBCDIC\s0 machines have more invariants than just the \s-1ASCII\s0 characters, so \f(CW\*(C`is_utf8_invariant_string\*(C'\fR is preferred. .Sp .Vb 1 \& bool is_ascii_string(const U8* const s, STRLEN len) .Ve .IP "is_c9strict_utf8_string" 8 .IX Xref "is_c9strict_utf8_string" .IX Item "is_c9strict_utf8_string" Returns \s-1TRUE\s0 if the first \f(CW\*(C`len\*(C'\fR bytes of string \f(CW\*(C`s\*(C'\fR form a valid UTF\-8\-encoded string that conforms to Unicode Corrigendum #9 ; otherwise it returns \s-1FALSE.\s0 If \f(CW\*(C`len\*(C'\fR is 0, it will be calculated using \&\f(CWstrlen(s)\fR (which means if you use this option, that \f(CW\*(C`s\*(C'\fR can't have embedded \&\f(CW\*(C`NUL\*(C'\fR characters and has to have a terminating \f(CW\*(C`NUL\*(C'\fR byte). Note that all characters being \s-1ASCII\s0 constitute 'a valid \s-1UTF\-8\s0 string'. .Sp This function returns \s-1FALSE\s0 for strings containing any code points above the Unicode max of 0x10FFFF or surrogate code points, but accepts non-character code points per Corrigendum #9 . .Sp See also \&\f(CW"is_utf8_invariant_string"\fR, \&\f(CW"is_utf8_invariant_string_loc"\fR, \&\f(CW"is_utf8_string"\fR, \&\f(CW"is_utf8_string_flags"\fR, \&\f(CW"is_utf8_string_loc"\fR, \&\f(CW"is_utf8_string_loc_flags"\fR, \&\f(CW"is_utf8_string_loclen"\fR, \&\f(CW"is_utf8_string_loclen_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loc_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loclen_flags"\fR, \&\f(CW"is_strict_utf8_string"\fR, \&\f(CW"is_strict_utf8_string_loc"\fR, \&\f(CW"is_strict_utf8_string_loclen"\fR, \&\f(CW"is_c9strict_utf8_string_loc"\fR, and \&\f(CW"is_c9strict_utf8_string_loclen"\fR. .Sp .Vb 1 \& bool is_c9strict_utf8_string(const U8 *s, STRLEN len) .Ve .IP "is_c9strict_utf8_string_loc" 8 .IX Xref "is_c9strict_utf8_string_loc" .IX Item "is_c9strict_utf8_string_loc" Like \f(CW"is_c9strict_utf8_string"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer. .Sp See also \f(CW"is_c9strict_utf8_string_loclen"\fR. .Sp .Vb 3 \& bool is_c9strict_utf8_string_loc(const U8 *s, \& STRLEN len, \& const U8 **ep) .Ve .IP "is_c9strict_utf8_string_loclen" 8 .IX Xref "is_c9strict_utf8_string_loclen" .IX Item "is_c9strict_utf8_string_loclen" Like \f(CW"is_c9strict_utf8_string"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer, and the number of \s-1UTF\-8\s0 encoded characters in the \f(CW\*(C`el\*(C'\fR pointer. .Sp See also \f(CW"is_c9strict_utf8_string_loc"\fR. .Sp .Vb 4 \& bool is_c9strict_utf8_string_loclen(const U8 *s, \& STRLEN len, \& const U8 **ep, \& STRLEN *el) .Ve .IP "isC9_STRICT_UTF8_CHAR" 8 .IX Xref "isC9_STRICT_UTF8_CHAR" .IX Item "isC9_STRICT_UTF8_CHAR" Evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are well-formed \s-1UTF\-8\s0 that represents some Unicode non-surrogate code point; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. Any bytes remaining before \f(CW\*(C`e\*(C'\fR, but beyond the ones needed to form the first code point in \f(CW\*(C`s\*(C'\fR, are not examined. .Sp The largest acceptable code point is the Unicode maximum 0x10FFFF. This differs from \f(CW"isSTRICT_UTF8_CHAR"\fR only in that it accepts non-character code points. This corresponds to Unicode Corrigendum #9 . which said that non-character code points are merely discouraged rather than completely forbidden in open interchange. See \&\*(L"Noncharacter code points\*(R" in perlunicode. .Sp Use \f(CW"isUTF8_CHAR"\fR to check for Perl's extended \s-1UTF\-8\s0; and \&\f(CW"isUTF8_CHAR_flags"\fR for a more customized definition. .Sp Use \f(CW"is_c9strict_utf8_string"\fR, \f(CW"is_c9strict_utf8_string_loc"\fR, and \&\f(CW"is_c9strict_utf8_string_loclen"\fR to check entire strings. .Sp .Vb 2 \& Size_t isC9_STRICT_UTF8_CHAR(const U8 * const s0, \& const U8 * const e) .Ve .IP "is_invariant_string" 8 .IX Xref "is_invariant_string" .IX Item "is_invariant_string" This is a somewhat misleadingly-named synonym for \*(L"is_utf8_invariant_string\*(R". \&\f(CW\*(C`is_utf8_invariant_string\*(C'\fR is preferred, as it indicates under what conditions the string is invariant. .Sp .Vb 2 \& bool is_invariant_string(const U8* const s, \& STRLEN len) .Ve .IP "isSTRICT_UTF8_CHAR" 8 .IX Xref "isSTRICT_UTF8_CHAR" .IX Item "isSTRICT_UTF8_CHAR" Evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are well-formed \s-1UTF\-8\s0 that represents some Unicode code point completely acceptable for open interchange between all applications; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. Any bytes remaining before \f(CW\*(C`e\*(C'\fR, but beyond the ones needed to form the first code point in \f(CW\*(C`s\*(C'\fR, are not examined. .Sp The largest acceptable code point is the Unicode maximum 0x10FFFF, and must not be a surrogate nor a non-character code point. Thus this excludes any code point from Perl's extended \s-1UTF\-8.\s0 .Sp This is used to efficiently decide if the next few bytes in \f(CW\*(C`s\*(C'\fR is legal Unicode-acceptable \s-1UTF\-8\s0 for a single character. .Sp Use \f(CW"isC9_STRICT_UTF8_CHAR"\fR to use the Unicode Corrigendum #9 definition of allowable code points; \f(CW"isUTF8_CHAR"\fR to check for Perl's extended \s-1UTF\-8\s0; and \f(CW"isUTF8_CHAR_flags"\fR for a more customized definition. .Sp Use \f(CW"is_strict_utf8_string"\fR, \f(CW"is_strict_utf8_string_loc"\fR, and \&\f(CW"is_strict_utf8_string_loclen"\fR to check entire strings. .Sp .Vb 2 \& Size_t isSTRICT_UTF8_CHAR(const U8 * const s0, \& const U8 * const e) .Ve .IP "is_strict_utf8_string" 8 .IX Xref "is_strict_utf8_string" .IX Item "is_strict_utf8_string" Returns \s-1TRUE\s0 if the first \f(CW\*(C`len\*(C'\fR bytes of string \f(CW\*(C`s\*(C'\fR form a valid UTF\-8\-encoded string that is fully interchangeable by any application using Unicode rules; otherwise it returns \s-1FALSE.\s0 If \f(CW\*(C`len\*(C'\fR is 0, it will be calculated using \f(CWstrlen(s)\fR (which means if you use this option, that \f(CW\*(C`s\*(C'\fR can't have embedded \f(CW\*(C`NUL\*(C'\fR characters and has to have a terminating \f(CW\*(C`NUL\*(C'\fR byte). Note that all characters being \s-1ASCII\s0 constitute 'a valid \s-1UTF\-8\s0 string'. .Sp This function returns \s-1FALSE\s0 for strings containing any code points above the Unicode max of 0x10FFFF, surrogate code points, or non-character code points. .Sp See also \&\f(CW"is_utf8_invariant_string"\fR, \&\f(CW"is_utf8_invariant_string_loc"\fR, \&\f(CW"is_utf8_string"\fR, \&\f(CW"is_utf8_string_flags"\fR, \&\f(CW"is_utf8_string_loc"\fR, \&\f(CW"is_utf8_string_loc_flags"\fR, \&\f(CW"is_utf8_string_loclen"\fR, \&\f(CW"is_utf8_string_loclen_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loc_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loclen_flags"\fR, \&\f(CW"is_strict_utf8_string_loc"\fR, \&\f(CW"is_strict_utf8_string_loclen"\fR, \&\f(CW"is_c9strict_utf8_string"\fR, \&\f(CW"is_c9strict_utf8_string_loc"\fR, and \&\f(CW"is_c9strict_utf8_string_loclen"\fR. .Sp .Vb 1 \& bool is_strict_utf8_string(const U8 *s, STRLEN len) .Ve .IP "is_strict_utf8_string_loc" 8 .IX Xref "is_strict_utf8_string_loc" .IX Item "is_strict_utf8_string_loc" Like \f(CW"is_strict_utf8_string"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer. .Sp See also \f(CW"is_strict_utf8_string_loclen"\fR. .Sp .Vb 3 \& bool is_strict_utf8_string_loc(const U8 *s, \& STRLEN len, \& const U8 **ep) .Ve .IP "is_strict_utf8_string_loclen" 8 .IX Xref "is_strict_utf8_string_loclen" .IX Item "is_strict_utf8_string_loclen" Like \f(CW"is_strict_utf8_string"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer, and the number of \s-1UTF\-8\s0 encoded characters in the \f(CW\*(C`el\*(C'\fR pointer. .Sp See also \f(CW"is_strict_utf8_string_loc"\fR. .Sp .Vb 4 \& bool is_strict_utf8_string_loclen(const U8 *s, \& STRLEN len, \& const U8 **ep, \& STRLEN *el) .Ve .IP "is_utf8_fixed_width_buf_flags" 8 .IX Xref "is_utf8_fixed_width_buf_flags" .IX Item "is_utf8_fixed_width_buf_flags" Returns \s-1TRUE\s0 if the fixed-width buffer starting at \f(CW\*(C`s\*(C'\fR with length \f(CW\*(C`len\*(C'\fR is entirely valid \s-1UTF\-8,\s0 subject to the restrictions given by \f(CW\*(C`flags\*(C'\fR; otherwise it returns \s-1FALSE.\s0 .Sp If \f(CW\*(C`flags\*(C'\fR is 0, any well-formed \s-1UTF\-8,\s0 as extended by Perl, is accepted without restriction. If the final few bytes of the buffer do not form a complete code point, this will return \s-1TRUE\s0 anyway, provided that \&\f(CW"is_utf8_valid_partial_char_flags"\fR returns \s-1TRUE\s0 for them. .Sp If \f(CW\*(C`flags\*(C'\fR in non-zero, it can be any combination of the \&\f(CW\*(C`UTF8_DISALLOW_\f(CIfoo\f(CW\*(C'\fR flags accepted by \f(CW"utf8n_to_uvchr"\fR, and with the same meanings. .Sp This function differs from \f(CW"is_utf8_string_flags"\fR only in that the latter returns \s-1FALSE\s0 if the final few bytes of the string don't form a complete code point. .Sp .Vb 4 \& bool is_utf8_fixed_width_buf_flags( \& const U8 * const s, STRLEN len, \& const U32 flags \& ) .Ve .IP "is_utf8_fixed_width_buf_loclen_flags" 8 .IX Xref "is_utf8_fixed_width_buf_loclen_flags" .IX Item "is_utf8_fixed_width_buf_loclen_flags" Like \f(CW"is_utf8_fixed_width_buf_loc_flags"\fR but stores the number of complete, valid characters found in the \f(CW\*(C`el\*(C'\fR pointer. .Sp .Vb 4 \& bool is_utf8_fixed_width_buf_loclen_flags( \& const U8 * const s, STRLEN len, \& const U8 **ep, STRLEN *el, const U32 flags \& ) .Ve .IP "is_utf8_fixed_width_buf_loc_flags" 8 .IX Xref "is_utf8_fixed_width_buf_loc_flags" .IX Item "is_utf8_fixed_width_buf_loc_flags" Like \f(CW"is_utf8_fixed_width_buf_flags"\fR but stores the location of the failure in the \f(CW\*(C`ep\*(C'\fR pointer. If the function returns \s-1TRUE,\s0 \f(CW*ep\fR will point to the beginning of any partial character at the end of the buffer; if there is no partial character \f(CW*ep\fR will contain \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR. .Sp See also \f(CW"is_utf8_fixed_width_buf_loclen_flags"\fR. .Sp .Vb 4 \& bool is_utf8_fixed_width_buf_loc_flags( \& const U8 * const s, STRLEN len, \& const U8 **ep, const U32 flags \& ) .Ve .IP "is_utf8_invariant_string" 8 .IX Xref "is_utf8_invariant_string" .IX Item "is_utf8_invariant_string" Returns \s-1TRUE\s0 if the first \f(CW\*(C`len\*(C'\fR bytes of the string \f(CW\*(C`s\*(C'\fR are the same regardless of the \s-1UTF\-8\s0 encoding of the string (or UTF-EBCDIC encoding on \&\s-1EBCDIC\s0 machines); otherwise it returns \s-1FALSE.\s0 That is, it returns \s-1TRUE\s0 if they are \s-1UTF\-8\s0 invariant. On ASCII-ish machines, all the \s-1ASCII\s0 characters and only the \s-1ASCII\s0 characters fit this definition. On \s-1EBCDIC\s0 machines, the ASCII-range characters are invariant, but so also are the C1 controls. .Sp If \f(CW\*(C`len\*(C'\fR is 0, it will be calculated using \f(CWstrlen(s)\fR, (which means if you use this option, that \f(CW\*(C`s\*(C'\fR can't have embedded \f(CW\*(C`NUL\*(C'\fR characters and has to have a terminating \f(CW\*(C`NUL\*(C'\fR byte). .Sp See also \&\f(CW"is_utf8_string"\fR, \&\f(CW"is_utf8_string_flags"\fR, \&\f(CW"is_utf8_string_loc"\fR, \&\f(CW"is_utf8_string_loc_flags"\fR, \&\f(CW"is_utf8_string_loclen"\fR, \&\f(CW"is_utf8_string_loclen_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loc_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loclen_flags"\fR, \&\f(CW"is_strict_utf8_string"\fR, \&\f(CW"is_strict_utf8_string_loc"\fR, \&\f(CW"is_strict_utf8_string_loclen"\fR, \&\f(CW"is_c9strict_utf8_string"\fR, \&\f(CW"is_c9strict_utf8_string_loc"\fR, and \&\f(CW"is_c9strict_utf8_string_loclen"\fR. .Sp .Vb 2 \& bool is_utf8_invariant_string(const U8* const s, \& STRLEN len) .Ve .IP "is_utf8_invariant_string_loc" 8 .IX Xref "is_utf8_invariant_string_loc" .IX Item "is_utf8_invariant_string_loc" Like \f(CW"is_utf8_invariant_string"\fR but upon failure, stores the location of the first \s-1UTF\-8\s0 variant character in the \f(CW\*(C`ep\*(C'\fR pointer; if all characters are \&\s-1UTF\-8\s0 invariant, this function does not change the contents of \f(CW*ep\fR. .Sp .Vb 3 \& bool is_utf8_invariant_string_loc(const U8* const s, \& STRLEN len, \& const U8 ** ep) .Ve .IP "is_utf8_string" 8 .IX Xref "is_utf8_string" .IX Item "is_utf8_string" Returns \s-1TRUE\s0 if the first \f(CW\*(C`len\*(C'\fR bytes of string \f(CW\*(C`s\*(C'\fR form a valid Perl\-extended\-UTF\-8 string; returns \s-1FALSE\s0 otherwise. If \f(CW\*(C`len\*(C'\fR is 0, it will be calculated using \f(CWstrlen(s)\fR (which means if you use this option, that \f(CW\*(C`s\*(C'\fR can't have embedded \f(CW\*(C`NUL\*(C'\fR characters and has to have a terminating \f(CW\*(C`NUL\*(C'\fR byte). Note that all characters being \s-1ASCII\s0 constitute 'a valid \s-1UTF\-8\s0 string'. .Sp This function considers Perl's extended \s-1UTF\-8\s0 to be valid. That means that code points above Unicode, surrogates, and non-character code points are considered valid by this function. Use \f(CW"is_strict_utf8_string"\fR, \&\f(CW"is_c9strict_utf8_string"\fR, or \f(CW"is_utf8_string_flags"\fR to restrict what code points are considered valid. .Sp See also \&\f(CW"is_utf8_invariant_string"\fR, \&\f(CW"is_utf8_invariant_string_loc"\fR, \&\f(CW"is_utf8_string_loc"\fR, \&\f(CW"is_utf8_string_loclen"\fR, \&\f(CW"is_utf8_fixed_width_buf_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loc_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loclen_flags"\fR, .Sp .Vb 1 \& bool is_utf8_string(const U8 *s, STRLEN len) .Ve .IP "is_utf8_string_flags" 8 .IX Xref "is_utf8_string_flags" .IX Item "is_utf8_string_flags" Returns \s-1TRUE\s0 if the first \f(CW\*(C`len\*(C'\fR bytes of string \f(CW\*(C`s\*(C'\fR form a valid \&\s-1UTF\-8\s0 string, subject to the restrictions imposed by \f(CW\*(C`flags\*(C'\fR; returns \s-1FALSE\s0 otherwise. If \f(CW\*(C`len\*(C'\fR is 0, it will be calculated using \f(CWstrlen(s)\fR (which means if you use this option, that \f(CW\*(C`s\*(C'\fR can't have embedded \f(CW\*(C`NUL\*(C'\fR characters and has to have a terminating \f(CW\*(C`NUL\*(C'\fR byte). Note that all characters being \s-1ASCII\s0 constitute 'a valid \s-1UTF\-8\s0 string'. .Sp If \f(CW\*(C`flags\*(C'\fR is 0, this gives the same results as \f(CW"is_utf8_string"\fR; if \&\f(CW\*(C`flags\*(C'\fR is \f(CW\*(C`UTF8_DISALLOW_ILLEGAL_INTERCHANGE\*(C'\fR, this gives the same results as \f(CW"is_strict_utf8_string"\fR; and if \f(CW\*(C`flags\*(C'\fR is \&\f(CW\*(C`UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE\*(C'\fR, this gives the same results as \&\f(CW"is_c9strict_utf8_string"\fR. Otherwise \f(CW\*(C`flags\*(C'\fR may be any combination of the \f(CW\*(C`UTF8_DISALLOW_\f(CIfoo\f(CW\*(C'\fR flags understood by \&\f(CW"utf8n_to_uvchr"\fR, with the same meanings. .Sp See also \&\f(CW"is_utf8_invariant_string"\fR, \&\f(CW"is_utf8_invariant_string_loc"\fR, \&\f(CW"is_utf8_string"\fR, \&\f(CW"is_utf8_string_loc"\fR, \&\f(CW"is_utf8_string_loc_flags"\fR, \&\f(CW"is_utf8_string_loclen"\fR, \&\f(CW"is_utf8_string_loclen_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loc_flags"\fR, \&\f(CW"is_utf8_fixed_width_buf_loclen_flags"\fR, \&\f(CW"is_strict_utf8_string"\fR, \&\f(CW"is_strict_utf8_string_loc"\fR, \&\f(CW"is_strict_utf8_string_loclen"\fR, \&\f(CW"is_c9strict_utf8_string"\fR, \&\f(CW"is_c9strict_utf8_string_loc"\fR, and \&\f(CW"is_c9strict_utf8_string_loclen"\fR. .Sp .Vb 2 \& bool is_utf8_string_flags(const U8 *s, STRLEN len, \& const U32 flags) .Ve .IP "is_utf8_string_loc" 8 .IX Xref "is_utf8_string_loc" .IX Item "is_utf8_string_loc" Like \f(CW"is_utf8_string"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer. .Sp See also \f(CW"is_utf8_string_loclen"\fR. .Sp .Vb 3 \& bool is_utf8_string_loc(const U8 *s, \& const STRLEN len, \& const U8 **ep) .Ve .IP "is_utf8_string_loclen" 8 .IX Xref "is_utf8_string_loclen" .IX Item "is_utf8_string_loclen" Like \f(CW"is_utf8_string"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer, and the number of \s-1UTF\-8\s0 encoded characters in the \f(CW\*(C`el\*(C'\fR pointer. .Sp See also \f(CW"is_utf8_string_loc"\fR. .Sp .Vb 2 \& bool is_utf8_string_loclen(const U8 *s, STRLEN len, \& const U8 **ep, STRLEN *el) .Ve .IP "is_utf8_string_loclen_flags" 8 .IX Xref "is_utf8_string_loclen_flags" .IX Item "is_utf8_string_loclen_flags" Like \f(CW"is_utf8_string_flags"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer, and the number of \s-1UTF\-8\s0 encoded characters in the \f(CW\*(C`el\*(C'\fR pointer. .Sp See also \f(CW"is_utf8_string_loc_flags"\fR. .Sp .Vb 5 \& bool is_utf8_string_loclen_flags(const U8 *s, \& STRLEN len, \& const U8 **ep, \& STRLEN *el, \& const U32 flags) .Ve .IP "is_utf8_string_loc_flags" 8 .IX Xref "is_utf8_string_loc_flags" .IX Item "is_utf8_string_loc_flags" Like \f(CW"is_utf8_string_flags"\fR but stores the location of the failure (in the case of \*(L"utf8ness failure\*(R") or the location \f(CW\*(C`s\*(C'\fR+\f(CW\*(C`len\*(C'\fR (in the case of \&\*(L"utf8ness success\*(R") in the \f(CW\*(C`ep\*(C'\fR pointer. .Sp See also \f(CW"is_utf8_string_loclen_flags"\fR. .Sp .Vb 4 \& bool is_utf8_string_loc_flags(const U8 *s, \& STRLEN len, \& const U8 **ep, \& const U32 flags) .Ve .IP "is_utf8_valid_partial_char" 8 .IX Xref "is_utf8_valid_partial_char" .IX Item "is_utf8_valid_partial_char" Returns 0 if the sequence of bytes starting at \f(CW\*(C`s\*(C'\fR and looking no further than \&\f(CW\*(C`e \- 1\*(C'\fR is the \s-1UTF\-8\s0 encoding, as extended by Perl, for one or more code points. Otherwise, it returns 1 if there exists at least one non-empty sequence of bytes that when appended to sequence \f(CW\*(C`s\*(C'\fR, starting at position \&\f(CW\*(C`e\*(C'\fR causes the entire sequence to be the well-formed \s-1UTF\-8\s0 of some code point; otherwise returns 0. .Sp In other words this returns \s-1TRUE\s0 if \f(CW\*(C`s\*(C'\fR points to a partial UTF\-8\-encoded code point. .Sp This is useful when a fixed-length buffer is being tested for being well-formed \&\s-1UTF\-8,\s0 but the final few bytes in it don't comprise a full character; that is, it is split somewhere in the middle of the final code point's \s-1UTF\-8\s0 representation. (Presumably when the buffer is refreshed with the next chunk of data, the new first bytes will complete the partial code point.) This function is used to verify that the final bytes in the current buffer are in fact the legal beginning of some code point, so that if they aren't, the failure can be signalled without having to wait for the next read. .Sp .Vb 2 \& bool is_utf8_valid_partial_char(const U8 * const s, \& const U8 * const e) .Ve .IP "is_utf8_valid_partial_char_flags" 8 .IX Xref "is_utf8_valid_partial_char_flags" .IX Item "is_utf8_valid_partial_char_flags" Like \f(CW"is_utf8_valid_partial_char"\fR, it returns a boolean giving whether or not the input is a valid \s-1UTF\-8\s0 encoded partial character, but it takes an extra parameter, \f(CW\*(C`flags\*(C'\fR, which can further restrict which code points are considered valid. .Sp If \f(CW\*(C`flags\*(C'\fR is 0, this behaves identically to \&\f(CW"is_utf8_valid_partial_char"\fR. Otherwise \f(CW\*(C`flags\*(C'\fR can be any combination of the \f(CW\*(C`UTF8_DISALLOW_\f(CIfoo\f(CW\*(C'\fR flags accepted by \f(CW"utf8n_to_uvchr"\fR. If there is any sequence of bytes that can complete the input partial character in such a way that a non-prohibited character is formed, the function returns \&\s-1TRUE\s0; otherwise \s-1FALSE.\s0 Non character code points cannot be determined based on partial character input. But many of the other possible excluded types can be determined from just the first one or two bytes. .Sp .Vb 4 \& bool is_utf8_valid_partial_char_flags( \& const U8 * const s, const U8 * const e, \& const U32 flags \& ) .Ve .IP "isUTF8_CHAR" 8 .IX Xref "isUTF8_CHAR" .IX Item "isUTF8_CHAR" Evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are well-formed \s-1UTF\-8,\s0 as extended by Perl, that represents some code point; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. Any bytes remaining before \f(CW\*(C`e\*(C'\fR, but beyond the ones needed to form the first code point in \f(CW\*(C`s\*(C'\fR, are not examined. .Sp The code point can be any that will fit in an \s-1IV\s0 on this machine, using Perl's extension to official \s-1UTF\-8\s0 to represent those higher than the Unicode maximum of 0x10FFFF. That means that this macro is used to efficiently decide if the next few bytes in \f(CW\*(C`s\*(C'\fR is legal \s-1UTF\-8\s0 for a single character. .Sp Use \f(CW"isSTRICT_UTF8_CHAR"\fR to restrict the acceptable code points to those defined by Unicode to be fully interchangeable across applications; \&\f(CW"isC9_STRICT_UTF8_CHAR"\fR to use the Unicode Corrigendum #9 definition of allowable code points; and \f(CW"isUTF8_CHAR_flags"\fR for a more customized definition. .Sp Use \f(CW"is_utf8_string"\fR, \f(CW"is_utf8_string_loc"\fR, and \&\f(CW"is_utf8_string_loclen"\fR to check entire strings. .Sp Note also that a \s-1UTF\-8\s0 \*(L"invariant\*(R" character (i.e. \s-1ASCII\s0 on non-EBCDIC machines) is a valid \s-1UTF\-8\s0 character. .Sp .Vb 2 \& Size_t isUTF8_CHAR(const U8 * const s0, \& const U8 * const e) .Ve .IP "isUTF8_CHAR_flags" 8 .IX Xref "isUTF8_CHAR_flags" .IX Item "isUTF8_CHAR_flags" Evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are well-formed \s-1UTF\-8,\s0 as extended by Perl, that represents some code point, subject to the restrictions given by \f(CW\*(C`flags\*(C'\fR; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. Any bytes remaining before \f(CW\*(C`e\*(C'\fR, but beyond the ones needed to form the first code point in \f(CW\*(C`s\*(C'\fR, are not examined. .Sp If \f(CW\*(C`flags\*(C'\fR is 0, this gives the same results as \f(CW"isUTF8_CHAR"\fR; if \f(CW\*(C`flags\*(C'\fR is \f(CW\*(C`UTF8_DISALLOW_ILLEGAL_INTERCHANGE\*(C'\fR, this gives the same results as \f(CW"isSTRICT_UTF8_CHAR"\fR; and if \f(CW\*(C`flags\*(C'\fR is \f(CW\*(C`UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE\*(C'\fR, this gives the same results as \f(CW"isC9_STRICT_UTF8_CHAR"\fR. Otherwise \f(CW\*(C`flags\*(C'\fR may be any combination of the \f(CW\*(C`UTF8_DISALLOW_\f(CIfoo\f(CW\*(C'\fR flags understood by \f(CW"utf8n_to_uvchr"\fR, with the same meanings. .Sp The three alternative macros are for the most commonly needed validations; they are likely to run somewhat faster than this more general one, as they can be inlined into your code. .Sp Use \*(L"is_utf8_string_flags\*(R", \*(L"is_utf8_string_loc_flags\*(R", and \&\*(L"is_utf8_string_loclen_flags\*(R" to check entire strings. .Sp .Vb 2 \& STRLEN isUTF8_CHAR_flags(const U8 *s, const U8 *e, \& const U32 flags) .Ve .IP "\s-1LATIN1_TO_NATIVE\s0" 8 .IX Xref "LATIN1_TO_NATIVE" .IX Item "LATIN1_TO_NATIVE" Returns the native equivalent of the input Latin\-1 code point (including \s-1ASCII\s0 and control characters) given by \f(CW\*(C`ch\*(C'\fR. Thus, \f(CW\*(C`LATIN1_TO_NATIVE(66)\*(C'\fR on \&\s-1EBCDIC\s0 platforms returns 194. These each represent the character \f(CW"B"\fR on their respective platforms. On \s-1ASCII\s0 platforms no conversion is needed, so this macro expands to just its input, adding no time nor space requirements to the implementation. .Sp For conversion of code points potentially larger than will fit in a character, use \*(L"\s-1UNI_TO_NATIVE\*(R"\s0. .Sp .Vb 1 \& U8 LATIN1_TO_NATIVE(U8 ch) .Ve .IP "\s-1NATIVE_TO_LATIN1\s0" 8 .IX Xref "NATIVE_TO_LATIN1" .IX Item "NATIVE_TO_LATIN1" Returns the Latin\-1 (including \s-1ASCII\s0 and control characters) equivalent of the input native code point given by \f(CW\*(C`ch\*(C'\fR. Thus, \f(CW\*(C`NATIVE_TO_LATIN1(193)\*(C'\fR on \&\s-1EBCDIC\s0 platforms returns 65. These each represent the character \f(CW"A"\fR on their respective platforms. On \s-1ASCII\s0 platforms no conversion is needed, so this macro expands to just its input, adding no time nor space requirements to the implementation. .Sp For conversion of code points potentially larger than will fit in a character, use \*(L"\s-1NATIVE_TO_UNI\*(R"\s0. .Sp .Vb 1 \& U8 NATIVE_TO_LATIN1(U8 ch) .Ve .IP "\s-1NATIVE_TO_UNI\s0" 8 .IX Xref "NATIVE_TO_UNI" .IX Item "NATIVE_TO_UNI" Returns the Unicode equivalent of the input native code point given by \f(CW\*(C`ch\*(C'\fR. Thus, \f(CW\*(C`NATIVE_TO_UNI(195)\*(C'\fR on \s-1EBCDIC\s0 platforms returns 67. These each represent the character \f(CW"C"\fR on their respective platforms. On \s-1ASCII\s0 platforms no conversion is needed, so this macro expands to just its input, adding no time nor space requirements to the implementation. .Sp .Vb 1 \& UV NATIVE_TO_UNI(UV ch) .Ve .IP "pv_uni_display" 8 .IX Xref "pv_uni_display" .IX Item "pv_uni_display" Build to the scalar \f(CW\*(C`dsv\*(C'\fR a displayable version of the \s-1UTF\-8\s0 encoded string \&\f(CW\*(C`spv\*(C'\fR, length \f(CW\*(C`len\*(C'\fR, the displayable version being at most \f(CW\*(C`pvlim\*(C'\fR bytes long (if longer, the rest is truncated and \f(CW"..."\fR will be appended). .Sp The \f(CW\*(C`flags\*(C'\fR argument can have \f(CW\*(C`UNI_DISPLAY_ISPRINT\*(C'\fR set to display \&\f(CW\*(C`isPRINT()\*(C'\fRable characters as themselves, \f(CW\*(C`UNI_DISPLAY_BACKSLASH\*(C'\fR to display the \f(CW\*(C`\e\e[nrfta\e\e]\*(C'\fR as the backslashed versions (like \f(CW"\en"\fR) (\f(CW\*(C`UNI_DISPLAY_BACKSLASH\*(C'\fR is preferred over \f(CW\*(C`UNI_DISPLAY_ISPRINT\*(C'\fR for \f(CW"\e\e"\fR). \&\f(CW\*(C`UNI_DISPLAY_QQ\*(C'\fR (and its alias \f(CW\*(C`UNI_DISPLAY_REGEX\*(C'\fR) have both \&\f(CW\*(C`UNI_DISPLAY_BACKSLASH\*(C'\fR and \f(CW\*(C`UNI_DISPLAY_ISPRINT\*(C'\fR turned on. .Sp Additionally, there is now \f(CW\*(C`UNI_DISPLAY_BACKSPACE\*(C'\fR which allows \f(CW\*(C`\eb\*(C'\fR for a backspace, but only when \f(CW\*(C`UNI_DISPLAY_BACKSLASH\*(C'\fR also is set. .Sp The pointer to the \s-1PV\s0 of the \f(CW\*(C`dsv\*(C'\fR is returned. .Sp See also \*(L"sv_uni_display\*(R". .Sp .Vb 3 \& char* pv_uni_display(SV *dsv, const U8 *spv, \& STRLEN len, STRLEN pvlim, \& UV flags) .Ve .IP "\s-1REPLACEMENT_CHARACTER_UTF8\s0" 8 .IX Xref "REPLACEMENT_CHARACTER_UTF8" .IX Item "REPLACEMENT_CHARACTER_UTF8" This is a macro that evaluates to a string constant of the \s-1UTF\-8\s0 bytes that define the Unicode \s-1REPLACEMENT CHARACTER\s0 (U+FFFD) for the platform that perl is compiled on. This allows code to use a mnemonic for this character that works on both \s-1ASCII\s0 and \s-1EBCDIC\s0 platforms. \&\f(CW\*(C`sizeof(REPLACEMENT_CHARACTER_UTF8) \- 1\*(C'\fR can be used to get its length in bytes. .IP "sv_cat_decode" 8 .IX Xref "sv_cat_decode" .IX Item "sv_cat_decode" \&\f(CW\*(C`encoding\*(C'\fR is assumed to be an \f(CW\*(C`Encode\*(C'\fR object, the \s-1PV\s0 of \f(CW\*(C`ssv\*(C'\fR is assumed to be octets in that encoding and decoding the input starts from the position which \f(CW\*(C`(PV + *offset)\*(C'\fR pointed to. \f(CW\*(C`dsv\*(C'\fR will be concatenated with the decoded \s-1UTF\-8\s0 string from \f(CW\*(C`ssv\*(C'\fR. Decoding will terminate when the string \f(CW\*(C`tstr\*(C'\fR appears in decoding output or the input ends on the \s-1PV\s0 of \f(CW\*(C`ssv\*(C'\fR. The value which \f(CW\*(C`offset\*(C'\fR points will be modified to the last input position on \f(CW\*(C`ssv\*(C'\fR. .Sp Returns \s-1TRUE\s0 if the terminator was found, else returns \s-1FALSE.\s0 .Sp .Vb 2 \& bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, \& int *offset, char* tstr, int tlen) .Ve .IP "sv_recode_to_utf8" 8 .IX Xref "sv_recode_to_utf8" .IX Item "sv_recode_to_utf8" \&\f(CW\*(C`encoding\*(C'\fR is assumed to be an \f(CW\*(C`Encode\*(C'\fR object, on entry the \s-1PV\s0 of \f(CW\*(C`sv\*(C'\fR is assumed to be octets in that encoding, and \f(CW\*(C`sv\*(C'\fR will be converted into Unicode (and \s-1UTF\-8\s0). .Sp If \f(CW\*(C`sv\*(C'\fR already is \s-1UTF\-8\s0 (or if it is not \f(CW\*(C`POK\*(C'\fR), or if \f(CW\*(C`encoding\*(C'\fR is not a reference, nothing is done to \f(CW\*(C`sv\*(C'\fR. If \f(CW\*(C`encoding\*(C'\fR is not an \f(CW\*(C`Encode::XS\*(C'\fR Encoding object, bad things will happen. (See \fIcpan/Encode/encoding.pm\fR and Encode.) .Sp The \s-1PV\s0 of \f(CW\*(C`sv\*(C'\fR is returned. .Sp .Vb 1 \& char* sv_recode_to_utf8(SV* sv, SV *encoding) .Ve .IP "sv_uni_display" 8 .IX Xref "sv_uni_display" .IX Item "sv_uni_display" Build to the scalar \f(CW\*(C`dsv\*(C'\fR a displayable version of the scalar \f(CW\*(C`sv\*(C'\fR, the displayable version being at most \f(CW\*(C`pvlim\*(C'\fR bytes long (if longer, the rest is truncated and \*(L"...\*(R" will be appended). .Sp The \f(CW\*(C`flags\*(C'\fR argument is as in \*(L"pv_uni_display\*(R"(). .Sp The pointer to the \s-1PV\s0 of the \f(CW\*(C`dsv\*(C'\fR is returned. .Sp .Vb 2 \& char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, \& UV flags) .Ve .IP "\s-1UNICODE_REPLACEMENT\s0" 8 .IX Xref "UNICODE_REPLACEMENT" .IX Item "UNICODE_REPLACEMENT" Evaluates to 0xFFFD, the code point of the Unicode \s-1REPLACEMENT CHARACTER\s0 .IP "\s-1UNI_TO_NATIVE\s0" 8 .IX Xref "UNI_TO_NATIVE" .IX Item "UNI_TO_NATIVE" Returns the native equivalent of the input Unicode code point given by \f(CW\*(C`ch\*(C'\fR. Thus, \f(CW\*(C`UNI_TO_NATIVE(68)\*(C'\fR on \s-1EBCDIC\s0 platforms returns 196. These each represent the character \f(CW"D"\fR on their respective platforms. On \s-1ASCII\s0 platforms no conversion is needed, so this macro expands to just its input, adding no time nor space requirements to the implementation. .Sp .Vb 1 \& UV UNI_TO_NATIVE(UV ch) .Ve .IP "utf8n_to_uvchr" 8 .IX Xref "utf8n_to_uvchr" .IX Item "utf8n_to_uvchr" \&\s-1THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES.\s0 Most code should use \*(L"utf8_to_uvchr_buf\*(R"() rather than call this directly. .Sp Bottom level \s-1UTF\-8\s0 decode routine. Returns the native code point value of the first character in the string \f(CW\*(C`s\*(C'\fR, which is assumed to be in \s-1UTF\-8\s0 (or UTF-EBCDIC) encoding, and no longer than \&\f(CW\*(C`curlen\*(C'\fR bytes; \f(CW*retlen\fR (if \f(CW\*(C`retlen\*(C'\fR isn't \s-1NULL\s0) will be set to the length, in bytes, of that character. .Sp The value of \f(CW\*(C`flags\*(C'\fR determines the behavior when \f(CW\*(C`s\*(C'\fR does not point to a well-formed \s-1UTF\-8\s0 character. If \f(CW\*(C`flags\*(C'\fR is 0, encountering a malformation causes zero to be returned and \f(CW*retlen\fR is set so that (\f(CW\*(C`s\*(C'\fR + \f(CW*retlen\fR) is the next possible position in \f(CW\*(C`s\*(C'\fR that could begin a non-malformed character. Also, if \s-1UTF\-8\s0 warnings haven't been lexically disabled, a warning is raised. Some \s-1UTF\-8\s0 input sequences may contain multiple malformations. This function tries to find every possible one in each call, so multiple warnings can be raised for the same sequence. .Sp Various \s-1ALLOW\s0 flags can be set in \f(CW\*(C`flags\*(C'\fR 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 \s-1UTF\-8\s0 standard due to potential security issues). Another malformation example is the first byte of a character not being a legal first byte. See \fIutf8.h\fR for the list of such flags. Even if allowed, this function generally returns the Unicode \&\s-1REPLACEMENT CHARACTER\s0 when it encounters a malformation. There are flags in \&\fIutf8.h\fR to override this behavior for the overlong malformations, but don't do that except for very specialized purposes. .Sp The \f(CW\*(C`UTF8_CHECK_ONLY\*(C'\fR 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 \&\f(CW\*(C`retlen\*(C'\fR to \f(CW\*(C`\-1\*(C'\fR (cast to \f(CW\*(C`STRLEN\*(C'\fR) and return zero. .Sp Note that this \s-1API\s0 requires disambiguation between successful decoding a \f(CW\*(C`NUL\*(C'\fR character, and an error return (unless the \f(CW\*(C`UTF8_CHECK_ONLY\*(C'\fR flag is set), as in both cases, 0 is returned, and, depending on the malformation, \f(CW\*(C`retlen\*(C'\fR may be set to 1. To disambiguate, upon a zero return, see if the first byte of \&\f(CW\*(C`s\*(C'\fR is 0 as well. If so, the input was a \f(CW\*(C`NUL\*(C'\fR; if not, the input had an error. Or you can use \f(CW"utf8n_to_uvchr_error"\fR. .Sp 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, which can be specified using the \f(CW\*(C`flags\*(C'\fR parameter. If \f(CW\*(C`flags\*(C'\fR contains \f(CW\*(C`UTF8_DISALLOW_ILLEGAL_INTERCHANGE\*(C'\fR, all three classes are treated as malformations and handled as such. The flags \&\f(CW\*(C`UTF8_DISALLOW_SURROGATE\*(C'\fR, \f(CW\*(C`UTF8_DISALLOW_NONCHAR\*(C'\fR, and \&\f(CW\*(C`UTF8_DISALLOW_SUPER\*(C'\fR (meaning above the legal Unicode maximum) can be set to disallow these categories individually. \f(CW\*(C`UTF8_DISALLOW_ILLEGAL_INTERCHANGE\*(C'\fR restricts the allowed inputs to the strict \s-1UTF\-8\s0 traditionally defined by Unicode. Use \f(CW\*(C`UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE\*(C'\fR to use the strictness definition given by Unicode Corrigendum #9 . The difference between traditional strictness and C9 strictness is that the latter does not forbid non-character code points. (They are still discouraged, however.) For more discussion see \*(L"Noncharacter code points\*(R" in perlunicode. .Sp The flags \f(CW\*(C`UTF8_WARN_ILLEGAL_INTERCHANGE\*(C'\fR, \&\f(CW\*(C`UTF8_WARN_ILLEGAL_C9_INTERCHANGE\*(C'\fR, \f(CW\*(C`UTF8_WARN_SURROGATE\*(C'\fR, \&\f(CW\*(C`UTF8_WARN_NONCHAR\*(C'\fR, and \f(CW\*(C`UTF8_WARN_SUPER\*(C'\fR 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 \s-1WARN\s0 and \s-1DISALLOW\s0 flags. (But note that warnings are not raised if lexically disabled nor if \&\f(CW\*(C`UTF8_CHECK_ONLY\*(C'\fR is also specified.) .Sp Extremely high code points were never specified in any standard, and require an extension to \s-1UTF\-8\s0 to express, which Perl does. It is likely that programs written in something other than Perl would not be able to read files that contain these; nor would Perl understand files written by something that uses a different extension. For these reasons, there is a separate set of flags that can warn and/or disallow these extremely high code points, even if other above-Unicode ones are accepted. They are the \f(CW\*(C`UTF8_WARN_PERL_EXTENDED\*(C'\fR and \&\f(CW\*(C`UTF8_DISALLOW_PERL_EXTENDED\*(C'\fR flags. For more information see "\f(CW\*(C`UTF8_GOT_PERL_EXTENDED\*(C'\fR". Of course \f(CW\*(C`UTF8_DISALLOW_SUPER\*(C'\fR will treat all above-Unicode code points, including these, as malformations. (Note that the Unicode standard considers anything above 0x10FFFF to be illegal, but there are standards predating it that allow up to 0x7FFF_FFFF (2**31 \-1)) .Sp A somewhat misleadingly named synonym for \f(CW\*(C`UTF8_WARN_PERL_EXTENDED\*(C'\fR is retained for backward compatibility: \f(CW\*(C`UTF8_WARN_ABOVE_31_BIT\*(C'\fR. Similarly, \&\f(CW\*(C`UTF8_DISALLOW_ABOVE_31_BIT\*(C'\fR is usable instead of the more accurately named \&\f(CW\*(C`UTF8_DISALLOW_PERL_EXTENDED\*(C'\fR. The names are misleading because these flags can apply to code points that actually do fit in 31 bits. This happens on \&\s-1EBCDIC\s0 platforms, and sometimes when the overlong malformation is also present. The new names accurately describe the situation in all cases. .Sp All other code points corresponding to Unicode characters, including private use and those yet to be assigned, are never considered malformed and never warn. .Sp .Vb 2 \& UV utf8n_to_uvchr(const U8 *s, STRLEN curlen, \& STRLEN *retlen, const U32 flags) .Ve .IP "utf8n_to_uvchr_error" 8 .IX Xref "utf8n_to_uvchr_error" .IX Item "utf8n_to_uvchr_error" \&\s-1THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES.\s0 Most code should use \*(L"utf8_to_uvchr_buf\*(R"() rather than call this directly. .Sp This function is for code that needs to know what the precise malformation(s) are when an error is found. If you also need to know the generated warning messages, use \*(L"utf8n_to_uvchr_msgs\*(R"() instead. .Sp It is like \f(CW"utf8n_to_uvchr"\fR but it takes an extra parameter placed after all the others, \f(CW\*(C`errors\*(C'\fR. If this parameter is 0, this function behaves identically to \f(CW"utf8n_to_uvchr"\fR. Otherwise, \f(CW\*(C`errors\*(C'\fR should be a pointer to a \f(CW\*(C`U32\*(C'\fR variable, which this function sets to indicate any errors found. Upon return, if \f(CW*errors\fR is 0, there were no errors found. Otherwise, \&\f(CW*errors\fR is the bit-wise \f(CW\*(C`OR\*(C'\fR of the bits described in the list below. Some of these bits will be set if a malformation is found, even if the input \&\f(CW\*(C`flags\*(C'\fR parameter indicates that the given malformation is allowed; those exceptions are noted: .RS 8 .ie n .IP """UTF8_GOT_PERL_EXTENDED""" 4 .el .IP "\f(CWUTF8_GOT_PERL_EXTENDED\fR" 4 .IX Item "UTF8_GOT_PERL_EXTENDED" The input sequence is not standard \s-1UTF\-8,\s0 but a Perl extension. This bit is set only if the input \f(CW\*(C`flags\*(C'\fR parameter contains either the \&\f(CW\*(C`UTF8_DISALLOW_PERL_EXTENDED\*(C'\fR or the \f(CW\*(C`UTF8_WARN_PERL_EXTENDED\*(C'\fR flags. .Sp Code points above 0x7FFF_FFFF (2**31 \- 1) were never specified in any standard, and so some extension must be used to express them. Perl uses a natural extension to \s-1UTF\-8\s0 to represent the ones up to 2**36\-1, and invented a further extension to represent even higher ones, so that any code point that fits in a 64\-bit word can be represented. Text using these extensions is not likely to be portable to non-Perl code. We lump both of these extensions together and refer to them as Perl extended \s-1UTF\-8.\s0 There exist other extensions that people have invented, incompatible with Perl's. .Sp On \s-1EBCDIC\s0 platforms starting in Perl v5.24, the Perl extension for representing extremely high code points kicks in at 0x3FFF_FFFF (2**30 \-1), which is lower than on \s-1ASCII.\s0 Prior to that, code points 2**31 and higher were simply unrepresentable, and a different, incompatible method was used to represent code points between 2**30 and 2**31 \- 1. .Sp On both platforms, \s-1ASCII\s0 and \s-1EBCDIC,\s0 \f(CW\*(C`UTF8_GOT_PERL_EXTENDED\*(C'\fR is set if Perl extended \s-1UTF\-8\s0 is used. .Sp In earlier Perls, this bit was named \f(CW\*(C`UTF8_GOT_ABOVE_31_BIT\*(C'\fR, which you still may use for backward compatibility. That name is misleading, as this flag may be set when the code point actually does fit in 31 bits. This happens on \&\s-1EBCDIC\s0 platforms, and sometimes when the overlong malformation is also present. The new name accurately describes the situation in all cases. .ie n .IP """UTF8_GOT_CONTINUATION""" 4 .el .IP "\f(CWUTF8_GOT_CONTINUATION\fR" 4 .IX Item "UTF8_GOT_CONTINUATION" The input sequence was malformed in that the first byte was a \s-1UTF\-8\s0 continuation byte. .ie n .IP """UTF8_GOT_EMPTY""" 4 .el .IP "\f(CWUTF8_GOT_EMPTY\fR" 4 .IX Item "UTF8_GOT_EMPTY" The input \f(CW\*(C`curlen\*(C'\fR parameter was 0. .ie n .IP """UTF8_GOT_LONG""" 4 .el .IP "\f(CWUTF8_GOT_LONG\fR" 4 .IX Item "UTF8_GOT_LONG" The input sequence was malformed in that there is some other sequence that evaluates to the same code point, but that sequence is shorter than this one. .Sp Until Unicode 3.1, it was legal for programs to accept this malformation, but it was discovered that this created security issues. .ie n .IP """UTF8_GOT_NONCHAR""" 4 .el .IP "\f(CWUTF8_GOT_NONCHAR\fR" 4 .IX Item "UTF8_GOT_NONCHAR" The code point represented by the input \s-1UTF\-8\s0 sequence is for a Unicode non-character code point. This bit is set only if the input \f(CW\*(C`flags\*(C'\fR parameter contains either the \&\f(CW\*(C`UTF8_DISALLOW_NONCHAR\*(C'\fR or the \f(CW\*(C`UTF8_WARN_NONCHAR\*(C'\fR flags. .ie n .IP """UTF8_GOT_NON_CONTINUATION""" 4 .el .IP "\f(CWUTF8_GOT_NON_CONTINUATION\fR" 4 .IX Item "UTF8_GOT_NON_CONTINUATION" The input sequence was malformed in that a non-continuation type byte was found in a position where only a continuation type one should be. See also "\f(CW\*(C`UTF8_GOT_SHORT\*(C'\fR". .ie n .IP """UTF8_GOT_OVERFLOW""" 4 .el .IP "\f(CWUTF8_GOT_OVERFLOW\fR" 4 .IX Item "UTF8_GOT_OVERFLOW" The input sequence was malformed in that it is for a code point that is not representable in the number of bits available in an \s-1IV\s0 on the current platform. .ie n .IP """UTF8_GOT_SHORT""" 4 .el .IP "\f(CWUTF8_GOT_SHORT\fR" 4 .IX Item "UTF8_GOT_SHORT" The input sequence was malformed in that \f(CW\*(C`curlen\*(C'\fR is smaller than required for a complete sequence. In other words, the input is for a partial character sequence. .Sp \&\f(CW\*(C`UTF8_GOT_SHORT\*(C'\fR and \f(CW\*(C`UTF8_GOT_NON_CONTINUATION\*(C'\fR both indicate a too short sequence. The difference is that \f(CW\*(C`UTF8_GOT_NON_CONTINUATION\*(C'\fR indicates always that there is an error, while \f(CW\*(C`UTF8_GOT_SHORT\*(C'\fR means that an incomplete sequence was looked at. If no other flags are present, it means that the sequence was valid as far as it went. Depending on the application, this could mean one of three things: .RS 4 .IP "\(bu" 4 The \f(CW\*(C`curlen\*(C'\fR length parameter passed in was too small, and the function was prevented from examining all the necessary bytes. .IP "\(bu" 4 The buffer being looked at is based on reading data, and the data received so far stopped in the middle of a character, so that the next read will read the remainder of this character. (It is up to the caller to deal with the split bytes somehow.) .IP "\(bu" 4 This is a real error, and the partial sequence is all we're going to get. .RE .RS 4 .RE .ie n .IP """UTF8_GOT_SUPER""" 4 .el .IP "\f(CWUTF8_GOT_SUPER\fR" 4 .IX Item "UTF8_GOT_SUPER" The input sequence was malformed in that it is for a non-Unicode code point; that is, one above the legal Unicode maximum. This bit is set only if the input \f(CW\*(C`flags\*(C'\fR parameter contains either the \&\f(CW\*(C`UTF8_DISALLOW_SUPER\*(C'\fR or the \f(CW\*(C`UTF8_WARN_SUPER\*(C'\fR flags. .ie n .IP """UTF8_GOT_SURROGATE""" 4 .el .IP "\f(CWUTF8_GOT_SURROGATE\fR" 4 .IX Item "UTF8_GOT_SURROGATE" The input sequence was malformed in that it is for a \-Unicode \s-1UTF\-16\s0 surrogate code point. This bit is set only if the input \f(CW\*(C`flags\*(C'\fR parameter contains either the \&\f(CW\*(C`UTF8_DISALLOW_SURROGATE\*(C'\fR or the \f(CW\*(C`UTF8_WARN_SURROGATE\*(C'\fR flags. .RE .RS 8 .Sp To do your own error handling, call this function with the \f(CW\*(C`UTF8_CHECK_ONLY\*(C'\fR flag to suppress any warnings, and then examine the \f(CW*errors\fR return. .Sp .Vb 4 \& UV utf8n_to_uvchr_error(const U8 *s, STRLEN curlen, \& STRLEN *retlen, \& const U32 flags, \& U32 * errors) .Ve .RE .IP "utf8n_to_uvchr_msgs" 8 .IX Xref "utf8n_to_uvchr_msgs" .IX Item "utf8n_to_uvchr_msgs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp \&\s-1THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES.\s0 Most code should use \*(L"utf8_to_uvchr_buf\*(R"() rather than call this directly. .Sp This function is for code that needs to know what the precise malformation(s) are when an error is found, and wants the corresponding warning and/or error messages to be returned to the caller rather than be displayed. All messages that would have been displayed if all lexcial warnings are enabled will be returned. .Sp It is just like \f(CW"utf8n_to_uvchr_error"\fR but it takes an extra parameter placed after all the others, \f(CW\*(C`msgs\*(C'\fR. If this parameter is 0, this function behaves identically to \f(CW"utf8n_to_uvchr_error"\fR. Otherwise, \f(CW\*(C`msgs\*(C'\fR should be a pointer to an \f(CW\*(C`AV *\*(C'\fR variable, in which this function creates a new \s-1AV\s0 to contain any appropriate messages. The elements of the array are ordered so that the first message that would have been displayed is in the 0th element, and so on. Each element is a hash with three key-value pairs, as follows: .RS 8 .ie n .IP """text""" 4 .el .IP "\f(CWtext\fR" 4 .IX Item "text" The text of the message as a \f(CW\*(C`SVpv\*(C'\fR. .ie n .IP """warn_categories""" 4 .el .IP "\f(CWwarn_categories\fR" 4 .IX Item "warn_categories" The warning category (or categories) packed into a \f(CW\*(C`SVuv\*(C'\fR. .ie n .IP """flag""" 4 .el .IP "\f(CWflag\fR" 4 .IX Item "flag" A single flag bit associated with this message, in a \f(CW\*(C`SVuv\*(C'\fR. The bit corresponds to some bit in the \f(CW*errors\fR return value, such as \f(CW\*(C`UTF8_GOT_LONG\*(C'\fR. .RE .RS 8 .Sp It's important to note that specifying this parameter as non-null will cause any warnings this function would otherwise generate to be suppressed, and instead be placed in \f(CW*msgs\fR. The caller can check the lexical warnings state (or not) when choosing what to do with the returned messages. .Sp If the flag \f(CW\*(C`UTF8_CHECK_ONLY\*(C'\fR is passed, no warnings are generated, and hence no \s-1AV\s0 is created. .Sp The caller, of course, is responsible for freeing any returned \s-1AV.\s0 .Sp .Vb 4 \& UV utf8n_to_uvchr_msgs(const U8 *s, STRLEN curlen, \& STRLEN *retlen, \& const U32 flags, \& U32 * errors, AV ** msgs) .Ve .RE .IP "\s-1UTF8SKIP\s0" 8 .IX Xref "UTF8SKIP" .IX Item "UTF8SKIP" returns the number of bytes a non-malformed \s-1UTF\-8\s0 encoded character whose first (perhaps only) byte is pointed to by \f(CW\*(C`s\*(C'\fR. .Sp If there is a possibility of malformed input, use instead: .RS 8 .ie n .IP """""UTF8_SAFE_SKIP"""" if you know the maximum ending pointer in the buffer pointed to by ""s""; or" 4 .el .IP "``\f(CWUTF8_SAFE_SKIP\fR'' if you know the maximum ending pointer in the buffer pointed to by \f(CWs\fR; or" 4 .IX Item """UTF8_SAFE_SKIP"" if you know the maximum ending pointer in the buffer pointed to by s; or" .PD 0 .ie n .IP """""UTF8_CHK_SKIP"""" if you don't know it." 4 .el .IP "``\f(CWUTF8_CHK_SKIP\fR'' if you don't know it." 4 .IX Item """UTF8_CHK_SKIP"" if you don't know it." .RE .RS 8 .PD .Sp It is better to restructure your code so the end pointer is passed down so that you know what it actually is at the point of this call, but if that isn't possible, "\f(CW\*(C`UTF8_CHK_SKIP\*(C'\fR" can minimize the chance of accessing beyond the end of the input buffer. .Sp .Vb 1 \& STRLEN UTF8SKIP(char* s) .Ve .RE .IP "\s-1UTF8_CHK_SKIP\s0" 8 .IX Xref "UTF8_CHK_SKIP" .IX Item "UTF8_CHK_SKIP" This is a safer version of "\f(CW\*(C`UTF8SKIP\*(C'\fR", but still not as safe as "\f(CW\*(C`UTF8_SAFE_SKIP\*(C'\fR". This version doesn't blindly assume that the input string pointed to by \f(CW\*(C`s\*(C'\fR is well-formed, but verifies that there isn't a \s-1NUL\s0 terminating character before the expected end of the next character in \f(CW\*(C`s\*(C'\fR. The length \f(CW\*(C`UTF8_CHK_SKIP\*(C'\fR returns stops just before any such \s-1NUL.\s0 .Sp Perl tends to add NULs, as an insurance policy, after the end of strings in \&\s-1SV\s0's, so it is likely that using this macro will prevent inadvertent reading beyond the end of the input buffer, even if it is malformed \s-1UTF\-8.\s0 .Sp This macro is intended to be used by \s-1XS\s0 modules where the inputs could be malformed, and it isn't feasible to restructure to use the safer "\f(CW\*(C`UTF8_SAFE_SKIP\*(C'\fR", for example when interfacing with a C library. .Sp .Vb 1 \& STRLEN UTF8_CHK_SKIP(char* s) .Ve .IP "utf8_distance" 8 .IX Xref "utf8_distance" .IX Item "utf8_distance" Returns the number of \s-1UTF\-8\s0 characters between the \s-1UTF\-8\s0 pointers \f(CW\*(C`a\*(C'\fR and \f(CW\*(C`b\*(C'\fR. .Sp \&\s-1WARNING:\s0 use only if you *know* that the pointers point inside the same \s-1UTF\-8\s0 buffer. .Sp .Vb 1 \& IV utf8_distance(const U8 *a, const U8 *b) .Ve .IP "utf8_hop" 8 .IX Xref "utf8_hop" .IX Item "utf8_hop" Return the \s-1UTF\-8\s0 pointer \f(CW\*(C`s\*(C'\fR displaced by \f(CW\*(C`off\*(C'\fR characters, either forward or backward. .Sp \&\s-1WARNING:\s0 do not use the following unless you *know* \f(CW\*(C`off\*(C'\fR is within the \s-1UTF\-8\s0 data pointed to by \f(CW\*(C`s\*(C'\fR *and* that on entry \f(CW\*(C`s\*(C'\fR is aligned on the first byte of character or just after the last byte of a character. .Sp .Vb 1 \& U8* utf8_hop(const U8 *s, SSize_t off) .Ve .IP "utf8_hop_back" 8 .IX Xref "utf8_hop_back" .IX Item "utf8_hop_back" Return the \s-1UTF\-8\s0 pointer \f(CW\*(C`s\*(C'\fR displaced by up to \f(CW\*(C`off\*(C'\fR characters, backward. .Sp \&\f(CW\*(C`off\*(C'\fR must be non-positive. .Sp \&\f(CW\*(C`s\*(C'\fR must be after or equal to \f(CW\*(C`start\*(C'\fR. .Sp When moving backward it will not move before \f(CW\*(C`start\*(C'\fR. .Sp Will not exceed this limit even if the string is not valid \*(L"\s-1UTF\-8\*(R".\s0 .Sp .Vb 2 \& U8* utf8_hop_back(const U8 *s, SSize_t off, \& const U8 *start) .Ve .IP "utf8_hop_forward" 8 .IX Xref "utf8_hop_forward" .IX Item "utf8_hop_forward" Return the \s-1UTF\-8\s0 pointer \f(CW\*(C`s\*(C'\fR displaced by up to \f(CW\*(C`off\*(C'\fR characters, forward. .Sp \&\f(CW\*(C`off\*(C'\fR must be non-negative. .Sp \&\f(CW\*(C`s\*(C'\fR must be before or equal to \f(CW\*(C`end\*(C'\fR. .Sp When moving forward it will not move beyond \f(CW\*(C`end\*(C'\fR. .Sp Will not exceed this limit even if the string is not valid \*(L"\s-1UTF\-8\*(R".\s0 .Sp .Vb 2 \& U8* utf8_hop_forward(const U8 *s, SSize_t off, \& const U8 *end) .Ve .IP "utf8_hop_safe" 8 .IX Xref "utf8_hop_safe" .IX Item "utf8_hop_safe" Return the \s-1UTF\-8\s0 pointer \f(CW\*(C`s\*(C'\fR displaced by up to \f(CW\*(C`off\*(C'\fR characters, either forward or backward. .Sp When moving backward it will not move before \f(CW\*(C`start\*(C'\fR. .Sp When moving forward it will not move beyond \f(CW\*(C`end\*(C'\fR. .Sp Will not exceed those limits even if the string is not valid \*(L"\s-1UTF\-8\*(R".\s0 .Sp .Vb 2 \& U8* utf8_hop_safe(const U8 *s, SSize_t off, \& const U8 *start, const U8 *end) .Ve .IP "\s-1UTF8_IS_INVARIANT\s0" 8 .IX Xref "UTF8_IS_INVARIANT" .IX Item "UTF8_IS_INVARIANT" Evaluates to 1 if the byte \f(CW\*(C`c\*(C'\fR represents the same character when encoded in \&\s-1UTF\-8\s0 as when not; otherwise evaluates to 0. \s-1UTF\-8\s0 invariant characters can be copied as-is when converting to/from \s-1UTF\-8,\s0 saving time. .Sp In spite of the name, this macro gives the correct result if the input string from which \f(CW\*(C`c\*(C'\fR comes is not encoded in \s-1UTF\-8.\s0 .Sp See \f(CW"UVCHR_IS_INVARIANT"\fR for checking if a \s-1UV\s0 is invariant. .Sp .Vb 1 \& bool UTF8_IS_INVARIANT(char c) .Ve .IP "\s-1UTF8_IS_NONCHAR\s0" 8 .IX Xref "UTF8_IS_NONCHAR" .IX Item "UTF8_IS_NONCHAR" Evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are well-formed \s-1UTF\-8\s0 that represents one of the Unicode non-character code points; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. .Sp .Vb 1 \& bool UTF8_IS_NONCHAR(const U8 *s, const U8 *e) .Ve .IP "\s-1UTF8_IS_SUPER\s0" 8 .IX Xref "UTF8_IS_SUPER" .IX Item "UTF8_IS_SUPER" Recall that Perl recognizes an extension to \s-1UTF\-8\s0 that can encode code points larger than the ones defined by Unicode, which are 0..0x10FFFF. .Sp This macro evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are from this \s-1UTF\-8\s0 extension; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. .Sp 0 is returned if the bytes are not well-formed extended \s-1UTF\-8,\s0 or if they represent a code point that cannot fit in a \s-1UV\s0 on the current platform. Hence this macro can give different results when run on a 64\-bit word machine than on one with a 32\-bit word size. .Sp Note that it is illegal to have code points that are larger than what can fit in an \s-1IV\s0 on the current machine. .Sp .Vb 1 \& bool UTF8_IS_SUPER(const U8 *s, const U8 *e) .Ve .IP "\s-1UTF8_IS_SURROGATE\s0" 8 .IX Xref "UTF8_IS_SURROGATE" .IX Item "UTF8_IS_SURROGATE" Evaluates to non-zero if the first few bytes of the string starting at \f(CW\*(C`s\*(C'\fR and looking no further than \f(CW\*(C`e \- 1\*(C'\fR are well-formed \s-1UTF\-8\s0 that represents one of the Unicode surrogate code points; otherwise it evaluates to 0. If non-zero, the value gives how many bytes starting at \f(CW\*(C`s\*(C'\fR comprise the code point's representation. .Sp .Vb 1 \& bool UTF8_IS_SURROGATE(const U8 *s, const U8 *e) .Ve .IP "utf8_length" 8 .IX Xref "utf8_length" .IX Item "utf8_length" Returns the number of characters in the sequence of UTF\-8\-encoded bytes starting at \f(CW\*(C`s\*(C'\fR and ending at the byte just before \f(CW\*(C`e\*(C'\fR. If and point to the same place, it returns 0 with no warning raised. .Sp If \f(CW\*(C`e < s\*(C'\fR or if the scan would end up past \f(CW\*(C`e\*(C'\fR, it raises a \s-1UTF8\s0 warning and returns the number of valid characters. .Sp .Vb 1 \& STRLEN utf8_length(const U8* s, const U8 *e) .Ve .IP "\s-1UTF8_MAXBYTES\s0" 8 .IX Xref "UTF8_MAXBYTES" .IX Item "UTF8_MAXBYTES" The maximum width of a single \s-1UTF\-8\s0 encoded character, in bytes. .Sp \&\s-1NOTE:\s0 Strictly speaking Perl's \s-1UTF\-8\s0 should not be called \s-1UTF\-8\s0 since \s-1UTF\-8\s0 is an encoding of Unicode, and Unicode's upper limit, 0x10FFFF, can be expressed with 4 bytes. However, Perl thinks of \s-1UTF\-8\s0 as a way to encode non-negative integers in a binary format, even those above Unicode. .IP "\s-1UTF8_MAXBYTES_CASE\s0" 8 .IX Xref "UTF8_MAXBYTES_CASE" .IX Item "UTF8_MAXBYTES_CASE" The maximum number of \s-1UTF\-8\s0 bytes a single Unicode character can uppercase/lowercase/titlecase/fold into. .IP "\s-1UTF8_SAFE_SKIP\s0" 8 .IX Xref "UTF8_SAFE_SKIP" .IX Item "UTF8_SAFE_SKIP" returns 0 if \f(CW\*(C`s >= e\*(C'\fR; otherwise returns the number of bytes in the \&\s-1UTF\-8\s0 encoded character whose first byte is pointed to by \f(CW\*(C`s\*(C'\fR. But it never returns beyond \f(CW\*(C`e\*(C'\fR. On \s-1DEBUGGING\s0 builds, it asserts that \f(CW\*(C`s <= e\*(C'\fR. .Sp .Vb 1 \& STRLEN UTF8_SAFE_SKIP(char* s, char* e) .Ve .IP "\s-1UTF8_SKIP\s0" 8 .IX Xref "UTF8_SKIP" .IX Item "UTF8_SKIP" This is a synonym for "\f(CW\*(C`UTF8SKIP\*(C'\fR" .Sp .Vb 1 \& STRLEN UTF8_SKIP(char* s) .Ve .IP "utf8_to_bytes" 8 .IX Xref "utf8_to_bytes" .IX Item "utf8_to_bytes" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp Converts a string \f(CW"s"\fR of length \f(CW*lenp\fR from \s-1UTF\-8\s0 into native byte encoding. Unlike \*(L"bytes_to_utf8\*(R", this over-writes the original string, and updates \f(CW*lenp\fR to contain the new length. Returns zero on failure (leaving \f(CW"s"\fR unchanged) setting \f(CW*lenp\fR to \-1. .Sp Upon successful return, the number of variants in the string can be computed by having saved the value of \f(CW*lenp\fR before the call, and subtracting the after-call value of \f(CW*lenp\fR from it. .Sp If you need a copy of the string, see \*(L"bytes_from_utf8\*(R". .Sp .Vb 1 \& U8* utf8_to_bytes(U8 *s, STRLEN *lenp) .Ve .IP "utf8_to_uvchr_buf" 8 .IX Xref "utf8_to_uvchr_buf" .IX Item "utf8_to_uvchr_buf" Returns the native code point of the first character in the string \f(CW\*(C`s\*(C'\fR which is assumed to be in \s-1UTF\-8\s0 encoding; \f(CW\*(C`send\*(C'\fR points to 1 beyond the end of \f(CW\*(C`s\*(C'\fR. \&\f(CW*retlen\fR will be set to the length, in bytes, of that character. .Sp If \f(CW\*(C`s\*(C'\fR does not point to a well-formed \s-1UTF\-8\s0 character and \s-1UTF8\s0 warnings are enabled, zero is returned and \f(CW*retlen\fR is set (if \f(CW\*(C`retlen\*(C'\fR isn't \&\f(CW\*(C`NULL\*(C'\fR) to \-1. If those warnings are off, the computed value, if well-defined (or the Unicode \s-1REPLACEMENT CHARACTER\s0 if not), is silently returned, and \&\f(CW*retlen\fR is set (if \f(CW\*(C`retlen\*(C'\fR isn't \f(CW\*(C`NULL\*(C'\fR) so that (\f(CW\*(C`s\*(C'\fR + \f(CW*retlen\fR) is the next possible position in \f(CW\*(C`s\*(C'\fR that could begin a non-malformed character. See \*(L"utf8n_to_uvchr\*(R" for details on when the \s-1REPLACEMENT CHARACTER\s0 is returned. .Sp .Vb 2 \& UV utf8_to_uvchr_buf(const U8 *s, const U8 *send, \& STRLEN *retlen) .Ve .IP "\s-1UVCHR_IS_INVARIANT\s0" 8 .IX Xref "UVCHR_IS_INVARIANT" .IX Item "UVCHR_IS_INVARIANT" Evaluates to 1 if the representation of code point \f(CW\*(C`cp\*(C'\fR is the same whether or not it is encoded in \s-1UTF\-8\s0; otherwise evaluates to 0. \s-1UTF\-8\s0 invariant characters can be copied as-is when converting to/from \s-1UTF\-8,\s0 saving time. \&\f(CW\*(C`cp\*(C'\fR is Unicode if above 255; otherwise is platform-native. .Sp .Vb 1 \& bool UVCHR_IS_INVARIANT(UV cp) .Ve .IP "\s-1UVCHR_SKIP\s0" 8 .IX Xref "UVCHR_SKIP" .IX Item "UVCHR_SKIP" returns the number of bytes required to represent the code point \f(CW\*(C`cp\*(C'\fR when encoded as \s-1UTF\-8.\s0 \f(CW\*(C`cp\*(C'\fR is a native (\s-1ASCII\s0 or \s-1EBCDIC\s0) code point if less than 255; a Unicode code point otherwise. .Sp .Vb 1 \& STRLEN UVCHR_SKIP(UV cp) .Ve .IP "uvchr_to_utf8" 8 .IX Xref "uvchr_to_utf8" .IX Item "uvchr_to_utf8" Adds the \s-1UTF\-8\s0 representation of the native code point \f(CW\*(C`uv\*(C'\fR to the end of the string \f(CW\*(C`d\*(C'\fR; \f(CW\*(C`d\*(C'\fR should have at least \f(CW\*(C`UVCHR_SKIP(uv)+1\*(C'\fR (up to \&\f(CW\*(C`UTF8_MAXBYTES+1\*(C'\fR) free bytes available. The return value is the pointer to the byte after the end of the new character. In other words, .Sp .Vb 1 \& d = uvchr_to_utf8(d, uv); .Ve .Sp is the recommended wide native character-aware way of saying .Sp .Vb 1 \& *(d++) = uv; .Ve .Sp This function accepts any code point from 0..\f(CW\*(C`IV_MAX\*(C'\fR as input. \&\f(CW\*(C`IV_MAX\*(C'\fR is typically 0x7FFF_FFFF in a 32\-bit word. .Sp It is possible to forbid or warn on non-Unicode code points, or those that may be problematic by using \*(L"uvchr_to_utf8_flags\*(R". .Sp .Vb 1 \& U8* uvchr_to_utf8(U8 *d, UV uv) .Ve .IP "uvchr_to_utf8_flags" 8 .IX Xref "uvchr_to_utf8_flags" .IX Item "uvchr_to_utf8_flags" Adds the \s-1UTF\-8\s0 representation of the native code point \f(CW\*(C`uv\*(C'\fR to the end of the string \f(CW\*(C`d\*(C'\fR; \f(CW\*(C`d\*(C'\fR should have at least \f(CW\*(C`UVCHR_SKIP(uv)+1\*(C'\fR (up to \&\f(CW\*(C`UTF8_MAXBYTES+1\*(C'\fR) free bytes available. The return value is the pointer to the byte after the end of the new character. In other words, .Sp .Vb 1 \& d = uvchr_to_utf8_flags(d, uv, flags); .Ve .Sp or, in most cases, .Sp .Vb 1 \& d = uvchr_to_utf8_flags(d, uv, 0); .Ve .Sp This is the Unicode-aware way of saying .Sp .Vb 1 \& *(d++) = uv; .Ve .Sp If \f(CW\*(C`flags\*(C'\fR is 0, this function accepts any code point from 0..\f(CW\*(C`IV_MAX\*(C'\fR as input. \f(CW\*(C`IV_MAX\*(C'\fR is typically 0x7FFF_FFFF in a 32\-bit word. .Sp Specifying \f(CW\*(C`flags\*(C'\fR can further restrict what is allowed and not warned on, as follows: .Sp If \f(CW\*(C`uv\*(C'\fR is a Unicode surrogate code point and \f(CW\*(C`UNICODE_WARN_SURROGATE\*(C'\fR is set, the function will raise a warning, provided \s-1UTF8\s0 warnings are enabled. If instead \f(CW\*(C`UNICODE_DISALLOW_SURROGATE\*(C'\fR is set, the function will fail and return \&\s-1NULL.\s0 If both flags are set, the function will both warn and return \s-1NULL.\s0 .Sp Similarly, the \f(CW\*(C`UNICODE_WARN_NONCHAR\*(C'\fR and \f(CW\*(C`UNICODE_DISALLOW_NONCHAR\*(C'\fR flags affect how the function handles a Unicode non-character. .Sp And likewise, the \f(CW\*(C`UNICODE_WARN_SUPER\*(C'\fR and \f(CW\*(C`UNICODE_DISALLOW_SUPER\*(C'\fR flags affect the handling of code points that are above the Unicode maximum of 0x10FFFF. Languages other than Perl may not be able to accept files that contain these. .Sp The flag \f(CW\*(C`UNICODE_WARN_ILLEGAL_INTERCHANGE\*(C'\fR selects all three of the above \s-1WARN\s0 flags; and \f(CW\*(C`UNICODE_DISALLOW_ILLEGAL_INTERCHANGE\*(C'\fR selects all three \s-1DISALLOW\s0 flags. \f(CW\*(C`UNICODE_DISALLOW_ILLEGAL_INTERCHANGE\*(C'\fR restricts the allowed inputs to the strict \s-1UTF\-8\s0 traditionally defined by Unicode. Similarly, \f(CW\*(C`UNICODE_WARN_ILLEGAL_C9_INTERCHANGE\*(C'\fR and \&\f(CW\*(C`UNICODE_DISALLOW_ILLEGAL_C9_INTERCHANGE\*(C'\fR are shortcuts to select the above-Unicode and surrogate flags, but not the non-character ones, as defined in Unicode Corrigendum #9 . See \*(L"Noncharacter code points\*(R" in perlunicode. .Sp Extremely high code points were never specified in any standard, and require an extension to \s-1UTF\-8\s0 to express, which Perl does. It is likely that programs written in something other than Perl would not be able to read files that contain these; nor would Perl understand files written by something that uses a different extension. For these reasons, there is a separate set of flags that can warn and/or disallow these extremely high code points, even if other above-Unicode ones are accepted. They are the \f(CW\*(C`UNICODE_WARN_PERL_EXTENDED\*(C'\fR and \f(CW\*(C`UNICODE_DISALLOW_PERL_EXTENDED\*(C'\fR flags. For more information see "\f(CW\*(C`UTF8_GOT_PERL_EXTENDED\*(C'\fR". Of course \f(CW\*(C`UNICODE_DISALLOW_SUPER\*(C'\fR will treat all above-Unicode code points, including these, as malformations. (Note that the Unicode standard considers anything above 0x10FFFF to be illegal, but there are standards predating it that allow up to 0x7FFF_FFFF (2**31 \-1)) .Sp A somewhat misleadingly named synonym for \f(CW\*(C`UNICODE_WARN_PERL_EXTENDED\*(C'\fR is retained for backward compatibility: \f(CW\*(C`UNICODE_WARN_ABOVE_31_BIT\*(C'\fR. Similarly, \&\f(CW\*(C`UNICODE_DISALLOW_ABOVE_31_BIT\*(C'\fR is usable instead of the more accurately named \&\f(CW\*(C`UNICODE_DISALLOW_PERL_EXTENDED\*(C'\fR. The names are misleading because on \s-1EBCDIC\s0 platforms,these flags can apply to code points that actually do fit in 31 bits. The new names accurately describe the situation in all cases. .Sp .Vb 1 \& U8* uvchr_to_utf8_flags(U8 *d, UV uv, UV flags) .Ve .IP "uvchr_to_utf8_flags_msgs" 8 .IX Xref "uvchr_to_utf8_flags_msgs" .IX Item "uvchr_to_utf8_flags_msgs" \&\s-1NOTE:\s0 this function is experimental and may change or be removed without notice. .Sp \&\s-1THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED CIRCUMSTANCES.\s0 .Sp Most code should use \f(CW\*(C`"uvchr_to_utf8_flags"()\*(C'\fR rather than call this directly. .Sp This function is for code that wants any warning and/or error messages to be returned to the caller rather than be displayed. All messages that would have been displayed if all lexical warnings are enabled will be returned. .Sp It is just like \f(CW"uvchr_to_utf8_flags"\fR but it takes an extra parameter placed after all the others, \f(CW\*(C`msgs\*(C'\fR. If this parameter is 0, this function behaves identically to \f(CW"uvchr_to_utf8_flags"\fR. Otherwise, \f(CW\*(C`msgs\*(C'\fR should be a pointer to an \f(CW\*(C`HV *\*(C'\fR variable, in which this function creates a new \s-1HV\s0 to contain any appropriate messages. The hash has three key-value pairs, as follows: .RS 8 .ie n .IP """text""" 4 .el .IP "\f(CWtext\fR" 4 .IX Item "text" The text of the message as a \f(CW\*(C`SVpv\*(C'\fR. .ie n .IP """warn_categories""" 4 .el .IP "\f(CWwarn_categories\fR" 4 .IX Item "warn_categories" The warning category (or categories) packed into a \f(CW\*(C`SVuv\*(C'\fR. .ie n .IP """flag""" 4 .el .IP "\f(CWflag\fR" 4 .IX Item "flag" A single flag bit associated with this message, in a \f(CW\*(C`SVuv\*(C'\fR. The bit corresponds to some bit in the \f(CW*errors\fR return value, such as \f(CW\*(C`UNICODE_GOT_SURROGATE\*(C'\fR. .RE .RS 8 .Sp It's important to note that specifying this parameter as non-null will cause any warnings this function would otherwise generate to be suppressed, and instead be placed in \f(CW*msgs\fR. The caller can check the lexical warnings state (or not) when choosing what to do with the returned messages. .Sp The caller, of course, is responsible for freeing any returned \s-1HV.\s0 .Sp .Vb 2 \& U8* uvchr_to_utf8_flags_msgs(U8 *d, UV uv, UV flags, \& HV ** msgs) .Ve .RE .ie n .SH "Variables created by ""xsubpp"" and ""xsubpp"" internal functions" .el .SH "Variables created by \f(CWxsubpp\fP and \f(CWxsubpp\fP internal functions" .IX Header "Variables created by xsubpp and xsubpp internal functions" .IP "newXSproto" 8 .IX Xref "newXSproto" .IX Item "newXSproto" Used by \f(CW\*(C`xsubpp\*(C'\fR to hook up XSUBs as Perl subs. Adds Perl prototypes to the subs. .IP "\s-1XS_APIVERSION_BOOTCHECK\s0" 8 .IX Xref "XS_APIVERSION_BOOTCHECK" .IX Item "XS_APIVERSION_BOOTCHECK" Macro to verify that the perl api version an \s-1XS\s0 module has been compiled against matches the api version of the perl interpreter it's being loaded into. .Sp .Vb 1 \& XS_APIVERSION_BOOTCHECK; .Ve .IP "\s-1XS_VERSION\s0" 8 .IX Xref "XS_VERSION" .IX Item "XS_VERSION" The version identifier for an \s-1XS\s0 module. This is usually handled automatically by \f(CW\*(C`ExtUtils::MakeMaker\*(C'\fR. See \&\f(CW"XS_VERSION_BOOTCHECK"\fR. .IP "\s-1XS_VERSION_BOOTCHECK\s0" 8 .IX Xref "XS_VERSION_BOOTCHECK" .IX Item "XS_VERSION_BOOTCHECK" Macro to verify that a \s-1PM\s0 module's \f(CW$VERSION\fR variable matches the \s-1XS\s0 module's \f(CW\*(C`XS_VERSION\*(C'\fR variable. This is usually handled automatically by \&\f(CW\*(C`xsubpp\*(C'\fR. See \*(L"The \s-1VERSIONCHECK:\s0 Keyword\*(R" in perlxs. .Sp .Vb 1 \& XS_VERSION_BOOTCHECK; .Ve .SH "Warning and Dieing" .IX Header "Warning and Dieing" In all these calls, the \f(CW\*(C`U32 w\f(CIn\f(CW\*(C'\fR parameters are warning category constants. You can see the ones currently available in \&\*(L"Category Hierarchy\*(R" in warnings, just capitalize all letters in the names and prefix them by \f(CW\*(C`WARN_\*(C'\fR. So, for example, the category \f(CW\*(C`void\*(C'\fR used in a perl program becomes \f(CW\*(C`WARN_VOID\*(C'\fR when used in \s-1XS\s0 code and passed to one of the calls below. .IP "ckWARN" 8 .IX Xref "ckWARN" .IX Item "ckWARN" Returns a boolean as to whether or not warnings are enabled for the warning category \f(CW\*(C`w\*(C'\fR. If the category is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR, instead use the \*(L"ckWARN_d\*(R" macro. .Sp .Vb 1 \& bool ckWARN(U32 w) .Ve .IP "ckWARN2" 8 .IX Xref "ckWARN2" .IX Item "ckWARN2" Like \f(CW"ckWARN"\fR, but takes two warnings categories as input, and returns \&\s-1TRUE\s0 if either is enabled. If either category is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR, instead use the \*(L"ckWARN2_d\*(R" macro. The categories must be completely independent, one may not be subclassed from the other. .Sp .Vb 1 \& bool ckWARN2(U32 w1, U32 w2) .Ve .IP "ckWARN3" 8 .IX Xref "ckWARN3" .IX Item "ckWARN3" Like \f(CW"ckWARN2"\fR, but takes three warnings categories as input, and returns \&\s-1TRUE\s0 if any is enabled. If any of the categories is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR, instead use the \*(L"ckWARN3_d\*(R" macro. The categories must be completely independent, one may not be subclassed from any other. .Sp .Vb 1 \& bool ckWARN3(U32 w1, U32 w2, U32 w3) .Ve .IP "ckWARN4" 8 .IX Xref "ckWARN4" .IX Item "ckWARN4" Like \f(CW"ckWARN3"\fR, but takes four warnings categories as input, and returns \&\s-1TRUE\s0 if any is enabled. If any of the categories is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR, instead use the \*(L"ckWARN4_d\*(R" macro. The categories must be completely independent, one may not be subclassed from any other. .Sp .Vb 1 \& bool ckWARN4(U32 w1, U32 w2, U32 w3, U32 w4) .Ve .IP "ckWARN_d" 8 .IX Xref "ckWARN_d" .IX Item "ckWARN_d" Like \f(CW"ckWARN"\fR, but for use if and only if the warning category is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR. .Sp .Vb 1 \& bool ckWARN_d(U32 w) .Ve .IP "ckWARN2_d" 8 .IX Xref "ckWARN2_d" .IX Item "ckWARN2_d" Like \f(CW"ckWARN2"\fR, but for use if and only if either warning category is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR. .Sp .Vb 1 \& bool ckWARN2_d(U32 w1, U32 w2) .Ve .IP "ckWARN3_d" 8 .IX Xref "ckWARN3_d" .IX Item "ckWARN3_d" Like \f(CW"ckWARN3"\fR, but for use if and only if any of the warning categories is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR. .Sp .Vb 1 \& bool ckWARN3_d(U32 w1, U32 w2, U32 w3) .Ve .IP "ckWARN4_d" 8 .IX Xref "ckWARN4_d" .IX Item "ckWARN4_d" Like \f(CW"ckWARN4"\fR, but for use if and only if any of the warning categories is by default enabled even if not within the scope of \f(CW\*(C`use warnings\*(C'\fR. .Sp .Vb 1 \& bool ckWARN4_d(U32 w1, U32 w2, U32 w3, U32 w4) .Ve .IP "\s-1CLEAR_ERRSV\s0" 8 .IX Xref "CLEAR_ERRSV" .IX Item "CLEAR_ERRSV" Clear the contents of \f(CW$@\fR, setting it to the empty string. .Sp This replaces any read-only \s-1SV\s0 with a fresh \s-1SV\s0 and removes any magic. .Sp .Vb 1 \& void CLEAR_ERRSV() .Ve .IP "croak" 8 .IX Xref "croak" .IX Item "croak" This is an \s-1XS\s0 interface to Perl's \f(CW\*(C`die\*(C'\fR function. .Sp Take a sprintf-style format pattern and argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for \*(L"mess_sv\*(R". .Sp The error message will be used as an exception, by default returning control to the nearest enclosing \f(CW\*(C`eval\*(C'\fR, but subject to modification by a \f(CW$SIG{_\|_DIE_\|_}\fR handler. In any case, the \f(CW\*(C`croak\*(C'\fR function never returns normally. .Sp For historical reasons, if \f(CW\*(C`pat\*(C'\fR is null then the contents of \f(CW\*(C`ERRSV\*(C'\fR (\f(CW$@\fR) 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 \s-1SV\s0 yourself, it is preferable to use the \*(L"croak_sv\*(R" function, which does not involve clobbering \f(CW\*(C`ERRSV\*(C'\fR. .Sp .Vb 1 \& void croak(const char* pat, ...) .Ve .IP "croak_no_modify" 8 .IX Xref "croak_no_modify" .IX Item "croak_no_modify" Exactly equivalent to \f(CW\*(C`Perl_croak(aTHX_ "%s", PL_no_modify)\*(C'\fR, but generates terser object code than using \f(CW\*(C`Perl_croak\*(C'\fR. Less code used on exception code paths reduces \s-1CPU\s0 cache pressure. .Sp .Vb 1 \& void croak_no_modify() .Ve .IP "croak_sv" 8 .IX Xref "croak_sv" .IX Item "croak_sv" This is an \s-1XS\s0 interface to Perl's \f(CW\*(C`die\*(C'\fR function. .Sp \&\f(CW\*(C`baseex\*(C'\fR is the error message or object. If it is a reference, it will be used as-is. Otherwise it is used as a string, and if it does not end with a newline then it will be extended with some indication of the current location in the code, as described for \*(L"mess_sv\*(R". .Sp The error message or object will be used as an exception, by default returning control to the nearest enclosing \f(CW\*(C`eval\*(C'\fR, but subject to modification by a \f(CW$SIG{_\|_DIE_\|_}\fR handler. In any case, the \f(CW\*(C`croak_sv\*(C'\fR function never returns normally. .Sp To die with a simple string message, the \*(L"croak\*(R" function may be more convenient. .Sp .Vb 1 \& void croak_sv(SV *baseex) .Ve .IP "die" 8 .IX Xref "die" .IX Item "die" Behaves the same as \*(L"croak\*(R", except for the return type. It should be used only where the \f(CW\*(C`OP *\*(C'\fR return type is required. The function never actually returns. .Sp .Vb 1 \& OP* die(const char* pat, ...) .Ve .IP "die_sv" 8 .IX Xref "die_sv" .IX Item "die_sv" Behaves the same as \*(L"croak_sv\*(R", except for the return type. It should be used only where the \f(CW\*(C`OP *\*(C'\fR return type is required. The function never actually returns. .Sp .Vb 1 \& OP* die_sv(SV *baseex) .Ve .IP "\s-1ERRSV\s0" 8 .IX Xref "ERRSV" .IX Item "ERRSV" Returns the \s-1SV\s0 for \f(CW$@\fR, creating it if needed. .Sp .Vb 1 \& SV * ERRSV .Ve .IP "my_setenv" 8 .IX Xref "my_setenv" .IX Item "my_setenv" A wrapper for the C library \fBsetenv\fR\|(3). Don't use the latter, as the perl version has desirable safeguards .Sp .Vb 1 \& void my_setenv(const char* nam, const char* val) .Ve .IP "rsignal" 8 .IX Xref "rsignal" .IX Item "rsignal" A wrapper for the C library \fBsignal\fR\|(2). Don't use the latter, as the Perl version knows things that interact with the rest of the perl interpreter. .Sp .Vb 1 \& Sighandler_t rsignal(int i, Sighandler_t t) .Ve .IP "\s-1SANE_ERRSV\s0" 8 .IX Xref "SANE_ERRSV" .IX Item "SANE_ERRSV" Clean up \s-1ERRSV\s0 so we can safely set it. .Sp This replaces any read-only \s-1SV\s0 with a fresh writable copy and removes any magic. .Sp .Vb 1 \& void SANE_ERRSV() .Ve .IP "vcroak" 8 .IX Xref "vcroak" .IX Item "vcroak" This is an \s-1XS\s0 interface to Perl's \f(CW\*(C`die\*(C'\fR function. .Sp \&\f(CW\*(C`pat\*(C'\fR and \f(CW\*(C`args\*(C'\fR are a sprintf-style format pattern and encapsulated argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for \&\*(L"mess_sv\*(R". .Sp The error message will be used as an exception, by default returning control to the nearest enclosing \f(CW\*(C`eval\*(C'\fR, but subject to modification by a \f(CW$SIG{_\|_DIE_\|_}\fR handler. In any case, the \f(CW\*(C`croak\*(C'\fR function never returns normally. .Sp For historical reasons, if \f(CW\*(C`pat\*(C'\fR is null then the contents of \f(CW\*(C`ERRSV\*(C'\fR (\f(CW$@\fR) 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 \s-1SV\s0 yourself, it is preferable to use the \*(L"croak_sv\*(R" function, which does not involve clobbering \f(CW\*(C`ERRSV\*(C'\fR. .Sp .Vb 1 \& void vcroak(const char* pat, va_list* args) .Ve .IP "vwarn" 8 .IX Xref "vwarn" .IX Item "vwarn" This is an \s-1XS\s0 interface to Perl's \f(CW\*(C`warn\*(C'\fR function. .Sp \&\f(CW\*(C`pat\*(C'\fR and \f(CW\*(C`args\*(C'\fR are a sprintf-style format pattern and encapsulated argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for \&\*(L"mess_sv\*(R". .Sp The error message or object will by default be written to standard error, but this is subject to modification by a \f(CW$SIG{_\|_WARN_\|_}\fR handler. .Sp Unlike with \*(L"vcroak\*(R", \f(CW\*(C`pat\*(C'\fR is not permitted to be null. .Sp .Vb 1 \& void vwarn(const char* pat, va_list* args) .Ve .IP "warn" 8 .IX Xref "warn" .IX Item "warn" This is an \s-1XS\s0 interface to Perl's \f(CW\*(C`warn\*(C'\fR function. .Sp Take a sprintf-style format pattern and argument list. These are used to generate a string message. If the message does not end with a newline, then it will be extended with some indication of the current location in the code, as described for \*(L"mess_sv\*(R". .Sp The error message or object will by default be written to standard error, but this is subject to modification by a \f(CW$SIG{_\|_WARN_\|_}\fR handler. .Sp Unlike with \*(L"croak\*(R", \f(CW\*(C`pat\*(C'\fR is not permitted to be null. .Sp .Vb 1 \& void warn(const char* pat, ...) .Ve .IP "warn_sv" 8 .IX Xref "warn_sv" .IX Item "warn_sv" This is an \s-1XS\s0 interface to Perl's \f(CW\*(C`warn\*(C'\fR function. .Sp \&\f(CW\*(C`baseex\*(C'\fR is the error message or object. If it is a reference, it will be used as-is. Otherwise it is used as a string, and if it does not end with a newline then it will be extended with some indication of the current location in the code, as described for \*(L"mess_sv\*(R". .Sp The error message or object will by default be written to standard error, but this is subject to modification by a \f(CW$SIG{_\|_WARN_\|_}\fR handler. .Sp To warn with a simple string message, the \*(L"warn\*(R" function may be more convenient. .Sp .Vb 1 \& void warn_sv(SV *baseex) .Ve .SH "Undocumented functions" .IX Header "Undocumented functions" The following functions have been flagged as part of the public \s-1API,\s0 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 \s-1NOT\s0 be used under any circumstances. .PP If you feel you need to use one of these functions, first send email to perl5\-porters@perl.org . It may be that there is a good reason for the function not being documented, and it should be removed from this list; or it may just be that no one has gotten around to documenting it. In the latter case, you will be asked to submit a patch to document the function. Once your patch is accepted, it will indicate that the interface is stable (unless it is explicitly marked otherwise) and usable by you. .IP "CvDEPTH" 4 .IX Xref "CvDEPTH" .IX Item "CvDEPTH" .PD 0 .IP "CvGV" 4 .IX Xref "CvGV" .IX Item "CvGV" .IP "GetVars" 4 .IX Xref "GetVars" .IX Item "GetVars" .IP "Gv_AMupdate" 4 .IX Xref "Gv_AMupdate" .IX Item "Gv_AMupdate" .IP "PerlIO_close" 4 .IX Xref "PerlIO_close" .IX Item "PerlIO_close" .IP "PerlIO_context_layers" 4 .IX Xref "PerlIO_context_layers" .IX Item "PerlIO_context_layers" .IP "PerlIO_error" 4 .IX Xref "PerlIO_error" .IX Item "PerlIO_error" .IP "PerlIO_fill" 4 .IX Xref "PerlIO_fill" .IX Item "PerlIO_fill" .IP "PerlIO_flush" 4 .IX Xref "PerlIO_flush" .IX Item "PerlIO_flush" .IP "PerlIO_get_bufsiz" 4 .IX Xref "PerlIO_get_bufsiz" .IX Item "PerlIO_get_bufsiz" .IP "PerlIO_get_ptr" 4 .IX Xref "PerlIO_get_ptr" .IX Item "PerlIO_get_ptr" .IP "PerlIO_read" 4 .IX Xref "PerlIO_read" .IX Item "PerlIO_read" .IP "PerlIO_seek" 4 .IX Xref "PerlIO_seek" .IX Item "PerlIO_seek" .IP "PerlIO_set_cnt" 4 .IX Xref "PerlIO_set_cnt" .IX Item "PerlIO_set_cnt" .IP "PerlIO_setlinebuf" 4 .IX Xref "PerlIO_setlinebuf" .IX Item "PerlIO_setlinebuf" .IP "PerlIO_stdout" 4 .IX Xref "PerlIO_stdout" .IX Item "PerlIO_stdout" .IP "PerlIO_unread" 4 .IX Xref "PerlIO_unread" .IX Item "PerlIO_unread" .IP "SvAMAGIC_off" 4 .IX Xref "SvAMAGIC_off" .IX Item "SvAMAGIC_off" .IP "SvAMAGIC_on" 4 .IX Xref "SvAMAGIC_on" .IX Item "SvAMAGIC_on" .IP "amagic_call" 4 .IX Xref "amagic_call" .IX Item "amagic_call" .IP "amagic_deref_call" 4 .IX Xref "amagic_deref_call" .IX Item "amagic_deref_call" .IP "any_dup" 4 .IX Xref "any_dup" .IX Item "any_dup" .IP "atfork_lock" 4 .IX Xref "atfork_lock" .IX Item "atfork_lock" .IP "atfork_unlock" 4 .IX Xref "atfork_unlock" .IX Item "atfork_unlock" .IP "av_arylen_p" 4 .IX Xref "av_arylen_p" .IX Item "av_arylen_p" .IP "av_iter_p" 4 .IX Xref "av_iter_p" .IX Item "av_iter_p" .IP "block_gimme" 4 .IX Xref "block_gimme" .IX Item "block_gimme" .IP "call_atexit" 4 .IX Xref "call_atexit" .IX Item "call_atexit" .IP "call_list" 4 .IX Xref "call_list" .IX Item "call_list" .IP "calloc" 4 .IX Xref "calloc" .IX Item "calloc" .IP "cast_i32" 4 .IX Xref "cast_i32" .IX Item "cast_i32" .IP "cast_iv" 4 .IX Xref "cast_iv" .IX Item "cast_iv" .IP "cast_ulong" 4 .IX Xref "cast_ulong" .IX Item "cast_ulong" .IP "cast_uv" 4 .IX Xref "cast_uv" .IX Item "cast_uv" .IP "ck_warner" 4 .IX Xref "ck_warner" .IX Item "ck_warner" .IP "ck_warner_d" 4 .IX Xref "ck_warner_d" .IX Item "ck_warner_d" .IP "ckwarn" 4 .IX Xref "ckwarn" .IX Item "ckwarn" .IP "ckwarn_d" 4 .IX Xref "ckwarn_d" .IX Item "ckwarn_d" .IP "clear_defarray" 4 .IX Xref "clear_defarray" .IX Item "clear_defarray" .IP "clone_params_del" 4 .IX Xref "clone_params_del" .IX Item "clone_params_del" .IP "clone_params_new" 4 .IX Xref "clone_params_new" .IX Item "clone_params_new" .IP "croak_nocontext" 4 .IX Xref "croak_nocontext" .IX Item "croak_nocontext" .IP "csighandler" 4 .IX Xref "csighandler" .IX Item "csighandler" .IP "csighandler1" 4 .IX Xref "csighandler1" .IX Item "csighandler1" .IP "csighandler3" 4 .IX Xref "csighandler3" .IX Item "csighandler3" .IP "cx_dump" 4 .IX Xref "cx_dump" .IX Item "cx_dump" .IP "cx_dup" 4 .IX Xref "cx_dup" .IX Item "cx_dup" .IP "cxinc" 4 .IX Xref "cxinc" .IX Item "cxinc" .IP "deb" 4 .IX Xref "deb" .IX Item "deb" .IP "deb_nocontext" 4 .IX Xref "deb_nocontext" .IX Item "deb_nocontext" .IP "debop" 4 .IX Xref "debop" .IX Item "debop" .IP "debprofdump" 4 .IX Xref "debprofdump" .IX Item "debprofdump" .IP "debstack" 4 .IX Xref "debstack" .IX Item "debstack" .IP "debstackptrs" 4 .IX Xref "debstackptrs" .IX Item "debstackptrs" .IP "delimcpy" 4 .IX Xref "delimcpy" .IX Item "delimcpy" .IP "despatch_signals" 4 .IX Xref "despatch_signals" .IX Item "despatch_signals" .IP "die_nocontext" 4 .IX Xref "die_nocontext" .IX Item "die_nocontext" .IP "dirp_dup" 4 .IX Xref "dirp_dup" .IX Item "dirp_dup" .IP "do_aspawn" 4 .IX Xref "do_aspawn" .IX Item "do_aspawn" .IP "do_close" 4 .IX Xref "do_close" .IX Item "do_close" .IP "do_gv_dump" 4 .IX Xref "do_gv_dump" .IX Item "do_gv_dump" .IP "do_gvgv_dump" 4 .IX Xref "do_gvgv_dump" .IX Item "do_gvgv_dump" .IP "do_hv_dump" 4 .IX Xref "do_hv_dump" .IX Item "do_hv_dump" .IP "do_join" 4 .IX Xref "do_join" .IX Item "do_join" .IP "do_magic_dump" 4 .IX Xref "do_magic_dump" .IX Item "do_magic_dump" .IP "do_op_dump" 4 .IX Xref "do_op_dump" .IX Item "do_op_dump" .IP "do_open" 4 .IX Xref "do_open" .IX Item "do_open" .IP "do_openn" 4 .IX Xref "do_openn" .IX Item "do_openn" .IP "do_pmop_dump" 4 .IX Xref "do_pmop_dump" .IX Item "do_pmop_dump" .IP "do_spawn" 4 .IX Xref "do_spawn" .IX Item "do_spawn" .IP "do_spawn_nowait" 4 .IX Xref "do_spawn_nowait" .IX Item "do_spawn_nowait" .IP "do_sprintf" 4 .IX Xref "do_sprintf" .IX Item "do_sprintf" .IP "do_sv_dump" 4 .IX Xref "do_sv_dump" .IX Item "do_sv_dump" .IP "doing_taint" 4 .IX Xref "doing_taint" .IX Item "doing_taint" .IP "doref" 4 .IX Xref "doref" .IX Item "doref" .IP "dounwind" 4 .IX Xref "dounwind" .IX Item "dounwind" .IP "dowantarray" 4 .IX Xref "dowantarray" .IX Item "dowantarray" .IP "dump_eval" 4 .IX Xref "dump_eval" .IX Item "dump_eval" .IP "dump_form" 4 .IX Xref "dump_form" .IX Item "dump_form" .IP "dump_indent" 4 .IX Xref "dump_indent" .IX Item "dump_indent" .IP "dump_mstats" 4 .IX Xref "dump_mstats" .IX Item "dump_mstats" .IP "dump_sub" 4 .IX Xref "dump_sub" .IX Item "dump_sub" .IP "dump_vindent" 4 .IX Xref "dump_vindent" .IX Item "dump_vindent" .IP "filter_del" 4 .IX Xref "filter_del" .IX Item "filter_del" .IP "filter_read" 4 .IX Xref "filter_read" .IX Item "filter_read" .IP "foldEQ_latin1" 4 .IX Xref "foldEQ_latin1" .IX Item "foldEQ_latin1" .IP "form_nocontext" 4 .IX Xref "form_nocontext" .IX Item "form_nocontext" .IP "fp_dup" 4 .IX Xref "fp_dup" .IX Item "fp_dup" .IP "free_global_struct" 4 .IX Xref "free_global_struct" .IX Item "free_global_struct" .IP "free_tmps" 4 .IX Xref "free_tmps" .IX Item "free_tmps" .IP "get_context" 4 .IX Xref "get_context" .IX Item "get_context" .IP "get_mstats" 4 .IX Xref "get_mstats" .IX Item "get_mstats" .IP "get_op_descs" 4 .IX Xref "get_op_descs" .IX Item "get_op_descs" .IP "get_op_names" 4 .IX Xref "get_op_names" .IX Item "get_op_names" .IP "get_ppaddr" 4 .IX Xref "get_ppaddr" .IX Item "get_ppaddr" .IP "get_vtbl" 4 .IX Xref "get_vtbl" .IX Item "get_vtbl" .IP "gp_dup" 4 .IX Xref "gp_dup" .IX Item "gp_dup" .IP "gp_free" 4 .IX Xref "gp_free" .IX Item "gp_free" .IP "gp_ref" 4 .IX Xref "gp_ref" .IX Item "gp_ref" .IP "gv_AVadd" 4 .IX Xref "gv_AVadd" .IX Item "gv_AVadd" .IP "gv_HVadd" 4 .IX Xref "gv_HVadd" .IX Item "gv_HVadd" .IP "gv_IOadd" 4 .IX Xref "gv_IOadd" .IX Item "gv_IOadd" .IP "gv_SVadd" 4 .IX Xref "gv_SVadd" .IX Item "gv_SVadd" .IP "gv_add_by_type" 4 .IX Xref "gv_add_by_type" .IX Item "gv_add_by_type" .IP "gv_autoload4" 4 .IX Xref "gv_autoload4" .IX Item "gv_autoload4" .IP "gv_autoload_pv" 4 .IX Xref "gv_autoload_pv" .IX Item "gv_autoload_pv" .IP "gv_autoload_pvn" 4 .IX Xref "gv_autoload_pvn" .IX Item "gv_autoload_pvn" .IP "gv_autoload_sv" 4 .IX Xref "gv_autoload_sv" .IX Item "gv_autoload_sv" .IP "gv_check" 4 .IX Xref "gv_check" .IX Item "gv_check" .IP "gv_dump" 4 .IX Xref "gv_dump" .IX Item "gv_dump" .IP "gv_efullname3" 4 .IX Xref "gv_efullname3" .IX Item "gv_efullname3" .IP "gv_efullname4" 4 .IX Xref "gv_efullname4" .IX Item "gv_efullname4" .IP "gv_fetchfile" 4 .IX Xref "gv_fetchfile" .IX Item "gv_fetchfile" .IP "gv_fetchfile_flags" 4 .IX Xref "gv_fetchfile_flags" .IX Item "gv_fetchfile_flags" .IP "gv_fetchpv" 4 .IX Xref "gv_fetchpv" .IX Item "gv_fetchpv" .IP "gv_fetchpvn_flags" 4 .IX Xref "gv_fetchpvn_flags" .IX Item "gv_fetchpvn_flags" .IP "gv_fetchsv" 4 .IX Xref "gv_fetchsv" .IX Item "gv_fetchsv" .IP "gv_fullname3" 4 .IX Xref "gv_fullname3" .IX Item "gv_fullname3" .IP "gv_fullname4" 4 .IX Xref "gv_fullname4" .IX Item "gv_fullname4" .IP "gv_handler" 4 .IX Xref "gv_handler" .IX Item "gv_handler" .IP "gv_name_set" 4 .IX Xref "gv_name_set" .IX Item "gv_name_set" .IP "he_dup" 4 .IX Xref "he_dup" .IX Item "he_dup" .IP "hek_dup" 4 .IX Xref "hek_dup" .IX Item "hek_dup" .IP "hv_common" 4 .IX Xref "hv_common" .IX Item "hv_common" .IP "hv_common_key_len" 4 .IX Xref "hv_common_key_len" .IX Item "hv_common_key_len" .IP "hv_delayfree_ent" 4 .IX Xref "hv_delayfree_ent" .IX Item "hv_delayfree_ent" .IP "hv_eiter_p" 4 .IX Xref "hv_eiter_p" .IX Item "hv_eiter_p" .IP "hv_eiter_set" 4 .IX Xref "hv_eiter_set" .IX Item "hv_eiter_set" .IP "hv_free_ent" 4 .IX Xref "hv_free_ent" .IX Item "hv_free_ent" .IP "hv_ksplit" 4 .IX Xref "hv_ksplit" .IX Item "hv_ksplit" .IP "hv_name_set" 4 .IX Xref "hv_name_set" .IX Item "hv_name_set" .IP "hv_placeholders_get" 4 .IX Xref "hv_placeholders_get" .IX Item "hv_placeholders_get" .IP "hv_placeholders_set" 4 .IX Xref "hv_placeholders_set" .IX Item "hv_placeholders_set" .IP "hv_rand_set" 4 .IX Xref "hv_rand_set" .IX Item "hv_rand_set" .IP "hv_riter_p" 4 .IX Xref "hv_riter_p" .IX Item "hv_riter_p" .IP "hv_riter_set" 4 .IX Xref "hv_riter_set" .IX Item "hv_riter_set" .IP "ibcmp_utf8" 4 .IX Xref "ibcmp_utf8" .IX Item "ibcmp_utf8" .IP "init_global_struct" 4 .IX Xref "init_global_struct" .IX Item "init_global_struct" .IP "init_stacks" 4 .IX Xref "init_stacks" .IX Item "init_stacks" .IP "init_tm" 4 .IX Xref "init_tm" .IX Item "init_tm" .IP "is_lvalue_sub" 4 .IX Xref "is_lvalue_sub" .IX Item "is_lvalue_sub" .IP "leave_scope" 4 .IX Xref "leave_scope" .IX Item "leave_scope" .IP "load_module_nocontext" 4 .IX Xref "load_module_nocontext" .IX Item "load_module_nocontext" .IP "magic_dump" 4 .IX Xref "magic_dump" .IX Item "magic_dump" .IP "markstack_grow" 4 .IX Xref "markstack_grow" .IX Item "markstack_grow" .IP "mess_nocontext" 4 .IX Xref "mess_nocontext" .IX Item "mess_nocontext" .IP "mfree" 4 .IX Xref "mfree" .IX Item "mfree" .IP "mg_dup" 4 .IX Xref "mg_dup" .IX Item "mg_dup" .IP "mg_size" 4 .IX Xref "mg_size" .IX Item "mg_size" .IP "mini_mktime" 4 .IX Xref "mini_mktime" .IX Item "mini_mktime" .IP "moreswitches" 4 .IX Xref "moreswitches" .IX Item "moreswitches" .IP "mro_get_from_name" 4 .IX Xref "mro_get_from_name" .IX Item "mro_get_from_name" .IP "mro_set_mro" 4 .IX Xref "mro_set_mro" .IX Item "mro_set_mro" .IP "mro_set_private_data" 4 .IX Xref "mro_set_private_data" .IX Item "mro_set_private_data" .IP "my_atof" 4 .IX Xref "my_atof" .IX Item "my_atof" .IP "my_chsize" 4 .IX Xref "my_chsize" .IX Item "my_chsize" .IP "my_cxt_index" 4 .IX Xref "my_cxt_index" .IX Item "my_cxt_index" .IP "my_cxt_init" 4 .IX Xref "my_cxt_init" .IX Item "my_cxt_init" .IP "my_dirfd" 4 .IX Xref "my_dirfd" .IX Item "my_dirfd" .IP "my_failure_exit" 4 .IX Xref "my_failure_exit" .IX Item "my_failure_exit" .IP "my_fflush_all" 4 .IX Xref "my_fflush_all" .IX Item "my_fflush_all" .IP "my_fork" 4 .IX Xref "my_fork" .IX Item "my_fork" .IP "my_lstat" 4 .IX Xref "my_lstat" .IX Item "my_lstat" .IP "my_pclose" 4 .IX Xref "my_pclose" .IX Item "my_pclose" .IP "my_popen" 4 .IX Xref "my_popen" .IX Item "my_popen" .IP "my_popen_list" 4 .IX Xref "my_popen_list" .IX Item "my_popen_list" .IP "my_socketpair" 4 .IX Xref "my_socketpair" .IX Item "my_socketpair" .IP "my_stat" 4 .IX Xref "my_stat" .IX Item "my_stat" .IP "my_strftime" 4 .IX Xref "my_strftime" .IX Item "my_strftime" .IP "newANONATTRSUB" 4 .IX Xref "newANONATTRSUB" .IX Item "newANONATTRSUB" .IP "newANONHASH" 4 .IX Xref "newANONHASH" .IX Item "newANONHASH" .IP "newANONLIST" 4 .IX Xref "newANONLIST" .IX Item "newANONLIST" .IP "newANONSUB" 4 .IX Xref "newANONSUB" .IX Item "newANONSUB" .IP "newATTRSUB" 4 .IX Xref "newATTRSUB" .IX Item "newATTRSUB" .IP "newAVREF" 4 .IX Xref "newAVREF" .IX Item "newAVREF" .IP "newCVREF" 4 .IX Xref "newCVREF" .IX Item "newCVREF" .IP "newFORM" 4 .IX Xref "newFORM" .IX Item "newFORM" .IP "newGVREF" 4 .IX Xref "newGVREF" .IX Item "newGVREF" .IP "newGVgen" 4 .IX Xref "newGVgen" .IX Item "newGVgen" .IP "newGVgen_flags" 4 .IX Xref "newGVgen_flags" .IX Item "newGVgen_flags" .IP "newHVREF" 4 .IX Xref "newHVREF" .IX Item "newHVREF" .IP "newHVhv" 4 .IX Xref "newHVhv" .IX Item "newHVhv" .IP "newIO" 4 .IX Xref "newIO" .IX Item "newIO" .IP "newMYSUB" 4 .IX Xref "newMYSUB" .IX Item "newMYSUB" .IP "newPROG" 4 .IX Xref "newPROG" .IX Item "newPROG" .IP "newRV" 4 .IX Xref "newRV" .IX Item "newRV" .IP "newSUB" 4 .IX Xref "newSUB" .IX Item "newSUB" .IP "newSVREF" 4 .IX Xref "newSVREF" .IX Item "newSVREF" .IP "newSVpvf_nocontext" 4 .IX Xref "newSVpvf_nocontext" .IX Item "newSVpvf_nocontext" .IP "newSVsv_flags" 4 .IX Xref "newSVsv_flags" .IX Item "newSVsv_flags" .IP "new_stackinfo" 4 .IX Xref "new_stackinfo" .IX Item "new_stackinfo" .IP "op_refcnt_lock" 4 .IX Xref "op_refcnt_lock" .IX Item "op_refcnt_lock" .IP "op_refcnt_unlock" 4 .IX Xref "op_refcnt_unlock" .IX Item "op_refcnt_unlock" .IP "parser_dup" 4 .IX Xref "parser_dup" .IX Item "parser_dup" .IP "perl_alloc_using" 4 .IX Xref "perl_alloc_using" .IX Item "perl_alloc_using" .IP "perl_clone_using" 4 .IX Xref "perl_clone_using" .IX Item "perl_clone_using" .IP "perly_sighandler" 4 .IX Xref "perly_sighandler" .IX Item "perly_sighandler" .IP "pmop_dump" 4 .IX Xref "pmop_dump" .IX Item "pmop_dump" .IP "pop_scope" 4 .IX Xref "pop_scope" .IX Item "pop_scope" .IP "pregcomp" 4 .IX Xref "pregcomp" .IX Item "pregcomp" .IP "pregexec" 4 .IX Xref "pregexec" .IX Item "pregexec" .IP "pregfree" 4 .IX Xref "pregfree" .IX Item "pregfree" .IP "pregfree2" 4 .IX Xref "pregfree2" .IX Item "pregfree2" .IP "ptr_table_fetch" 4 .IX Xref "ptr_table_fetch" .IX Item "ptr_table_fetch" .IP "ptr_table_free" 4 .IX Xref "ptr_table_free" .IX Item "ptr_table_free" .IP "ptr_table_new" 4 .IX Xref "ptr_table_new" .IX Item "ptr_table_new" .IP "ptr_table_split" 4 .IX Xref "ptr_table_split" .IX Item "ptr_table_split" .IP "ptr_table_store" 4 .IX Xref "ptr_table_store" .IX Item "ptr_table_store" .IP "push_scope" 4 .IX Xref "push_scope" .IX Item "push_scope" .IP "re_compile" 4 .IX Xref "re_compile" .IX Item "re_compile" .IP "re_dup_guts" 4 .IX Xref "re_dup_guts" .IX Item "re_dup_guts" .IP "reentrant_free" 4 .IX Xref "reentrant_free" .IX Item "reentrant_free" .IP "reentrant_init" 4 .IX Xref "reentrant_init" .IX Item "reentrant_init" .IP "reentrant_retry" 4 .IX Xref "reentrant_retry" .IX Item "reentrant_retry" .IP "reentrant_size" 4 .IX Xref "reentrant_size" .IX Item "reentrant_size" .IP "ref" 4 .IX Xref "ref" .IX Item "ref" .IP "reg_named_buff_all" 4 .IX Xref "reg_named_buff_all" .IX Item "reg_named_buff_all" .IP "reg_named_buff_exists" 4 .IX Xref "reg_named_buff_exists" .IX Item "reg_named_buff_exists" .IP "reg_named_buff_fetch" 4 .IX Xref "reg_named_buff_fetch" .IX Item "reg_named_buff_fetch" .IP "reg_named_buff_firstkey" 4 .IX Xref "reg_named_buff_firstkey" .IX Item "reg_named_buff_firstkey" .IP "reg_named_buff_nextkey" 4 .IX Xref "reg_named_buff_nextkey" .IX Item "reg_named_buff_nextkey" .IP "reg_named_buff_scalar" 4 .IX Xref "reg_named_buff_scalar" .IX Item "reg_named_buff_scalar" .IP "regdump" 4 .IX Xref "regdump" .IX Item "regdump" .IP "regdupe_internal" 4 .IX Xref "regdupe_internal" .IX Item "regdupe_internal" .IP "regexec_flags" 4 .IX Xref "regexec_flags" .IX Item "regexec_flags" .IP "regfree_internal" 4 .IX Xref "regfree_internal" .IX Item "regfree_internal" .IP "reginitcolors" 4 .IX Xref "reginitcolors" .IX Item "reginitcolors" .IP "regnext" 4 .IX Xref "regnext" .IX Item "regnext" .IP "repeatcpy" 4 .IX Xref "repeatcpy" .IX Item "repeatcpy" .IP "rsignal_state" 4 .IX Xref "rsignal_state" .IX Item "rsignal_state" .IP "runops_debug" 4 .IX Xref "runops_debug" .IX Item "runops_debug" .IP "runops_standard" 4 .IX Xref "runops_standard" .IX Item "runops_standard" .IP "rvpv_dup" 4 .IX Xref "rvpv_dup" .IX Item "rvpv_dup" .IP "safesyscalloc" 4 .IX Xref "safesyscalloc" .IX Item "safesyscalloc" .IP "safesysfree" 4 .IX Xref "safesysfree" .IX Item "safesysfree" .IP "safesysmalloc" 4 .IX Xref "safesysmalloc" .IX Item "safesysmalloc" .IP "safesysrealloc" 4 .IX Xref "safesysrealloc" .IX Item "safesysrealloc" .IP "save_I16" 4 .IX Xref "save_I16" .IX Item "save_I16" .IP "save_I32" 4 .IX Xref "save_I32" .IX Item "save_I32" .IP "save_I8" 4 .IX Xref "save_I8" .IX Item "save_I8" .IP "save_adelete" 4 .IX Xref "save_adelete" .IX Item "save_adelete" .IP "save_aelem" 4 .IX Xref "save_aelem" .IX Item "save_aelem" .IP "save_aelem_flags" 4 .IX Xref "save_aelem_flags" .IX Item "save_aelem_flags" .IP "save_alloc" 4 .IX Xref "save_alloc" .IX Item "save_alloc" .IP "save_ary" 4 .IX Xref "save_ary" .IX Item "save_ary" .IP "save_bool" 4 .IX Xref "save_bool" .IX Item "save_bool" .IP "save_clearsv" 4 .IX Xref "save_clearsv" .IX Item "save_clearsv" .IP "save_delete" 4 .IX Xref "save_delete" .IX Item "save_delete" .IP "save_destructor" 4 .IX Xref "save_destructor" .IX Item "save_destructor" .IP "save_destructor_x" 4 .IX Xref "save_destructor_x" .IX Item "save_destructor_x" .IP "save_freeop" 4 .IX Xref "save_freeop" .IX Item "save_freeop" .IP "save_freepv" 4 .IX Xref "save_freepv" .IX Item "save_freepv" .IP "save_freesv" 4 .IX Xref "save_freesv" .IX Item "save_freesv" .IP "save_generic_pvref" 4 .IX Xref "save_generic_pvref" .IX Item "save_generic_pvref" .IP "save_generic_svref" 4 .IX Xref "save_generic_svref" .IX Item "save_generic_svref" .IP "save_hdelete" 4 .IX Xref "save_hdelete" .IX Item "save_hdelete" .IP "save_helem" 4 .IX Xref "save_helem" .IX Item "save_helem" .IP "save_helem_flags" 4 .IX Xref "save_helem_flags" .IX Item "save_helem_flags" .IP "save_hints" 4 .IX Xref "save_hints" .IX Item "save_hints" .IP "save_hptr" 4 .IX Xref "save_hptr" .IX Item "save_hptr" .IP "save_int" 4 .IX Xref "save_int" .IX Item "save_int" .IP "save_item" 4 .IX Xref "save_item" .IX Item "save_item" .IP "save_iv" 4 .IX Xref "save_iv" .IX Item "save_iv" .IP "save_mortalizesv" 4 .IX Xref "save_mortalizesv" .IX Item "save_mortalizesv" .IP "save_op" 4 .IX Xref "save_op" .IX Item "save_op" .IP "save_padsv_and_mortalize" 4 .IX Xref "save_padsv_and_mortalize" .IX Item "save_padsv_and_mortalize" .IP "save_pptr" 4 .IX Xref "save_pptr" .IX Item "save_pptr" .IP "save_pushi32ptr" 4 .IX Xref "save_pushi32ptr" .IX Item "save_pushi32ptr" .IP "save_pushptr" 4 .IX Xref "save_pushptr" .IX Item "save_pushptr" .IP "save_pushptrptr" 4 .IX Xref "save_pushptrptr" .IX Item "save_pushptrptr" .IP "save_re_context" 4 .IX Xref "save_re_context" .IX Item "save_re_context" .IP "save_set_svflags" 4 .IX Xref "save_set_svflags" .IX Item "save_set_svflags" .IP "save_shared_pvref" 4 .IX Xref "save_shared_pvref" .IX Item "save_shared_pvref" .IP "save_sptr" 4 .IX Xref "save_sptr" .IX Item "save_sptr" .IP "save_svref" 4 .IX Xref "save_svref" .IX Item "save_svref" .IP "save_vptr" 4 .IX Xref "save_vptr" .IX Item "save_vptr" .IP "savestack_grow" 4 .IX Xref "savestack_grow" .IX Item "savestack_grow" .IP "savestack_grow_cnt" 4 .IX Xref "savestack_grow_cnt" .IX Item "savestack_grow_cnt" .IP "scan_num" 4 .IX Xref "scan_num" .IX Item "scan_num" .IP "scan_vstring" 4 .IX Xref "scan_vstring" .IX Item "scan_vstring" .IP "seed" 4 .IX Xref "seed" .IX Item "seed" .IP "set_context" 4 .IX Xref "set_context" .IX Item "set_context" .IP "share_hek" 4 .IX Xref "share_hek" .IX Item "share_hek" .IP "si_dup" 4 .IX Xref "si_dup" .IX Item "si_dup" .IP "ss_dup" 4 .IX Xref "ss_dup" .IX Item "ss_dup" .IP "stack_grow" 4 .IX Xref "stack_grow" .IX Item "stack_grow" .IP "start_subparse" 4 .IX Xref "start_subparse" .IX Item "start_subparse" .IP "str_to_version" 4 .IX Xref "str_to_version" .IX Item "str_to_version" .IP "sv_2iv" 4 .IX Xref "sv_2iv" .IX Item "sv_2iv" .IP "sv_2pv" 4 .IX Xref "sv_2pv" .IX Item "sv_2pv" .IP "sv_2pvbyte_flags" 4 .IX Xref "sv_2pvbyte_flags" .IX Item "sv_2pvbyte_flags" .IP "sv_2pvutf8_flags" 4 .IX Xref "sv_2pvutf8_flags" .IX Item "sv_2pvutf8_flags" .IP "sv_2uv" 4 .IX Xref "sv_2uv" .IX Item "sv_2uv" .IP "sv_catpvf_mg_nocontext" 4 .IX Xref "sv_catpvf_mg_nocontext" .IX Item "sv_catpvf_mg_nocontext" .IP "sv_catpvf_nocontext" 4 .IX Xref "sv_catpvf_nocontext" .IX Item "sv_catpvf_nocontext" .IP "sv_dup" 4 .IX Xref "sv_dup" .IX Item "sv_dup" .IP "sv_dup_inc" 4 .IX Xref "sv_dup_inc" .IX Item "sv_dup_inc" .IP "sv_peek" 4 .IX Xref "sv_peek" .IX Item "sv_peek" .IP "sv_setpvf_mg_nocontext" 4 .IX Xref "sv_setpvf_mg_nocontext" .IX Item "sv_setpvf_mg_nocontext" .IP "sv_setpvf_nocontext" 4 .IX Xref "sv_setpvf_nocontext" .IX Item "sv_setpvf_nocontext" .IP "sys_init" 4 .IX Xref "sys_init" .IX Item "sys_init" .IP "sys_init3" 4 .IX Xref "sys_init3" .IX Item "sys_init3" .IP "sys_intern_clear" 4 .IX Xref "sys_intern_clear" .IX Item "sys_intern_clear" .IP "sys_intern_dup" 4 .IX Xref "sys_intern_dup" .IX Item "sys_intern_dup" .IP "sys_intern_init" 4 .IX Xref "sys_intern_init" .IX Item "sys_intern_init" .IP "sys_term" 4 .IX Xref "sys_term" .IX Item "sys_term" .IP "taint_env" 4 .IX Xref "taint_env" .IX Item "taint_env" .IP "taint_proper" 4 .IX Xref "taint_proper" .IX Item "taint_proper" .IP "unlnk" 4 .IX Xref "unlnk" .IX Item "unlnk" .IP "unsharepvn" 4 .IX Xref "unsharepvn" .IX Item "unsharepvn" .IP "vdeb" 4 .IX Xref "vdeb" .IX Item "vdeb" .IP "vform" 4 .IX Xref "vform" .IX Item "vform" .IP "vload_module" 4 .IX Xref "vload_module" .IX Item "vload_module" .IP "vnewSVpvf" 4 .IX Xref "vnewSVpvf" .IX Item "vnewSVpvf" .IP "vwarner" 4 .IX Xref "vwarner" .IX Item "vwarner" .IP "warn_nocontext" 4 .IX Xref "warn_nocontext" .IX Item "warn_nocontext" .IP "warner" 4 .IX Xref "warner" .IX Item "warner" .IP "warner_nocontext" 4 .IX Xref "warner_nocontext" .IX Item "warner_nocontext" .IP "whichsig" 4 .IX Xref "whichsig" .IX Item "whichsig" .IP "whichsig_pv" 4 .IX Xref "whichsig_pv" .IX Item "whichsig_pv" .IP "whichsig_pvn" 4 .IX Xref "whichsig_pvn" .IX Item "whichsig_pvn" .IP "whichsig_sv" 4 .IX Xref "whichsig_sv" .IX Item "whichsig_sv" .PD .SH "AUTHORS" .IX Header "AUTHORS" Until May 1997, this document was maintained by Jeff Okamoto . It is now maintained as part of Perl itself. .PP 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. .PP \&\s-1API\s0 Listing originally by Dean Roehrich . .PP Updated to be autogenerated from comments in the source by Benjamin Stuhl. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIconfig.h\fR perlapio perlcall perlclib perlfilter perlguts perlintern perlmroapi perlxs perlxstut warnings