.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.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. | will give a
.\" real vertical bar. \*(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-|\(bv\*(Tr
.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" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "PERLAPI 1"
.TH PERLAPI 1 "2002-11-24" "perl v5.8.0" "Perl Programmers Reference Guide"
.SH "NAME"
perlapi \- autogenerated documentation for the perl public API
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This file contains the documentation of the perl public \s-1API\s0 generated by
embed.pl, specifically a listing of functions, macros, flags, and variables
that may be used by extension writers. The interfaces of any functions that
are not listed here are subject to change without notice. For this reason,
blindly using functions listed in proto.h is to be avoided when writing
extensions.
.PP
Note that all Perl \s-1API\s0 global variables must be referenced with the \f(CW\*(C`PL_\*(C'\fR
prefix. Some macros are provided for compatibility with the older,
unadorned names, but this support may be disabled in a future release.
.PP
The listing is alphabetical, case insensitive.
.ie n .SH """Gimme"" Values"
.el .SH "``Gimme'' Values"
.IX Header "Gimme Values"
.IP "\s-1GIMME\s0" 8
.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 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.
.Sp
.Vb 1
\& U32 GIMME_V
.Ve
.IP "G_ARRAY" 8
.IX Item "G_ARRAY"
Used to indicate list context. See \f(CW\*(C`GIMME_V\*(C'\fR, \f(CW\*(C`GIMME\*(C'\fR and
perlcall.
.IP "G_DISCARD" 8
.IX Item "G_DISCARD"
Indicates that arguments returned from a callback should be discarded. See
perlcall.
.IP "G_EVAL" 8
.IX Item "G_EVAL"
Used to force a Perl \f(CW\*(C`eval\*(C'\fR wrapper around a callback. See
perlcall.
.IP "G_NOARGS" 8
.IX Item "G_NOARGS"
Indicates that no arguments are being sent to a callback. See
perlcall.
.IP "G_SCALAR" 8
.IX Item "G_SCALAR"
Used to indicate scalar context. See \f(CW\*(C`GIMME_V\*(C'\fR, \f(CW\*(C`GIMME\*(C'\fR, and
perlcall.
.IP "G_VOID" 8
.IX Item "G_VOID"
Used to indicate void context. See \f(CW\*(C`GIMME_V\*(C'\fR and perlcall.
.SH "Array Manipulation Functions"
.IX Header "Array Manipulation Functions"
.IP "AvFILL" 8
.IX Item "AvFILL"
Same as \f(CW\*(C`av_len()\*(C'\fR. Deprecated, use \f(CW\*(C`av_len()\*(C'\fR instead.
.Sp
.Vb 1
\& int AvFILL(AV* av)
.Ve
.IP "av_clear" 8
.IX Item "av_clear"
Clears an array, making it empty. Does not free the memory used by the
array itself.
.Sp
.Vb 1
\& void av_clear(AV* ar)
.Ve
.IP "av_delete" 8
.IX Item "av_delete"
Deletes the element indexed by \f(CW\*(C`key\*(C'\fR from the array. Returns the
deleted element. \f(CW\*(C`flags\*(C'\fR is currently ignored.
.Sp
.Vb 1
\& SV* av_delete(AV* ar, I32 key, I32 flags)
.Ve
.IP "av_exists" 8
.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&PL_sv_undef\fR.
.Sp
.Vb 1
\& bool av_exists(AV* ar, I32 key)
.Ve
.IP "av_extend" 8
.IX Item "av_extend"
Pre-extend an array. The \f(CW\*(C`key\*(C'\fR is the index to which the array should be
extended.
.Sp
.Vb 1
\& void av_extend(AV* ar, I32 key)
.Ve
.IP "av_fetch" 8
.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 \f(CW\*(C`lval\*(C'\fR is set then the fetch will be part of a store. 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
.Vb 1
\& SV** av_fetch(AV* ar, I32 key, I32 lval)
.Ve
.IP "av_fill" 8
.IX Item "av_fill"
Ensure than an array has a given number of elements, equivalent to
Perl's \f(CW\*(C`$#array = $fill;\*(C'\fR.
.Sp
.Vb 1
\& void av_fill(AV* ar, I32 fill)
.Ve
.IP "av_len" 8
.IX Item "av_len"
Returns the highest index in the array. Returns \-1 if the array is
empty.
.Sp
.Vb 1
\& I32 av_len(AV* ar)
.Ve
.IP "av_make" 8
.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 av_make. The new \s-1AV\s0
will have a reference count of 1.
.Sp
.Vb 1
\& AV* av_make(I32 size, SV** svp)
.Ve
.IP "av_pop" 8
.IX Item "av_pop"
Pops an \s-1SV\s0 off the end of the array. Returns \f(CW&PL_sv_undef\fR if the array
is empty.
.Sp
.Vb 1
\& SV* av_pop(AV* ar)
.Ve
.IP "av_push" 8
.IX Item "av_push"
Pushes an \s-1SV\s0 onto the end of the array. The array will grow automatically
to accommodate the addition.
.Sp
.Vb 1
\& void av_push(AV* ar, SV* val)
.Ve
.IP "av_shift" 8
.IX Item "av_shift"
Shifts an \s-1SV\s0 off the beginning of the array.
.Sp
.Vb 1
\& SV* av_shift(AV* ar)
.Ve
.IP "av_store" 8
.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 \s-1NULL\s0 if the operation failed or if the value did not
need to be actually stored within the array (as in the case of tied
arrays). Otherwise it can be dereferenced to get the original \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 \s-1NULL\s0.
.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* ar, I32 key, SV* val)
.Ve
.IP "av_undef" 8
.IX Item "av_undef"
Undefines the array. Frees the memory used by the array itself.
.Sp
.Vb 1
\& void av_undef(AV* ar)
.Ve
.IP "av_unshift" 8
.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. You
must then use \f(CW\*(C`av_store\*(C'\fR to assign values to these new elements.
.Sp
.Vb 1
\& void av_unshift(AV* ar, I32 num)
.Ve
.IP "get_av" 8
.IX Item "get_av"
Returns the \s-1AV\s0 of the specified Perl array. If \f(CW\*(C`create\*(C'\fR is set and the
Perl variable does not exist then it will be created. If \f(CW\*(C`create\*(C'\fR is not
set 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
\& AV* get_av(const char* name, I32 create)
.Ve
.IP "newAV" 8
.IX Item "newAV"
Creates a new \s-1AV\s0. The reference count is set to 1.
.Sp
.Vb 1
\& AV* newAV()
.Ve
.IP "Nullav" 8
.IX Item "Nullav"
Null \s-1AV\s0 pointer.
.IP "sortsv" 8
.IX Item "sortsv"
Sort an array. Here is an example:
.Sp
.Vb 1
\& sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
.Ve
.Sp
See lib/sort.pm for details about controlling the sorting algorithm.
.Sp
.Vb 1
\& void sortsv(SV ** array, size_t num_elts, SVCOMPARE_t cmp)
.Ve
.SH "Callback Functions"
.IX Header "Callback Functions"
.IP "call_argv" 8
.IX Item "call_argv"
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_argv(const char* sub_name, I32 flags, char** argv)
.Ve
.IP "call_method" 8
.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 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 Item "call_sv"
Performs a callback to the Perl sub whose name is in the \s-1SV\s0. See
perlcall.
.Sp
\&\s-1NOTE:\s0 the perl_ form of this function is deprecated.
.Sp
.Vb 1
\& I32 call_sv(SV* sv, I32 flags)
.Ve
.IP "\s-1ENTER\s0" 8
.IX Item "ENTER"
Opening bracket on a callback. See \f(CW\*(C`LEAVE\*(C'\fR and perlcall.
.Sp
.Vb 1
\& ENTER;
.Ve
.IP "eval_pv" 8
.IX Item "eval_pv"
Tells Perl to \f(CW\*(C`eval\*(C'\fR the given string 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 Item "eval_sv"
Tells Perl to \f(CW\*(C`eval\*(C'\fR the string in the \s-1SV\s0.
.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 Item "FREETMPS"
Closing bracket for temporaries on a callback. See \f(CW\*(C`SAVETMPS\*(C'\fR and
perlcall.
.Sp
.Vb 1
\& FREETMPS;
.Ve
.IP "\s-1LEAVE\s0" 8
.IX Item "LEAVE"
Closing bracket on a callback. See \f(CW\*(C`ENTER\*(C'\fR and perlcall.
.Sp
.Vb 1
\& LEAVE;
.Ve
.IP "\s-1SAVETMPS\s0" 8
.IX Item "SAVETMPS"
Opening bracket for temporaries on a callback. See \f(CW\*(C`FREETMPS\*(C'\fR and
perlcall.
.Sp
.Vb 1
\& SAVETMPS;
.Ve
.SH "Character classes"
.IX Header "Character classes"
.IP "isALNUM" 8
.IX Item "isALNUM"
Returns a boolean indicating whether the C \f(CW\*(C`char\*(C'\fR is an \s-1ASCII\s0 alphanumeric
character (including underscore) or digit.
.Sp
.Vb 1
\& bool isALNUM(char ch)
.Ve
.IP "isALPHA" 8
.IX Item "isALPHA"
Returns a boolean indicating whether the C \f(CW\*(C`char\*(C'\fR is an \s-1ASCII\s0 alphabetic
character.
.Sp
.Vb 1
\& bool isALPHA(char ch)
.Ve
.IP "isDIGIT" 8
.IX Item "isDIGIT"
Returns a boolean indicating whether the C \f(CW\*(C`char\*(C'\fR is an \s-1ASCII\s0
digit.
.Sp
.Vb 1
\& bool isDIGIT(char ch)
.Ve
.IP "isLOWER" 8
.IX Item "isLOWER"
Returns a boolean indicating whether the C \f(CW\*(C`char\*(C'\fR is a lowercase
character.
.Sp
.Vb 1
\& bool isLOWER(char ch)
.Ve
.IP "isSPACE" 8
.IX Item "isSPACE"
Returns a boolean indicating whether the C \f(CW\*(C`char\*(C'\fR is whitespace.
.Sp
.Vb 1
\& bool isSPACE(char ch)
.Ve
.IP "isUPPER" 8
.IX Item "isUPPER"
Returns a boolean indicating whether the C \f(CW\*(C`char\*(C'\fR is an uppercase
character.
.Sp
.Vb 1
\& bool isUPPER(char ch)
.Ve
.IP "toLOWER" 8
.IX Item "toLOWER"
Converts the specified character to lowercase.
.Sp
.Vb 1
\& char toLOWER(char ch)
.Ve
.IP "toUPPER" 8
.IX Item "toUPPER"
Converts the specified character to uppercase.
.Sp
.Vb 1
\& char toUPPER(char ch)
.Ve
.SH "Cloning an interpreter"
.IX Header "Cloning an interpreter"
.IP "perl_clone" 8
.IX Item "perl_clone"
Create and return a new interpreter by cloning the current one.
.Sp
.Vb 1
\& PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags)
.Ve
.SH "CV Manipulation Functions"
.IX Header "CV Manipulation Functions"
.IP "CvSTASH" 8
.IX Item "CvSTASH"
Returns the stash of the \s-1CV\s0.
.Sp
.Vb 1
\& HV* CvSTASH(CV* cv)
.Ve
.IP "get_cv" 8
.IX Item "get_cv"
Returns the \s-1CV\s0 of the specified Perl subroutine. If \f(CW\*(C`create\*(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`create\*(C'\fR is not set and the
subroutine does not exist then \s-1NULL\s0 is returned.
.Sp
\&\s-1NOTE:\s0 the perl_ form of this function is deprecated.
.Sp
.Vb 1
\& CV* get_cv(const char* name, I32 create)
.Ve
.IP "Nullcv" 8
.IX Item "Nullcv"
Null \s-1CV\s0 pointer.
.SH "Embedding Functions"
.IX Header "Embedding Functions"
.IP "load_module" 8
.IX Item "load_module"
Loads the module whose name is pointed to by the string part of name.
Note that the actual module name, not its filename, should be given.
Eg, \*(L"Foo::Bar\*(R" instead of \*(L"Foo/Bar.pm\*(R". flags can be any of
\&\s-1PERL_LOADMOD_DENY\s0, \s-1PERL_LOADMOD_NOIMPORT\s0, or \s-1PERL_LOADMOD_IMPORT_OPS\s0
(or 0 for no flags). ver, if specified, provides version semantics
similar to \f(CW\*(C`use Foo::Bar VERSION\*(C'\fR. The optional trailing SV*
arguments can be used to specify arguments to the module's \fIimport()\fR
method, similar to \f(CW\*(C`use Foo::Bar VERSION LIST\*(C'\fR.
.Sp
.Vb 1
\& void load_module(U32 flags, SV* name, SV* ver, ...)
.Ve
.IP "nothreadhook" 8
.IX Item "nothreadhook"
Stub that provides thread hook for perl_destruct when there are
no threads.
.Sp
.Vb 1
\& int nothreadhook()
.Ve
.IP "perl_alloc" 8
.IX Item "perl_alloc"
Allocates a new Perl interpreter. See perlembed.
.Sp
.Vb 1
\& PerlInterpreter* perl_alloc()
.Ve
.IP "perl_construct" 8
.IX Item "perl_construct"
Initializes a new Perl interpreter. See perlembed.
.Sp
.Vb 1
\& void perl_construct(PerlInterpreter* interp)
.Ve
.IP "perl_destruct" 8
.IX Item "perl_destruct"
Shuts down a Perl interpreter. See perlembed.
.Sp
.Vb 1
\& int perl_destruct(PerlInterpreter* interp)
.Ve
.IP "perl_free" 8
.IX Item "perl_free"
Releases a Perl interpreter. See perlembed.
.Sp
.Vb 1
\& void perl_free(PerlInterpreter* interp)
.Ve
.IP "perl_parse" 8
.IX Item "perl_parse"
Tells a Perl interpreter to parse a Perl script. See perlembed.
.Sp
.Vb 1
\& int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)
.Ve
.IP "perl_run" 8
.IX Item "perl_run"
Tells a Perl interpreter to run. See perlembed.
.Sp
.Vb 1
\& int perl_run(PerlInterpreter* interp)
.Ve
.IP "require_pv" 8
.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 '$file'"\*(C'\fR. It's even
implemented that way; consider using Perl_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 "Functions in file pp_pack.c"
.IX Header "Functions in file pp_pack.c"
.IP "pack_cat" 8
.IX Item "pack_cat"
The engine implementing \fIpack()\fR Perl function.
.Sp
.Vb 1
\& void pack_cat(SV *cat, char *pat, char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
.Ve
.IP "unpack_str" 8
.IX Item "unpack_str"
The engine implementing \fIunpack()\fR Perl function.
.Sp
.Vb 1
\& I32 unpack_str(char *pat, char *patend, char *s, char *strbeg, char *strend, char **new_s, I32 ocnt, U32 flags)
.Ve
.SH "Global Variables"
.IX Header "Global Variables"
.IP "PL_modglobal" 8
.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 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_sv_no" 8
.IX Item "PL_sv_no"
This is the \f(CW\*(C`false\*(C'\fR \s-1SV\s0. See \f(CW\*(C`PL_sv_yes\*(C'\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 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 Item "PL_sv_yes"
This is the \f(CW\*(C`true\*(C'\fR \s-1SV\s0. See \f(CW\*(C`PL_sv_no\*(C'\fR. Always refer to this as
\&\f(CW&PL_sv_yes\fR.
.Sp
.Vb 1
\& SV PL_sv_yes
.Ve
.SH "GV Functions"
.IX Header "GV Functions"
.IP "GvSV" 8
.IX Item "GvSV"
Return the \s-1SV\s0 from the \s-1GV\s0.
.Sp
.Vb 1
\& SV* GvSV(GV* gv)
.Ve
.IP "gv_fetchmeth" 8
.IX Item "gv_fetchmeth"
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 \s-1UNIVERSAL::\s0.
.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. Similarly for all the searched stashes.
.Sp
This function grants \f(CW"SUPER"\fR token as a postfix of the stash name. 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 1
\& GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)
.Ve
.IP "gv_fetchmethod" 8
.IX Item "gv_fetchmethod"
See gv_fetchmethod_autoload.
.Sp
.Vb 1
\& GV* gv_fetchmethod(HV* stash, const char* name)
.Ve
.IP "gv_fetchmethod_autoload" 8
.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\s0\*(R". 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\s0\*(R", 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 via a side effect to do this.
.Sp
These functions have the same side-effects and as \f(CW\*(C`gv_fetchmeth\*(C'\fR with
\&\f(CW\*(C`level==0\*(C'\fR. \f(CW\*(C`name\*(C'\fR should be writable if contains \f(CW':'\fR or \f(CW\*(C`'
\&''\*(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 apply equally to these functions.
.Sp
.Vb 1
\& GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)
.Ve
.IP "gv_fetchmeth_autoload" 8
.IX Item "gv_fetchmeth_autoload"
Same as \fIgv_fetchmeth()\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, \fIGvCV()\fR
of the result may be zero.
.Sp
.Vb 1
\& GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)
.Ve
.IP "gv_stashpv" 8
.IX Item "gv_stashpv"
Returns a pointer to the stash for a specified package. \f(CW\*(C`name\*(C'\fR should
be a valid \s-1UTF\-8\s0 string. If \f(CW\*(C`create\*(C'\fR is set then the package will be
created if it does not already exist. If \f(CW\*(C`create\*(C'\fR is not set and the
package does not exist then \s-1NULL\s0 is returned.
.Sp
.Vb 1
\& HV* gv_stashpv(const char* name, I32 create)
.Ve
.IP "gv_stashsv" 8
.IX Item "gv_stashsv"
Returns a pointer to the stash for a specified package, which must be a
valid \s-1UTF\-8\s0 string. See \f(CW\*(C`gv_stashpv\*(C'\fR.
.Sp
.Vb 1
\& HV* gv_stashsv(SV* sv, I32 create)
.Ve
.SH "Handy Values"
.IX Header "Handy Values"
.IP "HEf_SVKEY" 8
.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 "Nullch" 8
.IX Item "Nullch"
Null character pointer.
=for hackers
Found in file handy.h
.IP "Nullsv" 8
.IX Item "Nullsv"
Null \s-1SV\s0 pointer.
.SH "Hash Manipulation Functions"
.IX Header "Hash Manipulation Functions"
.IP "get_hv" 8
.IX Item "get_hv"
Returns the \s-1HV\s0 of the specified Perl hash. If \f(CW\*(C`create\*(C'\fR is set and the
Perl variable does not exist then it will be created. If \f(CW\*(C`create\*(C'\fR is not
set 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
\& HV* get_hv(const char* name, I32 create)
.Ve
.IP "HeHASH" 8
.IX Item "HeHASH"
Returns the computed hash stored in the hash entry.
.Sp
.Vb 1
\& U32 HeHASH(HE* he)
.Ve
.IP "HeKEY" 8
.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 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 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.
.Sp
.Vb 1
\& char* HePV(HE* he, STRLEN len)
.Ve
.IP "HeSVKEY" 8
.IX Item "HeSVKEY"
Returns the key as an \f(CW\*(C`SV*\*(C'\fR, or \f(CW\*(C`Nullsv\*(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 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 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 "HeVAL" 8
.IX Item "HeVAL"
Returns the value slot (type \f(CW\*(C`SV*\*(C'\fR) stored in the hash entry.
.Sp
.Vb 1
\& SV* HeVAL(HE* he)
.Ve
.IP "HvNAME" 8
.IX Item "HvNAME"
Returns the package name of a stash. See \f(CW\*(C`SvSTASH\*(C'\fR, \f(CW\*(C`CvSTASH\*(C'\fR.
.Sp
.Vb 1
\& char* HvNAME(HV* stash)
.Ve
.IP "hv_clear" 8
.IX Item "hv_clear"
Clears a hash, making it empty.
.Sp
.Vb 1
\& void hv_clear(HV* tb)
.Ve
.IP "hv_delete" 8
.IX Item "hv_delete"
Deletes a key/value pair in the hash. The value \s-1SV\s0 is removed from the
hash and returned to the caller. The \f(CW\*(C`klen\*(C'\fR is the length of the key.
The \f(CW\*(C`flags\*(C'\fR value will normally be zero; if set to G_DISCARD then \s-1NULL\s0
will be returned.
.Sp
.Vb 1
\& SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)
.Ve
.IP "hv_delete_ent" 8
.IX Item "hv_delete_ent"
Deletes a key/value pair in the hash. The value \s-1SV\s0 is removed from the
hash and returned to the caller. The \f(CW\*(C`flags\*(C'\fR value will normally be zero;
if set to G_DISCARD then \s-1NULL\s0 will be returned. \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
\& SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)
.Ve
.IP "hv_exists" 8
.IX Item "hv_exists"
Returns a boolean indicating whether the specified hash key exists. The
\&\f(CW\*(C`klen\*(C'\fR is the length of the key.
.Sp
.Vb 1
\& bool hv_exists(HV* tb, const char* key, I32 klen)
.Ve
.IP "hv_exists_ent" 8
.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* tb, SV* key, U32 hash)
.Ve
.IP "hv_fetch" 8
.IX Item "hv_fetch"
Returns the \s-1SV\s0 which corresponds to the specified key in the hash. The
\&\f(CW\*(C`klen\*(C'\fR is the length of the key. If \f(CW\*(C`lval\*(C'\fR is set then the fetch will be
part of a store. 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 1
\& SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)
.Ve
.IP "hv_fetch_ent" 8
.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`tb\*(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 1
\& HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)
.Ve
.IP "hv_iterinit" 8
.IX Item "hv_iterinit"
Prepares a starting point to traverse a hash table. Returns the number of
keys in the hash (i.e. the same as \f(CW\*(C`HvKEYS(tb)\*(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(tb)\*(C'\fR.
.Sp
.Vb 1
\& I32 hv_iterinit(HV* tb)
.Ve
.IP "hv_iterkey" 8
.IX Item "hv_iterkey"
Returns the key from the current position of the hash iterator. See
\&\f(CW\*(C`hv_iterinit\*(C'\fR.
.Sp
.Vb 1
\& char* hv_iterkey(HE* entry, I32* retlen)
.Ve
.IP "hv_iterkeysv" 8
.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\*(C`hv_iterinit\*(C'\fR.
.Sp
.Vb 1
\& SV* hv_iterkeysv(HE* entry)
.Ve
.IP "hv_iternext" 8
.IX Item "hv_iternext"
Returns entries from a hash iterator. See \f(CW\*(C`hv_iterinit\*(C'\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* tb)
.Ve
.IP "hv_iternextsv" 8
.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 Item "hv_iternext_flags"
Returns entries from a hash iterator. See \f(CW\*(C`hv_iterinit\*(C'\fR and \f(CW\*(C`hv_iternext\*(C'\fR.
The \f(CW\*(C`flags\*(C'\fR value will normally be zero; if \s-1HV_ITERNEXT_WANTPLACEHOLDERS\s0 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 literally
<&Perl_sv_undef> (a regular \f(CW\*(C`undef\*(C'\fR value is a normal read-write \s-1SV\s0 for which
\&\f(CW\*(C`!SvOK\*(C'\fR is false). 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
\&\s-1NOTE:\s0 this function is experimental and may change or be
removed without notice.
.Sp
.Vb 1
\& HE* hv_iternext_flags(HV* tb, I32 flags)
.Ve
.IP "hv_iterval" 8
.IX Item "hv_iterval"
Returns the value from the current position of the hash iterator. See
\&\f(CW\*(C`hv_iterkey\*(C'\fR.
.Sp
.Vb 1
\& SV* hv_iterval(HV* tb, HE* entry)
.Ve
.IP "hv_magic" 8
.IX Item "hv_magic"
Adds magic to a hash. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& void hv_magic(HV* hv, GV* gv, int how)
.Ve
.IP "hv_store" 8
.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 \f(CW\*(C`klen\*(C'\fR is
the length of the key. 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 will be
\&\s-1NULL\s0 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 \s-1NULL\s0.
.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
\& SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)
.Ve
.IP "hv_store_ent" 8
.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
\&\s-1NULL\s0 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.
.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* tb, SV* key, SV* val, U32 hash)
.Ve
.IP "hv_undef" 8
.IX Item "hv_undef"
Undefines the hash.
.Sp
.Vb 1
\& void hv_undef(HV* tb)
.Ve
.IP "newHV" 8
.IX Item "newHV"
Creates a new \s-1HV\s0. The reference count is set to 1.
.Sp
.Vb 1
\& HV* newHV()
.Ve
.IP "Nullhv" 8
.IX Item "Nullhv"
Null \s-1HV\s0 pointer.
.SH "Magical Functions"
.IX Header "Magical Functions"
.IP "mg_clear" 8
.IX Item "mg_clear"
Clear something magical that the \s-1SV\s0 represents. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& int mg_clear(SV* sv)
.Ve
.IP "mg_copy" 8
.IX Item "mg_copy"
Copies the magic from one \s-1SV\s0 to another. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen)
.Ve
.IP "mg_find" 8
.IX Item "mg_find"
Finds the magic pointer for type matching the \s-1SV\s0. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& MAGIC* mg_find(SV* sv, int type)
.Ve
.IP "mg_free" 8
.IX Item "mg_free"
Free any magic storage used by the \s-1SV\s0. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& int mg_free(SV* sv)
.Ve
.IP "mg_get" 8
.IX Item "mg_get"
Do magic after a value is retrieved from the \s-1SV\s0. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& int mg_get(SV* sv)
.Ve
.IP "mg_length" 8
.IX Item "mg_length"
Report on the \s-1SV\s0's length. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& U32 mg_length(SV* sv)
.Ve
.IP "mg_magical" 8
.IX Item "mg_magical"
Turns on the magical status of an \s-1SV\s0. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& void mg_magical(SV* sv)
.Ve
.IP "mg_set" 8
.IX Item "mg_set"
Do magic after a value is assigned to the \s-1SV\s0. See \f(CW\*(C`sv_magic\*(C'\fR.
.Sp
.Vb 1
\& int mg_set(SV* sv)
.Ve
.IP "SvGETMAGIC" 8
.IX Item "SvGETMAGIC"
Invokes \f(CW\*(C`mg_get\*(C'\fR on an \s-1SV\s0 if it has 'get' magic. This macro evaluates its
argument more than once.
.Sp
.Vb 1
\& void SvGETMAGIC(SV* sv)
.Ve
.IP "SvLOCK" 8
.IX Item "SvLOCK"
Arranges for a mutual exclusion lock to be obtained on sv if a suitable module
has been loaded.
.Sp
.Vb 1
\& void SvLOCK(SV* sv)
.Ve
.IP "SvSETMAGIC" 8
.IX Item "SvSETMAGIC"
Invokes \f(CW\*(C`mg_set\*(C'\fR on an \s-1SV\s0 if it has 'set' magic. This macro evaluates its
argument more than once.
.Sp
.Vb 1
\& void SvSETMAGIC(SV* sv)
.Ve
.IP "SvSetMagicSV" 8
.IX Item "SvSetMagicSV"
Like \f(CW\*(C`SvSetSV\*(C'\fR, but does any set magic required afterwards.
.Sp
.Vb 1
\& void SvSetMagicSV(SV* dsb, SV* ssv)
.Ve
.IP "SvSetMagicSV_nosteal" 8
.IX Item "SvSetMagicSV_nosteal"
Like \f(CW\*(C`SvSetMagicSV\*(C'\fR, but does any set magic required afterwards.
.Sp
.Vb 1
\& void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
.Ve
.IP "SvSetSV" 8
.IX Item "SvSetSV"
Calls \f(CW\*(C`sv_setsv\*(C'\fR if dsv is not the same as ssv. May evaluate arguments
more than once.
.Sp
.Vb 1
\& void SvSetSV(SV* dsb, SV* ssv)
.Ve
.IP "SvSetSV_nosteal" 8
.IX Item "SvSetSV_nosteal"
Calls a non-destructive version of \f(CW\*(C`sv_setsv\*(C'\fR if dsv is not the same as
ssv. May evaluate arguments more than once.
.Sp
.Vb 1
\& void SvSetSV_nosteal(SV* dsv, SV* ssv)
.Ve
.IP "SvSHARE" 8
.IX Item "SvSHARE"
Arranges for sv to be shared between threads if a suitable module
has been loaded.
.Sp
.Vb 1
\& void SvSHARE(SV* sv)
.Ve
.SH "Memory Management"
.IX Header "Memory Management"
.IP "Copy" 8
.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\*(C`Move\*(C'\fR.
.Sp
.Vb 1
\& void Copy(void* src, void* dest, int nitems, type)
.Ve
.IP "Move" 8
.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\*(C`Copy\*(C'\fR.
.Sp
.Vb 1
\& void Move(void* src, void* dest, int nitems, type)
.Ve
.IP "New" 8
.IX Item "New"
The XSUB\-writer's interface to the C \f(CW\*(C`malloc\*(C'\fR function.
.Sp
.Vb 1
\& void New(int id, void* ptr, int nitems, type)
.Ve
.IP "Newc" 8
.IX Item "Newc"
The XSUB\-writer's interface to the C \f(CW\*(C`malloc\*(C'\fR function, with
cast.
.Sp
.Vb 1
\& void Newc(int id, void* ptr, int nitems, type, cast)
.Ve
.IP "\s-1NEWSV\s0" 8
.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
tailing \s-1NUL\s0 is also reserved. (SvPOK 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.
\&\f(CW\*(C`id\*(C'\fR is an integer id between 0 and 1299 (used to identify leaks).
.Sp
.Vb 1
\& SV* NEWSV(int id, STRLEN len)
.Ve
.IP "Newz" 8
.IX Item "Newz"
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.
.Sp
.Vb 1
\& void Newz(int id, void* ptr, int nitems, type)
.Ve
.IP "Poison" 8
.IX Item "Poison"
Fill up memory with a pattern (byte 0xAB over and over again) that
hopefully catches attempts to access uninitialized memory.
.Sp
.Vb 1
\& void Poison(void* dest, int nitems, type)
.Ve
.IP "Renew" 8
.IX Item "Renew"
The XSUB\-writer's interface to the C \f(CW\*(C`realloc\*(C'\fR function.
.Sp
.Vb 1
\& void Renew(void* ptr, int nitems, type)
.Ve
.IP "Renewc" 8
.IX Item "Renewc"
The XSUB\-writer's interface to the C \f(CW\*(C`realloc\*(C'\fR function, with
cast.
.Sp
.Vb 1
\& void Renewc(void* ptr, int nitems, type, cast)
.Ve
.IP "Safefree" 8
.IX Item "Safefree"
The XSUB\-writer's interface to the C \f(CW\*(C`free\*(C'\fR function.
.Sp
.Vb 1
\& void Safefree(void* ptr)
.Ve
.IP "savepv" 8
.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. The memory allocated for the new string can
be freed with the \f(CW\*(C`Safefree()\*(C'\fR function.
.Sp
.Vb 1
\& char* savepv(const char* pv)
.Ve
.IP "savepvn" 8
.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. The memory allocated for the new string can be
freed with the \f(CW\*(C`Safefree()\*(C'\fR function.
.Sp
.Vb 1
\& char* savepvn(const char* pv, I32 len)
.Ve
.IP "savesharedpv" 8
.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 "StructCopy" 8
.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 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
.SH "Miscellaneous Functions"
.IX Header "Miscellaneous Functions"
.IP "fbm_compile" 8
.IX Item "fbm_compile"
Analyses the string in order to make fast searches on it using \fIfbm_instr()\fR
\&\*(-- the Boyer-Moore algorithm.
.Sp
.Vb 1
\& void fbm_compile(SV* sv, U32 flags)
.Ve
.IP "fbm_instr" 8
.IX Item "fbm_instr"
Returns the location of the \s-1SV\s0 in the string delimited by \f(CW\*(C`str\*(C'\fR and
\&\f(CW\*(C`strend\*(C'\fR. It returns \f(CW\*(C`Nullch\*(C'\fR if the string can't be found. The \f(CW\*(C`sv\*(C'\fR
does not have to be fbm_compiled, but the search will not be as fast
then.
.Sp
.Vb 1
\& char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)
.Ve
.IP "form" 8
.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 Item "getcwd_sv"
Fill the sv with current working directory
.Sp
.Vb 1
\& int getcwd_sv(SV* sv)
.Ve
.IP "strEQ" 8
.IX Item "strEQ"
Test two 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 Item "strGE"
Test two 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 Item "strGT"
Test two 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 Item "strLE"
Test two 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 Item "strLT"
Test two 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 Item "strNE"
Test two 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 Item "strnEQ"
Test two 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 Item "strnNE"
Test two 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
.SH "Numeric functions"
.IX Header "Numeric functions"
.IP "grok_bin" 8
.IX Item "grok_bin"
converts a string representing a binary number to numeric form.
.Sp
On entry \fIstart\fR and \fI*len\fR give the string to scan, \fI*flags\fR gives
conversion flags, and \fIresult\fR should be \s-1NULL\s0 or a pointer to an \s-1NV\s0.
The scan stops at the end of the string, or the first invalid character.
On return \fI*len\fR is set to the length scanned string, and \fI*flags\fR gives
output flags.
.Sp
If the value is <= \s-1UV_MAX\s0 it is returned as a \s-1UV\s0, the output flags are clear,
and nothing is written to \fI*result\fR. If the value is > \s-1UV_MAX\s0 \f(CW\*(C`grok_bin\*(C'\fR
returns \s-1UV_MAX\s0, sets \f(CW\*(C`PERL_SCAN_GREATER_THAN_UV_MAX\*(C'\fR in the output flags,
and writes the value to \fI*result\fR (or the value is discarded if \fIresult\fR
is \s-1NULL\s0).
.Sp
The hex number may optionally be prefixed with \*(L"0b\*(R" or \*(L"b\*(R" unless
\&\f(CW\*(C`PERL_SCAN_DISALLOW_PREFIX\*(C'\fR is set in \fI*flags\fR on entry. If
\&\f(CW\*(C`PERL_SCAN_ALLOW_UNDERSCORES\*(C'\fR is set in \fI*flags\fR then the binary
number may use '_' characters to separate digits.
.Sp
.Vb 1
\& UV grok_bin(char* start, STRLEN* len, I32* flags, NV *result)
.Ve
.IP "grok_hex" 8
.IX Item "grok_hex"
converts a string representing a hex number to numeric form.
.Sp
On entry \fIstart\fR and \fI*len\fR give the string to scan, \fI*flags\fR gives
conversion flags, and \fIresult\fR should be \s-1NULL\s0 or a pointer to an \s-1NV\s0.
The scan stops at the end of the string, or the first non-hex-digit character.
On return \fI*len\fR is set to the length scanned string, and \fI*flags\fR gives
output flags.
.Sp
If the value is <= \s-1UV_MAX\s0 it is returned as a \s-1UV\s0, the output flags are clear,
and nothing is written to \fI*result\fR. If the value is > \s-1UV_MAX\s0 \f(CW\*(C`grok_hex\*(C'\fR
returns \s-1UV_MAX\s0, sets \f(CW\*(C`PERL_SCAN_GREATER_THAN_UV_MAX\*(C'\fR in the output flags,
and writes the value to \fI*result\fR (or the value is discarded if \fIresult\fR
is \s-1NULL\s0).
.Sp
The hex number may optionally be prefixed with \*(L"0x\*(R" or \*(L"x\*(R" unless
\&\f(CW\*(C`PERL_SCAN_DISALLOW_PREFIX\*(C'\fR is set in \fI*flags\fR on entry. If
\&\f(CW\*(C`PERL_SCAN_ALLOW_UNDERSCORES\*(C'\fR is set in \fI*flags\fR then the hex
number may use '_' characters to separate digits.
.Sp
.Vb 1
\& UV grok_hex(char* start, STRLEN* len, I32* flags, NV *result)
.Ve
.IP "grok_number" 8
.IX Item "grok_number"
Recognise (or not) a number. The type of the number is returned
(0 if unrecognised), otherwise it is a bit-ORed combination of
\&\s-1IS_NUMBER_IN_UV\s0, \s-1IS_NUMBER_GREATER_THAN_UV_MAX\s0, \s-1IS_NUMBER_NOT_INT\s0,
\&\s-1IS_NUMBER_NEG\s0, \s-1IS_NUMBER_INFINITY\s0, \s-1IS_NUMBER_NAN\s0 (defined in perl.h).
.Sp
If the value of the number can fit an in \s-1UV\s0, it is returned in the *valuep
\&\s-1IS_NUMBER_IN_UV\s0 will be set to indicate that *valuep is valid, \s-1IS_NUMBER_IN_UV\s0
will never be set unless *valuep is valid, but *valuep may have been assigned
to during processing even though \s-1IS_NUMBER_IN_UV\s0 is not set on return.
If valuep is \s-1NULL\s0, \s-1IS_NUMBER_IN_UV\s0 will be set for the same cases as when
valuep is non\-NULL, but no actual assignment (or \s-1SEGV\s0) will occur.
.Sp
\&\s-1IS_NUMBER_NOT_INT\s0 will be set with \s-1IS_NUMBER_IN_UV\s0 if trailing decimals were
seen (in which case *valuep gives the true value truncated to an integer), and
\&\s-1IS_NUMBER_NEG\s0 if the number is negative (in which case *valuep holds the
absolute value). \s-1IS_NUMBER_IN_UV\s0 is not set if e notation was used or the
number is larger than a \s-1UV\s0.
.Sp
.Vb 1
\& int grok_number(const char *pv, STRLEN len, UV *valuep)
.Ve
.IP "grok_numeric_radix" 8
.IX Item "grok_numeric_radix"
Scan and skip for a numeric decimal separator (radix).
.Sp
.Vb 1
\& bool grok_numeric_radix(const char **sp, const char *send)
.Ve
.IP "grok_oct" 8
.IX Item "grok_oct"
.Vb 1
\& UV grok_oct(char* start, STRLEN* len, I32* flags, NV *result)
.Ve
.IP "scan_bin" 8
.IX Item "scan_bin"
For backwards compatibility. Use \f(CW\*(C`grok_bin\*(C'\fR instead.
.Sp
.Vb 1
\& NV scan_bin(char* start, STRLEN len, STRLEN* retlen)
.Ve
.IP "scan_hex" 8
.IX Item "scan_hex"
For backwards compatibility. Use \f(CW\*(C`grok_hex\*(C'\fR instead.
.Sp
.Vb 1
\& NV scan_hex(char* start, STRLEN len, STRLEN* retlen)
.Ve
.IP "scan_oct" 8
.IX Item "scan_oct"
For backwards compatibility. Use \f(CW\*(C`grok_oct\*(C'\fR instead.
.Sp
.Vb 1
\& NV scan_oct(char* start, STRLEN len, STRLEN* retlen)
.Ve
.SH "Optree Manipulation Functions"
.IX Header "Optree Manipulation Functions"
.IP "cv_const_sv" 8
.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 \s-1NULL\s0.
.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(CV* cv)
.Ve
.IP "newCONSTSUB" 8
.IX Item "newCONSTSUB"
Creates a constant sub equivalent to Perl \f(CW\*(C`sub FOO () { 123 }\*(C'\fR which is
eligible for inlining at compile\-time.
.Sp
.Vb 1
\& CV* newCONSTSUB(HV* stash, char* name, SV* sv)
.Ve
.IP "newXS" 8
.IX Item "newXS"
Used by \f(CW\*(C`xsubpp\*(C'\fR to hook up XSUBs as Perl subs.
.SH "Stack Manipulation Macros"
.IX Header "Stack Manipulation Macros"
.IP "dMARK" 8
.IX Item "dMARK"
Declare a stack marker variable, \f(CW\*(C`mark\*(C'\fR, for the \s-1XSUB\s0. See \f(CW\*(C`MARK\*(C'\fR and
\&\f(CW\*(C`dORIGMARK\*(C'\fR.
.Sp
.Vb 1
\& dMARK;
.Ve
.IP "dORIGMARK" 8
.IX Item "dORIGMARK"
Saves the original stack mark for the \s-1XSUB\s0. See \f(CW\*(C`ORIGMARK\*(C'\fR.
.Sp
.Vb 1
\& dORIGMARK;
.Ve
.IP "dSP" 8
.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\*(C`SP\*(C'\fR.
.Sp
.Vb 1
\& dSP;
.Ve
.IP "\s-1EXTEND\s0" 8
.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, int nitems)
.Ve
.IP "\s-1MARK\s0" 8
.IX Item "MARK"
Stack marker variable for the \s-1XSUB\s0. See \f(CW\*(C`dMARK\*(C'\fR.
.IP "\s-1ORIGMARK\s0" 8
.IX Item "ORIGMARK"
The original stack mark for the \s-1XSUB\s0. See \f(CW\*(C`dORIGMARK\*(C'\fR.
.IP "POPi" 8
.IX Item "POPi"
Pops an integer off the stack.
.Sp
.Vb 1
\& IV POPi
.Ve
.IP "POPl" 8
.IX Item "POPl"
Pops a long off the stack.
.Sp
.Vb 1
\& long POPl
.Ve
.IP "POPn" 8
.IX Item "POPn"
Pops a double off the stack.
.Sp
.Vb 1
\& NV POPn
.Ve
.IP "POPp" 8
.IX Item "POPp"
Pops a string off the stack. Deprecated. New code should provide
a \s-1STRLEN\s0 n_a and use POPpx.
.Sp
.Vb 1
\& char* POPp
.Ve
.IP "POPpbytex" 8
.IX Item "POPpbytex"
Pops a string off the stack which must consist of bytes i.e. characters < 256.
Requires a variable \s-1STRLEN\s0 n_a in scope.
.Sp
.Vb 1
\& char* POPpbytex
.Ve
.IP "POPpx" 8
.IX Item "POPpx"
Pops a string off the stack.
Requires a variable \s-1STRLEN\s0 n_a in scope.
.Sp
.Vb 1
\& char* POPpx
.Ve
.IP "POPs" 8
.IX Item "POPs"
Pops an \s-1SV\s0 off the stack.
.Sp
.Vb 1
\& SV* POPs
.Ve
.IP "PUSHi" 8
.IX Item "PUSHi"
Push an integer onto the stack. The stack must have room for this element.
Handles 'set' magic. See \f(CW\*(C`XPUSHi\*(C'\fR.
.Sp
.Vb 1
\& void PUSHi(IV iv)
.Ve
.IP "\s-1PUSHMARK\s0" 8
.IX Item "PUSHMARK"
Opening bracket for arguments on a callback. See \f(CW\*(C`PUTBACK\*(C'\fR and
perlcall.
.Sp
.Vb 1
\& PUSHMARK;
.Ve
.IP "PUSHn" 8
.IX Item "PUSHn"
Push a double onto the stack. The stack must have room for this element.
Handles 'set' magic. See \f(CW\*(C`XPUSHn\*(C'\fR.
.Sp
.Vb 1
\& void PUSHn(NV nv)
.Ve
.IP "PUSHp" 8
.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. See
\&\f(CW\*(C`XPUSHp\*(C'\fR.
.Sp
.Vb 1
\& void PUSHp(char* str, STRLEN len)
.Ve
.IP "PUSHs" 8
.IX Item "PUSHs"
Push an \s-1SV\s0 onto the stack. The stack must have room for this element.
Does not handle 'set' magic. See \f(CW\*(C`XPUSHs\*(C'\fR.
.Sp
.Vb 1
\& void PUSHs(SV* sv)
.Ve
.IP "PUSHu" 8
.IX Item "PUSHu"
Push an unsigned integer onto the stack. The stack must have room for this
element. See \f(CW\*(C`XPUSHu\*(C'\fR.
.Sp
.Vb 1
\& void PUSHu(UV uv)
.Ve
.IP "\s-1PUTBACK\s0" 8
.IX Item "PUTBACK"
Closing bracket for \s-1XSUB\s0 arguments. This is usually handled by \f(CW\*(C`xsubpp\*(C'\fR.
See \f(CW\*(C`PUSHMARK\*(C'\fR and perlcall for other uses.
.Sp
.Vb 1
\& PUTBACK;
.Ve
.IP "\s-1SP\s0" 8
.IX Item "SP"
Stack pointer. This is usually handled by \f(CW\*(C`xsubpp\*(C'\fR. See \f(CW\*(C`dSP\*(C'\fR and
\&\f(CW\*(C`SPAGAIN\*(C'\fR.
.IP "\s-1SPAGAIN\s0" 8
.IX Item "SPAGAIN"
Refetch the stack pointer. Used after a callback. See perlcall.
.Sp
.Vb 1
\& SPAGAIN;
.Ve
.IP "XPUSHi" 8
.IX Item "XPUSHi"
Push an integer onto the stack, extending the stack if necessary. Handles
\&'set' magic. See \f(CW\*(C`PUSHi\*(C'\fR.
.Sp
.Vb 1
\& void XPUSHi(IV iv)
.Ve
.IP "XPUSHn" 8
.IX Item "XPUSHn"
Push a double onto the stack, extending the stack if necessary. Handles
\&'set' magic. See \f(CW\*(C`PUSHn\*(C'\fR.
.Sp
.Vb 1
\& void XPUSHn(NV nv)
.Ve
.IP "XPUSHp" 8
.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. See
\&\f(CW\*(C`PUSHp\*(C'\fR.
.Sp
.Vb 1
\& void XPUSHp(char* str, STRLEN len)
.Ve
.IP "XPUSHs" 8
.IX Item "XPUSHs"
Push an \s-1SV\s0 onto the stack, extending the stack if necessary. Does not
handle 'set' magic. See \f(CW\*(C`PUSHs\*(C'\fR.
.Sp
.Vb 1
\& void XPUSHs(SV* sv)
.Ve
.IP "XPUSHu" 8
.IX Item "XPUSHu"
Push an unsigned integer onto the stack, extending the stack if necessary.
See \f(CW\*(C`PUSHu\*(C'\fR.
.Sp
.Vb 1
\& void XPUSHu(UV uv)
.Ve
.IP "\s-1XSRETURN\s0" 8
.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_IV\s0" 8
.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 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 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 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 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_YES\s0" 8
.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 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 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 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 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 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_mYES" 8
.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 "svtype" 8
.IX Item "svtype"
An enum of flags for Perl types. These are found in the file \fBsv.h\fR
in the \f(CW\*(C`svtype\*(C'\fR enum. Test these flags with the \f(CW\*(C`SvTYPE\*(C'\fR macro.
.IP "SVt_IV" 8
.IX Item "SVt_IV"
Integer type flag for scalars. See \f(CW\*(C`svtype\*(C'\fR.
.IP "SVt_NV" 8
.IX Item "SVt_NV"
Double type flag for scalars. See \f(CW\*(C`svtype\*(C'\fR.
.IP "SVt_PV" 8
.IX Item "SVt_PV"
Pointer type flag for scalars. See \f(CW\*(C`svtype\*(C'\fR.
.IP "SVt_PVAV" 8
.IX Item "SVt_PVAV"
Type flag for arrays. See \f(CW\*(C`svtype\*(C'\fR.
.IP "SVt_PVCV" 8
.IX Item "SVt_PVCV"
Type flag for code refs. See \f(CW\*(C`svtype\*(C'\fR.
.IP "SVt_PVHV" 8
.IX Item "SVt_PVHV"
Type flag for hashes. See \f(CW\*(C`svtype\*(C'\fR.
.IP "SVt_PVMG" 8
.IX Item "SVt_PVMG"
Type flag for blessed scalars. See \f(CW\*(C`svtype\*(C'\fR.
.SH "SV Manipulation Functions"
.IX Header "SV Manipulation Functions"
.IP "get_sv" 8
.IX Item "get_sv"
Returns the \s-1SV\s0 of the specified Perl scalar. If \f(CW\*(C`create\*(C'\fR is set and the
Perl variable does not exist then it will be created. If \f(CW\*(C`create\*(C'\fR is not
set 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 create)
.Ve
.IP "looks_like_number" 8
.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 \fIatof()\fR doesn't grok them.
.Sp
.Vb 1
\& I32 looks_like_number(SV* sv)
.Ve
.IP "newRV_inc" 8
.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 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 *sv)
.Ve
.IP "newSV" 8
.IX Item "newSV"
Create a new null \s-1SV\s0, or if len > 0, create a new empty SVt_PV type \s-1SV\s0
with an initial \s-1PV\s0 allocation of len+1. Normally accessed via the \f(CW\*(C`NEWSV\*(C'\fR
macro.
.Sp
.Vb 1
\& SV* newSV(STRLEN len)
.Ve
.IP "newSViv" 8
.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(IV i)
.Ve
.IP "newSVnv" 8
.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(NV n)
.Ve
.IP "newSVpv" 8
.IX Item "newSVpv"
Creates a new \s-1SV\s0 and copies a string 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
\&\fIstrlen()\fR. For efficiency, consider using \f(CW\*(C`newSVpvn\*(C'\fR instead.
.Sp
.Vb 1
\& SV* newSVpv(const char* s, STRLEN len)
.Ve
.IP "newSVpvf" 8
.IX Item "newSVpvf"
Creates a new \s-1SV\s0 and initializes it with the string formatted like
\&\f(CW\*(C`sprintf\*(C'\fR.
.Sp
.Vb 1
\& SV* newSVpvf(const char* pat, ...)
.Ve
.IP "newSVpvn" 8
.IX Item "newSVpvn"
Creates a new \s-1SV\s0 and copies a string 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.
.Sp
.Vb 1
\& SV* newSVpvn(const char* s, STRLEN len)
.Ve
.IP "newSVpvn_share" 8
.IX Item "newSVpvn_share"
Creates a new \s-1SV\s0 with its SvPVX 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 \s-1READONLY\s0 and \s-1FAKE\s0. The string's hash is stored in the \s-1UV\s0
slot of the \s-1SV\s0; if the \f(CW\*(C`hash\*(C'\fR parameter is non\-zero, that value is used;
otherwise the hash is computed. The idea here is that as the string table
is used for shared hash keys these strings will have SvPVX == HeKEY and
hash lookup will avoid string compare.
.Sp
.Vb 1
\& SV* newSVpvn_share(const char* s, I32 len, U32 hash)
.Ve
.IP "newSVrv" 8
.IX Item "newSVrv"
Creates a new \s-1SV\s0 for the \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.
.Sp
.Vb 1
\& SV* newSVrv(SV* rv, const char* classname)
.Ve
.IP "newSVsv" 8
.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* old)
.Ve
.IP "newSVuv" 8
.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(UV u)
.Ve
.IP "new_vstring" 8
.IX Item "new_vstring"
Returns a pointer to the next character after the parsed
vstring, as well as updating the passed in sv.
.Sp
Function must be called like
.Sp
.Vb 2
\& sv = NEWSV(92,5);
\& s = new_vstring(s,sv);
.Ve
.Sp
The sv must already be large enough to store the vstring
passed in.
.Sp
.Vb 1
\& char* new_vstring(char *vstr, SV *sv)
.Ve
.IP "SvCUR" 8
.IX Item "SvCUR"
Returns the length of the string which is in the \s-1SV\s0. See \f(CW\*(C`SvLEN\*(C'\fR.
.Sp
.Vb 1
\& STRLEN SvCUR(SV* sv)
.Ve
.IP "SvCUR_set" 8
.IX Item "SvCUR_set"
Set the length of the string which is in the \s-1SV\s0. See \f(CW\*(C`SvCUR\*(C'\fR.
.Sp
.Vb 1
\& void SvCUR_set(SV* sv, STRLEN len)
.Ve
.IP "SvEND" 8
.IX Item "SvEND"
Returns a pointer to the last character in the string which is in the \s-1SV\s0.
See \f(CW\*(C`SvCUR\*(C'\fR. Access the character as *(SvEND(sv)).
.Sp
.Vb 1
\& char* SvEND(SV* sv)
.Ve
.IP "SvGROW" 8
.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
\&\s-1NUL\s0 character). Calls \f(CW\*(C`sv_grow\*(C'\fR to perform the expansion if necessary.
Returns a pointer to the character buffer.
.Sp
.Vb 1
\& char * SvGROW(SV* sv, STRLEN len)
.Ve
.IP "SvIOK" 8
.IX Item "SvIOK"
Returns a boolean indicating whether the \s-1SV\s0 contains an integer.
.Sp
.Vb 1
\& bool SvIOK(SV* sv)
.Ve
.IP "SvIOKp" 8
.IX Item "SvIOKp"
Returns a boolean indicating whether the \s-1SV\s0 contains an integer. Checks
the \fBprivate\fR setting. Use \f(CW\*(C`SvIOK\*(C'\fR.
.Sp
.Vb 1
\& bool SvIOKp(SV* sv)
.Ve
.IP "SvIOK_notUV" 8
.IX Item "SvIOK_notUV"
Returns a boolean indicating whether the \s-1SV\s0 contains a signed integer.
.Sp
.Vb 1
\& void SvIOK_notUV(SV* sv)
.Ve
.IP "SvIOK_off" 8
.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 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 Item "SvIOK_only"
Tells an \s-1SV\s0 that it is an integer and disables all other \s-1OK\s0 bits.
.Sp
.Vb 1
\& void SvIOK_only(SV* sv)
.Ve
.IP "SvIOK_only_UV" 8
.IX Item "SvIOK_only_UV"
Tells and \s-1SV\s0 that it is an unsigned integer and disables all other \s-1OK\s0 bits.
.Sp
.Vb 1
\& void SvIOK_only_UV(SV* sv)
.Ve
.IP "SvIOK_UV" 8
.IX Item "SvIOK_UV"
Returns a boolean indicating whether the \s-1SV\s0 contains an unsigned integer.
.Sp
.Vb 1
\& void SvIOK_UV(SV* sv)
.Ve
.IP "SvIV" 8
.IX Item "SvIV"
Coerces the given \s-1SV\s0 to an integer and returns it. See \f(CW\*(C`SvIVx\*(C'\fR for a
version which guarantees to evaluate sv only once.
.Sp
.Vb 1
\& IV SvIV(SV* sv)
.Ve
.IP "SvIVx" 8
.IX Item "SvIVx"
Coerces the given \s-1SV\s0 to an integer and returns it. Guarantees to evaluate
sv only once. Use the more efficient \f(CW\*(C`SvIV\*(C'\fR otherwise.
.Sp
.Vb 1
\& IV SvIVx(SV* sv)
.Ve
.IP "SvIVX" 8
.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 SvIOK is true. See also \f(CW\*(C`SvIV()\*(C'\fR.
.Sp
.Vb 1
\& IV SvIVX(SV* sv)
.Ve
.IP "SvLEN" 8
.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\*(C`SvCUR\*(C'\fR.
.Sp
.Vb 1
\& STRLEN SvLEN(SV* sv)
.Ve
.IP "SvNIOK" 8
.IX Item "SvNIOK"
Returns a boolean indicating whether the \s-1SV\s0 contains a number, integer or
double.
.Sp
.Vb 1
\& bool SvNIOK(SV* sv)
.Ve
.IP "SvNIOKp" 8
.IX Item "SvNIOKp"
Returns a boolean indicating whether the \s-1SV\s0 contains a number, integer or
double. Checks the \fBprivate\fR setting. Use \f(CW\*(C`SvNIOK\*(C'\fR.
.Sp
.Vb 1
\& bool SvNIOKp(SV* sv)
.Ve
.IP "SvNIOK_off" 8
.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 "SvNOK" 8
.IX Item "SvNOK"
Returns a boolean indicating whether the \s-1SV\s0 contains a double.
.Sp
.Vb 1
\& bool SvNOK(SV* sv)
.Ve
.IP "SvNOKp" 8
.IX Item "SvNOKp"
Returns a boolean indicating whether the \s-1SV\s0 contains a double. Checks the
\&\fBprivate\fR setting. Use \f(CW\*(C`SvNOK\*(C'\fR.
.Sp
.Vb 1
\& bool SvNOKp(SV* sv)
.Ve
.IP "SvNOK_off" 8
.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 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 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 "SvNV" 8
.IX Item "SvNV"
Coerce the given \s-1SV\s0 to a double and return it. See \f(CW\*(C`SvNVx\*(C'\fR for a version
which guarantees to evaluate sv only once.
.Sp
.Vb 1
\& NV SvNV(SV* sv)
.Ve
.IP "SvNVX" 8
.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 SvNOK is true. See also \f(CW\*(C`SvNV()\*(C'\fR.
.Sp
.Vb 1
\& NV SvNVX(SV* sv)
.Ve
.IP "SvNVx" 8
.IX Item "SvNVx"
Coerces the given \s-1SV\s0 to a double and returns it. Guarantees to evaluate
sv only once. Use the more efficient \f(CW\*(C`SvNV\*(C'\fR otherwise.
.Sp
.Vb 1
\& NV SvNVx(SV* sv)
.Ve
.IP "SvOK" 8
.IX Item "SvOK"
Returns a boolean indicating whether the value is an \s-1SV\s0.
.Sp
.Vb 1
\& bool SvOK(SV* sv)
.Ve
.IP "SvOOK" 8
.IX Item "SvOOK"
Returns a boolean indicating whether the SvIVX is a valid offset value for
the SvPVX. This hack is used internally to speed up removal of characters
from the beginning of a SvPV. When SvOOK is true, then the start of the
allocated string buffer is really (SvPVX \- SvIVX).
.Sp
.Vb 1
\& bool SvOOK(SV* sv)
.Ve
.IP "SvPOK" 8
.IX Item "SvPOK"
Returns a boolean indicating whether the \s-1SV\s0 contains a character
string.
.Sp
.Vb 1
\& bool SvPOK(SV* sv)
.Ve
.IP "SvPOKp" 8
.IX Item "SvPOKp"
Returns a boolean indicating whether the \s-1SV\s0 contains a character string.
Checks the \fBprivate\fR setting. Use \f(CW\*(C`SvPOK\*(C'\fR.
.Sp
.Vb 1
\& bool SvPOKp(SV* sv)
.Ve
.IP "SvPOK_off" 8
.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 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 Item "SvPOK_only"
Tells an \s-1SV\s0 that it is a string and disables all other \s-1OK\s0 bits.
Will also turn off the \s-1UTF8\s0 status.
.Sp
.Vb 1
\& void SvPOK_only(SV* sv)
.Ve
.IP "SvPOK_only_UTF8" 8
.IX Item "SvPOK_only_UTF8"
Tells an \s-1SV\s0 that it is a string and disables all other \s-1OK\s0 bits,
and leaves the \s-1UTF8\s0 status as it was.
.Sp
.Vb 1
\& void SvPOK_only_UTF8(SV* sv)
.Ve
.IP "SvPV" 8
.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. See also
\&\f(CW\*(C`SvPVx\*(C'\fR for a version which guarantees to evaluate sv only once.
.Sp
.Vb 1
\& char* SvPV(SV* sv, STRLEN len)
.Ve
.IP "SvPVbyte" 8
.IX Item "SvPVbyte"
Like \f(CW\*(C`SvPV\*(C'\fR, but converts sv to byte representation first if necessary.
.Sp
.Vb 1
\& char* SvPVbyte(SV* sv, STRLEN len)
.Ve
.IP "SvPVbytex" 8
.IX Item "SvPVbytex"
Like \f(CW\*(C`SvPV\*(C'\fR, but converts sv to byte representation first if necessary.
Guarantees to evaluate sv only once; use the more efficient \f(CW\*(C`SvPVbyte\*(C'\fR
otherwise.
.Sp
.Vb 1
\& char* SvPVbytex(SV* sv, STRLEN len)
.Ve
.IP "SvPVbytex_force" 8
.IX Item "SvPVbytex_force"
Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts sv to byte representation first if necessary.
Guarantees to evaluate sv only once; use the more efficient \f(CW\*(C`SvPVbyte_force\*(C'\fR
otherwise.
.Sp
.Vb 1
\& char* SvPVbytex_force(SV* sv, STRLEN len)
.Ve
.IP "SvPVbyte_force" 8
.IX Item "SvPVbyte_force"
Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts sv to byte representation first if necessary.
.Sp
.Vb 1
\& char* SvPVbyte_force(SV* sv, STRLEN len)
.Ve
.IP "SvPVbyte_nolen" 8
.IX Item "SvPVbyte_nolen"
Like \f(CW\*(C`SvPV_nolen\*(C'\fR, but converts sv to byte representation first if necessary.
.Sp
.Vb 1
\& char* SvPVbyte_nolen(SV* sv)
.Ve
.IP "SvPVutf8" 8
.IX Item "SvPVutf8"
Like \f(CW\*(C`SvPV\*(C'\fR, but converts sv to utf8 first if necessary.
.Sp
.Vb 1
\& char* SvPVutf8(SV* sv, STRLEN len)
.Ve
.IP "SvPVutf8x" 8
.IX Item "SvPVutf8x"
Like \f(CW\*(C`SvPV\*(C'\fR, but converts sv to utf8 first if necessary.
Guarantees to evaluate sv 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 Item "SvPVutf8x_force"
Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts sv to utf8 first if necessary.
Guarantees to evaluate sv 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 Item "SvPVutf8_force"
Like \f(CW\*(C`SvPV_force\*(C'\fR, but converts sv to utf8 first if necessary.
.Sp
.Vb 1
\& char* SvPVutf8_force(SV* sv, STRLEN len)
.Ve
.IP "SvPVutf8_nolen" 8
.IX Item "SvPVutf8_nolen"
Like \f(CW\*(C`SvPV_nolen\*(C'\fR, but converts sv to utf8 first if necessary.
.Sp
.Vb 1
\& char* SvPVutf8_nolen(SV* sv)
.Ve
.IP "SvPVx" 8
.IX Item "SvPVx"
A version of \f(CW\*(C`SvPV\*(C'\fR which guarantees to evaluate sv only once.
.Sp
.Vb 1
\& char* SvPVx(SV* sv, STRLEN len)
.Ve
.IP "SvPVX" 8
.IX Item "SvPVX"
Returns a pointer to the physical string in the \s-1SV\s0. The \s-1SV\s0 must contain a
string.
.Sp
.Vb 1
\& char* SvPVX(SV* sv)
.Ve
.IP "SvPV_force" 8
.IX Item "SvPV_force"
Like \f(CW\*(C`SvPV\*(C'\fR but will force the \s-1SV\s0 into containing just a string
(\f(CW\*(C`SvPOK_only\*(C'\fR). You want force if you are going to update the \f(CW\*(C`SvPVX\*(C'\fR
directly.
.Sp
.Vb 1
\& char* SvPV_force(SV* sv, STRLEN len)
.Ve
.IP "SvPV_force_nomg" 8
.IX Item "SvPV_force_nomg"
Like \f(CW\*(C`SvPV\*(C'\fR but will force the \s-1SV\s0 into containing just a string
(\f(CW\*(C`SvPOK_only\*(C'\fR). You want force if you are going to update the \f(CW\*(C`SvPVX\*(C'\fR
directly. Doesn't process magic.
.Sp
.Vb 1
\& char* SvPV_force_nomg(SV* sv, STRLEN len)
.Ve
.IP "SvPV_nolen" 8
.IX Item "SvPV_nolen"
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 form becoming \f(CW\*(C`SvPOK\*(C'\fR. Handles 'get' magic.
.Sp
.Vb 1
\& char* SvPV_nolen(SV* sv)
.Ve
.IP "SvREFCNT" 8
.IX Item "SvREFCNT"
Returns the value of the object's reference count.
.Sp
.Vb 1
\& U32 SvREFCNT(SV* sv)
.Ve
.IP "SvREFCNT_dec" 8
.IX Item "SvREFCNT_dec"
Decrements the reference count of the given \s-1SV\s0.
.Sp
.Vb 1
\& void SvREFCNT_dec(SV* sv)
.Ve
.IP "SvREFCNT_inc" 8
.IX Item "SvREFCNT_inc"
Increments the reference count of the given \s-1SV\s0.
.Sp
.Vb 1
\& SV* SvREFCNT_inc(SV* sv)
.Ve
.IP "SvROK" 8
.IX Item "SvROK"
Tests if the \s-1SV\s0 is an \s-1RV\s0.
.Sp
.Vb 1
\& bool SvROK(SV* sv)
.Ve
.IP "SvROK_off" 8
.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 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 Item "SvRV"
Dereferences an \s-1RV\s0 to return the \s-1SV\s0.
.Sp
.Vb 1
\& SV* SvRV(SV* sv)
.Ve
.IP "SvSTASH" 8
.IX Item "SvSTASH"
Returns the stash of the \s-1SV\s0.
.Sp
.Vb 1
\& HV* SvSTASH(SV* sv)
.Ve
.IP "SvTAINT" 8
.IX Item "SvTAINT"
Taints an \s-1SV\s0 if tainting is enabled
.Sp
.Vb 1
\& void SvTAINT(SV* sv)
.Ve
.IP "SvTAINTED" 8
.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 "SvTAINTED_off" 8
.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 Item "SvTAINTED_on"
Marks an \s-1SV\s0 as tainted.
.Sp
.Vb 1
\& void SvTAINTED_on(SV* sv)
.Ve
.IP "SvTRUE" 8
.IX Item "SvTRUE"
Returns a boolean indicating whether Perl would evaluate the \s-1SV\s0 as true or
false, defined or undefined. Does not handle 'get' magic.
.Sp
.Vb 1
\& bool SvTRUE(SV* sv)
.Ve
.IP "SvTYPE" 8
.IX Item "SvTYPE"
Returns the type of the \s-1SV\s0. See \f(CW\*(C`svtype\*(C'\fR.
.Sp
.Vb 1
\& svtype SvTYPE(SV* sv)
.Ve
.IP "SvUNLOCK" 8
.IX Item "SvUNLOCK"
Releases a mutual exclusion lock on sv if a suitable module
has been loaded.
.Sp
.Vb 1
\& void SvUNLOCK(SV* sv)
.Ve
.IP "SvUOK" 8
.IX Item "SvUOK"
Returns a boolean indicating whether the \s-1SV\s0 contains an unsigned integer.
.Sp
.Vb 1
\& void SvUOK(SV* sv)
.Ve
.IP "SvUPGRADE" 8
.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\*(C`svtype\*(C'\fR.
.Sp
.Vb 1
\& void SvUPGRADE(SV* sv, svtype type)
.Ve
.IP "SvUTF8" 8
.IX Item "SvUTF8"
Returns a boolean indicating whether the \s-1SV\s0 contains \s-1UTF\-8\s0 encoded data.
.Sp
.Vb 1
\& void SvUTF8(SV* sv)
.Ve
.IP "SvUTF8_off" 8
.IX Item "SvUTF8_off"
Unsets the \s-1UTF8\s0 status of an \s-1SV\s0.
.Sp
.Vb 1
\& void SvUTF8_off(SV *sv)
.Ve
.IP "SvUTF8_on" 8
.IX Item "SvUTF8_on"
Turn on the \s-1UTF8\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 Item "SvUV"
Coerces the given \s-1SV\s0 to an unsigned integer and returns it. See \f(CW\*(C`SvUVx\*(C'\fR
for a version which guarantees to evaluate sv only once.
.Sp
.Vb 1
\& UV SvUV(SV* sv)
.Ve
.IP "SvUVX" 8
.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 SvIOK is true. See also \f(CW\*(C`SvUV()\*(C'\fR.
.Sp
.Vb 1
\& UV SvUVX(SV* sv)
.Ve
.IP "SvUVx" 8
.IX Item "SvUVx"
Coerces the given \s-1SV\s0 to an unsigned integer and returns it. Guarantees to
evaluate sv only once. Use the more efficient \f(CW\*(C`SvUV\*(C'\fR otherwise.
.Sp
.Vb 1
\& UV SvUVx(SV* sv)
.Ve
.IP "sv_2bool" 8
.IX Item "sv_2bool"
This function is only called on magical items, and is only used by
\&\fIsv_true()\fR or its macro equivalent.
.Sp
.Vb 1
\& bool sv_2bool(SV* sv)
.Ve
.IP "sv_2cv" 8
.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.
.Sp
.Vb 1
\& CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref)
.Ve
.IP "sv_2io" 8
.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
.Vb 1
\& IO* sv_2io(SV* sv)
.Ve
.IP "sv_2iv" 8
.IX Item "sv_2iv"
Return the integer value of an \s-1SV\s0, doing any necessary string conversion,
magic etc. 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(SV* sv)
.Ve
.IP "sv_2mortal" 8
.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 \s-1FREETMPS\s0, or by an implicit call at places such as
statement boundaries. See also \f(CW\*(C`sv_newmortal\*(C'\fR and \f(CW\*(C`sv_mortalcopy\*(C'\fR.
.Sp
.Vb 1
\& SV* sv_2mortal(SV* sv)
.Ve
.IP "sv_2nv" 8
.IX Item "sv_2nv"
Return the num value of an \s-1SV\s0, doing any necessary string or integer
conversion, magic etc. 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(SV* sv)
.Ve
.IP "sv_2pvbyte" 8
.IX Item "sv_2pvbyte"
Return a pointer to the byte-encoded representation of the \s-1SV\s0, and set *lp
to its length. May cause the \s-1SV\s0 to be downgraded from \s-1UTF8\s0 as a
side\-effect.
.Sp
Usually accessed via the \f(CW\*(C`SvPVbyte\*(C'\fR macro.
.Sp
.Vb 1
\& char* sv_2pvbyte(SV* sv, STRLEN* lp)
.Ve
.IP "sv_2pvbyte_nolen" 8
.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-1UTF8\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" 8
.IX Item "sv_2pvutf8"
Return a pointer to the UTF8\-encoded representation of the \s-1SV\s0, and set *lp
to its length. May cause the \s-1SV\s0 to be upgraded to \s-1UTF8\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* lp)
.Ve
.IP "sv_2pvutf8_nolen" 8
.IX Item "sv_2pvutf8_nolen"
Return a pointer to the UTF8\-encoded representation of the \s-1SV\s0.
May cause the \s-1SV\s0 to be upgraded to \s-1UTF8\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_flags" 8
.IX Item "sv_2pv_flags"
Returns a pointer to the string value of an \s-1SV\s0, and sets *lp to its length.
If flags includes \s-1SV_GMAGIC\s0, does an \fImg_get()\fR first. Coerces sv 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 1
\& char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags)
.Ve
.IP "sv_2pv_nolen" 8
.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.
char* sv_2pv_nolen(SV* sv)
.IP "sv_2uv" 8
.IX Item "sv_2uv"
Return the unsigned integer value of an \s-1SV\s0, doing any necessary string
conversion, magic etc. 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(SV* sv)
.Ve
.IP "sv_backoff" 8
.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
\& int sv_backoff(SV* sv)
.Ve
.IP "sv_bless" 8
.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\*(C`gv_stashpv()\*(C'\fR). The reference count
of the \s-1SV\s0 is unaffected.
.Sp
.Vb 1
\& SV* sv_bless(SV* sv, HV* stash)
.Ve
.IP "sv_catpv" 8
.IX Item "sv_catpv"
Concatenates the string onto the end of the string which is in the \s-1SV\s0.
If the \s-1SV\s0 has the \s-1UTF8\s0 status set, then the bytes appended should be
valid \s-1UTF8\s0. Handles 'get' magic, but not 'set' magic. See \f(CW\*(C`sv_catpv_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_catpv(SV* sv, const char* ptr)
.Ve
.IP "sv_catpvf" 8
.IX Item "sv_catpvf"
Processes its arguments like \f(CW\*(C`sprintf\*(C'\fR and appends the formatted
output to an \s-1SV\s0. If the appended data contains \*(L"wide\*(R" characters
(including, but not limited to, SVs with a \s-1UTF\-8\s0 \s-1PV\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.
\&\f(CW\*(C`SvSETMAGIC()\*(C'\fR must typically be called after calling this function
to handle 'set' magic.
.Sp
.Vb 1
\& void sv_catpvf(SV* sv, const char* pat, ...)
.Ve
.IP "sv_catpvf_mg" 8
.IX Item "sv_catpvf_mg"
Like \f(CW\*(C`sv_catpvf\*(C'\fR, but also handles 'set' magic.
.Sp
.Vb 1
\& void sv_catpvf_mg(SV *sv, const char* pat, ...)
.Ve
.IP "sv_catpvn" 8
.IX Item "sv_catpvn"
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. If the \s-1SV\s0 has the \s-1UTF8\s0
status set, then the bytes appended should be valid \s-1UTF8\s0.
Handles 'get' magic, but not 'set' magic. See \f(CW\*(C`sv_catpvn_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_catpvn(SV* sv, const char* ptr, STRLEN len)
.Ve
.IP "sv_catpvn_flags" 8
.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. If the \s-1SV\s0 has the \s-1UTF8\s0
status set, then the bytes appended should be valid \s-1UTF8\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`dsv\*(C'\fR if
appropriate, else not. \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 1
\& void sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags)
.Ve
.IP "sv_catpvn_mg" 8
.IX Item "sv_catpvn_mg"
Like \f(CW\*(C`sv_catpvn\*(C'\fR, but also handles 'set' magic.
.Sp
.Vb 1
\& void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
.Ve
.IP "sv_catpv_mg" 8
.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 *sv, const char *ptr)
.Ve
.IP "sv_catsv" 8
.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. Modifies \f(CW\*(C`dsv\*(C'\fR but not \f(CW\*(C`ssv\*(C'\fR. Handles 'get' magic, but
not 'set' magic. See \f(CW\*(C`sv_catsv_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_catsv(SV* dsv, SV* ssv)
.Ve
.IP "sv_catsv_flags" 8
.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. Modifies \f(CW\*(C`dsv\*(C'\fR but not \f(CW\*(C`ssv\*(C'\fR. 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 the SVs if appropriate, else not. \f(CW\*(C`sv_catsv\*(C'\fR
and \f(CW\*(C`sv_catsv_nomg\*(C'\fR are implemented in terms of this function.
.Sp
.Vb 1
\& void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags)
.Ve
.IP "sv_catsv_mg" 8
.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 *dstr, SV *sstr)
.Ve
.IP "sv_chop" 8
.IX Item "sv_chop"
Efficient removal of characters from the beginning of the string buffer.
SvPOK(sv) must be true and the \f(CW\*(C`ptr\*(C'\fR must be a pointer to somewhere inside
the string buffer. The \f(CW\*(C`ptr\*(C'\fR becomes the first character of the adjusted
string. Uses the \*(L"\s-1OOK\s0 hack\*(R".
.Sp
.Vb 1
\& void sv_chop(SV* sv, char* ptr)
.Ve
.IP "sv_clear" 8
.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 \s-1REFCNT\s0 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* sv)
.Ve
.IP "sv_cmp" 8
.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 'use bytes' aware, handles get magic, and will
coerce its args to strings if necessary. See also \f(CW\*(C`sv_cmp_locale\*(C'\fR.
.Sp
.Vb 1
\& I32 sv_cmp(SV* sv1, SV* sv2)
.Ve
.IP "sv_cmp_locale" 8
.IX Item "sv_cmp_locale"
Compares the strings in two SVs in a locale-aware manner. Is \s-1UTF\-8\s0 and
\&'use bytes' aware, handles get magic, and will coerce its args to strings
if necessary. See also \f(CW\*(C`sv_cmp_locale\*(C'\fR. See also \f(CW\*(C`sv_cmp\*(C'\fR.
.Sp
.Vb 1
\& I32 sv_cmp_locale(SV* sv1, SV* sv2)
.Ve
.IP "sv_collxfrm" 8
.IX Item "sv_collxfrm"
Add Collate Transform magic to an \s-1SV\s0 if it doesn't already have it.
.Sp
Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the
scalar data of the variable, but transformed to such a format that a normal
memory comparison can be used to compare the data according to the locale
settings.
.Sp
.Vb 1
\& char* sv_collxfrm(SV* sv, STRLEN* nxp)
.Ve
.IP "sv_copypv" 8
.IX Item "sv_copypv"
Copies a stringified representation of the source \s-1SV\s0 into the
destination \s-1SV\s0. Automatically performs any necessary mg_get and
coercion of numeric values into strings. Guaranteed to preserve
\&\s-1UTF\-8\s0 flag even from overloaded objects. Similar in nature to
sv_2pv[_flags] but operates directly on an \s-1SV\s0 instead of just the
string. Mostly uses sv_2pv_flags 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* dsv, SV* ssv)
.Ve
.IP "sv_dec" 8
.IX Item "sv_dec"
Auto-decrement of the value in the \s-1SV\s0, doing string to numeric conversion
if necessary. Handles 'get' magic.
.Sp
.Vb 1
\& void sv_dec(SV* sv)
.Ve
.IP "sv_derived_from" 8
.IX Item "sv_derived_from"
Returns a boolean indicating whether the \s-1SV\s0 is derived from the specified
class. This is the function that implements \f(CW\*(C`UNIVERSAL::isa\*(C'\fR. It works
for class names as well as for objects.
.Sp
.Vb 1
\& bool sv_derived_from(SV* sv, const char* name)
.Ve
.IP "sv_eq" 8
.IX Item "sv_eq"
Returns a boolean indicating whether the strings in the two SVs are
identical. Is \s-1UTF\-8\s0 and 'use bytes' 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_force_normal" 8
.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 xpvmg. See also \f(CW\*(C`sv_force_normal_flags\*(C'\fR.
.Sp
.Vb 1
\& void sv_force_normal(SV *sv)
.Ve
.IP "sv_force_normal_flags" 8
.IX Item "sv_force_normal_flags"
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 xpvmg. The \f(CW\*(C`flags\*(C'\fR parameter gets passed to \f(CW\*(C`sv_unref_flags()\*(C'\fR
when unrefing. \f(CW\*(C`sv_force_normal\*(C'\fR calls this function with flags set to 0.
.Sp
.Vb 1
\& void sv_force_normal_flags(SV *sv, U32 flags)
.Ve
.IP "sv_free" 8
.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, deallocate 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* sv)
.Ve
.IP "sv_gets" 8
.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.
.Sp
.Vb 1
\& char* sv_gets(SV* sv, PerlIO* fp, I32 append)
.Ve
.IP "sv_grow" 8
.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* sv, STRLEN newlen)
.Ve
.IP "sv_inc" 8
.IX Item "sv_inc"
Auto-increment of the value in the \s-1SV\s0, doing string to numeric conversion
if necessary. Handles 'get' magic.
.Sp
.Vb 1
\& void sv_inc(SV* sv)
.Ve
.IP "sv_insert" 8
.IX Item "sv_insert"
Inserts a string at the specified offset/length within the \s-1SV\s0. Similar to
the Perl \fIsubstr()\fR function.
.Sp
.Vb 1
\& void sv_insert(SV* bigsv, STRLEN offset, STRLEN len, char* little, STRLEN littlelen)
.Ve
.IP "sv_isa" 8
.IX Item "sv_isa"
Returns a boolean indicating whether the \s-1SV\s0 is blessed into the specified
class. This does not check for subtypes; use \f(CW\*(C`sv_derived_from\*(C'\fR to verify
an inheritance relationship.
.Sp
.Vb 1
\& int sv_isa(SV* sv, const char* name)
.Ve
.IP "sv_isobject" 8
.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 "sv_iv" 8
.IX Item "sv_iv"
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_len" 8
.IX Item "sv_len"
Returns the length of the string in the \s-1SV\s0. Handles magic and type
coercion. See also \f(CW\*(C`SvCUR\*(C'\fR, which gives raw access to the xpv_cur slot.
.Sp
.Vb 1
\& STRLEN sv_len(SV* sv)
.Ve
.IP "sv_len_utf8" 8
.IX Item "sv_len_utf8"
Returns the number of characters in the string in an \s-1SV\s0, counting wide
\&\s-1UTF8\s0 bytes as a single character. Handles magic and type coercion.
.Sp
.Vb 1
\& STRLEN sv_len_utf8(SV* sv)
.Ve
.IP "sv_magic" 8
.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
.Vb 1
\& void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)
.Ve
.IP "sv_magicext" 8
.IX Item "sv_magicext"
Adds magic to an \s-1SV\s0, upgrading it if necessary. Applies the
supplied vtable and returns pointer to the magic added.
.Sp
Note that sv_magicext will allow things that sv_magic will not.
In particular you can add magic to SvREADONLY SVs and and more than
one instance of the same 'how'
.Sp
I \f(CW\*(C`namelen\*(C'\fR is greater then zero then a \fIsavepvn()\fR \fIcopy\fR of \f(CW\*(C`name\*(C'\fR is stored,
if \f(CW\*(C`namelen\*(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 && namelen == HEf_SVKEY)\*(C'\fR then \f(CW\*(C`name\*(C'\fR is assumed to contain
an \f(CW\*(C`SV*\*(C'\fR and has its \s-1REFCNT\s0 incremented
.Sp
(This is now used as a subroutine by sv_magic.)
.Sp
.Vb 1
\& MAGIC * sv_magicext(SV* sv, SV* obj, int how, MGVTBL *vtbl, const char* name, I32 namlen )
.Ve
.IP "sv_mortalcopy" 8
.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 \s-1FREETMPS\s0, or by an implicit call at places such as
statement boundaries. See also \f(CW\*(C`sv_newmortal\*(C'\fR and \f(CW\*(C`sv_2mortal\*(C'\fR.
.Sp
.Vb 1
\& SV* sv_mortalcopy(SV* oldsv)
.Ve
.IP "sv_newmortal" 8
.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
\&\s-1FREETMPS\s0, or by an implicit call at places such as statement boundaries.
See also \f(CW\*(C`sv_mortalcopy\*(C'\fR and \f(CW\*(C`sv_2mortal\*(C'\fR.
.Sp
.Vb 1
\& SV* sv_newmortal()
.Ve
.IP "sv_newref" 8
.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* sv)
.Ve
.IP "sv_nolocking" 8
.IX Item "sv_nolocking"
Dummy routine which \*(L"locks\*(R" an \s-1SV\s0 when there is no locking module present.
Exists to avoid test for a \s-1NULL\s0 function pointer and because it could potentially warn under
some level of strict\-ness.
.Sp
.Vb 1
\& void sv_nolocking(SV *)
.Ve
.IP "sv_nosharing" 8
.IX Item "sv_nosharing"
Dummy routine which \*(L"shares\*(R" an \s-1SV\s0 when there is no sharing module present.
Exists to avoid test for a \s-1NULL\s0 function pointer and because it could potentially warn under
some level of strict\-ness.
.Sp
.Vb 1
\& void sv_nosharing(SV *)
.Ve
.IP "sv_nounlocking" 8
.IX Item "sv_nounlocking"
Dummy routine which \*(L"unlocks\*(R" an \s-1SV\s0 when there is no locking module present.
Exists to avoid test for a \s-1NULL\s0 function pointer and because it could potentially warn under
some level of strict\-ness.
.Sp
.Vb 1
\& void sv_nounlocking(SV *)
.Ve
.IP "sv_nv" 8
.IX Item "sv_nv"
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_pos_b2u" 8
.IX Item "sv_pos_b2u"
Converts the value pointed to by offsetp from a count of bytes from the
start of the string, to a count of the equivalent number of \s-1UTF8\s0 chars.
Handles magic and type coercion.
.Sp
.Vb 1
\& void sv_pos_b2u(SV* sv, I32* offsetp)
.Ve
.IP "sv_pos_u2b" 8
.IX Item "sv_pos_u2b"
Converts the value pointed to by offsetp from a count of \s-1UTF8\s0 chars from
the start of the string, to a count of the equivalent number of bytes; if
lenp is non\-zero, it does the same to lenp, but this time starting from
the offset, rather than from the start of the string. Handles magic and
type coercion.
.Sp
.Vb 1
\& void sv_pos_u2b(SV* sv, I32* offsetp, I32* lenp)
.Ve
.IP "sv_pv" 8
.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 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 Item "sv_pvbyten"
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 *len)
.Ve
.IP "sv_pvbyten_force" 8
.IX Item "sv_pvbyten_force"
A private implementation of the \f(CW\*(C`SvPVbytex_force\*(C'\fR macro for compilers
which can't cope with complex macro expressions. Always use the macro
instead.
.Sp
.Vb 1
\& char* sv_pvbyten_force(SV* sv, STRLEN* lp)
.Ve
.IP "sv_pvn" 8
.IX Item "sv_pvn"
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 *len)
.Ve
.IP "sv_pvn_force" 8
.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 Item "sv_pvn_force_flags"
Get a sensible string out of the \s-1SV\s0 somehow.
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. \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\*(C`SvPV_force\*(C'\fR and \f(CW\*(C`SvPV_force_nomg\*(C'\fR
.Sp
.Vb 1
\& char* sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags)
.Ve
.IP "sv_pvutf8" 8
.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 Item "sv_pvutf8n"
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 *len)
.Ve
.IP "sv_pvutf8n_force" 8
.IX Item "sv_pvutf8n_force"
A private implementation of the \f(CW\*(C`SvPVutf8_force\*(C'\fR macro for compilers
which can't cope with complex macro expressions. Always use the macro
instead.
.Sp
.Vb 1
\& char* sv_pvutf8n_force(SV* sv, STRLEN* lp)
.Ve
.IP "sv_reftype" 8
.IX Item "sv_reftype"
Returns a string describing what the \s-1SV\s0 is a reference to.
.Sp
.Vb 1
\& char* sv_reftype(SV* sv, int ob)
.Ve
.IP "sv_replace" 8
.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* sv, SV* nsv)
.Ve
.IP "sv_report_used" 8
.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 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(char* s, HV* stash)
.Ve
.IP "sv_rvweaken" 8
.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.
.Sp
.Vb 1
\& SV* sv_rvweaken(SV *sv)
.Ve
.IP "sv_setiv" 8
.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\*(C`sv_setiv_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_setiv(SV* sv, IV num)
.Ve
.IP "sv_setiv_mg" 8
.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 *sv, IV i)
.Ve
.IP "sv_setnv" 8
.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\*(C`sv_setnv_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_setnv(SV* sv, NV num)
.Ve
.IP "sv_setnv_mg" 8
.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 *sv, NV num)
.Ve
.IP "sv_setpv" 8
.IX Item "sv_setpv"
Copies a string into an \s-1SV\s0. The string must be null\-terminated. Does not
handle 'set' magic. See \f(CW\*(C`sv_setpv_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_setpv(SV* sv, const char* ptr)
.Ve
.IP "sv_setpvf" 8
.IX Item "sv_setpvf"
Processes its arguments like \f(CW\*(C`sprintf\*(C'\fR and sets an \s-1SV\s0 to the formatted
output. Does not handle 'set' magic. See \f(CW\*(C`sv_setpvf_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_setpvf(SV* sv, const char* pat, ...)
.Ve
.IP "sv_setpvf_mg" 8
.IX Item "sv_setpvf_mg"
Like \f(CW\*(C`sv_setpvf\*(C'\fR, but also handles 'set' magic.
.Sp
.Vb 1
\& void sv_setpvf_mg(SV *sv, const char* pat, ...)
.Ve
.IP "sv_setpvn" 8
.IX Item "sv_setpvn"
Copies a string into an \s-1SV\s0. The \f(CW\*(C`len\*(C'\fR parameter indicates the number of
bytes to be copied. Does not handle 'set' magic. See \f(CW\*(C`sv_setpvn_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_setpvn(SV* sv, const char* ptr, STRLEN len)
.Ve
.IP "sv_setpvn_mg" 8
.IX Item "sv_setpvn_mg"
Like \f(CW\*(C`sv_setpvn\*(C'\fR, but also handles 'set' magic.
.Sp
.Vb 1
\& void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len)
.Ve
.IP "sv_setpv_mg" 8
.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 *sv, const char *ptr)
.Ve
.IP "sv_setref_iv" 8
.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`Nullch\*(C'\fR to avoid the blessing. The new \s-1SV\s0
will be returned and will have a reference count of 1.
.Sp
.Vb 1
\& SV* sv_setref_iv(SV* rv, const char* classname, IV iv)
.Ve
.IP "sv_setref_nv" 8
.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`Nullch\*(C'\fR to avoid the blessing. The new \s-1SV\s0
will be returned and will have a reference count of 1.
.Sp
.Vb 1
\& SV* sv_setref_nv(SV* rv, const char* classname, NV nv)
.Ve
.IP "sv_setref_pv" 8
.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 \s-1NULL\s0 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`Nullch\*(C'\fR to avoid the blessing. The new \s-1SV\s0
will be returned and will have a reference count of 1.
.Sp
Do not use with other Perl types such as \s-1HV\s0, \s-1AV\s0, \s-1SV\s0, \s-1CV\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 1
\& SV* sv_setref_pv(SV* rv, const char* classname, void* pv)
.Ve
.IP "sv_setref_pvn" 8
.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`Nullch\*(C'\fR to avoid the blessing. The new \s-1SV\s0 will be returned and will have
a reference count of 1.
.Sp
Note that \f(CW\*(C`sv_setref_pv\*(C'\fR copies the pointer while this copies the string.
.Sp
.Vb 1
\& SV* sv_setref_pvn(SV* rv, const char* classname, char* pv, STRLEN n)
.Ve
.IP "sv_setref_uv" 8
.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`Nullch\*(C'\fR to avoid the blessing. The new \s-1SV\s0
will be returned and will have a reference count of 1.
.Sp
.Vb 1
\& SV* sv_setref_uv(SV* rv, const char* classname, UV uv)
.Ve
.IP "sv_setsv" 8
.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.
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* dsv, SV* ssv)
.Ve
.IP "sv_setsv_flags" 8
.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. \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 1
\& void sv_setsv_flags(SV* dsv, SV* ssv, I32 flags)
.Ve
.IP "sv_setsv_mg" 8
.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 *dstr, SV *sstr)
.Ve
.IP "sv_setuv" 8
.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\*(C`sv_setuv_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_setuv(SV* sv, UV num)
.Ve
.IP "sv_setuv_mg" 8
.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 *sv, UV u)
.Ve
.IP "sv_taint" 8
.IX Item "sv_taint"
Taint an \s-1SV\s0. Use \f(CW\*(C`SvTAINTED_on\*(C'\fR instead.
void sv_taint(SV* sv)
.IP "sv_tainted" 8
.IX Item "sv_tainted"
Test an \s-1SV\s0 for taintedness. Use \f(CW\*(C`SvTAINTED\*(C'\fR instead.
bool sv_tainted(SV* sv)
.IP "sv_true" 8
.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 *sv)
.Ve
.IP "sv_unmagic" 8
.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* sv, int type)
.Ve
.IP "sv_unref" 8
.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\*(C`SvROK_off\*(C'\fR.
.Sp
.Vb 1
\& void sv_unref(SV* sv)
.Ve
.IP "sv_unref_flags" 8
.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\*(C`SvROK_off\*(C'\fR.
.Sp
.Vb 1
\& void sv_unref_flags(SV* sv, U32 flags)
.Ve
.IP "sv_untaint" 8
.IX Item "sv_untaint"
Untaint an \s-1SV\s0. Use \f(CW\*(C`SvTAINTED_off\*(C'\fR instead.
void sv_untaint(SV* sv)
.IP "sv_upgrade" 8
.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.
You generally want to use the \f(CW\*(C`SvUPGRADE\*(C'\fR macro wrapper. See also \f(CW\*(C`svtype\*(C'\fR.
.Sp
.Vb 1
\& bool sv_upgrade(SV* sv, U32 mt)
.Ve
.IP "sv_usepvn" 8
.IX Item "sv_usepvn"
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.
The \f(CW\*(C`ptr\*(C'\fR should point to memory that was allocated by \f(CW\*(C`malloc\*(C'\fR. The
string length, \f(CW\*(C`len\*(C'\fR, must be supplied. This function will realloc 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 sv_usepvn. Does not handle 'set' magic.
See \f(CW\*(C`sv_usepvn_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_usepvn(SV* sv, char* ptr, STRLEN len)
.Ve
.IP "sv_usepvn_mg" 8
.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_utf8_decode" 8
.IX Item "sv_utf8_decode"
Convert the octets in the \s-1PV\s0 from \s-1UTF\-8\s0 to chars. Scan for validity and then
turn off SvUTF8 if needed so that we see characters. Used as a building block
for decode_utf8 in Encode.xs
.Sp
\&\s-1NOTE:\s0 this function is experimental and may change or be
removed without notice.
.Sp
.Vb 1
\& bool sv_utf8_decode(SV *sv)
.Ve
.IP "sv_utf8_downgrade" 8
.IX Item "sv_utf8_downgrade"
Attempt to convert the \s-1PV\s0 of an \s-1SV\s0 from UTF8\-encoded to byte encoding.
This may not be possible if the \s-1PV\s0 contains non-byte encoding characters;
if this is the case, either returns false or, if \f(CW\*(C`fail_ok\*(C'\fR is not
true, croaks.
.Sp
This is not as a general purpose Unicode to byte encoding interface:
use the Encode extension for that.
.Sp
\&\s-1NOTE:\s0 this function is experimental and may change or be
removed without notice.
.Sp
.Vb 1
\& bool sv_utf8_downgrade(SV *sv, bool fail_ok)
.Ve
.IP "sv_utf8_encode" 8
.IX Item "sv_utf8_encode"
Convert the \s-1PV\s0 of an \s-1SV\s0 to UTF8\-encoded, but then turn off the \f(CW\*(C`SvUTF8\*(C'\fR
flag so that it looks like octets again. Used as a building block
for encode_utf8 in Encode.xs
.Sp
.Vb 1
\& void sv_utf8_encode(SV *sv)
.Ve
.IP "sv_utf8_upgrade" 8
.IX Item "sv_utf8_upgrade"
Convert the \s-1PV\s0 of an \s-1SV\s0 to its UTF8\-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 have hibit clear.
.Sp
This is not as 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 Item "sv_utf8_upgrade_flags"
Convert the \s-1PV\s0 of an \s-1SV\s0 to its UTF8\-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 have hibit clear. 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. \f(CW\*(C`sv_utf8_upgrade\*(C'\fR and
\&\f(CW\*(C`sv_utf8_upgrade_nomg\*(C'\fR are implemented in terms of this function.
.Sp
This is not as a general purpose byte encoding to Unicode interface:
use the Encode extension for that.
.Sp
.Vb 1
\& STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags)
.Ve
.IP "sv_uv" 8
.IX Item "sv_uv"
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 "sv_vcatpvfn" 8
.IX Item "sv_vcatpvfn"
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 (\s-1NULL\s0). 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
Usually used via one of its frontends \f(CW\*(C`sv_catpvf\*(C'\fR and \f(CW\*(C`sv_catpvf_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
.Ve
.IP "sv_vsetpvfn" 8
.IX Item "sv_vsetpvfn"
Works like \f(CW\*(C`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_setpvf\*(C'\fR and \f(CW\*(C`sv_setpvf_mg\*(C'\fR.
.Sp
.Vb 1
\& void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
.Ve
.SH "Unicode Support"
.IX Header "Unicode Support"
.IP "bytes_from_utf8" 8
.IX Item "bytes_from_utf8"
Converts a string \f(CW\*(C`s\*(C'\fR of length \f(CW\*(C`len\*(C'\fR from \s-1UTF8\s0 into byte encoding.
Unlike <utf8_to_bytes> but like \f(CW\*(C`bytes_to_utf8\*(C'\fR, returns a pointer to
the newly-created string, and updates \f(CW\*(C`len\*(C'\fR to contain the new
length. Returns the original string if no conversion occurs, \f(CW\*(C`len\*(C'\fR
is unchanged. Do nothing if \f(CW\*(C`is_utf8\*(C'\fR points to 0. Sets \f(CW\*(C`is_utf8\*(C'\fR to
0 if \f(CW\*(C`s\*(C'\fR is converted or contains all 7bit characters.
.Sp
\&\s-1NOTE:\s0 this function is experimental and may change or be
removed without notice.
.Sp
.Vb 1
\& U8* bytes_from_utf8(U8 *s, STRLEN *len, bool *is_utf8)
.Ve
.IP "bytes_to_utf8" 8
.IX Item "bytes_to_utf8"
Converts a string \f(CW\*(C`s\*(C'\fR of length \f(CW\*(C`len\*(C'\fR from \s-1ASCII\s0 into \s-1UTF8\s0 encoding.
Returns a pointer to the newly-created string, and sets \f(CW\*(C`len\*(C'\fR to
reflect the new length.
.Sp
\&\s-1NOTE:\s0 this function is experimental and may change or be
removed without notice.
.Sp
.Vb 1
\& U8* bytes_to_utf8(U8 *s, STRLEN *len)
.Ve
.IP "ibcmp_utf8" 8
.IX Item "ibcmp_utf8"
Return true if the strings s1 and s2 differ case\-insensitively, false
if not (if they are equal case\-insensitively). If u1 is true, the
string s1 is assumed to be in UTF\-8\-encoded Unicode. If u2 is true,
the string s2 is assumed to be in UTF\-8\-encoded Unicode. If u1 or u2
are false, the respective string is assumed to be in native 8\-bit
encoding.
.Sp
If the pe1 and pe2 are non\-NULL, the scanning pointers will be copied
in there (they will point at the beginning of the \fInext\fR character).
If the pointers behind pe1 or pe2 are non\-NULL, they are the end
pointers beyond which scanning will not continue under any
circustances. If the byte lengths l1 and l2 are non\-zero, s1+l1 and
s2+l2 will be used as goal end pointers that will also stop the scan,
and which qualify towards defining a successful match: all the scans
that define an explicit length must reach their goal pointers for
a match to succeed).
.Sp
For case\-insensitiveness, the \*(L"casefolding\*(R" of Unicode is used
instead of upper/lowercasing both the characters, see
http://www.unicode.org/unicode/reports/tr21/ (Case Mappings).
.Sp
.Vb 1
\& I32 ibcmp_utf8(const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2)
.Ve
.IP "is_utf8_char" 8
.IX Item "is_utf8_char"
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) 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
.Vb 1
\& STRLEN is_utf8_char(U8 *p)
.Ve
.IP "is_utf8_string" 8
.IX Item "is_utf8_string"
Returns true if first \f(CW\*(C`len\*(C'\fR bytes of the given string form a valid \s-1UTF8\s0
string, false otherwise. Note that 'a valid \s-1UTF8\s0 string' does not mean
\&'a string that contains \s-1UTF8\s0' because a valid \s-1ASCII\s0 string is a valid
\&\s-1UTF8\s0 string.
.Sp
.Vb 1
\& bool is_utf8_string(U8 *s, STRLEN len)
.Ve
.IP "pv_uni_display" 8
.IX Item "pv_uni_display"
Build to the scalar dsv a displayable version of the string spv,
length len, the displayable version being at most pvlim bytes long
(if longer, the rest is truncated and \*(L"...\*(R" will be appended).
.Sp
The flags argument can have \s-1UNI_DISPLAY_ISPRINT\s0 set to display
\&\fIisPRINT()\fRable characters as themselves, \s-1UNI_DISPLAY_BACKSLASH\s0
to display the \e\e[nrfta\e\e] as the backslashed versions (like '\en')
(\s-1UNI_DISPLAY_BACKSLASH\s0 is preferred over \s-1UNI_DISPLAY_ISPRINT\s0 for \e\e).
\&\s-1UNI_DISPLAY_QQ\s0 (and its alias \s-1UNI_DISPLAY_REGEX\s0) have both
\&\s-1UNI_DISPLAY_BACKSLASH\s0 and \s-1UNI_DISPLAY_ISPRINT\s0 turned on.
.Sp
The pointer to the \s-1PV\s0 of the dsv is returned.
.Sp
.Vb 1
\& char* pv_uni_display(SV *dsv, U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
.Ve
.IP "sv_recode_to_utf8" 8
.IX Item "sv_recode_to_utf8"
The encoding is assumed to be an Encode object, on entry the \s-1PV\s0
of the sv is assumed to be octets in that encoding, and the sv
will be converted into Unicode (and \s-1UTF\-8\s0).
.Sp
If the sv already is \s-1UTF\-8\s0 (or if it is not \s-1POK\s0), or if the encoding
is not a reference, nothing is done to the sv. If the encoding is not
an \f(CW\*(C`Encode::XS\*(C'\fR Encoding object, bad things will happen.
(See \fIlib/encoding.pm\fR and Encode).
.Sp
The \s-1PV\s0 of the sv is returned.
.Sp
.Vb 1
\& char* sv_recode_to_utf8(SV* sv, SV *encoding)
.Ve
.IP "sv_uni_display" 8
.IX Item "sv_uni_display"
Build to the scalar dsv a displayable version of the scalar sv,
the displayable version being at most pvlim bytes long
(if longer, the rest is truncated and \*(L"...\*(R" will be appended).
.Sp
The flags argument is as in \fIpv_uni_display()\fR.
.Sp
The pointer to the \s-1PV\s0 of the dsv is returned.
.Sp
.Vb 1
\& char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
.Ve
.IP "to_utf8_case" 8
.IX Item "to_utf8_case"
The \*(L"p\*(R" contains the pointer to the \s-1UTF\-8\s0 string encoding
the character that is being converted.
.Sp
The \*(L"ustrp\*(R" is a pointer to the character buffer to put the
conversion result to. The \*(L"lenp\*(R" is a pointer to the length
of the result.
.Sp
The \*(L"swashp\*(R" is a pointer to the swash to use.
.Sp
Both the special and normal mappings are stored lib/unicore/To/Foo.pl,
and loaded by \s-1SWASHGET\s0, using lib/utf8_heavy.pl. The special (usually,
but not always, a multicharacter mapping), is tried first.
.Sp
The \*(L"special\*(R" is a string like \*(L"utf8::ToSpecLower\*(R", which means the
hash \f(CW%utf8::ToSpecLower\fR. The access to the hash is through
\&\fIPerl_to_utf8_case()\fR.
.Sp
The \*(L"normal\*(R" is a string like \*(L"ToLower\*(R" which means the swash
\&\f(CW%utf8::ToLower\fR.
.Sp
.Vb 1
\& UV to_utf8_case(U8 *p, U8* ustrp, STRLEN *lenp, SV **swash, char *normal, char *special)
.Ve
.IP "to_utf8_fold" 8
.IX Item "to_utf8_fold"
Convert the \s-1UTF\-8\s0 encoded character at p to its foldcase version and
store that in \s-1UTF\-8\s0 in ustrp and its length in bytes in lenp. Note
that the ustrp needs to be at least \s-1UTF8_MAXLEN_FOLD+1\s0 bytes since the
foldcase version may be longer than the original character (up to
three characters).
.Sp
The first character of the foldcased version is returned
(but note, as explained above, that there may be more.)
.Sp
.Vb 1
\& UV to_utf8_fold(U8 *p, U8* ustrp, STRLEN *lenp)
.Ve
.IP "to_utf8_lower" 8
.IX Item "to_utf8_lower"
Convert the \s-1UTF\-8\s0 encoded character at p to its lowercase version and
store that in \s-1UTF\-8\s0 in ustrp and its length in bytes in lenp. Note
that the ustrp needs to be at least \s-1UTF8_MAXLEN_UCLC+1\s0 bytes since the
lowercase version may be longer than the original character (up to two
characters).
.Sp
The first character of the lowercased version is returned
(but note, as explained above, that there may be more.)
.Sp
.Vb 1
\& UV to_utf8_lower(U8 *p, U8* ustrp, STRLEN *lenp)
.Ve
.IP "to_utf8_title" 8
.IX Item "to_utf8_title"
Convert the \s-1UTF\-8\s0 encoded character at p to its titlecase version and
store that in \s-1UTF\-8\s0 in ustrp and its length in bytes in lenp. Note
that the ustrp needs to be at least \s-1UTF8_MAXLEN_UCLC+1\s0 bytes since the
titlecase version may be longer than the original character (up to two
characters).
.Sp
The first character of the titlecased version is returned
(but note, as explained above, that there may be more.)
.Sp
.Vb 1
\& UV to_utf8_title(U8 *p, U8* ustrp, STRLEN *lenp)
.Ve
.IP "to_utf8_upper" 8
.IX Item "to_utf8_upper"
Convert the \s-1UTF\-8\s0 encoded character at p to its uppercase version and
store that in \s-1UTF\-8\s0 in ustrp and its length in bytes in lenp. Note
that the ustrp needs to be at least \s-1UTF8_MAXLEN_UCLC+1\s0 bytes since the
uppercase version may be longer than the original character (up to two
characters).
.Sp
The first character of the uppercased version is returned
(but note, as explained above, that there may be more.)
.Sp
.Vb 1
\& UV to_utf8_upper(U8 *p, U8* ustrp, STRLEN *lenp)
.Ve
.IP "utf8n_to_uvchr" 8
.IX Item "utf8n_to_uvchr"
Returns the native character value of the first character in the string \f(CW\*(C`s\*(C'\fR
which is assumed to be in \s-1UTF8\s0 encoding; \f(CW\*(C`retlen\*(C'\fR will be set to the
length, in bytes, of that character.
.Sp
Allows length and flags to be passed to low level routine.
.Sp
.Vb 1
\& UV utf8n_to_uvchr(U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags)
.Ve
.IP "utf8n_to_uvuni" 8
.IX Item "utf8n_to_uvuni"
Bottom level \s-1UTF\-8\s0 decode routine.
Returns the unicode code point value of the first character in the string \f(CW\*(C`s\*(C'\fR
which is assumed to be in \s-1UTF8\s0 encoding and no longer than \f(CW\*(C`curlen\*(C'\fR;
\&\f(CW\*(C`retlen\*(C'\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-1UTF8\s0 character, the behaviour
is dependent on the value of \f(CW\*(C`flags\*(C'\fR: if it contains \s-1UTF8_CHECK_ONLY\s0,
it is assumed 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 and return zero. If the
\&\f(CW\*(C`flags\*(C'\fR does not contain \s-1UTF8_CHECK_ONLY\s0, warnings about
malformations will be given, \f(CW\*(C`retlen\*(C'\fR will be set to the expected
length of the \s-1UTF\-8\s0 character in bytes, and zero will be returned.
.Sp
The \f(CW\*(C`flags\*(C'\fR can also contain various flags to allow deviations from
the strict \s-1UTF\-8\s0 encoding (see \fIutf8.h\fR).
.Sp
Most code should use \fIutf8_to_uvchr()\fR rather than call this directly.
.Sp
.Vb 1
\& UV utf8n_to_uvuni(U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags)
.Ve
.IP "utf8_distance" 8
.IX Item "utf8_distance"
Returns the number of \s-1UTF8\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(U8 *a, U8 *b)
.Ve
.IP "utf8_hop" 8
.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(U8 *s, I32 off)
.Ve
.IP "utf8_length" 8
.IX Item "utf8_length"
Return the length of the \s-1UTF\-8\s0 char encoded string \f(CW\*(C`s\*(C'\fR in characters.
Stops at \f(CW\*(C`e\*(C'\fR (inclusive). If \f(CW\*(C`e < s\*(C'\fR or if the scan would end
up past \f(CW\*(C`e\*(C'\fR, croaks.
.Sp
.Vb 1
\& STRLEN utf8_length(U8* s, U8 *e)
.Ve
.IP "utf8_to_bytes" 8
.IX Item "utf8_to_bytes"
Converts a string \f(CW\*(C`s\*(C'\fR of length \f(CW\*(C`len\*(C'\fR from \s-1UTF8\s0 into byte encoding.
Unlike \f(CW\*(C`bytes_to_utf8\*(C'\fR, this over-writes the original string, and
updates len to contain the new length.
Returns zero on failure, setting \f(CW\*(C`len\*(C'\fR to \-1.
.Sp
\&\s-1NOTE:\s0 this function is experimental and may change or be
removed without notice.
.Sp
.Vb 1
\& U8* utf8_to_bytes(U8 *s, STRLEN *len)
.Ve
.IP "utf8_to_uvchr" 8
.IX Item "utf8_to_uvchr"
Returns the native character value of the first character in the string \f(CW\*(C`s\*(C'\fR
which is assumed to be in \s-1UTF8\s0 encoding; \f(CW\*(C`retlen\*(C'\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-1UTF8\s0 character, zero is
returned and retlen is set, if possible, to \-1.
.Sp
.Vb 1
\& UV utf8_to_uvchr(U8 *s, STRLEN* retlen)
.Ve
.IP "utf8_to_uvuni" 8
.IX Item "utf8_to_uvuni"
Returns the Unicode code point of the first character in the string \f(CW\*(C`s\*(C'\fR
which is assumed to be in \s-1UTF8\s0 encoding; \f(CW\*(C`retlen\*(C'\fR will be set to the
length, in bytes, of that character.
.Sp
This function should only be used when returned \s-1UV\s0 is considered
an index into the Unicode semantic tables (e.g. swashes).
.Sp
If \f(CW\*(C`s\*(C'\fR does not point to a well-formed \s-1UTF8\s0 character, zero is
returned and retlen is set, if possible, to \-1.
.Sp
.Vb 1
\& UV utf8_to_uvuni(U8 *s, STRLEN* retlen)
.Ve
.IP "uvchr_to_utf8" 8
.IX Item "uvchr_to_utf8"
Adds the \s-1UTF8\s0 representation of the Native codepoint \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 be have at least \f(CW\*(C`UTF8_MAXLEN+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
.Vb 1
\& U8* uvchr_to_utf8(U8 *d, UV uv)
.Ve
.IP "uvuni_to_utf8_flags" 8
.IX Item "uvuni_to_utf8_flags"
Adds the \s-1UTF8\s0 representation of the Unicode codepoint \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 be have at least \f(CW\*(C`UTF8_MAXLEN+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 = uvuni_to_utf8_flags(d, uv, flags);
.Ve
.Sp
or, in most cases,
.Sp
.Vb 1
\& d = uvuni_to_utf8(d, uv);
.Ve
.Sp
(which is equivalent to)
.Sp
.Vb 1
\& d = uvuni_to_utf8_flags(d, uv, 0);
.Ve
.Sp
is the recommended Unicode-aware way of saying
.Sp
.Vb 1
\& *(d++) = uv;
.Ve
.Sp
.Vb 1
\& U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags)
.Ve
.ie n .SH "Variables created by ""xsubpp""\fP and \f(CW""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 "ax" 8
.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 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\*(C`THIS\*(C'\fR.
.Sp
.Vb 1
\& char* CLASS
.Ve
.IP "dAX" 8
.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 "dITEMS" 8
.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 "dXSARGS" 8
.IX Item "dXSARGS"
Sets up stack and mark pointers for an \s-1XSUB\s0, calling dSP and dMARK.
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 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 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 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 "newXSproto" 8
.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-1RETVAL\s0" 8
.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 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 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\*(C`CLASS\*(C'\fR and
\&\*(L"Using \s-1XS\s0 With \*(C+\*(R" in perlxs.
.Sp
.Vb 1
\& (whatever) THIS
.Ve
.IP "\s-1XS\s0" 8
.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.
.IP "\s-1XSRETURN_EMPTY\s0" 8
.IX Item "XSRETURN_EMPTY"
Return an empty list from an \s-1XSUB\s0 immediately.
.Sp
.Vb 1
\& XSRETURN_EMPTY;
.Ve
.IP "\s-1XS_VERSION\s0" 8
.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\*(C`XS_VERSION_BOOTCHECK\*(C'\fR.
.IP "\s-1XS_VERSION_BOOTCHECK\s0" 8
.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"
.IP "croak" 8
.IX Item "croak"
This is the XSUB\-writer's interface to Perl's \f(CW\*(C`die\*(C'\fR function.
Normally use this function the same way you use the C \f(CW\*(C`printf\*(C'\fR
function. See \f(CW\*(C`warn\*(C'\fR.
.Sp
If you want to throw an exception object, assign the object to
\&\f(CW$@\fR and then pass \f(CW\*(C`Nullch\*(C'\fR to \fIcroak()\fR:
.Sp
.Vb 3
\& errsv = get_sv("@", TRUE);
\& sv_setsv(errsv, exception_object);
\& croak(Nullch);
.Ve
.Sp
.Vb 1
\& void croak(const char* pat, ...)
.Ve
.IP "warn" 8
.IX Item "warn"
This is the XSUB\-writer's interface to Perl's \f(CW\*(C`warn\*(C'\fR function. Use this
function the same way you use the C \f(CW\*(C`printf\*(C'\fR function. See
\&\f(CW\*(C`croak\*(C'\fR.
.Sp
.Vb 1
\& void warn(const char* pat, ...)
.Ve
.SH "AUTHORS"
.IX Header "AUTHORS"
Until May 1997, this document was maintained by Jeff Okamoto
<okamoto@corp.hp.com>. 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 <roehrich@cray.com>.
.PP
Updated to be autogenerated from comments in the source by Benjamin Stuhl.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIperlguts\fR\|(1), \fIperlxs\fR\|(1), \fIperlxstut\fR\|(1), \fIperlintern\fR\|(1)
|