This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The regexp engine should check SV flags rather than SV type for
[perl5.git] / pod / perlapi.pod
CommitLineData
954c1994
GS
1=head1 NAME
2
3perlapi - autogenerated documentation for the perl public API
4
5=head1 DESCRIPTION
d8c40edc 6X<Perl API> X<API> X<api>
954c1994 7
1c846c1f
NIS
8This file contains the documentation of the perl public API generated by
9embed.pl, specifically a listing of functions, macros, flags, and variables
10that may be used by extension writers. The interfaces of any functions that
954c1994
GS
11are not listed here are subject to change without notice. For this reason,
12blindly using functions listed in proto.h is to be avoided when writing
13extensions.
14
15Note that all Perl API global variables must be referenced with the C<PL_>
16prefix. Some macros are provided for compatibility with the older,
17unadorned names, but this support may be disabled in a future release.
18
19The listing is alphabetical, case insensitive.
20
94bdecf9
JH
21
22=head1 "Gimme" Values
23
24=over 8
25
26=item GIMME
d8c40edc 27X<GIMME>
94bdecf9
JH
28
29A backward-compatible version of C<GIMME_V> which can only return
30C<G_SCALAR> or C<G_ARRAY>; in a void context, it returns C<G_SCALAR>.
31Deprecated. Use C<GIMME_V> instead.
32
33 U32 GIMME
34
35=for hackers
36Found in file op.h
37
38=item GIMME_V
d8c40edc 39X<GIMME_V>
94bdecf9
JH
40
41The XSUB-writer's equivalent to Perl's C<wantarray>. Returns C<G_VOID>,
42C<G_SCALAR> or C<G_ARRAY> for void, scalar or list context,
43respectively.
44
45 U32 GIMME_V
46
47=for hackers
48Found in file op.h
49
50=item G_ARRAY
d8c40edc 51X<G_ARRAY>
94bdecf9
JH
52
53Used to indicate list context. See C<GIMME_V>, C<GIMME> and
54L<perlcall>.
55
56=for hackers
57Found in file cop.h
58
59=item G_DISCARD
d8c40edc 60X<G_DISCARD>
94bdecf9
JH
61
62Indicates that arguments returned from a callback should be discarded. See
63L<perlcall>.
64
65=for hackers
66Found in file cop.h
67
68=item G_EVAL
d8c40edc 69X<G_EVAL>
94bdecf9
JH
70
71Used to force a Perl C<eval> wrapper around a callback. See
72L<perlcall>.
73
74=for hackers
75Found in file cop.h
76
77=item G_NOARGS
d8c40edc 78X<G_NOARGS>
94bdecf9
JH
79
80Indicates that no arguments are being sent to a callback. See
81L<perlcall>.
82
83=for hackers
84Found in file cop.h
85
86=item G_SCALAR
d8c40edc 87X<G_SCALAR>
94bdecf9
JH
88
89Used to indicate scalar context. See C<GIMME_V>, C<GIMME>, and
90L<perlcall>.
91
92=for hackers
93Found in file cop.h
94
95=item G_VOID
d8c40edc 96X<G_VOID>
94bdecf9
JH
97
98Used to indicate void context. See C<GIMME_V> and L<perlcall>.
99
100=for hackers
101Found in file cop.h
102
103
104=back
105
106=head1 Array Manipulation Functions
107
954c1994
GS
108=over 8
109
110=item AvFILL
d8c40edc 111X<AvFILL>
954c1994
GS
112
113Same as C<av_len()>. Deprecated, use C<av_len()> instead.
114
115 int AvFILL(AV* av)
116
497711e7
GS
117=for hackers
118Found in file av.h
119
954c1994 120=item av_clear
d8c40edc 121X<av_clear>
954c1994
GS
122
123Clears an array, making it empty. Does not free the memory used by the
124array itself.
125
126 void av_clear(AV* ar)
127
497711e7
GS
128=for hackers
129Found in file av.c
130
f3b76584 131=item av_delete
d8c40edc 132X<av_delete>
f3b76584
SC
133
134Deletes the element indexed by C<key> from the array. Returns the
b9381830
JP
135deleted element. If C<flags> equals C<G_DISCARD>, the element is freed
136and null is returned.
f3b76584
SC
137
138 SV* av_delete(AV* ar, I32 key, I32 flags)
139
140=for hackers
141Found in file av.c
142
143=item av_exists
d8c40edc 144X<av_exists>
f3b76584
SC
145
146Returns true if the element indexed by C<key> has been initialized.
147
148This relies on the fact that uninitialized array elements are set to
149C<&PL_sv_undef>.
150
151 bool av_exists(AV* ar, I32 key)
152
153=for hackers
154Found in file av.c
155
954c1994 156=item av_extend
d8c40edc 157X<av_extend>
954c1994
GS
158
159Pre-extend an array. The C<key> is the index to which the array should be
160extended.
161
162 void av_extend(AV* ar, I32 key)
163
497711e7
GS
164=for hackers
165Found in file av.c
166
954c1994 167=item av_fetch
d8c40edc 168X<av_fetch>
954c1994
GS
169
170Returns the SV at the specified index in the array. The C<key> is the
171index. If C<lval> is set then the fetch will be part of a store. Check
172that the return value is non-null before dereferencing it to a C<SV*>.
173
96f1132b
GS
174See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
175more information on how to use this function on tied arrays.
954c1994
GS
176
177 SV** av_fetch(AV* ar, I32 key, I32 lval)
178
497711e7
GS
179=for hackers
180Found in file av.c
181
f3b76584 182=item av_fill
d8c40edc 183X<av_fill>
f3b76584
SC
184
185Ensure than an array has a given number of elements, equivalent to
186Perl's C<$#array = $fill;>.
187
188 void av_fill(AV* ar, I32 fill)
189
190=for hackers
191Found in file av.c
192
954c1994 193=item av_len
d8c40edc 194X<av_len>
954c1994
GS
195
196Returns the highest index in the array. Returns -1 if the array is
197empty.
198
35a4481c 199 I32 av_len(const AV* ar)
954c1994 200
497711e7
GS
201=for hackers
202Found in file av.c
203
954c1994 204=item av_make
d8c40edc 205X<av_make>
954c1994
GS
206
207Creates a new AV and populates it with a list of SVs. The SVs are copied
208into the array, so they may be freed after the call to av_make. The new AV
209will have a reference count of 1.
210
211 AV* av_make(I32 size, SV** svp)
212
497711e7
GS
213=for hackers
214Found in file av.c
215
954c1994 216=item av_pop
d8c40edc 217X<av_pop>
954c1994
GS
218
219Pops an SV off the end of the array. Returns C<&PL_sv_undef> if the array
220is empty.
221
222 SV* av_pop(AV* ar)
223
497711e7
GS
224=for hackers
225Found in file av.c
226
954c1994 227=item av_push
d8c40edc 228X<av_push>
954c1994
GS
229
230Pushes an SV onto the end of the array. The array will grow automatically
231to accommodate the addition.
232
233 void av_push(AV* ar, SV* val)
234
497711e7
GS
235=for hackers
236Found in file av.c
237
954c1994 238=item av_shift
d8c40edc 239X<av_shift>
954c1994
GS
240
241Shifts an SV off the beginning of the array.
242
243 SV* av_shift(AV* ar)
244
497711e7
GS
245=for hackers
246Found in file av.c
247
954c1994 248=item av_store
d8c40edc 249X<av_store>
954c1994
GS
250
251Stores an SV in an array. The array index is specified as C<key>. The
252return value will be NULL if the operation failed or if the value did not
253need to be actually stored within the array (as in the case of tied
254arrays). Otherwise it can be dereferenced to get the original C<SV*>. Note
255that the caller is responsible for suitably incrementing the reference
256count of C<val> before the call, and decrementing it if the function
257returned NULL.
258
96f1132b 259See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for
954c1994
GS
260more information on how to use this function on tied arrays.
261
262 SV** av_store(AV* ar, I32 key, SV* val)
263
497711e7
GS
264=for hackers
265Found in file av.c
266
954c1994 267=item av_undef
d8c40edc 268X<av_undef>
954c1994
GS
269
270Undefines the array. Frees the memory used by the array itself.
271
272 void av_undef(AV* ar)
273
497711e7
GS
274=for hackers
275Found in file av.c
276
954c1994 277=item av_unshift
d8c40edc 278X<av_unshift>
954c1994
GS
279
280Unshift the given number of C<undef> values onto the beginning of the
281array. The array will grow automatically to accommodate the addition. You
282must then use C<av_store> to assign values to these new elements.
283
284 void av_unshift(AV* ar, I32 num)
285
497711e7
GS
286=for hackers
287Found in file av.c
288
94bdecf9 289=item get_av
d8c40edc 290X<get_av>
9f2ea798 291
94bdecf9
JH
292Returns the AV of the specified Perl array. If C<create> is set and the
293Perl variable does not exist then it will be created. If C<create> is not
294set and the variable does not exist then NULL is returned.
9f2ea798 295
94bdecf9
JH
296NOTE: the perl_ form of this function is deprecated.
297
298 AV* get_av(const char* name, I32 create)
9f2ea798
DM
299
300=for hackers
94bdecf9 301Found in file perl.c
9f2ea798 302
94bdecf9 303=item newAV
d8c40edc 304X<newAV>
f9a63242 305
94bdecf9 306Creates a new AV. The reference count is set to 1.
f9a63242 307
94bdecf9
JH
308 AV* newAV()
309
310=for hackers
311Found in file av.c
312
94bdecf9 313=item sortsv
d8c40edc 314X<sortsv>
497711e7 315
94bdecf9 316Sort an array. Here is an example:
497711e7 317
94bdecf9 318 sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale);
eebe1485 319
641d4181
JH
320See lib/sort.pm for details about controlling the sorting algorithm.
321
aa924a5a 322 void sortsv(SV** array, size_t num_elts, SVCOMPARE_t cmp)
497711e7
GS
323
324=for hackers
94bdecf9
JH
325Found in file pp_sort.c
326
327
328=back
329
330=head1 Callback Functions
331
332=over 8
497711e7 333
954c1994 334=item call_argv
d8c40edc 335X<call_argv>
954c1994
GS
336
337Performs a callback to the specified Perl sub. See L<perlcall>.
338
339NOTE: the perl_ form of this function is deprecated.
340
8f42b153 341 I32 call_argv(const char* sub_name, I32 flags, char** argv)
954c1994 342
497711e7
GS
343=for hackers
344Found in file perl.c
345
954c1994 346=item call_method
d8c40edc 347X<call_method>
954c1994
GS
348
349Performs a callback to the specified Perl method. The blessed object must
350be on the stack. See L<perlcall>.
351
352NOTE: the perl_ form of this function is deprecated.
353
354 I32 call_method(const char* methname, I32 flags)
355
497711e7
GS
356=for hackers
357Found in file perl.c
358
954c1994 359=item call_pv
d8c40edc 360X<call_pv>
954c1994
GS
361
362Performs a callback to the specified Perl sub. See L<perlcall>.
363
364NOTE: the perl_ form of this function is deprecated.
365
366 I32 call_pv(const char* sub_name, I32 flags)
367
497711e7
GS
368=for hackers
369Found in file perl.c
370
954c1994 371=item call_sv
d8c40edc 372X<call_sv>
954c1994
GS
373
374Performs a callback to the Perl sub whose name is in the SV. See
375L<perlcall>.
376
377NOTE: the perl_ form of this function is deprecated.
378
379 I32 call_sv(SV* sv, I32 flags)
380
497711e7
GS
381=for hackers
382Found in file perl.c
383
94bdecf9 384=item ENTER
d8c40edc 385X<ENTER>
954c1994 386
94bdecf9 387Opening bracket on a callback. See C<LEAVE> and L<perlcall>.
954c1994 388
94bdecf9 389 ENTER;
954c1994 390
497711e7 391=for hackers
94bdecf9 392Found in file scope.h
497711e7 393
94bdecf9 394=item eval_pv
d8c40edc 395X<eval_pv>
954c1994 396
94bdecf9 397Tells Perl to C<eval> the given string and return an SV* result.
954c1994 398
94bdecf9 399NOTE: the perl_ form of this function is deprecated.
954c1994 400
94bdecf9 401 SV* eval_pv(const char* p, I32 croak_on_error)
497711e7 402
94bdecf9
JH
403=for hackers
404Found in file perl.c
954c1994 405
94bdecf9 406=item eval_sv
d8c40edc 407X<eval_sv>
c9d5ac95 408
94bdecf9 409Tells Perl to C<eval> the string in the SV.
c9d5ac95 410
94bdecf9 411NOTE: the perl_ form of this function is deprecated.
954c1994 412
94bdecf9 413 I32 eval_sv(SV* sv, I32 flags)
954c1994 414
497711e7 415=for hackers
94bdecf9 416Found in file perl.c
497711e7 417
94bdecf9 418=item FREETMPS
d8c40edc 419X<FREETMPS>
954c1994 420
94bdecf9
JH
421Closing bracket for temporaries on a callback. See C<SAVETMPS> and
422L<perlcall>.
954c1994 423
94bdecf9 424 FREETMPS;
954c1994 425
497711e7 426=for hackers
94bdecf9 427Found in file scope.h
beab0874 428
94bdecf9 429=item LEAVE
d8c40edc 430X<LEAVE>
beab0874 431
94bdecf9 432Closing bracket on a callback. See C<ENTER> and L<perlcall>.
beab0874 433
94bdecf9 434 LEAVE;
beab0874
JT
435
436=for hackers
94bdecf9 437Found in file scope.h
beab0874 438
94bdecf9 439=item SAVETMPS
d8c40edc 440X<SAVETMPS>
9f2ea798 441
94bdecf9
JH
442Opening bracket for temporaries on a callback. See C<FREETMPS> and
443L<perlcall>.
9f2ea798 444
94bdecf9 445 SAVETMPS;
9f2ea798
DM
446
447=for hackers
94bdecf9 448Found in file scope.h
9f2ea798 449
9f2ea798 450
94bdecf9 451=back
9f2ea798 452
94bdecf9 453=head1 Character classes
9f2ea798 454
94bdecf9 455=over 8
9f2ea798 456
94bdecf9 457=item isALNUM
d8c40edc 458X<isALNUM>
954c1994 459
94bdecf9
JH
460Returns a boolean indicating whether the C C<char> is an ASCII alphanumeric
461character (including underscore) or digit.
954c1994 462
94bdecf9 463 bool isALNUM(char ch)
954c1994 464
497711e7 465=for hackers
94bdecf9 466Found in file handy.h
497711e7 467
94bdecf9 468=item isALPHA
d8c40edc 469X<isALPHA>
954c1994 470
94bdecf9
JH
471Returns a boolean indicating whether the C C<char> is an ASCII alphabetic
472character.
954c1994 473
94bdecf9 474 bool isALPHA(char ch)
954c1994 475
497711e7 476=for hackers
94bdecf9 477Found in file handy.h
497711e7 478
94bdecf9 479=item isDIGIT
d8c40edc 480X<isDIGIT>
954c1994 481
94bdecf9
JH
482Returns a boolean indicating whether the C C<char> is an ASCII
483digit.
954c1994 484
94bdecf9 485 bool isDIGIT(char ch)
954c1994 486
497711e7 487=for hackers
94bdecf9 488Found in file handy.h
497711e7 489
94bdecf9 490=item isLOWER
d8c40edc 491X<isLOWER>
954c1994 492
94bdecf9
JH
493Returns a boolean indicating whether the C C<char> is a lowercase
494character.
954c1994 495
94bdecf9 496 bool isLOWER(char ch)
954c1994 497
497711e7 498=for hackers
94bdecf9 499Found in file handy.h
497711e7 500
94bdecf9 501=item isSPACE
d8c40edc 502X<isSPACE>
954c1994 503
94bdecf9 504Returns a boolean indicating whether the C C<char> is whitespace.
954c1994 505
94bdecf9 506 bool isSPACE(char ch)
954c1994 507
497711e7 508=for hackers
94bdecf9 509Found in file handy.h
497711e7 510
94bdecf9 511=item isUPPER
d8c40edc 512X<isUPPER>
954c1994 513
94bdecf9
JH
514Returns a boolean indicating whether the C C<char> is an uppercase
515character.
954c1994 516
94bdecf9 517 bool isUPPER(char ch)
954c1994 518
497711e7 519=for hackers
94bdecf9 520Found in file handy.h
497711e7 521
94bdecf9 522=item toLOWER
d8c40edc 523X<toLOWER>
954c1994 524
94bdecf9 525Converts the specified character to lowercase.
954c1994 526
94bdecf9 527 char toLOWER(char ch)
954c1994 528
94bdecf9
JH
529=for hackers
530Found in file handy.h
531
532=item toUPPER
d8c40edc 533X<toUPPER>
94bdecf9
JH
534
535Converts the specified character to uppercase.
536
537 char toUPPER(char ch)
954c1994 538
497711e7 539=for hackers
94bdecf9 540Found in file handy.h
497711e7 541
954c1994 542
94bdecf9 543=back
954c1994 544
94bdecf9 545=head1 Cloning an interpreter
954c1994 546
94bdecf9
JH
547=over 8
548
549=item perl_clone
d8c40edc 550X<perl_clone>
94bdecf9
JH
551
552Create and return a new interpreter by cloning the current one.
553
4be49ee6 554perl_clone takes these flags as parameters:
c78c2b74 555
b0bc38e6
NC
556CLONEf_COPY_STACKS - is used to, well, copy the stacks also,
557without it we only clone the data and zero the stacks,
558with it we copy the stacks and the new perl interpreter is
559ready to run at the exact same point as the previous one.
560The pseudo-fork code uses COPY_STACKS while the
c78c2b74
HS
561threads->new doesn't.
562
563CLONEf_KEEP_PTR_TABLE
b0bc38e6
NC
564perl_clone keeps a ptr_table with the pointer of the old
565variable as a key and the new variable as a value,
566this allows it to check if something has been cloned and not
567clone it again but rather just use the value and increase the
568refcount. If KEEP_PTR_TABLE is not set then perl_clone will kill
569the ptr_table using the function
570C<ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;>,
571reason to keep it around is if you want to dup some of your own
572variable who are outside the graph perl scans, example of this
c78c2b74
HS
573code is in threads.xs create
574
575CLONEf_CLONE_HOST
b0bc38e6
NC
576This is a win32 thing, it is ignored on unix, it tells perls
577win32host code (which is c++) to clone itself, this is needed on
578win32 if you want to run two threads at the same time,
579if you just want to do some stuff in a separate perl interpreter
580and then throw it away and return to the original one,
c78c2b74
HS
581you don't need to do anything.
582
94bdecf9 583 PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags)
954c1994 584
497711e7 585=for hackers
94bdecf9 586Found in file sv.c
497711e7 587
954c1994 588
94bdecf9 589=back
954c1994 590
94bdecf9
JH
591=head1 CV Manipulation Functions
592
593=over 8
594
595=item CvSTASH
d8c40edc 596X<CvSTASH>
94bdecf9
JH
597
598Returns the stash of the CV.
599
600 HV* CvSTASH(CV* cv)
954c1994 601
497711e7 602=for hackers
94bdecf9 603Found in file cv.h
497711e7 604
94bdecf9 605=item get_cv
d8c40edc 606X<get_cv>
954c1994 607
94bdecf9
JH
608Returns the CV of the specified Perl subroutine. If C<create> is set and
609the Perl subroutine does not exist then it will be declared (which has the
610same effect as saying C<sub name;>). If C<create> is not set and the
611subroutine does not exist then NULL is returned.
954c1994 612
94bdecf9
JH
613NOTE: the perl_ form of this function is deprecated.
614
615 CV* get_cv(const char* name, I32 create)
954c1994 616
497711e7 617=for hackers
94bdecf9 618Found in file perl.c
497711e7 619
7c9e965c 620
94bdecf9 621=back
7c9e965c 622
94bdecf9 623=head1 Embedding Functions
7c9e965c 624
94bdecf9 625=over 8
7c9e965c 626
7dafbf52 627=item cv_undef
d8c40edc 628X<cv_undef>
7dafbf52
DM
629
630Clear out all the active components of a CV. This can happen either
631by an explicit C<undef &foo>, or by the reference count going to zero.
632In the former case, we keep the CvOUTSIDE pointer, so that any anonymous
633children can still follow the full lexical scope chain.
634
635 void cv_undef(CV* cv)
636
637=for hackers
638Found in file op.c
639
94bdecf9 640=item load_module
d8c40edc 641X<load_module>
7c9e965c 642
94bdecf9
JH
643Loads the module whose name is pointed to by the string part of name.
644Note that the actual module name, not its filename, should be given.
645Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of
646PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS
647(or 0 for no flags). ver, if specified, provides version semantics
648similar to C<use Foo::Bar VERSION>. The optional trailing SV*
649arguments can be used to specify arguments to the module's import()
650method, similar to C<use Foo::Bar VERSION LIST>.
7c9e965c 651
94bdecf9 652 void load_module(U32 flags, SV* name, SV* ver, ...)
7c9e965c
JP
653
654=for hackers
94bdecf9 655Found in file op.c
7c9e965c 656
62375a60 657=item nothreadhook
d8c40edc 658X<nothreadhook>
62375a60
NIS
659
660Stub that provides thread hook for perl_destruct when there are
661no threads.
662
663 int nothreadhook()
664
665=for hackers
666Found in file perl.c
667
94bdecf9 668=item perl_alloc
d8c40edc 669X<perl_alloc>
954c1994 670
94bdecf9 671Allocates a new Perl interpreter. See L<perlembed>.
954c1994 672
94bdecf9 673 PerlInterpreter* perl_alloc()
954c1994 674
497711e7 675=for hackers
94bdecf9 676Found in file perl.c
497711e7 677
94bdecf9 678=item perl_construct
d8c40edc 679X<perl_construct>
89423764 680
94bdecf9 681Initializes a new Perl interpreter. See L<perlembed>.
89423764 682
94bdecf9 683 void perl_construct(PerlInterpreter* interp)
89423764
GS
684
685=for hackers
94bdecf9 686Found in file perl.c
954c1994 687
94bdecf9 688=item perl_destruct
d8c40edc 689X<perl_destruct>
954c1994 690
94bdecf9 691Shuts down a Perl interpreter. See L<perlembed>.
954c1994 692
94bdecf9 693 int perl_destruct(PerlInterpreter* interp)
954c1994 694
497711e7
GS
695=for hackers
696Found in file perl.c
697
94bdecf9 698=item perl_free
d8c40edc 699X<perl_free>
954c1994 700
94bdecf9 701Releases a Perl interpreter. See L<perlembed>.
954c1994 702
94bdecf9 703 void perl_free(PerlInterpreter* interp)
954c1994 704
497711e7
GS
705=for hackers
706Found in file perl.c
707
94bdecf9 708=item perl_parse
d8c40edc 709X<perl_parse>
954c1994 710
94bdecf9 711Tells a Perl interpreter to parse a Perl script. See L<perlembed>.
954c1994 712
94bdecf9 713 int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env)
954c1994 714
94bdecf9
JH
715=for hackers
716Found in file perl.c
717
718=item perl_run
d8c40edc 719X<perl_run>
94bdecf9
JH
720
721Tells a Perl interpreter to run. See L<perlembed>.
722
723 int perl_run(PerlInterpreter* interp)
954c1994 724
497711e7
GS
725=for hackers
726Found in file perl.c
727
94bdecf9 728=item require_pv
d8c40edc 729X<require_pv>
954c1994 730
94bdecf9
JH
731Tells Perl to C<require> the file named by the string argument. It is
732analogous to the Perl code C<eval "require '$file'">. It's even
2307c6d0 733implemented that way; consider using load_module instead.
954c1994
GS
734
735NOTE: the perl_ form of this function is deprecated.
736
94bdecf9 737 void require_pv(const char* pv)
954c1994 738
497711e7
GS
739=for hackers
740Found in file perl.c
741
954c1994 742
94bdecf9 743=back
954c1994 744
9244d4ad
RGS
745=head1 Functions in file mathoms.c
746
747
748=over 8
749
750=item gv_fetchmethod
751X<gv_fetchmethod>
752
753See L<gv_fetchmethod_autoload>.
754
755 GV* gv_fetchmethod(HV* stash, const char* name)
756
757=for hackers
758Found in file mathoms.c
759
760=item sv_2pvbyte_nolen
761X<sv_2pvbyte_nolen>
762
763Return a pointer to the byte-encoded representation of the SV.
764May cause the SV to be downgraded from UTF-8 as a side-effect.
765
766Usually accessed via the C<SvPVbyte_nolen> macro.
767
768 char* sv_2pvbyte_nolen(SV* sv)
769
770=for hackers
771Found in file mathoms.c
772
773=item sv_2pvutf8_nolen
774X<sv_2pvutf8_nolen>
775
776Return a pointer to the UTF-8-encoded representation of the SV.
777May cause the SV to be upgraded to UTF-8 as a side-effect.
778
779Usually accessed via the C<SvPVutf8_nolen> macro.
780
781 char* sv_2pvutf8_nolen(SV* sv)
782
783=for hackers
784Found in file mathoms.c
785
786=item sv_2pv_nolen
787X<sv_2pv_nolen>
788
789Like C<sv_2pv()>, but doesn't return the length too. You should usually
790use the macro wrapper C<SvPV_nolen(sv)> instead.
791 char* sv_2pv_nolen(SV* sv)
792
793=for hackers
794Found in file mathoms.c
795
796=item sv_catpvn_mg
797X<sv_catpvn_mg>
798
799Like C<sv_catpvn>, but also handles 'set' magic.
800
801 void sv_catpvn_mg(SV *sv, const char *ptr, STRLEN len)
802
803=for hackers
804Found in file mathoms.c
805
806=item sv_catsv_mg
807X<sv_catsv_mg>
808
809Like C<sv_catsv>, but also handles 'set' magic.
810
811 void sv_catsv_mg(SV *dstr, SV *sstr)
812
813=for hackers
814Found in file mathoms.c
815
816=item sv_force_normal
817X<sv_force_normal>
818
819Undo various types of fakery on an SV: if the PV is a shared string, make
820a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
821an xpvmg. See also C<sv_force_normal_flags>.
822
823 void sv_force_normal(SV *sv)
824
825=for hackers
826Found in file mathoms.c
827
828=item sv_iv
829X<sv_iv>
830
831A private implementation of the C<SvIVx> macro for compilers which can't
832cope with complex macro expressions. Always use the macro instead.
833
834 IV sv_iv(SV* sv)
835
836=for hackers
837Found in file mathoms.c
838
839=item sv_nolocking
840X<sv_nolocking>
841
842Dummy routine which "locks" an SV when there is no locking module present.
843Exists to avoid test for a NULL function pointer and because it could
844potentially warn under some level of strict-ness.
845
846"Superseded" by sv_nosharing().
847
848 void sv_nolocking(SV *)
849
850=for hackers
851Found in file mathoms.c
852
853=item sv_nounlocking
854X<sv_nounlocking>
855
856Dummy routine which "unlocks" an SV when there is no locking module present.
857Exists to avoid test for a NULL function pointer and because it could
858potentially warn under some level of strict-ness.
859
860"Superseded" by sv_nosharing().
861
862 void sv_nounlocking(SV *)
863
864=for hackers
865Found in file mathoms.c
866
867=item sv_nv
868X<sv_nv>
869
870A private implementation of the C<SvNVx> macro for compilers which can't
871cope with complex macro expressions. Always use the macro instead.
872
873 NV sv_nv(SV* sv)
874
875=for hackers
876Found in file mathoms.c
877
878=item sv_pv
879X<sv_pv>
880
881Use the C<SvPV_nolen> macro instead
882
883 char* sv_pv(SV *sv)
884
885=for hackers
886Found in file mathoms.c
887
888=item sv_pvbyte
889X<sv_pvbyte>
890
891Use C<SvPVbyte_nolen> instead.
892
893 char* sv_pvbyte(SV *sv)
894
895=for hackers
896Found in file mathoms.c
897
898=item sv_pvbyten
899X<sv_pvbyten>
900
901A private implementation of the C<SvPVbyte> macro for compilers
902which can't cope with complex macro expressions. Always use the macro
903instead.
904
905 char* sv_pvbyten(SV *sv, STRLEN *len)
906
907=for hackers
908Found in file mathoms.c
909
910=item sv_pvn
911X<sv_pvn>
912
913A private implementation of the C<SvPV> macro for compilers which can't
914cope with complex macro expressions. Always use the macro instead.
915
916 char* sv_pvn(SV *sv, STRLEN *len)
917
918=for hackers
919Found in file mathoms.c
920
921=item sv_pvutf8
922X<sv_pvutf8>
923
924Use the C<SvPVutf8_nolen> macro instead
925
926 char* sv_pvutf8(SV *sv)
927
928=for hackers
929Found in file mathoms.c
930
931=item sv_pvutf8n
932X<sv_pvutf8n>
933
934A private implementation of the C<SvPVutf8> macro for compilers
935which can't cope with complex macro expressions. Always use the macro
936instead.
937
938 char* sv_pvutf8n(SV *sv, STRLEN *len)
939
940=for hackers
941Found in file mathoms.c
942
943=item sv_taint
944X<sv_taint>
945
946Taint an SV. Use C<SvTAINTED_on> instead.
947 void sv_taint(SV* sv)
948
949=for hackers
950Found in file mathoms.c
951
952=item sv_unref
953X<sv_unref>
954
955Unsets the RV status of the SV, and decrements the reference count of
956whatever was being referenced by the RV. This can almost be thought of
957as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag>
958being zero. See C<SvROK_off>.
959
960 void sv_unref(SV* sv)
961
962=for hackers
963Found in file mathoms.c
964
965=item sv_uv
966X<sv_uv>
967
968A private implementation of the C<SvUVx> macro for compilers which can't
969cope with complex macro expressions. Always use the macro instead.
970
971 UV sv_uv(SV* sv)
972
973=for hackers
974Found in file mathoms.c
975
9244d4ad
RGS
976
977=back
978
6050d10e
JP
979=head1 Functions in file pp_pack.c
980
981
982=over 8
983
7accc089 984=item packlist
d8c40edc 985X<packlist>
6050d10e
JP
986
987The engine implementing pack() Perl function.
988
f7fe979e 989 void packlist(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist)
7accc089
JH
990
991=for hackers
992Found in file pp_pack.c
993
994=item pack_cat
d8c40edc 995X<pack_cat>
7accc089
JH
996
997The engine implementing pack() Perl function. Note: parameters next_in_list and
998flags are not used. This call should not be used; use packlist instead.
999
f7fe979e 1000 void pack_cat(SV *cat, const char *pat, const char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
6050d10e
JP
1001
1002=for hackers
1003Found in file pp_pack.c
1004
7accc089 1005=item unpackstring
d8c40edc 1006X<unpackstring>
6050d10e 1007
608d3aed
WL
1008The engine implementing unpack() Perl function. C<unpackstring> puts the
1009extracted list items on the stack and returns the number of elements.
1010Issue C<PUTBACK> before and C<SPAGAIN> after the call to this function.
6050d10e 1011
f7fe979e 1012 I32 unpackstring(const char *pat, const char *patend, const char *s, const char *strend, U32 flags)
7accc089
JH
1013
1014=for hackers
1015Found in file pp_pack.c
1016
1017=item unpack_str
d8c40edc 1018X<unpack_str>
7accc089
JH
1019
1020The engine implementing unpack() Perl function. Note: parameters strbeg, new_s
1021and ocnt are not used. This call should not be used, use unpackstring instead.
1022
f7fe979e 1023 I32 unpack_str(const char *pat, const char *patend, const char *s, const char *strbeg, const char *strend, char **new_s, I32 ocnt, U32 flags)
6050d10e
JP
1024
1025=for hackers
1026Found in file pp_pack.c
1027
1028
1029=back
1030
94bdecf9 1031=head1 Global Variables
954c1994 1032
94bdecf9 1033=over 8
497711e7 1034
94bdecf9 1035=item PL_modglobal
d8c40edc 1036X<PL_modglobal>
954c1994 1037
94bdecf9
JH
1038C<PL_modglobal> is a general purpose, interpreter global HV for use by
1039extensions that need to keep information on a per-interpreter basis.
1040In a pinch, it can also be used as a symbol table for extensions
1041to share data among each other. It is a good idea to use keys
1042prefixed by the package name of the extension that owns the data.
954c1994 1043
94bdecf9 1044 HV* PL_modglobal
954c1994 1045
497711e7 1046=for hackers
94bdecf9 1047Found in file intrpvar.h
497711e7 1048
94bdecf9 1049=item PL_na
d8c40edc 1050X<PL_na>
6e9d1081 1051
94bdecf9
JH
1052A convenience variable which is typically used with C<SvPV> when one
1053doesn't care about the length of the string. It is usually more efficient
1054to either declare a local variable and use that instead or to use the
1055C<SvPV_nolen> macro.
6e9d1081 1056
94bdecf9 1057 STRLEN PL_na
6e9d1081 1058
94bdecf9
JH
1059=for hackers
1060Found in file thrdvar.h
6e9d1081 1061
94bdecf9 1062=item PL_sv_no
d8c40edc 1063X<PL_sv_no>
6e9d1081 1064
94bdecf9
JH
1065This is the C<false> SV. See C<PL_sv_yes>. Always refer to this as
1066C<&PL_sv_no>.
1067
1068 SV PL_sv_no
6e9d1081
NC
1069
1070=for hackers
94bdecf9 1071Found in file intrpvar.h
6e9d1081 1072
94bdecf9 1073=item PL_sv_undef
d8c40edc 1074X<PL_sv_undef>
6e9d1081 1075
94bdecf9 1076This is the C<undef> SV. Always refer to this as C<&PL_sv_undef>.
6e9d1081 1077
94bdecf9 1078 SV PL_sv_undef
6e9d1081 1079
94bdecf9
JH
1080=for hackers
1081Found in file intrpvar.h
6e9d1081 1082
94bdecf9 1083=item PL_sv_yes
d8c40edc 1084X<PL_sv_yes>
6e9d1081 1085
94bdecf9
JH
1086This is the C<true> SV. See C<PL_sv_no>. Always refer to this as
1087C<&PL_sv_yes>.
1088
1089 SV PL_sv_yes
6e9d1081
NC
1090
1091=for hackers
94bdecf9 1092Found in file intrpvar.h
6e9d1081 1093
6e9d1081 1094
94bdecf9 1095=back
6e9d1081 1096
94bdecf9 1097=head1 GV Functions
6e9d1081 1098
94bdecf9 1099=over 8
6e9d1081 1100
954c1994 1101=item GvSV
d8c40edc 1102X<GvSV>
954c1994
GS
1103
1104Return the SV from the GV.
1105
1106 SV* GvSV(GV* gv)
1107
497711e7
GS
1108=for hackers
1109Found in file gv.h
1110
954c1994 1111=item gv_fetchmeth
d8c40edc 1112X<gv_fetchmeth>
954c1994
GS
1113
1114Returns the glob with the given C<name> and a defined subroutine or
1115C<NULL>. The glob lives in the given C<stash>, or in the stashes
a453c169 1116accessible via @ISA and UNIVERSAL::.
954c1994
GS
1117
1118The argument C<level> should be either 0 or -1. If C<level==0>, as a
1119side-effect creates a glob with the given C<name> in the given C<stash>
1120which in the case of success contains an alias for the subroutine, and sets
1c846c1f 1121up caching info for this glob. Similarly for all the searched stashes.
954c1994
GS
1122
1123This function grants C<"SUPER"> token as a postfix of the stash name. The
1124GV returned from C<gv_fetchmeth> may be a method cache entry, which is not
4929bf7b 1125visible to Perl code. So when calling C<call_sv>, you should not use
954c1994 1126the GV directly; instead, you should use the method's CV, which can be
1c846c1f 1127obtained from the GV with the C<GvCV> macro.
954c1994
GS
1128
1129 GV* gv_fetchmeth(HV* stash, const char* name, STRLEN len, I32 level)
1130
497711e7
GS
1131=for hackers
1132Found in file gv.c
1133
954c1994 1134=item gv_fetchmethod_autoload
d8c40edc 1135X<gv_fetchmethod_autoload>
954c1994
GS
1136
1137Returns the glob which contains the subroutine to call to invoke the method
1138on the C<stash>. In fact in the presence of autoloading this may be the
1139glob for "AUTOLOAD". In this case the corresponding variable $AUTOLOAD is
1c846c1f 1140already setup.
954c1994
GS
1141
1142The third parameter of C<gv_fetchmethod_autoload> determines whether
1143AUTOLOAD lookup is performed if the given method is not present: non-zero
1c846c1f 1144means yes, look for AUTOLOAD; zero means no, don't look for AUTOLOAD.
954c1994 1145Calling C<gv_fetchmethod> is equivalent to calling C<gv_fetchmethod_autoload>
1c846c1f 1146with a non-zero C<autoload> parameter.
954c1994
GS
1147
1148These functions grant C<"SUPER"> token as a prefix of the method name. Note
1149that if you want to keep the returned glob for a long time, you need to
1150check for it being "AUTOLOAD", since at the later time the call may load a
1151different subroutine due to $AUTOLOAD changing its value. Use the glob
1c846c1f 1152created via a side effect to do this.
954c1994
GS
1153
1154These functions have the same side-effects and as C<gv_fetchmeth> with
1155C<level==0>. C<name> should be writable if contains C<':'> or C<'
1156''>. The warning against passing the GV returned by C<gv_fetchmeth> to
1c846c1f 1157C<call_sv> apply equally to these functions.
954c1994
GS
1158
1159 GV* gv_fetchmethod_autoload(HV* stash, const char* name, I32 autoload)
1160
497711e7
GS
1161=for hackers
1162Found in file gv.c
1163
0c81b680 1164=item gv_fetchmeth_autoload
d8c40edc 1165X<gv_fetchmeth_autoload>
0c81b680
JH
1166
1167Same as gv_fetchmeth(), but looks for autoloaded subroutines too.
1168Returns a glob for the subroutine.
1169
1170For an autoloaded subroutine without a GV, will create a GV even
1171if C<level < 0>. For an autoloaded subroutine without a stub, GvCV()
1172of the result may be zero.
1173
1174 GV* gv_fetchmeth_autoload(HV* stash, const char* name, STRLEN len, I32 level)
1175
1176=for hackers
1177Found in file gv.c
1178
954c1994 1179=item gv_stashpv
d8c40edc 1180X<gv_stashpv>
954c1994 1181
386d01d6 1182Returns a pointer to the stash for a specified package. C<name> should
bc96cb06
SH
1183be a valid UTF-8 string and must be null-terminated. If C<create> is set
1184then the package will be created if it does not already exist. If C<create>
1185is not set and the package does not exist then NULL is returned.
1186
1187 HV* gv_stashpv(const char* name, I32 create)
1188
1189=for hackers
1190Found in file gv.c
1191
1192=item gv_stashpvn
d8c40edc 1193X<gv_stashpvn>
bc96cb06
SH
1194
1195Returns a pointer to the stash for a specified package. C<name> should
1196be a valid UTF-8 string. The C<namelen> parameter indicates the length of
1197the C<name>, in bytes. If C<create> is set then the package will be
386d01d6
GS
1198created if it does not already exist. If C<create> is not set and the
1199package does not exist then NULL is returned.
954c1994 1200
bc96cb06 1201 HV* gv_stashpvn(const char* name, U32 namelen, I32 create)
954c1994 1202
497711e7
GS
1203=for hackers
1204Found in file gv.c
1205
954c1994 1206=item gv_stashsv
d8c40edc 1207X<gv_stashsv>
954c1994 1208
386d01d6
GS
1209Returns a pointer to the stash for a specified package, which must be a
1210valid UTF-8 string. See C<gv_stashpv>.
954c1994
GS
1211
1212 HV* gv_stashsv(SV* sv, I32 create)
1213
497711e7
GS
1214=for hackers
1215Found in file gv.c
1216
954c1994 1217
94bdecf9 1218=back
954c1994 1219
94bdecf9 1220=head1 Handy Values
497711e7 1221
94bdecf9 1222=over 8
954c1994 1223
e509e693 1224=item Nullav
d8c40edc 1225X<Nullav>
497711e7 1226
e509e693 1227Null AV pointer.
954c1994 1228
94bdecf9 1229=for hackers
e509e693 1230Found in file av.h
954c1994 1231
dd2155a4 1232=item Nullch
d8c40edc 1233X<Nullch>
94bdecf9
JH
1234
1235Null character pointer.
2307c6d0 1236
497711e7 1237=for hackers
94bdecf9 1238Found in file handy.h
497711e7 1239
e509e693 1240=item Nullcv
d8c40edc 1241X<Nullcv>
e509e693
SH
1242
1243Null CV pointer.
1244
1245=for hackers
1246Found in file cv.h
1247
1248=item Nullhv
d8c40edc 1249X<Nullhv>
e509e693
SH
1250
1251Null HV pointer.
1252
1253=for hackers
1254Found in file hv.h
1255
94bdecf9 1256=item Nullsv
d8c40edc 1257X<Nullsv>
954c1994 1258
94bdecf9 1259Null SV pointer.
954c1994 1260
497711e7 1261=for hackers
94bdecf9 1262Found in file handy.h
497711e7 1263
954c1994 1264
94bdecf9 1265=back
954c1994 1266
94bdecf9 1267=head1 Hash Manipulation Functions
497711e7 1268
94bdecf9 1269=over 8
954c1994 1270
94bdecf9 1271=item get_hv
d8c40edc 1272X<get_hv>
954c1994 1273
94bdecf9
JH
1274Returns the HV of the specified Perl hash. If C<create> is set and the
1275Perl variable does not exist then it will be created. If C<create> is not
1276set and the variable does not exist then NULL is returned.
497711e7 1277
94bdecf9 1278NOTE: the perl_ form of this function is deprecated.
954c1994 1279
94bdecf9 1280 HV* get_hv(const char* name, I32 create)
954c1994 1281
497711e7 1282=for hackers
94bdecf9 1283Found in file perl.c
497711e7 1284
e509e693 1285=item HEf_SVKEY
d8c40edc 1286X<HEf_SVKEY>
e509e693
SH
1287
1288This flag, used in the length slot of hash entries and magic structures,
1289specifies the structure contains an C<SV*> pointer where a C<char*> pointer
1290is to be expected. (For information only--not to be used).
1291
1292=for hackers
1293Found in file hv.h
1294
954c1994 1295=item HeHASH
d8c40edc 1296X<HeHASH>
954c1994
GS
1297
1298Returns the computed hash stored in the hash entry.
1299
1300 U32 HeHASH(HE* he)
1301
497711e7
GS
1302=for hackers
1303Found in file hv.h
1304
954c1994 1305=item HeKEY
d8c40edc 1306X<HeKEY>
954c1994
GS
1307
1308Returns the actual pointer stored in the key slot of the hash entry. The
1309pointer may be either C<char*> or C<SV*>, depending on the value of
1310C<HeKLEN()>. Can be assigned to. The C<HePV()> or C<HeSVKEY()> macros are
1311usually preferable for finding the value of a key.
1312
1313 void* HeKEY(HE* he)
1314
497711e7
GS
1315=for hackers
1316Found in file hv.h
1317
954c1994 1318=item HeKLEN
d8c40edc 1319X<HeKLEN>
954c1994
GS
1320
1321If this is negative, and amounts to C<HEf_SVKEY>, it indicates the entry
1322holds an C<SV*> key. Otherwise, holds the actual length of the key. Can
1323be assigned to. The C<HePV()> macro is usually preferable for finding key
1324lengths.
1325
1326 STRLEN HeKLEN(HE* he)
1327
497711e7
GS
1328=for hackers
1329Found in file hv.h
1330
954c1994 1331=item HePV
d8c40edc 1332X<HePV>
954c1994
GS
1333
1334Returns the key slot of the hash entry as a C<char*> value, doing any
1335necessary dereferencing of possibly C<SV*> keys. The length of the string
1336is placed in C<len> (this is a macro, so do I<not> use C<&len>). If you do
1337not care about what the length of the key is, you may use the global
1338variable C<PL_na>, though this is rather less efficient than using a local
1339variable. Remember though, that hash keys in perl are free to contain
1340embedded nulls, so using C<strlen()> or similar is not a good way to find
1341the length of hash keys. This is very similar to the C<SvPV()> macro
1342described elsewhere in this document.
1343
1344 char* HePV(HE* he, STRLEN len)
1345
497711e7
GS
1346=for hackers
1347Found in file hv.h
1348
954c1994 1349=item HeSVKEY
d8c40edc 1350X<HeSVKEY>
954c1994
GS
1351
1352Returns the key as an C<SV*>, or C<Nullsv> if the hash entry does not
1353contain an C<SV*> key.
1354
1355 SV* HeSVKEY(HE* he)
1356
497711e7
GS
1357=for hackers
1358Found in file hv.h
1359
954c1994 1360=item HeSVKEY_force
d8c40edc 1361X<HeSVKEY_force>
954c1994
GS
1362
1363Returns the key as an C<SV*>. Will create and return a temporary mortal
1364C<SV*> if the hash entry contains only a C<char*> key.
1365
1366 SV* HeSVKEY_force(HE* he)
1367
497711e7
GS
1368=for hackers
1369Found in file hv.h
1370
954c1994 1371=item HeSVKEY_set
d8c40edc 1372X<HeSVKEY_set>
954c1994
GS
1373
1374Sets the key to a given C<SV*>, taking care to set the appropriate flags to
1375indicate the presence of an C<SV*> key, and returns the same
1376C<SV*>.
1377
1378 SV* HeSVKEY_set(HE* he, SV* sv)
1379
497711e7
GS
1380=for hackers
1381Found in file hv.h
1382
954c1994 1383=item HeVAL
d8c40edc 1384X<HeVAL>
954c1994
GS
1385
1386Returns the value slot (type C<SV*>) stored in the hash entry.
1387
1388 SV* HeVAL(HE* he)
1389
497711e7
GS
1390=for hackers
1391Found in file hv.h
1392
954c1994 1393=item HvNAME
d8c40edc 1394X<HvNAME>
954c1994 1395
9282b5fd
SH
1396Returns the package name of a stash, or NULL if C<stash> isn't a stash.
1397See C<SvSTASH>, C<CvSTASH>.
954c1994
GS
1398
1399 char* HvNAME(HV* stash)
1400
497711e7
GS
1401=for hackers
1402Found in file hv.h
1403
ecae49c0 1404=item hv_assert
d8c40edc 1405X<hv_assert>
ecae49c0
NC
1406
1407Check that a hash is in an internally consistent state.
1408
1409 void hv_assert(HV* tb)
1410
1411=for hackers
1412Found in file hv.c
1413
954c1994 1414=item hv_clear
d8c40edc 1415X<hv_clear>
954c1994
GS
1416
1417Clears a hash, making it empty.
1418
1419 void hv_clear(HV* tb)
1420
497711e7
GS
1421=for hackers
1422Found in file hv.c
1423
3540d4ce 1424=item hv_clear_placeholders
d8c40edc 1425X<hv_clear_placeholders>
3540d4ce
AB
1426
1427Clears any placeholders from a hash. If a restricted hash has any of its keys
1428marked as readonly and the key is subsequently deleted, the key is not actually
1429deleted but is marked by assigning it a value of &PL_sv_placeholder. This tags
1430it so it will be ignored by future operations such as iterating over the hash,
fa11829f 1431but will still allow the hash to have a value reassigned to the key at some
3540d4ce
AB
1432future point. This function clears any such placeholder keys from the hash.
1433See Hash::Util::lock_keys() for an example of its use.
1434
1435 void hv_clear_placeholders(HV* hb)
1436
1437=for hackers
1438Found in file hv.c
1439
954c1994 1440=item hv_delete
d8c40edc 1441X<hv_delete>
954c1994
GS
1442
1443Deletes a key/value pair in the hash. The value SV is removed from the
1c846c1f 1444hash and returned to the caller. The C<klen> is the length of the key.
954c1994
GS
1445The C<flags> value will normally be zero; if set to G_DISCARD then NULL
1446will be returned.
1447
da58a35d 1448 SV* hv_delete(HV* tb, const char* key, I32 klen, I32 flags)
954c1994 1449
497711e7
GS
1450=for hackers
1451Found in file hv.c
1452
954c1994 1453=item hv_delete_ent
d8c40edc 1454X<hv_delete_ent>
954c1994
GS
1455
1456Deletes a key/value pair in the hash. The value SV is removed from the
1457hash and returned to the caller. The C<flags> value will normally be zero;
1458if set to G_DISCARD then NULL will be returned. C<hash> can be a valid
1459precomputed hash value, or 0 to ask for it to be computed.
1460
1461 SV* hv_delete_ent(HV* tb, SV* key, I32 flags, U32 hash)
1462
497711e7
GS
1463=for hackers
1464Found in file hv.c
1465
954c1994 1466=item hv_exists
d8c40edc 1467X<hv_exists>
954c1994
GS
1468
1469Returns a boolean indicating whether the specified hash key exists. The
1470C<klen> is the length of the key.
1471
da58a35d 1472 bool hv_exists(HV* tb, const char* key, I32 klen)
954c1994 1473
497711e7
GS
1474=for hackers
1475Found in file hv.c
1476
954c1994 1477=item hv_exists_ent
d8c40edc 1478X<hv_exists_ent>
954c1994
GS
1479
1480Returns a boolean indicating whether the specified hash key exists. C<hash>
1481can be a valid precomputed hash value, or 0 to ask for it to be
1482computed.
1483
1484 bool hv_exists_ent(HV* tb, SV* key, U32 hash)
1485
497711e7
GS
1486=for hackers
1487Found in file hv.c
1488
954c1994 1489=item hv_fetch
d8c40edc 1490X<hv_fetch>
954c1994
GS
1491
1492Returns the SV which corresponds to the specified key in the hash. The
1493C<klen> is the length of the key. If C<lval> is set then the fetch will be
1494part of a store. Check that the return value is non-null before
f4758303 1495dereferencing it to an C<SV*>.
954c1994 1496
96f1132b 1497See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
954c1994
GS
1498information on how to use this function on tied hashes.
1499
da58a35d 1500 SV** hv_fetch(HV* tb, const char* key, I32 klen, I32 lval)
954c1994 1501
497711e7
GS
1502=for hackers
1503Found in file hv.c
1504
954c1994 1505=item hv_fetch_ent
d8c40edc 1506X<hv_fetch_ent>
954c1994
GS
1507
1508Returns the hash entry which corresponds to the specified key in the hash.
1509C<hash> must be a valid precomputed hash number for the given C<key>, or 0
1510if you want the function to compute it. IF C<lval> is set then the fetch
1511will be part of a store. Make sure the return value is non-null before
1512accessing it. The return value when C<tb> is a tied hash is a pointer to a
1513static location, so be sure to make a copy of the structure if you need to
1c846c1f 1514store it somewhere.
954c1994 1515
96f1132b 1516See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
954c1994
GS
1517information on how to use this function on tied hashes.
1518
1519 HE* hv_fetch_ent(HV* tb, SV* key, I32 lval, U32 hash)
1520
497711e7
GS
1521=for hackers
1522Found in file hv.c
1523
954c1994 1524=item hv_iterinit
d8c40edc 1525X<hv_iterinit>
954c1994
GS
1526
1527Prepares a starting point to traverse a hash table. Returns the number of
1528keys in the hash (i.e. the same as C<HvKEYS(tb)>). The return value is
1c846c1f 1529currently only meaningful for hashes without tie magic.
954c1994
GS
1530
1531NOTE: Before version 5.004_65, C<hv_iterinit> used to return the number of
1532hash buckets that happen to be in use. If you still need that esoteric
1533value, you can get it through the macro C<HvFILL(tb)>.
1534
641d4181 1535
954c1994
GS
1536 I32 hv_iterinit(HV* tb)
1537
497711e7
GS
1538=for hackers
1539Found in file hv.c
1540
954c1994 1541=item hv_iterkey
d8c40edc 1542X<hv_iterkey>
954c1994
GS
1543
1544Returns the key from the current position of the hash iterator. See
1545C<hv_iterinit>.
1546
1547 char* hv_iterkey(HE* entry, I32* retlen)
1548
497711e7
GS
1549=for hackers
1550Found in file hv.c
1551
954c1994 1552=item hv_iterkeysv
d8c40edc 1553X<hv_iterkeysv>
954c1994
GS
1554
1555Returns the key as an C<SV*> from the current position of the hash
1556iterator. The return value will always be a mortal copy of the key. Also
1557see C<hv_iterinit>.
1558
1559 SV* hv_iterkeysv(HE* entry)
1560
497711e7
GS
1561=for hackers
1562Found in file hv.c
1563
954c1994 1564=item hv_iternext
d8c40edc 1565X<hv_iternext>
954c1994
GS
1566
1567Returns entries from a hash iterator. See C<hv_iterinit>.
1568
641d4181
JH
1569You may call C<hv_delete> or C<hv_delete_ent> on the hash entry that the
1570iterator currently points to, without losing your place or invalidating your
1571iterator. Note that in this case the current entry is deleted from the hash
1572with your iterator holding the last reference to it. Your iterator is flagged
1573to free the entry on the next call to C<hv_iternext>, so you must not discard
1574your iterator immediately else the entry will leak - call C<hv_iternext> to
1575trigger the resource deallocation.
1576
954c1994
GS
1577 HE* hv_iternext(HV* tb)
1578
497711e7
GS
1579=for hackers
1580Found in file hv.c
1581
954c1994 1582=item hv_iternextsv
d8c40edc 1583X<hv_iternextsv>
954c1994
GS
1584
1585Performs an C<hv_iternext>, C<hv_iterkey>, and C<hv_iterval> in one
1586operation.
1587
1588 SV* hv_iternextsv(HV* hv, char** key, I32* retlen)
1589
497711e7
GS
1590=for hackers
1591Found in file hv.c
1592
641d4181 1593=item hv_iternext_flags
d8c40edc 1594X<hv_iternext_flags>
641d4181
JH
1595
1596Returns entries from a hash iterator. See C<hv_iterinit> and C<hv_iternext>.
1597The C<flags> value will normally be zero; if HV_ITERNEXT_WANTPLACEHOLDERS is
1598set the placeholders keys (for restricted hashes) will be returned in addition
1599to normal keys. By default placeholders are automatically skipped over.
384679aa
RGS
1600Currently a placeholder is implemented with a value that is
1601C<&Perl_sv_placeholder>. Note that the implementation of placeholders and
641d4181
JH
1602restricted hashes may change, and the implementation currently is
1603insufficiently abstracted for any change to be tidy.
1604
1605NOTE: this function is experimental and may change or be
1606removed without notice.
1607
1608 HE* hv_iternext_flags(HV* tb, I32 flags)
1609
1610=for hackers
1611Found in file hv.c
1612
954c1994 1613=item hv_iterval
d8c40edc 1614X<hv_iterval>
954c1994
GS
1615
1616Returns the value from the current position of the hash iterator. See
1617C<hv_iterkey>.
1618
1619 SV* hv_iterval(HV* tb, HE* entry)
1620
497711e7
GS
1621=for hackers
1622Found in file hv.c
1623
954c1994 1624=item hv_magic
d8c40edc 1625X<hv_magic>
954c1994
GS
1626
1627Adds magic to a hash. See C<sv_magic>.
1628
1629 void hv_magic(HV* hv, GV* gv, int how)
1630
497711e7
GS
1631=for hackers
1632Found in file hv.c
1633
a3bcc51e 1634=item hv_scalar
d8c40edc 1635X<hv_scalar>
a3bcc51e
TP
1636
1637Evaluates the hash in scalar context and returns the result. Handles magic when the hash is tied.
1638
1639 SV* hv_scalar(HV* hv)
1640
1641=for hackers
1642Found in file hv.c
1643
954c1994 1644=item hv_store
d8c40edc 1645X<hv_store>
954c1994
GS
1646
1647Stores an SV in a hash. The hash key is specified as C<key> and C<klen> is
1648the length of the key. The C<hash> parameter is the precomputed hash
1649value; if it is zero then Perl will compute it. The return value will be
1650NULL if the operation failed or if the value did not need to be actually
1651stored within the hash (as in the case of tied hashes). Otherwise it can
1652be dereferenced to get the original C<SV*>. Note that the caller is
1653responsible for suitably incrementing the reference count of C<val> before
7e8c5dac
HS
1654the call, and decrementing it if the function returned NULL. Effectively
1655a successful hv_store takes ownership of one reference to C<val>. This is
1656usually what you want; a newly created SV has a reference count of one, so
1657if all your code does is create SVs then store them in a hash, hv_store
1658will own the only reference to the new SV, and your code doesn't need to do
1659anything further to tidy up. hv_store is not implemented as a call to
1660hv_store_ent, and does not create a temporary SV for the key, so if your
1661key data is not already in SV form then use hv_store in preference to
1662hv_store_ent.
954c1994 1663
96f1132b 1664See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
954c1994
GS
1665information on how to use this function on tied hashes.
1666
da58a35d 1667 SV** hv_store(HV* tb, const char* key, I32 klen, SV* val, U32 hash)
954c1994 1668
497711e7
GS
1669=for hackers
1670Found in file hv.c
1671
954c1994 1672=item hv_store_ent
d8c40edc 1673X<hv_store_ent>
954c1994
GS
1674
1675Stores C<val> in a hash. The hash key is specified as C<key>. The C<hash>
1676parameter is the precomputed hash value; if it is zero then Perl will
1677compute it. The return value is the new hash entry so created. It will be
1678NULL if the operation failed or if the value did not need to be actually
1679stored within the hash (as in the case of tied hashes). Otherwise the
f22d8e4b 1680contents of the return value can be accessed using the C<He?> macros
954c1994
GS
1681described here. Note that the caller is responsible for suitably
1682incrementing the reference count of C<val> before the call, and
7e8c5dac
HS
1683decrementing it if the function returned NULL. Effectively a successful
1684hv_store_ent takes ownership of one reference to C<val>. This is
1685usually what you want; a newly created SV has a reference count of one, so
1686if all your code does is create SVs then store them in a hash, hv_store
1687will own the only reference to the new SV, and your code doesn't need to do
1688anything further to tidy up. Note that hv_store_ent only reads the C<key>;
1689unlike C<val> it does not take ownership of it, so maintaining the correct
1690reference count on C<key> is entirely the caller's responsibility. hv_store
1691is not implemented as a call to hv_store_ent, and does not create a temporary
1692SV for the key, so if your key data is not already in SV form then use
1693hv_store in preference to hv_store_ent.
954c1994 1694
96f1132b 1695See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
954c1994
GS
1696information on how to use this function on tied hashes.
1697
1698 HE* hv_store_ent(HV* tb, SV* key, SV* val, U32 hash)
1699
497711e7
GS
1700=for hackers
1701Found in file hv.c
1702
954c1994 1703=item hv_undef
d8c40edc 1704X<hv_undef>
954c1994
GS
1705
1706Undefines the hash.
1707
1708 void hv_undef(HV* tb)
1709
497711e7
GS
1710=for hackers
1711Found in file hv.c
1712
94bdecf9 1713=item newHV
d8c40edc 1714X<newHV>
d2cc3551 1715
94bdecf9 1716Creates a new HV. The reference count is set to 1.
d2cc3551 1717
94bdecf9 1718 HV* newHV()
d2cc3551
JH
1719
1720=for hackers
94bdecf9 1721Found in file hv.c
d2cc3551 1722
954c1994 1723
94bdecf9 1724=back
954c1994 1725
94bdecf9 1726=head1 Magical Functions
954c1994 1727
94bdecf9 1728=over 8
497711e7 1729
94bdecf9 1730=item mg_clear
d8c40edc 1731X<mg_clear>
954c1994 1732
94bdecf9 1733Clear something magical that the SV represents. See C<sv_magic>.
954c1994 1734
94bdecf9 1735 int mg_clear(SV* sv)
954c1994 1736
497711e7 1737=for hackers
94bdecf9 1738Found in file mg.c
497711e7 1739
94bdecf9 1740=item mg_copy
d8c40edc 1741X<mg_copy>
954c1994 1742
94bdecf9 1743Copies the magic from one SV to another. See C<sv_magic>.
954c1994 1744
94bdecf9 1745 int mg_copy(SV* sv, SV* nsv, const char* key, I32 klen)
954c1994 1746
497711e7 1747=for hackers
94bdecf9 1748Found in file mg.c
497711e7 1749
94bdecf9 1750=item mg_find
d8c40edc 1751X<mg_find>
954c1994 1752
94bdecf9 1753Finds the magic pointer for type matching the SV. See C<sv_magic>.
954c1994 1754
35a4481c 1755 MAGIC* mg_find(const SV* sv, int type)
954c1994 1756
497711e7 1757=for hackers
94bdecf9 1758Found in file mg.c
497711e7 1759
94bdecf9 1760=item mg_free
d8c40edc 1761X<mg_free>
954c1994 1762
94bdecf9 1763Free any magic storage used by the SV. See C<sv_magic>.
954c1994 1764
94bdecf9 1765 int mg_free(SV* sv)
954c1994 1766
497711e7 1767=for hackers
94bdecf9 1768Found in file mg.c
497711e7 1769
94bdecf9 1770=item mg_get
d8c40edc 1771X<mg_get>
eebe1485 1772
94bdecf9 1773Do magic after a value is retrieved from the SV. See C<sv_magic>.
282f25c9 1774
94bdecf9 1775 int mg_get(SV* sv)
eebe1485
SC
1776
1777=for hackers
94bdecf9 1778Found in file mg.c
eebe1485 1779
94bdecf9 1780=item mg_length
d8c40edc 1781X<mg_length>
eebe1485 1782
94bdecf9 1783Report on the SV's length. See C<sv_magic>.
eebe1485 1784
94bdecf9 1785 U32 mg_length(SV* sv)
eebe1485
SC
1786
1787=for hackers
94bdecf9 1788Found in file mg.c
eebe1485 1789
94bdecf9 1790=item mg_magical
d8c40edc 1791X<mg_magical>
954c1994 1792
94bdecf9 1793Turns on the magical status of an SV. See C<sv_magic>.
954c1994 1794
94bdecf9 1795 void mg_magical(SV* sv)
954c1994 1796
497711e7 1797=for hackers
94bdecf9 1798Found in file mg.c
497711e7 1799
94bdecf9 1800=item mg_set
d8c40edc 1801X<mg_set>
954c1994 1802
94bdecf9 1803Do magic after a value is assigned to the SV. See C<sv_magic>.
954c1994 1804
94bdecf9 1805 int mg_set(SV* sv)
954c1994 1806
497711e7 1807=for hackers
94bdecf9 1808Found in file mg.c
497711e7 1809
94bdecf9 1810=item SvGETMAGIC
d8c40edc 1811X<SvGETMAGIC>
954c1994 1812
94bdecf9
JH
1813Invokes C<mg_get> on an SV if it has 'get' magic. This macro evaluates its
1814argument more than once.
954c1994 1815
94bdecf9 1816 void SvGETMAGIC(SV* sv)
954c1994 1817
497711e7 1818=for hackers
94bdecf9 1819Found in file sv.h
497711e7 1820
a4f1a029 1821=item SvLOCK
d8c40edc 1822X<SvLOCK>
a4f1a029
NIS
1823
1824Arranges for a mutual exclusion lock to be obtained on sv if a suitable module
1825has been loaded.
1826
1827 void SvLOCK(SV* sv)
1828
1829=for hackers
1830Found in file sv.h
1831
94bdecf9 1832=item SvSETMAGIC
d8c40edc 1833X<SvSETMAGIC>
7d3fb230 1834
94bdecf9
JH
1835Invokes C<mg_set> on an SV if it has 'set' magic. This macro evaluates its
1836argument more than once.
7d3fb230 1837
94bdecf9 1838 void SvSETMAGIC(SV* sv)
7d3fb230
BS
1839
1840=for hackers
94bdecf9 1841Found in file sv.h
7d3fb230 1842
94bdecf9 1843=item SvSetMagicSV
d8c40edc 1844X<SvSetMagicSV>
954c1994 1845
94bdecf9 1846Like C<SvSetSV>, but does any set magic required afterwards.
954c1994 1847
94bdecf9 1848 void SvSetMagicSV(SV* dsb, SV* ssv)
954c1994 1849
497711e7 1850=for hackers
94bdecf9 1851Found in file sv.h
497711e7 1852
a4f1a029 1853=item SvSetMagicSV_nosteal
d8c40edc 1854X<SvSetMagicSV_nosteal>
a4f1a029 1855
80663158 1856Like C<SvSetSV_nosteal>, but does any set magic required afterwards.
a4f1a029
NIS
1857
1858 void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
1859
1860=for hackers
1861Found in file sv.h
1862
94bdecf9 1863=item SvSetSV
d8c40edc 1864X<SvSetSV>
954c1994 1865
94bdecf9
JH
1866Calls C<sv_setsv> if dsv is not the same as ssv. May evaluate arguments
1867more than once.
1868
1869 void SvSetSV(SV* dsb, SV* ssv)
954c1994 1870
497711e7 1871=for hackers
94bdecf9 1872Found in file sv.h
497711e7 1873
94bdecf9 1874=item SvSetSV_nosteal
d8c40edc 1875X<SvSetSV_nosteal>
954c1994 1876
94bdecf9
JH
1877Calls a non-destructive version of C<sv_setsv> if dsv is not the same as
1878ssv. May evaluate arguments more than once.
954c1994 1879
94bdecf9 1880 void SvSetSV_nosteal(SV* dsv, SV* ssv)
954c1994 1881
497711e7 1882=for hackers
94bdecf9 1883Found in file sv.h
497711e7 1884
a4f1a029 1885=item SvSHARE
d8c40edc 1886X<SvSHARE>
a4f1a029
NIS
1887
1888Arranges for sv to be shared between threads if a suitable module
1889has been loaded.
1890
1891 void SvSHARE(SV* sv)
1892
1893=for hackers
1894Found in file sv.h
1895
e509e693 1896=item SvUNLOCK
d8c40edc 1897X<SvUNLOCK>
e509e693
SH
1898
1899Releases a mutual exclusion lock on sv if a suitable module
1900has been loaded.
1901
1902 void SvUNLOCK(SV* sv)
1903
1904=for hackers
1905Found in file sv.h
1906
954c1994 1907
94bdecf9 1908=back
954c1994 1909
94bdecf9 1910=head1 Memory Management
954c1994 1911
94bdecf9 1912=over 8
497711e7 1913
94bdecf9 1914=item Copy
d8c40edc 1915X<Copy>
954c1994 1916
94bdecf9
JH
1917The XSUB-writer's interface to the C C<memcpy> function. The C<src> is the
1918source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
1919the type. May fail on overlapping copies. See also C<Move>.
954c1994 1920
94bdecf9 1921 void Copy(void* src, void* dest, int nitems, type)
954c1994 1922
497711e7 1923=for hackers
94bdecf9 1924Found in file handy.h
497711e7 1925
e90e2364 1926=item CopyD
d8c40edc 1927X<CopyD>
e90e2364
NC
1928
1929Like C<Copy> but returns dest. Useful for encouraging compilers to tail-call
1930optimise.
1931
1932 void * CopyD(void* src, void* dest, int nitems, type)
1933
1934=for hackers
1935Found in file handy.h
1936
94bdecf9 1937=item Move
d8c40edc 1938X<Move>
954c1994 1939
94bdecf9
JH
1940The XSUB-writer's interface to the C C<memmove> function. The C<src> is the
1941source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
1942the type. Can do overlapping moves. See also C<Copy>.
954c1994 1943
94bdecf9 1944 void Move(void* src, void* dest, int nitems, type)
954c1994 1945
497711e7 1946=for hackers
94bdecf9 1947Found in file handy.h
497711e7 1948
e90e2364 1949=item MoveD
d8c40edc 1950X<MoveD>
e90e2364
NC
1951
1952Like C<Move> but returns dest. Useful for encouraging compilers to tail-call
1953optimise.
1954
1955 void * MoveD(void* src, void* dest, int nitems, type)
1956
1957=for hackers
1958Found in file handy.h
1959
a02a5408 1960=item Newx
d8c40edc 1961X<Newx>
954c1994 1962
94bdecf9 1963The XSUB-writer's interface to the C C<malloc> function.
954c1994 1964
c5008215
JC
1965In 5.9.3, Newx() and friends replace the older New() API, and drops
1966the first parameter, I<x>, a debug aid which allowed callers to identify
1967themselves. This aid has been superceded by a new build option,
1968PERL_MEM_LOG (see L<perlhack/PERL_MEM_LOG>). The older API is still
1969there for use in XS modules supporting older perls.
1970
a02a5408 1971 void Newx(void* ptr, int nitems, type)
954c1994 1972
497711e7 1973=for hackers
94bdecf9 1974Found in file handy.h
497711e7 1975
a02a5408 1976=item Newxc
d8c40edc 1977X<Newxc>
954c1994 1978
94bdecf9 1979The XSUB-writer's interface to the C C<malloc> function, with
c5008215 1980cast. See also C<Newx>.
954c1994 1981
a02a5408 1982 void Newxc(void* ptr, int nitems, type, cast)
954c1994 1983
497711e7 1984=for hackers
94bdecf9 1985Found in file handy.h
954c1994 1986
a02a5408 1987=item Newxz
d8c40edc 1988X<Newxz>
954c1994 1989
94bdecf9 1990The XSUB-writer's interface to the C C<malloc> function. The allocated
c5008215 1991memory is zeroed with C<memzero>. See also C<Newx>.
a02a5408
JC
1992
1993 void Newxz(void* ptr, int nitems, type)
954c1994 1994
497711e7
GS
1995=for hackers
1996Found in file handy.h
1997
9965345d 1998=item Poison
d8c40edc 1999X<Poison>
9965345d
JH
2000
2001Fill up memory with a pattern (byte 0xAB over and over again) that
2002hopefully catches attempts to access uninitialized memory.
2003
2004 void Poison(void* dest, int nitems, type)
2005
2006=for hackers
2007Found in file handy.h
2008
94bdecf9 2009=item Renew
d8c40edc 2010X<Renew>
954c1994 2011
94bdecf9 2012The XSUB-writer's interface to the C C<realloc> function.
954c1994 2013
94bdecf9 2014 void Renew(void* ptr, int nitems, type)
954c1994 2015
497711e7
GS
2016=for hackers
2017Found in file handy.h
2018
94bdecf9 2019=item Renewc
d8c40edc 2020X<Renewc>
954c1994 2021
94bdecf9
JH
2022The XSUB-writer's interface to the C C<realloc> function, with
2023cast.
954c1994 2024
94bdecf9 2025 void Renewc(void* ptr, int nitems, type, cast)
954c1994 2026
497711e7 2027=for hackers
94bdecf9 2028Found in file handy.h
497711e7 2029
94bdecf9 2030=item Safefree
d8c40edc 2031X<Safefree>
954c1994 2032
94bdecf9 2033The XSUB-writer's interface to the C C<free> function.
954c1994 2034
94bdecf9 2035 void Safefree(void* ptr)
954c1994 2036
497711e7
GS
2037=for hackers
2038Found in file handy.h
2039
94bdecf9 2040=item savepv
d8c40edc 2041X<savepv>
954c1994 2042
641d4181
JH
2043Perl's version of C<strdup()>. Returns a pointer to a newly allocated
2044string which is a duplicate of C<pv>. The size of the string is
2045determined by C<strlen()>. The memory allocated for the new string can
2046be freed with the C<Safefree()> function.
954c1994 2047
641d4181 2048 char* savepv(const char* pv)
954c1994 2049
497711e7 2050=for hackers
94bdecf9 2051Found in file util.c
497711e7 2052
94bdecf9 2053=item savepvn
d8c40edc 2054X<savepvn>
954c1994 2055
641d4181
JH
2056Perl's version of what C<strndup()> would be if it existed. Returns a
2057pointer to a newly allocated string which is a duplicate of the first
2058C<len> bytes from C<pv>. The memory allocated for the new string can be
2059freed with the C<Safefree()> function.
954c1994 2060
641d4181 2061 char* savepvn(const char* pv, I32 len)
954c1994 2062
497711e7 2063=for hackers
94bdecf9 2064Found in file util.c
497711e7 2065
a4f1a029 2066=item savesharedpv
d8c40edc 2067X<savesharedpv>
a4f1a029 2068
641d4181
JH
2069A version of C<savepv()> which allocates the duplicate string in memory
2070which is shared between threads.
a4f1a029 2071
641d4181 2072 char* savesharedpv(const char* pv)
a4f1a029
NIS
2073
2074=for hackers
2075Found in file util.c
2076
766f8916 2077=item savesvpv
d8c40edc 2078X<savesvpv>
766f8916 2079
9c2fe30c 2080A version of C<savepv()>/C<savepvn()> which gets the string to duplicate from
766f8916
MHM
2081the passed in SV using C<SvPV()>
2082
2083 char* savesvpv(SV* sv)
2084
2085=for hackers
2086Found in file util.c
2087
94bdecf9 2088=item StructCopy
d8c40edc 2089X<StructCopy>
954c1994 2090
94bdecf9 2091This is an architecture-independent macro to copy one structure to another.
954c1994 2092
94bdecf9 2093 void StructCopy(type src, type dest, type)
954c1994 2094
497711e7 2095=for hackers
94bdecf9 2096Found in file handy.h
497711e7 2097
94bdecf9 2098=item Zero
d8c40edc 2099X<Zero>
954c1994 2100
94bdecf9
JH
2101The XSUB-writer's interface to the C C<memzero> function. The C<dest> is the
2102destination, C<nitems> is the number of items, and C<type> is the type.
954c1994 2103
94bdecf9 2104 void Zero(void* dest, int nitems, type)
954c1994 2105
497711e7 2106=for hackers
94bdecf9 2107Found in file handy.h
497711e7 2108
e90e2364 2109=item ZeroD
d8c40edc 2110X<ZeroD>
e90e2364
NC
2111
2112Like C<Zero> but returns dest. Useful for encouraging compilers to tail-call
2113optimise.
2114
2115 void * ZeroD(void* dest, int nitems, type)
2116
2117=for hackers
2118Found in file handy.h
2119
954c1994 2120
94bdecf9 2121=back
954c1994 2122
94bdecf9 2123=head1 Miscellaneous Functions
954c1994 2124
94bdecf9 2125=over 8
497711e7 2126
94bdecf9 2127=item fbm_compile
d8c40edc 2128X<fbm_compile>
8b4ac5a4 2129
94bdecf9
JH
2130Analyses the string in order to make fast searches on it using fbm_instr()
2131-- the Boyer-Moore algorithm.
8b4ac5a4 2132
94bdecf9 2133 void fbm_compile(SV* sv, U32 flags)
8b4ac5a4
JH
2134
2135=for hackers
94bdecf9 2136Found in file util.c
8b4ac5a4 2137
94bdecf9 2138=item fbm_instr
d8c40edc 2139X<fbm_instr>
954c1994 2140
94bdecf9
JH
2141Returns the location of the SV in the string delimited by C<str> and
2142C<strend>. It returns C<Nullch> if the string can't be found. The C<sv>
2143does not have to be fbm_compiled, but the search will not be as fast
2144then.
954c1994 2145
94bdecf9 2146 char* fbm_instr(unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags)
954c1994 2147
497711e7 2148=for hackers
94bdecf9 2149Found in file util.c
497711e7 2150
94bdecf9 2151=item form
d8c40edc 2152X<form>
954c1994 2153
94bdecf9
JH
2154Takes a sprintf-style format pattern and conventional
2155(non-SV) arguments and returns the formatted string.
954c1994 2156
94bdecf9 2157 (char *) Perl_form(pTHX_ const char* pat, ...)
954c1994 2158
94bdecf9 2159can be used any place a string (char *) is required:
497711e7 2160
94bdecf9 2161 char * s = Perl_form("%d.%d",major,minor);
954c1994 2162
94bdecf9
JH
2163Uses a single private buffer so if you want to format several strings you
2164must explicitly copy the earlier strings away (and free the copies when you
2165are done).
954c1994 2166
94bdecf9 2167 char* form(const char* pat, ...)
954c1994 2168
497711e7 2169=for hackers
94bdecf9 2170Found in file util.c
497711e7 2171
94bdecf9 2172=item getcwd_sv
d8c40edc 2173X<getcwd_sv>
954c1994 2174
94bdecf9 2175Fill the sv with current working directory
954c1994 2176
94bdecf9 2177 int getcwd_sv(SV* sv)
954c1994 2178
497711e7 2179=for hackers
94bdecf9 2180Found in file util.c
497711e7 2181
9244d4ad
RGS
2182=item my_sprintf
2183X<my_sprintf>
2184
2185The C library C<sprintf>, wrapped if necessary, to ensure that it will return
2186the length of the string written to the buffer. Only rare pre-ANSI systems
2187need the wrapper function - usually this is a direct call to C<sprintf>.
2188
2189 int my_sprintf(char *buffer, const char *pat, ...)
2190
2191=for hackers
2192Found in file util.c
2193
f333445c 2194=item new_version
d8c40edc 2195X<new_version>
f333445c
JP
2196
2197Returns a new version object based on the passed in SV:
2198
2199 SV *sv = new_version(SV *ver);
2200
2201Does not alter the passed in ver SV. See "upg_version" if you
2202want to upgrade the SV.
2203
2204 SV* new_version(SV *ver)
2205
2206=for hackers
2207Found in file util.c
2208
2209=item scan_version
d8c40edc 2210X<scan_version>
f333445c
JP
2211
2212Returns a pointer to the next character after the parsed
2213version string, as well as upgrading the passed in SV to
2214an RV.
2215
2216Function must be called with an already existing SV like
2217
137d6fc0
JP
2218 sv = newSV(0);
2219 s = scan_version(s,SV *sv, bool qv);
f333445c
JP
2220
2221Performs some preprocessing to the string to ensure that
2222it has the correct characteristics of a version. Flags the
2223object if it contains an underscore (which denotes this
137d6fc0
JP
2224is a alpha version). The boolean qv denotes that the version
2225should be interpreted as if it had multiple decimals, even if
2226it doesn't.
f333445c 2227
9137345a 2228 const char* scan_version(const char *vstr, SV *sv, bool qv)
f333445c
JP
2229
2230=for hackers
2231Found in file util.c
2232
94bdecf9 2233=item strEQ
d8c40edc 2234X<strEQ>
954c1994 2235
94bdecf9 2236Test two strings to see if they are equal. Returns true or false.
954c1994 2237
94bdecf9 2238 bool strEQ(char* s1, char* s2)
954c1994 2239
497711e7 2240=for hackers
94bdecf9 2241Found in file handy.h
497711e7 2242
94bdecf9 2243=item strGE
d8c40edc 2244X<strGE>
1c846c1f 2245
94bdecf9
JH
2246Test two strings to see if the first, C<s1>, is greater than or equal to
2247the second, C<s2>. Returns true or false.
1c846c1f 2248
94bdecf9 2249 bool strGE(char* s1, char* s2)
1c846c1f
NIS
2250
2251=for hackers
94bdecf9 2252Found in file handy.h
1c846c1f 2253
94bdecf9 2254=item strGT
d8c40edc 2255X<strGT>
954c1994 2256
94bdecf9
JH
2257Test two strings to see if the first, C<s1>, is greater than the second,
2258C<s2>. Returns true or false.
954c1994 2259
94bdecf9 2260 bool strGT(char* s1, char* s2)
954c1994 2261
497711e7 2262=for hackers
94bdecf9 2263Found in file handy.h
497711e7 2264
94bdecf9 2265=item strLE
d8c40edc 2266X<strLE>
954c1994 2267
94bdecf9
JH
2268Test two strings to see if the first, C<s1>, is less than or equal to the
2269second, C<s2>. Returns true or false.
954c1994 2270
94bdecf9 2271 bool strLE(char* s1, char* s2)
954c1994 2272
497711e7 2273=for hackers
94bdecf9 2274Found in file handy.h
497711e7 2275
94bdecf9 2276=item strLT
d8c40edc 2277X<strLT>
1a3327fb 2278
94bdecf9
JH
2279Test two strings to see if the first, C<s1>, is less than the second,
2280C<s2>. Returns true or false.
1a3327fb 2281
94bdecf9 2282 bool strLT(char* s1, char* s2)
1a3327fb 2283
497711e7 2284=for hackers
94bdecf9 2285Found in file handy.h
497711e7 2286
94bdecf9 2287=item strNE
d8c40edc 2288X<strNE>
954c1994 2289
94bdecf9
JH
2290Test two strings to see if they are different. Returns true or
2291false.
2292
2293 bool strNE(char* s1, char* s2)
954c1994 2294
497711e7 2295=for hackers
94bdecf9 2296Found in file handy.h
497711e7 2297
94bdecf9 2298=item strnEQ
d8c40edc 2299X<strnEQ>
954c1994 2300
94bdecf9
JH
2301Test two strings to see if they are equal. The C<len> parameter indicates
2302the number of bytes to compare. Returns true or false. (A wrapper for
2303C<strncmp>).
2304
2305 bool strnEQ(char* s1, char* s2, STRLEN len)
954c1994 2306
497711e7 2307=for hackers
94bdecf9 2308Found in file handy.h
497711e7 2309
94bdecf9 2310=item strnNE
d8c40edc 2311X<strnNE>
954c1994 2312
94bdecf9
JH
2313Test two strings to see if they are different. The C<len> parameter
2314indicates the number of bytes to compare. Returns true or false. (A
2315wrapper for C<strncmp>).
954c1994 2316
94bdecf9 2317 bool strnNE(char* s1, char* s2, STRLEN len)
954c1994 2318
497711e7
GS
2319=for hackers
2320Found in file handy.h
2321
f333445c 2322=item sv_nosharing
d8c40edc 2323X<sv_nosharing>
f333445c
JP
2324
2325Dummy routine which "shares" an SV when there is no sharing module present.
9244d4ad
RGS
2326Or "locks" it. Or "unlocks" it. In other words, ignores its single SV argument.
2327Exists to avoid test for a NULL function pointer and because it could
2328potentially warn under some level of strict-ness.
f333445c
JP
2329
2330 void sv_nosharing(SV *)
2331
2332=for hackers
2333Found in file util.c
2334
f333445c 2335=item upg_version
d8c40edc 2336X<upg_version>
f333445c
JP
2337
2338In-place upgrade of the supplied SV to a version object.
2339
2340 SV *sv = upg_version(SV *sv);
2341
2342Returns a pointer to the upgraded SV.
2343
2344 SV* upg_version(SV *ver)
2345
2346=for hackers
2347Found in file util.c
2348
2349=item vcmp
d8c40edc 2350X<vcmp>
f333445c
JP
2351
2352Version object aware cmp. Both operands must already have been
2353converted into version objects.
2354
2355 int vcmp(SV *lvs, SV *rvs)
2356
2357=for hackers
2358Found in file util.c
2359
b9381830 2360=item vnormal
d8c40edc 2361X<vnormal>
b9381830
JP
2362
2363Accepts a version object and returns the normalized string
2364representation. Call like:
2365
2366 sv = vnormal(rv);
2367
2368NOTE: you can pass either the object directly or the SV
2369contained within the RV.
2370
2371 SV* vnormal(SV *vs)
2372
2373=for hackers
2374Found in file util.c
2375
f333445c 2376=item vnumify
d8c40edc 2377X<vnumify>
f333445c
JP
2378
2379Accepts a version object and returns the normalized floating
2380point representation. Call like:
2381
2382 sv = vnumify(rv);
2383
2384NOTE: you can pass either the object directly or the SV
2385contained within the RV.
2386
2387 SV* vnumify(SV *vs)
2388
2389=for hackers
2390Found in file util.c
2391
2392=item vstringify
d8c40edc 2393X<vstringify>
f333445c 2394
b9381830
JP
2395In order to maintain maximum compatibility with earlier versions
2396of Perl, this function will return either the floating point
2397notation or the multiple dotted notation, depending on whether
2398the original version contained 1 or more dots, respectively
f333445c
JP
2399
2400 SV* vstringify(SV *vs)
2401
2402=for hackers
2403Found in file util.c
2404
e0218a61 2405=item vverify
d8c40edc 2406X<vverify>
e0218a61
JP
2407
2408Validates that the SV contains a valid version object.
2409
2410 bool vverify(SV *vobj);
2411
2412Note that it only confirms the bare minimum structure (so as not to get
2413confused by derived classes which may contain additional hash entries):
2414
2415 bool vverify(SV *vs)
2416
2417=for hackers
2418Found in file util.c
2419
f4758303 2420
94bdecf9 2421=back
7207e29d 2422
cd299c6e
RGS
2423=head1 Multicall Functions
2424
2425=over 8
2426
2427=item dMULTICALL
2428X<dMULTICALL>
2429
2430Declare local variables for a multicall. See L<perlcall/Lightweight Callbacks>.
2431
2432 dMULTICALL;
2433
2434=for hackers
2435Found in file cop.h
2436
2437=item MULTICALL
2438X<MULTICALL>
2439
2440Make a lightweight callback. See L<perlcall/Lightweight Callbacks>.
2441
2442 MULTICALL;
2443
2444=for hackers
2445Found in file cop.h
2446
2447=item POP_MULTICALL
2448X<POP_MULTICALL>
2449
2450Closing bracket for a lightweight callback.
2451See L<perlcall/Lightweight Callbacks>.
2452
2453 POP_MULTICALL;
2454
2455=for hackers
2456Found in file cop.h
2457
2458=item PUSH_MULTICALL
2459X<PUSH_MULTICALL>
2460
2461Opening bracket for a lightweight callback.
2462See L<perlcall/Lightweight Callbacks>.
2463
2464 PUSH_MULTICALL;
2465
2466=for hackers
2467Found in file cop.h
2468
2469
2470=back
2471
94bdecf9 2472=head1 Numeric functions
7207e29d 2473
94bdecf9 2474=over 8
f4758303 2475
94bdecf9 2476=item grok_bin
d8c40edc 2477X<grok_bin>
f4758303 2478
94bdecf9
JH
2479converts a string representing a binary number to numeric form.
2480
2481On entry I<start> and I<*len> give the string to scan, I<*flags> gives
2482conversion flags, and I<result> should be NULL or a pointer to an NV.
2483The scan stops at the end of the string, or the first invalid character.
7b667b5f
MHM
2484Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an
2485invalid character will also trigger a warning.
2486On return I<*len> is set to the length of the scanned string,
2487and I<*flags> gives output flags.
94bdecf9 2488
7fc63493 2489If the value is <= C<UV_MAX> it is returned as a UV, the output flags are clear,
94bdecf9
JH
2490and nothing is written to I<*result>. If the value is > UV_MAX C<grok_bin>
2491returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags,
2492and writes the value to I<*result> (or the value is discarded if I<result>
2493is NULL).
2494
7b667b5f 2495The binary number may optionally be prefixed with "0b" or "b" unless
94bdecf9
JH
2496C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If
2497C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the binary
2498number may use '_' characters to separate digits.
2499
a3b680e6 2500 UV grok_bin(const char* start, STRLEN* len_p, I32* flags, NV *result)
f4758303
JP
2501
2502=for hackers
94bdecf9 2503Found in file numeric.c
f4758303 2504
94bdecf9 2505=item grok_hex
d8c40edc 2506X<grok_hex>
954c1994 2507
94bdecf9
JH
2508converts a string representing a hex number to numeric form.
2509
2510On entry I<start> and I<*len> give the string to scan, I<*flags> gives
2511conversion flags, and I<result> should be NULL or a pointer to an NV.
7b667b5f
MHM
2512The scan stops at the end of the string, or the first invalid character.
2513Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an
2514invalid character will also trigger a warning.
2515On return I<*len> is set to the length of the scanned string,
2516and I<*flags> gives output flags.
94bdecf9
JH
2517
2518If the value is <= UV_MAX it is returned as a UV, the output flags are clear,
2519and nothing is written to I<*result>. If the value is > UV_MAX C<grok_hex>
2520returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags,
2521and writes the value to I<*result> (or the value is discarded if I<result>
2522is NULL).
2523
2524The hex number may optionally be prefixed with "0x" or "x" unless
2525C<PERL_SCAN_DISALLOW_PREFIX> is set in I<*flags> on entry. If
2526C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the hex
2527number may use '_' characters to separate digits.
2528
a3b680e6 2529 UV grok_hex(const char* start, STRLEN* len_p, I32* flags, NV *result)
954c1994 2530
497711e7 2531=for hackers
94bdecf9 2532Found in file numeric.c
497711e7 2533
94bdecf9 2534=item grok_number
d8c40edc 2535X<grok_number>
954c1994 2536
94bdecf9
JH
2537Recognise (or not) a number. The type of the number is returned
2538(0 if unrecognised), otherwise it is a bit-ORed combination of
2539IS_NUMBER_IN_UV, IS_NUMBER_GREATER_THAN_UV_MAX, IS_NUMBER_NOT_INT,
2540IS_NUMBER_NEG, IS_NUMBER_INFINITY, IS_NUMBER_NAN (defined in perl.h).
2541
2542If the value of the number can fit an in UV, it is returned in the *valuep
2543IS_NUMBER_IN_UV will be set to indicate that *valuep is valid, IS_NUMBER_IN_UV
2544will never be set unless *valuep is valid, but *valuep may have been assigned
2545to during processing even though IS_NUMBER_IN_UV is not set on return.
2546If valuep is NULL, IS_NUMBER_IN_UV will be set for the same cases as when
2547valuep is non-NULL, but no actual assignment (or SEGV) will occur.
2548
2549IS_NUMBER_NOT_INT will be set with IS_NUMBER_IN_UV if trailing decimals were
2550seen (in which case *valuep gives the true value truncated to an integer), and
2551IS_NUMBER_NEG if the number is negative (in which case *valuep holds the
2552absolute value). IS_NUMBER_IN_UV is not set if e notation was used or the
2553number is larger than a UV.
2554
2555 int grok_number(const char *pv, STRLEN len, UV *valuep)
954c1994 2556
497711e7 2557=for hackers
94bdecf9 2558Found in file numeric.c
497711e7 2559
94bdecf9 2560=item grok_numeric_radix
d8c40edc 2561X<grok_numeric_radix>
954c1994 2562
94bdecf9
JH
2563Scan and skip for a numeric decimal separator (radix).
2564
2565 bool grok_numeric_radix(const char **sp, const char *send)
954c1994 2566
497711e7 2567=for hackers
94bdecf9 2568Found in file numeric.c
497711e7 2569
94bdecf9 2570=item grok_oct
d8c40edc 2571X<grok_oct>
954c1994 2572
7b667b5f
MHM
2573converts a string representing an octal number to numeric form.
2574
2575On entry I<start> and I<*len> give the string to scan, I<*flags> gives
2576conversion flags, and I<result> should be NULL or a pointer to an NV.
2577The scan stops at the end of the string, or the first invalid character.
2578Unless C<PERL_SCAN_SILENT_ILLDIGIT> is set in I<*flags>, encountering an
2579invalid character will also trigger a warning.
2580On return I<*len> is set to the length of the scanned string,
2581and I<*flags> gives output flags.
2582
2583If the value is <= UV_MAX it is returned as a UV, the output flags are clear,
2584and nothing is written to I<*result>. If the value is > UV_MAX C<grok_oct>
2585returns UV_MAX, sets C<PERL_SCAN_GREATER_THAN_UV_MAX> in the output flags,
2586and writes the value to I<*result> (or the value is discarded if I<result>
2587is NULL).
2588
2589If C<PERL_SCAN_ALLOW_UNDERSCORES> is set in I<*flags> then the octal
2590number may use '_' characters to separate digits.
94bdecf9 2591
a3b680e6 2592 UV grok_oct(const char* start, STRLEN* len_p, I32* flags, NV *result)
954c1994 2593
497711e7 2594=for hackers
94bdecf9 2595Found in file numeric.c
497711e7 2596
94bdecf9 2597=item scan_bin
d8c40edc 2598X<scan_bin>
954c1994 2599
94bdecf9
JH
2600For backwards compatibility. Use C<grok_bin> instead.
2601
73d840c0 2602 NV scan_bin(const char* start, STRLEN len, STRLEN* retlen)
954c1994 2603
497711e7 2604=for hackers
94bdecf9 2605Found in file numeric.c
497711e7 2606
94bdecf9 2607=item scan_hex
d8c40edc 2608X<scan_hex>
954c1994 2609
94bdecf9
JH
2610For backwards compatibility. Use C<grok_hex> instead.
2611
73d840c0 2612 NV scan_hex(const char* start, STRLEN len, STRLEN* retlen)
954c1994 2613
497711e7 2614=for hackers
94bdecf9 2615Found in file numeric.c
497711e7 2616
94bdecf9 2617=item scan_oct
d8c40edc 2618X<scan_oct>
954c1994 2619
94bdecf9 2620For backwards compatibility. Use C<grok_oct> instead.
954c1994 2621
73d840c0 2622 NV scan_oct(const char* start, STRLEN len, STRLEN* retlen)
954c1994 2623
497711e7 2624=for hackers
94bdecf9 2625Found in file numeric.c
497711e7 2626
645c22ef 2627
94bdecf9 2628=back
645c22ef 2629
94bdecf9
JH
2630=head1 Optree Manipulation Functions
2631
2632=over 8
2633
2634=item cv_const_sv
d8c40edc 2635X<cv_const_sv>
94bdecf9
JH
2636
2637If C<cv> is a constant sub eligible for inlining. returns the constant
2638value returned by the sub. Otherwise, returns NULL.
2639
2640Constant subs can be created with C<newCONSTSUB> or as described in
2641L<perlsub/"Constant Functions">.
2642
2643 SV* cv_const_sv(CV* cv)
645c22ef
DM
2644
2645=for hackers
94bdecf9 2646Found in file op.c
645c22ef 2647
94bdecf9 2648=item newCONSTSUB
d8c40edc 2649X<newCONSTSUB>
954c1994 2650
94bdecf9
JH
2651Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is
2652eligible for inlining at compile-time.
954c1994 2653
e1ec3a88 2654 CV* newCONSTSUB(HV* stash, const char* name, SV* sv)
954c1994 2655
497711e7 2656=for hackers
94bdecf9 2657Found in file op.c
497711e7 2658
94bdecf9 2659=item newXS
d8c40edc 2660X<newXS>
954c1994 2661
94bdecf9 2662Used by C<xsubpp> to hook up XSUBs as Perl subs.
954c1994 2663
94bdecf9
JH
2664=for hackers
2665Found in file op.c
2666
2667
2668=back
2669
dd2155a4
DM
2670=head1 Pad Data Structures
2671
2672=over 8
2673
2674=item pad_sv
d8c40edc 2675X<pad_sv>
dd2155a4
DM
2676
2677Get the value at offset po in the current pad.
2678Use macro PAD_SV instead of calling this function directly.
2679
2680 SV* pad_sv(PADOFFSET po)
2681
2682=for hackers
2683Found in file pad.c
2684
2685
2686=back
2687
59887a99
MHM
2688=head1 Simple Exception Handling Macros
2689
2690=over 8
2691
2692=item dXCPT
d8c40edc 2693X<dXCPT>
59887a99 2694
2dfe1b17 2695Set up necessary local variables for exception handling.
59887a99
MHM
2696See L<perlguts/"Exception Handling">.
2697
2698 dXCPT;
2699
2700=for hackers
2701Found in file XSUB.h
2702
2703=item XCPT_CATCH
d8c40edc 2704X<XCPT_CATCH>
59887a99
MHM
2705
2706Introduces a catch block. See L<perlguts/"Exception Handling">.
2707
2708=for hackers
2709Found in file XSUB.h
2710
2711=item XCPT_RETHROW
d8c40edc 2712X<XCPT_RETHROW>
59887a99
MHM
2713
2714Rethrows a previously caught exception. See L<perlguts/"Exception Handling">.
2715
2716 XCPT_RETHROW;
2717
2718=for hackers
2719Found in file XSUB.h
2720
2721=item XCPT_TRY_END
d8c40edc 2722X<XCPT_TRY_END>
59887a99
MHM
2723
2724Ends a try block. See L<perlguts/"Exception Handling">.
2725
2726=for hackers
2727Found in file XSUB.h
2728
2729=item XCPT_TRY_START
d8c40edc 2730X<XCPT_TRY_START>
59887a99
MHM
2731
2732Starts a try block. See L<perlguts/"Exception Handling">.
2733
2734=for hackers
2735Found in file XSUB.h
2736
2737
2738=back
2739
94bdecf9
JH
2740=head1 Stack Manipulation Macros
2741
2742=over 8
2743
2744=item dMARK
d8c40edc 2745X<dMARK>
954c1994 2746
94bdecf9
JH
2747Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and
2748C<dORIGMARK>.
954c1994 2749
94bdecf9 2750 dMARK;
954c1994 2751
497711e7 2752=for hackers
94bdecf9 2753Found in file pp.h
497711e7 2754
94bdecf9 2755=item dORIGMARK
d8c40edc 2756X<dORIGMARK>
954c1994 2757
94bdecf9 2758Saves the original stack mark for the XSUB. See C<ORIGMARK>.
954c1994 2759
94bdecf9 2760 dORIGMARK;
954c1994 2761
497711e7 2762=for hackers
94bdecf9 2763Found in file pp.h
497711e7 2764
94bdecf9 2765=item dSP
d8c40edc 2766X<dSP>
954c1994 2767
94bdecf9
JH
2768Declares a local copy of perl's stack pointer for the XSUB, available via
2769the C<SP> macro. See C<SP>.
954c1994 2770
94bdecf9 2771 dSP;
954c1994 2772
497711e7 2773=for hackers
94bdecf9 2774Found in file pp.h
497711e7 2775
94bdecf9 2776=item EXTEND
d8c40edc 2777X<EXTEND>
954c1994 2778
94bdecf9
JH
2779Used to extend the argument stack for an XSUB's return values. Once
2780used, guarantees that there is room for at least C<nitems> to be pushed
2781onto the stack.
954c1994 2782
94bdecf9 2783 void EXTEND(SP, int nitems)
954c1994 2784
497711e7 2785=for hackers
94bdecf9 2786Found in file pp.h
954c1994 2787
94bdecf9 2788=item MARK
d8c40edc 2789X<MARK>
954c1994 2790
94bdecf9 2791Stack marker variable for the XSUB. See C<dMARK>.
954c1994 2792
497711e7 2793=for hackers
94bdecf9 2794Found in file pp.h
954c1994 2795
d82b684c 2796=item mPUSHi
d8c40edc 2797X<mPUSHi>
d82b684c
SH
2798
2799Push an integer onto the stack. The stack must have room for this element.
de4f2208
RGS
2800Handles 'set' magic. Does not use C<TARG>. See also C<PUSHi>, C<mXPUSHi>
2801and C<XPUSHi>.
d82b684c
SH
2802
2803 void mPUSHi(IV iv)
2804
2805=for hackers
2806Found in file pp.h
2807
2808=item mPUSHn
d8c40edc 2809X<mPUSHn>
d82b684c
SH
2810
2811Push a double onto the stack. The stack must have room for this element.
de4f2208
RGS
2812Handles 'set' magic. Does not use C<TARG>. See also C<PUSHn>, C<mXPUSHn>
2813and C<XPUSHn>.
d82b684c
SH
2814
2815 void mPUSHn(NV nv)
2816
2817=for hackers
2818Found in file pp.h
2819
2820=item mPUSHp
d8c40edc 2821X<mPUSHp>
d82b684c
SH
2822
2823Push a string onto the stack. The stack must have room for this element.
de4f2208
RGS
2824The C<len> indicates the length of the string. Handles 'set' magic. Does
2825not use C<TARG>. See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>.
d82b684c
SH
2826
2827 void mPUSHp(char* str, STRLEN len)
2828
2829=for hackers
2830Found in file pp.h
2831
2832=item mPUSHu
d8c40edc 2833X<mPUSHu>
d82b684c
SH
2834
2835Push an unsigned integer onto the stack. The stack must have room for this
de4f2208
RGS
2836element. Handles 'set' magic. Does not use C<TARG>. See also C<PUSHu>,
2837C<mXPUSHu> and C<XPUSHu>.
d82b684c
SH
2838
2839 void mPUSHu(UV uv)
2840
2841=for hackers
2842Found in file pp.h
2843
2844=item mXPUSHi
d8c40edc 2845X<mXPUSHi>
d82b684c 2846
de4f2208
RGS
2847Push an integer onto the stack, extending the stack if necessary. Handles
2848'set' magic. Does not use C<TARG>. See also C<XPUSHi>, C<mPUSHi> and
2849C<PUSHi>.
d82b684c
SH
2850
2851 void mXPUSHi(IV iv)
2852
2853=for hackers
2854Found in file pp.h
2855
2856=item mXPUSHn
d8c40edc 2857X<mXPUSHn>
d82b684c 2858
de4f2208
RGS
2859Push a double onto the stack, extending the stack if necessary. Handles
2860'set' magic. Does not use C<TARG>. See also C<XPUSHn>, C<mPUSHn> and
2861C<PUSHn>.
d82b684c
SH
2862
2863 void mXPUSHn(NV nv)
2864
2865=for hackers
2866Found in file pp.h
2867
2868=item mXPUSHp
d8c40edc 2869X<mXPUSHp>
d82b684c
SH
2870
2871Push a string onto the stack, extending the stack if necessary. The C<len>
de4f2208
RGS
2872indicates the length of the string. Handles 'set' magic. Does not use
2873C<TARG>. See also C<XPUSHp>, C<mPUSHp> and C<PUSHp>.
d82b684c
SH
2874
2875 void mXPUSHp(char* str, STRLEN len)
2876
2877=for hackers
2878Found in file pp.h
2879
2880=item mXPUSHu
d8c40edc 2881X<mXPUSHu>
d82b684c
SH
2882
2883Push an unsigned integer onto the stack, extending the stack if necessary.
de4f2208
RGS
2884Handles 'set' magic. Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu>
2885and C<PUSHu>.
d82b684c
SH
2886
2887 void mXPUSHu(UV uv)
2888
2889=for hackers
2890Found in file pp.h
2891
94bdecf9 2892=item ORIGMARK
d8c40edc 2893X<ORIGMARK>
954c1994 2894
94bdecf9 2895The original stack mark for the XSUB. See C<dORIGMARK>.
954c1994 2896
497711e7 2897=for hackers
94bdecf9 2898Found in file pp.h
497711e7 2899
954c1994 2900=item POPi
d8c40edc 2901X<POPi>
954c1994
GS
2902
2903Pops an integer off the stack.
2904
2905 IV POPi
2906
497711e7
GS
2907=for hackers
2908Found in file pp.h
2909
954c1994 2910=item POPl
d8c40edc 2911X<POPl>
954c1994
GS
2912
2913Pops a long off the stack.
2914
2915 long POPl
2916
497711e7
GS
2917=for hackers
2918Found in file pp.h
2919
954c1994 2920=item POPn
d8c40edc 2921X<POPn>
954c1994
GS
2922
2923Pops a double off the stack.
2924
2925 NV POPn
2926
497711e7
GS
2927=for hackers
2928Found in file pp.h
2929
954c1994 2930=item POPp
d8c40edc 2931X<POPp>
954c1994 2932
184499a4 2933Pops a string off the stack. Deprecated. New code should use POPpx.
954c1994
GS
2934
2935 char* POPp
2936
497711e7
GS
2937=for hackers
2938Found in file pp.h
2939
fa519979 2940=item POPpbytex
d8c40edc 2941X<POPpbytex>
fa519979
JH
2942
2943Pops a string off the stack which must consist of bytes i.e. characters < 256.
fa519979
JH
2944
2945 char* POPpbytex
2946
2947=for hackers
2948Found in file pp.h
2949
2950=item POPpx
d8c40edc 2951X<POPpx>
fa519979
JH
2952
2953Pops a string off the stack.
fa519979
JH
2954
2955 char* POPpx
2956
2957=for hackers
2958Found in file pp.h
2959
954c1994 2960=item POPs
d8c40edc 2961X<POPs>
954c1994
GS
2962
2963Pops an SV off the stack.
2964
2965 SV* POPs
2966
497711e7
GS
2967=for hackers
2968Found in file pp.h
2969
954c1994 2970=item PUSHi
d8c40edc 2971X<PUSHi>
954c1994
GS
2972
2973Push an integer onto the stack. The stack must have room for this element.
d82b684c
SH
2974Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
2975called to declare it. Do not call multiple C<TARG>-oriented macros to
2976return lists from XSUB's - see C<mPUSHi> instead. See also C<XPUSHi> and
2977C<mXPUSHi>.
954c1994
GS
2978
2979 void PUSHi(IV iv)
2980
497711e7
GS
2981=for hackers
2982Found in file pp.h
2983
954c1994 2984=item PUSHMARK
d8c40edc 2985X<PUSHMARK>
954c1994
GS
2986
2987Opening bracket for arguments on a callback. See C<PUTBACK> and
2988L<perlcall>.
2989
c578083c 2990 void PUSHMARK(SP)
954c1994 2991
497711e7
GS
2992=for hackers
2993Found in file pp.h
2994
d82b684c 2995=item PUSHmortal
d8c40edc 2996X<PUSHmortal>
d82b684c
SH
2997
2998Push a new mortal SV onto the stack. The stack must have room for this
2999element. Does not handle 'set' magic. Does not use C<TARG>. See also
3000C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>.
3001
3002 void PUSHmortal()
3003
3004=for hackers
3005Found in file pp.h
3006
954c1994 3007=item PUSHn
d8c40edc 3008X<PUSHn>
954c1994
GS
3009
3010Push a double onto the stack. The stack must have room for this element.
d82b684c
SH
3011Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
3012called to declare it. Do not call multiple C<TARG>-oriented macros to
3013return lists from XSUB's - see C<mPUSHn> instead. See also C<XPUSHn> and
3014C<mXPUSHn>.
954c1994
GS
3015
3016 void PUSHn(NV nv)
3017
497711e7
GS
3018=for hackers
3019Found in file pp.h
3020
954c1994 3021=item PUSHp
d8c40edc 3022X<PUSHp>
954c1994
GS
3023
3024Push a string onto the stack. The stack must have room for this element.
d82b684c
SH
3025The C<len> indicates the length of the string. Handles 'set' magic. Uses
3026C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it. Do not
3027call multiple C<TARG>-oriented macros to return lists from XSUB's - see
3028C<mPUSHp> instead. See also C<XPUSHp> and C<mXPUSHp>.
954c1994
GS
3029
3030 void PUSHp(char* str, STRLEN len)
3031
497711e7
GS
3032=for hackers
3033Found in file pp.h
3034
954c1994 3035=item PUSHs
d8c40edc 3036X<PUSHs>
954c1994 3037
1c846c1f 3038Push an SV onto the stack. The stack must have room for this element.
d82b684c
SH
3039Does not handle 'set' magic. Does not use C<TARG>. See also C<PUSHmortal>,
3040C<XPUSHs> and C<XPUSHmortal>.
954c1994
GS
3041
3042 void PUSHs(SV* sv)
3043
497711e7
GS
3044=for hackers
3045Found in file pp.h
3046
954c1994 3047=item PUSHu
d8c40edc 3048X<PUSHu>
954c1994
GS
3049
3050Push an unsigned integer onto the stack. The stack must have room for this
d82b684c
SH
3051element. Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG>
3052should be called to declare it. Do not call multiple C<TARG>-oriented
3053macros to return lists from XSUB's - see C<mPUSHu> instead. See also
3054C<XPUSHu> and C<mXPUSHu>.
954c1994
GS
3055
3056 void PUSHu(UV uv)
3057
497711e7
GS
3058=for hackers
3059Found in file pp.h
3060
954c1994 3061=item PUTBACK
d8c40edc 3062X<PUTBACK>
954c1994
GS
3063
3064Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
3065See C<PUSHMARK> and L<perlcall> for other uses.
3066
3067 PUTBACK;
3068
497711e7
GS
3069=for hackers
3070Found in file pp.h
3071
94bdecf9 3072=item SP
d8c40edc 3073X<SP>
d2cc3551 3074
94bdecf9
JH
3075Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and
3076C<SPAGAIN>.
d2cc3551 3077
94bdecf9
JH
3078=for hackers
3079Found in file pp.h
3080
3081=item SPAGAIN
d8c40edc 3082X<SPAGAIN>
94bdecf9
JH
3083
3084Refetch the stack pointer. Used after a callback. See L<perlcall>.
3085
3086 SPAGAIN;
d2cc3551
JH
3087
3088=for hackers
94bdecf9 3089Found in file pp.h
d2cc3551 3090
94bdecf9 3091=item XPUSHi
d8c40edc 3092X<XPUSHi>
954c1994 3093
94bdecf9 3094Push an integer onto the stack, extending the stack if necessary. Handles
d82b684c
SH
3095'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
3096declare it. Do not call multiple C<TARG>-oriented macros to return lists
3097from XSUB's - see C<mXPUSHi> instead. See also C<PUSHi> and C<mPUSHi>.
954c1994 3098
94bdecf9 3099 void XPUSHi(IV iv)
954c1994 3100
497711e7 3101=for hackers
94bdecf9 3102Found in file pp.h
497711e7 3103
d82b684c 3104=item XPUSHmortal
d8c40edc 3105X<XPUSHmortal>
d82b684c
SH
3106
3107Push a new mortal SV onto the stack, extending the stack if necessary. Does
3108not handle 'set' magic. Does not use C<TARG>. See also C<XPUSHs>,
3109C<PUSHmortal> and C<PUSHs>.
3110
3111 void XPUSHmortal()
3112
3113=for hackers
3114Found in file pp.h
3115
94bdecf9 3116=item XPUSHn
d8c40edc 3117X<XPUSHn>
954c1994 3118
94bdecf9 3119Push a double onto the stack, extending the stack if necessary. Handles
d82b684c
SH
3120'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
3121declare it. Do not call multiple C<TARG>-oriented macros to return lists
3122from XSUB's - see C<mXPUSHn> instead. See also C<PUSHn> and C<mPUSHn>.
954c1994 3123
94bdecf9 3124 void XPUSHn(NV nv)
954c1994 3125
497711e7 3126=for hackers
94bdecf9 3127Found in file pp.h
497711e7 3128
94bdecf9 3129=item XPUSHp
d8c40edc 3130X<XPUSHp>
954c1994 3131
94bdecf9 3132Push a string onto the stack, extending the stack if necessary. The C<len>
d82b684c
SH
3133indicates the length of the string. Handles 'set' magic. Uses C<TARG>, so
3134C<dTARGET> or C<dXSTARG> should be called to declare it. Do not call
3135multiple C<TARG>-oriented macros to return lists from XSUB's - see
3136C<mXPUSHp> instead. See also C<PUSHp> and C<mPUSHp>.
954c1994 3137
94bdecf9 3138 void XPUSHp(char* str, STRLEN len)
954c1994 3139
94bdecf9
JH
3140=for hackers
3141Found in file pp.h
3142
3143=item XPUSHs
d8c40edc 3144X<XPUSHs>
94bdecf9
JH
3145
3146Push an SV onto the stack, extending the stack if necessary. Does not
d82b684c
SH
3147handle 'set' magic. Does not use C<TARG>. See also C<XPUSHmortal>,
3148C<PUSHs> and C<PUSHmortal>.
94bdecf9
JH
3149
3150 void XPUSHs(SV* sv)
954c1994 3151
497711e7 3152=for hackers
94bdecf9 3153Found in file pp.h
497711e7 3154
94bdecf9 3155=item XPUSHu
d8c40edc 3156X<XPUSHu>
954c1994 3157
94bdecf9 3158Push an unsigned integer onto the stack, extending the stack if necessary.
d82b684c
SH
3159Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
3160called to declare it. Do not call multiple C<TARG>-oriented macros to
3161return lists from XSUB's - see C<mXPUSHu> instead. See also C<PUSHu> and
3162C<mPUSHu>.
954c1994 3163
94bdecf9
JH
3164 void XPUSHu(UV uv)
3165
3166=for hackers
3167Found in file pp.h
3168
3169=item XSRETURN
d8c40edc 3170X<XSRETURN>
94bdecf9
JH
3171
3172Return from XSUB, indicating number of items on the stack. This is usually
3173handled by C<xsubpp>.
3174
3175 void XSRETURN(int nitems)
954c1994 3176
497711e7
GS
3177=for hackers
3178Found in file XSUB.h
3179
e509e693 3180=item XSRETURN_EMPTY
d8c40edc 3181X<XSRETURN_EMPTY>
e509e693
SH
3182
3183Return an empty list from an XSUB immediately.
3184
3185 XSRETURN_EMPTY;
3186
3187=for hackers
3188Found in file XSUB.h
3189
94bdecf9 3190=item XSRETURN_IV
d8c40edc 3191X<XSRETURN_IV>
954c1994 3192
94bdecf9 3193Return an integer from an XSUB immediately. Uses C<XST_mIV>.
954c1994 3194
94bdecf9 3195 void XSRETURN_IV(IV iv)
954c1994 3196
497711e7 3197=for hackers
94bdecf9 3198Found in file XSUB.h
497711e7 3199
94bdecf9 3200=item XSRETURN_NO
d8c40edc 3201X<XSRETURN_NO>
954c1994 3202
94bdecf9 3203Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>.
954c1994 3204
94bdecf9 3205 XSRETURN_NO;
954c1994 3206
497711e7 3207=for hackers
94bdecf9 3208Found in file XSUB.h
497711e7 3209
94bdecf9 3210=item XSRETURN_NV
d8c40edc 3211X<XSRETURN_NV>
954c1994 3212
94bdecf9 3213Return a double from an XSUB immediately. Uses C<XST_mNV>.
954c1994 3214
94bdecf9 3215 void XSRETURN_NV(NV nv)
954c1994 3216
497711e7 3217=for hackers
94bdecf9
JH
3218Found in file XSUB.h
3219
3220=item XSRETURN_PV
d8c40edc 3221X<XSRETURN_PV>
94bdecf9
JH
3222
3223Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>.
3224
3225 void XSRETURN_PV(char* str)
3226
3227=for hackers
3228Found in file XSUB.h
3229
3230=item XSRETURN_UNDEF
d8c40edc 3231X<XSRETURN_UNDEF>
94bdecf9
JH
3232
3233Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>.
3234
3235 XSRETURN_UNDEF;
3236
3237=for hackers
3238Found in file XSUB.h
3239
0ee80f49 3240=item XSRETURN_UV
d8c40edc 3241X<XSRETURN_UV>
0ee80f49
JH
3242
3243Return an integer from an XSUB immediately. Uses C<XST_mUV>.
3244
3245 void XSRETURN_UV(IV uv)
3246
3247=for hackers
3248Found in file XSUB.h
3249
94bdecf9 3250=item XSRETURN_YES
d8c40edc 3251X<XSRETURN_YES>
94bdecf9
JH
3252
3253Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>.
3254
3255 XSRETURN_YES;
3256
3257=for hackers
3258Found in file XSUB.h
3259
3260=item XST_mIV
d8c40edc 3261X<XST_mIV>
94bdecf9
JH
3262
3263Place an integer into the specified position C<pos> on the stack. The
3264value is stored in a new mortal SV.
3265
3266 void XST_mIV(int pos, IV iv)
3267
3268=for hackers
3269Found in file XSUB.h
3270
3271=item XST_mNO
d8c40edc 3272X<XST_mNO>
94bdecf9
JH
3273
3274Place C<&PL_sv_no> into the specified position C<pos> on the
3275stack.
3276
3277 void XST_mNO(int pos)
3278
3279=for hackers
3280Found in file XSUB.h
3281
3282=item XST_mNV
d8c40edc 3283X<XST_mNV>
94bdecf9
JH
3284
3285Place a double into the specified position C<pos> on the stack. The value
3286is stored in a new mortal SV.
3287
3288 void XST_mNV(int pos, NV nv)
3289
3290=for hackers
3291Found in file XSUB.h
3292
3293=item XST_mPV
d8c40edc 3294X<XST_mPV>
94bdecf9
JH
3295
3296Place a copy of a string into the specified position C<pos> on the stack.
3297The value is stored in a new mortal SV.
3298
3299 void XST_mPV(int pos, char* str)
3300
3301=for hackers
3302Found in file XSUB.h
3303
3304=item XST_mUNDEF
d8c40edc 3305X<XST_mUNDEF>
94bdecf9
JH
3306
3307Place C<&PL_sv_undef> into the specified position C<pos> on the
3308stack.
3309
3310 void XST_mUNDEF(int pos)
3311
3312=for hackers
3313Found in file XSUB.h
3314
3315=item XST_mYES
d8c40edc 3316X<XST_mYES>
94bdecf9
JH
3317
3318Place C<&PL_sv_yes> into the specified position C<pos> on the
3319stack.
3320
3321 void XST_mYES(int pos)
3322
3323=for hackers
3324Found in file XSUB.h
3325
3326
3327=back
3328
3329=head1 SV Flags
497711e7 3330
94bdecf9 3331=over 8
954c1994 3332
94bdecf9 3333=item svtype
d8c40edc 3334X<svtype>
954c1994 3335
94bdecf9
JH
3336An enum of flags for Perl types. These are found in the file B<sv.h>
3337in the C<svtype> enum. Test these flags with the C<SvTYPE> macro.
954c1994 3338
497711e7 3339=for hackers
94bdecf9 3340Found in file sv.h
6e9d1081 3341
94bdecf9 3342=item SVt_IV
d8c40edc 3343X<SVt_IV>
6e9d1081 3344
94bdecf9 3345Integer type flag for scalars. See C<svtype>.
6e9d1081
NC
3346
3347=for hackers
94bdecf9 3348Found in file sv.h
6e9d1081 3349
94bdecf9 3350=item SVt_NV
d8c40edc 3351X<SVt_NV>
6e9d1081 3352
94bdecf9 3353Double type flag for scalars. See C<svtype>.
6e9d1081
NC
3354
3355=for hackers
94bdecf9 3356Found in file sv.h
6e9d1081 3357
94bdecf9 3358=item SVt_PV
d8c40edc 3359X<SVt_PV>
6e9d1081 3360
94bdecf9 3361Pointer type flag for scalars. See C<svtype>.
6e9d1081
NC
3362
3363=for hackers
94bdecf9 3364Found in file sv.h
cd1ee231 3365
94bdecf9 3366=item SVt_PVAV
d8c40edc 3367X<SVt_PVAV>
cd1ee231 3368
94bdecf9 3369Type flag for arrays. See C<svtype>.
cd1ee231
JH
3370
3371=for hackers
94bdecf9 3372Found in file sv.h
cd1ee231 3373
94bdecf9 3374=item SVt_PVCV
d8c40edc 3375X<SVt_PVCV>
cd1ee231 3376
94bdecf9 3377Type flag for code refs. See C<svtype>.
cd1ee231
JH
3378
3379=for hackers
94bdecf9 3380Found in file sv.h
cd1ee231 3381
94bdecf9 3382=item SVt_PVHV
d8c40edc 3383X<SVt_PVHV>
cd1ee231 3384
94bdecf9 3385Type flag for hashes. See C<svtype>.
cd1ee231
JH
3386
3387=for hackers
94bdecf9 3388Found in file sv.h
cd1ee231 3389
94bdecf9 3390=item SVt_PVMG
d8c40edc 3391X<SVt_PVMG>
cd1ee231 3392
94bdecf9 3393Type flag for blessed scalars. See C<svtype>.
cd1ee231
JH
3394
3395=for hackers
94bdecf9 3396Found in file sv.h
cd1ee231 3397
cd1ee231 3398
94bdecf9 3399=back
cd1ee231 3400
94bdecf9 3401=head1 SV Manipulation Functions
cd1ee231 3402
94bdecf9 3403=over 8
cd1ee231 3404
94bdecf9 3405=item get_sv
d8c40edc 3406X<get_sv>
cd1ee231 3407
94bdecf9
JH
3408Returns the SV of the specified Perl scalar. If C<create> is set and the
3409Perl variable does not exist then it will be created. If C<create> is not
3410set and the variable does not exist then NULL is returned.
3411
3412NOTE: the perl_ form of this function is deprecated.
3413
3414 SV* get_sv(const char* name, I32 create)
cd1ee231
JH
3415
3416=for hackers
94bdecf9 3417Found in file perl.c
cd1ee231 3418
94bdecf9 3419=item looks_like_number
d8c40edc 3420X<looks_like_number>
cd1ee231 3421
94bdecf9
JH
3422Test if the content of an SV looks like a number (or is a number).
3423C<Inf> and C<Infinity> are treated as numbers (so will not issue a
3424non-numeric warning), even if your atof() doesn't grok them.
cd1ee231 3425
94bdecf9 3426 I32 looks_like_number(SV* sv)
cd1ee231
JH
3427
3428=for hackers
94bdecf9 3429Found in file sv.c
2a5a0c38 3430
94bdecf9 3431=item newRV_inc
d8c40edc 3432X<newRV_inc>
2a5a0c38 3433
94bdecf9
JH
3434Creates an RV wrapper for an SV. The reference count for the original SV is
3435incremented.
2a5a0c38 3436
94bdecf9 3437 SV* newRV_inc(SV* sv)
2a5a0c38
JH
3438
3439=for hackers
94bdecf9 3440Found in file sv.h
2a5a0c38 3441
94bdecf9 3442=item newRV_noinc
d8c40edc 3443X<newRV_noinc>
954c1994 3444
94bdecf9
JH
3445Creates an RV wrapper for an SV. The reference count for the original
3446SV is B<not> incremented.
3447
3448 SV* newRV_noinc(SV *sv)
954c1994 3449
497711e7 3450=for hackers
94bdecf9 3451Found in file sv.c
497711e7 3452
e509e693 3453=item NEWSV
d8c40edc 3454X<NEWSV>
e509e693
SH
3455
3456Creates a new SV. A non-zero C<len> parameter indicates the number of
3457bytes of preallocated string space the SV should have. An extra byte for a
3458tailing NUL is also reserved. (SvPOK is not set for the SV even if string
3459space is allocated.) The reference count for the new SV is set to 1.
3460C<id> is an integer id between 0 and 1299 (used to identify leaks).
3461
3462 SV* NEWSV(int id, STRLEN len)
3463
3464=for hackers
3465Found in file handy.h
3466
94bdecf9 3467=item newSV
d8c40edc 3468X<newSV>
954c1994 3469
94bdecf9
JH
3470Create a new null SV, or if len > 0, create a new empty SVt_PV type SV
3471with an initial PV allocation of len+1. Normally accessed via the C<NEWSV>
3472macro.
954c1994 3473
94bdecf9 3474 SV* newSV(STRLEN len)
954c1994 3475
497711e7 3476=for hackers
94bdecf9 3477Found in file sv.c
497711e7 3478
926f8064 3479=item newSVhek
d8c40edc 3480X<newSVhek>
926f8064
RGS
3481
3482Creates a new SV from the hash key structure. It will generate scalars that
3483point to the shared string table where possible. Returns a new (undefined)
3484SV if the hek is NULL.
3485
3486 SV* newSVhek(const HEK *hek)
3487
3488=for hackers
3489Found in file sv.c
3490
94bdecf9 3491=item newSViv
d8c40edc 3492X<newSViv>
954c1994 3493
94bdecf9
JH
3494Creates a new SV and copies an integer into it. The reference count for the
3495SV is set to 1.
954c1994 3496
94bdecf9 3497 SV* newSViv(IV i)
954c1994 3498
497711e7 3499=for hackers
94bdecf9 3500Found in file sv.c
497711e7 3501
94bdecf9 3502=item newSVnv
d8c40edc 3503X<newSVnv>
954c1994 3504
94bdecf9
JH
3505Creates a new SV and copies a floating point value into it.
3506The reference count for the SV is set to 1.
954c1994 3507
94bdecf9 3508 SV* newSVnv(NV n)
954c1994 3509
497711e7 3510=for hackers
94bdecf9 3511Found in file sv.c
497711e7 3512
94bdecf9 3513=item newSVpv
d8c40edc 3514X<newSVpv>
954c1994 3515
94bdecf9
JH
3516Creates a new SV and copies a string into it. The reference count for the
3517SV is set to 1. If C<len> is zero, Perl will compute the length using
3518strlen(). For efficiency, consider using C<newSVpvn> instead.
954c1994 3519
94bdecf9 3520 SV* newSVpv(const char* s, STRLEN len)
954c1994 3521
497711e7 3522=for hackers
94bdecf9 3523Found in file sv.c
497711e7 3524
94bdecf9 3525=item newSVpvf
d8c40edc 3526X<newSVpvf>
954c1994 3527
94bdecf9
JH
3528Creates a new SV and initializes it with the string formatted like
3529C<sprintf>.
954c1994 3530
94bdecf9 3531 SV* newSVpvf(const char* pat, ...)
954c1994 3532
497711e7 3533=for hackers
94bdecf9 3534Found in file sv.c
497711e7 3535
94bdecf9 3536=item newSVpvn
d8c40edc 3537X<newSVpvn>
954c1994 3538
94bdecf9
JH
3539Creates a new SV and copies a string into it. The reference count for the
3540SV is set to 1. Note that if C<len> is zero, Perl will create a zero length
3541string. You are responsible for ensuring that the source string is at least
9e09f5f2 3542C<len> bytes long. If the C<s> argument is NULL the new SV will be undefined.
954c1994 3543
94bdecf9 3544 SV* newSVpvn(const char* s, STRLEN len)
954c1994 3545
497711e7 3546=for hackers
94bdecf9 3547Found in file sv.c
497711e7 3548
94bdecf9 3549=item newSVpvn_share
d8c40edc 3550X<newSVpvn_share>
954c1994 3551
3f7c398e 3552Creates a new SV with its SvPVX_const pointing to a shared string in the string
94bdecf9
JH
3553table. If the string does not already exist in the table, it is created
3554first. Turns on READONLY and FAKE. The string's hash is stored in the UV
3555slot of the SV; if the C<hash> parameter is non-zero, that value is used;
3556otherwise the hash is computed. The idea here is that as the string table
3f7c398e 3557is used for shared hash keys these strings will have SvPVX_const == HeKEY and
94bdecf9 3558hash lookup will avoid string compare.
954c1994 3559
94bdecf9 3560 SV* newSVpvn_share(const char* s, I32 len, U32 hash)
954c1994 3561
497711e7 3562=for hackers
94bdecf9 3563Found in file sv.c
497711e7 3564
94bdecf9 3565=item newSVrv
d8c40edc 3566X<newSVrv>
954c1994 3567
94bdecf9
JH
3568Creates a new SV for the RV, C<rv>, to point to. If C<rv> is not an RV then
3569it will be upgraded to one. If C<classname> is non-null then the new SV will
3570be blessed in the specified package. The new SV is returned and its
3571reference count is 1.
954c1994 3572
94bdecf9 3573 SV* newSVrv(SV* rv, const char* classname)
954c1994 3574
497711e7 3575=for hackers
94bdecf9 3576Found in file sv.c
497711e7 3577
94bdecf9 3578=item newSVsv
d8c40edc 3579X<newSVsv>
954c1994 3580
94bdecf9
JH
3581Creates a new SV which is an exact duplicate of the original SV.
3582(Uses C<sv_setsv>).
954c1994 3583
94bdecf9 3584 SV* newSVsv(SV* old)
954c1994 3585
497711e7 3586=for hackers
94bdecf9 3587Found in file sv.c
497711e7 3588
94bdecf9 3589=item newSVuv
d8c40edc 3590X<newSVuv>
954c1994 3591
94bdecf9
JH
3592Creates a new SV and copies an unsigned integer into it.
3593The reference count for the SV is set to 1.
954c1994 3594
94bdecf9 3595 SV* newSVuv(UV u)
954c1994 3596
497711e7 3597=for hackers
94bdecf9 3598Found in file sv.c
497711e7 3599
954c1994 3600=item SvCUR
d8c40edc 3601X<SvCUR>
954c1994
GS
3602
3603Returns the length of the string which is in the SV. See C<SvLEN>.
3604
3605 STRLEN SvCUR(SV* sv)
3606
497711e7
GS
3607=for hackers
3608Found in file sv.h
3609
954c1994 3610=item SvCUR_set
d8c40edc 3611X<SvCUR_set>
954c1994 3612
20799e15
SP
3613Set the current length of the string which is in the SV. See C<SvCUR>
3614and C<SvIV_set>.
954c1994
GS
3615
3616 void SvCUR_set(SV* sv, STRLEN len)
3617
497711e7
GS
3618=for hackers
3619Found in file sv.h
3620
94bdecf9 3621=item SvEND
d8c40edc 3622X<SvEND>
954c1994 3623
94bdecf9
JH
3624Returns a pointer to the last character in the string which is in the SV.
3625See C<SvCUR>. Access the character as *(SvEND(sv)).
954c1994 3626
94bdecf9 3627 char* SvEND(SV* sv)
954c1994 3628
497711e7
GS
3629=for hackers
3630Found in file sv.h
3631
954c1994 3632=item SvGROW
d8c40edc 3633X<SvGROW>
954c1994
GS
3634
3635Expands the character buffer in the SV so that it has room for the
3636indicated number of bytes (remember to reserve space for an extra trailing
8cf8f3d1 3637NUL character). Calls C<sv_grow> to perform the expansion if necessary.
954c1994
GS
3638Returns a pointer to the character buffer.
3639
679ac26e 3640 char * SvGROW(SV* sv, STRLEN len)
954c1994 3641
497711e7
GS
3642=for hackers
3643Found in file sv.h
3644
954c1994 3645=item SvIOK
d8c40edc 3646X<SvIOK>
954c1994
GS
3647
3648Returns a boolean indicating whether the SV contains an integer.
3649
3650 bool SvIOK(SV* sv)
3651
497711e7
GS
3652=for hackers
3653Found in file sv.h
3654
954c1994 3655=item SvIOKp
d8c40edc 3656X<SvIOKp>
954c1994
GS
3657
3658Returns a boolean indicating whether the SV contains an integer. Checks
3659the B<private> setting. Use C<SvIOK>.
3660
3661 bool SvIOKp(SV* sv)
3662
497711e7
GS
3663=for hackers
3664Found in file sv.h
3665
e331fc52 3666=item SvIOK_notUV
d8c40edc 3667X<SvIOK_notUV>
e331fc52 3668
f4758303 3669Returns a boolean indicating whether the SV contains a signed integer.
e331fc52 3670
12fa07df 3671 bool SvIOK_notUV(SV* sv)
e331fc52
JH
3672
3673=for hackers
3674Found in file sv.h
3675
954c1994 3676=item SvIOK_off
d8c40edc 3677X<SvIOK_off>
954c1994
GS
3678
3679Unsets the IV status of an SV.
3680
3681 void SvIOK_off(SV* sv)
3682
497711e7
GS
3683=for hackers
3684Found in file sv.h
3685
954c1994 3686=item SvIOK_on
d8c40edc 3687X<SvIOK_on>
954c1994
GS
3688
3689Tells an SV that it is an integer.
3690
3691 void SvIOK_on(SV* sv)
3692
497711e7
GS
3693=for hackers
3694Found in file sv.h
3695
954c1994 3696=item SvIOK_only
d8c40edc 3697X<SvIOK_only>
954c1994
GS
3698
3699Tells an SV that it is an integer and disables all other OK bits.
3700
3701 void SvIOK_only(SV* sv)
3702
497711e7
GS
3703=for hackers
3704Found in file sv.h
3705
e331fc52 3706=item SvIOK_only_UV
d8c40edc 3707X<SvIOK_only_UV>
e331fc52
JH
3708
3709Tells and SV that it is an unsigned integer and disables all other OK bits.
3710
3711 void SvIOK_only_UV(SV* sv)
3712
3713=for hackers
3714Found in file sv.h
3715
3716=item SvIOK_UV
d8c40edc 3717X<SvIOK_UV>
e331fc52
JH
3718
3719Returns a boolean indicating whether the SV contains an unsigned integer.
3720
12fa07df 3721 bool SvIOK_UV(SV* sv)
e331fc52
JH
3722
3723=for hackers
3724Found in file sv.h
3725
19dbb8f1 3726=item SvIsCOW
d8c40edc 3727X<SvIsCOW>
19dbb8f1
NC
3728
3729Returns a boolean indicating whether the SV is Copy-On-Write. (either shared
3730hash key scalars, or full Copy On Write scalars if 5.9.0 is configured for
3731COW)
3732
3733 bool SvIsCOW(SV* sv)
3734
3735=for hackers
3736Found in file sv.h
3737
3738=item SvIsCOW_shared_hash
d8c40edc 3739X<SvIsCOW_shared_hash>
19dbb8f1
NC
3740
3741Returns a boolean indicating whether the SV is Copy-On-Write shared hash key
3742scalar.
3743
3744 bool SvIsCOW_shared_hash(SV* sv)
3745
3746=for hackers
3747Found in file sv.h
3748
954c1994 3749=item SvIV
d8c40edc 3750X<SvIV>
954c1994 3751
645c22ef
DM
3752Coerces the given SV to an integer and returns it. See C<SvIVx> for a
3753version which guarantees to evaluate sv only once.
954c1994
GS
3754
3755 IV SvIV(SV* sv)
3756
497711e7
GS
3757=for hackers
3758Found in file sv.h
3759
df344c0f 3760=item SvIVX
d8c40edc 3761X<SvIVX>
954c1994 3762
df344c0f
NC
3763Returns the raw value in the SV's IV slot, without checks or conversions.
3764Only use when you are sure SvIOK is true. See also C<SvIV()>.
954c1994 3765
df344c0f 3766 IV SvIVX(SV* sv)
954c1994 3767
497711e7
GS
3768=for hackers
3769Found in file sv.h
3770
df344c0f 3771=item SvIVx
d8c40edc 3772X<SvIVx>
645c22ef 3773
df344c0f
NC
3774Coerces the given SV to an integer and returns it. Guarantees to evaluate
3775sv only once. Use the more efficient C<SvIV> otherwise.
645c22ef 3776
df344c0f 3777 IV SvIVx(SV* sv)
645c22ef
DM
3778
3779=for hackers
3780Found in file sv.h
3781
891f9566 3782=item SvIV_nomg
d8c40edc 3783X<SvIV_nomg>
891f9566
YST
3784
3785Like C<SvIV> but doesn't process magic.
3786
3787 IV SvIV_nomg(SV* sv)
3788
3789=for hackers
3790Found in file sv.h
3791
672994ce 3792=item SvIV_set
d8c40edc 3793X<SvIV_set>
672994ce 3794
20799e15
SP
3795Set the value of the IV pointer in sv to val. It is possible to perform
3796the same function of this macro with an lvalue assignment to C<SvIVX>.
3797With future Perls, however, it will be more efficient to use
3798C<SvIV_set> instead of the lvalue assignment to C<SvIVX>.
672994ce
SP
3799
3800 void SvIV_set(SV* sv, IV val)
3801
3802=for hackers
3803Found in file sv.h
3804
954c1994 3805=item SvLEN
d8c40edc 3806X<SvLEN>
954c1994 3807
91e74348
JH
3808Returns the size of the string buffer in the SV, not including any part
3809attributable to C<SvOOK>. See C<SvCUR>.
954c1994
GS
3810
3811 STRLEN SvLEN(SV* sv)
3812
497711e7
GS
3813=for hackers
3814Found in file sv.h
3815
672994ce 3816=item SvLEN_set
d8c40edc 3817X<SvLEN_set>
672994ce 3818
20799e15 3819Set the actual length of the string which is in the SV. See C<SvIV_set>.
672994ce
SP
3820
3821 void SvLEN_set(SV* sv, STRLEN len)
3822
3823=for hackers
3824Found in file sv.h
3825
3826=item SvMAGIC_set
d8c40edc 3827X<SvMAGIC_set>
672994ce 3828
20799e15 3829Set the value of the MAGIC pointer in sv to val. See C<SvIV_set>.
672994ce
SP
3830
3831 void SvMAGIC_set(SV* sv, MAGIC* val)
3832
3833=for hackers
3834Found in file sv.h
3835
954c1994 3836=item SvNIOK
d8c40edc 3837X<SvNIOK>
954c1994
GS
3838
3839Returns a boolean indicating whether the SV contains a number, integer or
3840double.
3841
3842 bool SvNIOK(SV* sv)
3843
497711e7
GS
3844=for hackers
3845Found in file sv.h
3846
954c1994 3847=item SvNIOKp
d8c40edc 3848X<SvNIOKp>
954c1994
GS
3849
3850Returns a boolean indicating whether the SV contains a number, integer or
3851double. Checks the B<private> setting. Use C<SvNIOK>.
3852
3853 bool SvNIOKp(SV* sv)
3854
497711e7
GS
3855=for hackers
3856Found in file sv.h
3857
954c1994 3858=item SvNIOK_off
d8c40edc 3859X<SvNIOK_off>
954c1994
GS
3860
3861Unsets the NV/IV status of an SV.
3862
3863 void SvNIOK_off(SV* sv)
3864
497711e7
GS
3865=for hackers
3866Found in file sv.h
3867
954c1994 3868=item SvNOK
d8c40edc 3869X<SvNOK>
954c1994
GS
3870
3871Returns a boolean indicating whether the SV contains a double.
3872
3873 bool SvNOK(SV* sv)
3874
497711e7
GS
3875=for hackers
3876Found in file sv.h
3877
954c1994 3878=item SvNOKp
d8c40edc 3879X<SvNOKp>
954c1994
GS
3880
3881Returns a boolean indicating whether the SV contains a double. Checks the
3882B<private> setting. Use C<SvNOK>.
3883
3884 bool SvNOKp(SV* sv)
3885
497711e7
GS
3886=for hackers
3887Found in file sv.h
3888
954c1994 3889=item SvNOK_off
d8c40edc 3890X<SvNOK_off>
954c1994
GS
3891
3892Unsets the NV status of an SV.
3893
3894 void SvNOK_off(SV* sv)
3895
497711e7
GS
3896=for hackers
3897Found in file sv.h
3898
954c1994 3899=item SvNOK_on
d8c40edc 3900X<SvNOK_on>
954c1994
GS
3901
3902Tells an SV that it is a double.
3903
3904 void SvNOK_on(SV* sv)
3905
497711e7
GS
3906=for hackers
3907Found in file sv.h
3908
954c1994 3909=item SvNOK_only
d8c40edc 3910X<SvNOK_only>
954c1994
GS
3911
3912Tells an SV that it is a double and disables all other OK bits.
3913
3914 void SvNOK_only(SV* sv)
3915
497711e7
GS
3916=for hackers
3917Found in file sv.h
3918
954c1994 3919=item SvNV
d8c40edc 3920X<SvNV>
954c1994 3921
645c22ef
DM
3922Coerce the given SV to a double and return it. See C<SvNVx> for a version
3923which guarantees to evaluate sv only once.
954c1994
GS
3924
3925 NV SvNV(SV* sv)
3926
497711e7
GS
3927=for hackers
3928Found in file sv.h
3929
b9381830 3930=item SvNVX
d8c40edc 3931X<SvNVX>
645c22ef 3932
b9381830
JP
3933Returns the raw value in the SV's NV slot, without checks or conversions.
3934Only use when you are sure SvNOK is true. See also C<SvNV()>.
645c22ef 3935
b9381830 3936 NV SvNVX(SV* sv)
645c22ef
DM
3937
3938=for hackers
3939Found in file sv.h
3940
b9381830 3941=item SvNVx
d8c40edc 3942X<SvNVx>
954c1994 3943
b9381830
JP
3944Coerces the given SV to a double and returns it. Guarantees to evaluate
3945sv only once. Use the more efficient C<SvNV> otherwise.
954c1994 3946
b9381830 3947 NV SvNVx(SV* sv)
954c1994 3948
497711e7
GS
3949=for hackers
3950Found in file sv.h
3951
672994ce 3952=item SvNV_set
d8c40edc 3953X<SvNV_set>
672994ce 3954
20799e15 3955Set the value of the NV pointer in sv to val. See C<SvIV_set>.
672994ce
SP
3956
3957 void SvNV_set(SV* sv, NV val)
3958
3959=for hackers
3960Found in file sv.h
3961
954c1994 3962=item SvOK
d8c40edc 3963X<SvOK>
954c1994 3964
9adebda4
SB
3965Returns a boolean indicating whether the value is an SV. It also tells
3966whether the value is defined or not.
954c1994
GS
3967
3968 bool SvOK(SV* sv)
3969
497711e7
GS
3970=for hackers
3971Found in file sv.h
3972
954c1994 3973=item SvOOK
d8c40edc 3974X<SvOOK>
954c1994
GS
3975
3976Returns a boolean indicating whether the SvIVX is a valid offset value for
3977the SvPVX. This hack is used internally to speed up removal of characters
3978from the beginning of a SvPV. When SvOOK is true, then the start of the
3979allocated string buffer is really (SvPVX - SvIVX).
3980
3981 bool SvOOK(SV* sv)
3982
497711e7
GS
3983=for hackers
3984Found in file sv.h
3985
954c1994 3986=item SvPOK
d8c40edc 3987X<SvPOK>
954c1994
GS
3988
3989Returns a boolean indicating whether the SV contains a character
3990string.
3991
3992 bool SvPOK(SV* sv)
3993
497711e7
GS
3994=for hackers
3995Found in file sv.h
3996
954c1994 3997=item SvPOKp
d8c40edc 3998X<SvPOKp>
954c1994
GS
3999
4000Returns a boolean indicating whether the SV contains a character string.
4001Checks the B<private> setting. Use C<SvPOK>.
4002
4003 bool SvPOKp(SV* sv)
4004
497711e7
GS
4005=for hackers
4006Found in file sv.h
4007
954c1994 4008=item SvPOK_off
d8c40edc 4009X<SvPOK_off>
954c1994
GS
4010
4011Unsets the PV status of an SV.
4012
4013 void SvPOK_off(SV* sv)
4014
497711e7
GS
4015=for hackers
4016Found in file sv.h
4017
954c1994 4018=item SvPOK_on
d8c40edc 4019X<SvPOK_on>
954c1994
GS
4020
4021Tells an SV that it is a string.
4022
4023 void SvPOK_on(SV* sv)
4024
497711e7
GS
4025=for hackers
4026Found in file sv.h
4027
954c1994 4028=item SvPOK_only
d8c40edc 4029X<SvPOK_only>
954c1994
GS
4030
4031Tells an SV that it is a string and disables all other OK bits.
1e54db1a 4032Will also turn off the UTF-8 status.
954c1994
GS
4033
4034 void SvPOK_only(SV* sv)
4035
497711e7
GS
4036=for hackers
4037Found in file sv.h
4038
914184e1 4039=item SvPOK_only_UTF8
d8c40edc 4040X<SvPOK_only_UTF8>
914184e1 4041
d5ce4a7c 4042Tells an SV that it is a string and disables all other OK bits,
1e54db1a 4043and leaves the UTF-8 status as it was.
f1a1024e 4044
914184e1
JH
4045 void SvPOK_only_UTF8(SV* sv)
4046
4047=for hackers
4048Found in file sv.h
4049
954c1994 4050=item SvPV
d8c40edc 4051X<SvPV>
954c1994 4052
12b7c5c7
JH
4053Returns a pointer to the string in the SV, or a stringified form of
4054the SV if the SV does not contain a string. The SV may cache the
4055stringified version becoming C<SvPOK>. Handles 'get' magic. See also
645c22ef 4056C<SvPVx> for a version which guarantees to evaluate sv only once.
954c1994
GS
4057
4058 char* SvPV(SV* sv, STRLEN len)
4059
497711e7
GS
4060=for hackers
4061Found in file sv.h
4062
645c22ef 4063=item SvPVbyte
d8c40edc 4064X<SvPVbyte>
645c22ef
DM
4065
4066Like C<SvPV>, but converts sv to byte representation first if necessary.
4067
4068 char* SvPVbyte(SV* sv, STRLEN len)
4069
4070=for hackers
4071Found in file sv.h
4072
4073=item SvPVbytex
d8c40edc 4074X<SvPVbytex>
645c22ef
DM
4075
4076Like C<SvPV>, but converts sv to byte representation first if necessary.
d1be9408 4077Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte>
645c22ef
DM
4078otherwise.
4079
645c22ef
DM
4080 char* SvPVbytex(SV* sv, STRLEN len)
4081
4082=for hackers
4083Found in file sv.h
4084
4085=item SvPVbytex_force
d8c40edc 4086X<SvPVbytex_force>
645c22ef
DM
4087
4088Like C<SvPV_force>, but converts sv to byte representation first if necessary.
d1be9408 4089Guarantees to evaluate sv only once; use the more efficient C<SvPVbyte_force>
645c22ef
DM
4090otherwise.
4091
4092 char* SvPVbytex_force(SV* sv, STRLEN len)
4093
4094=for hackers
4095Found in file sv.h
4096
4097=item SvPVbyte_force
d8c40edc 4098X<SvPVbyte_force>
645c22ef
DM
4099
4100Like C<SvPV_force>, but converts sv to byte representation first if necessary.
4101
4102 char* SvPVbyte_force(SV* sv, STRLEN len)
4103
4104=for hackers
4105Found in file sv.h
4106
4107=item SvPVbyte_nolen
d8c40edc 4108X<SvPVbyte_nolen>
645c22ef
DM
4109
4110Like C<SvPV_nolen>, but converts sv to byte representation first if necessary.
4111
1fdc5aa6 4112 char* SvPVbyte_nolen(SV* sv)
645c22ef
DM
4113
4114=for hackers
4115Found in file sv.h
4116
4117=item SvPVutf8
d8c40edc 4118X<SvPVutf8>
645c22ef 4119
1fdc5aa6 4120Like C<SvPV>, but converts sv to utf8 first if necessary.
645c22ef
DM
4121
4122 char* SvPVutf8(SV* sv, STRLEN len)
4123
4124=for hackers
4125Found in file sv.h
4126
4127=item SvPVutf8x
d8c40edc 4128X<SvPVutf8x>
645c22ef 4129
1fdc5aa6 4130Like C<SvPV>, but converts sv to utf8 first if necessary.
d1be9408 4131Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8>
645c22ef
DM
4132otherwise.
4133
4134 char* SvPVutf8x(SV* sv, STRLEN len)
4135
4136=for hackers
4137Found in file sv.h
4138
4139=item SvPVutf8x_force
d8c40edc 4140X<SvPVutf8x_force>
645c22ef 4141
1fdc5aa6 4142Like C<SvPV_force>, but converts sv to utf8 first if necessary.
d1be9408 4143Guarantees to evaluate sv only once; use the more efficient C<SvPVutf8_force>
645c22ef
DM
4144otherwise.
4145
4146 char* SvPVutf8x_force(SV* sv, STRLEN len)
4147
4148=for hackers
4149Found in file sv.h
4150
4151=item SvPVutf8_force
d8c40edc 4152X<SvPVutf8_force>
645c22ef 4153
1fdc5aa6 4154Like C<SvPV_force>, but converts sv to utf8 first if necessary.
645c22ef
DM
4155
4156 char* SvPVutf8_force(SV* sv, STRLEN len)
4157
4158=for hackers
4159Found in file sv.h
4160
4161=item SvPVutf8_nolen
d8c40edc 4162X<SvPVutf8_nolen>
645c22ef 4163
1fdc5aa6 4164Like C<SvPV_nolen>, but converts sv to utf8 first if necessary.
645c22ef 4165
1fdc5aa6 4166 char* SvPVutf8_nolen(SV* sv)
645c22ef
DM
4167
4168=for hackers
4169Found in file sv.h
4170
df344c0f 4171=item SvPVX
d8c40edc 4172X<SvPVX>
645c22ef 4173
df344c0f
NC
4174Returns a pointer to the physical string in the SV. The SV must contain a
4175string.
645c22ef 4176
df344c0f 4177 char* SvPVX(SV* sv)
645c22ef
DM
4178
4179=for hackers
4180Found in file sv.h
4181
df344c0f 4182=item SvPVx
d8c40edc 4183X<SvPVx>
954c1994 4184
df344c0f 4185A version of C<SvPV> which guarantees to evaluate sv only once.
954c1994 4186
df344c0f 4187 char* SvPVx(SV* sv, STRLEN len)
954c1994 4188
497711e7
GS
4189=for hackers
4190Found in file sv.h
4191
954c1994 4192=item SvPV_force
d8c40edc 4193X<SvPV_force>
954c1994 4194
12b7c5c7
JH
4195Like C<SvPV> but will force the SV into containing just a string
4196(C<SvPOK_only>). You want force if you are going to update the C<SvPVX>
4197directly.
954c1994
GS
4198
4199 char* SvPV_force(SV* sv, STRLEN len)
4200
497711e7
GS
4201=for hackers
4202Found in file sv.h
4203
645c22ef 4204=item SvPV_force_nomg
d8c40edc 4205X<SvPV_force_nomg>
645c22ef 4206
12b7c5c7
JH
4207Like C<SvPV> but will force the SV into containing just a string
4208(C<SvPOK_only>). You want force if you are going to update the C<SvPVX>
4209directly. Doesn't process magic.
645c22ef
DM
4210
4211 char* SvPV_force_nomg(SV* sv, STRLEN len)
4212
4213=for hackers
4214Found in file sv.h
4215
954c1994 4216=item SvPV_nolen
d8c40edc 4217X<SvPV_nolen>
954c1994 4218
12b7c5c7
JH
4219Returns a pointer to the string in the SV, or a stringified form of
4220the SV if the SV does not contain a string. The SV may cache the
4221stringified form becoming C<SvPOK>. Handles 'get' magic.
954c1994
GS
4222
4223 char* SvPV_nolen(SV* sv)
4224
497711e7
GS
4225=for hackers
4226Found in file sv.h
4227
891f9566 4228=item SvPV_nomg
d8c40edc 4229X<SvPV_nomg>
891f9566
YST
4230
4231Like C<SvPV> but doesn't process magic.
4232
4233 char* SvPV_nomg(SV* sv, STRLEN len)
4234
4235=for hackers
4236Found in file sv.h
4237
672994ce 4238=item SvPV_set
d8c40edc 4239X<SvPV_set>
672994ce 4240
20799e15 4241Set the value of the PV pointer in sv to val. See C<SvIV_set>.
672994ce
SP
4242
4243 void SvPV_set(SV* sv, char* val)
4244
4245=for hackers
4246Found in file sv.h
4247
954c1994 4248=item SvREFCNT
d8c40edc 4249X<SvREFCNT>
954c1994
GS
4250
4251Returns the value of the object's reference count.
4252
4253 U32 SvREFCNT(SV* sv)
4254
497711e7
GS
4255=for hackers
4256Found in file sv.h
4257
954c1994 4258=item SvREFCNT_dec
d8c40edc 4259X<SvREFCNT_dec>
954c1994
GS
4260
4261Decrements the reference count of the given SV.
4262
4263 void SvREFCNT_dec(SV* sv)
4264
497711e7
GS
4265=for hackers
4266Found in file sv.h
4267
954c1994 4268=item SvREFCNT_inc
d8c40edc 4269X<SvREFCNT_inc>
954c1994
GS
4270
4271Increments the reference count of the given SV.
4272
4273 SV* SvREFCNT_inc(SV* sv)
4274
497711e7
GS
4275=for hackers
4276Found in file sv.h
4277
954c1994 4278=item SvROK
d8c40edc 4279X<SvROK>
954c1994
GS
4280
4281Tests if the SV is an RV.
4282
4283 bool SvROK(SV* sv)
4284
497711e7
GS
4285=for hackers
4286Found in file sv.h
4287
954c1994 4288=item SvROK_off
d8c40edc 4289X<SvROK_off>
954c1994
GS
4290
4291Unsets the RV status of an SV.
4292
4293 void SvROK_off(SV* sv)
4294
497711e7
GS
4295=for hackers
4296Found in file sv.h
4297
954c1994 4298=item SvROK_on
d8c40edc 4299X<SvROK_on>
954c1994
GS
4300
4301Tells an SV that it is an RV.
4302
4303 void SvROK_on(SV* sv)
4304
497711e7
GS
4305=for hackers
4306Found in file sv.h
4307
954c1994 4308=item SvRV
d8c40edc 4309X<SvRV>
954c1994
GS
4310
4311Dereferences an RV to return the SV.
4312
4313 SV* SvRV(SV* sv)
4314
497711e7
GS
4315=for hackers
4316Found in file sv.h
4317
672994ce 4318=item SvRV_set
d8c40edc 4319X<SvRV_set>
672994ce 4320
20799e15 4321Set the value of the RV pointer in sv to val. See C<SvIV_set>.
672994ce
SP
4322
4323 void SvRV_set(SV* sv, SV* val)
4324
4325=for hackers
4326Found in file sv.h
4327
954c1994 4328=item SvSTASH
d8c40edc 4329X<SvSTASH>
954c1994
GS
4330
4331Returns the stash of the SV.
4332
4333 HV* SvSTASH(SV* sv)
4334
497711e7
GS
4335=for hackers
4336Found in file sv.h
4337
672994ce 4338=item SvSTASH_set
d8c40edc 4339X<SvSTASH_set>
672994ce 4340
20799e15 4341Set the value of the STASH pointer in sv to val. See C<SvIV_set>.
672994ce
SP
4342
4343 void SvSTASH_set(SV* sv, STASH* val)
4344
4345=for hackers
4346Found in file sv.h
4347
954c1994 4348=item SvTAINT
d8c40edc 4349X<SvTAINT>
954c1994 4350
c55831ac 4351Taints an SV if tainting is enabled.
954c1994
GS
4352
4353 void SvTAINT(SV* sv)
4354
497711e7
GS
4355=for hackers
4356Found in file sv.h
4357
954c1994 4358=item SvTAINTED
d8c40edc 4359X<SvTAINTED>
954c1994
GS
4360
4361Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if
4362not.
4363
4364 bool SvTAINTED(SV* sv)
4365
497711e7
GS
4366=for hackers
4367Found in file sv.h
4368
954c1994 4369=item SvTAINTED_off
d8c40edc 4370X<SvTAINTED_off>
954c1994
GS
4371
4372Untaints an SV. Be I<very> careful with this routine, as it short-circuits
4373some of Perl's fundamental security features. XS module authors should not
4374use this function unless they fully understand all the implications of
4375unconditionally untainting the value. Untainting should be done in the
4376standard perl fashion, via a carefully crafted regexp, rather than directly
4377untainting variables.
4378
4379 void SvTAINTED_off(SV* sv)
4380
497711e7
GS
4381=for hackers
4382Found in file sv.h
4383
954c1994 4384=item SvTAINTED_on
d8c40edc 4385X<SvTAINTED_on>
954c1994 4386
c55831ac 4387Marks an SV as tainted if tainting is enabled.
954c1994
GS
4388
4389 void SvTAINTED_on(SV* sv)
4390
497711e7
GS
4391=for hackers
4392Found in file sv.h
4393
954c1994 4394=item SvTRUE
d8c40edc 4395X<SvTRUE>
954c1994
GS
4396
4397Returns a boolean indicating whether Perl would evaluate the SV as true or
4398false, defined or undefined. Does not handle 'get' magic.
4399
4400 bool SvTRUE(SV* sv)
4401
497711e7
GS
4402=for hackers
4403Found in file sv.h
4404
9f4817db 4405=item SvTYPE
d8c40edc 4406X<SvTYPE>
af3c7592 4407
9f4817db
JH
4408Returns the type of the SV. See C<svtype>.
4409
4410 svtype SvTYPE(SV* sv)
954c1994 4411
497711e7
GS
4412=for hackers
4413Found in file sv.h
4414
a8586c98 4415=item SvUOK
d8c40edc 4416X<SvUOK>
a8586c98
JH
4417
4418Returns a boolean indicating whether the SV contains an unsigned integer.
4419
4420 void SvUOK(SV* sv)
4421
4422=for hackers
4423Found in file sv.h
4424
954c1994 4425=item SvUPGRADE
d8c40edc 4426X<SvUPGRADE>
954c1994
GS
4427
4428Used to upgrade an SV to a more complex form. Uses C<sv_upgrade> to
4429perform the upgrade if necessary. See C<svtype>.
4430
4431 void SvUPGRADE(SV* sv, svtype type)
4432
497711e7
GS
4433=for hackers
4434Found in file sv.h
4435
914184e1 4436=item SvUTF8
d8c40edc 4437X<SvUTF8>
914184e1
JH
4438
4439Returns a boolean indicating whether the SV contains UTF-8 encoded data.
4440
12fa07df 4441 bool SvUTF8(SV* sv)
914184e1
JH
4442
4443=for hackers
4444Found in file sv.h
4445
4446=item SvUTF8_off
d8c40edc 4447X<SvUTF8_off>
914184e1 4448
1e54db1a 4449Unsets the UTF-8 status of an SV.
914184e1
JH
4450
4451 void SvUTF8_off(SV *sv)
4452
4453=for hackers
4454Found in file sv.h
4455
4456=item SvUTF8_on
d8c40edc 4457X<SvUTF8_on>
914184e1 4458
1e54db1a 4459Turn on the UTF-8 status of an SV (the data is not changed, just the flag).
d5ce4a7c 4460Do not use frivolously.
914184e1
JH
4461
4462 void SvUTF8_on(SV *sv)
4463
4464=for hackers
4465Found in file sv.h
4466
954c1994 4467=item SvUV
d8c40edc 4468X<SvUV>
954c1994 4469
645c22ef
DM
4470Coerces the given SV to an unsigned integer and returns it. See C<SvUVx>
4471for a version which guarantees to evaluate sv only once.
954c1994
GS
4472
4473 UV SvUV(SV* sv)
4474
497711e7
GS
4475=for hackers
4476Found in file sv.h
4477
b9381830 4478=item SvUVX
d8c40edc 4479X<SvUVX>
891f9566 4480
b9381830
JP
4481Returns the raw value in the SV's UV slot, without checks or conversions.
4482Only use when you are sure SvIOK is true. See also C<SvUV()>.
891f9566 4483
b9381830 4484 UV SvUVX(SV* sv)
891f9566
YST
4485
4486=for hackers
4487Found in file sv.h
4488
b9381830 4489=item SvUVx
d8c40edc 4490X<SvUVx>
b0f01acb 4491
b9381830
JP
4492Coerces the given SV to an unsigned integer and returns it. Guarantees to
4493evaluate sv only once. Use the more efficient C<SvUV> otherwise.
b0f01acb 4494
b9381830 4495 UV SvUVx(SV* sv)
b0f01acb
JP
4496
4497=for hackers
4498Found in file sv.h
4499
891f9566 4500=item SvUV_nomg
d8c40edc 4501X<SvUV_nomg>
954c1994 4502
891f9566 4503Like C<SvUV> but doesn't process magic.
954c1994 4504
891f9566 4505 UV SvUV_nomg(SV* sv)
954c1994 4506
497711e7
GS
4507=for hackers
4508Found in file sv.h
4509
672994ce 4510=item SvUV_set
d8c40edc 4511X<SvUV_set>
672994ce 4512
20799e15 4513Set the value of the UV pointer in sv to val. See C<SvIV_set>.
672994ce
SP
4514
4515 void SvUV_set(SV* sv, UV val)
4516
4517=for hackers
4518Found in file sv.h
4519
b0f01acb 4520=item SvVOK
d8c40edc 4521X<SvVOK>
645c22ef 4522
b0f01acb 4523Returns a boolean indicating whether the SV contains a v-string.
645c22ef 4524
b0f01acb 4525 bool SvVOK(SV* sv)
645c22ef
DM
4526
4527=for hackers
4528Found in file sv.h
4529
4530=item sv_2bool
d8c40edc 4531X<sv_2bool>
645c22ef
DM
4532
4533This function is only called on magical items, and is only used by
8cf8f3d1 4534sv_true() or its macro equivalent.
645c22ef
DM
4535
4536 bool sv_2bool(SV* sv)
4537
4538=for hackers
4539Found in file sv.c
4540
4541=item sv_2cv
d8c40edc 4542X<sv_2cv>
645c22ef
DM
4543
4544Using various gambits, try to get a CV from an SV; in addition, try if
4545possible to set C<*st> and C<*gvp> to the stash and GV associated with it.
4546
4547 CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref)
4548
4549=for hackers
4550Found in file sv.c
4551
4552=item sv_2io
d8c40edc 4553X<sv_2io>
645c22ef
DM
4554
4555Using various gambits, try to get an IO from an SV: the IO slot if its a
4556GV; or the recursive result if we're an RV; or the IO slot of the symbol
4557named after the PV if we're a string.
4558
4559 IO* sv_2io(SV* sv)
4560
4561=for hackers
4562Found in file sv.c
4563
891f9566 4564=item sv_2iv_flags
d8c40edc 4565X<sv_2iv_flags>
645c22ef 4566
891f9566
YST
4567Return the integer value of an SV, doing any necessary string
4568conversion. If flags includes SV_GMAGIC, does an mg_get() first.
4569Normally used via the C<SvIV(sv)> and C<SvIVx(sv)> macros.
645c22ef 4570
891f9566 4571 IV sv_2iv_flags(SV* sv, I32 flags)
645c22ef
DM
4572
4573=for hackers
4574Found in file sv.c
4575
954c1994 4576=item sv_2mortal
d8c40edc 4577X<sv_2mortal>
954c1994 4578
793edb8a
JH
4579Marks an existing SV as mortal. The SV will be destroyed "soon", either
4580by an explicit call to FREETMPS, or by an implicit call at places such as
b0bc38e6
NC
4581statement boundaries. SvTEMP() is turned on which means that the SV's
4582string buffer can be "stolen" if this SV is copied. See also C<sv_newmortal>
4583and C<sv_mortalcopy>.
954c1994
GS
4584
4585 SV* sv_2mortal(SV* sv)
4586
497711e7
GS
4587=for hackers
4588Found in file sv.c
4589
645c22ef 4590=item sv_2nv
d8c40edc 4591X<sv_2nv>
645c22ef
DM
4592
4593Return the num value of an SV, doing any necessary string or integer
4594conversion, magic etc. Normally used via the C<SvNV(sv)> and C<SvNVx(sv)>
4595macros.
4596
4597 NV sv_2nv(SV* sv)
4598
4599=for hackers
4600Found in file sv.c
4601
451be7b1 4602=item sv_2pvbyte
d8c40edc 4603X<sv_2pvbyte>
451be7b1
DM
4604
4605Return a pointer to the byte-encoded representation of the SV, and set *lp
1e54db1a 4606to its length. May cause the SV to be downgraded from UTF-8 as a
451be7b1
DM
4607side-effect.
4608
4609Usually accessed via the C<SvPVbyte> macro.
4610
4611 char* sv_2pvbyte(SV* sv, STRLEN* lp)
4612
4613=for hackers
4614Found in file sv.c
4615
035cbb0e
RGS
4616=item sv_2pvutf8
4617X<sv_2pvutf8>
4618
4619Return a pointer to the UTF-8-encoded representation of the SV, and set *lp
4620to its length. May cause the SV to be upgraded to UTF-8 as a side-effect.
4621
4622Usually accessed via the C<SvPVutf8> macro.
4623
4624 char* sv_2pvutf8(SV* sv, STRLEN* lp)
4625
4626=for hackers
4627Found in file sv.c
4628
645c22ef 4629=item sv_2pv_flags
d8c40edc 4630X<sv_2pv_flags>
645c22ef 4631
ff276b08 4632Returns a pointer to the string value of an SV, and sets *lp to its length.
645c22ef
DM
4633If flags includes SV_GMAGIC, does an mg_get() first. Coerces sv to a string
4634if necessary.
4635Normally invoked via the C<SvPV_flags> macro. C<sv_2pv()> and C<sv_2pv_nomg>
4636usually end up here too.
4637
4638 char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags)
4639
4640=for hackers
4641Found in file sv.c
4642
891f9566 4643=item sv_2uv_flags
d8c40edc 4644X<sv_2uv_flags>
645c22ef
DM
4645
4646Return the unsigned integer value of an SV, doing any necessary string
891f9566
YST
4647conversion. If flags includes SV_GMAGIC, does an mg_get() first.
4648Normally used via the C<SvUV(sv)> and C<SvUVx(sv)> macros.
645c22ef 4649
891f9566 4650 UV sv_2uv_flags(SV* sv, I32 flags)
645c22ef
DM
4651
4652=for hackers
4653Found in file sv.c
4654
4655=item sv_backoff
d8c40edc 4656X<sv_backoff>
645c22ef
DM
4657
4658Remove any string offset. You should normally use the C<SvOOK_off> macro
4659wrapper instead.
4660
4661 int sv_backoff(SV* sv)
4662
4663=for hackers
4664Found in file sv.c
4665
954c1994 4666=item sv_bless
d8c40edc 4667X<sv_bless>
954c1994
GS
4668
4669Blesses an SV into a specified package. The SV must be an RV. The package
4670must be designated by its stash (see C<gv_stashpv()>). The reference count
4671of the SV is unaffected.
4672
4673 SV* sv_bless(SV* sv, HV* stash)
4674
497711e7
GS
4675=for hackers
4676Found in file sv.c
4677
954c1994 4678=item sv_catpv
d8c40edc 4679X<sv_catpv>
954c1994
GS
4680
4681Concatenates the string onto the end of the string which is in the SV.
1e54db1a
JH
4682If the SV has the UTF-8 status set, then the bytes appended should be
4683valid UTF-8. Handles 'get' magic, but not 'set' magic. See C<sv_catpv_mg>.
954c1994
GS
4684
4685 void sv_catpv(SV* sv, const char* ptr)
4686
497711e7
GS
4687=for hackers
4688Found in file sv.c
4689
954c1994 4690=item sv_catpvf
d8c40edc 4691X<sv_catpvf>
954c1994 4692
d5ce4a7c
GA
4693Processes its arguments like C<sprintf> and appends the formatted
4694output to an SV. If the appended data contains "wide" characters
4695(including, but not limited to, SVs with a UTF-8 PV formatted with %s,
4696and characters >255 formatted with %c), the original SV might get
bffc3d17 4697upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. See
cdd94ca7
NC
4698C<sv_catpvf_mg>. If the original SV was UTF-8, the pattern should be
4699valid UTF-8; if the original SV was bytes, the pattern should be too.
954c1994
GS
4700
4701 void sv_catpvf(SV* sv, const char* pat, ...)
4702
497711e7
GS
4703=for hackers
4704Found in file sv.c
4705
954c1994 4706=item sv_catpvf_mg
d8c40edc 4707X<sv_catpvf_mg>
954c1994
GS
4708
4709Like C<sv_catpvf>, but also handles 'set' magic.
4710
4711 void sv_catpvf_mg(SV *sv, const char* pat, ...)
4712
497711e7
GS
4713=for hackers
4714Found in file sv.c
4715
954c1994 4716=item sv_catpvn
d8c40edc 4717X<sv_catpvn>
954c1994
GS
4718
4719Concatenates the string onto the end of the string which is in the SV. The
1e54db1a
JH
4720C<len> indicates number of bytes to copy. If the SV has the UTF-8
4721status set, then the bytes appended should be valid UTF-8.
d5ce4a7c 4722Handles 'get' magic, but not 'set' magic. See C<sv_catpvn_mg>.
954c1994
GS
4723
4724 void sv_catpvn(SV* sv, const char* ptr, STRLEN len)
4725
497711e7
GS
4726=for hackers
4727Found in file sv.c
4728
8d6d96c1 4729=item sv_catpvn_flags
d8c40edc 4730X<sv_catpvn_flags>
8d6d96c1
HS
4731
4732Concatenates the string onto the end of the string which is in the SV. The
1e54db1a
JH
4733C<len> indicates number of bytes to copy. If the SV has the UTF-8
4734status set, then the bytes appended should be valid UTF-8.
8d6d96c1
HS
4735If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<dsv> if
4736appropriate, else not. C<sv_catpvn> and C<sv_catpvn_nomg> are implemented
4737in terms of this function.
4738
4739 void sv_catpvn_flags(SV* sv, const char* ptr, STRLEN len, I32 flags)
4740
4741=for hackers
4742Found in file sv.c
4743
0f76ff59 4744=item sv_catpvn_nomg
d8c40edc 4745X<sv_catpvn_nomg>
0f76ff59
MHM
4746
4747Like C<sv_catpvn> but doesn't process magic.
4748
4749 void sv_catpvn_nomg(SV* sv, const char* ptr, STRLEN len)
4750
4751=for hackers
4752Found in file sv.h
4753
954c1994 4754=item sv_catpv_mg
d8c40edc 4755X<sv_catpv_mg>
954c1994
GS
4756
4757Like C<sv_catpv>, but also handles 'set' magic.
4758
4759 void sv_catpv_mg(SV *sv, const char *ptr)
4760
497711e7
GS
4761=for hackers
4762Found in file sv.c
4763
954c1994 4764=item sv_catsv
d8c40edc 4765X<sv_catsv>
954c1994 4766
1aa99e6b
IH
4767Concatenates the string from SV C<ssv> onto the end of the string in
4768SV C<dsv>. Modifies C<dsv> but not C<ssv>. Handles 'get' magic, but
4769not 'set' magic. See C<sv_catsv_mg>.
954c1994
GS
4770
4771 void sv_catsv(SV* dsv, SV* ssv)
4772
497711e7
GS
4773=for hackers
4774Found in file sv.c
4775
8d6d96c1 4776=item sv_catsv_flags
d8c40edc 4777X<sv_catsv_flags>
8d6d96c1
HS
4778
4779Concatenates the string from SV C<ssv> onto the end of the string in
4780SV C<dsv>. Modifies C<dsv> but not C<ssv>. If C<flags> has C<SV_GMAGIC>
4781bit set, will C<mg_get> on the SVs if appropriate, else not. C<sv_catsv>
4782and C<sv_catsv_nomg> are implemented in terms of this function.
4783
4784 void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags)
4785
4786=for hackers
4787Found in file sv.c
4788
0f76ff59 4789=item sv_catsv_nomg
d8c40edc 4790X<sv_catsv_nomg>
0f76ff59
MHM
4791
4792Like C<sv_catsv> but doesn't process magic.
4793
4794 void sv_catsv_nomg(SV* dsv, SV* ssv)
4795
4796=for hackers
4797Found in file sv.h
4798
954c1994 4799=item sv_chop
d8c40edc 4800X<sv_chop>
954c1994 4801
1c846c1f 4802Efficient removal of characters from the beginning of the string buffer.
954c1994
GS
4803SvPOK(sv) must be true and the C<ptr> must be a pointer to somewhere inside
4804the string buffer. The C<ptr> becomes the first character of the adjusted
645c22ef 4805string. Uses the "OOK hack".
3f7c398e 4806Beware: after this function returns, C<ptr> and SvPVX_const(sv) may no longer
5c3943b6 4807refer to the same chunk of data.
954c1994 4808
f54cb97a 4809 void sv_chop(SV* sv, const char* ptr)
954c1994 4810
497711e7
GS
4811=for hackers
4812Found in file sv.c
4813
c461cf8f 4814=item sv_clear
d8c40edc 4815X<sv_clear>
c461cf8f 4816
645c22ef
DM
4817Clear an SV: call any destructors, free up any memory used by the body,
4818and free the body itself. The SV's head is I<not> freed, although
4819its type is set to all 1's so that it won't inadvertently be assumed
4820to be live during global destruction etc.
4821This function should only be called when REFCNT is zero. Most of the time
4822you'll want to call C<sv_free()> (or its macro wrapper C<SvREFCNT_dec>)
4823instead.
c461cf8f
JH
4824
4825 void sv_clear(SV* sv)
4826
4827=for hackers
4828Found in file sv.c
4829
954c1994 4830=item sv_cmp
d8c40edc 4831X<sv_cmp>
954c1994
GS
4832
4833Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the
4834string in C<sv1> is less than, equal to, or greater than the string in
645c22ef
DM
4835C<sv2>. Is UTF-8 and 'use bytes' aware, handles get magic, and will
4836coerce its args to strings if necessary. See also C<sv_cmp_locale>.
954c1994
GS
4837
4838 I32 sv_cmp(SV* sv1, SV* sv2)
4839
497711e7
GS
4840=for hackers
4841Found in file sv.c
4842
c461cf8f 4843=item sv_cmp_locale
d8c40edc 4844X<sv_cmp_locale>
c461cf8f 4845
645c22ef
DM
4846Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and
4847'use bytes' aware, handles get magic, and will coerce its args to strings
4848if necessary. See also C<sv_cmp_locale>. See also C<sv_cmp>.
c461cf8f
JH
4849
4850 I32 sv_cmp_locale(SV* sv1, SV* sv2)
4851
4852=for hackers
4853Found in file sv.c
4854
645c22ef 4855=item sv_collxfrm
d8c40edc 4856X<sv_collxfrm>
645c22ef
DM
4857
4858Add Collate Transform magic to an SV if it doesn't already have it.
4859
4860Any scalar variable may carry PERL_MAGIC_collxfrm magic that contains the
4861scalar data of the variable, but transformed to such a format that a normal
4862memory comparison can be used to compare the data according to the locale
4863settings.
4864
4865 char* sv_collxfrm(SV* sv, STRLEN* nxp)
4866
4867=for hackers
4868Found in file sv.c
4869
6050d10e 4870=item sv_copypv
d8c40edc 4871X<sv_copypv>
6050d10e
JP
4872
4873Copies a stringified representation of the source SV into the
4874destination SV. Automatically performs any necessary mg_get and
9ede5bc8 4875coercion of numeric values into strings. Guaranteed to preserve
6050d10e 4876UTF-8 flag even from overloaded objects. Similar in nature to
9ede5bc8
DM
4877sv_2pv[_flags] but operates directly on an SV instead of just the
4878string. Mostly uses sv_2pv_flags to do its work, except when that
6050d10e
JP
4879would lose the UTF-8'ness of the PV.
4880
4881 void sv_copypv(SV* dsv, SV* ssv)
4882
4883=for hackers
4884Found in file sv.c
4885
954c1994 4886=item sv_dec
d8c40edc 4887X<sv_dec>
954c1994 4888
645c22ef
DM
4889Auto-decrement of the value in the SV, doing string to numeric conversion
4890if necessary. Handles 'get' magic.
954c1994
GS
4891
4892 void sv_dec(SV* sv)
4893
497711e7
GS
4894=for hackers
4895Found in file sv.c
4896
954c1994 4897=item sv_derived_from
d8c40edc 4898X<sv_derived_from>
954c1994
GS
4899
4900Returns a boolean indicating whether the SV is derived from the specified
4901class. This is the function that implements C<UNIVERSAL::isa>. It works
4902for class names as well as for objects.
4903
4904 bool sv_derived_from(SV* sv, const char* name)
4905
497711e7
GS
4906=for hackers
4907Found in file universal.c
4908
954c1994 4909=item sv_eq
d8c40edc 4910X<sv_eq>
954c1994
GS
4911
4912Returns a boolean indicating whether the strings in the two SVs are
645c22ef
DM
4913identical. Is UTF-8 and 'use bytes' aware, handles get magic, and will
4914coerce its args to strings if necessary.
954c1994
GS
4915
4916 I32 sv_eq(SV* sv1, SV* sv2)
4917
497711e7
GS
4918=for hackers
4919Found in file sv.c
4920
645c22ef 4921=item sv_force_normal_flags
d8c40edc 4922X<sv_force_normal_flags>
645c22ef
DM
4923
4924Undo various types of fakery on an SV: if the PV is a shared string, make
4925a private copy; if we're a ref, stop refing; if we're a glob, downgrade to
765f542d
NC
4926an xpvmg; if we're a copy-on-write scalar, this is the on-write time when
4927we do the copy, and is also used locally. If C<SV_COW_DROP_PV> is set
4928then a copy-on-write scalar drops its PV buffer (if any) and becomes
4929SvPOK_off rather than making a copy. (Used where this scalar is about to be
d3050d9d 4930set to some other value.) In addition, the C<flags> parameter gets passed to
765f542d
NC
4931C<sv_unref_flags()> when unrefing. C<sv_force_normal> calls this function
4932with flags set to 0.
645c22ef
DM
4933
4934 void sv_force_normal_flags(SV *sv, U32 flags)
4935
4936=for hackers
4937Found in file sv.c
4938
c461cf8f 4939=item sv_free
d8c40edc 4940X<sv_free>
c461cf8f 4941
645c22ef
DM
4942Decrement an SV's reference count, and if it drops to zero, call
4943C<sv_clear> to invoke destructors and free up any memory used by
4944the body; finally, deallocate the SV's head itself.
4945Normally called via a wrapper macro C<SvREFCNT_dec>.
c461cf8f
JH
4946
4947 void sv_free(SV* sv)
4948
4949=for hackers
4950Found in file sv.c
4951
4952=item sv_gets
d8c40edc 4953X<sv_gets>
c461cf8f
JH
4954
4955Get a line from the filehandle and store it into the SV, optionally
4956appending to the currently-stored string.
4957
4958 char* sv_gets(SV* sv, PerlIO* fp, I32 append)
4959
4960=for hackers
4961Found in file sv.c
4962
954c1994 4963=item sv_grow
d8c40edc 4964X<sv_grow>
954c1994 4965
645c22ef
DM
4966Expands the character buffer in the SV. If necessary, uses C<sv_unref> and
4967upgrades the SV to C<SVt_PV>. Returns a pointer to the character buffer.
4968Use the C<SvGROW> wrapper instead.
954c1994
GS
4969
4970 char* sv_grow(SV* sv, STRLEN newlen)
4971
497711e7
GS
4972=for hackers
4973Found in file sv.c
4974
954c1994 4975=item sv_inc
d8c40edc 4976X<sv_inc>
954c1994 4977
645c22ef
DM
4978Auto-increment of the value in the SV, doing string to numeric conversion
4979if necessary. Handles 'get' magic.
954c1994
GS
4980
4981 void sv_inc(SV* sv)
4982
497711e7
GS
4983=for hackers
4984Found in file sv.c
4985
954c1994 4986=item sv_insert
d8c40edc 4987X<sv_insert>
954c1994
GS
4988
4989Inserts a string at the specified offset/length within the SV. Similar to
4990the Perl substr() function.
4991
e1ec3a88 4992 void sv_insert(SV* bigsv, STRLEN offset, STRLEN len, const char* little, STRLEN littlelen)
954c1994 4993
497711e7
GS
4994=for hackers
4995Found in file sv.c
4996
954c1994 4997=item sv_isa
d8c40edc 4998X<sv_isa>
954c1994
GS
4999
5000Returns a boolean indicating whether the SV is blessed into the specified
5001class. This does not check for subtypes; use C<sv_derived_from> to verify
5002an inheritance relationship.
5003
5004 int sv_isa(SV* sv, const char* name)
5005
497711e7
GS
5006=for hackers
5007Found in file sv.c
5008
954c1994 5009=item sv_isobject
d8c40edc 5010X<sv_isobject>
954c1994
GS
5011
5012Returns a boolean indicating whether the SV is an RV pointing to a blessed
5013object. If the SV is not an RV, or if the object is not blessed, then this
5014will return false.
5015
5016 int sv_isobject(SV* sv)
5017
497711e7
GS
5018=for hackers
5019Found in file sv.c
5020
954c1994 5021=item sv_len
d8c40edc 5022X<sv_len>
954c1994 5023
645c22ef
DM
5024Returns the length of the string in the SV. Handles magic and type
5025coercion. See also C<SvCUR>, which gives raw access to the xpv_cur slot.
954c1994
GS
5026
5027 STRLEN sv_len(SV* sv)
5028
497711e7
GS
5029=for hackers
5030Found in file sv.c
5031
c461cf8f 5032=item sv_len_utf8
d8c40edc 5033X<sv_len_utf8>
c461cf8f
JH
5034
5035Returns the number of characters in the string in an SV, counting wide
1e54db1a 5036UTF-8 bytes as a single character. Handles magic and type coercion.
c461cf8f
JH
5037
5038 STRLEN sv_len_utf8(SV* sv)
5039
5040=for hackers
5041Found in file sv.c
5042
954c1994 5043=item sv_magic
d8c40edc 5044X<sv_magic>
954c1994 5045
645c22ef
DM
5046Adds magic to an SV. First upgrades C<sv> to type C<SVt_PVMG> if necessary,
5047then adds a new magic item of type C<how> to the head of the magic list.
5048
2d8d5d5a
SH
5049See C<sv_magicext> (which C<sv_magic> now calls) for a description of the
5050handling of the C<name> and C<namlen> arguments.
5051
4509d3fb
SB
5052You need to use C<sv_magicext> to add magic to SvREADONLY SVs and also
5053to add more than one instance of the same 'how'.
5054
954c1994
GS
5055 void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen)
5056
497711e7
GS
5057=for hackers
5058Found in file sv.c
5059
a4f1a029 5060=item sv_magicext
d8c40edc 5061X<sv_magicext>
a4f1a029
NIS
5062
5063Adds magic to an SV, upgrading it if necessary. Applies the
2d8d5d5a 5064supplied vtable and returns a pointer to the magic added.
a4f1a029 5065
2d8d5d5a
SH
5066Note that C<sv_magicext> will allow things that C<sv_magic> will not.
5067In particular, you can add magic to SvREADONLY SVs, and add more than
5068one instance of the same 'how'.
a4f1a029 5069
2d8d5d5a
SH
5070If C<namlen> is greater than zero then a C<savepvn> I<copy> of C<name> is
5071stored, if C<namlen> is zero then C<name> is stored as-is and - as another
5072special case - if C<(name && namlen == HEf_SVKEY)> then C<name> is assumed
5073to contain an C<SV*> and is stored as-is with its REFCNT incremented.
a4f1a029 5074
2d8d5d5a 5075(This is now used as a subroutine by C<sv_magic>.)
a4f1a029 5076
e1ec3a88 5077 MAGIC * sv_magicext(SV* sv, SV* obj, int how, const MGVTBL *vtbl, const char* name, I32 namlen)
a4f1a029
NIS
5078
5079=for hackers
5080Found in file sv.c
5081
954c1994 5082=item sv_mortalcopy
d8c40edc 5083X<sv_mortalcopy>
954c1994 5084
645c22ef 5085Creates a new SV which is a copy of the original SV (using C<sv_setsv>).
793edb8a
JH
5086The new SV is marked as mortal. It will be destroyed "soon", either by an
5087explicit call to FREETMPS, or by an implicit call at places such as
5088statement boundaries. See also C<sv_newmortal> and C<sv_2mortal>.
954c1994
GS
5089
5090 SV* sv_mortalcopy(SV* oldsv)
5091
497711e7
GS
5092=for hackers
5093Found in file sv.c
5094
954c1994 5095=item sv_newmortal
d8c40edc 5096X<sv_newmortal>
954c1994 5097
645c22ef 5098Creates a new null SV which is mortal. The reference count of the SV is
793edb8a
JH
5099set to 1. It will be destroyed "soon", either by an explicit call to
5100FREETMPS, or by an implicit call at places such as statement boundaries.
5101See also C<sv_mortalcopy> and C<sv_2mortal>.
954c1994
GS
5102
5103 SV* sv_newmortal()
5104
497711e7
GS
5105=for hackers
5106Found in file sv.c
5107
645c22ef 5108=item sv_newref
d8c40edc 5109X<sv_newref>
645c22ef
DM
5110
5111Increment an SV's reference count. Use the C<SvREFCNT_inc()> wrapper
5112instead.
5113
5114 SV* sv_newref(SV* sv)
5115
5116=for hackers
5117Found in file sv.c
5118
645c22ef 5119=item sv_pos_b2u
d8c40edc 5120X<sv_pos_b2u>
645c22ef
DM
5121
5122Converts the value pointed to by offsetp from a count of bytes from the
1e54db1a 5123start of the string, to a count of the equivalent number of UTF-8 chars.
645c22ef
DM
5124Handles magic and type coercion.
5125
5126 void sv_pos_b2u(SV* sv, I32* offsetp)
5127
5128=for hackers
5129Found in file sv.c
5130
5131=item sv_pos_u2b
d8c40edc 5132X<sv_pos_u2b>
645c22ef 5133
1e54db1a 5134Converts the value pointed to by offsetp from a count of UTF-8 chars from
645c22ef
DM
5135the start of the string, to a count of the equivalent number of bytes; if
5136lenp is non-zero, it does the same to lenp, but this time starting from
5137the offset, rather than from the start of the string. Handles magic and
5138type coercion.
5139
5140 void sv_pos_u2b(SV* sv, I32* offsetp, I32* lenp)
5141
5142=for hackers
5143Found in file sv.c
5144
645c22ef 5145=item sv_pvbyten_force
d8c40edc 5146X<sv_pvbyten_force>
645c22ef 5147
9244d4ad 5148The backend for the C<SvPVbytex_force> macro. Always use the macro instead.
645c22ef
DM
5149
5150 char* sv_pvbyten_force(SV* sv, STRLEN* lp)
5151
5152=for hackers
5153Found in file sv.c
5154
c461cf8f 5155=item sv_pvn_force
d8c40edc 5156X<sv_pvn_force>
c461cf8f
JH
5157
5158Get a sensible string out of the SV somehow.
645c22ef
DM
5159A private implementation of the C<SvPV_force> macro for compilers which
5160can't cope with complex macro expressions. Always use the macro instead.
c461cf8f
JH
5161
5162 char* sv_pvn_force(SV* sv, STRLEN* lp)
5163
5164=for hackers
5165Found in file sv.c
5166
8d6d96c1 5167=item sv_pvn_force_flags
d8c40edc 5168X<sv_pvn_force_flags>
8d6d96c1
HS
5169
5170Get a sensible string out of the SV somehow.
5171If C<flags> has C<SV_GMAGIC> bit set, will C<mg_get> on C<sv> if
5172appropriate, else not. C<sv_pvn_force> and C<sv_pvn_force_nomg> are
5173implemented in terms of this function.
645c22ef
DM
5174You normally want to use the various wrapper macros instead: see
5175C<SvPV_force> and C<SvPV_force_nomg>
8d6d96c1
HS
5176
5177 char* sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags)
5178
5179=for hackers
5180Found in file sv.c
5181
c461cf8f 5182=item sv_pvutf8n_force
d8c40edc 5183X<sv_pvutf8n_force>
c461cf8f 5184
9244d4ad 5185The backend for the C<SvPVutf8x_force> macro. Always use the macro instead.
c461cf8f
JH
5186
5187 char* sv_pvutf8n_force(SV* sv, STRLEN* lp)
5188
5189=for hackers
5190Found in file sv.c
5191
5192=item sv_reftype
d8c40edc 5193X<sv_reftype>
c461cf8f
JH
5194
5195Returns a string describing what the SV is a reference to.
5196
1cb0ed9b 5197 char* sv_reftype(const SV* sv, int ob)
c461cf8f
JH
5198
5199=for hackers
5200Found in file sv.c
5201
5202=item sv_replace
d8c40edc 5203X<sv_replace>
c461cf8f
JH
5204
5205Make the first argument a copy of the second, then delete the original.
645c22ef
DM
5206The target SV physically takes over ownership of the body of the source SV
5207and inherits its flags; however, the target keeps any magic it owns,
5208and any magic in the source is discarded.
ff276b08 5209Note that this is a rather specialist SV copying operation; most of the
645c22ef 5210time you'll want to use C<sv_setsv> or one of its many macro front-ends.
c461cf8f
JH
5211
5212 void sv_replace(SV* sv, SV* nsv)
5213
5214=for hackers
5215Found in file sv.c
5216
645c22ef 5217=item sv_report_used
d8c40edc 5218X<sv_report_used>
645c22ef
DM
5219
5220Dump the contents of all SVs not yet freed. (Debugging aid).
5221
5222 void sv_report_used()
5223
5224=for hackers
5225Found in file sv.c
5226
451be7b1 5227=item sv_reset
d8c40edc 5228X<sv_reset>
451be7b1
DM
5229
5230Underlying implementation for the C<reset> Perl function.
5231Note that the perl-level function is vaguely deprecated.
5232
e1ec3a88 5233 void sv_reset(const char* s, HV* stash)
451be7b1
DM
5234
5235=for hackers
5236Found in file sv.c
5237
c461cf8f 5238=item sv_rvweaken
d8c40edc 5239X<sv_rvweaken>
c461cf8f 5240
645c22ef
DM
5241Weaken a reference: set the C<SvWEAKREF> flag on this RV; give the
5242referred-to SV C<PERL_MAGIC_backref> magic if it hasn't already; and
5243push a back-reference to this RV onto the array of backreferences
5244associated with that magic.
c461cf8f
JH
5245
5246 SV* sv_rvweaken(SV *sv)
5247
5248=for hackers
5249Found in file sv.c
5250
954c1994 5251=item sv_setiv
d8c40edc 5252X<sv_setiv>
954c1994 5253
645c22ef
DM
5254Copies an integer into the given SV, upgrading first if necessary.
5255Does not handle 'set' magic. See also C<sv_setiv_mg>.
954c1994
GS
5256
5257 void sv_setiv(SV* sv, IV num)
5258
497711e7
GS
5259=for hackers
5260Found in file sv.c
5261
954c1994 5262=item sv_setiv_mg
d8c40edc 5263X<sv_setiv_mg>
954c1994
GS
5264
5265Like C<sv_setiv>, but also handles 'set' magic.
5266
5267 void sv_setiv_mg(SV *sv, IV i)
5268
497711e7
GS
5269=for hackers
5270Found in file sv.c
5271
954c1994 5272=item sv_setnv
d8c40edc 5273X<sv_setnv>
954c1994 5274
645c22ef
DM
5275Copies a double into the given SV, upgrading first if necessary.
5276Does not handle 'set' magic. See also C<sv_setnv_mg>.
954c1994
GS
5277
5278 void sv_setnv(SV* sv, NV num)
5279
497711e7
GS
5280=for hackers
5281Found in file sv.c
5282
954c1994 5283=item sv_setnv_mg
d8c40edc 5284X<sv_setnv_mg>
954c1994
GS
5285
5286Like C<sv_setnv>, but also handles 'set' magic.
5287
5288 void sv_setnv_mg(SV *sv, NV num)
5289
497711e7
GS
5290=for hackers
5291Found in file sv.c
5292
954c1994 5293=item sv_setpv
d8c40edc 5294X<sv_setpv>
954c1994
GS
5295
5296Copies a string into an SV. The string must be null-terminated. Does not
5297handle 'set' magic. See C<sv_setpv_mg>.
5298
5299 void sv_setpv(SV* sv, const char* ptr)
5300
497711e7
GS
5301=for hackers
5302Found in file sv.c
5303
954c1994 5304=item sv_setpvf
d8c40edc 5305X<sv_setpvf>
954c1994 5306
bffc3d17
SH
5307Works like C<sv_catpvf> but copies the text into the SV instead of
5308appending it. Does not handle 'set' magic. See C<sv_setpvf_mg>.
954c1994
GS
5309
5310 void sv_setpvf(SV* sv, const char* pat, ...)
5311
497711e7
GS
5312=for hackers
5313Found in file sv.c
5314
954c1994 5315=item sv_setpvf_mg
d8c40edc 5316X<sv_setpvf_mg>
954c1994
GS
5317
5318Like C<sv_setpvf>, but also handles 'set' magic.
5319
5320 void sv_setpvf_mg(SV *sv, const char* pat, ...)
5321
497711e7
GS
5322=for hackers
5323Found in file sv.c
5324
2307c6d0 5325=item sv_setpviv
d8c40edc 5326X<sv_setpviv>
2307c6d0
SB
5327
5328Copies an integer into the given SV, also updating its string value.
5329Does not handle 'set' magic. See C<sv_setpviv_mg>.
5330
5331 void sv_setpviv(SV* sv, IV num)
5332
5333=for hackers
5334Found in file sv.c
5335
5336=item sv_setpviv_mg
d8c40edc 5337X<sv_setpviv_mg>
2307c6d0
SB
5338
5339Like C<sv_setpviv>, but also handles 'set' magic.
5340
5341 void sv_setpviv_mg(SV *sv, IV iv)
5342
5343=for hackers
5344Found in file sv.c
5345
954c1994 5346=item sv_setpvn
d8c40edc 5347X<sv_setpvn>
954c1994
GS
5348
5349Copies a string into an SV. The C<len> parameter indicates the number of
9e09f5f2
MHM
5350bytes to be copied. If the C<ptr> argument is NULL the SV will become
5351undefined. Does not handle 'set' magic. See C<sv_setpvn_mg>.
954c1994
GS
5352
5353 void sv_setpvn(SV* sv, const char* ptr, STRLEN len)
5354
497711e7
GS
5355=for hackers
5356Found in file sv.c
5357
954c1994 5358=item sv_setpvn_mg
d8c40edc 5359X<sv_setpvn_mg>
954c1994
GS
5360
5361Like C<sv_setpvn>, but also handles 'set' magic.
5362
5363 void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len)
5364
497711e7
GS
5365=for hackers
5366Found in file sv.c
5367
954c1994 5368=item sv_setpv_mg
d8c40edc 5369X<sv_setpv_mg>
954c1994
GS
5370
5371Like C<sv_setpv>, but also handles 'set' magic.
5372
5373 void sv_setpv_mg(SV *sv, const char *ptr)
5374
497711e7
GS
5375=for hackers
5376Found in file sv.c
5377
954c1994 5378=item sv_setref_iv
d8c40edc 5379X<sv_setref_iv>
954c1994
GS
5380
5381Copies an integer into a new SV, optionally blessing the SV. The C<rv>
5382argument will be upgraded to an RV. That RV will be modified to point to
5383the new SV. The C<classname> argument indicates the package for the
5384blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
d34c2299 5385will have a reference count of 1, and the RV will be returned.
954c1994
GS
5386
5387 SV* sv_setref_iv(SV* rv, const char* classname, IV iv)
5388
497711e7
GS
5389=for hackers
5390Found in file sv.c
5391
954c1994 5392=item sv_setref_nv
d8c40edc 5393X<sv_setref_nv>
954c1994
GS
5394
5395Copies a double into a new SV, optionally blessing the SV. The C<rv>
5396argument will be upgraded to an RV. That RV will be modified to point to
5397the new SV. The C<classname> argument indicates the package for the
5398blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
d34c2299 5399will have a reference count of 1, and the RV will be returned.
954c1994
GS
5400
5401 SV* sv_setref_nv(SV* rv, const char* classname, NV nv)
5402
497711e7
GS
5403=for hackers
5404Found in file sv.c
5405
954c1994 5406=item sv_setref_pv
d8c40edc 5407X<sv_setref_pv>
954c1994
GS
5408
5409Copies a pointer into a new SV, optionally blessing the SV. The C<rv>
5410argument will be upgraded to an RV. That RV will be modified to point to
5411the new SV. If the C<pv> argument is NULL then C<PL_sv_undef> will be placed
5412into the SV. The C<classname> argument indicates the package for the
5413blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
d34c2299 5414will have a reference count of 1, and the RV will be returned.
954c1994
GS
5415
5416Do not use with other Perl types such as HV, AV, SV, CV, because those
5417objects will become corrupted by the pointer copy process.
5418
5419Note that C<sv_setref_pvn> copies the string while this copies the pointer.
5420
5421 SV* sv_setref_pv(SV* rv, const char* classname, void* pv)
5422
497711e7
GS
5423=for hackers
5424Found in file sv.c
5425
954c1994 5426=item sv_setref_pvn
d8c40edc 5427X<sv_setref_pvn>
954c1994
GS
5428
5429Copies a string into a new SV, optionally blessing the SV. The length of the
5430string must be specified with C<n>. The C<rv> argument will be upgraded to
5431an RV. That RV will be modified to point to the new SV. The C<classname>
5432argument indicates the package for the blessing. Set C<classname> to
b0bc38e6 5433C<Nullch> to avoid the blessing. The new SV will have a reference count
d34c2299 5434of 1, and the RV will be returned.
954c1994
GS
5435
5436Note that C<sv_setref_pv> copies the pointer while this copies the string.
5437
1b6737cc 5438 SV* sv_setref_pvn(SV* rv, const char* classname, const char* pv, STRLEN n)
954c1994 5439
497711e7
GS
5440=for hackers
5441Found in file sv.c
5442
e1c57cef 5443=item sv_setref_uv
d8c40edc 5444X<sv_setref_uv>
e1c57cef
JH
5445
5446Copies an unsigned integer into a new SV, optionally blessing the SV. The C<rv>
5447argument will be upgraded to an RV. That RV will be modified to point to
5448the new SV. The C<classname> argument indicates the package for the
5449blessing. Set C<classname> to C<Nullch> to avoid the blessing. The new SV
d34c2299 5450will have a reference count of 1, and the RV will be returned.
e1c57cef
JH
5451
5452 SV* sv_setref_uv(SV* rv, const char* classname, UV uv)
5453
5454=for hackers
5455Found in file sv.c
5456
954c1994 5457=item sv_setsv
d8c40edc 5458X<sv_setsv>
954c1994 5459
645c22ef
DM
5460Copies the contents of the source SV C<ssv> into the destination SV
5461C<dsv>. The source SV may be destroyed if it is mortal, so don't use this
5462function if the source SV needs to be reused. Does not handle 'set' magic.
5463Loosely speaking, it performs a copy-by-value, obliterating any previous
5464content of the destination.
5465
5466You probably want to use one of the assortment of wrappers, such as
5467C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and
5468C<SvSetMagicSV_nosteal>.
5469
954c1994
GS
5470 void sv_setsv(SV* dsv, SV* ssv)
5471
497711e7
GS
5472=for hackers
5473Found in file sv.c
5474
8d6d96c1 5475=item sv_setsv_flags
d8c40edc 5476X<sv_setsv_flags>
8d6d96c1 5477
645c22ef
DM
5478Copies the contents of the source SV C<ssv> into the destination SV
5479C<dsv>. The source SV may be destroyed if it is mortal, so don't use this
5480function if the source SV needs to be reused. Does not handle 'set' magic.
5481Loosely speaking, it performs a copy-by-value, obliterating any previous
5482content of the destination.
5483If the C<flags> parameter has the C<SV_GMAGIC> bit set, will C<mg_get> on
2d8d5d5a
SH
5484C<ssv> if appropriate, else not. If the C<flags> parameter has the
5485C<NOSTEAL> bit set then the buffers of temps will not be stolen. <sv_setsv>
5486and C<sv_setsv_nomg> are implemented in terms of this function.
645c22ef
DM
5487
5488You probably want to use one of the assortment of wrappers, such as
5489C<SvSetSV>, C<SvSetSV_nosteal>, C<SvSetMagicSV> and
5490C<SvSetMagicSV_nosteal>.
5491
5492This is the primary function for copying scalars, and most other
5493copy-ish functions and macros use this underneath.
8d6d96c1
HS
5494
5495 void sv_setsv_flags(SV* dsv, SV* ssv, I32 flags)
5496
5497=for hackers
5498Found in file sv.c
5499
954c1994 5500=item sv_setsv_mg
d8c40edc 5501X<sv_setsv_mg>
954c1994
GS
5502
5503Like C<sv_setsv>, but also handles 'set' magic.
5504
5505 void sv_setsv_mg(SV *dstr, SV *sstr)
5506
497711e7
GS
5507=for hackers
5508Found in file sv.c
5509
0f76ff59 5510=item sv_setsv_nomg
d8c40edc 5511X<sv_setsv_nomg>
0f76ff59
MHM
5512
5513Like C<sv_setsv> but doesn't process magic.
5514
5515 void sv_setsv_nomg(SV* dsv, SV* ssv)
5516
5517=for hackers
5518Found in file sv.h
5519
954c1994 5520=item sv_setuv
d8c40edc 5521X<sv_setuv>
954c1994 5522
645c22ef
DM
5523Copies an unsigned integer into the given SV, upgrading first if necessary.
5524Does not handle 'set' magic. See also C<sv_setuv_mg>.
954c1994
GS
5525
5526 void sv_setuv(SV* sv, UV num)
5527
497711e7
GS
5528=for hackers
5529Found in file sv.c
5530
954c1994 5531=item sv_setuv_mg
d8c40edc 5532X<sv_setuv_mg>
954c1994
GS
5533
5534Like C<sv_setuv>, but also handles 'set' magic.
5535
5536 void sv_setuv_mg(SV *sv, UV u)
5537
497711e7
GS
5538=for hackers
5539Found in file sv.c
5540
451be7b1 5541=item sv_tainted
d8c40edc 5542X<sv_tainted>
451be7b1
DM
5543
5544Test an SV for taintedness. Use C<SvTAINTED> instead.
5545 bool sv_tainted(SV* sv)
5546
5547=for hackers
5548Found in file sv.c
5549
c461cf8f 5550=item sv_true
d8c40edc 5551X<sv_true>
c461cf8f
JH
5552
5553Returns true if the SV has a true value by Perl's rules.
645c22ef
DM
5554Use the C<SvTRUE> macro instead, which may call C<sv_true()> or may
5555instead use an in-line version.
c461cf8f
JH
5556
5557 I32 sv_true(SV *sv)
5558
5559=for hackers
5560Found in file sv.c
5561
5562=item sv_unmagic
d8c40edc 5563X<sv_unmagic>
c461cf8f 5564
645c22ef 5565Removes all magic of type C<type> from an SV.
c461cf8f
JH
5566
5567 int sv_unmagic(SV* sv, int type)
5568
5569=for hackers
5570Found in file sv.c
5571
840a7b70 5572=item sv_unref_flags
d8c40edc 5573X<sv_unref_flags>
840a7b70
IZ
5574
5575Unsets the RV status of the SV, and decrements the reference count of
5576whatever was being referenced by the RV. This can almost be thought of
5577as a reversal of C<newSVrv>. The C<cflags> argument can contain
5578C<SV_IMMEDIATE_UNREF> to force the reference count to be decremented
5579(otherwise the decrementing is conditional on the reference count being
5580different from one or the reference being a readonly SV).
ae154d6d 5581See C<SvROK_off>.
840a7b70
IZ
5582
5583 void sv_unref_flags(SV* sv, U32 flags)
5584
5585=for hackers
5586Found in file sv.c
5587
451be7b1 5588=item sv_untaint
d8c40edc 5589X<sv_untaint>
451be7b1
DM
5590
5591Untaint an SV. Use C<SvTAINTED_off> instead.
5592 void sv_untaint(SV* sv)
5593
5594=for hackers
5595Found in file sv.c
5596
954c1994 5597=item sv_upgrade
d8c40edc 5598X<sv_upgrade>
954c1994 5599
ff276b08 5600Upgrade an SV to a more complex form. Generally adds a new body type to the
645c22ef 5601SV, then copies across as much information as possible from the old body.
ff276b08 5602You generally want to use the C<SvUPGRADE> macro wrapper. See also C<svtype>.
954c1994 5603
63f97190 5604 void sv_upgrade(SV* sv, U32 mt)
954c1994 5605
497711e7
GS
5606=for hackers
5607Found in file sv.c
5608
954c1994 5609=item sv_usepvn
d8c40edc 5610X<sv_usepvn>
954c1994
GS
5611
5612Tells an SV to use C<ptr> to find its string value. Normally the string is
1c846c1f 5613stored inside the SV but sv_usepvn allows the SV to use an outside string.
954c1994
GS
5614The C<ptr> should point to memory that was allocated by C<malloc>. The
5615string length, C<len>, must be supplied. This function will realloc the
5616memory pointed to by C<ptr>, so that pointer should not be freed or used by
5617the programmer after giving it to sv_usepvn. Does not handle 'set' magic.
5618See C<sv_usepvn_mg>.
5619
5620 void sv_usepvn(SV* sv, char* ptr, STRLEN len)
5621
497711e7
GS
5622=for hackers
5623Found in file sv.c
5624
954c1994 5625=item sv_usepvn_mg
d8c40edc 5626X<sv_usepvn_mg>
954c1994
GS
5627
5628Like C<sv_usepvn>, but also handles 'set' magic.
5629
5630 void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)
5631
497711e7
GS
5632=for hackers
5633Found in file sv.c
5634
2457d041 5635=item sv_utf8_decode
d8c40edc 5636X<sv_utf8_decode>
2457d041 5637
78ea37eb
TS
5638If the PV of the SV is an octet sequence in UTF-8
5639and contains a multiple-byte character, the C<SvUTF8> flag is turned on
5640so that it looks like a character. If the PV contains only single-byte
5641characters, the C<SvUTF8> flag stays being off.
5642Scans PV for validity and returns false if the PV is invalid UTF-8.
2457d041
JH
5643
5644NOTE: this function is experimental and may change or be
5645removed without notice.
5646
5647 bool sv_utf8_decode(SV *sv)
5648
5649=for hackers
5650Found in file sv.c
5651
c461cf8f 5652=item sv_utf8_downgrade
d8c40edc 5653X<sv_utf8_downgrade>
c461cf8f 5654
78ea37eb
TS
5655Attempts to convert the PV of an SV from characters to bytes.
5656If the PV contains a character beyond byte, this conversion will fail;
5657in this case, either returns false or, if C<fail_ok> is not
c461cf8f
JH
5658true, croaks.
5659
9ede5bc8
DM
5660This is not as a general purpose Unicode to byte encoding interface:
5661use the Encode extension for that.
5662
c461cf8f
JH
5663NOTE: this function is experimental and may change or be
5664removed without notice.
5665
5666 bool sv_utf8_downgrade(SV *sv, bool fail_ok)
5667
5668=for hackers
5669Found in file sv.c
5670
5671=item sv_utf8_encode
d8c40edc 5672X<sv_utf8_encode>
c461cf8f 5673
78ea37eb
TS
5674Converts the PV of an SV to UTF-8, but then turns the C<SvUTF8>
5675flag off so that it looks like octets again.
c461cf8f
JH
5676
5677 void sv_utf8_encode(SV *sv)
5678
5679=for hackers
5680Found in file sv.c
5681
5682=item sv_utf8_upgrade
d8c40edc 5683X<sv_utf8_upgrade>
c461cf8f 5684
78ea37eb 5685Converts the PV of an SV to its UTF-8-encoded form.
645c22ef 5686Forces the SV to string form if it is not already.
2457d041
JH
5687Always sets the SvUTF8 flag to avoid future validity checks even
5688if all the bytes have hibit clear.
c461cf8f 5689
9ede5bc8
DM
5690This is not as a general purpose byte encoding to Unicode interface:
5691use the Encode extension for that.
5692
2457d041 5693 STRLEN sv_utf8_upgrade(SV *sv)
c461cf8f
JH
5694
5695=for hackers
5696Found in file sv.c
5697
8d6d96c1 5698=item sv_utf8_upgrade_flags
d8c40edc 5699X<sv_utf8_upgrade_flags>
8d6d96c1 5700
78ea37eb 5701Converts the PV of an SV to its UTF-8-encoded form.
645c22ef 5702Forces the SV to string form if it is not already.
8d6d96c1
HS
5703Always sets the SvUTF8 flag to avoid future validity checks even
5704if all the bytes have hibit clear. If C<flags> has C<SV_GMAGIC> bit set,
5705will C<mg_get> on C<sv> if appropriate, else not. C<sv_utf8_upgrade> and
5706C<sv_utf8_upgrade_nomg> are implemented in terms of this function.
5707
9ede5bc8
DM
5708This is not as a general purpose byte encoding to Unicode interface:
5709use the Encode extension for that.
5710
8d6d96c1
HS
5711 STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags)
5712
5713=for hackers
5714Found in file sv.c
5715
bffc3d17 5716=item sv_vcatpvf
d8c40edc 5717X<sv_vcatpvf>
bffc3d17
SH
5718
5719Processes its arguments like C<vsprintf> and appends the formatted output
5720to an SV. Does not handle 'set' magic. See C<sv_vcatpvf_mg>.
5721
5722Usually used via its frontend C<sv_catpvf>.
5723
5724 void sv_vcatpvf(SV* sv, const char* pat, va_list* args)
5725
5726=for hackers
5727Found in file sv.c
5728
954c1994 5729=item sv_vcatpvfn
d8c40edc 5730X<sv_vcatpvfn>
954c1994
GS
5731
5732Processes its arguments like C<vsprintf> and appends the formatted output
5733to an SV. Uses an array of SVs if the C style variable argument list is
5734missing (NULL). When running with taint checks enabled, indicates via
5735C<maybe_tainted> if results are untrustworthy (often due to the use of
5736locales).
5737
bffc3d17 5738Usually used via one of its frontends C<sv_vcatpvf> and C<sv_vcatpvf_mg>.
645c22ef 5739
954c1994
GS
5740 void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
5741
497711e7
GS
5742=for hackers
5743Found in file sv.c
5744
bffc3d17 5745=item sv_vcatpvf_mg
d8c40edc 5746X<sv_vcatpvf_mg>
bffc3d17
SH
5747
5748Like C<sv_vcatpvf>, but also handles 'set' magic.
5749
5750Usually used via its frontend C<sv_catpvf_mg>.
5751
5752 void sv_vcatpvf_mg(SV* sv, const char* pat, va_list* args)
5753
5754=for hackers
5755Found in file sv.c
5756
5757=item sv_vsetpvf
d8c40edc 5758X<sv_vsetpvf>
bffc3d17
SH
5759
5760Works like C<sv_vcatpvf> but copies the text into the SV instead of
5761appending it. Does not handle 'set' magic. See C<sv_vsetpvf_mg>.
5762
5763Usually used via its frontend C<sv_setpvf>.
5764
5765 void sv_vsetpvf(SV* sv, const char* pat, va_list* args)
5766
5767=for hackers
5768Found in file sv.c
5769
954c1994 5770=item sv_vsetpvfn
d8c40edc 5771X<sv_vsetpvfn>
954c1994 5772
bffc3d17 5773Works like C<sv_vcatpvfn> but copies the text into the SV instead of
954c1994
GS
5774appending it.
5775
bffc3d17 5776Usually used via one of its frontends C<sv_vsetpvf> and C<sv_vsetpvf_mg>.
645c22ef 5777
954c1994
GS
5778 void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted)
5779
497711e7 5780=for hackers
94bdecf9
JH
5781Found in file sv.c
5782
bffc3d17 5783=item sv_vsetpvf_mg
d8c40edc 5784X<sv_vsetpvf_mg>
bffc3d17
SH
5785
5786Like C<sv_vsetpvf>, but also handles 'set' magic.
5787
5788Usually used via its frontend C<sv_setpvf_mg>.
5789
5790 void sv_vsetpvf_mg(SV* sv, const char* pat, va_list* args)
5791
5792=for hackers
5793Found in file sv.c
5794
94bdecf9
JH
5795
5796=back
5797
5798=head1 Unicode Support
5799
5800=over 8
5801
5802=item bytes_from_utf8
d8c40edc 5803X<bytes_from_utf8>
94bdecf9 5804
1e54db1a 5805Converts a string C<s> of length C<len> from UTF-8 into byte encoding.
35a4481c 5806Unlike C<utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
94bdecf9
JH
5807the newly-created string, and updates C<len> to contain the new
5808length. Returns the original string if no conversion occurs, C<len>
5809is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to
58100 if C<s> is converted or contains all 7bit characters.
5811
5812NOTE: this function is experimental and may change or be
5813removed without notice.
5814
e1ec3a88 5815 U8* bytes_from_utf8(const U8 *s, STRLEN *len, bool *is_utf8)
94bdecf9
JH
5816
5817=for hackers
5818Found in file utf8.c
5819
5820=item bytes_to_utf8
d8c40edc 5821X<bytes_to_utf8>
94bdecf9 5822
1e54db1a 5823Converts a string C<s> of length C<len> from ASCII into UTF-8 encoding.
94bdecf9
JH
5824Returns a pointer to the newly-created string, and sets C<len> to
5825reflect the new length.
5826
1e54db1a 5827If you want to convert to UTF-8 from other encodings than ASCII,
bd5cf849
HS
5828see sv_recode_to_utf8().
5829
94bdecf9
JH
5830NOTE: this function is experimental and may change or be
5831removed without notice.
5832
35a4481c 5833 U8* bytes_to_utf8(const U8 *s, STRLEN *len)
94bdecf9
JH
5834
5835=for hackers
5836Found in file utf8.c
5837
5838=item ibcmp_utf8
d8c40edc 5839X<ibcmp_utf8>
94bdecf9
JH
5840
5841Return true if the strings s1 and s2 differ case-insensitively, false
5842if not (if they are equal case-insensitively). If u1 is true, the
5843string s1 is assumed to be in UTF-8-encoded Unicode. If u2 is true,
5844the string s2 is assumed to be in UTF-8-encoded Unicode. If u1 or u2
5845are false, the respective string is assumed to be in native 8-bit
5846encoding.
5847
5848If the pe1 and pe2 are non-NULL, the scanning pointers will be copied
5849in there (they will point at the beginning of the I<next> character).
5850If the pointers behind pe1 or pe2 are non-NULL, they are the end
5851pointers beyond which scanning will not continue under any
fa11829f 5852circumstances. If the byte lengths l1 and l2 are non-zero, s1+l1 and
94bdecf9
JH
5853s2+l2 will be used as goal end pointers that will also stop the scan,
5854and which qualify towards defining a successful match: all the scans
5855that define an explicit length must reach their goal pointers for
5856a match to succeed).
5857
5858For case-insensitiveness, the "casefolding" of Unicode is used
5859instead of upper/lowercasing both the characters, see
5860http://www.unicode.org/unicode/reports/tr21/ (Case Mappings).
5861
5862 I32 ibcmp_utf8(const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2)
5863
5864=for hackers
5865Found in file utf8.c
5866
5867=item is_utf8_char
d8c40edc 5868X<is_utf8_char>
94bdecf9
JH
5869
5870Tests if some arbitrary number of bytes begins in a valid UTF-8
641d4181
JH
5871character. Note that an INVARIANT (i.e. ASCII) character is a valid
5872UTF-8 character. The actual number of bytes in the UTF-8 character
5873will be returned if it is valid, otherwise 0.
94bdecf9 5874
7fc63493 5875 STRLEN is_utf8_char(const U8 *p)
94bdecf9
JH
5876
5877=for hackers
5878Found in file utf8.c
5879
5880=item is_utf8_string
d8c40edc 5881X<is_utf8_string>
94bdecf9 5882
bd5cf849 5883Returns true if first C<len> bytes of the given string form a valid
1e54db1a
JH
5884UTF-8 string, false otherwise. Note that 'a valid UTF-8 string' does
5885not mean 'a string that contains code points above 0x7F encoded in UTF-8'
5886because a valid ASCII string is a valid UTF-8 string.
94bdecf9 5887
768c67ee
JH
5888See also is_utf8_string_loclen() and is_utf8_string_loc().
5889
7fc63493 5890 bool is_utf8_string(const U8 *s, STRLEN len)
94bdecf9
JH
5891
5892=for hackers
5893Found in file utf8.c
497711e7 5894
72d6ef7d 5895=item is_utf8_string_loc
d8c40edc 5896X<is_utf8_string_loc>
72d6ef7d 5897
9244d4ad 5898Like is_utf8_string() but stores the location of the failure (in the
768c67ee
JH
5899case of "utf8ness failure") or the location s+len (in the case of
5900"utf8ness success") in the C<ep>.
5901
5902See also is_utf8_string_loclen() and is_utf8_string().
72d6ef7d 5903
7fc63493 5904 bool is_utf8_string_loc(const U8 *s, STRLEN len, const U8 **p)
72d6ef7d
JH
5905
5906=for hackers
5907Found in file utf8.c
5908
768c67ee 5909=item is_utf8_string_loclen
d8c40edc 5910X<is_utf8_string_loclen>
768c67ee 5911
9244d4ad 5912Like is_utf8_string() but stores the location of the failure (in the
768c67ee
JH
5913case of "utf8ness failure") or the location s+len (in the case of
5914"utf8ness success") in the C<ep>, and the number of UTF-8
5915encoded characters in the C<el>.
5916
5917See also is_utf8_string_loc() and is_utf8_string().
5918
5919 bool is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
5920
5921=for hackers
5922Found in file utf8.c
5923
94bdecf9 5924=item pv_uni_display
d8c40edc 5925X<pv_uni_display>
954c1994 5926
94bdecf9
JH
5927Build to the scalar dsv a displayable version of the string spv,
5928length len, the displayable version being at most pvlim bytes long
5929(if longer, the rest is truncated and "..." will be appended).
0a2ef054
JH
5930
5931The flags argument can have UNI_DISPLAY_ISPRINT set to display
a4f1a029 5932isPRINT()able characters as themselves, UNI_DISPLAY_BACKSLASH
0a2ef054
JH
5933to display the \\[nrfta\\] as the backslashed versions (like '\n')
5934(UNI_DISPLAY_BACKSLASH is preferred over UNI_DISPLAY_ISPRINT for \\).
5935UNI_DISPLAY_QQ (and its alias UNI_DISPLAY_REGEX) have both
5936UNI_DISPLAY_BACKSLASH and UNI_DISPLAY_ISPRINT turned on.
5937
94bdecf9 5938The pointer to the PV of the dsv is returned.
954c1994 5939
e1ec3a88 5940 char* pv_uni_display(SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim, UV flags)
954c1994 5941
497711e7 5942=for hackers
94bdecf9 5943Found in file utf8.c
497711e7 5944
220e2d4e 5945=item sv_cat_decode
d8c40edc 5946X<sv_cat_decode>
220e2d4e
IH
5947
5948The encoding is assumed to be an Encode object, the PV of the ssv is
5949assumed to be octets in that encoding and decoding the input starts
5950from the position which (PV + *offset) pointed to. The dsv will be
5951concatenated the decoded UTF-8 string from ssv. Decoding will terminate
5952when the string tstr appears in decoding output or the input ends on
5953the PV of the ssv. The value which the offset points will be modified
5954to the last input position on the ssv.
5955
5956Returns TRUE if the terminator was found, else returns FALSE.
5957
5958 bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen)
5959
5960=for hackers
5961Found in file sv.c
5962
94bdecf9 5963=item sv_recode_to_utf8
d8c40edc 5964X<sv_recode_to_utf8>
954c1994 5965
94bdecf9
JH
5966The encoding is assumed to be an Encode object, on entry the PV
5967of the sv is assumed to be octets in that encoding, and the sv
5968will be converted into Unicode (and UTF-8).
954c1994 5969
94bdecf9
JH
5970If the sv already is UTF-8 (or if it is not POK), or if the encoding
5971is not a reference, nothing is done to the sv. If the encoding is not
5972an C<Encode::XS> Encoding object, bad things will happen.
5973(See F<lib/encoding.pm> and L<Encode>).
5974
5975The PV of the sv is returned.
5976
5977 char* sv_recode_to_utf8(SV* sv, SV *encoding)
954c1994 5978
497711e7 5979=for hackers
94bdecf9 5980Found in file sv.c
497711e7 5981
94bdecf9 5982=item sv_uni_display
d8c40edc 5983X<sv_uni_display>
954c1994 5984
94bdecf9 5985Build to the scalar dsv a displayable version of the scalar sv,
0a2ef054 5986the displayable version being at most pvlim bytes long
94bdecf9 5987(if longer, the rest is truncated and "..." will be appended).
0a2ef054
JH
5988
5989The flags argument is as in pv_uni_display().
5990
94bdecf9 5991The pointer to the PV of the dsv is returned.
954c1994 5992
94bdecf9 5993 char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
954c1994 5994
497711e7 5995=for hackers
94bdecf9 5996Found in file utf8.c
497711e7 5997
6b5c0936 5998=item to_utf8_case
d8c40edc 5999X<to_utf8_case>
6b5c0936
JH
6000
6001The "p" contains the pointer to the UTF-8 string encoding
6002the character that is being converted.
6003
6004The "ustrp" is a pointer to the character buffer to put the
6005conversion result to. The "lenp" is a pointer to the length
6006of the result.
6007
12b7c5c7 6008The "swashp" is a pointer to the swash to use.
6b5c0936 6009
12b7c5c7
JH
6010Both the special and normal mappings are stored lib/unicore/To/Foo.pl,
6011and loaded by SWASHGET, using lib/utf8_heavy.pl. The special (usually,
6012but not always, a multicharacter mapping), is tried first.
6013
6014The "special" is a string like "utf8::ToSpecLower", which means the
6015hash %utf8::ToSpecLower. The access to the hash is through
6016Perl_to_utf8_case().
6b5c0936 6017
12b7c5c7
JH
6018The "normal" is a string like "ToLower" which means the swash
6019%utf8::ToLower.
6b5c0936 6020
9a957fbc 6021 UV to_utf8_case(const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special)
6b5c0936
JH
6022
6023=for hackers
6024Found in file utf8.c
6025
d3e79532 6026=item to_utf8_fold
d8c40edc 6027X<to_utf8_fold>
d3e79532
JH
6028
6029Convert the UTF-8 encoded character at p to its foldcase version and
6030store that in UTF-8 in ustrp and its length in bytes in lenp. Note
59887a99 6031that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
d3e79532
JH
6032foldcase version may be longer than the original character (up to
6033three characters).
6034
6035The first character of the foldcased version is returned
6036(but note, as explained above, that there may be more.)
6037
7fc63493 6038 UV to_utf8_fold(const U8 *p, U8* ustrp, STRLEN *lenp)
d3e79532
JH
6039
6040=for hackers
6041Found in file utf8.c
6042
6043=item to_utf8_lower
d8c40edc 6044X<to_utf8_lower>
d3e79532
JH
6045
6046Convert the UTF-8 encoded character at p to its lowercase version and
6047store that in UTF-8 in ustrp and its length in bytes in lenp. Note
59887a99
MHM
6048that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
6049lowercase version may be longer than the original character.
d3e79532
JH
6050
6051The first character of the lowercased version is returned
6052(but note, as explained above, that there may be more.)
6053
7fc63493 6054 UV to_utf8_lower(const U8 *p, U8* ustrp, STRLEN *lenp)
d3e79532
JH
6055
6056=for hackers
6057Found in file utf8.c
6058
6059=item to_utf8_title
d8c40edc 6060X<to_utf8_title>
d3e79532
JH
6061
6062Convert the UTF-8 encoded character at p to its titlecase version and
6063store that in UTF-8 in ustrp and its length in bytes in lenp. Note
59887a99
MHM
6064that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since the
6065titlecase version may be longer than the original character.
d3e79532
JH
6066
6067The first character of the titlecased version is returned
6068(but note, as explained above, that there may be more.)
6069
7fc63493 6070 UV to_utf8_title(const U8 *p, U8* ustrp, STRLEN *lenp)
d3e79532
JH
6071
6072=for hackers
6073Found in file utf8.c
6074
6075=item to_utf8_upper
d8c40edc 6076X<to_utf8_upper>
d3e79532
JH
6077
6078Convert the UTF-8 encoded character at p to its uppercase version and
6079store that in UTF-8 in ustrp and its length in bytes in lenp. Note
59887a99
MHM
6080that the ustrp needs to be at least UTF8_MAXBYTES_CASE+1 bytes since
6081the uppercase version may be longer than the original character.
d3e79532
JH
6082
6083The first character of the uppercased version is returned
6084(but note, as explained above, that there may be more.)
6085
7fc63493 6086 UV to_utf8_upper(const U8 *p, U8* ustrp, STRLEN *lenp)
d3e79532
JH
6087
6088=for hackers
6089Found in file utf8.c
6090
cd299c6e
RGS
6091=item utf8n_to_uvchr
6092X<utf8n_to_uvchr>
6093
6094flags
6095
6096Returns the native character value of the first character in the string
6097C<s>
6098which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
6099length, in bytes, of that character.
6100
6101Allows length and flags to be passed to low level routine.
6102
6103 UV utf8n_to_uvchr(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
6104
6105=for hackers
6106Found in file utf8.c
6107
282f25c9 6108=item utf8n_to_uvuni
d8c40edc 6109X<utf8n_to_uvuni>
282f25c9
JH
6110
6111Bottom level UTF-8 decode routine.
6112Returns the unicode code point value of the first character in the string C<s>
1e54db1a 6113which is assumed to be in UTF-8 encoding and no longer than C<curlen>;
282f25c9
JH
6114C<retlen> will be set to the length, in bytes, of that character.
6115
1e54db1a 6116If C<s> does not point to a well-formed UTF-8 character, the behaviour
282f25c9
JH
6117is dependent on the value of C<flags>: if it contains UTF8_CHECK_ONLY,
6118it is assumed that the caller will raise a warning, and this function
6119will silently just set C<retlen> to C<-1> and return zero. If the
6120C<flags> does not contain UTF8_CHECK_ONLY, warnings about
6121malformations will be given, C<retlen> will be set to the expected
6122length of the UTF-8 character in bytes, and zero will be returned.
6123
6124The C<flags> can also contain various flags to allow deviations from
6125the strict UTF-8 encoding (see F<utf8.h>).
6126
6127Most code should use utf8_to_uvchr() rather than call this directly.
6128
9a957fbc 6129 UV utf8n_to_uvuni(const U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
282f25c9
JH
6130
6131=for hackers
6132Found in file utf8.c
6133
b06226ff 6134=item utf8_distance
d8c40edc 6135X<utf8_distance>
b06226ff 6136
1e54db1a 6137Returns the number of UTF-8 characters between the UTF-8 pointers C<a>
b06226ff
JH
6138and C<b>.
6139
6140WARNING: use only if you *know* that the pointers point inside the
6141same UTF-8 buffer.
6142
35a4481c 6143 IV utf8_distance(const U8 *a, const U8 *b)
b06226ff
JH
6144
6145=for hackers
6146Found in file utf8.c
6147
6148=item utf8_hop
d8c40edc 6149X<utf8_hop>
b06226ff 6150
8850bf83
JH
6151Return the UTF-8 pointer C<s> displaced by C<off> characters, either
6152forward or backward.
b06226ff
JH
6153
6154WARNING: do not use the following unless you *know* C<off> is within
8850bf83
JH
6155the UTF-8 data pointed to by C<s> *and* that on entry C<s> is aligned
6156on the first byte of character or just after the last byte of a character.
b06226ff 6157
4373e329 6158 U8* utf8_hop(const U8 *s, I32 off)
b06226ff
JH
6159
6160=for hackers
6161Found in file utf8.c
6162
6163=item utf8_length
d8c40edc 6164X<utf8_length>
b06226ff
JH
6165
6166Return the length of the UTF-8 char encoded string C<s> in characters.
6167Stops at C<e> (inclusive). If C<e E<lt> s> or if the scan would end
6168up past C<e>, croaks.
6169
35a4481c 6170 STRLEN utf8_length(const U8* s, const U8 *e)
b06226ff
JH
6171
6172=for hackers
6173Found in file utf8.c
6174
497711e7 6175=item utf8_to_bytes
d8c40edc 6176X<utf8_to_bytes>
497711e7 6177
1e54db1a 6178Converts a string C<s> of length C<len> from UTF-8 into byte encoding.
246fae53
MG
6179Unlike C<bytes_to_utf8>, this over-writes the original string, and
6180updates len to contain the new length.
67e989fb 6181Returns zero on failure, setting C<len> to -1.
497711e7 6182
eebe1485
SC
6183NOTE: this function is experimental and may change or be
6184removed without notice.
6185
6186 U8* utf8_to_bytes(U8 *s, STRLEN *len)
497711e7
GS
6187
6188=for hackers
6189Found in file utf8.c
6190
282f25c9 6191=item utf8_to_uvchr
d8c40edc 6192X<utf8_to_uvchr>
b6b716fe 6193
282f25c9 6194Returns the native character value of the first character in the string C<s>
1e54db1a 6195which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
282f25c9 6196length, in bytes, of that character.
28d3d195 6197
1e54db1a 6198If C<s> does not point to a well-formed UTF-8 character, zero is
282f25c9 6199returned and retlen is set, if possible, to -1.
444155da 6200
9a957fbc 6201 UV utf8_to_uvchr(const U8 *s, STRLEN *retlen)
444155da
JH
6202
6203=for hackers
6204Found in file utf8.c
6205
282f25c9 6206=item utf8_to_uvuni
d8c40edc 6207X<utf8_to_uvuni>
444155da 6208
282f25c9 6209Returns the Unicode code point of the first character in the string C<s>
1e54db1a 6210which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
1aa99e6b 6211length, in bytes, of that character.
444155da 6212
282f25c9
JH
6213This function should only be used when returned UV is considered
6214an index into the Unicode semantic tables (e.g. swashes).
6215
1e54db1a 6216If C<s> does not point to a well-formed UTF-8 character, zero is
dcad2880 6217returned and retlen is set, if possible, to -1.
b6b716fe 6218
9a957fbc 6219 UV utf8_to_uvuni(const U8 *s, STRLEN *retlen)
282f25c9
JH
6220
6221=for hackers
6222Found in file utf8.c
6223
cd299c6e
RGS
6224=item uvchr_to_utf8
6225X<uvchr_to_utf8>
6226
6227Adds the UTF-8 representation of the Native codepoint C<uv> to the end
6228of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
6229bytes available. The return value is the pointer to the byte after the
6230end of the new character. In other words,
6231
6232 d = uvchr_to_utf8(d, uv);
6233
6234is the recommended wide native character-aware way of saying
6235
6236 *(d++) = uv;
6237
6238 U8* uvchr_to_utf8(U8 *d, UV uv)
6239
6240=for hackers
6241Found in file utf8.c
6242
b851fbc1 6243=item uvuni_to_utf8_flags
d8c40edc 6244X<uvuni_to_utf8_flags>
eebe1485 6245
1e54db1a 6246Adds the UTF-8 representation of the Unicode codepoint C<uv> to the end
59887a99 6247of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
eebe1485 6248bytes available. The return value is the pointer to the byte after the
282f25c9 6249end of the new character. In other words,
eebe1485 6250
b851fbc1
JH
6251 d = uvuni_to_utf8_flags(d, uv, flags);
6252
6253or, in most cases,
6254
282f25c9 6255 d = uvuni_to_utf8(d, uv);
eebe1485 6256
b851fbc1
JH
6257(which is equivalent to)
6258
6259 d = uvuni_to_utf8_flags(d, uv, 0);
6260
eebe1485
SC
6261is the recommended Unicode-aware way of saying
6262
6263 *(d++) = uv;
6264
b851fbc1 6265 U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags)
b6b716fe
SC
6266
6267=for hackers
6268Found in file utf8.c
6269
497711e7 6270
94bdecf9 6271=back
954c1994 6272
94bdecf9 6273=head1 Variables created by C<xsubpp> and C<xsubpp> internal functions
954c1994 6274
94bdecf9 6275=over 8
954c1994 6276
94bdecf9 6277=item ax
d8c40edc 6278X<ax>
497711e7 6279
94bdecf9
JH
6280Variable which is setup by C<xsubpp> to indicate the stack base offset,
6281used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros. The C<dMARK> macro
6282must be called prior to setup the C<MARK> variable.
954c1994 6283
94bdecf9 6284 I32 ax
954c1994 6285
497711e7
GS
6286=for hackers
6287Found in file XSUB.h
6288
94bdecf9 6289=item CLASS
d8c40edc 6290X<CLASS>
954c1994 6291
94bdecf9
JH
6292Variable which is setup by C<xsubpp> to indicate the
6293class name for a C++ XS constructor. This is always a C<char*>. See C<THIS>.
954c1994 6294
94bdecf9 6295 char* CLASS
954c1994 6296
497711e7
GS
6297=for hackers
6298Found in file XSUB.h
6299
94bdecf9 6300=item dAX
d8c40edc 6301X<dAX>
954c1994 6302
94bdecf9
JH
6303Sets up the C<ax> variable.
6304This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
954c1994 6305
94bdecf9 6306 dAX;
954c1994 6307
497711e7
GS
6308=for hackers
6309Found in file XSUB.h
6310
557b887a 6311=item dAXMARK
d8c40edc 6312X<dAXMARK>
557b887a
SS
6313
6314Sets up the C<ax> variable and stack marker variable C<mark>.
6315This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
6316
6317 dAXMARK;
6318
6319=for hackers
6320Found in file XSUB.h
6321
94bdecf9 6322=item dITEMS
d8c40edc 6323X<dITEMS>
954c1994 6324
94bdecf9
JH
6325Sets up the C<items> variable.
6326This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
954c1994 6327
94bdecf9 6328 dITEMS;
954c1994 6329
497711e7
GS
6330=for hackers
6331Found in file XSUB.h
6332
88037a85 6333=item dUNDERBAR
d8c40edc 6334X<dUNDERBAR>
88037a85
RGS
6335
6336Sets up the C<padoff_du> variable for an XSUB that wishes to use
6337C<UNDERBAR>.
6338
6339 dUNDERBAR;
6340
6341=for hackers
6342Found in file XSUB.h
6343
94bdecf9 6344=item dXSARGS
d8c40edc 6345X<dXSARGS>
954c1994 6346
94bdecf9
JH
6347Sets up stack and mark pointers for an XSUB, calling dSP and dMARK.
6348Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>.
6349This is usually handled automatically by C<xsubpp>.
954c1994 6350
94bdecf9 6351 dXSARGS;
954c1994 6352
497711e7
GS
6353=for hackers
6354Found in file XSUB.h
6355
94bdecf9 6356=item dXSI32
d8c40edc 6357X<dXSI32>
954c1994 6358
94bdecf9
JH
6359Sets up the C<ix> variable for an XSUB which has aliases. This is usually
6360handled automatically by C<xsubpp>.
954c1994 6361
94bdecf9 6362 dXSI32;
954c1994 6363
497711e7
GS
6364=for hackers
6365Found in file XSUB.h
6366
94bdecf9 6367=item items
d8c40edc 6368X<items>
954c1994 6369
94bdecf9
JH
6370Variable which is setup by C<xsubpp> to indicate the number of
6371items on the stack. See L<perlxs/"Variable-length Parameter Lists">.
954c1994 6372
94bdecf9 6373 I32 items
954c1994 6374
497711e7
GS
6375=for hackers
6376Found in file XSUB.h
6377
94bdecf9 6378=item ix
d8c40edc 6379X<ix>
954c1994 6380
94bdecf9
JH
6381Variable which is setup by C<xsubpp> to indicate which of an
6382XSUB's aliases was used to invoke it. See L<perlxs/"The ALIAS: Keyword">.
954c1994 6383
94bdecf9 6384 I32 ix
954c1994 6385
497711e7
GS
6386=for hackers
6387Found in file XSUB.h
6388
94bdecf9 6389=item newXSproto
d8c40edc 6390X<newXSproto>
954c1994 6391
94bdecf9
JH
6392Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to
6393the subs.
954c1994 6394
497711e7
GS
6395=for hackers
6396Found in file XSUB.h
6397
94bdecf9 6398=item RETVAL
d8c40edc 6399X<RETVAL>
954c1994 6400
94bdecf9
JH
6401Variable which is setup by C<xsubpp> to hold the return value for an
6402XSUB. This is always the proper type for the XSUB. See
6403L<perlxs/"The RETVAL Variable">.
954c1994 6404
94bdecf9 6405 (whatever) RETVAL
954c1994 6406
497711e7
GS
6407=for hackers
6408Found in file XSUB.h
6409
94bdecf9 6410=item ST
d8c40edc 6411X<ST>
954c1994 6412
94bdecf9 6413Used to access elements on the XSUB's stack.
954c1994 6414
94bdecf9 6415 SV* ST(int ix)
954c1994 6416
497711e7
GS
6417=for hackers
6418Found in file XSUB.h
6419
94bdecf9 6420=item THIS
d8c40edc 6421X<THIS>
954c1994 6422
94bdecf9
JH
6423Variable which is setup by C<xsubpp> to designate the object in a C++
6424XSUB. This is always the proper type for the C++ object. See C<CLASS> and
6425L<perlxs/"Using XS With C++">.
954c1994 6426
94bdecf9 6427 (whatever) THIS
954c1994 6428
497711e7
GS
6429=for hackers
6430Found in file XSUB.h
6431
88037a85 6432=item UNDERBAR
d8c40edc 6433X<UNDERBAR>
88037a85
RGS
6434
6435The SV* corresponding to the $_ variable. Works even if there
6436is a lexical $_ in scope.
6437
6438=for hackers
6439Found in file XSUB.h
6440
94bdecf9 6441=item XS
d8c40edc 6442X<XS>
954c1994 6443
94bdecf9
JH
6444Macro to declare an XSUB and its C parameter list. This is handled by
6445C<xsubpp>.
954c1994 6446
497711e7
GS
6447=for hackers
6448Found in file XSUB.h
6449
954c1994 6450=item XS_VERSION
d8c40edc 6451X<XS_VERSION>
954c1994
GS
6452
6453The version identifier for an XS module. This is usually
6454handled automatically by C<ExtUtils::MakeMaker>. See C<XS_VERSION_BOOTCHECK>.
6455
497711e7
GS
6456=for hackers
6457Found in file XSUB.h
6458
954c1994 6459=item XS_VERSION_BOOTCHECK
d8c40edc 6460X<XS_VERSION_BOOTCHECK>
954c1994
GS
6461
6462Macro to verify that a PM module's $VERSION variable matches the XS
6463module's C<XS_VERSION> variable. This is usually handled automatically by
6464C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">.
6465
6466 XS_VERSION_BOOTCHECK;
6467
497711e7
GS
6468=for hackers
6469Found in file XSUB.h
6470
954c1994 6471
94bdecf9 6472=back
954c1994 6473
94bdecf9
JH
6474=head1 Warning and Dieing
6475
6476=over 8
6477
6478=item croak
d8c40edc 6479X<croak>
94bdecf9
JH
6480
6481This is the XSUB-writer's interface to Perl's C<die> function.
966353fd
MF
6482Normally call this function the same way you call the C C<printf>
6483function. Calling C<croak> returns control directly to Perl,
6484sidestepping the normal C order of execution. See C<warn>.
94bdecf9
JH
6485
6486If you want to throw an exception object, assign the object to
6487C<$@> and then pass C<Nullch> to croak():
6488
6489 errsv = get_sv("@", TRUE);
6490 sv_setsv(errsv, exception_object);
6491 croak(Nullch);
6492
6493 void croak(const char* pat, ...)
954c1994 6494
497711e7 6495=for hackers
94bdecf9
JH
6496Found in file util.c
6497
6498=item warn
d8c40edc 6499X<warn>
94bdecf9 6500
966353fd
MF
6501This is the XSUB-writer's interface to Perl's C<warn> function. Call this
6502function the same way you call the C C<printf> function. See C<croak>.
94bdecf9
JH
6503
6504 void warn(const char* pat, ...)
6505
6506=for hackers
6507Found in file util.c
6508
497711e7 6509
954c1994
GS
6510=back
6511
6512=head1 AUTHORS
6513
6514Until May 1997, this document was maintained by Jeff Okamoto
6515<okamoto@corp.hp.com>. It is now maintained as part of Perl itself.
6516
6517With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
6518Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
6519Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
6520Stephen McCamant, and Gurusamy Sarathy.
6521
6522API Listing originally by Dean Roehrich <roehrich@cray.com>.
6523
6524Updated to be autogenerated from comments in the source by Benjamin Stuhl.
6525
6526=head1 SEE ALSO
6527
6528perlguts(1), perlxs(1), perlxstut(1), perlintern(1)
6529