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