1PERLAPI(1) Perl Programmers Reference Guide PERLAPI(1)
2
3
4
6 perlapi - autogenerated documentation for the perl public API
7
9 This file contains the documentation of the perl public API generated
10 by embed.pl, specifically a listing of functions, macros, flags, and
11 variables that may be used by extension writers. At the end is a list
12 of functions which have yet to be documented. The interfaces of those
13 are subject to change without notice. Anything not listed here is not
14 part of the public API, and should not be used by extension writers at
15 all. For these reasons, blindly using functions listed in proto.h is
16 to be avoided when writing extensions.
17
18 In Perl, unlike C, a string of characters may generally contain
19 embedded "NUL" characters. Sometimes in the documentation a Perl
20 string is referred to as a "buffer" to distinguish it from a C string,
21 but sometimes they are both just referred to as strings.
22
23 Note that all Perl API global variables must be referenced with the
24 "PL_" prefix. Again, those not listed here are not to be used by
25 extension writers, and can be changed or removed without notice; same
26 with macros. Some macros are provided for compatibility with the
27 older, unadorned names, but this support may be disabled in a future
28 release.
29
30 Perl was originally written to handle US-ASCII only (that is characters
31 whose ordinal numbers are in the range 0 - 127). And documentation and
32 comments may still use the term ASCII, when sometimes in fact the
33 entire range from 0 - 255 is meant.
34
35 The non-ASCII characters below 256 can have various meanings, depending
36 on various things. (See, most notably, perllocale.) But usually the
37 whole range can be referred to as ISO-8859-1. Often, the term
38 "Latin-1" (or "Latin1") is used as an equivalent for ISO-8859-1. But
39 some people treat "Latin1" as referring just to the characters in the
40 range 128 through 255, or somethimes from 160 through 255. This
41 documentation uses "Latin1" and "Latin-1" to refer to all 256
42 characters.
43
44 Note that Perl can be compiled and run under either ASCII or EBCDIC
45 (See perlebcdic). Most of the documentation (and even comments in the
46 code) ignore the EBCDIC possibility. For almost all purposes the
47 differences are transparent. As an example, under EBCDIC, instead of
48 UTF-8, UTF-EBCDIC is used to encode Unicode strings, and so whenever
49 this documentation refers to "utf8" (and variants of that name,
50 including in function names), it also (essentially transparently) means
51 "UTF-EBCDIC". But the ordinals of characters differ between ASCII,
52 EBCDIC, and the UTF- encodings, and a string encoded in UTF-EBCDIC may
53 occupy a different number of bytes than in UTF-8.
54
55 The listing below is alphabetical, case insensitive.
56
58 av_clear
59 Frees the all the elements of an array, leaving it empty. The
60 XS equivalent of "@array = ()". See also "av_undef".
61
62 Note that it is possible that the actions of a destructor
63 called directly or indirectly by freeing an element of the
64 array could cause the reference count of the array itself to be
65 reduced (e.g. by deleting an entry in the symbol table). So it
66 is a possibility that the AV could have been freed (or even
67 reallocated) on return from the call unless you hold a
68 reference to it.
69
70 void av_clear(AV *av)
71
72 av_create_and_push
73 NOTE: this function is experimental and may change or be
74 removed without notice.
75
76 Push an SV onto the end of the array, creating the array if
77 necessary. A small internal helper function to remove a
78 commonly duplicated idiom.
79
80 void av_create_and_push(AV **const avp,
81 SV *const val)
82
83 av_create_and_unshift_one
84 NOTE: this function is experimental and may change or be
85 removed without notice.
86
87 Unshifts an SV onto the beginning of the array, creating the
88 array if necessary. A small internal helper function to remove
89 a commonly duplicated idiom.
90
91 SV** av_create_and_unshift_one(AV **const avp,
92 SV *const val)
93
94 av_delete
95 Deletes the element indexed by "key" from the array, makes the
96 element mortal, and returns it. If "flags" equals "G_DISCARD",
97 the element is freed and NULL is returned. NULL is also
98 returned if "key" is out of range.
99
100 Perl equivalent: "splice(@myarray, $key, 1, undef)" (with the
101 "splice" in void context if "G_DISCARD" is present).
102
103 SV* av_delete(AV *av, SSize_t key, I32 flags)
104
105 av_exists
106 Returns true if the element indexed by "key" has been
107 initialized.
108
109 This relies on the fact that uninitialized array elements are
110 set to "NULL".
111
112 Perl equivalent: "exists($myarray[$key])".
113
114 bool av_exists(AV *av, SSize_t key)
115
116 av_extend
117 Pre-extend an array. The "key" is the index to which the array
118 should be extended.
119
120 void av_extend(AV *av, SSize_t key)
121
122 av_fetch
123 Returns the SV at the specified index in the array. The "key"
124 is the index. If lval is true, you are guaranteed to get a
125 real SV back (in case it wasn't real before), which you can
126 then modify. Check that the return value is non-null before
127 dereferencing it to a "SV*".
128
129 See "Understanding the Magic of Tied Hashes and Arrays" in
130 perlguts for more information on how to use this function on
131 tied arrays.
132
133 The rough perl equivalent is $myarray[$key].
134
135 SV** av_fetch(AV *av, SSize_t key, I32 lval)
136
137 AvFILL Same as "av_top_index()" or "av_tindex()".
138
139 int AvFILL(AV* av)
140
141 av_fill Set the highest index in the array to the given number,
142 equivalent to Perl's "$#array = $fill;".
143
144 The number of elements in the array will be "fill + 1" after
145 "av_fill()" returns. If the array was previously shorter, then
146 the additional elements appended are set to NULL. If the array
147 was longer, then the excess elements are freed.
148 "av_fill(av, -1)" is the same as "av_clear(av)".
149
150 void av_fill(AV *av, SSize_t fill)
151
152 av_len Same as "av_top_index". Note that, unlike what the name
153 implies, it returns the highest index in the array, so to get
154 the size of the array you need to use "av_len(av) + 1". This
155 is unlike "sv_len", which returns what you would expect.
156
157 SSize_t av_len(AV *av)
158
159 av_make Creates a new AV and populates it with a list of SVs. The SVs
160 are copied into the array, so they may be freed after the call
161 to "av_make". The new AV will have a reference count of 1.
162
163 Perl equivalent: "my @new_array = ($scalar1, $scalar2,
164 $scalar3...);"
165
166 AV* av_make(SSize_t size, SV **strp)
167
168 av_pop Removes one SV from the end of the array, reducing its size by
169 one and returning the SV (transferring control of one reference
170 count) to the caller. Returns &PL_sv_undef if the array is
171 empty.
172
173 Perl equivalent: "pop(@myarray);"
174
175 SV* av_pop(AV *av)
176
177 av_push Pushes an SV (transferring control of one reference count) onto
178 the end of the array. The array will grow automatically to
179 accommodate the addition.
180
181 Perl equivalent: "push @myarray, $val;".
182
183 void av_push(AV *av, SV *val)
184
185 av_shift
186 Removes one SV from the start of the array, reducing its size
187 by one and returning the SV (transferring control of one
188 reference count) to the caller. Returns &PL_sv_undef if the
189 array is empty.
190
191 Perl equivalent: "shift(@myarray);"
192
193 SV* av_shift(AV *av)
194
195 av_store
196 Stores an SV in an array. The array index is specified as
197 "key". The return value will be "NULL" if the operation failed
198 or if the value did not need to be actually stored within the
199 array (as in the case of tied arrays). Otherwise, it can be
200 dereferenced to get the "SV*" that was stored there (= "val")).
201
202 Note that the caller is responsible for suitably incrementing
203 the reference count of "val" before the call, and decrementing
204 it if the function returned "NULL".
205
206 Approximate Perl equivalent: "splice(@myarray, $key, 1, $val)".
207
208 See "Understanding the Magic of Tied Hashes and Arrays" in
209 perlguts for more information on how to use this function on
210 tied arrays.
211
212 SV** av_store(AV *av, SSize_t key, SV *val)
213
214 av_tindex
215 Same as "av_top_index()".
216
217 int av_tindex(AV* av)
218
219 av_top_index
220 Returns the highest index in the array. The number of elements
221 in the array is "av_top_index(av) + 1". Returns -1 if the
222 array is empty.
223
224 The Perl equivalent for this is $#myarray.
225
226 (A slightly shorter form is "av_tindex".)
227
228 SSize_t av_top_index(AV *av)
229
230 av_undef
231 Undefines the array. The XS equivalent of "undef(@array)".
232
233 As well as freeing all the elements of the array (like
234 "av_clear()"), this also frees the memory used by the av to
235 store its list of scalars.
236
237 See "av_clear" for a note about the array possibly being
238 invalid on return.
239
240 void av_undef(AV *av)
241
242 av_unshift
243 Unshift the given number of "undef" values onto the beginning
244 of the array. The array will grow automatically to accommodate
245 the addition.
246
247 Perl equivalent: "unshift @myarray, ((undef) x $num);"
248
249 void av_unshift(AV *av, SSize_t num)
250
251 get_av Returns the AV of the specified Perl global or package array
252 with the given name (so it won't work on lexical variables).
253 "flags" are passed to "gv_fetchpv". If "GV_ADD" is set and the
254 Perl variable does not exist then it will be created. If
255 "flags" is zero and the variable does not exist then NULL is
256 returned.
257
258 Perl equivalent: "@{"$name"}".
259
260 NOTE: the perl_ form of this function is deprecated.
261
262 AV* get_av(const char *name, I32 flags)
263
264 newAV Creates a new AV. The reference count is set to 1.
265
266 Perl equivalent: "my @array;".
267
268 AV* newAV()
269
270 sortsv In-place sort an array of SV pointers with the given comparison
271 routine.
272
273 Currently this always uses mergesort. See "sortsv_flags" for a
274 more flexible routine.
275
276 void sortsv(SV** array, size_t num_elts,
277 SVCOMPARE_t cmp)
278
280 call_argv
281 Performs a callback to the specified named and package-scoped
282 Perl subroutine with "argv" (a "NULL"-terminated array of
283 strings) as arguments. See perlcall.
284
285 Approximate Perl equivalent: "&{"$sub_name"}(@$argv)".
286
287 NOTE: the perl_ form of this function is deprecated.
288
289 I32 call_argv(const char* sub_name, I32 flags,
290 char** argv)
291
292 call_method
293 Performs a callback to the specified Perl method. The blessed
294 object must be on the stack. See perlcall.
295
296 NOTE: the perl_ form of this function is deprecated.
297
298 I32 call_method(const char* methname, I32 flags)
299
300 call_pv Performs a callback to the specified Perl sub. See perlcall.
301
302 NOTE: the perl_ form of this function is deprecated.
303
304 I32 call_pv(const char* sub_name, I32 flags)
305
306 call_sv Performs a callback to the Perl sub specified by the SV.
307
308 If neither the "G_METHOD" nor "G_METHOD_NAMED" flag is
309 supplied, the SV may be any of a CV, a GV, a reference to a CV,
310 a reference to a GV or "SvPV(sv)" will be used as the name of
311 the sub to call.
312
313 If the "G_METHOD" flag is supplied, the SV may be a reference
314 to a CV or "SvPV(sv)" will be used as the name of the method to
315 call.
316
317 If the "G_METHOD_NAMED" flag is supplied, "SvPV(sv)" will be
318 used as the name of the method to call.
319
320 Some other values are treated specially for internal use and
321 should not be depended on.
322
323 See perlcall.
324
325 NOTE: the perl_ form of this function is deprecated.
326
327 I32 call_sv(SV* sv, volatile I32 flags)
328
329 ENTER Opening bracket on a callback. See "LEAVE" and perlcall.
330
331 ENTER;
332
333 ENTER_with_name(name)
334 Same as "ENTER", but when debugging is enabled it also
335 associates the given literal string with the new scope.
336
337 ENTER_with_name(name);
338
339 eval_pv Tells Perl to "eval" the given string in scalar context and
340 return an SV* result.
341
342 NOTE: the perl_ form of this function is deprecated.
343
344 SV* eval_pv(const char* p, I32 croak_on_error)
345
346 eval_sv Tells Perl to "eval" the string in the SV. It supports the
347 same flags as "call_sv", with the obvious exception of
348 "G_EVAL". See perlcall.
349
350 NOTE: the perl_ form of this function is deprecated.
351
352 I32 eval_sv(SV* sv, I32 flags)
353
354 FREETMPS
355 Closing bracket for temporaries on a callback. See "SAVETMPS"
356 and perlcall.
357
358 FREETMPS;
359
360 LEAVE Closing bracket on a callback. See "ENTER" and perlcall.
361
362 LEAVE;
363
364 LEAVE_with_name(name)
365 Same as "LEAVE", but when debugging is enabled it first checks
366 that the scope has the given name. "name" must be a literal
367 string.
368
369 LEAVE_with_name(name);
370
371 SAVETMPS
372 Opening bracket for temporaries on a callback. See "FREETMPS"
373 and perlcall.
374
375 SAVETMPS;
376
378 Perl uses "full" Unicode case mappings. This means that converting a
379 single character to another case may result in a sequence of more than
380 one character. For example, the uppercase of "ss" (LATIN SMALL LETTER
381 SHARP S) is the two character sequence "SS". This presents some
382 complications The lowercase of all characters in the range 0..255 is
383 a single character, and thus "toLOWER_L1" is furnished. But,
384 "toUPPER_L1" can't exist, as it couldn't return a valid result for all
385 legal inputs. Instead "toUPPER_uvchr" has an API that does allow every
386 possible legal result to be returned.) Likewise no other function that
387 is crippled by not being able to give the correct results for the full
388 range of possible inputs has been implemented here.
389
390 toFOLD Converts the specified character to foldcase. If the input is
391 anything but an ASCII uppercase character, that input character
392 itself is returned. Variant "toFOLD_A" is equivalent. (There
393 is no equivalent "to_FOLD_L1" for the full Latin1 range, as the
394 full generality of "toFOLD_uvchr" is needed there.)
395
396 U8 toFOLD(U8 ch)
397
398 toFOLD_utf8
399 This is like "toFOLD_utf8_safe", but doesn't have the "e"
400 parameter The function therefore can't check if it is reading
401 beyond the end of the string. Starting in Perl v5.30, it will
402 take the "e" parameter, becoming a synonym for
403 "toFOLD_utf8_safe". At that time every program that uses it
404 will have to be changed to successfully compile. In the
405 meantime, the first runtime call to "toFOLD_utf8" from each
406 call point in the program will raise a deprecation warning,
407 enabled by default. You can convert your program now to use
408 "toFOLD_utf8_safe", and avoid the warnings, and get an extra
409 measure of protection, or you can wait until v5.30, when you'll
410 be forced to add the "e" parameter.
411
412 UV toFOLD_utf8(U8* p, U8* s, STRLEN* lenp)
413
414 toFOLD_utf8_safe
415 Converts the first UTF-8 encoded character in the sequence
416 starting at "p" and extending no further than "e - 1" to its
417 foldcase version, and stores that in UTF-8 in "s", and its
418 length in bytes in "lenp". Note that the buffer pointed to by
419 "s" needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
420 foldcase version may be longer than the original character.
421
422 The first code point of the foldcased version is returned (but
423 note, as explained at the top of this section, that there may
424 be more).
425
426 The suffix "_safe" in the function's name indicates that it
427 will not attempt to read beyond "e - 1", provided that the
428 constraint "s < e" is true (this is asserted for in
429 "-DDEBUGGING" builds). If the UTF-8 for the input character is
430 malformed in some way, the program may croak, or the function
431 may return the REPLACEMENT CHARACTER, at the discretion of the
432 implementation, and subject to change in future releases.
433
434 UV toFOLD_utf8_safe(U8* p, U8* e, U8* s,
435 STRLEN* lenp)
436
437 toFOLD_uvchr
438 Converts the code point "cp" to its foldcase version, and
439 stores that in UTF-8 in "s", and its length in bytes in "lenp".
440 The code point is interpreted as native if less than 256;
441 otherwise as Unicode. Note that the buffer pointed to by "s"
442 needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
443 foldcase version may be longer than the original character.
444
445 The first code point of the foldcased version is returned (but
446 note, as explained at the top of this section, that there may
447 be more).
448
449 UV toFOLD_uvchr(UV cp, U8* s, STRLEN* lenp)
450
451 toLOWER Converts the specified character to lowercase. If the input is
452 anything but an ASCII uppercase character, that input character
453 itself is returned. Variant "toLOWER_A" is equivalent.
454
455 U8 toLOWER(U8 ch)
456
457 toLOWER_L1
458 Converts the specified Latin1 character to lowercase. The
459 results are undefined if the input doesn't fit in a byte.
460
461 U8 toLOWER_L1(U8 ch)
462
463 toLOWER_LC
464 Converts the specified character to lowercase using the current
465 locale's rules, if possible; otherwise returns the input
466 character itself.
467
468 U8 toLOWER_LC(U8 ch)
469
470 toLOWER_utf8
471 This is like "toLOWER_utf8_safe", but doesn't have the "e"
472 parameter The function therefore can't check if it is reading
473 beyond the end of the string. Starting in Perl v5.30, it will
474 take the "e" parameter, becoming a synonym for
475 "toLOWER_utf8_safe". At that time every program that uses it
476 will have to be changed to successfully compile. In the
477 meantime, the first runtime call to "toLOWER_utf8" from each
478 call point in the program will raise a deprecation warning,
479 enabled by default. You can convert your program now to use
480 "toLOWER_utf8_safe", and avoid the warnings, and get an extra
481 measure of protection, or you can wait until v5.30, when you'll
482 be forced to add the "e" parameter.
483
484 UV toLOWER_utf8(U8* p, U8* s, STRLEN* lenp)
485
486 toLOWER_utf8_safe
487 Converts the first UTF-8 encoded character in the sequence
488 starting at "p" and extending no further than "e - 1" to its
489 lowercase version, and stores that in UTF-8 in "s", and its
490 length in bytes in "lenp". Note that the buffer pointed to by
491 "s" needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
492 lowercase version may be longer than the original character.
493
494 The first code point of the lowercased version is returned (but
495 note, as explained at the top of this section, that there may
496 be more).
497
498 The suffix "_safe" in the function's name indicates that it
499 will not attempt to read beyond "e - 1", provided that the
500 constraint "s < e" is true (this is asserted for in
501 "-DDEBUGGING" builds). If the UTF-8 for the input character is
502 malformed in some way, the program may croak, or the function
503 may return the REPLACEMENT CHARACTER, at the discretion of the
504 implementation, and subject to change in future releases.
505
506 UV toLOWER_utf8_safe(U8* p, U8* e, U8* s,
507 STRLEN* lenp)
508
509 toLOWER_uvchr
510 Converts the code point "cp" to its lowercase version, and
511 stores that in UTF-8 in "s", and its length in bytes in "lenp".
512 The code point is interpreted as native if less than 256;
513 otherwise as Unicode. Note that the buffer pointed to by "s"
514 needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
515 lowercase version may be longer than the original character.
516
517 The first code point of the lowercased version is returned (but
518 note, as explained at the top of this section, that there may
519 be more).
520
521 UV toLOWER_uvchr(UV cp, U8* s, STRLEN* lenp)
522
523 toTITLE Converts the specified character to titlecase. If the input is
524 anything but an ASCII lowercase character, that input character
525 itself is returned. Variant "toTITLE_A" is equivalent. (There
526 is no "toTITLE_L1" for the full Latin1 range, as the full
527 generality of "toTITLE_uvchr" is needed there. Titlecase is
528 not a concept used in locale handling, so there is no
529 functionality for that.)
530
531 U8 toTITLE(U8 ch)
532
533 toTITLE_utf8
534 This is like "toLOWER_utf8_safe", but doesn't have the "e"
535 parameter The function therefore can't check if it is reading
536 beyond the end of the string. Starting in Perl v5.30, it will
537 take the "e" parameter, becoming a synonym for
538 "toTITLE_utf8_safe". At that time every program that uses it
539 will have to be changed to successfully compile. In the
540 meantime, the first runtime call to "toTITLE_utf8" from each
541 call point in the program will raise a deprecation warning,
542 enabled by default. You can convert your program now to use
543 "toTITLE_utf8_safe", and avoid the warnings, and get an extra
544 measure of protection, or you can wait until v5.30, when you'll
545 be forced to add the "e" parameter.
546
547 UV toTITLE_utf8(U8* p, U8* s, STRLEN* lenp)
548
549 toTITLE_utf8_safe
550 Converts the first UTF-8 encoded character in the sequence
551 starting at "p" and extending no further than "e - 1" to its
552 titlecase version, and stores that in UTF-8 in "s", and its
553 length in bytes in "lenp". Note that the buffer pointed to by
554 "s" needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
555 titlecase version may be longer than the original character.
556
557 The first code point of the titlecased version is returned (but
558 note, as explained at the top of this section, that there may
559 be more).
560
561 The suffix "_safe" in the function's name indicates that it
562 will not attempt to read beyond "e - 1", provided that the
563 constraint "s < e" is true (this is asserted for in
564 "-DDEBUGGING" builds). If the UTF-8 for the input character is
565 malformed in some way, the program may croak, or the function
566 may return the REPLACEMENT CHARACTER, at the discretion of the
567 implementation, and subject to change in future releases.
568
569 UV toTITLE_utf8_safe(U8* p, U8* e, U8* s,
570 STRLEN* lenp)
571
572 toTITLE_uvchr
573 Converts the code point "cp" to its titlecase version, and
574 stores that in UTF-8 in "s", and its length in bytes in "lenp".
575 The code point is interpreted as native if less than 256;
576 otherwise as Unicode. Note that the buffer pointed to by "s"
577 needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
578 titlecase version may be longer than the original character.
579
580 The first code point of the titlecased version is returned (but
581 note, as explained at the top of this section, that there may
582 be more).
583
584 UV toTITLE_uvchr(UV cp, U8* s, STRLEN* lenp)
585
586 toUPPER Converts the specified character to uppercase. If the input is
587 anything but an ASCII lowercase character, that input character
588 itself is returned. Variant "toUPPER_A" is equivalent.
589
590 U8 toUPPER(U8 ch)
591
592 toUPPER_utf8
593 This is like "toUPPER_utf8_safe", but doesn't have the "e"
594 parameter The function therefore can't check if it is reading
595 beyond the end of the string. Starting in Perl v5.30, it will
596 take the "e" parameter, becoming a synonym for
597 "toUPPER_utf8_safe". At that time every program that uses it
598 will have to be changed to successfully compile. In the
599 meantime, the first runtime call to "toUPPER_utf8" from each
600 call point in the program will raise a deprecation warning,
601 enabled by default. You can convert your program now to use
602 "toUPPER_utf8_safe", and avoid the warnings, and get an extra
603 measure of protection, or you can wait until v5.30, when you'll
604 be forced to add the "e" parameter.
605
606 UV toUPPER_utf8(U8* p, U8* s, STRLEN* lenp)
607
608 toUPPER_utf8_safe
609 Converts the first UTF-8 encoded character in the sequence
610 starting at "p" and extending no further than "e - 1" to its
611 uppercase version, and stores that in UTF-8 in "s", and its
612 length in bytes in "lenp". Note that the buffer pointed to by
613 "s" needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
614 uppercase version may be longer than the original character.
615
616 The first code point of the uppercased version is returned (but
617 note, as explained at the top of this section, that there may
618 be more).
619
620 The suffix "_safe" in the function's name indicates that it
621 will not attempt to read beyond "e - 1", provided that the
622 constraint "s < e" is true (this is asserted for in
623 "-DDEBUGGING" builds). If the UTF-8 for the input character is
624 malformed in some way, the program may croak, or the function
625 may return the REPLACEMENT CHARACTER, at the discretion of the
626 implementation, and subject to change in future releases.
627
628 UV toUPPER_utf8_safe(U8* p, U8* e, U8* s,
629 STRLEN* lenp)
630
631 toUPPER_uvchr
632 Converts the code point "cp" to its uppercase version, and
633 stores that in UTF-8 in "s", and its length in bytes in "lenp".
634 The code point is interpreted as native if less than 256;
635 otherwise as Unicode. Note that the buffer pointed to by "s"
636 needs to be at least "UTF8_MAXBYTES_CASE+1" bytes since the
637 uppercase version may be longer than the original character.
638
639 The first code point of the uppercased version is returned (but
640 note, as explained at the top of this section, that there may
641 be more.)
642
643 UV toUPPER_uvchr(UV cp, U8* s, STRLEN* lenp)
644
646 This section is about functions (really macros) that classify
647 characters into types, such as punctuation versus alphabetic, etc.
648 Most of these are analogous to regular expression character classes.
649 (See "POSIX Character Classes" in perlrecharclass.) There are several
650 variants for each class. (Not all macros have all variants; each item
651 below lists the ones valid for it.) None are affected by "use bytes",
652 and only the ones with "LC" in the name are affected by the current
653 locale.
654
655 The base function, e.g., "isALPHA()", takes an octet (either a "char"
656 or a "U8") as input and returns a boolean as to whether or not the
657 character represented by that octet is (or on non-ASCII platforms,
658 corresponds to) an ASCII character in the named class based on
659 platform, Unicode, and Perl rules. If the input is a number that
660 doesn't fit in an octet, FALSE is returned.
661
662 Variant "isFOO_A" (e.g., "isALPHA_A()") is identical to the base
663 function with no suffix "_A". This variant is used to emphasize by its
664 name that only ASCII-range characters can return TRUE.
665
666 Variant "isFOO_L1" imposes the Latin-1 (or EBCDIC equivalent) character
667 set onto the platform. That is, the code points that are ASCII are
668 unaffected, since ASCII is a subset of Latin-1. But the non-ASCII code
669 points are treated as if they are Latin-1 characters. For example,
670 "isWORDCHAR_L1()" will return true when called with the code point
671 0xDF, which is a word character in both ASCII and EBCDIC (though it
672 represents different characters in each).
673
674 Variant "isFOO_uvchr" is like the "isFOO_L1" variant, but accepts any
675 UV code point as input. If the code point is larger than 255, Unicode
676 rules are used to determine if it is in the character class. For
677 example, "isWORDCHAR_uvchr(0x100)" returns TRUE, since 0x100 is LATIN
678 CAPITAL LETTER A WITH MACRON in Unicode, and is a word character.
679
680 Variant "isFOO_utf8_safe" is like "isFOO_uvchr", but is used for UTF-8
681 encoded strings. Each call classifies one character, even if the
682 string contains many. This variant takes two parameters. The first,
683 "p", is a pointer to the first byte of the character to be classified.
684 (Recall that it may take more than one byte to represent a character in
685 UTF-8 strings.) The second parameter, "e", points to anywhere in the
686 string beyond the first character, up to one byte past the end of the
687 entire string. The suffix "_safe" in the function's name indicates
688 that it will not attempt to read beyond "e - 1", provided that the
689 constraint "s < e" is true (this is asserted for in "-DDEBUGGING"
690 builds). If the UTF-8 for the input character is malformed in some
691 way, the program may croak, or the function may return FALSE, at the
692 discretion of the implementation, and subject to change in future
693 releases.
694
695 Variant "isFOO_utf8" is like "isFOO_utf8_safe", but takes just a single
696 parameter, "p", which has the same meaning as the corresponding
697 parameter does in "isFOO_utf8_safe". The function therefore can't
698 check if it is reading beyond the end of the string. Starting in Perl
699 v5.30, it will take a second parameter, becoming a synonym for
700 "isFOO_utf8_safe". At that time every program that uses it will have
701 to be changed to successfully compile. In the meantime, the first
702 runtime call to "isFOO_utf8" from each call point in the program will
703 raise a deprecation warning, enabled by default. You can convert your
704 program now to use "isFOO_utf8_safe", and avoid the warnings, and get
705 an extra measure of protection, or you can wait until v5.30, when
706 you'll be forced to add the "e" parameter.
707
708 Variant "isFOO_LC" is like the "isFOO_A" and "isFOO_L1" variants, but
709 the result is based on the current locale, which is what "LC" in the
710 name stands for. If Perl can determine that the current locale is a
711 UTF-8 locale, it uses the published Unicode rules; otherwise, it uses
712 the C library function that gives the named classification. For
713 example, "isDIGIT_LC()" when not in a UTF-8 locale returns the result
714 of calling "isdigit()". FALSE is always returned if the input won't
715 fit into an octet. On some platforms where the C library function is
716 known to be defective, Perl changes its result to follow the POSIX
717 standard's rules.
718
719 Variant "isFOO_LC_uvchr" is like "isFOO_LC", but is defined on any UV.
720 It returns the same as "isFOO_LC" for input code points less than 256,
721 and returns the hard-coded, not-affected-by-locale, Unicode results for
722 larger ones.
723
724 Variant "isFOO_LC_utf8_safe" is like "isFOO_LC_uvchr", but is used for
725 UTF-8 encoded strings. Each call classifies one character, even if the
726 string contains many. This variant takes two parameters. The first,
727 "p", is a pointer to the first byte of the character to be classified.
728 (Recall that it may take more than one byte to represent a character in
729 UTF-8 strings.) The second parameter, "e", points to anywhere in the
730 string beyond the first character, up to one byte past the end of the
731 entire string. The suffix "_safe" in the function's name indicates
732 that it will not attempt to read beyond "e - 1", provided that the
733 constraint "s < e" is true (this is asserted for in "-DDEBUGGING"
734 builds). If the UTF-8 for the input character is malformed in some
735 way, the program may croak, or the function may return FALSE, at the
736 discretion of the implementation, and subject to change in future
737 releases.
738
739 Variant "isFOO_LC_utf8" is like "isFOO_LC_utf8_safe", but takes just a
740 single parameter, "p", which has the same meaning as the corresponding
741 parameter does in "isFOO_LC_utf8_safe". The function therefore can't
742 check if it is reading beyond the end of the string. Starting in Perl
743 v5.30, it will take a second parameter, becoming a synonym for
744 "isFOO_LC_utf8_safe". At that time every program that uses it will
745 have to be changed to successfully compile. In the meantime, the first
746 runtime call to "isFOO_LC_utf8" from each call point in the program
747 will raise a deprecation warning, enabled by default. You can convert
748 your program now to use "isFOO_LC_utf8_safe", and avoid the warnings,
749 and get an extra measure of protection, or you can wait until v5.30,
750 when you'll be forced to add the "e" parameter.
751
752 isALPHA Returns a boolean indicating whether the specified character is
753 an alphabetic character, analogous to "m/[[:alpha:]]/". See
754 the top of this section for an explanation of variants
755 "isALPHA_A", "isALPHA_L1", "isALPHA_uvchr",
756 "isALPHA_utf8_safe", "isALPHA_LC", "isALPHA_LC_uvchr", and
757 "isALPHA_LC_utf8_safe".
758
759 bool isALPHA(char ch)
760
761 isALPHANUMERIC
762 Returns a boolean indicating whether the specified character is
763 a either an alphabetic character or decimal digit, analogous to
764 "m/[[:alnum:]]/". See the top of this section for an
765 explanation of variants "isALPHANUMERIC_A",
766 "isALPHANUMERIC_L1", "isALPHANUMERIC_uvchr",
767 "isALPHANUMERIC_utf8_safe", "isALPHANUMERIC_LC",
768 "isALPHANUMERIC_LC_uvchr", and "isALPHANUMERIC_LC_utf8_safe".
769
770 bool isALPHANUMERIC(char ch)
771
772 isASCII Returns a boolean indicating whether the specified character is
773 one of the 128 characters in the ASCII character set, analogous
774 to "m/[[:ascii:]]/". On non-ASCII platforms, it returns TRUE
775 iff this character corresponds to an ASCII character. Variants
776 "isASCII_A()" and "isASCII_L1()" are identical to "isASCII()".
777 See the top of this section for an explanation of variants
778 "isASCII_uvchr", "isASCII_utf8_safe", "isASCII_LC",
779 "isASCII_LC_uvchr", and "isASCII_LC_utf8_safe". Note, however,
780 that some platforms do not have the C library routine
781 "isascii()". In these cases, the variants whose names contain
782 "LC" are the same as the corresponding ones without.
783
784 Also note, that because all ASCII characters are UTF-8
785 invariant (meaning they have the exact same representation
786 (always a single byte) whether encoded in UTF-8 or not),
787 "isASCII" will give the correct results when called with any
788 byte in any string encoded or not in UTF-8. And similarly
789 "isASCII_utf8_safe" will work properly on any string encoded or
790 not in UTF-8.
791
792 bool isASCII(char ch)
793
794 isBLANK Returns a boolean indicating whether the specified character is
795 a character considered to be a blank, analogous to
796 "m/[[:blank:]]/". See the top of this section for an
797 explanation of variants "isBLANK_A", "isBLANK_L1",
798 "isBLANK_uvchr", "isBLANK_utf8_safe", "isBLANK_LC",
799 "isBLANK_LC_uvchr", and "isBLANK_LC_utf8_safe". Note, however,
800 that some platforms do not have the C library routine
801 "isblank()". In these cases, the variants whose names contain
802 "LC" are the same as the corresponding ones without.
803
804 bool isBLANK(char ch)
805
806 isCNTRL Returns a boolean indicating whether the specified character is
807 a control character, analogous to "m/[[:cntrl:]]/". See the
808 top of this section for an explanation of variants "isCNTRL_A",
809 "isCNTRL_L1", "isCNTRL_uvchr", "isCNTRL_utf8_safe",
810 "isCNTRL_LC", "isCNTRL_LC_uvchr", and "isCNTRL_LC_utf8_safe" On
811 EBCDIC platforms, you almost always want to use the
812 "isCNTRL_L1" variant.
813
814 bool isCNTRL(char ch)
815
816 isDIGIT Returns a boolean indicating whether the specified character is
817 a digit, analogous to "m/[[:digit:]]/". Variants "isDIGIT_A"
818 and "isDIGIT_L1" are identical to "isDIGIT". See the top of
819 this section for an explanation of variants "isDIGIT_uvchr",
820 "isDIGIT_utf8_safe", "isDIGIT_LC", "isDIGIT_LC_uvchr", and
821 "isDIGIT_LC_utf8_safe".
822
823 bool isDIGIT(char ch)
824
825 isGRAPH Returns a boolean indicating whether the specified character is
826 a graphic character, analogous to "m/[[:graph:]]/". See the
827 top of this section for an explanation of variants "isGRAPH_A",
828 "isGRAPH_L1", "isGRAPH_uvchr", "isGRAPH_utf8_safe",
829 "isGRAPH_LC", "isGRAPH_LC_uvchr", and "isGRAPH_LC_utf8_safe".
830
831 bool isGRAPH(char ch)
832
833 isIDCONT
834 Returns a boolean indicating whether the specified character
835 can be the second or succeeding character of an identifier.
836 This is very close to, but not quite the same as the official
837 Unicode property "XID_Continue". The difference is that this
838 returns true only if the input character also matches
839 "isWORDCHAR". See the top of this section for an explanation
840 of variants "isIDCONT_A", "isIDCONT_L1", "isIDCONT_uvchr",
841 "isIDCONT_utf8_safe", "isIDCONT_LC", "isIDCONT_LC_uvchr", and
842 "isIDCONT_LC_utf8_safe".
843
844 bool isIDCONT(char ch)
845
846 isIDFIRST
847 Returns a boolean indicating whether the specified character
848 can be the first character of an identifier. This is very
849 close to, but not quite the same as the official Unicode
850 property "XID_Start". The difference is that this returns true
851 only if the input character also matches "isWORDCHAR". See the
852 top of this section for an explanation of variants
853 "isIDFIRST_A", "isIDFIRST_L1", "isIDFIRST_uvchr",
854 "isIDFIRST_utf8_safe", "isIDFIRST_LC", "isIDFIRST_LC_uvchr",
855 and "isIDFIRST_LC_utf8_safe".
856
857 bool isIDFIRST(char ch)
858
859 isLOWER Returns a boolean indicating whether the specified character is
860 a lowercase character, analogous to "m/[[:lower:]]/". See the
861 top of this section for an explanation of variants "isLOWER_A",
862 "isLOWER_L1", "isLOWER_uvchr", "isLOWER_utf8_safe",
863 "isLOWER_LC", "isLOWER_LC_uvchr", and "isLOWER_LC_utf8_safe".
864
865 bool isLOWER(char ch)
866
867 isOCTAL Returns a boolean indicating whether the specified character is
868 an octal digit, [0-7]. The only two variants are "isOCTAL_A"
869 and "isOCTAL_L1"; each is identical to "isOCTAL".
870
871 bool isOCTAL(char ch)
872
873 isPRINT Returns a boolean indicating whether the specified character is
874 a printable character, analogous to "m/[[:print:]]/". See the
875 top of this section for an explanation of variants "isPRINT_A",
876 "isPRINT_L1", "isPRINT_uvchr", "isPRINT_utf8_safe",
877 "isPRINT_LC", "isPRINT_LC_uvchr", and "isPRINT_LC_utf8_safe".
878
879 bool isPRINT(char ch)
880
881 isPSXSPC
882 (short for Posix Space) Starting in 5.18, this is identical in
883 all its forms to the corresponding "isSPACE()" macros. The
884 locale forms of this macro are identical to their corresponding
885 "isSPACE()" forms in all Perl releases. In releases prior to
886 5.18, the non-locale forms differ from their "isSPACE()" forms
887 only in that the "isSPACE()" forms don't match a Vertical Tab,
888 and the "isPSXSPC()" forms do. Otherwise they are identical.
889 Thus this macro is analogous to what "m/[[:space:]]/" matches
890 in a regular expression. See the top of this section for an
891 explanation of variants "isPSXSPC_A", "isPSXSPC_L1",
892 "isPSXSPC_uvchr", "isPSXSPC_utf8_safe", "isPSXSPC_LC",
893 "isPSXSPC_LC_uvchr", and "isPSXSPC_LC_utf8_safe".
894
895 bool isPSXSPC(char ch)
896
897 isPUNCT Returns a boolean indicating whether the specified character is
898 a punctuation character, analogous to "m/[[:punct:]]/". Note
899 that the definition of what is punctuation isn't as
900 straightforward as one might desire. See "POSIX Character
901 Classes" in perlrecharclass for details. See the top of this
902 section for an explanation of variants "isPUNCT_A",
903 "isPUNCT_L1", "isPUNCT_uvchr", "isPUNCT_utf8_safe",
904 "isPUNCT_LC", "isPUNCT_LC_uvchr", and "isPUNCT_LC_utf8_safe".
905
906 bool isPUNCT(char ch)
907
908 isSPACE Returns a boolean indicating whether the specified character is
909 a whitespace character. This is analogous to what "m/\s/"
910 matches in a regular expression. Starting in Perl 5.18 this
911 also matches what "m/[[:space:]]/" does. Prior to 5.18, only
912 the locale forms of this macro (the ones with "LC" in their
913 names) matched precisely what "m/[[:space:]]/" does. In those
914 releases, the only difference, in the non-locale variants, was
915 that "isSPACE()" did not match a vertical tab. (See "isPSXSPC"
916 for a macro that matches a vertical tab in all releases.) See
917 the top of this section for an explanation of variants
918 "isSPACE_A", "isSPACE_L1", "isSPACE_uvchr",
919 "isSPACE_utf8_safe", "isSPACE_LC", "isSPACE_LC_uvchr", and
920 "isSPACE_LC_utf8_safe".
921
922 bool isSPACE(char ch)
923
924 isUPPER Returns a boolean indicating whether the specified character is
925 an uppercase character, analogous to "m/[[:upper:]]/". See the
926 top of this section for an explanation of variants "isUPPER_A",
927 "isUPPER_L1", "isUPPER_uvchr", "isUPPER_utf8_safe",
928 "isUPPER_LC", "isUPPER_LC_uvchr", and "isUPPER_LC_utf8_safe".
929
930 bool isUPPER(char ch)
931
932 isWORDCHAR
933 Returns a boolean indicating whether the specified character is
934 a character that is a word character, analogous to what "m/\w/"
935 and "m/[[:word:]]/" match in a regular expression. A word
936 character is an alphabetic character, a decimal digit, a
937 connecting punctuation character (such as an underscore), or a
938 "mark" character that attaches to one of those (like some sort
939 of accent). "isALNUM()" is a synonym provided for backward
940 compatibility, even though a word character includes more than
941 the standard C language meaning of alphanumeric. See the top
942 of this section for an explanation of variants "isWORDCHAR_A",
943 "isWORDCHAR_L1", "isWORDCHAR_uvchr", and
944 "isWORDCHAR_utf8_safe". "isWORDCHAR_LC",
945 "isWORDCHAR_LC_uvchr", and "isWORDCHAR_LC_utf8_safe" are also
946 as described there, but additionally include the platform's
947 native underscore.
948
949 bool isWORDCHAR(char ch)
950
951 isXDIGIT
952 Returns a boolean indicating whether the specified character is
953 a hexadecimal digit. In the ASCII range these are
954 "[0-9A-Fa-f]". Variants "isXDIGIT_A()" and "isXDIGIT_L1()" are
955 identical to "isXDIGIT()". See the top of this section for an
956 explanation of variants "isXDIGIT_uvchr", "isXDIGIT_utf8_safe",
957 "isXDIGIT_LC", "isXDIGIT_LC_uvchr", and
958 "isXDIGIT_LC_utf8_safe".
959
960 bool isXDIGIT(char ch)
961
963 perl_clone
964 Create and return a new interpreter by cloning the current one.
965
966 "perl_clone" takes these flags as parameters:
967
968 "CLONEf_COPY_STACKS" - is used to, well, copy the stacks also,
969 without it we only clone the data and zero the stacks, with it
970 we copy the stacks and the new perl interpreter is ready to run
971 at the exact same point as the previous one. The pseudo-fork
972 code uses "COPY_STACKS" while the threads->create doesn't.
973
974 "CLONEf_KEEP_PTR_TABLE" - "perl_clone" keeps a ptr_table with
975 the pointer of the old variable as a key and the new variable
976 as a value, this allows it to check if something has been
977 cloned and not clone it again but rather just use the value and
978 increase the refcount. If "KEEP_PTR_TABLE" is not set then
979 "perl_clone" will kill the ptr_table using the function
980 "ptr_table_free(PL_ptr_table); PL_ptr_table = NULL;", reason to
981 keep it around is if you want to dup some of your own variable
982 who are outside the graph perl scans, an example of this code
983 is in threads.xs create.
984
985 "CLONEf_CLONE_HOST" - This is a win32 thing, it is ignored on
986 unix, it tells perls win32host code (which is c++) to clone
987 itself, this is needed on win32 if you want to run two threads
988 at the same time, if you just want to do some stuff in a
989 separate perl interpreter and then throw it away and return to
990 the original one, you don't need to do anything.
991
992 PerlInterpreter* perl_clone(
993 PerlInterpreter *proto_perl,
994 UV flags
995 )
996
998 BhkDISABLE
999 NOTE: this function is experimental and may change or be
1000 removed without notice.
1001
1002 Temporarily disable an entry in this BHK structure, by clearing
1003 the appropriate flag. "which" is a preprocessor token
1004 indicating which entry to disable.
1005
1006 void BhkDISABLE(BHK *hk, which)
1007
1008 BhkENABLE
1009 NOTE: this function is experimental and may change or be
1010 removed without notice.
1011
1012 Re-enable an entry in this BHK structure, by setting the
1013 appropriate flag. "which" is a preprocessor token indicating
1014 which entry to enable. This will assert (under -DDEBUGGING) if
1015 the entry doesn't contain a valid pointer.
1016
1017 void BhkENABLE(BHK *hk, which)
1018
1019 BhkENTRY_set
1020 NOTE: this function is experimental and may change or be
1021 removed without notice.
1022
1023 Set an entry in the BHK structure, and set the flags to
1024 indicate it is valid. "which" is a preprocessing token
1025 indicating which entry to set. The type of "ptr" depends on
1026 the entry.
1027
1028 void BhkENTRY_set(BHK *hk, which, void *ptr)
1029
1030 blockhook_register
1031 NOTE: this function is experimental and may change or be
1032 removed without notice.
1033
1034 Register a set of hooks to be called when the Perl lexical
1035 scope changes at compile time. See "Compile-time scope hooks"
1036 in perlguts.
1037
1038 NOTE: this function must be explicitly called as
1039 Perl_blockhook_register with an aTHX_ parameter.
1040
1041 void Perl_blockhook_register(pTHX_ BHK *hk)
1042
1044 cophh_2hv
1045 NOTE: this function is experimental and may change or be
1046 removed without notice.
1047
1048 Generates and returns a standard Perl hash representing the
1049 full set of key/value pairs in the cop hints hash "cophh".
1050 "flags" is currently unused and must be zero.
1051
1052 HV * cophh_2hv(const COPHH *cophh, U32 flags)
1053
1054 cophh_copy
1055 NOTE: this function is experimental and may change or be
1056 removed without notice.
1057
1058 Make and return a complete copy of the cop hints hash "cophh".
1059
1060 COPHH * cophh_copy(COPHH *cophh)
1061
1062 cophh_delete_pv
1063 NOTE: this function is experimental and may change or be
1064 removed without notice.
1065
1066 Like "cophh_delete_pvn", but takes a nul-terminated string
1067 instead of a string/length pair.
1068
1069 COPHH * cophh_delete_pv(const COPHH *cophh,
1070 const char *key, U32 hash,
1071 U32 flags)
1072
1073 cophh_delete_pvn
1074 NOTE: this function is experimental and may change or be
1075 removed without notice.
1076
1077 Delete a key and its associated value from the cop hints hash
1078 "cophh", and returns the modified hash. The returned hash
1079 pointer is in general not the same as the hash pointer that was
1080 passed in. The input hash is consumed by the function, and the
1081 pointer to it must not be subsequently used. Use "cophh_copy"
1082 if you need both hashes.
1083
1084 The key is specified by "keypv" and "keylen". If "flags" has
1085 the "COPHH_KEY_UTF8" bit set, the key octets are interpreted as
1086 UTF-8, otherwise they are interpreted as Latin-1. "hash" is a
1087 precomputed hash of the key string, or zero if it has not been
1088 precomputed.
1089
1090 COPHH * cophh_delete_pvn(COPHH *cophh,
1091 const char *keypv,
1092 STRLEN keylen, U32 hash,
1093 U32 flags)
1094
1095 cophh_delete_pvs
1096 NOTE: this function is experimental and may change or be
1097 removed without notice.
1098
1099 Like "cophh_delete_pvn", but takes a literal string instead of
1100 a string/length pair, and no precomputed hash.
1101
1102 COPHH * cophh_delete_pvs(const COPHH *cophh,
1103 "literal string" key,
1104 U32 flags)
1105
1106 cophh_delete_sv
1107 NOTE: this function is experimental and may change or be
1108 removed without notice.
1109
1110 Like "cophh_delete_pvn", but takes a Perl scalar instead of a
1111 string/length pair.
1112
1113 COPHH * cophh_delete_sv(const COPHH *cophh, SV *key,
1114 U32 hash, U32 flags)
1115
1116 cophh_fetch_pv
1117 NOTE: this function is experimental and may change or be
1118 removed without notice.
1119
1120 Like "cophh_fetch_pvn", but takes a nul-terminated string
1121 instead of a string/length pair.
1122
1123 SV * cophh_fetch_pv(const COPHH *cophh,
1124 const char *key, U32 hash,
1125 U32 flags)
1126
1127 cophh_fetch_pvn
1128 NOTE: this function is experimental and may change or be
1129 removed without notice.
1130
1131 Look up the entry in the cop hints hash "cophh" with the key
1132 specified by "keypv" and "keylen". If "flags" has the
1133 "COPHH_KEY_UTF8" bit set, the key octets are interpreted as
1134 UTF-8, otherwise they are interpreted as Latin-1. "hash" is a
1135 precomputed hash of the key string, or zero if it has not been
1136 precomputed. Returns a mortal scalar copy of the value
1137 associated with the key, or &PL_sv_placeholder if there is no
1138 value associated with the key.
1139
1140 SV * cophh_fetch_pvn(const COPHH *cophh,
1141 const char *keypv,
1142 STRLEN keylen, U32 hash,
1143 U32 flags)
1144
1145 cophh_fetch_pvs
1146 NOTE: this function is experimental and may change or be
1147 removed without notice.
1148
1149 Like "cophh_fetch_pvn", but takes a literal string instead of a
1150 string/length pair, and no precomputed hash.
1151
1152 SV * cophh_fetch_pvs(const COPHH *cophh,
1153 "literal string" key, U32 flags)
1154
1155 cophh_fetch_sv
1156 NOTE: this function is experimental and may change or be
1157 removed without notice.
1158
1159 Like "cophh_fetch_pvn", but takes a Perl scalar instead of a
1160 string/length pair.
1161
1162 SV * cophh_fetch_sv(const COPHH *cophh, SV *key,
1163 U32 hash, U32 flags)
1164
1165 cophh_free
1166 NOTE: this function is experimental and may change or be
1167 removed without notice.
1168
1169 Discard the cop hints hash "cophh", freeing all resources
1170 associated with it.
1171
1172 void cophh_free(COPHH *cophh)
1173
1174 cophh_new_empty
1175 NOTE: this function is experimental and may change or be
1176 removed without notice.
1177
1178 Generate and return a fresh cop hints hash containing no
1179 entries.
1180
1181 COPHH * cophh_new_empty()
1182
1183 cophh_store_pv
1184 NOTE: this function is experimental and may change or be
1185 removed without notice.
1186
1187 Like "cophh_store_pvn", but takes a nul-terminated string
1188 instead of a string/length pair.
1189
1190 COPHH * cophh_store_pv(const COPHH *cophh,
1191 const char *key, U32 hash,
1192 SV *value, U32 flags)
1193
1194 cophh_store_pvn
1195 NOTE: this function is experimental and may change or be
1196 removed without notice.
1197
1198 Stores a value, associated with a key, in the cop hints hash
1199 "cophh", and returns the modified hash. The returned hash
1200 pointer is in general not the same as the hash pointer that was
1201 passed in. The input hash is consumed by the function, and the
1202 pointer to it must not be subsequently used. Use "cophh_copy"
1203 if you need both hashes.
1204
1205 The key is specified by "keypv" and "keylen". If "flags" has
1206 the "COPHH_KEY_UTF8" bit set, the key octets are interpreted as
1207 UTF-8, otherwise they are interpreted as Latin-1. "hash" is a
1208 precomputed hash of the key string, or zero if it has not been
1209 precomputed.
1210
1211 "value" is the scalar value to store for this key. "value" is
1212 copied by this function, which thus does not take ownership of
1213 any reference to it, and later changes to the scalar will not
1214 be reflected in the value visible in the cop hints hash.
1215 Complex types of scalar will not be stored with referential
1216 integrity, but will be coerced to strings.
1217
1218 COPHH * cophh_store_pvn(COPHH *cophh, const char *keypv,
1219 STRLEN keylen, U32 hash,
1220 SV *value, U32 flags)
1221
1222 cophh_store_pvs
1223 NOTE: this function is experimental and may change or be
1224 removed without notice.
1225
1226 Like "cophh_store_pvn", but takes a literal string instead of a
1227 string/length pair, and no precomputed hash.
1228
1229 COPHH * cophh_store_pvs(const COPHH *cophh,
1230 "literal string" key, SV *value,
1231 U32 flags)
1232
1233 cophh_store_sv
1234 NOTE: this function is experimental and may change or be
1235 removed without notice.
1236
1237 Like "cophh_store_pvn", but takes a Perl scalar instead of a
1238 string/length pair.
1239
1240 COPHH * cophh_store_sv(const COPHH *cophh, SV *key,
1241 U32 hash, SV *value, U32 flags)
1242
1244 cop_hints_2hv
1245 Generates and returns a standard Perl hash representing the
1246 full set of hint entries in the cop "cop". "flags" is
1247 currently unused and must be zero.
1248
1249 HV * cop_hints_2hv(const COP *cop, U32 flags)
1250
1251 cop_hints_fetch_pv
1252 Like "cop_hints_fetch_pvn", but takes a nul-terminated string
1253 instead of a string/length pair.
1254
1255 SV * cop_hints_fetch_pv(const COP *cop,
1256 const char *key, U32 hash,
1257 U32 flags)
1258
1259 cop_hints_fetch_pvn
1260 Look up the hint entry in the cop "cop" with the key specified
1261 by "keypv" and "keylen". If "flags" has the "COPHH_KEY_UTF8"
1262 bit set, the key octets are interpreted as UTF-8, otherwise
1263 they are interpreted as Latin-1. "hash" is a precomputed hash
1264 of the key string, or zero if it has not been precomputed.
1265 Returns a mortal scalar copy of the value associated with the
1266 key, or &PL_sv_placeholder if there is no value associated with
1267 the key.
1268
1269 SV * cop_hints_fetch_pvn(const COP *cop,
1270 const char *keypv,
1271 STRLEN keylen, U32 hash,
1272 U32 flags)
1273
1274 cop_hints_fetch_pvs
1275 Like "cop_hints_fetch_pvn", but takes a literal string instead
1276 of a string/length pair, and no precomputed hash.
1277
1278 SV * cop_hints_fetch_pvs(const COP *cop,
1279 "literal string" key,
1280 U32 flags)
1281
1282 cop_hints_fetch_sv
1283 Like "cop_hints_fetch_pvn", but takes a Perl scalar instead of
1284 a string/length pair.
1285
1286 SV * cop_hints_fetch_sv(const COP *cop, SV *key,
1287 U32 hash, U32 flags)
1288
1290 custom_op_register
1291 Register a custom op. See "Custom Operators" in perlguts.
1292
1293 NOTE: this function must be explicitly called as
1294 Perl_custom_op_register with an aTHX_ parameter.
1295
1296 void Perl_custom_op_register(pTHX_
1297 Perl_ppaddr_t ppaddr,
1298 const XOP *xop)
1299
1300 custom_op_xop
1301 Return the XOP structure for a given custom op. This macro
1302 should be considered internal to "OP_NAME" and the other access
1303 macros: use them instead. This macro does call a function.
1304 Prior to 5.19.6, this was implemented as a function.
1305
1306 NOTE: this function must be explicitly called as
1307 Perl_custom_op_xop with an aTHX_ parameter.
1308
1309 const XOP * Perl_custom_op_xop(pTHX_ const OP *o)
1310
1311 XopDISABLE
1312 Temporarily disable a member of the XOP, by clearing the
1313 appropriate flag.
1314
1315 void XopDISABLE(XOP *xop, which)
1316
1317 XopENABLE
1318 Reenable a member of the XOP which has been disabled.
1319
1320 void XopENABLE(XOP *xop, which)
1321
1322 XopENTRY
1323 Return a member of the XOP structure. "which" is a cpp token
1324 indicating which entry to return. If the member is not set
1325 this will return a default value. The return type depends on
1326 "which". This macro evaluates its arguments more than once.
1327 If you are using "Perl_custom_op_xop" to retreive a "XOP *"
1328 from a "OP *", use the more efficient "XopENTRYCUSTOM" instead.
1329
1330 XopENTRY(XOP *xop, which)
1331
1332 XopENTRYCUSTOM
1333 Exactly like "XopENTRY(XopENTRY(Perl_custom_op_xop(aTHX_ o),
1334 which)" but more efficient. The "which" parameter is identical
1335 to "XopENTRY".
1336
1337 XopENTRYCUSTOM(const OP *o, which)
1338
1339 XopENTRY_set
1340 Set a member of the XOP structure. "which" is a cpp token
1341 indicating which entry to set. See "Custom Operators" in
1342 perlguts for details about the available members and how they
1343 are used. This macro evaluates its argument more than once.
1344
1345 void XopENTRY_set(XOP *xop, which, value)
1346
1347 XopFLAGS
1348 Return the XOP's flags.
1349
1350 U32 XopFLAGS(XOP *xop)
1351
1353 This section documents functions to manipulate CVs which are code-
1354 values, or subroutines. For more information, see perlguts.
1355
1356 caller_cx
1357 The XSUB-writer's equivalent of caller(). The returned
1358 "PERL_CONTEXT" structure can be interrogated to find all the
1359 information returned to Perl by "caller". Note that XSUBs
1360 don't get a stack frame, so "caller_cx(0, NULL)" will return
1361 information for the immediately-surrounding Perl code.
1362
1363 This function skips over the automatic calls to &DB::sub made
1364 on the behalf of the debugger. If the stack frame requested
1365 was a sub called by "DB::sub", the return value will be the
1366 frame for the call to "DB::sub", since that has the correct
1367 line number/etc. for the call site. If dbcxp is non-"NULL", it
1368 will be set to a pointer to the frame for the sub call itself.
1369
1370 const PERL_CONTEXT * caller_cx(
1371 I32 level,
1372 const PERL_CONTEXT **dbcxp
1373 )
1374
1375 CvSTASH Returns the stash of the CV. A stash is the symbol table hash,
1376 containing the package-scoped variables in the package where
1377 the subroutine was defined. For more information, see
1378 perlguts.
1379
1380 This also has a special use with XS AUTOLOAD subs. See
1381 "Autoloading with XSUBs" in perlguts.
1382
1383 HV* CvSTASH(CV* cv)
1384
1385 find_runcv
1386 Locate the CV corresponding to the currently executing sub or
1387 eval. If "db_seqp" is non_null, skip CVs that are in the DB
1388 package and populate *db_seqp with the cop sequence number at
1389 the point that the DB:: code was entered. (This allows
1390 debuggers to eval in the scope of the breakpoint rather than in
1391 the scope of the debugger itself.)
1392
1393 CV* find_runcv(U32 *db_seqp)
1394
1395 get_cv Uses "strlen" to get the length of "name", then calls
1396 "get_cvn_flags".
1397
1398 NOTE: the perl_ form of this function is deprecated.
1399
1400 CV* get_cv(const char* name, I32 flags)
1401
1402 get_cvn_flags
1403 Returns the CV of the specified Perl subroutine. "flags" are
1404 passed to "gv_fetchpvn_flags". If "GV_ADD" is set and the Perl
1405 subroutine does not exist then it will be declared (which has
1406 the same effect as saying "sub name;"). If "GV_ADD" is not set
1407 and the subroutine does not exist then NULL is returned.
1408
1409 NOTE: the perl_ form of this function is deprecated.
1410
1411 CV* get_cvn_flags(const char* name, STRLEN len,
1412 I32 flags)
1413
1415 ax Variable which is setup by "xsubpp" to indicate the stack base
1416 offset, used by the "ST", "XSprePUSH" and "XSRETURN" macros.
1417 The "dMARK" macro must be called prior to setup the "MARK"
1418 variable.
1419
1420 I32 ax
1421
1422 CLASS Variable which is setup by "xsubpp" to indicate the class name
1423 for a C++ XS constructor. This is always a "char*". See
1424 "THIS".
1425
1426 char* CLASS
1427
1428 dAX Sets up the "ax" variable. This is usually handled
1429 automatically by "xsubpp" by calling "dXSARGS".
1430
1431 dAX;
1432
1433 dAXMARK Sets up the "ax" variable and stack marker variable "mark".
1434 This is usually handled automatically by "xsubpp" by calling
1435 "dXSARGS".
1436
1437 dAXMARK;
1438
1439 dITEMS Sets up the "items" variable. This is usually handled
1440 automatically by "xsubpp" by calling "dXSARGS".
1441
1442 dITEMS;
1443
1444 dUNDERBAR
1445 Sets up any variable needed by the "UNDERBAR" macro. It used
1446 to define "padoff_du", but it is currently a noop. However, it
1447 is strongly advised to still use it for ensuring past and
1448 future compatibility.
1449
1450 dUNDERBAR;
1451
1452 dXSARGS Sets up stack and mark pointers for an XSUB, calling "dSP" and
1453 "dMARK". Sets up the "ax" and "items" variables by calling
1454 "dAX" and "dITEMS". This is usually handled automatically by
1455 "xsubpp".
1456
1457 dXSARGS;
1458
1459 dXSI32 Sets up the "ix" variable for an XSUB which has aliases. This
1460 is usually handled automatically by "xsubpp".
1461
1462 dXSI32;
1463
1464 items Variable which is setup by "xsubpp" to indicate the number of
1465 items on the stack. See "Variable-length Parameter Lists" in
1466 perlxs.
1467
1468 I32 items
1469
1470 ix Variable which is setup by "xsubpp" to indicate which of an
1471 XSUB's aliases was used to invoke it. See "The ALIAS: Keyword"
1472 in perlxs.
1473
1474 I32 ix
1475
1476 RETVAL Variable which is setup by "xsubpp" to hold the return value
1477 for an XSUB. This is always the proper type for the XSUB. See
1478 "The RETVAL Variable" in perlxs.
1479
1480 (whatever) RETVAL
1481
1482 ST Used to access elements on the XSUB's stack.
1483
1484 SV* ST(int ix)
1485
1486 THIS Variable which is setup by "xsubpp" to designate the object in
1487 a C++ XSUB. This is always the proper type for the C++ object.
1488 See "CLASS" and "Using XS With C++" in perlxs.
1489
1490 (whatever) THIS
1491
1492 UNDERBAR
1493 The SV* corresponding to the $_ variable. Works even if there
1494 is a lexical $_ in scope.
1495
1496 XS Macro to declare an XSUB and its C parameter list. This is
1497 handled by "xsubpp". It is the same as using the more explicit
1498 "XS_EXTERNAL" macro.
1499
1500 XS_EXTERNAL
1501 Macro to declare an XSUB and its C parameter list explicitly
1502 exporting the symbols.
1503
1504 XS_INTERNAL
1505 Macro to declare an XSUB and its C parameter list without
1506 exporting the symbols. This is handled by "xsubpp" and
1507 generally preferable over exporting the XSUB symbols
1508 unnecessarily.
1509
1511 dump_all
1512 Dumps the entire optree of the current program starting at
1513 "PL_main_root" to "STDERR". Also dumps the optrees for all
1514 visible subroutines in "PL_defstash".
1515
1516 void dump_all()
1517
1518 dump_packsubs
1519 Dumps the optrees for all visible subroutines in "stash".
1520
1521 void dump_packsubs(const HV* stash)
1522
1523 op_class
1524 Given an op, determine what type of struct it has been
1525 allocated as. Returns one of the OPclass enums, such as
1526 OPclass_LISTOP.
1527
1528 OPclass op_class(const OP *o)
1529
1530 op_dump Dumps the optree starting at OP "o" to "STDERR".
1531
1532 void op_dump(const OP *o)
1533
1534 sv_dump Dumps the contents of an SV to the "STDERR" filehandle.
1535
1536 For an example of its output, see Devel::Peek.
1537
1538 void sv_dump(SV* sv)
1539
1541 pv_display
1542 Similar to
1543
1544 pv_escape(dsv,pv,cur,pvlim,PERL_PV_ESCAPE_QUOTE);
1545
1546 except that an additional "\0" will be appended to the string
1547 when len > cur and pv[cur] is "\0".
1548
1549 Note that the final string may be up to 7 chars longer than
1550 pvlim.
1551
1552 char* pv_display(SV *dsv, const char *pv, STRLEN cur,
1553 STRLEN len, STRLEN pvlim)
1554
1555 pv_escape
1556 Escapes at most the first "count" chars of "pv" and puts the
1557 results into "dsv" such that the size of the escaped string
1558 will not exceed "max" chars and will not contain any incomplete
1559 escape sequences. The number of bytes escaped will be returned
1560 in the "STRLEN *escaped" parameter if it is not null. When the
1561 "dsv" parameter is null no escaping actually occurs, but the
1562 number of bytes that would be escaped were it not null will be
1563 calculated.
1564
1565 If flags contains "PERL_PV_ESCAPE_QUOTE" then any double quotes
1566 in the string will also be escaped.
1567
1568 Normally the SV will be cleared before the escaped string is
1569 prepared, but when "PERL_PV_ESCAPE_NOCLEAR" is set this will
1570 not occur.
1571
1572 If "PERL_PV_ESCAPE_UNI" is set then the input string is treated
1573 as UTF-8 if "PERL_PV_ESCAPE_UNI_DETECT" is set then the input
1574 string is scanned using "is_utf8_string()" to determine if it
1575 is UTF-8.
1576
1577 If "PERL_PV_ESCAPE_ALL" is set then all input chars will be
1578 output using "\x01F1" style escapes, otherwise if
1579 "PERL_PV_ESCAPE_NONASCII" is set, only non-ASCII chars will be
1580 escaped using this style; otherwise, only chars above 255 will
1581 be so escaped; other non printable chars will use octal or
1582 common escaped patterns like "\n". Otherwise, if
1583 "PERL_PV_ESCAPE_NOBACKSLASH" then all chars below 255 will be
1584 treated as printable and will be output as literals.
1585
1586 If "PERL_PV_ESCAPE_FIRSTCHAR" is set then only the first char
1587 of the string will be escaped, regardless of max. If the
1588 output is to be in hex, then it will be returned as a plain hex
1589 sequence. Thus the output will either be a single char, an
1590 octal escape sequence, a special escape like "\n" or a hex
1591 value.
1592
1593 If "PERL_PV_ESCAPE_RE" is set then the escape char used will be
1594 a "%" and not a "\\". This is because regexes very often
1595 contain backslashed sequences, whereas "%" is not a
1596 particularly common character in patterns.
1597
1598 Returns a pointer to the escaped text as held by "dsv".
1599
1600 char* pv_escape(SV *dsv, char const * const str,
1601 const STRLEN count, const STRLEN max,
1602 STRLEN * const escaped,
1603 const U32 flags)
1604
1605 pv_pretty
1606 Converts a string into something presentable, handling escaping
1607 via "pv_escape()" and supporting quoting and ellipses.
1608
1609 If the "PERL_PV_PRETTY_QUOTE" flag is set then the result will
1610 be double quoted with any double quotes in the string escaped.
1611 Otherwise if the "PERL_PV_PRETTY_LTGT" flag is set then the
1612 result be wrapped in angle brackets.
1613
1614 If the "PERL_PV_PRETTY_ELLIPSES" flag is set and not all
1615 characters in string were output then an ellipsis "..." will be
1616 appended to the string. Note that this happens AFTER it has
1617 been quoted.
1618
1619 If "start_color" is non-null then it will be inserted after the
1620 opening quote (if there is one) but before the escaped text.
1621 If "end_color" is non-null then it will be inserted after the
1622 escaped text but before any quotes or ellipses.
1623
1624 Returns a pointer to the prettified text as held by "dsv".
1625
1626 char* pv_pretty(SV *dsv, char const * const str,
1627 const STRLEN count, const STRLEN max,
1628 char const * const start_color,
1629 char const * const end_color,
1630 const U32 flags)
1631
1633 cv_clone
1634 Clone a CV, making a lexical closure. "proto" supplies the
1635 prototype of the function: its code, pad structure, and other
1636 attributes. The prototype is combined with a capture of outer
1637 lexicals to which the code refers, which are taken from the
1638 currently-executing instance of the immediately surrounding
1639 code.
1640
1641 CV * cv_clone(CV *proto)
1642
1643 cv_name Returns an SV containing the name of the CV, mainly for use in
1644 error reporting. The CV may actually be a GV instead, in which
1645 case the returned SV holds the GV's name. Anything other than
1646 a GV or CV is treated as a string already holding the sub name,
1647 but this could change in the future.
1648
1649 An SV may be passed as a second argument. If so, the name will
1650 be assigned to it and it will be returned. Otherwise the
1651 returned SV will be a new mortal.
1652
1653 If "flags" has the "CV_NAME_NOTQUAL" bit set, then the package
1654 name will not be included. If the first argument is neither a
1655 CV nor a GV, this flag is ignored (subject to change).
1656
1657 SV * cv_name(CV *cv, SV *sv, U32 flags)
1658
1659 cv_undef
1660 Clear out all the active components of a CV. This can happen
1661 either by an explicit "undef &foo", or by the reference count
1662 going to zero. In the former case, we keep the "CvOUTSIDE"
1663 pointer, so that any anonymous children can still follow the
1664 full lexical scope chain.
1665
1666 void cv_undef(CV* cv)
1667
1668 find_rundefsv
1669 Returns the global variable $_.
1670
1671 SV * find_rundefsv()
1672
1673 find_rundefsvoffset
1674 DEPRECATED! It is planned to remove this function from a
1675 future release of Perl. Do not use it for new code; remove it
1676 from existing code.
1677
1678 Until the lexical $_ feature was removed, this function would
1679 find the position of the lexical $_ in the pad of the
1680 currently-executing function and return the offset in the
1681 current pad, or "NOT_IN_PAD".
1682
1683 Now it always returns "NOT_IN_PAD".
1684
1685 NOTE: the perl_ form of this function is deprecated.
1686
1687 PADOFFSET find_rundefsvoffset()
1688
1689 intro_my
1690 "Introduce" "my" variables to visible status. This is called
1691 during parsing at the end of each statement to make lexical
1692 variables visible to subsequent statements.
1693
1694 U32 intro_my()
1695
1696 load_module
1697 Loads the module whose name is pointed to by the string part of
1698 "name". Note that the actual module name, not its filename,
1699 should be given. Eg, "Foo::Bar" instead of "Foo/Bar.pm". ver,
1700 if specified and not NULL, provides version semantics similar
1701 to "use Foo::Bar VERSION". The optional trailing arguments can
1702 be used to specify arguments to the module's "import()" method,
1703 similar to "use Foo::Bar VERSION LIST"; their precise handling
1704 depends on the flags. The flags argument is a bitwise-ORed
1705 collection of any of "PERL_LOADMOD_DENY",
1706 "PERL_LOADMOD_NOIMPORT", or "PERL_LOADMOD_IMPORT_OPS" (or 0 for
1707 no flags).
1708
1709 If "PERL_LOADMOD_NOIMPORT" is set, the module is loaded as if
1710 with an empty import list, as in "use Foo::Bar ()"; this is the
1711 only circumstance in which the trailing optional arguments may
1712 be omitted entirely. Otherwise, if "PERL_LOADMOD_IMPORT_OPS" is
1713 set, the trailing arguments must consist of exactly one "OP*",
1714 containing the op tree that produces the relevant import
1715 arguments. Otherwise, the trailing arguments must all be "SV*"
1716 values that will be used as import arguments; and the list must
1717 be terminated with "(SV*) NULL". If neither
1718 "PERL_LOADMOD_NOIMPORT" nor "PERL_LOADMOD_IMPORT_OPS" is set,
1719 the trailing "NULL" pointer is needed even if no import
1720 arguments are desired. The reference count for each specified
1721 "SV*" argument is decremented. In addition, the "name" argument
1722 is modified.
1723
1724 If "PERL_LOADMOD_DENY" is set, the module is loaded as if with
1725 "no" rather than "use".
1726
1727 void load_module(U32 flags, SV* name, SV* ver, ...)
1728
1729 newPADNAMELIST
1730 NOTE: this function is experimental and may change or be
1731 removed without notice.
1732
1733 Creates a new pad name list. "max" is the highest index for
1734 which space is allocated.
1735
1736 PADNAMELIST * newPADNAMELIST(size_t max)
1737
1738 newPADNAMEouter
1739 NOTE: this function is experimental and may change or be
1740 removed without notice.
1741
1742 Constructs and returns a new pad name. Only use this function
1743 for names that refer to outer lexicals. (See also
1744 "newPADNAMEpvn".) "outer" is the outer pad name that this one
1745 mirrors. The returned pad name has the "PADNAMEt_OUTER" flag
1746 already set.
1747
1748 PADNAME * newPADNAMEouter(PADNAME *outer)
1749
1750 newPADNAMEpvn
1751 NOTE: this function is experimental and may change or be
1752 removed without notice.
1753
1754 Constructs and returns a new pad name. "s" must be a UTF-8
1755 string. Do not use this for pad names that point to outer
1756 lexicals. See "newPADNAMEouter".
1757
1758 PADNAME * newPADNAMEpvn(const char *s, STRLEN len)
1759
1760 nothreadhook
1761 Stub that provides thread hook for perl_destruct when there are
1762 no threads.
1763
1764 int nothreadhook()
1765
1766 pad_add_anon
1767 Allocates a place in the currently-compiling pad (via
1768 "pad_alloc") for an anonymous function that is lexically scoped
1769 inside the currently-compiling function. The function "func"
1770 is linked into the pad, and its "CvOUTSIDE" link to the outer
1771 scope is weakened to avoid a reference loop.
1772
1773 One reference count is stolen, so you may need to do
1774 "SvREFCNT_inc(func)".
1775
1776 "optype" should be an opcode indicating the type of operation
1777 that the pad entry is to support. This doesn't affect
1778 operational semantics, but is used for debugging.
1779
1780 PADOFFSET pad_add_anon(CV *func, I32 optype)
1781
1782 pad_add_name_pv
1783 Exactly like "pad_add_name_pvn", but takes a nul-terminated
1784 string instead of a string/length pair.
1785
1786 PADOFFSET pad_add_name_pv(const char *name, U32 flags,
1787 HV *typestash, HV *ourstash)
1788
1789 pad_add_name_pvn
1790 Allocates a place in the currently-compiling pad for a named
1791 lexical variable. Stores the name and other metadata in the
1792 name part of the pad, and makes preparations to manage the
1793 variable's lexical scoping. Returns the offset of the
1794 allocated pad slot.
1795
1796 "namepv"/"namelen" specify the variable's name, including
1797 leading sigil. If "typestash" is non-null, the name is for a
1798 typed lexical, and this identifies the type. If "ourstash" is
1799 non-null, it's a lexical reference to a package variable, and
1800 this identifies the package. The following flags can be OR'ed
1801 together:
1802
1803 padadd_OUR redundantly specifies if it's a package var
1804 padadd_STATE variable will retain value persistently
1805 padadd_NO_DUP_CHECK skip check for lexical shadowing
1806
1807 PADOFFSET pad_add_name_pvn(const char *namepv,
1808 STRLEN namelen, U32 flags,
1809 HV *typestash, HV *ourstash)
1810
1811 pad_add_name_sv
1812 Exactly like "pad_add_name_pvn", but takes the name string in
1813 the form of an SV instead of a string/length pair.
1814
1815 PADOFFSET pad_add_name_sv(SV *name, U32 flags,
1816 HV *typestash, HV *ourstash)
1817
1818 pad_alloc
1819 NOTE: this function is experimental and may change or be
1820 removed without notice.
1821
1822 Allocates a place in the currently-compiling pad, returning the
1823 offset of the allocated pad slot. No name is initially
1824 attached to the pad slot. "tmptype" is a set of flags
1825 indicating the kind of pad entry required, which will be set in
1826 the value SV for the allocated pad entry:
1827
1828 SVs_PADMY named lexical variable ("my", "our", "state")
1829 SVs_PADTMP unnamed temporary store
1830 SVf_READONLY constant shared between recursion levels
1831
1832 "SVf_READONLY" has been supported here only since perl 5.20.
1833 To work with earlier versions as well, use
1834 "SVf_READONLY|SVs_PADTMP". "SVf_READONLY" does not cause the
1835 SV in the pad slot to be marked read-only, but simply tells
1836 "pad_alloc" that it will be made read-only (by the caller), or
1837 at least should be treated as such.
1838
1839 "optype" should be an opcode indicating the type of operation
1840 that the pad entry is to support. This doesn't affect
1841 operational semantics, but is used for debugging.
1842
1843 PADOFFSET pad_alloc(I32 optype, U32 tmptype)
1844
1845 pad_findmy_pv
1846 Exactly like "pad_findmy_pvn", but takes a nul-terminated
1847 string instead of a string/length pair.
1848
1849 PADOFFSET pad_findmy_pv(const char *name, U32 flags)
1850
1851 pad_findmy_pvn
1852 Given the name of a lexical variable, find its position in the
1853 currently-compiling pad. "namepv"/"namelen" specify the
1854 variable's name, including leading sigil. "flags" is reserved
1855 and must be zero. If it is not in the current pad but appears
1856 in the pad of any lexically enclosing scope, then a pseudo-
1857 entry for it is added in the current pad. Returns the offset
1858 in the current pad, or "NOT_IN_PAD" if no such lexical is in
1859 scope.
1860
1861 PADOFFSET pad_findmy_pvn(const char *namepv,
1862 STRLEN namelen, U32 flags)
1863
1864 pad_findmy_sv
1865 Exactly like "pad_findmy_pvn", but takes the name string in the
1866 form of an SV instead of a string/length pair.
1867
1868 PADOFFSET pad_findmy_sv(SV *name, U32 flags)
1869
1870 padnamelist_fetch
1871 NOTE: this function is experimental and may change or be
1872 removed without notice.
1873
1874 Fetches the pad name from the given index.
1875
1876 PADNAME * padnamelist_fetch(PADNAMELIST *pnl,
1877 SSize_t key)
1878
1879 padnamelist_store
1880 NOTE: this function is experimental and may change or be
1881 removed without notice.
1882
1883 Stores the pad name (which may be null) at the given index,
1884 freeing any existing pad name in that slot.
1885
1886 PADNAME ** padnamelist_store(PADNAMELIST *pnl,
1887 SSize_t key, PADNAME *val)
1888
1889 pad_setsv
1890 Set the value at offset "po" in the current (compiling or
1891 executing) pad. Use the macro "PAD_SETSV()" rather than
1892 calling this function directly.
1893
1894 void pad_setsv(PADOFFSET po, SV *sv)
1895
1896 pad_sv Get the value at offset "po" in the current (compiling or
1897 executing) pad. Use macro "PAD_SV" instead of calling this
1898 function directly.
1899
1900 SV * pad_sv(PADOFFSET po)
1901
1902 pad_tidy
1903 NOTE: this function is experimental and may change or be
1904 removed without notice.
1905
1906 Tidy up a pad at the end of compilation of the code to which it
1907 belongs. Jobs performed here are: remove most stuff from the
1908 pads of anonsub prototypes; give it a @_; mark temporaries as
1909 such. "type" indicates the kind of subroutine:
1910
1911 padtidy_SUB ordinary subroutine
1912 padtidy_SUBCLONE prototype for lexical closure
1913 padtidy_FORMAT format
1914
1915 void pad_tidy(padtidy_type type)
1916
1917 perl_alloc
1918 Allocates a new Perl interpreter. See perlembed.
1919
1920 PerlInterpreter* perl_alloc()
1921
1922 perl_construct
1923 Initializes a new Perl interpreter. See perlembed.
1924
1925 void perl_construct(PerlInterpreter *my_perl)
1926
1927 perl_destruct
1928 Shuts down a Perl interpreter. See perlembed for a tutorial.
1929
1930 "my_perl" points to the Perl interpreter. It must have been
1931 previously created through the use of "perl_alloc" and
1932 "perl_construct". It may have been initialised through
1933 "perl_parse", and may have been used through "perl_run" and
1934 other means. This function should be called for any Perl
1935 interpreter that has been constructed with "perl_construct",
1936 even if subsequent operations on it failed, for example if
1937 "perl_parse" returned a non-zero value.
1938
1939 If the interpreter's "PL_exit_flags" word has the
1940 "PERL_EXIT_DESTRUCT_END" flag set, then this function will
1941 execute code in "END" blocks before performing the rest of
1942 destruction. If it is desired to make any use of the
1943 interpreter between "perl_parse" and "perl_destruct" other than
1944 just calling "perl_run", then this flag should be set early on.
1945 This matters if "perl_run" will not be called, or if anything
1946 else will be done in addition to calling "perl_run".
1947
1948 Returns a value be a suitable value to pass to the C library
1949 function "exit" (or to return from "main"), to serve as an exit
1950 code indicating the nature of the way the interpreter
1951 terminated. This takes into account any failure of
1952 "perl_parse" and any early exit from "perl_run". The exit code
1953 is of the type required by the host operating system, so
1954 because of differing exit code conventions it is not portable
1955 to interpret specific numeric values as having specific
1956 meanings.
1957
1958 int perl_destruct(PerlInterpreter *my_perl)
1959
1960 perl_free
1961 Releases a Perl interpreter. See perlembed.
1962
1963 void perl_free(PerlInterpreter *my_perl)
1964
1965 perl_parse
1966 Tells a Perl interpreter to parse a Perl script. This performs
1967 most of the initialisation of a Perl interpreter. See
1968 perlembed for a tutorial.
1969
1970 "my_perl" points to the Perl interpreter that is to parse the
1971 script. It must have been previously created through the use
1972 of "perl_alloc" and "perl_construct". "xsinit" points to a
1973 callback function that will be called to set up the ability for
1974 this Perl interpreter to load XS extensions, or may be null to
1975 perform no such setup.
1976
1977 "argc" and "argv" supply a set of command-line arguments to the
1978 Perl interpreter, as would normally be passed to the "main"
1979 function of a C program. "argv[argc]" must be null. These
1980 arguments are where the script to parse is specified, either by
1981 naming a script file or by providing a script in a "-e" option.
1982 If $0 will be written to in the Perl interpreter, then the
1983 argument strings must be in writable memory, and so mustn't
1984 just be string constants.
1985
1986 "env" specifies a set of environment variables that will be
1987 used by this Perl interpreter. If non-null, it must point to a
1988 null-terminated array of environment strings. If null, the
1989 Perl interpreter will use the environment supplied by the
1990 "environ" global variable.
1991
1992 This function initialises the interpreter, and parses and
1993 compiles the script specified by the command-line arguments.
1994 This includes executing code in "BEGIN", "UNITCHECK", and
1995 "CHECK" blocks. It does not execute "INIT" blocks or the main
1996 program.
1997
1998 Returns an integer of slightly tricky interpretation. The
1999 correct use of the return value is as a truth value indicating
2000 whether there was a failure in initialisation. If zero is
2001 returned, this indicates that initialisation was successful,
2002 and it is safe to proceed to call "perl_run" and make other use
2003 of it. If a non-zero value is returned, this indicates some
2004 problem that means the interpreter wants to terminate. The
2005 interpreter should not be just abandoned upon such failure; the
2006 caller should proceed to shut the interpreter down cleanly with
2007 "perl_destruct" and free it with "perl_free".
2008
2009 For historical reasons, the non-zero return value also attempts
2010 to be a suitable value to pass to the C library function "exit"
2011 (or to return from "main"), to serve as an exit code indicating
2012 the nature of the way initialisation terminated. However, this
2013 isn't portable, due to differing exit code conventions. A
2014 historical bug is preserved for the time being: if the Perl
2015 built-in "exit" is called during this function's execution,
2016 with a type of exit entailing a zero exit code under the host
2017 operating system's conventions, then this function returns zero
2018 rather than a non-zero value. This bug, [perl #2754], leads to
2019 "perl_run" being called (and therefore "INIT" blocks and the
2020 main program running) despite a call to "exit". It has been
2021 preserved because a popular module-installing module has come
2022 to rely on it and needs time to be fixed. This issue is [perl
2023 #132577], and the original bug is due to be fixed in Perl 5.30.
2024
2025 int perl_parse(PerlInterpreter *my_perl,
2026 XSINIT_t xsinit, int argc,
2027 char **argv, char **env)
2028
2029 perl_run
2030 Tells a Perl interpreter to run its main program. See
2031 perlembed for a tutorial.
2032
2033 "my_perl" points to the Perl interpreter. It must have been
2034 previously created through the use of "perl_alloc" and
2035 "perl_construct", and initialised through "perl_parse". This
2036 function should not be called if "perl_parse" returned a non-
2037 zero value, indicating a failure in initialisation or
2038 compilation.
2039
2040 This function executes code in "INIT" blocks, and then executes
2041 the main program. The code to be executed is that established
2042 by the prior call to "perl_parse". If the interpreter's
2043 "PL_exit_flags" word does not have the "PERL_EXIT_DESTRUCT_END"
2044 flag set, then this function will also execute code in "END"
2045 blocks. If it is desired to make any further use of the
2046 interpreter after calling this function, then "END" blocks
2047 should be postponed to "perl_destruct" time by setting that
2048 flag.
2049
2050 Returns an integer of slightly tricky interpretation. The
2051 correct use of the return value is as a truth value indicating
2052 whether the program terminated non-locally. If zero is
2053 returned, this indicates that the program ran to completion,
2054 and it is safe to make other use of the interpreter (provided
2055 that the "PERL_EXIT_DESTRUCT_END" flag was set as described
2056 above). If a non-zero value is returned, this indicates that
2057 the interpreter wants to terminate early. The interpreter
2058 should not be just abandoned because of this desire to
2059 terminate; the caller should proceed to shut the interpreter
2060 down cleanly with "perl_destruct" and free it with "perl_free".
2061
2062 For historical reasons, the non-zero return value also attempts
2063 to be a suitable value to pass to the C library function "exit"
2064 (or to return from "main"), to serve as an exit code indicating
2065 the nature of the way the program terminated. However, this
2066 isn't portable, due to differing exit code conventions. An
2067 attempt is made to return an exit code of the type required by
2068 the host operating system, but because it is constrained to be
2069 non-zero, it is not necessarily possible to indicate every type
2070 of exit. It is only reliable on Unix, where a zero exit code
2071 can be augmented with a set bit that will be ignored. In any
2072 case, this function is not the correct place to acquire an exit
2073 code: one should get that from "perl_destruct".
2074
2075 int perl_run(PerlInterpreter *my_perl)
2076
2077 require_pv
2078 Tells Perl to "require" the file named by the string argument.
2079 It is analogous to the Perl code "eval "require '$file'"".
2080 It's even implemented that way; consider using load_module
2081 instead.
2082
2083 NOTE: the perl_ form of this function is deprecated.
2084
2085 void require_pv(const char* pv)
2086
2088 dXCPT Set up necessary local variables for exception handling. See
2089 "Exception Handling" in perlguts.
2090
2091 dXCPT;
2092
2093 XCPT_CATCH
2094 Introduces a catch block. See "Exception Handling" in
2095 perlguts.
2096
2097 XCPT_RETHROW
2098 Rethrows a previously caught exception. See "Exception
2099 Handling" in perlguts.
2100
2101 XCPT_RETHROW;
2102
2103 XCPT_TRY_END
2104 Ends a try block. See "Exception Handling" in perlguts.
2105
2106 XCPT_TRY_START
2107 Starts a try block. See "Exception Handling" in perlguts.
2108
2110 sortsv_flags
2111 In-place sort an array of SV pointers with the given comparison
2112 routine, with various SORTf_* flag options.
2113
2114 void sortsv_flags(SV** array, size_t num_elts,
2115 SVCOMPARE_t cmp, U32 flags)
2116
2118 save_gp Saves the current GP of gv on the save stack to be restored on
2119 scope exit.
2120
2121 If empty is true, replace the GP with a new GP.
2122
2123 If empty is false, mark gv with GVf_INTRO so the next reference
2124 assigned is localized, which is how " local *foo = $someref; "
2125 works.
2126
2127 void save_gp(GV* gv, I32 empty)
2128
2130 new_version
2131 Returns a new version object based on the passed in SV:
2132
2133 SV *sv = new_version(SV *ver);
2134
2135 Does not alter the passed in ver SV. See "upg_version" if you
2136 want to upgrade the SV.
2137
2138 SV* new_version(SV *ver)
2139
2140 prescan_version
2141 Validate that a given string can be parsed as a version object,
2142 but doesn't actually perform the parsing. Can use either
2143 strict or lax validation rules. Can optionally set a number of
2144 hint variables to save the parsing code some time when
2145 tokenizing.
2146
2147 const char* prescan_version(const char *s, bool strict,
2148 const char** errstr,
2149 bool *sqv,
2150 int *ssaw_decimal,
2151 int *swidth, bool *salpha)
2152
2153 scan_version
2154 Returns a pointer to the next character after the parsed
2155 version string, as well as upgrading the passed in SV to an RV.
2156
2157 Function must be called with an already existing SV like
2158
2159 sv = newSV(0);
2160 s = scan_version(s, SV *sv, bool qv);
2161
2162 Performs some preprocessing to the string to ensure that it has
2163 the correct characteristics of a version. Flags the object if
2164 it contains an underscore (which denotes this is an alpha
2165 version). The boolean qv denotes that the version should be
2166 interpreted as if it had multiple decimals, even if it doesn't.
2167
2168 const char* scan_version(const char *s, SV *rv, bool qv)
2169
2170 upg_version
2171 In-place upgrade of the supplied SV to a version object.
2172
2173 SV *sv = upg_version(SV *sv, bool qv);
2174
2175 Returns a pointer to the upgraded SV. Set the boolean qv if
2176 you want to force this SV to be interpreted as an "extended"
2177 version.
2178
2179 SV* upg_version(SV *ver, bool qv)
2180
2181 vcmp Version object aware cmp. Both operands must already have been
2182 converted into version objects.
2183
2184 int vcmp(SV *lhv, SV *rhv)
2185
2186 vnormal Accepts a version object and returns the normalized string
2187 representation. Call like:
2188
2189 sv = vnormal(rv);
2190
2191 NOTE: you can pass either the object directly or the SV
2192 contained within the RV.
2193
2194 The SV returned has a refcount of 1.
2195
2196 SV* vnormal(SV *vs)
2197
2198 vnumify Accepts a version object and returns the normalized floating
2199 point representation. Call like:
2200
2201 sv = vnumify(rv);
2202
2203 NOTE: you can pass either the object directly or the SV
2204 contained within the RV.
2205
2206 The SV returned has a refcount of 1.
2207
2208 SV* vnumify(SV *vs)
2209
2210 vstringify
2211 In order to maintain maximum compatibility with earlier
2212 versions of Perl, this function will return either the floating
2213 point notation or the multiple dotted notation, depending on
2214 whether the original version contained 1 or more dots,
2215 respectively.
2216
2217 The SV returned has a refcount of 1.
2218
2219 SV* vstringify(SV *vs)
2220
2221 vverify Validates that the SV contains valid internal structure for a
2222 version object. It may be passed either the version object
2223 (RV) or the hash itself (HV). If the structure is valid, it
2224 returns the HV. If the structure is invalid, it returns NULL.
2225
2226 SV *hv = vverify(sv);
2227
2228 Note that it only confirms the bare minimum structure (so as
2229 not to get confused by derived classes which may contain
2230 additional hash entries):
2231
2232 · The SV is an HV or a reference to an HV
2233
2234 · The hash contains a "version" key
2235
2236 · The "version" key has a reference to an AV as its value
2237
2238 SV* vverify(SV *vs)
2239
2241 G_ARRAY Used to indicate list context. See "GIMME_V", "GIMME" and
2242 perlcall.
2243
2244 G_DISCARD
2245 Indicates that arguments returned from a callback should be
2246 discarded. See perlcall.
2247
2248 G_EVAL Used to force a Perl "eval" wrapper around a callback. See
2249 perlcall.
2250
2251 GIMME A backward-compatible version of "GIMME_V" which can only
2252 return "G_SCALAR" or "G_ARRAY"; in a void context, it returns
2253 "G_SCALAR". Deprecated. Use "GIMME_V" instead.
2254
2255 U32 GIMME
2256
2257 GIMME_V The XSUB-writer's equivalent to Perl's "wantarray". Returns
2258 "G_VOID", "G_SCALAR" or "G_ARRAY" for void, scalar or list
2259 context, respectively. See perlcall for a usage example.
2260
2261 U32 GIMME_V
2262
2263 G_NOARGS
2264 Indicates that no arguments are being sent to a callback. See
2265 perlcall.
2266
2267 G_SCALAR
2268 Used to indicate scalar context. See "GIMME_V", "GIMME", and
2269 perlcall.
2270
2271 G_VOID Used to indicate void context. See "GIMME_V" and perlcall.
2272
2274 These variables are global to an entire process. They are shared
2275 between all interpreters and all threads in a process. Any variables
2276 not documented here may be changed or removed without notice, so don't
2277 use them! If you feel you really do need to use an unlisted variable,
2278 first send email to perl5-porters@perl.org
2279 <mailto:perl5-porters@perl.org>. It may be that someone there will
2280 point out a way to accomplish what you need without using an internal
2281 variable. But if not, you should get a go-ahead to document and then
2282 use the variable.
2283
2284 PL_check
2285 Array, indexed by opcode, of functions that will be called for
2286 the "check" phase of optree building during compilation of Perl
2287 code. For most (but not all) types of op, once the op has been
2288 initially built and populated with child ops it will be
2289 filtered through the check function referenced by the
2290 appropriate element of this array. The new op is passed in as
2291 the sole argument to the check function, and the check function
2292 returns the completed op. The check function may (as the name
2293 suggests) check the op for validity and signal errors. It may
2294 also initialise or modify parts of the ops, or perform more
2295 radical surgery such as adding or removing child ops, or even
2296 throw the op away and return a different op in its place.
2297
2298 This array of function pointers is a convenient place to hook
2299 into the compilation process. An XS module can put its own
2300 custom check function in place of any of the standard ones, to
2301 influence the compilation of a particular type of op. However,
2302 a custom check function must never fully replace a standard
2303 check function (or even a custom check function from another
2304 module). A module modifying checking must instead wrap the
2305 preexisting check function. A custom check function must be
2306 selective about when to apply its custom behaviour. In the
2307 usual case where it decides not to do anything special with an
2308 op, it must chain the preexisting op function. Check functions
2309 are thus linked in a chain, with the core's base checker at the
2310 end.
2311
2312 For thread safety, modules should not write directly to this
2313 array. Instead, use the function "wrap_op_checker".
2314
2315 PL_keyword_plugin
2316 NOTE: this function is experimental and may change or be
2317 removed without notice.
2318
2319 Function pointer, pointing at a function used to handle
2320 extended keywords. The function should be declared as
2321
2322 int keyword_plugin_function(pTHX_
2323 char *keyword_ptr, STRLEN keyword_len,
2324 OP **op_ptr)
2325
2326 The function is called from the tokeniser, whenever a possible
2327 keyword is seen. "keyword_ptr" points at the word in the
2328 parser's input buffer, and "keyword_len" gives its length; it
2329 is not null-terminated. The function is expected to examine
2330 the word, and possibly other state such as %^H, to decide
2331 whether it wants to handle it as an extended keyword. If it
2332 does not, the function should return "KEYWORD_PLUGIN_DECLINE",
2333 and the normal parser process will continue.
2334
2335 If the function wants to handle the keyword, it first must
2336 parse anything following the keyword that is part of the syntax
2337 introduced by the keyword. See "Lexer interface" for details.
2338
2339 When a keyword is being handled, the plugin function must build
2340 a tree of "OP" structures, representing the code that was
2341 parsed. The root of the tree must be stored in *op_ptr. The
2342 function then returns a constant indicating the syntactic role
2343 of the construct that it has parsed: "KEYWORD_PLUGIN_STMT" if
2344 it is a complete statement, or "KEYWORD_PLUGIN_EXPR" if it is
2345 an expression. Note that a statement construct cannot be used
2346 inside an expression (except via "do BLOCK" and similar), and
2347 an expression is not a complete statement (it requires at least
2348 a terminating semicolon).
2349
2350 When a keyword is handled, the plugin function may also have
2351 (compile-time) side effects. It may modify "%^H", define
2352 functions, and so on. Typically, if side effects are the main
2353 purpose of a handler, it does not wish to generate any ops to
2354 be included in the normal compilation. In this case it is
2355 still required to supply an op tree, but it suffices to
2356 generate a single null op.
2357
2358 That's how the *PL_keyword_plugin function needs to behave
2359 overall. Conventionally, however, one does not completely
2360 replace the existing handler function. Instead, take a copy of
2361 "PL_keyword_plugin" before assigning your own function pointer
2362 to it. Your handler function should look for keywords that it
2363 is interested in and handle those. Where it is not interested,
2364 it should call the saved plugin function, passing on the
2365 arguments it received. Thus "PL_keyword_plugin" actually
2366 points at a chain of handler functions, all of which have an
2367 opportunity to handle keywords, and only the last function in
2368 the chain (built into the Perl core) will normally return
2369 "KEYWORD_PLUGIN_DECLINE".
2370
2371 For thread safety, modules should not set this variable
2372 directly. Instead, use the function "wrap_keyword_plugin".
2373
2375 A GV is a structure which corresponds to to a Perl typeglob, ie *foo.
2376 It is a structure that holds a pointer to a scalar, an array, a hash
2377 etc, corresponding to $foo, @foo, %foo.
2378
2379 GVs are usually found as values in stashes (symbol table hashes) where
2380 Perl stores its global variables.
2381
2382 GvAV Return the AV from the GV.
2383
2384 AV* GvAV(GV* gv)
2385
2386 gv_const_sv
2387 If "gv" is a typeglob whose subroutine entry is a constant sub
2388 eligible for inlining, or "gv" is a placeholder reference that
2389 would be promoted to such a typeglob, then returns the value
2390 returned by the sub. Otherwise, returns "NULL".
2391
2392 SV* gv_const_sv(GV* gv)
2393
2394 GvCV Return the CV from the GV.
2395
2396 CV* GvCV(GV* gv)
2397
2398 gv_fetchmeth
2399 Like "gv_fetchmeth_pvn", but lacks a flags parameter.
2400
2401 GV* gv_fetchmeth(HV* stash, const char* name,
2402 STRLEN len, I32 level)
2403
2404 gv_fetchmethod_autoload
2405 Returns the glob which contains the subroutine to call to
2406 invoke the method on the "stash". In fact in the presence of
2407 autoloading this may be the glob for "AUTOLOAD". In this case
2408 the corresponding variable $AUTOLOAD is already setup.
2409
2410 The third parameter of "gv_fetchmethod_autoload" determines
2411 whether AUTOLOAD lookup is performed if the given method is not
2412 present: non-zero means yes, look for AUTOLOAD; zero means no,
2413 don't look for AUTOLOAD. Calling "gv_fetchmethod" is
2414 equivalent to calling "gv_fetchmethod_autoload" with a non-zero
2415 "autoload" parameter.
2416
2417 These functions grant "SUPER" token as a prefix of the method
2418 name. Note that if you want to keep the returned glob for a
2419 long time, you need to check for it being "AUTOLOAD", since at
2420 the later time the call may load a different subroutine due to
2421 $AUTOLOAD changing its value. Use the glob created as a side
2422 effect to do this.
2423
2424 These functions have the same side-effects as "gv_fetchmeth"
2425 with "level==0". The warning against passing the GV returned
2426 by "gv_fetchmeth" to "call_sv" applies equally to these
2427 functions.
2428
2429 GV* gv_fetchmethod_autoload(HV* stash,
2430 const char* name,
2431 I32 autoload)
2432
2433 gv_fetchmeth_autoload
2434 This is the old form of "gv_fetchmeth_pvn_autoload", which has
2435 no flags parameter.
2436
2437 GV* gv_fetchmeth_autoload(HV* stash,
2438 const char* name,
2439 STRLEN len, I32 level)
2440
2441 gv_fetchmeth_pv
2442 Exactly like "gv_fetchmeth_pvn", but takes a nul-terminated
2443 string instead of a string/length pair.
2444
2445 GV* gv_fetchmeth_pv(HV* stash, const char* name,
2446 I32 level, U32 flags)
2447
2448 gv_fetchmeth_pvn
2449 Returns the glob with the given "name" and a defined subroutine
2450 or "NULL". The glob lives in the given "stash", or in the
2451 stashes accessible via @ISA and "UNIVERSAL::".
2452
2453 The argument "level" should be either 0 or -1. If "level==0",
2454 as a side-effect creates a glob with the given "name" in the
2455 given "stash" which in the case of success contains an alias
2456 for the subroutine, and sets up caching info for this glob.
2457
2458 The only significant values for "flags" are "GV_SUPER" and
2459 "SVf_UTF8".
2460
2461 "GV_SUPER" indicates that we want to look up the method in the
2462 superclasses of the "stash".
2463
2464 The GV returned from "gv_fetchmeth" may be a method cache
2465 entry, which is not visible to Perl code. So when calling
2466 "call_sv", you should not use the GV directly; instead, you
2467 should use the method's CV, which can be obtained from the GV
2468 with the "GvCV" macro.
2469
2470 GV* gv_fetchmeth_pvn(HV* stash, const char* name,
2471 STRLEN len, I32 level,
2472 U32 flags)
2473
2474 gv_fetchmeth_pvn_autoload
2475 Same as "gv_fetchmeth_pvn()", but looks for autoloaded
2476 subroutines too. Returns a glob for the subroutine.
2477
2478 For an autoloaded subroutine without a GV, will create a GV
2479 even if "level < 0". For an autoloaded subroutine without a
2480 stub, "GvCV()" of the result may be zero.
2481
2482 Currently, the only significant value for "flags" is
2483 "SVf_UTF8".
2484
2485 GV* gv_fetchmeth_pvn_autoload(HV* stash,
2486 const char* name,
2487 STRLEN len, I32 level,
2488 U32 flags)
2489
2490 gv_fetchmeth_pv_autoload
2491 Exactly like "gv_fetchmeth_pvn_autoload", but takes a nul-
2492 terminated string instead of a string/length pair.
2493
2494 GV* gv_fetchmeth_pv_autoload(HV* stash,
2495 const char* name,
2496 I32 level, U32 flags)
2497
2498 gv_fetchmeth_sv
2499 Exactly like "gv_fetchmeth_pvn", but takes the name string in
2500 the form of an SV instead of a string/length pair.
2501
2502 GV* gv_fetchmeth_sv(HV* stash, SV* namesv,
2503 I32 level, U32 flags)
2504
2505 gv_fetchmeth_sv_autoload
2506 Exactly like "gv_fetchmeth_pvn_autoload", but takes the name
2507 string in the form of an SV instead of a string/length pair.
2508
2509 GV* gv_fetchmeth_sv_autoload(HV* stash, SV* namesv,
2510 I32 level, U32 flags)
2511
2512 GvHV Return the HV from the GV.
2513
2514 HV* GvHV(GV* gv)
2515
2516 gv_init The old form of "gv_init_pvn()". It does not work with UTF-8
2517 strings, as it has no flags parameter. If the "multi"
2518 parameter is set, the "GV_ADDMULTI" flag will be passed to
2519 "gv_init_pvn()".
2520
2521 void gv_init(GV* gv, HV* stash, const char* name,
2522 STRLEN len, int multi)
2523
2524 gv_init_pv
2525 Same as "gv_init_pvn()", but takes a nul-terminated string for
2526 the name instead of separate char * and length parameters.
2527
2528 void gv_init_pv(GV* gv, HV* stash, const char* name,
2529 U32 flags)
2530
2531 gv_init_pvn
2532 Converts a scalar into a typeglob. This is an incoercible
2533 typeglob; assigning a reference to it will assign to one of its
2534 slots, instead of overwriting it as happens with typeglobs
2535 created by "SvSetSV". Converting any scalar that is "SvOK()"
2536 may produce unpredictable results and is reserved for perl's
2537 internal use.
2538
2539 "gv" is the scalar to be converted.
2540
2541 "stash" is the parent stash/package, if any.
2542
2543 "name" and "len" give the name. The name must be unqualified;
2544 that is, it must not include the package name. If "gv" is a
2545 stash element, it is the caller's responsibility to ensure that
2546 the name passed to this function matches the name of the
2547 element. If it does not match, perl's internal bookkeeping
2548 will get out of sync.
2549
2550 "flags" can be set to "SVf_UTF8" if "name" is a UTF-8 string,
2551 or the return value of SvUTF8(sv). It can also take the
2552 "GV_ADDMULTI" flag, which means to pretend that the GV has been
2553 seen before (i.e., suppress "Used once" warnings).
2554
2555 void gv_init_pvn(GV* gv, HV* stash, const char* name,
2556 STRLEN len, U32 flags)
2557
2558 gv_init_sv
2559 Same as "gv_init_pvn()", but takes an SV * for the name instead
2560 of separate char * and length parameters. "flags" is currently
2561 unused.
2562
2563 void gv_init_sv(GV* gv, HV* stash, SV* namesv,
2564 U32 flags)
2565
2566 gv_stashpv
2567 Returns a pointer to the stash for a specified package. Uses
2568 "strlen" to determine the length of "name", then calls
2569 "gv_stashpvn()".
2570
2571 HV* gv_stashpv(const char* name, I32 flags)
2572
2573 gv_stashpvn
2574 Returns a pointer to the stash for a specified package. The
2575 "namelen" parameter indicates the length of the "name", in
2576 bytes. "flags" is passed to "gv_fetchpvn_flags()", so if set
2577 to "GV_ADD" then the package will be created if it does not
2578 already exist. If the package does not exist and "flags" is 0
2579 (or any other setting that does not create packages) then
2580 "NULL" is returned.
2581
2582 Flags may be one of:
2583
2584 GV_ADD
2585 SVf_UTF8
2586 GV_NOADD_NOINIT
2587 GV_NOINIT
2588 GV_NOEXPAND
2589 GV_ADDMG
2590
2591 The most important of which are probably "GV_ADD" and
2592 "SVf_UTF8".
2593
2594 Note, use of "gv_stashsv" instead of "gv_stashpvn" where
2595 possible is strongly recommended for performance reasons.
2596
2597 HV* gv_stashpvn(const char* name, U32 namelen,
2598 I32 flags)
2599
2600 gv_stashpvs
2601 Like "gv_stashpvn", but takes a literal string instead of a
2602 string/length pair.
2603
2604 HV* gv_stashpvs("literal string" name, I32 create)
2605
2606 gv_stashsv
2607 Returns a pointer to the stash for a specified package. See
2608 "gv_stashpvn".
2609
2610 Note this interface is strongly preferred over "gv_stashpvn"
2611 for performance reasons.
2612
2613 HV* gv_stashsv(SV* sv, I32 flags)
2614
2615 GvSV Return the SV from the GV.
2616
2617 SV* GvSV(GV* gv)
2618
2619 setdefout
2620 Sets "PL_defoutgv", the default file handle for output, to the
2621 passed in typeglob. As "PL_defoutgv" "owns" a reference on its
2622 typeglob, the reference count of the passed in typeglob is
2623 increased by one, and the reference count of the typeglob that
2624 "PL_defoutgv" points to is decreased by one.
2625
2626 void setdefout(GV* gv)
2627
2629 Nullav Null AV pointer.
2630
2631 (deprecated - use "(AV *)NULL" instead)
2632
2633 Nullch Null character pointer. (No longer available when "PERL_CORE"
2634 is defined.)
2635
2636 Nullcv Null CV pointer.
2637
2638 (deprecated - use "(CV *)NULL" instead)
2639
2640 Nullhv Null HV pointer.
2641
2642 (deprecated - use "(HV *)NULL" instead)
2643
2644 Nullsv Null SV pointer. (No longer available when "PERL_CORE" is
2645 defined.)
2646
2648 A HV structure represents a Perl hash. It consists mainly of an array
2649 of pointers, each of which points to a linked list of HE structures.
2650 The array is indexed by the hash function of the key, so each linked
2651 list represents all the hash entries with the same hash value. Each HE
2652 contains a pointer to the actual value, plus a pointer to a HEK
2653 structure which holds the key and hash value.
2654
2655 cop_fetch_label
2656 NOTE: this function is experimental and may change or be
2657 removed without notice.
2658
2659 Returns the label attached to a cop. The flags pointer may be
2660 set to "SVf_UTF8" or 0.
2661
2662 const char * cop_fetch_label(COP *const cop,
2663 STRLEN *len, U32 *flags)
2664
2665 cop_store_label
2666 NOTE: this function is experimental and may change or be
2667 removed without notice.
2668
2669 Save a label into a "cop_hints_hash". You need to set flags to
2670 "SVf_UTF8" for a UTF-8 label.
2671
2672 void cop_store_label(COP *const cop,
2673 const char *label, STRLEN len,
2674 U32 flags)
2675
2676 get_hv Returns the HV of the specified Perl hash. "flags" are passed
2677 to "gv_fetchpv". If "GV_ADD" is set and the Perl variable does
2678 not exist then it will be created. If "flags" is zero and the
2679 variable does not exist then "NULL" is returned.
2680
2681 NOTE: the perl_ form of this function is deprecated.
2682
2683 HV* get_hv(const char *name, I32 flags)
2684
2685 HEf_SVKEY
2686 This flag, used in the length slot of hash entries and magic
2687 structures, specifies the structure contains an "SV*" pointer
2688 where a "char*" pointer is to be expected. (For information
2689 only--not to be used).
2690
2691 HeHASH Returns the computed hash stored in the hash entry.
2692
2693 U32 HeHASH(HE* he)
2694
2695 HeKEY Returns the actual pointer stored in the key slot of the hash
2696 entry. The pointer may be either "char*" or "SV*", depending
2697 on the value of "HeKLEN()". Can be assigned to. The "HePV()"
2698 or "HeSVKEY()" macros are usually preferable for finding the
2699 value of a key.
2700
2701 void* HeKEY(HE* he)
2702
2703 HeKLEN If this is negative, and amounts to "HEf_SVKEY", it indicates
2704 the entry holds an "SV*" key. Otherwise, holds the actual
2705 length of the key. Can be assigned to. The "HePV()" macro is
2706 usually preferable for finding key lengths.
2707
2708 STRLEN HeKLEN(HE* he)
2709
2710 HePV Returns the key slot of the hash entry as a "char*" value,
2711 doing any necessary dereferencing of possibly "SV*" keys. The
2712 length of the string is placed in "len" (this is a macro, so do
2713 not use &len). If you do not care about what the length of the
2714 key is, you may use the global variable "PL_na", though this is
2715 rather less efficient than using a local variable. Remember
2716 though, that hash keys in perl are free to contain embedded
2717 nulls, so using "strlen()" or similar is not a good way to find
2718 the length of hash keys. This is very similar to the "SvPV()"
2719 macro described elsewhere in this document. See also "HeUTF8".
2720
2721 If you are using "HePV" to get values to pass to "newSVpvn()"
2722 to create a new SV, you should consider using
2723 "newSVhek(HeKEY_hek(he))" as it is more efficient.
2724
2725 char* HePV(HE* he, STRLEN len)
2726
2727 HeSVKEY Returns the key as an "SV*", or "NULL" if the hash entry does
2728 not contain an "SV*" key.
2729
2730 SV* HeSVKEY(HE* he)
2731
2732 HeSVKEY_force
2733 Returns the key as an "SV*". Will create and return a
2734 temporary mortal "SV*" if the hash entry contains only a
2735 "char*" key.
2736
2737 SV* HeSVKEY_force(HE* he)
2738
2739 HeSVKEY_set
2740 Sets the key to a given "SV*", taking care to set the
2741 appropriate flags to indicate the presence of an "SV*" key, and
2742 returns the same "SV*".
2743
2744 SV* HeSVKEY_set(HE* he, SV* sv)
2745
2746 HeUTF8 Returns whether the "char *" value returned by "HePV" is
2747 encoded in UTF-8, doing any necessary dereferencing of possibly
2748 "SV*" keys. The value returned will be 0 or non-0, not
2749 necessarily 1 (or even a value with any low bits set), so do
2750 not blindly assign this to a "bool" variable, as "bool" may be
2751 a typedef for "char".
2752
2753 U32 HeUTF8(HE* he)
2754
2755 HeVAL Returns the value slot (type "SV*") stored in the hash entry.
2756 Can be assigned to.
2757
2758 SV *foo= HeVAL(hv);
2759 HeVAL(hv)= sv;
2760
2761
2762 SV* HeVAL(HE* he)
2763
2764 hv_assert
2765 Check that a hash is in an internally consistent state.
2766
2767 void hv_assert(HV *hv)
2768
2769 hv_bucket_ratio
2770 NOTE: this function is experimental and may change or be
2771 removed without notice.
2772
2773 If the hash is tied dispatches through to the SCALAR tied
2774 method, otherwise if the hash contains no keys returns 0,
2775 otherwise returns a mortal sv containing a string specifying
2776 the number of used buckets, followed by a slash, followed by
2777 the number of available buckets.
2778
2779 This function is expensive, it must scan all of the buckets to
2780 determine which are used, and the count is NOT cached. In a
2781 large hash this could be a lot of buckets.
2782
2783 SV* hv_bucket_ratio(HV *hv)
2784
2785 hv_clear
2786 Frees the all the elements of a hash, leaving it empty. The XS
2787 equivalent of "%hash = ()". See also "hv_undef".
2788
2789 See "av_clear" for a note about the hash possibly being invalid
2790 on return.
2791
2792 void hv_clear(HV *hv)
2793
2794 hv_clear_placeholders
2795 Clears any placeholders from a hash. If a restricted hash has
2796 any of its keys marked as readonly and the key is subsequently
2797 deleted, the key is not actually deleted but is marked by
2798 assigning it a value of &PL_sv_placeholder. This tags it so it
2799 will be ignored by future operations such as iterating over the
2800 hash, but will still allow the hash to have a value reassigned
2801 to the key at some future point. This function clears any such
2802 placeholder keys from the hash. See "Hash::Util::lock_keys()"
2803 for an example of its use.
2804
2805 void hv_clear_placeholders(HV *hv)
2806
2807 hv_copy_hints_hv
2808 A specialised version of "newHVhv" for copying "%^H". "ohv"
2809 must be a pointer to a hash (which may have "%^H" magic, but
2810 should be generally non-magical), or "NULL" (interpreted as an
2811 empty hash). The content of "ohv" is copied to a new hash,
2812 which has the "%^H"-specific magic added to it. A pointer to
2813 the new hash is returned.
2814
2815 HV * hv_copy_hints_hv(HV *ohv)
2816
2817 hv_delete
2818 Deletes a key/value pair in the hash. The value's SV is
2819 removed from the hash, made mortal, and returned to the caller.
2820 The absolute value of "klen" is the length of the key. If
2821 "klen" is negative the key is assumed to be in UTF-8-encoded
2822 Unicode. The "flags" value will normally be zero; if set to
2823 "G_DISCARD" then "NULL" will be returned. "NULL" will also be
2824 returned if the key is not found.
2825
2826 SV* hv_delete(HV *hv, const char *key, I32 klen,
2827 I32 flags)
2828
2829 hv_delete_ent
2830 Deletes a key/value pair in the hash. The value SV is removed
2831 from the hash, made mortal, and returned to the caller. The
2832 "flags" value will normally be zero; if set to "G_DISCARD" then
2833 "NULL" will be returned. "NULL" will also be returned if the
2834 key is not found. "hash" can be a valid precomputed hash
2835 value, or 0 to ask for it to be computed.
2836
2837 SV* hv_delete_ent(HV *hv, SV *keysv, I32 flags,
2838 U32 hash)
2839
2840 HvENAME Returns the effective name of a stash, or NULL if there is
2841 none. The effective name represents a location in the symbol
2842 table where this stash resides. It is updated automatically
2843 when packages are aliased or deleted. A stash that is no
2844 longer in the symbol table has no effective name. This name is
2845 preferable to "HvNAME" for use in MRO linearisations and isa
2846 caches.
2847
2848 char* HvENAME(HV* stash)
2849
2850 HvENAMELEN
2851 Returns the length of the stash's effective name.
2852
2853 STRLEN HvENAMELEN(HV *stash)
2854
2855 HvENAMEUTF8
2856 Returns true if the effective name is in UTF-8 encoding.
2857
2858 unsigned char HvENAMEUTF8(HV *stash)
2859
2860 hv_exists
2861 Returns a boolean indicating whether the specified hash key
2862 exists. The absolute value of "klen" is the length of the key.
2863 If "klen" is negative the key is assumed to be in UTF-8-encoded
2864 Unicode.
2865
2866 bool hv_exists(HV *hv, const char *key, I32 klen)
2867
2868 hv_exists_ent
2869 Returns a boolean indicating whether the specified hash key
2870 exists. "hash" can be a valid precomputed hash value, or 0 to
2871 ask for it to be computed.
2872
2873 bool hv_exists_ent(HV *hv, SV *keysv, U32 hash)
2874
2875 hv_fetch
2876 Returns the SV which corresponds to the specified key in the
2877 hash. The absolute value of "klen" is the length of the key.
2878 If "klen" is negative the key is assumed to be in UTF-8-encoded
2879 Unicode. If "lval" is set then the fetch will be part of a
2880 store. This means that if there is no value in the hash
2881 associated with the given key, then one is created and a
2882 pointer to it is returned. The "SV*" it points to can be
2883 assigned to. But always check that the return value is non-
2884 null before dereferencing it to an "SV*".
2885
2886 See "Understanding the Magic of Tied Hashes and Arrays" in
2887 perlguts for more information on how to use this function on
2888 tied hashes.
2889
2890 SV** hv_fetch(HV *hv, const char *key, I32 klen,
2891 I32 lval)
2892
2893 hv_fetchs
2894 Like "hv_fetch", but takes a literal string instead of a
2895 string/length pair.
2896
2897 SV** hv_fetchs(HV* tb, "literal string" key,
2898 I32 lval)
2899
2900 hv_fetch_ent
2901 Returns the hash entry which corresponds to the specified key
2902 in the hash. "hash" must be a valid precomputed hash number
2903 for the given "key", or 0 if you want the function to compute
2904 it. IF "lval" is set then the fetch will be part of a store.
2905 Make sure the return value is non-null before accessing it.
2906 The return value when "hv" is a tied hash is a pointer to a
2907 static location, so be sure to make a copy of the structure if
2908 you need to store it somewhere.
2909
2910 See "Understanding the Magic of Tied Hashes and Arrays" in
2911 perlguts for more information on how to use this function on
2912 tied hashes.
2913
2914 HE* hv_fetch_ent(HV *hv, SV *keysv, I32 lval,
2915 U32 hash)
2916
2917 hv_fill Returns the number of hash buckets that happen to be in use.
2918
2919 This function is wrapped by the macro "HvFILL".
2920
2921 As of perl 5.25 this function is used only for debugging
2922 purposes, and the number of used hash buckets is not in any way
2923 cached, thus this function can be costly to execute as it must
2924 iterate over all the buckets in the hash.
2925
2926 STRLEN hv_fill(HV *const hv)
2927
2928 hv_iterinit
2929 Prepares a starting point to traverse a hash table. Returns
2930 the number of keys in the hash, including placeholders (i.e.
2931 the same as "HvTOTALKEYS(hv)"). The return value is currently
2932 only meaningful for hashes without tie magic.
2933
2934 NOTE: Before version 5.004_65, "hv_iterinit" used to return the
2935 number of hash buckets that happen to be in use. If you still
2936 need that esoteric value, you can get it through the macro
2937 "HvFILL(hv)".
2938
2939 I32 hv_iterinit(HV *hv)
2940
2941 hv_iterkey
2942 Returns the key from the current position of the hash iterator.
2943 See "hv_iterinit".
2944
2945 char* hv_iterkey(HE* entry, I32* retlen)
2946
2947 hv_iterkeysv
2948 Returns the key as an "SV*" from the current position of the
2949 hash iterator. The return value will always be a mortal copy
2950 of the key. Also see "hv_iterinit".
2951
2952 SV* hv_iterkeysv(HE* entry)
2953
2954 hv_iternext
2955 Returns entries from a hash iterator. See "hv_iterinit".
2956
2957 You may call "hv_delete" or "hv_delete_ent" on the hash entry
2958 that the iterator currently points to, without losing your
2959 place or invalidating your iterator. Note that in this case
2960 the current entry is deleted from the hash with your iterator
2961 holding the last reference to it. Your iterator is flagged to
2962 free the entry on the next call to "hv_iternext", so you must
2963 not discard your iterator immediately else the entry will leak
2964 - call "hv_iternext" to trigger the resource deallocation.
2965
2966 HE* hv_iternext(HV *hv)
2967
2968 hv_iternextsv
2969 Performs an "hv_iternext", "hv_iterkey", and "hv_iterval" in
2970 one operation.
2971
2972 SV* hv_iternextsv(HV *hv, char **key, I32 *retlen)
2973
2974 hv_iternext_flags
2975 NOTE: this function is experimental and may change or be
2976 removed without notice.
2977
2978 Returns entries from a hash iterator. See "hv_iterinit" and
2979 "hv_iternext". The "flags" value will normally be zero; if
2980 "HV_ITERNEXT_WANTPLACEHOLDERS" is set the placeholders keys
2981 (for restricted hashes) will be returned in addition to normal
2982 keys. By default placeholders are automatically skipped over.
2983 Currently a placeholder is implemented with a value that is
2984 &PL_sv_placeholder. Note that the implementation of
2985 placeholders and restricted hashes may change, and the
2986 implementation currently is insufficiently abstracted for any
2987 change to be tidy.
2988
2989 HE* hv_iternext_flags(HV *hv, I32 flags)
2990
2991 hv_iterval
2992 Returns the value from the current position of the hash
2993 iterator. See "hv_iterkey".
2994
2995 SV* hv_iterval(HV *hv, HE *entry)
2996
2997 hv_magic
2998 Adds magic to a hash. See "sv_magic".
2999
3000 void hv_magic(HV *hv, GV *gv, int how)
3001
3002 HvNAME Returns the package name of a stash, or "NULL" if "stash" isn't
3003 a stash. See "SvSTASH", "CvSTASH".
3004
3005 char* HvNAME(HV* stash)
3006
3007 HvNAMELEN
3008 Returns the length of the stash's name.
3009
3010 STRLEN HvNAMELEN(HV *stash)
3011
3012 HvNAMEUTF8
3013 Returns true if the name is in UTF-8 encoding.
3014
3015 unsigned char HvNAMEUTF8(HV *stash)
3016
3017 hv_scalar
3018 Evaluates the hash in scalar context and returns the result.
3019
3020 When the hash is tied dispatches through to the SCALAR method,
3021 otherwise returns a mortal SV containing the number of keys in
3022 the hash.
3023
3024 Note, prior to 5.25 this function returned what is now returned
3025 by the hv_bucket_ratio() function.
3026
3027 SV* hv_scalar(HV *hv)
3028
3029 hv_store
3030 Stores an SV in a hash. The hash key is specified as "key" and
3031 the absolute value of "klen" is the length of the key. If
3032 "klen" is negative the key is assumed to be in UTF-8-encoded
3033 Unicode. The "hash" parameter is the precomputed hash value;
3034 if it is zero then Perl will compute it.
3035
3036 The return value will be "NULL" if the operation failed or if
3037 the value did not need to be actually stored within the hash
3038 (as in the case of tied hashes). Otherwise it can be
3039 dereferenced to get the original "SV*". Note that the caller
3040 is responsible for suitably incrementing the reference count of
3041 "val" before the call, and decrementing it if the function
3042 returned "NULL". Effectively a successful "hv_store" takes
3043 ownership of one reference to "val". This is usually what you
3044 want; a newly created SV has a reference count of one, so if
3045 all your code does is create SVs then store them in a hash,
3046 "hv_store" will own the only reference to the new SV, and your
3047 code doesn't need to do anything further to tidy up.
3048 "hv_store" is not implemented as a call to "hv_store_ent", and
3049 does not create a temporary SV for the key, so if your key data
3050 is not already in SV form then use "hv_store" in preference to
3051 "hv_store_ent".
3052
3053 See "Understanding the Magic of Tied Hashes and Arrays" in
3054 perlguts for more information on how to use this function on
3055 tied hashes.
3056
3057 SV** hv_store(HV *hv, const char *key, I32 klen,
3058 SV *val, U32 hash)
3059
3060 hv_stores
3061 Like "hv_store", but takes a literal string instead of a
3062 string/length pair and omits the hash parameter.
3063
3064 SV** hv_stores(HV* tb, "literal string" key, SV* val)
3065
3066 hv_store_ent
3067 Stores "val" in a hash. The hash key is specified as "key".
3068 The "hash" parameter is the precomputed hash value; if it is
3069 zero then Perl will compute it. The return value is the new
3070 hash entry so created. It will be "NULL" if the operation
3071 failed or if the value did not need to be actually stored
3072 within the hash (as in the case of tied hashes). Otherwise the
3073 contents of the return value can be accessed using the "He?"
3074 macros described here. Note that the caller is responsible for
3075 suitably incrementing the reference count of "val" before the
3076 call, and decrementing it if the function returned NULL.
3077 Effectively a successful "hv_store_ent" takes ownership of one
3078 reference to "val". This is usually what you want; a newly
3079 created SV has a reference count of one, so if all your code
3080 does is create SVs then store them in a hash, "hv_store" will
3081 own the only reference to the new SV, and your code doesn't
3082 need to do anything further to tidy up. Note that
3083 "hv_store_ent" only reads the "key"; unlike "val" it does not
3084 take ownership of it, so maintaining the correct reference
3085 count on "key" is entirely the caller's responsibility.
3086 "hv_store" is not implemented as a call to "hv_store_ent", and
3087 does not create a temporary SV for the key, so if your key data
3088 is not already in SV form then use "hv_store" in preference to
3089 "hv_store_ent".
3090
3091 See "Understanding the Magic of Tied Hashes and Arrays" in
3092 perlguts for more information on how to use this function on
3093 tied hashes.
3094
3095 HE* hv_store_ent(HV *hv, SV *key, SV *val, U32 hash)
3096
3097 hv_undef
3098 Undefines the hash. The XS equivalent of "undef(%hash)".
3099
3100 As well as freeing all the elements of the hash (like
3101 "hv_clear()"), this also frees any auxiliary data and storage
3102 associated with the hash.
3103
3104 See "av_clear" for a note about the hash possibly being invalid
3105 on return.
3106
3107 void hv_undef(HV *hv)
3108
3109 newHV Creates a new HV. The reference count is set to 1.
3110
3111 HV* newHV()
3112
3114 These functions provide convenient and thread-safe means of
3115 manipulating hook variables.
3116
3117 wrap_op_checker
3118 Puts a C function into the chain of check functions for a
3119 specified op type. This is the preferred way to manipulate the
3120 "PL_check" array. "opcode" specifies which type of op is to be
3121 affected. "new_checker" is a pointer to the C function that is
3122 to be added to that opcode's check chain, and "old_checker_p"
3123 points to the storage location where a pointer to the next
3124 function in the chain will be stored. The value of
3125 "new_checker" is written into the "PL_check" array, while the
3126 value previously stored there is written to *old_checker_p.
3127
3128 "PL_check" is global to an entire process, and a module wishing
3129 to hook op checking may find itself invoked more than once per
3130 process, typically in different threads. To handle that
3131 situation, this function is idempotent. The location
3132 *old_checker_p must initially (once per process) contain a null
3133 pointer. A C variable of static duration (declared at file
3134 scope, typically also marked "static" to give it internal
3135 linkage) will be implicitly initialised appropriately, if it
3136 does not have an explicit initialiser. This function will only
3137 actually modify the check chain if it finds *old_checker_p to
3138 be null. This function is also thread safe on the small scale.
3139 It uses appropriate locking to avoid race conditions in
3140 accessing "PL_check".
3141
3142 When this function is called, the function referenced by
3143 "new_checker" must be ready to be called, except for
3144 *old_checker_p being unfilled. In a threading situation,
3145 "new_checker" may be called immediately, even before this
3146 function has returned. *old_checker_p will always be
3147 appropriately set before "new_checker" is called. If
3148 "new_checker" decides not to do anything special with an op
3149 that it is given (which is the usual case for most uses of op
3150 check hooking), it must chain the check function referenced by
3151 *old_checker_p.
3152
3153 Taken all together, XS code to hook an op checker should
3154 typically look something like this:
3155
3156 static Perl_check_t nxck_frob;
3157 static OP *myck_frob(pTHX_ OP *op) {
3158 ...
3159 op = nxck_frob(aTHX_ op);
3160 ...
3161 return op;
3162 }
3163 BOOT:
3164 wrap_op_checker(OP_FROB, myck_frob, &nxck_frob);
3165
3166 If you want to influence compilation of calls to a specific
3167 subroutine, then use "cv_set_call_checker_flags" rather than
3168 hooking checking of all "entersub" ops.
3169
3170 void wrap_op_checker(Optype opcode,
3171 Perl_check_t new_checker,
3172 Perl_check_t *old_checker_p)
3173
3175 This is the lower layer of the Perl parser, managing characters and
3176 tokens.
3177
3178 lex_bufutf8
3179 NOTE: this function is experimental and may change or be
3180 removed without notice.
3181
3182 Indicates whether the octets in the lexer buffer
3183 ("PL_parser->linestr") should be interpreted as the UTF-8
3184 encoding of Unicode characters. If not, they should be
3185 interpreted as Latin-1 characters. This is analogous to the
3186 "SvUTF8" flag for scalars.
3187
3188 In UTF-8 mode, it is not guaranteed that the lexer buffer
3189 actually contains valid UTF-8. Lexing code must be robust in
3190 the face of invalid encoding.
3191
3192 The actual "SvUTF8" flag of the "PL_parser->linestr" scalar is
3193 significant, but not the whole story regarding the input
3194 character encoding. Normally, when a file is being read, the
3195 scalar contains octets and its "SvUTF8" flag is off, but the
3196 octets should be interpreted as UTF-8 if the "use utf8" pragma
3197 is in effect. During a string eval, however, the scalar may
3198 have the "SvUTF8" flag on, and in this case its octets should
3199 be interpreted as UTF-8 unless the "use bytes" pragma is in
3200 effect. This logic may change in the future; use this function
3201 instead of implementing the logic yourself.
3202
3203 bool lex_bufutf8()
3204
3205 lex_discard_to
3206 NOTE: this function is experimental and may change or be
3207 removed without notice.
3208
3209 Discards the first part of the "PL_parser->linestr" buffer, up
3210 to "ptr". The remaining content of the buffer will be moved,
3211 and all pointers into the buffer updated appropriately. "ptr"
3212 must not be later in the buffer than the position of
3213 "PL_parser->bufptr": it is not permitted to discard text that
3214 has yet to be lexed.
3215
3216 Normally it is not necessarily to do this directly, because it
3217 suffices to use the implicit discarding behaviour of
3218 "lex_next_chunk" and things based on it. However, if a token
3219 stretches across multiple lines, and the lexing code has kept
3220 multiple lines of text in the buffer for that purpose, then
3221 after completion of the token it would be wise to explicitly
3222 discard the now-unneeded earlier lines, to avoid future multi-
3223 line tokens growing the buffer without bound.
3224
3225 void lex_discard_to(char *ptr)
3226
3227 lex_grow_linestr
3228 NOTE: this function is experimental and may change or be
3229 removed without notice.
3230
3231 Reallocates the lexer buffer ("PL_parser->linestr") to
3232 accommodate at least "len" octets (including terminating
3233 "NUL"). Returns a pointer to the reallocated buffer. This is
3234 necessary before making any direct modification of the buffer
3235 that would increase its length. "lex_stuff_pvn" provides a
3236 more convenient way to insert text into the buffer.
3237
3238 Do not use "SvGROW" or "sv_grow" directly on
3239 "PL_parser->linestr"; this function updates all of the lexer's
3240 variables that point directly into the buffer.
3241
3242 char * lex_grow_linestr(STRLEN len)
3243
3244 lex_next_chunk
3245 NOTE: this function is experimental and may change or be
3246 removed without notice.
3247
3248 Reads in the next chunk of text to be lexed, appending it to
3249 "PL_parser->linestr". This should be called when lexing code
3250 has looked to the end of the current chunk and wants to know
3251 more. It is usual, but not necessary, for lexing to have
3252 consumed the entirety of the current chunk at this time.
3253
3254 If "PL_parser->bufptr" is pointing to the very end of the
3255 current chunk (i.e., the current chunk has been entirely
3256 consumed), normally the current chunk will be discarded at the
3257 same time that the new chunk is read in. If "flags" has the
3258 "LEX_KEEP_PREVIOUS" bit set, the current chunk will not be
3259 discarded. If the current chunk has not been entirely
3260 consumed, then it will not be discarded regardless of the flag.
3261
3262 Returns true if some new text was added to the buffer, or false
3263 if the buffer has reached the end of the input text.
3264
3265 bool lex_next_chunk(U32 flags)
3266
3267 lex_peek_unichar
3268 NOTE: this function is experimental and may change or be
3269 removed without notice.
3270
3271 Looks ahead one (Unicode) character in the text currently being
3272 lexed. Returns the codepoint (unsigned integer value) of the
3273 next character, or -1 if lexing has reached the end of the
3274 input text. To consume the peeked character, use
3275 "lex_read_unichar".
3276
3277 If the next character is in (or extends into) the next chunk of
3278 input text, the next chunk will be read in. Normally the
3279 current chunk will be discarded at the same time, but if
3280 "flags" has the "LEX_KEEP_PREVIOUS" bit set, then the current
3281 chunk will not be discarded.
3282
3283 If the input is being interpreted as UTF-8 and a UTF-8 encoding
3284 error is encountered, an exception is generated.
3285
3286 I32 lex_peek_unichar(U32 flags)
3287
3288 lex_read_space
3289 NOTE: this function is experimental and may change or be
3290 removed without notice.
3291
3292 Reads optional spaces, in Perl style, in the text currently
3293 being lexed. The spaces may include ordinary whitespace
3294 characters and Perl-style comments. "#line" directives are
3295 processed if encountered. "PL_parser->bufptr" is moved past
3296 the spaces, so that it points at a non-space character (or the
3297 end of the input text).
3298
3299 If spaces extend into the next chunk of input text, the next
3300 chunk will be read in. Normally the current chunk will be
3301 discarded at the same time, but if "flags" has the
3302 "LEX_KEEP_PREVIOUS" bit set, then the current chunk will not be
3303 discarded.
3304
3305 void lex_read_space(U32 flags)
3306
3307 lex_read_to
3308 NOTE: this function is experimental and may change or be
3309 removed without notice.
3310
3311 Consume text in the lexer buffer, from "PL_parser->bufptr" up
3312 to "ptr". This advances "PL_parser->bufptr" to match "ptr",
3313 performing the correct bookkeeping whenever a newline character
3314 is passed. This is the normal way to consume lexed text.
3315
3316 Interpretation of the buffer's octets can be abstracted out by
3317 using the slightly higher-level functions "lex_peek_unichar"
3318 and "lex_read_unichar".
3319
3320 void lex_read_to(char *ptr)
3321
3322 lex_read_unichar
3323 NOTE: this function is experimental and may change or be
3324 removed without notice.
3325
3326 Reads the next (Unicode) character in the text currently being
3327 lexed. Returns the codepoint (unsigned integer value) of the
3328 character read, and moves "PL_parser->bufptr" past the
3329 character, or returns -1 if lexing has reached the end of the
3330 input text. To non-destructively examine the next character,
3331 use "lex_peek_unichar" instead.
3332
3333 If the next character is in (or extends into) the next chunk of
3334 input text, the next chunk will be read in. Normally the
3335 current chunk will be discarded at the same time, but if
3336 "flags" has the "LEX_KEEP_PREVIOUS" bit set, then the current
3337 chunk will not be discarded.
3338
3339 If the input is being interpreted as UTF-8 and a UTF-8 encoding
3340 error is encountered, an exception is generated.
3341
3342 I32 lex_read_unichar(U32 flags)
3343
3344 lex_start
3345 NOTE: this function is experimental and may change or be
3346 removed without notice.
3347
3348 Creates and initialises a new lexer/parser state object,
3349 supplying a context in which to lex and parse from a new source
3350 of Perl code. A pointer to the new state object is placed in
3351 "PL_parser". An entry is made on the save stack so that upon
3352 unwinding, the new state object will be destroyed and the
3353 former value of "PL_parser" will be restored. Nothing else
3354 need be done to clean up the parsing context.
3355
3356 The code to be parsed comes from "line" and "rsfp". "line", if
3357 non-null, provides a string (in SV form) containing code to be
3358 parsed. A copy of the string is made, so subsequent
3359 modification of "line" does not affect parsing. "rsfp", if
3360 non-null, provides an input stream from which code will be read
3361 to be parsed. If both are non-null, the code in "line" comes
3362 first and must consist of complete lines of input, and "rsfp"
3363 supplies the remainder of the source.
3364
3365 The "flags" parameter is reserved for future use. Currently it
3366 is only used by perl internally, so extensions should always
3367 pass zero.
3368
3369 void lex_start(SV *line, PerlIO *rsfp, U32 flags)
3370
3371 lex_stuff_pv
3372 NOTE: this function is experimental and may change or be
3373 removed without notice.
3374
3375 Insert characters into the lexer buffer ("PL_parser->linestr"),
3376 immediately after the current lexing point
3377 ("PL_parser->bufptr"), reallocating the buffer if necessary.
3378 This means that lexing code that runs later will see the
3379 characters as if they had appeared in the input. It is not
3380 recommended to do this as part of normal parsing, and most uses
3381 of this facility run the risk of the inserted characters being
3382 interpreted in an unintended manner.
3383
3384 The string to be inserted is represented by octets starting at
3385 "pv" and continuing to the first nul. These octets are
3386 interpreted as either UTF-8 or Latin-1, according to whether
3387 the "LEX_STUFF_UTF8" flag is set in "flags". The characters
3388 are recoded for the lexer buffer, according to how the buffer
3389 is currently being interpreted ("lex_bufutf8"). If it is not
3390 convenient to nul-terminate a string to be inserted, the
3391 "lex_stuff_pvn" function is more appropriate.
3392
3393 void lex_stuff_pv(const char *pv, U32 flags)
3394
3395 lex_stuff_pvn
3396 NOTE: this function is experimental and may change or be
3397 removed without notice.
3398
3399 Insert characters into the lexer buffer ("PL_parser->linestr"),
3400 immediately after the current lexing point
3401 ("PL_parser->bufptr"), reallocating the buffer if necessary.
3402 This means that lexing code that runs later will see the
3403 characters as if they had appeared in the input. It is not
3404 recommended to do this as part of normal parsing, and most uses
3405 of this facility run the risk of the inserted characters being
3406 interpreted in an unintended manner.
3407
3408 The string to be inserted is represented by "len" octets
3409 starting at "pv". These octets are interpreted as either UTF-8
3410 or Latin-1, according to whether the "LEX_STUFF_UTF8" flag is
3411 set in "flags". The characters are recoded for the lexer
3412 buffer, according to how the buffer is currently being
3413 interpreted ("lex_bufutf8"). If a string to be inserted is
3414 available as a Perl scalar, the "lex_stuff_sv" function is more
3415 convenient.
3416
3417 void lex_stuff_pvn(const char *pv, STRLEN len,
3418 U32 flags)
3419
3420 lex_stuff_pvs
3421 NOTE: this function is experimental and may change or be
3422 removed without notice.
3423
3424 Like "lex_stuff_pvn", but takes a literal string instead of a
3425 string/length pair.
3426
3427 void lex_stuff_pvs("literal string" pv, U32 flags)
3428
3429 lex_stuff_sv
3430 NOTE: this function is experimental and may change or be
3431 removed without notice.
3432
3433 Insert characters into the lexer buffer ("PL_parser->linestr"),
3434 immediately after the current lexing point
3435 ("PL_parser->bufptr"), reallocating the buffer if necessary.
3436 This means that lexing code that runs later will see the
3437 characters as if they had appeared in the input. It is not
3438 recommended to do this as part of normal parsing, and most uses
3439 of this facility run the risk of the inserted characters being
3440 interpreted in an unintended manner.
3441
3442 The string to be inserted is the string value of "sv". The
3443 characters are recoded for the lexer buffer, according to how
3444 the buffer is currently being interpreted ("lex_bufutf8"). If
3445 a string to be inserted is not already a Perl scalar, the
3446 "lex_stuff_pvn" function avoids the need to construct a scalar.
3447
3448 void lex_stuff_sv(SV *sv, U32 flags)
3449
3450 lex_unstuff
3451 NOTE: this function is experimental and may change or be
3452 removed without notice.
3453
3454 Discards text about to be lexed, from "PL_parser->bufptr" up to
3455 "ptr". Text following "ptr" will be moved, and the buffer
3456 shortened. This hides the discarded text from any lexing code
3457 that runs later, as if the text had never appeared.
3458
3459 This is not the normal way to consume lexed text. For that,
3460 use "lex_read_to".
3461
3462 void lex_unstuff(char *ptr)
3463
3464 parse_arithexpr
3465 NOTE: this function is experimental and may change or be
3466 removed without notice.
3467
3468 Parse a Perl arithmetic expression. This may contain operators
3469 of precedence down to the bit shift operators. The expression
3470 must be followed (and thus terminated) either by a comparison
3471 or lower-precedence operator or by something that would
3472 normally terminate an expression such as semicolon. If "flags"
3473 has the "PARSE_OPTIONAL" bit set, then the expression is
3474 optional, otherwise it is mandatory. It is up to the caller to
3475 ensure that the dynamic parser state ("PL_parser" et al) is
3476 correctly set to reflect the source of the code to be parsed
3477 and the lexical context for the expression.
3478
3479 The op tree representing the expression is returned. If an
3480 optional expression is absent, a null pointer is returned,
3481 otherwise the pointer will be non-null.
3482
3483 If an error occurs in parsing or compilation, in most cases a
3484 valid op tree is returned anyway. The error is reflected in
3485 the parser state, normally resulting in a single exception at
3486 the top level of parsing which covers all the compilation
3487 errors that occurred. Some compilation errors, however, will
3488 throw an exception immediately.
3489
3490 OP * parse_arithexpr(U32 flags)
3491
3492 parse_barestmt
3493 NOTE: this function is experimental and may change or be
3494 removed without notice.
3495
3496 Parse a single unadorned Perl statement. This may be a normal
3497 imperative statement or a declaration that has compile-time
3498 effect. It does not include any label or other affixture. It
3499 is up to the caller to ensure that the dynamic parser state
3500 ("PL_parser" et al) is correctly set to reflect the source of
3501 the code to be parsed and the lexical context for the
3502 statement.
3503
3504 The op tree representing the statement is returned. This may
3505 be a null pointer if the statement is null, for example if it
3506 was actually a subroutine definition (which has compile-time
3507 side effects). If not null, it will be ops directly
3508 implementing the statement, suitable to pass to "newSTATEOP".
3509 It will not normally include a "nextstate" or equivalent op
3510 (except for those embedded in a scope contained entirely within
3511 the statement).
3512
3513 If an error occurs in parsing or compilation, in most cases a
3514 valid op tree (most likely null) is returned anyway. The error
3515 is reflected in the parser state, normally resulting in a
3516 single exception at the top level of parsing which covers all
3517 the compilation errors that occurred. Some compilation errors,
3518 however, will throw an exception immediately.
3519
3520 The "flags" parameter is reserved for future use, and must
3521 always be zero.
3522
3523 OP * parse_barestmt(U32 flags)
3524
3525 parse_block
3526 NOTE: this function is experimental and may change or be
3527 removed without notice.
3528
3529 Parse a single complete Perl code block. This consists of an
3530 opening brace, a sequence of statements, and a closing brace.
3531 The block constitutes a lexical scope, so "my" variables and
3532 various compile-time effects can be contained within it. It is
3533 up to the caller to ensure that the dynamic parser state
3534 ("PL_parser" et al) is correctly set to reflect the source of
3535 the code to be parsed and the lexical context for the
3536 statement.
3537
3538 The op tree representing the code block is returned. This is
3539 always a real op, never a null pointer. It will normally be a
3540 "lineseq" list, including "nextstate" or equivalent ops. No
3541 ops to construct any kind of runtime scope are included by
3542 virtue of it being a block.
3543
3544 If an error occurs in parsing or compilation, in most cases a
3545 valid op tree (most likely null) is returned anyway. The error
3546 is reflected in the parser state, normally resulting in a
3547 single exception at the top level of parsing which covers all
3548 the compilation errors that occurred. Some compilation errors,
3549 however, will throw an exception immediately.
3550
3551 The "flags" parameter is reserved for future use, and must
3552 always be zero.
3553
3554 OP * parse_block(U32 flags)
3555
3556 parse_fullexpr
3557 NOTE: this function is experimental and may change or be
3558 removed without notice.
3559
3560 Parse a single complete Perl expression. This allows the full
3561 expression grammar, including the lowest-precedence operators
3562 such as "or". The expression must be followed (and thus
3563 terminated) by a token that an expression would normally be
3564 terminated by: end-of-file, closing bracketing punctuation,
3565 semicolon, or one of the keywords that signals a postfix
3566 expression-statement modifier. If "flags" has the
3567 "PARSE_OPTIONAL" bit set, then the expression is optional,
3568 otherwise it is mandatory. It is up to the caller to ensure
3569 that the dynamic parser state ("PL_parser" et al) is correctly
3570 set to reflect the source of the code to be parsed and the
3571 lexical context for the expression.
3572
3573 The op tree representing the expression is returned. If an
3574 optional expression is absent, a null pointer is returned,
3575 otherwise the pointer will be non-null.
3576
3577 If an error occurs in parsing or compilation, in most cases a
3578 valid op tree is returned anyway. The error is reflected in
3579 the parser state, normally resulting in a single exception at
3580 the top level of parsing which covers all the compilation
3581 errors that occurred. Some compilation errors, however, will
3582 throw an exception immediately.
3583
3584 OP * parse_fullexpr(U32 flags)
3585
3586 parse_fullstmt
3587 NOTE: this function is experimental and may change or be
3588 removed without notice.
3589
3590 Parse a single complete Perl statement. This may be a normal
3591 imperative statement or a declaration that has compile-time
3592 effect, and may include optional labels. It is up to the
3593 caller to ensure that the dynamic parser state ("PL_parser" et
3594 al) is correctly set to reflect the source of the code to be
3595 parsed and the lexical context for the statement.
3596
3597 The op tree representing the statement is returned. This may
3598 be a null pointer if the statement is null, for example if it
3599 was actually a subroutine definition (which has compile-time
3600 side effects). If not null, it will be the result of a
3601 "newSTATEOP" call, normally including a "nextstate" or
3602 equivalent op.
3603
3604 If an error occurs in parsing or compilation, in most cases a
3605 valid op tree (most likely null) is returned anyway. The error
3606 is reflected in the parser state, normally resulting in a
3607 single exception at the top level of parsing which covers all
3608 the compilation errors that occurred. Some compilation errors,
3609 however, will throw an exception immediately.
3610
3611 The "flags" parameter is reserved for future use, and must
3612 always be zero.
3613
3614 OP * parse_fullstmt(U32 flags)
3615
3616 parse_label
3617 NOTE: this function is experimental and may change or be
3618 removed without notice.
3619
3620 Parse a single label, possibly optional, of the type that may
3621 prefix a Perl statement. It is up to the caller to ensure that
3622 the dynamic parser state ("PL_parser" et al) is correctly set
3623 to reflect the source of the code to be parsed. If "flags" has
3624 the "PARSE_OPTIONAL" bit set, then the label is optional,
3625 otherwise it is mandatory.
3626
3627 The name of the label is returned in the form of a fresh
3628 scalar. If an optional label is absent, a null pointer is
3629 returned.
3630
3631 If an error occurs in parsing, which can only occur if the
3632 label is mandatory, a valid label is returned anyway. The
3633 error is reflected in the parser state, normally resulting in a
3634 single exception at the top level of parsing which covers all
3635 the compilation errors that occurred.
3636
3637 SV * parse_label(U32 flags)
3638
3639 parse_listexpr
3640 NOTE: this function is experimental and may change or be
3641 removed without notice.
3642
3643 Parse a Perl list expression. This may contain operators of
3644 precedence down to the comma operator. The expression must be
3645 followed (and thus terminated) either by a low-precedence logic
3646 operator such as "or" or by something that would normally
3647 terminate an expression such as semicolon. If "flags" has the
3648 "PARSE_OPTIONAL" bit set, then the expression is optional,
3649 otherwise it is mandatory. It is up to the caller to ensure
3650 that the dynamic parser state ("PL_parser" et al) is correctly
3651 set to reflect the source of the code to be parsed and the
3652 lexical context for the expression.
3653
3654 The op tree representing the expression is returned. If an
3655 optional expression is absent, a null pointer is returned,
3656 otherwise the pointer will be non-null.
3657
3658 If an error occurs in parsing or compilation, in most cases a
3659 valid op tree is returned anyway. The error is reflected in
3660 the parser state, normally resulting in a single exception at
3661 the top level of parsing which covers all the compilation
3662 errors that occurred. Some compilation errors, however, will
3663 throw an exception immediately.
3664
3665 OP * parse_listexpr(U32 flags)
3666
3667 parse_stmtseq
3668 NOTE: this function is experimental and may change or be
3669 removed without notice.
3670
3671 Parse a sequence of zero or more Perl statements. These may be
3672 normal imperative statements, including optional labels, or
3673 declarations that have compile-time effect, or any mixture
3674 thereof. The statement sequence ends when a closing brace or
3675 end-of-file is encountered in a place where a new statement
3676 could have validly started. It is up to the caller to ensure
3677 that the dynamic parser state ("PL_parser" et al) is correctly
3678 set to reflect the source of the code to be parsed and the
3679 lexical context for the statements.
3680
3681 The op tree representing the statement sequence is returned.
3682 This may be a null pointer if the statements were all null, for
3683 example if there were no statements or if there were only
3684 subroutine definitions (which have compile-time side effects).
3685 If not null, it will be a "lineseq" list, normally including
3686 "nextstate" or equivalent ops.
3687
3688 If an error occurs in parsing or compilation, in most cases a
3689 valid op tree is returned anyway. The error is reflected in
3690 the parser state, normally resulting in a single exception at
3691 the top level of parsing which covers all the compilation
3692 errors that occurred. Some compilation errors, however, will
3693 throw an exception immediately.
3694
3695 The "flags" parameter is reserved for future use, and must
3696 always be zero.
3697
3698 OP * parse_stmtseq(U32 flags)
3699
3700 parse_termexpr
3701 NOTE: this function is experimental and may change or be
3702 removed without notice.
3703
3704 Parse a Perl term expression. This may contain operators of
3705 precedence down to the assignment operators. The expression
3706 must be followed (and thus terminated) either by a comma or
3707 lower-precedence operator or by something that would normally
3708 terminate an expression such as semicolon. If "flags" has the
3709 "PARSE_OPTIONAL" bit set, then the expression is optional,
3710 otherwise it is mandatory. It is up to the caller to ensure
3711 that the dynamic parser state ("PL_parser" et al) is correctly
3712 set to reflect the source of the code to be parsed and the
3713 lexical context for the expression.
3714
3715 The op tree representing the expression is returned. If an
3716 optional expression is absent, a null pointer is returned,
3717 otherwise the pointer will be non-null.
3718
3719 If an error occurs in parsing or compilation, in most cases a
3720 valid op tree is returned anyway. The error is reflected in
3721 the parser state, normally resulting in a single exception at
3722 the top level of parsing which covers all the compilation
3723 errors that occurred. Some compilation errors, however, will
3724 throw an exception immediately.
3725
3726 OP * parse_termexpr(U32 flags)
3727
3728 PL_parser
3729 Pointer to a structure encapsulating the state of the parsing
3730 operation currently in progress. The pointer can be locally
3731 changed to perform a nested parse without interfering with the
3732 state of an outer parse. Individual members of "PL_parser"
3733 have their own documentation.
3734
3735 PL_parser->bufend
3736 NOTE: this function is experimental and may change or be
3737 removed without notice.
3738
3739 Direct pointer to the end of the chunk of text currently being
3740 lexed, the end of the lexer buffer. This is equal to
3741 "SvPVX(PL_parser->linestr) + SvCUR(PL_parser->linestr)". A
3742 "NUL" character (zero octet) is always located at the end of
3743 the buffer, and does not count as part of the buffer's
3744 contents.
3745
3746 PL_parser->bufptr
3747 NOTE: this function is experimental and may change or be
3748 removed without notice.
3749
3750 Points to the current position of lexing inside the lexer
3751 buffer. Characters around this point may be freely examined,
3752 within the range delimited by "SvPVX("PL_parser->linestr")" and
3753 "PL_parser->bufend". The octets of the buffer may be intended
3754 to be interpreted as either UTF-8 or Latin-1, as indicated by
3755 "lex_bufutf8".
3756
3757 Lexing code (whether in the Perl core or not) moves this
3758 pointer past the characters that it consumes. It is also
3759 expected to perform some bookkeeping whenever a newline
3760 character is consumed. This movement can be more conveniently
3761 performed by the function "lex_read_to", which handles newlines
3762 appropriately.
3763
3764 Interpretation of the buffer's octets can be abstracted out by
3765 using the slightly higher-level functions "lex_peek_unichar"
3766 and "lex_read_unichar".
3767
3768 PL_parser->linestart
3769 NOTE: this function is experimental and may change or be
3770 removed without notice.
3771
3772 Points to the start of the current line inside the lexer
3773 buffer. This is useful for indicating at which column an error
3774 occurred, and not much else. This must be updated by any
3775 lexing code that consumes a newline; the function "lex_read_to"
3776 handles this detail.
3777
3778 PL_parser->linestr
3779 NOTE: this function is experimental and may change or be
3780 removed without notice.
3781
3782 Buffer scalar containing the chunk currently under
3783 consideration of the text currently being lexed. This is
3784 always a plain string scalar (for which "SvPOK" is true). It
3785 is not intended to be used as a scalar by normal scalar means;
3786 instead refer to the buffer directly by the pointer variables
3787 described below.
3788
3789 The lexer maintains various "char*" pointers to things in the
3790 "PL_parser->linestr" buffer. If "PL_parser->linestr" is ever
3791 reallocated, all of these pointers must be updated. Don't
3792 attempt to do this manually, but rather use "lex_grow_linestr"
3793 if you need to reallocate the buffer.
3794
3795 The content of the text chunk in the buffer is commonly exactly
3796 one complete line of input, up to and including a newline
3797 terminator, but there are situations where it is otherwise.
3798 The octets of the buffer may be intended to be interpreted as
3799 either UTF-8 or Latin-1. The function "lex_bufutf8" tells you
3800 which. Do not use the "SvUTF8" flag on this scalar, which may
3801 disagree with it.
3802
3803 For direct examination of the buffer, the variable
3804 "PL_parser->bufend" points to the end of the buffer. The
3805 current lexing position is pointed to by "PL_parser->bufptr".
3806 Direct use of these pointers is usually preferable to
3807 examination of the scalar through normal scalar means.
3808
3809 wrap_keyword_plugin
3810 NOTE: this function is experimental and may change or be
3811 removed without notice.
3812
3813 Puts a C function into the chain of keyword plugins. This is
3814 the preferred way to manipulate the "PL_keyword_plugin"
3815 variable. "new_plugin" is a pointer to the C function that is
3816 to be added to the keyword plugin chain, and "old_plugin_p"
3817 points to the storage location where a pointer to the next
3818 function in the chain will be stored. The value of
3819 "new_plugin" is written into the "PL_keyword_plugin" variable,
3820 while the value previously stored there is written to
3821 *old_plugin_p.
3822
3823 "PL_keyword_plugin" is global to an entire process, and a
3824 module wishing to hook keyword parsing may find itself invoked
3825 more than once per process, typically in different threads. To
3826 handle that situation, this function is idempotent. The
3827 location *old_plugin_p must initially (once per process)
3828 contain a null pointer. A C variable of static duration
3829 (declared at file scope, typically also marked "static" to give
3830 it internal linkage) will be implicitly initialised
3831 appropriately, if it does not have an explicit initialiser.
3832 This function will only actually modify the plugin chain if it
3833 finds *old_plugin_p to be null. This function is also thread
3834 safe on the small scale. It uses appropriate locking to avoid
3835 race conditions in accessing "PL_keyword_plugin".
3836
3837 When this function is called, the function referenced by
3838 "new_plugin" must be ready to be called, except for
3839 *old_plugin_p being unfilled. In a threading situation,
3840 "new_plugin" may be called immediately, even before this
3841 function has returned. *old_plugin_p will always be
3842 appropriately set before "new_plugin" is called. If
3843 "new_plugin" decides not to do anything special with the
3844 identifier that it is given (which is the usual case for most
3845 calls to a keyword plugin), it must chain the plugin function
3846 referenced by *old_plugin_p.
3847
3848 Taken all together, XS code to install a keyword plugin should
3849 typically look something like this:
3850
3851 static Perl_keyword_plugin_t next_keyword_plugin;
3852 static OP *my_keyword_plugin(pTHX_
3853 char *keyword_plugin, STRLEN keyword_len, OP **op_ptr)
3854 {
3855 if (memEQs(keyword_ptr, keyword_len,
3856 "my_new_keyword")) {
3857 ...
3858 } else {
3859 return next_keyword_plugin(aTHX_
3860 keyword_ptr, keyword_len, op_ptr);
3861 }
3862 }
3863 BOOT:
3864 wrap_keyword_plugin(my_keyword_plugin,
3865 &next_keyword_plugin);
3866
3867 Direct access to "PL_keyword_plugin" should be avoided.
3868
3869 void wrap_keyword_plugin(
3870 Perl_keyword_plugin_t new_plugin,
3871 Perl_keyword_plugin_t *old_plugin_p
3872 )
3873
3875 DECLARATION_FOR_LC_NUMERIC_MANIPULATION
3876 This macro should be used as a statement. It declares a
3877 private variable (whose name begins with an underscore) that is
3878 needed by the other macros in this section. Failing to include
3879 this correctly should lead to a syntax error. For
3880 compatibility with C89 C compilers it should be placed in a
3881 block before any executable statements.
3882
3883 void DECLARATION_FOR_LC_NUMERIC_MANIPULATION
3884
3885 Perl_langinfo
3886 This is an (almost) drop-in replacement for the system
3887 nl_langinfo(3), taking the same "item" parameter values, and
3888 returning the same information. But it is more thread-safe
3889 than regular "nl_langinfo()", and hides the quirks of Perl's
3890 locale handling from your code, and can be used on systems that
3891 lack a native "nl_langinfo".
3892
3893 Expanding on these:
3894
3895 · The reason it isn't quite a drop-in replacement is actually
3896 an advantage. The only difference is that it returns
3897 "const char *", whereas plain "nl_langinfo()" returns
3898 "char *", but you are (only by documentation) forbidden to
3899 write into the buffer. By declaring this "const", the
3900 compiler enforces this restriction, so if it is violated,
3901 you know at compilation time, rather than getting segfaults
3902 at runtime.
3903
3904 · It delivers the correct results for the "RADIXCHAR" and
3905 "THOUSEP" items, without you having to write extra code.
3906 The reason for the extra code would be because these are
3907 from the "LC_NUMERIC" locale category, which is normally
3908 kept set by Perl so that the radix is a dot, and the
3909 separator is the empty string, no matter what the
3910 underlying locale is supposed to be, and so to get the
3911 expected results, you have to temporarily toggle into the
3912 underlying locale, and later toggle back. (You could use
3913 plain "nl_langinfo" and
3914 "STORE_LC_NUMERIC_FORCE_TO_UNDERLYING" for this but then
3915 you wouldn't get the other advantages of "Perl_langinfo()";
3916 not keeping "LC_NUMERIC" in the C (or equivalent) locale
3917 would break a lot of CPAN, which is expecting the radix
3918 (decimal point) character to be a dot.)
3919
3920 · The system function it replaces can have its static return
3921 buffer trashed, not only by a subesequent call to that
3922 function, but by a "freelocale", "setlocale", or other
3923 locale change. The returned buffer of this function is not
3924 changed until the next call to it, so the buffer is never
3925 in a trashed state.
3926
3927 · Its return buffer is per-thread, so it also is never
3928 overwritten by a call to this function from another thread;
3929 unlike the function it replaces.
3930
3931 · But most importantly, it works on systems that don't have
3932 "nl_langinfo", such as Windows, hence makes your code more
3933 portable. Of the fifty-some possible items specified by
3934 the POSIX 2008 standard,
3935 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>,
3936 only one is completely unimplemented, though on non-Windows
3937 platforms, another significant one is also not
3938 implemented). It uses various techniques to recover the
3939 other items, including calling localeconv(3), and
3940 strftime(3), both of which are specified in C89, so should
3941 be always be available. Later "strftime()" versions have
3942 additional capabilities; "" is returned for those not
3943 available on your system.
3944
3945 It is important to note that when called with an item that
3946 is recovered by using "localeconv", the buffer from any
3947 previous explicit call to "localeconv" will be overwritten.
3948 This means you must save that buffer's contents if you need
3949 to access them after a call to this function. (But note
3950 that you might not want to be using "localeconv()" directly
3951 anyway, because of issues like the ones listed in the
3952 second item of this list (above) for "RADIXCHAR" and
3953 "THOUSEP". You can use the methods given in perlcall to
3954 call "localeconv" in POSIX and avoid all the issues, but
3955 then you have a hash to unpack).
3956
3957 The details for those items which may deviate from what
3958 this emulation returns and what a native "nl_langinfo()"
3959 would return are specified in I18N::Langinfo.
3960
3961 When using "Perl_langinfo" on systems that don't have a native
3962 "nl_langinfo()", you must
3963
3964 #include "perl_langinfo.h"
3965
3966 before the "perl.h" "#include". You can replace your
3967 "langinfo.h" "#include" with this one. (Doing it this way
3968 keeps out the symbols that plain "langinfo.h" would try to
3969 import into the namespace for code that doesn't need it.)
3970
3971 The original impetus for "Perl_langinfo()" was so that code
3972 that needs to find out the current currency symbol, floating
3973 point radix character, or digit grouping separator can use, on
3974 all systems, the simpler and more thread-friendly "nl_langinfo"
3975 API instead of localeconv(3) which is a pain to make thread-
3976 friendly. For other fields returned by "localeconv", it is
3977 better to use the methods given in perlcall to call
3978 "POSIX::localeconv()", which is thread-friendly.
3979
3980 const char* Perl_langinfo(const nl_item item)
3981
3982 Perl_setlocale
3983 This is an (almost) drop-in replacement for the system
3984 setlocale(3), taking the same parameters, and returning the
3985 same information, except that it returns the correct underlying
3986 "LC_NUMERIC" locale. Regular "setlocale" will instead return
3987 "C" if the underlying locale has a non-dot decimal point
3988 character, or a non-empty thousands separator for displaying
3989 floating point numbers. This is because perl keeps that locale
3990 category such that it has a dot and empty separator, changing
3991 the locale briefly during the operations where the underlying
3992 one is required. "Perl_setlocale" knows about this, and
3993 compensates; regular "setlocale" doesn't.
3994
3995 Another reason it isn't completely a drop-in replacement is
3996 that it is declared to return "const char *", whereas the
3997 system setlocale omits the "const" (presumably because its API
3998 was specified long ago, and can't be updated; it is illegal to
3999 change the information "setlocale" returns; doing so leads to
4000 segfaults.)
4001
4002 Finally, "Perl_setlocale" works under all circumstances,
4003 whereas plain "setlocale" can be completely ineffective on some
4004 platforms under some configurations.
4005
4006 "Perl_setlocale" should not be used to change the locale except
4007 on systems where the predefined variable "${^SAFE_LOCALES}" is
4008 1. On some such systems, the system "setlocale()" is
4009 ineffective, returning the wrong information, and failing to
4010 actually change the locale. "Perl_setlocale", however works
4011 properly in all circumstances.
4012
4013 The return points to a per-thread static buffer, which is
4014 overwritten the next time "Perl_setlocale" is called from the
4015 same thread.
4016
4017 const char* Perl_setlocale(const int category,
4018 const char* locale)
4019
4020 RESTORE_LC_NUMERIC
4021 This is used in conjunction with one of the macros
4022 "STORE_LC_NUMERIC_SET_TO_NEEDED" and
4023 "STORE_LC_NUMERIC_FORCE_TO_UNDERLYING" to properly restore the
4024 "LC_NUMERIC" state.
4025
4026 A call to "DECLARATION_FOR_LC_NUMERIC_MANIPULATION" must have
4027 been made to declare at compile time a private variable used by
4028 this macro and the two "STORE" ones. This macro should be
4029 called as a single statement, not an expression, but with an
4030 empty argument list, like this:
4031
4032 {
4033 DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
4034 ...
4035 RESTORE_LC_NUMERIC();
4036 ...
4037 }
4038
4039 void RESTORE_LC_NUMERIC()
4040
4041 STORE_LC_NUMERIC_FORCE_TO_UNDERLYING
4042 This is used by XS code that that is "LC_NUMERIC" locale-aware
4043 to force the locale for category "LC_NUMERIC" to be what perl
4044 thinks is the current underlying locale. (The perl interpreter
4045 could be wrong about what the underlying locale actually is if
4046 some C or XS code has called the C library function
4047 setlocale(3) behind its back; calling "sync_locale" before
4048 calling this macro will update perl's records.)
4049
4050 A call to "DECLARATION_FOR_LC_NUMERIC_MANIPULATION" must have
4051 been made to declare at compile time a private variable used by
4052 this macro. This macro should be called as a single statement,
4053 not an expression, but with an empty argument list, like this:
4054
4055 {
4056 DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
4057 ...
4058 STORE_LC_NUMERIC_FORCE_TO_UNDERLYING();
4059 ...
4060 RESTORE_LC_NUMERIC();
4061 ...
4062 }
4063
4064 The private variable is used to save the current locale state,
4065 so that the requisite matching call to "RESTORE_LC_NUMERIC" can
4066 restore it.
4067
4068 On threaded perls not operating with thread-safe functionality,
4069 this macro uses a mutex to force a critical section. Therefore
4070 the matching RESTORE should be close by, and guaranteed to be
4071 called.
4072
4073 void STORE_LC_NUMERIC_FORCE_TO_UNDERLYING()
4074
4075 STORE_LC_NUMERIC_SET_TO_NEEDED
4076 This is used to help wrap XS or C code that is "LC_NUMERIC"
4077 locale-aware. This locale category is generally kept set to a
4078 locale where the decimal radix character is a dot, and the
4079 separator between groups of digits is empty. This is because
4080 most XS code that reads floating point numbers is expecting
4081 them to have this syntax.
4082
4083 This macro makes sure the current "LC_NUMERIC" state is set
4084 properly, to be aware of locale if the call to the XS or C code
4085 from the Perl program is from within the scope of a
4086 "use locale"; or to ignore locale if the call is instead from
4087 outside such scope.
4088
4089 This macro is the start of wrapping the C or XS code; the wrap
4090 ending is done by calling the "RESTORE_LC_NUMERIC" macro after
4091 the operation. Otherwise the state can be changed that will
4092 adversely affect other XS code.
4093
4094 A call to "DECLARATION_FOR_LC_NUMERIC_MANIPULATION" must have
4095 been made to declare at compile time a private variable used by
4096 this macro. This macro should be called as a single statement,
4097 not an expression, but with an empty argument list, like this:
4098
4099 {
4100 DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
4101 ...
4102 STORE_LC_NUMERIC_SET_TO_NEEDED();
4103 ...
4104 RESTORE_LC_NUMERIC();
4105 ...
4106 }
4107
4108 On threaded perls not operating with thread-safe functionality,
4109 this macro uses a mutex to force a critical section. Therefore
4110 the matching RESTORE should be close by, and guaranteed to be
4111 called.
4112
4113 void STORE_LC_NUMERIC_SET_TO_NEEDED()
4114
4115 switch_to_global_locale
4116 On systems without locale support, or on single-threaded
4117 builds, or on platforms that do not support per-thread locale
4118 operations, this function does nothing. On such systems that
4119 do have locale support, only a locale global to the whole
4120 program is available.
4121
4122 On multi-threaded builds on systems that do have per-thread
4123 locale operations, this function converts the thread it is
4124 running in to use the global locale. This is for code that has
4125 not yet or cannot be updated to handle multi-threaded locale
4126 operation. As long as only a single thread is so-converted,
4127 everything works fine, as all the other threads continue to
4128 ignore the global one, so only this thread looks at it.
4129
4130 However, on Windows systems this isn't quite true prior to
4131 Visual Studio 15, at which point Microsoft fixed a bug. A race
4132 can occur if you use the following operations on earlier
4133 Windows platforms:
4134
4135 POSIX::localeconv
4136 I18N::Langinfo, items "CRNCYSTR" and "THOUSEP"
4137 "Perl_langinfo" in perlapi, items "CRNCYSTR" and "THOUSEP"
4138
4139 The first item is not fixable (except by upgrading to a later
4140 Visual Studio release), but it would be possible to work around
4141 the latter two items by using the Windows API functions
4142 "GetNumberFormat" and "GetCurrencyFormat"; patches welcome.
4143
4144 Without this function call, threads that use the setlocale(3)
4145 system function will not work properly, as all the locale-
4146 sensitive functions will look at the per-thread locale, and
4147 "setlocale" will have no effect on this thread.
4148
4149 Perl code should convert to either call "Perl_setlocale" (which
4150 is a drop-in for the system "setlocale") or use the methods
4151 given in perlcall to call "POSIX::setlocale". Either one will
4152 transparently properly handle all cases of single- vs multi-
4153 thread, POSIX 2008-supported or not.
4154
4155 Non-Perl libraries, such as "gtk", that call the system
4156 "setlocale" can continue to work if this function is called
4157 before transferring control to the library.
4158
4159 Upon return from the code that needs to use the global locale,
4160 "sync_locale()" should be called to restore the safe multi-
4161 thread operation.
4162
4163 void switch_to_global_locale()
4164
4165 sync_locale
4166 "Perl_setlocale" can be used at any time to query or change the
4167 locale (though changing the locale is antisocial and dangerous
4168 on multi-threaded systems that don't have multi-thread safe
4169 locale operations. (See "Multi-threaded operation" in
4170 perllocale). Using the system setlocale(3) should be avoided.
4171 Nevertheless, certain non-Perl libraries called from XS, such
4172 as "Gtk" do so, and this can't be changed. When the locale is
4173 changed by XS code that didn't use "Perl_setlocale", Perl needs
4174 to be told that the locale has changed. Use this function to
4175 do so, before returning to Perl.
4176
4177 The return value is a boolean: TRUE if the global locale at the
4178 time of call was in effect; and FALSE if a per-thread locale
4179 was in effect. This can be used by the caller that needs to
4180 restore things as-they-were to decide whether or not to call
4181 "Perl_switch_to_global_locale".
4182
4183 bool sync_locale()
4184
4186 mg_clear
4187 Clear something magical that the SV represents. See
4188 "sv_magic".
4189
4190 int mg_clear(SV* sv)
4191
4192 mg_copy Copies the magic from one SV to another. See "sv_magic".
4193
4194 int mg_copy(SV *sv, SV *nsv, const char *key,
4195 I32 klen)
4196
4197 mg_find Finds the magic pointer for "type" matching the SV. See
4198 "sv_magic".
4199
4200 MAGIC* mg_find(const SV* sv, int type)
4201
4202 mg_findext
4203 Finds the magic pointer of "type" with the given "vtbl" for the
4204 "SV". See "sv_magicext".
4205
4206 MAGIC* mg_findext(const SV* sv, int type,
4207 const MGVTBL *vtbl)
4208
4209 mg_free Free any magic storage used by the SV. See "sv_magic".
4210
4211 int mg_free(SV* sv)
4212
4213 mg_freeext
4214 Remove any magic of type "how" using virtual table "vtbl" from
4215 the SV "sv". See "sv_magic".
4216
4217 "mg_freeext(sv, how, NULL)" is equivalent to "mg_free_type(sv,
4218 how)".
4219
4220 void mg_freeext(SV* sv, int how, const MGVTBL *vtbl)
4221
4222 mg_free_type
4223 Remove any magic of type "how" from the SV "sv". See
4224 "sv_magic".
4225
4226 void mg_free_type(SV *sv, int how)
4227
4228 mg_get Do magic before a value is retrieved from the SV. The type of
4229 SV must be >= "SVt_PVMG". See "sv_magic".
4230
4231 int mg_get(SV* sv)
4232
4233 mg_length
4234 DEPRECATED! It is planned to remove this function from a
4235 future release of Perl. Do not use it for new code; remove it
4236 from existing code.
4237
4238 Reports on the SV's length in bytes, calling length magic if
4239 available, but does not set the UTF8 flag on "sv". It will
4240 fall back to 'get' magic if there is no 'length' magic, but
4241 with no indication as to whether it called 'get' magic. It
4242 assumes "sv" is a "PVMG" or higher. Use "sv_len()" instead.
4243
4244 U32 mg_length(SV* sv)
4245
4246 mg_magical
4247 Turns on the magical status of an SV. See "sv_magic".
4248
4249 void mg_magical(SV* sv)
4250
4251 mg_set Do magic after a value is assigned to the SV. See "sv_magic".
4252
4253 int mg_set(SV* sv)
4254
4255 SvGETMAGIC
4256 Invokes "mg_get" on an SV if it has 'get' magic. For example,
4257 this will call "FETCH" on a tied variable. This macro
4258 evaluates its argument more than once.
4259
4260 void SvGETMAGIC(SV* sv)
4261
4262 SvLOCK Arranges for a mutual exclusion lock to be obtained on "sv" if
4263 a suitable module has been loaded.
4264
4265 void SvLOCK(SV* sv)
4266
4267 SvSETMAGIC
4268 Invokes "mg_set" on an SV if it has 'set' magic. This is
4269 necessary after modifying a scalar, in case it is a magical
4270 variable like $| or a tied variable (it calls "STORE"). This
4271 macro evaluates its argument more than once.
4272
4273 void SvSETMAGIC(SV* sv)
4274
4275 SvSetMagicSV
4276 Like "SvSetSV", but does any set magic required afterwards.
4277
4278 void SvSetMagicSV(SV* dsv, SV* ssv)
4279
4280 SvSetMagicSV_nosteal
4281 Like "SvSetSV_nosteal", but does any set magic required
4282 afterwards.
4283
4284 void SvSetMagicSV_nosteal(SV* dsv, SV* ssv)
4285
4286 SvSetSV Calls "sv_setsv" if "dsv" is not the same as "ssv". May
4287 evaluate arguments more than once. Does not handle 'set' magic
4288 on the destination SV.
4289
4290 void SvSetSV(SV* dsv, SV* ssv)
4291
4292 SvSetSV_nosteal
4293 Calls a non-destructive version of "sv_setsv" if "dsv" is not
4294 the same as "ssv". May evaluate arguments more than once.
4295
4296 void SvSetSV_nosteal(SV* dsv, SV* ssv)
4297
4298 SvSHARE Arranges for "sv" to be shared between threads if a suitable
4299 module has been loaded.
4300
4301 void SvSHARE(SV* sv)
4302
4303 sv_string_from_errnum
4304 Generates the message string describing an OS error and returns
4305 it as an SV. "errnum" must be a value that "errno" could take,
4306 identifying the type of error.
4307
4308 If "tgtsv" is non-null then the string will be written into
4309 that SV (overwriting existing content) and it will be returned.
4310 If "tgtsv" is a null pointer then the string will be written
4311 into a new mortal SV which will be returned.
4312
4313 The message will be taken from whatever locale would be used by
4314 $!, and will be encoded in the SV in whatever manner would be
4315 used by $!. The details of this process are subject to future
4316 change. Currently, the message is taken from the C locale by
4317 default (usually producing an English message), and from the
4318 currently selected locale when in the scope of the "use locale"
4319 pragma. A heuristic attempt is made to decode the message from
4320 the locale's character encoding, but it will only be decoded as
4321 either UTF-8 or ISO-8859-1. It is always correctly decoded in
4322 a UTF-8 locale, usually in an ISO-8859-1 locale, and never in
4323 any other locale.
4324
4325 The SV is always returned containing an actual string, and with
4326 no other OK bits set. Unlike $!, a message is even yielded for
4327 "errnum" zero (meaning success), and if no useful message is
4328 available then a useless string (currently empty) is returned.
4329
4330 SV * sv_string_from_errnum(int errnum, SV *tgtsv)
4331
4332 SvUNLOCK
4333 Releases a mutual exclusion lock on "sv" if a suitable module
4334 has been loaded.
4335
4336 void SvUNLOCK(SV* sv)
4337
4339 Copy The XSUB-writer's interface to the C "memcpy" function. The
4340 "src" is the source, "dest" is the destination, "nitems" is the
4341 number of items, and "type" is the type. May fail on
4342 overlapping copies. See also "Move".
4343
4344 void Copy(void* src, void* dest, int nitems, type)
4345
4346 CopyD Like "Copy" but returns "dest". Useful for encouraging
4347 compilers to tail-call optimise.
4348
4349 void * CopyD(void* src, void* dest, int nitems, type)
4350
4351 Move The XSUB-writer's interface to the C "memmove" function. The
4352 "src" is the source, "dest" is the destination, "nitems" is the
4353 number of items, and "type" is the type. Can do overlapping
4354 moves. See also "Copy".
4355
4356 void Move(void* src, void* dest, int nitems, type)
4357
4358 MoveD Like "Move" but returns "dest". Useful for encouraging
4359 compilers to tail-call optimise.
4360
4361 void * MoveD(void* src, void* dest, int nitems, type)
4362
4363 Newx The XSUB-writer's interface to the C "malloc" function.
4364
4365 Memory obtained by this should ONLY be freed with "Safefree".
4366
4367 In 5.9.3, Newx() and friends replace the older New() API, and
4368 drops the first parameter, x, a debug aid which allowed callers
4369 to identify themselves. This aid has been superseded by a new
4370 build option, PERL_MEM_LOG (see "PERL_MEM_LOG" in
4371 perlhacktips). The older API is still there for use in XS
4372 modules supporting older perls.
4373
4374 void Newx(void* ptr, int nitems, type)
4375
4376 Newxc The XSUB-writer's interface to the C "malloc" function, with
4377 cast. See also "Newx".
4378
4379 Memory obtained by this should ONLY be freed with "Safefree".
4380
4381 void Newxc(void* ptr, int nitems, type, cast)
4382
4383 Newxz The XSUB-writer's interface to the C "malloc" function. The
4384 allocated memory is zeroed with "memzero". See also "Newx".
4385
4386 Memory obtained by this should ONLY be freed with "Safefree".
4387
4388 void Newxz(void* ptr, int nitems, type)
4389
4390 Poison PoisonWith(0xEF) for catching access to freed memory.
4391
4392 void Poison(void* dest, int nitems, type)
4393
4394 PoisonFree
4395 PoisonWith(0xEF) for catching access to freed memory.
4396
4397 void PoisonFree(void* dest, int nitems, type)
4398
4399 PoisonNew
4400 PoisonWith(0xAB) for catching access to allocated but
4401 uninitialized memory.
4402
4403 void PoisonNew(void* dest, int nitems, type)
4404
4405 PoisonWith
4406 Fill up memory with a byte pattern (a byte repeated over and
4407 over again) that hopefully catches attempts to access
4408 uninitialized memory.
4409
4410 void PoisonWith(void* dest, int nitems, type,
4411 U8 byte)
4412
4413 Renew The XSUB-writer's interface to the C "realloc" function.
4414
4415 Memory obtained by this should ONLY be freed with "Safefree".
4416
4417 void Renew(void* ptr, int nitems, type)
4418
4419 Renewc The XSUB-writer's interface to the C "realloc" function, with
4420 cast.
4421
4422 Memory obtained by this should ONLY be freed with "Safefree".
4423
4424 void Renewc(void* ptr, int nitems, type, cast)
4425
4426 Safefree
4427 The XSUB-writer's interface to the C "free" function.
4428
4429 This should ONLY be used on memory obtained using "Newx" and
4430 friends.
4431
4432 void Safefree(void* ptr)
4433
4434 savepv Perl's version of "strdup()". Returns a pointer to a newly
4435 allocated string which is a duplicate of "pv". The size of the
4436 string is determined by "strlen()", which means it may not
4437 contain embedded "NUL" characters and must have a trailing
4438 "NUL". The memory allocated for the new string can be freed
4439 with the "Safefree()" function.
4440
4441 On some platforms, Windows for example, all allocated memory
4442 owned by a thread is deallocated when that thread ends. So if
4443 you need that not to happen, you need to use the shared memory
4444 functions, such as "savesharedpv".
4445
4446 char* savepv(const char* pv)
4447
4448 savepvn Perl's version of what "strndup()" would be if it existed.
4449 Returns a pointer to a newly allocated string which is a
4450 duplicate of the first "len" bytes from "pv", plus a trailing
4451 "NUL" byte. The memory allocated for the new string can be
4452 freed with the "Safefree()" function.
4453
4454 On some platforms, Windows for example, all allocated memory
4455 owned by a thread is deallocated when that thread ends. So if
4456 you need that not to happen, you need to use the shared memory
4457 functions, such as "savesharedpvn".
4458
4459 char* savepvn(const char* pv, I32 len)
4460
4461 savepvs Like "savepvn", but takes a literal string instead of a
4462 string/length pair.
4463
4464 char* savepvs("literal string" s)
4465
4466 savesharedpv
4467 A version of "savepv()" which allocates the duplicate string in
4468 memory which is shared between threads.
4469
4470 char* savesharedpv(const char* pv)
4471
4472 savesharedpvn
4473 A version of "savepvn()" which allocates the duplicate string
4474 in memory which is shared between threads. (With the specific
4475 difference that a "NULL" pointer is not acceptable)
4476
4477 char* savesharedpvn(const char *const pv,
4478 const STRLEN len)
4479
4480 savesharedpvs
4481 A version of "savepvs()" which allocates the duplicate string
4482 in memory which is shared between threads.
4483
4484 char* savesharedpvs("literal string" s)
4485
4486 savesharedsvpv
4487 A version of "savesharedpv()" which allocates the duplicate
4488 string in memory which is shared between threads.
4489
4490 char* savesharedsvpv(SV *sv)
4491
4492 savesvpv
4493 A version of "savepv()"/"savepvn()" which gets the string to
4494 duplicate from the passed in SV using "SvPV()"
4495
4496 On some platforms, Windows for example, all allocated memory
4497 owned by a thread is deallocated when that thread ends. So if
4498 you need that not to happen, you need to use the shared memory
4499 functions, such as "savesharedsvpv".
4500
4501 char* savesvpv(SV* sv)
4502
4503 StructCopy
4504 This is an architecture-independent macro to copy one structure
4505 to another.
4506
4507 void StructCopy(type *src, type *dest, type)
4508
4509 Zero The XSUB-writer's interface to the C "memzero" function. The
4510 "dest" is the destination, "nitems" is the number of items, and
4511 "type" is the type.
4512
4513 void Zero(void* dest, int nitems, type)
4514
4515 ZeroD Like "Zero" but returns dest. Useful for encouraging compilers
4516 to tail-call optimise.
4517
4518 void * ZeroD(void* dest, int nitems, type)
4519
4521 dump_c_backtrace
4522 Dumps the C backtrace to the given "fp".
4523
4524 Returns true if a backtrace could be retrieved, false if not.
4525
4526 bool dump_c_backtrace(PerlIO* fp, int max_depth,
4527 int skip)
4528
4529 fbm_compile
4530 Analyzes the string in order to make fast searches on it using
4531 "fbm_instr()" -- the Boyer-Moore algorithm.
4532
4533 void fbm_compile(SV* sv, U32 flags)
4534
4535 fbm_instr
4536 Returns the location of the SV in the string delimited by "big"
4537 and "bigend" ("bigend") is the char following the last char).
4538 It returns "NULL" if the string can't be found. The "sv" does
4539 not have to be "fbm_compiled", but the search will not be as
4540 fast then.
4541
4542 char* fbm_instr(unsigned char* big,
4543 unsigned char* bigend, SV* littlestr,
4544 U32 flags)
4545
4546 foldEQ Returns true if the leading "len" bytes of the strings "s1" and
4547 "s2" are the same case-insensitively; false otherwise.
4548 Uppercase and lowercase ASCII range bytes match themselves and
4549 their opposite case counterparts. Non-cased and non-ASCII
4550 range bytes match only themselves.
4551
4552 I32 foldEQ(const char* a, const char* b, I32 len)
4553
4554 foldEQ_locale
4555 Returns true if the leading "len" bytes of the strings "s1" and
4556 "s2" are the same case-insensitively in the current locale;
4557 false otherwise.
4558
4559 I32 foldEQ_locale(const char* a, const char* b,
4560 I32 len)
4561
4562 form Takes a sprintf-style format pattern and conventional (non-SV)
4563 arguments and returns the formatted string.
4564
4565 (char *) Perl_form(pTHX_ const char* pat, ...)
4566
4567 can be used any place a string (char *) is required:
4568
4569 char * s = Perl_form("%d.%d",major,minor);
4570
4571 Uses a single private buffer so if you want to format several
4572 strings you must explicitly copy the earlier strings away (and
4573 free the copies when you are done).
4574
4575 char* form(const char* pat, ...)
4576
4577 getcwd_sv
4578 Fill "sv" with current working directory
4579
4580 int getcwd_sv(SV* sv)
4581
4582 get_c_backtrace_dump
4583 Returns a SV containing a dump of "depth" frames of the call
4584 stack, skipping the "skip" innermost ones. "depth" of 20 is
4585 usually enough.
4586
4587 The appended output looks like:
4588
4589 ... 1 10e004812:0082 Perl_croak util.c:1716
4590 /usr/bin/perl 2 10df8d6d2:1d72 perl_parse perl.c:3975
4591 /usr/bin/perl ...
4592
4593 The fields are tab-separated. The first column is the depth
4594 (zero being the innermost non-skipped frame). In the
4595 hex:offset, the hex is where the program counter was in
4596 "S_parse_body", and the :offset (might be missing) tells how
4597 much inside the "S_parse_body" the program counter was.
4598
4599 The "util.c:1716" is the source code file and line number.
4600
4601 The /usr/bin/perl is obvious (hopefully).
4602
4603 Unknowns are "-". Unknowns can happen unfortunately quite
4604 easily: if the platform doesn't support retrieving the
4605 information; if the binary is missing the debug information; if
4606 the optimizer has transformed the code by for example inlining.
4607
4608 SV* get_c_backtrace_dump(int max_depth, int skip)
4609
4610 ibcmp This is a synonym for "(! foldEQ())"
4611
4612 I32 ibcmp(const char* a, const char* b, I32 len)
4613
4614 ibcmp_locale
4615 This is a synonym for "(! foldEQ_locale())"
4616
4617 I32 ibcmp_locale(const char* a, const char* b,
4618 I32 len)
4619
4620 is_safe_syscall
4621 Test that the given "pv" doesn't contain any internal "NUL"
4622 characters. If it does, set "errno" to "ENOENT", optionally
4623 warn, and return FALSE.
4624
4625 Return TRUE if the name is safe.
4626
4627 Used by the "IS_SAFE_SYSCALL()" macro.
4628
4629 bool is_safe_syscall(const char *pv, STRLEN len,
4630 const char *what,
4631 const char *op_name)
4632
4633 memEQ Test two buffers (which may contain embedded "NUL" characters,
4634 to see if they are equal. The "len" parameter indicates the
4635 number of bytes to compare. Returns zero if equal, or non-zero
4636 if non-equal.
4637
4638 bool memEQ(char* s1, char* s2, STRLEN len)
4639
4640 memNE Test two buffers (which may contain embedded "NUL" characters,
4641 to see if they are not equal. The "len" parameter indicates
4642 the number of bytes to compare. Returns zero if non-equal, or
4643 non-zero if equal.
4644
4645 bool memNE(char* s1, char* s2, STRLEN len)
4646
4647 mess Take a sprintf-style format pattern and argument list. These
4648 are used to generate a string message. If the message does not
4649 end with a newline, then it will be extended with some
4650 indication of the current location in the code, as described
4651 for "mess_sv".
4652
4653 Normally, the resulting message is returned in a new mortal SV.
4654 During global destruction a single SV may be shared between
4655 uses of this function.
4656
4657 SV * mess(const char *pat, ...)
4658
4659 mess_sv Expands a message, intended for the user, to include an
4660 indication of the current location in the code, if the message
4661 does not already appear to be complete.
4662
4663 "basemsg" is the initial message or object. If it is a
4664 reference, it will be used as-is and will be the result of this
4665 function. Otherwise it is used as a string, and if it already
4666 ends with a newline, it is taken to be complete, and the result
4667 of this function will be the same string. If the message does
4668 not end with a newline, then a segment such as "at foo.pl line
4669 37" will be appended, and possibly other clauses indicating the
4670 current state of execution. The resulting message will end
4671 with a dot and a newline.
4672
4673 Normally, the resulting message is returned in a new mortal SV.
4674 During global destruction a single SV may be shared between
4675 uses of this function. If "consume" is true, then the function
4676 is permitted (but not required) to modify and return "basemsg"
4677 instead of allocating a new SV.
4678
4679 SV * mess_sv(SV *basemsg, bool consume)
4680
4681 my_snprintf
4682 The C library "snprintf" functionality, if available and
4683 standards-compliant (uses "vsnprintf", actually). However, if
4684 the "vsnprintf" is not available, will unfortunately use the
4685 unsafe "vsprintf" which can overrun the buffer (there is an
4686 overrun check, but that may be too late). Consider using
4687 "sv_vcatpvf" instead, or getting "vsnprintf".
4688
4689 int my_snprintf(char *buffer, const Size_t len,
4690 const char *format, ...)
4691
4692 my_strlcat
4693 The C library "strlcat" if available, or a Perl implementation
4694 of it. This operates on C "NUL"-terminated strings.
4695
4696 "my_strlcat()" appends string "src" to the end of "dst". It
4697 will append at most "size - strlen(dst) - 1" characters. It
4698 will then "NUL"-terminate, unless "size" is 0 or the original
4699 "dst" string was longer than "size" (in practice this should
4700 not happen as it means that either "size" is incorrect or that
4701 "dst" is not a proper "NUL"-terminated string).
4702
4703 Note that "size" is the full size of the destination buffer and
4704 the result is guaranteed to be "NUL"-terminated if there is
4705 room. Note that room for the "NUL" should be included in
4706 "size".
4707
4708 The return value is the total length that "dst" would have if
4709 "size" is sufficiently large. Thus it is the initial length of
4710 "dst" plus the length of "src". If "size" is smaller than the
4711 return, the excess was not appended.
4712
4713 Size_t my_strlcat(char *dst, const char *src,
4714 Size_t size)
4715
4716 my_strlcpy
4717 The C library "strlcpy" if available, or a Perl implementation
4718 of it. This operates on C "NUL"-terminated strings.
4719
4720 "my_strlcpy()" copies up to "size - 1" characters from the
4721 string "src" to "dst", "NUL"-terminating the result if "size"
4722 is not 0.
4723
4724 The return value is the total length "src" would be if the copy
4725 completely succeeded. If it is larger than "size", the excess
4726 was not copied.
4727
4728 Size_t my_strlcpy(char *dst, const char *src,
4729 Size_t size)
4730
4731 my_strnlen
4732 The C library "strnlen" if available, or a Perl implementation
4733 of it.
4734
4735 "my_strnlen()" computes the length of the string, up to
4736 "maxlen" characters. It will will never attempt to address
4737 more than "maxlen" characters, making it suitable for use with
4738 strings that are not guaranteed to be NUL-terminated.
4739
4740 Size_t my_strnlen(const char *str, Size_t maxlen)
4741
4742 my_vsnprintf
4743 The C library "vsnprintf" if available and standards-compliant.
4744 However, if if the "vsnprintf" is not available, will
4745 unfortunately use the unsafe "vsprintf" which can overrun the
4746 buffer (there is an overrun check, but that may be too late).
4747 Consider using "sv_vcatpvf" instead, or getting "vsnprintf".
4748
4749 int my_vsnprintf(char *buffer, const Size_t len,
4750 const char *format, va_list ap)
4751
4752 ninstr Find the first (leftmost) occurrence of a sequence of bytes
4753 within another sequence. This is the Perl version of
4754 "strstr()", extended to handle arbitrary sequences, potentially
4755 containing embedded "NUL" characters ("NUL" is what the initial
4756 "n" in the function name stands for; some systems have an
4757 equivalent, "memmem()", but with a somewhat different API).
4758
4759 Another way of thinking about this function is finding a needle
4760 in a haystack. "big" points to the first byte in the haystack.
4761 "big_end" points to one byte beyond the final byte in the
4762 haystack. "little" points to the first byte in the needle.
4763 "little_end" points to one byte beyond the final byte in the
4764 needle. All the parameters must be non-"NULL".
4765
4766 The function returns "NULL" if there is no occurrence of
4767 "little" within "big". If "little" is the empty string, "big"
4768 is returned.
4769
4770 Because this function operates at the byte level, and because
4771 of the inherent characteristics of UTF-8 (or UTF-EBCDIC), it
4772 will work properly if both the needle and the haystack are
4773 strings with the same UTF-8ness, but not if the UTF-8ness
4774 differs.
4775
4776 char * ninstr(char * big, char * bigend, char * little,
4777 char * little_end)
4778
4779 PERL_SYS_INIT
4780 Provides system-specific tune up of the C runtime environment
4781 necessary to run Perl interpreters. This should be called only
4782 once, before creating any Perl interpreters.
4783
4784 void PERL_SYS_INIT(int *argc, char*** argv)
4785
4786 PERL_SYS_INIT3
4787 Provides system-specific tune up of the C runtime environment
4788 necessary to run Perl interpreters. This should be called only
4789 once, before creating any Perl interpreters.
4790
4791 void PERL_SYS_INIT3(int *argc, char*** argv,
4792 char*** env)
4793
4794 PERL_SYS_TERM
4795 Provides system-specific clean up of the C runtime environment
4796 after running Perl interpreters. This should be called only
4797 once, after freeing any remaining Perl interpreters.
4798
4799 void PERL_SYS_TERM()
4800
4801 quadmath_format_needed
4802 "quadmath_format_needed()" returns true if the "format" string
4803 seems to contain at least one non-Q-prefixed "%[efgaEFGA]"
4804 format specifier, or returns false otherwise.
4805
4806 The format specifier detection is not complete printf-syntax
4807 detection, but it should catch most common cases.
4808
4809 If true is returned, those arguments should in theory be
4810 processed with "quadmath_snprintf()", but in case there is more
4811 than one such format specifier (see "quadmath_format_single"),
4812 and if there is anything else beyond that one (even just a
4813 single byte), they cannot be processed because
4814 "quadmath_snprintf()" is very strict, accepting only one format
4815 spec, and nothing else. In this case, the code should probably
4816 fail.
4817
4818 bool quadmath_format_needed(const char* format)
4819
4820 quadmath_format_single
4821 "quadmath_snprintf()" is very strict about its "format" string
4822 and will fail, returning -1, if the format is invalid. It
4823 accepts exactly one format spec.
4824
4825 "quadmath_format_single()" checks that the intended single spec
4826 looks sane: begins with "%", has only one "%", ends with
4827 "[efgaEFGA]", and has "Q" before it. This is not a full
4828 "printf syntax check", just the basics.
4829
4830 Returns the format if it is valid, NULL if not.
4831
4832 "quadmath_format_single()" can and will actually patch in the
4833 missing "Q", if necessary. In this case it will return the
4834 modified copy of the format, which the caller will need to
4835 free.
4836
4837 See also "quadmath_format_needed".
4838
4839 const char* quadmath_format_single(const char* format)
4840
4841 READ_XDIGIT
4842 Returns the value of an ASCII-range hex digit and advances the
4843 string pointer. Behaviour is only well defined when
4844 isXDIGIT(*str) is true.
4845
4846 U8 READ_XDIGIT(char str*)
4847
4848 rninstr Like "ninstr", but instead finds the final (rightmost)
4849 occurrence of a sequence of bytes within another sequence,
4850 returning "NULL" if there is no such occurrence.
4851
4852 char * rninstr(char * big, char * bigend,
4853 char * little, char * little_end)
4854
4855 strEQ Test two "NUL"-terminated strings to see if they are equal.
4856 Returns true or false.
4857
4858 bool strEQ(char* s1, char* s2)
4859
4860 strGE Test two "NUL"-terminated strings to see if the first, "s1", is
4861 greater than or equal to the second, "s2". Returns true or
4862 false.
4863
4864 bool strGE(char* s1, char* s2)
4865
4866 strGT Test two "NUL"-terminated strings to see if the first, "s1", is
4867 greater than the second, "s2". Returns true or false.
4868
4869 bool strGT(char* s1, char* s2)
4870
4871 strLE Test two "NUL"-terminated strings to see if the first, "s1", is
4872 less than or equal to the second, "s2". Returns true or false.
4873
4874 bool strLE(char* s1, char* s2)
4875
4876 strLT Test two "NUL"-terminated strings to see if the first, "s1", is
4877 less than the second, "s2". Returns true or false.
4878
4879 bool strLT(char* s1, char* s2)
4880
4881 strNE Test two "NUL"-terminated strings to see if they are different.
4882 Returns true or false.
4883
4884 bool strNE(char* s1, char* s2)
4885
4886 strnEQ Test two "NUL"-terminated strings to see if they are equal.
4887 The "len" parameter indicates the number of bytes to compare.
4888 Returns true or false. (A wrapper for "strncmp").
4889
4890 bool strnEQ(char* s1, char* s2, STRLEN len)
4891
4892 strnNE Test two "NUL"-terminated strings to see if they are different.
4893 The "len" parameter indicates the number of bytes to compare.
4894 Returns true or false. (A wrapper for "strncmp").
4895
4896 bool strnNE(char* s1, char* s2, STRLEN len)
4897
4898 sv_destroyable
4899 Dummy routine which reports that object can be destroyed when
4900 there is no sharing module present. It ignores its single SV
4901 argument, and returns 'true'. Exists to avoid test for a
4902 "NULL" function pointer and because it could potentially warn
4903 under some level of strict-ness.
4904
4905 bool sv_destroyable(SV *sv)
4906
4907 sv_nosharing
4908 Dummy routine which "shares" an SV when there is no sharing
4909 module present. Or "locks" it. Or "unlocks" it. In other
4910 words, ignores its single SV argument. Exists to avoid test
4911 for a "NULL" function pointer and because it could potentially
4912 warn under some level of strict-ness.
4913
4914 void sv_nosharing(SV *sv)
4915
4916 vmess "pat" and "args" are a sprintf-style format pattern and
4917 encapsulated argument list, respectively. These are used to
4918 generate a string message. If the message does not end with a
4919 newline, then it will be extended with some indication of the
4920 current location in the code, as described for "mess_sv".
4921
4922 Normally, the resulting message is returned in a new mortal SV.
4923 During global destruction a single SV may be shared between
4924 uses of this function.
4925
4926 SV * vmess(const char *pat, va_list *args)
4927
4929 These functions are related to the method resolution order of perl
4930 classes
4931
4932 mro_get_linear_isa
4933 Returns the mro linearisation for the given stash. By default,
4934 this will be whatever "mro_get_linear_isa_dfs" returns unless
4935 some other MRO is in effect for the stash. The return value is
4936 a read-only AV*.
4937
4938 You are responsible for "SvREFCNT_inc()" on the return value if
4939 you plan to store it anywhere semi-permanently (otherwise it
4940 might be deleted out from under you the next time the cache is
4941 invalidated).
4942
4943 AV* mro_get_linear_isa(HV* stash)
4944
4945 mro_method_changed_in
4946 Invalidates method caching on any child classes of the given
4947 stash, so that they might notice the changes in this one.
4948
4949 Ideally, all instances of "PL_sub_generation++" in perl source
4950 outside of mro.c should be replaced by calls to this.
4951
4952 Perl automatically handles most of the common ways a method
4953 might be redefined. However, there are a few ways you could
4954 change a method in a stash without the cache code noticing, in
4955 which case you need to call this method afterwards:
4956
4957 1) Directly manipulating the stash HV entries from XS code.
4958
4959 2) Assigning a reference to a readonly scalar constant into a
4960 stash entry in order to create a constant subroutine (like
4961 constant.pm does).
4962
4963 This same method is available from pure perl via,
4964 "mro::method_changed_in(classname)".
4965
4966 void mro_method_changed_in(HV* stash)
4967
4968 mro_register
4969 Registers a custom mro plugin. See perlmroapi for details.
4970
4971 void mro_register(const struct mro_alg *mro)
4972
4974 dMULTICALL
4975 Declare local variables for a multicall. See "LIGHTWEIGHT
4976 CALLBACKS" in perlcall.
4977
4978 dMULTICALL;
4979
4980 MULTICALL
4981 Make a lightweight callback. See "LIGHTWEIGHT CALLBACKS" in
4982 perlcall.
4983
4984 MULTICALL;
4985
4986 POP_MULTICALL
4987 Closing bracket for a lightweight callback. See "LIGHTWEIGHT
4988 CALLBACKS" in perlcall.
4989
4990 POP_MULTICALL;
4991
4992 PUSH_MULTICALL
4993 Opening bracket for a lightweight callback. See "LIGHTWEIGHT
4994 CALLBACKS" in perlcall.
4995
4996 PUSH_MULTICALL;
4997
4999 grok_bin
5000 converts a string representing a binary number to numeric form.
5001
5002 On entry "start" and *len give the string to scan, *flags gives
5003 conversion flags, and "result" should be "NULL" or a pointer to
5004 an NV. The scan stops at the end of the string, or the first
5005 invalid character. Unless "PERL_SCAN_SILENT_ILLDIGIT" is set
5006 in *flags, encountering an invalid character will also trigger
5007 a warning. On return *len is set to the length of the scanned
5008 string, and *flags gives output flags.
5009
5010 If the value is <= "UV_MAX" it is returned as a UV, the output
5011 flags are clear, and nothing is written to *result. If the
5012 value is > "UV_MAX", "grok_bin" returns "UV_MAX", sets
5013 "PERL_SCAN_GREATER_THAN_UV_MAX" in the output flags, and writes
5014 the value to *result (or the value is discarded if "result" is
5015 NULL).
5016
5017 The binary number may optionally be prefixed with "0b" or "b"
5018 unless "PERL_SCAN_DISALLOW_PREFIX" is set in *flags on entry.
5019 If "PERL_SCAN_ALLOW_UNDERSCORES" is set in *flags then the
5020 binary number may use "_" characters to separate digits.
5021
5022 UV grok_bin(const char* start, STRLEN* len_p,
5023 I32* flags, NV *result)
5024
5025 grok_hex
5026 converts a string representing a hex number to numeric form.
5027
5028 On entry "start" and *len_p give the string to scan, *flags
5029 gives conversion flags, and "result" should be "NULL" or a
5030 pointer to an NV. The scan stops at the end of the string, or
5031 the first invalid character. Unless
5032 "PERL_SCAN_SILENT_ILLDIGIT" is set in *flags, encountering an
5033 invalid character will also trigger a warning. On return *len
5034 is set to the length of the scanned string, and *flags gives
5035 output flags.
5036
5037 If the value is <= "UV_MAX" it is returned as a UV, the output
5038 flags are clear, and nothing is written to *result. If the
5039 value is > "UV_MAX", "grok_hex" returns "UV_MAX", sets
5040 "PERL_SCAN_GREATER_THAN_UV_MAX" in the output flags, and writes
5041 the value to *result (or the value is discarded if "result" is
5042 "NULL").
5043
5044 The hex number may optionally be prefixed with "0x" or "x"
5045 unless "PERL_SCAN_DISALLOW_PREFIX" is set in *flags on entry.
5046 If "PERL_SCAN_ALLOW_UNDERSCORES" is set in *flags then the hex
5047 number may use "_" characters to separate digits.
5048
5049 UV grok_hex(const char* start, STRLEN* len_p,
5050 I32* flags, NV *result)
5051
5052 grok_infnan
5053 Helper for "grok_number()", accepts various ways of spelling
5054 "infinity" or "not a number", and returns one of the following
5055 flag combinations:
5056
5057 IS_NUMBER_INFINITY
5058 IS_NUMBER_NAN
5059 IS_NUMBER_INFINITY | IS_NUMBER_NEG
5060 IS_NUMBER_NAN | IS_NUMBER_NEG
5061 0
5062
5063 possibly |-ed with "IS_NUMBER_TRAILING".
5064
5065 If an infinity or a not-a-number is recognized, *sp will point
5066 to one byte past the end of the recognized string. If the
5067 recognition fails, zero is returned, and *sp will not move.
5068
5069 int grok_infnan(const char** sp, const char *send)
5070
5071 grok_number
5072 Identical to "grok_number_flags()" with "flags" set to zero.
5073
5074 int grok_number(const char *pv, STRLEN len,
5075 UV *valuep)
5076
5077 grok_number_flags
5078 Recognise (or not) a number. The type of the number is
5079 returned (0 if unrecognised), otherwise it is a bit-ORed
5080 combination of "IS_NUMBER_IN_UV",
5081 "IS_NUMBER_GREATER_THAN_UV_MAX", "IS_NUMBER_NOT_INT",
5082 "IS_NUMBER_NEG", "IS_NUMBER_INFINITY", "IS_NUMBER_NAN" (defined
5083 in perl.h).
5084
5085 If the value of the number can fit in a UV, it is returned in
5086 *valuep. "IS_NUMBER_IN_UV" will be set to indicate that
5087 *valuep is valid, "IS_NUMBER_IN_UV" will never be set unless
5088 *valuep is valid, but *valuep may have been assigned to during
5089 processing even though "IS_NUMBER_IN_UV" is not set on return.
5090 If "valuep" is "NULL", "IS_NUMBER_IN_UV" will be set for the
5091 same cases as when "valuep" is non-"NULL", but no actual
5092 assignment (or SEGV) will occur.
5093
5094 "IS_NUMBER_NOT_INT" will be set with "IS_NUMBER_IN_UV" if
5095 trailing decimals were seen (in which case *valuep gives the
5096 true value truncated to an integer), and "IS_NUMBER_NEG" if the
5097 number is negative (in which case *valuep holds the absolute
5098 value). "IS_NUMBER_IN_UV" is not set if e notation was used or
5099 the number is larger than a UV.
5100
5101 "flags" allows only "PERL_SCAN_TRAILING", which allows for
5102 trailing non-numeric text on an otherwise successful grok,
5103 setting "IS_NUMBER_TRAILING" on the result.
5104
5105 int grok_number_flags(const char *pv, STRLEN len,
5106 UV *valuep, U32 flags)
5107
5108 grok_numeric_radix
5109 Scan and skip for a numeric decimal separator (radix).
5110
5111 bool grok_numeric_radix(const char **sp,
5112 const char *send)
5113
5114 grok_oct
5115 converts a string representing an octal number to numeric form.
5116
5117 On entry "start" and *len give the string to scan, *flags gives
5118 conversion flags, and "result" should be "NULL" or a pointer to
5119 an NV. The scan stops at the end of the string, or the first
5120 invalid character. Unless "PERL_SCAN_SILENT_ILLDIGIT" is set
5121 in *flags, encountering an 8 or 9 will also trigger a warning.
5122 On return *len is set to the length of the scanned string, and
5123 *flags gives output flags.
5124
5125 If the value is <= "UV_MAX" it is returned as a UV, the output
5126 flags are clear, and nothing is written to *result. If the
5127 value is > "UV_MAX", "grok_oct" returns "UV_MAX", sets
5128 "PERL_SCAN_GREATER_THAN_UV_MAX" in the output flags, and writes
5129 the value to *result (or the value is discarded if "result" is
5130 "NULL").
5131
5132 If "PERL_SCAN_ALLOW_UNDERSCORES" is set in *flags then the
5133 octal number may use "_" characters to separate digits.
5134
5135 UV grok_oct(const char* start, STRLEN* len_p,
5136 I32* flags, NV *result)
5137
5138 isinfnan
5139 "Perl_isinfnan()" is utility function that returns true if the
5140 NV argument is either an infinity or a "NaN", false otherwise.
5141 To test in more detail, use "Perl_isinf()" and "Perl_isnan()".
5142
5143 This is also the logical inverse of Perl_isfinite().
5144
5145 bool isinfnan(NV nv)
5146
5147 Perl_signbit
5148 NOTE: this function is experimental and may change or be
5149 removed without notice.
5150
5151 Return a non-zero integer if the sign bit on an NV is set, and
5152 0 if it is not.
5153
5154 If Configure detects this system has a "signbit()" that will
5155 work with our NVs, then we just use it via the "#define" in
5156 perl.h. Otherwise, fall back on this implementation. The main
5157 use of this function is catching "-0.0".
5158
5159 "Configure" notes: This function is called 'Perl_signbit'
5160 instead of a plain 'signbit' because it is easy to imagine a
5161 system having a "signbit()" function or macro that doesn't
5162 happen to work with our particular choice of NVs. We shouldn't
5163 just re-"#define" "signbit" as "Perl_signbit" and expect the
5164 standard system headers to be happy. Also, this is a no-
5165 context function (no "pTHX_") because "Perl_signbit()" is
5166 usually re-"#defined" in perl.h as a simple macro call to the
5167 system's "signbit()". Users should just always call
5168 "Perl_signbit()".
5169
5170 int Perl_signbit(NV f)
5171
5172 scan_bin
5173 For backwards compatibility. Use "grok_bin" instead.
5174
5175 NV scan_bin(const char* start, STRLEN len,
5176 STRLEN* retlen)
5177
5178 scan_hex
5179 For backwards compatibility. Use "grok_hex" instead.
5180
5181 NV scan_hex(const char* start, STRLEN len,
5182 STRLEN* retlen)
5183
5184 scan_oct
5185 For backwards compatibility. Use "grok_oct" instead.
5186
5187 NV scan_oct(const char* start, STRLEN len,
5188 STRLEN* retlen)
5189
5191 Some of these are also deprecated. You can exclude these from your
5192 compiled Perl by adding this option to Configure:
5193 "-Accflags='-DNO_MATHOMS'"
5194
5195 custom_op_desc
5196 Return the description of a given custom op. This was once
5197 used by the "OP_DESC" macro, but is no longer: it has only been
5198 kept for compatibility, and should not be used.
5199
5200 const char * custom_op_desc(const OP *o)
5201
5202 custom_op_name
5203 Return the name for a given custom op. This was once used by
5204 the "OP_NAME" macro, but is no longer: it has only been kept
5205 for compatibility, and should not be used.
5206
5207 const char * custom_op_name(const OP *o)
5208
5209 gv_fetchmethod
5210 See "gv_fetchmethod_autoload".
5211
5212 GV* gv_fetchmethod(HV* stash, const char* name)
5213
5214 is_utf8_char
5215 DEPRECATED! It is planned to remove this function from a
5216 future release of Perl. Do not use it for new code; remove it
5217 from existing code.
5218
5219 Tests if some arbitrary number of bytes begins in a valid UTF-8
5220 character. Note that an INVARIANT (i.e. ASCII on non-EBCDIC
5221 machines) character is a valid UTF-8 character. The actual
5222 number of bytes in the UTF-8 character will be returned if it
5223 is valid, otherwise 0.
5224
5225 This function is deprecated due to the possibility that
5226 malformed input could cause reading beyond the end of the input
5227 buffer. Use "isUTF8_CHAR" instead.
5228
5229 STRLEN is_utf8_char(const U8 *s)
5230
5231 is_utf8_char_buf
5232 This is identical to the macro "isUTF8_CHAR".
5233
5234 STRLEN is_utf8_char_buf(const U8 *buf,
5235 const U8 *buf_end)
5236
5237 pack_cat
5238 The engine implementing "pack()" Perl function. Note:
5239 parameters "next_in_list" and "flags" are not used. This call
5240 should not be used; use "packlist" instead.
5241
5242 void pack_cat(SV *cat, const char *pat,
5243 const char *patend, SV **beglist,
5244 SV **endlist, SV ***next_in_list,
5245 U32 flags)
5246
5247 pad_compname_type
5248 Looks up the type of the lexical variable at position "po" in
5249 the currently-compiling pad. If the variable is typed, the
5250 stash of the class to which it is typed is returned. If not,
5251 "NULL" is returned.
5252
5253 HV * pad_compname_type(PADOFFSET po)
5254
5255 sv_2pvbyte_nolen
5256 Return a pointer to the byte-encoded representation of the SV.
5257 May cause the SV to be downgraded from UTF-8 as a side-effect.
5258
5259 Usually accessed via the "SvPVbyte_nolen" macro.
5260
5261 char* sv_2pvbyte_nolen(SV* sv)
5262
5263 sv_2pvutf8_nolen
5264 Return a pointer to the UTF-8-encoded representation of the SV.
5265 May cause the SV to be upgraded to UTF-8 as a side-effect.
5266
5267 Usually accessed via the "SvPVutf8_nolen" macro.
5268
5269 char* sv_2pvutf8_nolen(SV* sv)
5270
5271 sv_2pv_nolen
5272 Like "sv_2pv()", but doesn't return the length too. You should
5273 usually use the macro wrapper "SvPV_nolen(sv)" instead.
5274
5275 char* sv_2pv_nolen(SV* sv)
5276
5277 sv_catpvn_mg
5278 Like "sv_catpvn", but also handles 'set' magic.
5279
5280 void sv_catpvn_mg(SV *sv, const char *ptr,
5281 STRLEN len)
5282
5283 sv_catsv_mg
5284 Like "sv_catsv", but also handles 'set' magic.
5285
5286 void sv_catsv_mg(SV *dsv, SV *ssv)
5287
5288 sv_force_normal
5289 Undo various types of fakery on an SV: if the PV is a shared
5290 string, make a private copy; if we're a ref, stop refing; if
5291 we're a glob, downgrade to an "xpvmg". See also
5292 "sv_force_normal_flags".
5293
5294 void sv_force_normal(SV *sv)
5295
5296 sv_iv A private implementation of the "SvIVx" macro for compilers
5297 which can't cope with complex macro expressions. Always use
5298 the macro instead.
5299
5300 IV sv_iv(SV* sv)
5301
5302 sv_nolocking
5303 Dummy routine which "locks" an SV when there is no locking
5304 module present. Exists to avoid test for a "NULL" function
5305 pointer and because it could potentially warn under some level
5306 of strict-ness.
5307
5308 "Superseded" by "sv_nosharing()".
5309
5310 void sv_nolocking(SV *sv)
5311
5312 sv_nounlocking
5313 Dummy routine which "unlocks" an SV when there is no locking
5314 module present. Exists to avoid test for a "NULL" function
5315 pointer and because it could potentially warn under some level
5316 of strict-ness.
5317
5318 "Superseded" by "sv_nosharing()".
5319
5320 void sv_nounlocking(SV *sv)
5321
5322 sv_nv A private implementation of the "SvNVx" macro for compilers
5323 which can't cope with complex macro expressions. Always use
5324 the macro instead.
5325
5326 NV sv_nv(SV* sv)
5327
5328 sv_pv Use the "SvPV_nolen" macro instead
5329
5330 char* sv_pv(SV *sv)
5331
5332 sv_pvbyte
5333 Use "SvPVbyte_nolen" instead.
5334
5335 char* sv_pvbyte(SV *sv)
5336
5337 sv_pvbyten
5338 A private implementation of the "SvPVbyte" macro for compilers
5339 which can't cope with complex macro expressions. Always use
5340 the macro instead.
5341
5342 char* sv_pvbyten(SV *sv, STRLEN *lp)
5343
5344 sv_pvn A private implementation of the "SvPV" macro for compilers
5345 which can't cope with complex macro expressions. Always use
5346 the macro instead.
5347
5348 char* sv_pvn(SV *sv, STRLEN *lp)
5349
5350 sv_pvutf8
5351 Use the "SvPVutf8_nolen" macro instead
5352
5353 char* sv_pvutf8(SV *sv)
5354
5355 sv_pvutf8n
5356 A private implementation of the "SvPVutf8" macro for compilers
5357 which can't cope with complex macro expressions. Always use
5358 the macro instead.
5359
5360 char* sv_pvutf8n(SV *sv, STRLEN *lp)
5361
5362 sv_taint
5363 Taint an SV. Use "SvTAINTED_on" instead.
5364
5365 void sv_taint(SV* sv)
5366
5367 sv_unref
5368 Unsets the RV status of the SV, and decrements the reference
5369 count of whatever was being referenced by the RV. This can
5370 almost be thought of as a reversal of "newSVrv". This is
5371 "sv_unref_flags" with the "flag" being zero. See "SvROK_off".
5372
5373 void sv_unref(SV* sv)
5374
5375 sv_usepvn
5376 Tells an SV to use "ptr" to find its string value. Implemented
5377 by calling "sv_usepvn_flags" with "flags" of 0, hence does not
5378 handle 'set' magic. See "sv_usepvn_flags".
5379
5380 void sv_usepvn(SV* sv, char* ptr, STRLEN len)
5381
5382 sv_usepvn_mg
5383 Like "sv_usepvn", but also handles 'set' magic.
5384
5385 void sv_usepvn_mg(SV *sv, char *ptr, STRLEN len)
5386
5387 sv_uv A private implementation of the "SvUVx" macro for compilers
5388 which can't cope with complex macro expressions. Always use
5389 the macro instead.
5390
5391 UV sv_uv(SV* sv)
5392
5393 unpack_str
5394 The engine implementing "unpack()" Perl function. Note:
5395 parameters "strbeg", "new_s" and "ocnt" are not used. This
5396 call should not be used, use "unpackstring" instead.
5397
5398 SSize_t unpack_str(const char *pat, const char *patend,
5399 const char *s, const char *strbeg,
5400 const char *strend, char **new_s,
5401 I32 ocnt, U32 flags)
5402
5403 utf8_to_uvuni
5404 DEPRECATED! It is planned to remove this function from a
5405 future release of Perl. Do not use it for new code; remove it
5406 from existing code.
5407
5408 Returns the Unicode code point of the first character in the
5409 string "s" which is assumed to be in UTF-8 encoding; "retlen"
5410 will be set to the length, in bytes, of that character.
5411
5412 Some, but not all, UTF-8 malformations are detected, and in
5413 fact, some malformed input could cause reading beyond the end
5414 of the input buffer, which is one reason why this function is
5415 deprecated. The other is that only in extremely limited
5416 circumstances should the Unicode versus native code point be of
5417 any interest to you. See "utf8_to_uvuni_buf" for alternatives.
5418
5419 If "s" points to one of the detected malformations, and UTF8
5420 warnings are enabled, zero is returned and *retlen is set (if
5421 "retlen" doesn't point to NULL) to -1. If those warnings are
5422 off, the computed value if well-defined (or the Unicode
5423 REPLACEMENT CHARACTER, if not) is silently returned, and
5424 *retlen is set (if "retlen" isn't NULL) so that ("s" + *retlen)
5425 is the next possible position in "s" that could begin a non-
5426 malformed character. See "utf8n_to_uvchr" for details on when
5427 the REPLACEMENT CHARACTER is returned.
5428
5429 UV utf8_to_uvuni(const U8 *s, STRLEN *retlen)
5430
5432 newASSIGNOP
5433 Constructs, checks, and returns an assignment op. "left" and
5434 "right" supply the parameters of the assignment; they are
5435 consumed by this function and become part of the constructed op
5436 tree.
5437
5438 If "optype" is "OP_ANDASSIGN", "OP_ORASSIGN", or
5439 "OP_DORASSIGN", then a suitable conditional optree is
5440 constructed. If "optype" is the opcode of a binary operator,
5441 such as "OP_BIT_OR", then an op is constructed that performs
5442 the binary operation and assigns the result to the left
5443 argument. Either way, if "optype" is non-zero then "flags" has
5444 no effect.
5445
5446 If "optype" is zero, then a plain scalar or list assignment is
5447 constructed. Which type of assignment it is is automatically
5448 determined. "flags" gives the eight bits of "op_flags", except
5449 that "OPf_KIDS" will be set automatically, and, shifted up
5450 eight bits, the eight bits of "op_private", except that the bit
5451 with value 1 or 2 is automatically set as required.
5452
5453 OP * newASSIGNOP(I32 flags, OP *left, I32 optype,
5454 OP *right)
5455
5456 newBINOP
5457 Constructs, checks, and returns an op of any binary type.
5458 "type" is the opcode. "flags" gives the eight bits of
5459 "op_flags", except that "OPf_KIDS" will be set automatically,
5460 and, shifted up eight bits, the eight bits of "op_private",
5461 except that the bit with value 1 or 2 is automatically set as
5462 required. "first" and "last" supply up to two ops to be the
5463 direct children of the binary op; they are consumed by this
5464 function and become part of the constructed op tree.
5465
5466 OP * newBINOP(I32 type, I32 flags, OP *first,
5467 OP *last)
5468
5469 newCONDOP
5470 Constructs, checks, and returns a conditional-expression
5471 ("cond_expr") op. "flags" gives the eight bits of "op_flags",
5472 except that "OPf_KIDS" will be set automatically, and, shifted
5473 up eight bits, the eight bits of "op_private", except that the
5474 bit with value 1 is automatically set. "first" supplies the
5475 expression selecting between the two branches, and "trueop" and
5476 "falseop" supply the branches; they are consumed by this
5477 function and become part of the constructed op tree.
5478
5479 OP * newCONDOP(I32 flags, OP *first, OP *trueop,
5480 OP *falseop)
5481
5482 newDEFSVOP
5483 Constructs and returns an op to access $_.
5484
5485 OP * newDEFSVOP()
5486
5487 newFOROP
5488 Constructs, checks, and returns an op tree expressing a
5489 "foreach" loop (iteration through a list of values). This is a
5490 heavyweight loop, with structure that allows exiting the loop
5491 by "last" and suchlike.
5492
5493 "sv" optionally supplies the variable that will be aliased to
5494 each item in turn; if null, it defaults to $_. "expr" supplies
5495 the list of values to iterate over. "block" supplies the main
5496 body of the loop, and "cont" optionally supplies a "continue"
5497 block that operates as a second half of the body. All of these
5498 optree inputs are consumed by this function and become part of
5499 the constructed op tree.
5500
5501 "flags" gives the eight bits of "op_flags" for the "leaveloop"
5502 op and, shifted up eight bits, the eight bits of "op_private"
5503 for the "leaveloop" op, except that (in both cases) some bits
5504 will be set automatically.
5505
5506 OP * newFOROP(I32 flags, OP *sv, OP *expr, OP *block,
5507 OP *cont)
5508
5509 newGIVENOP
5510 Constructs, checks, and returns an op tree expressing a "given"
5511 block. "cond" supplies the expression to whose value $_ will
5512 be locally aliased, and "block" supplies the body of the
5513 "given" construct; they are consumed by this function and
5514 become part of the constructed op tree. "defsv_off" must be
5515 zero (it used to identity the pad slot of lexical $_).
5516
5517 OP * newGIVENOP(OP *cond, OP *block,
5518 PADOFFSET defsv_off)
5519
5520 newGVOP Constructs, checks, and returns an op of any type that involves
5521 an embedded reference to a GV. "type" is the opcode. "flags"
5522 gives the eight bits of "op_flags". "gv" identifies the GV
5523 that the op should reference; calling this function does not
5524 transfer ownership of any reference to it.
5525
5526 OP * newGVOP(I32 type, I32 flags, GV *gv)
5527
5528 newLISTOP
5529 Constructs, checks, and returns an op of any list type. "type"
5530 is the opcode. "flags" gives the eight bits of "op_flags",
5531 except that "OPf_KIDS" will be set automatically if required.
5532 "first" and "last" supply up to two ops to be direct children
5533 of the list op; they are consumed by this function and become
5534 part of the constructed op tree.
5535
5536 For most list operators, the check function expects all the kid
5537 ops to be present already, so calling "newLISTOP(OP_JOIN, ...)"
5538 (e.g.) is not appropriate. What you want to do in that case is
5539 create an op of type "OP_LIST", append more children to it, and
5540 then call "op_convert_list". See "op_convert_list" for more
5541 information.
5542
5543 OP * newLISTOP(I32 type, I32 flags, OP *first,
5544 OP *last)
5545
5546 newLOGOP
5547 Constructs, checks, and returns a logical (flow control) op.
5548 "type" is the opcode. "flags" gives the eight bits of
5549 "op_flags", except that "OPf_KIDS" will be set automatically,
5550 and, shifted up eight bits, the eight bits of "op_private",
5551 except that the bit with value 1 is automatically set. "first"
5552 supplies the expression controlling the flow, and "other"
5553 supplies the side (alternate) chain of ops; they are consumed
5554 by this function and become part of the constructed op tree.
5555
5556 OP * newLOGOP(I32 type, I32 flags, OP *first,
5557 OP *other)
5558
5559 newLOOPEX
5560 Constructs, checks, and returns a loop-exiting op (such as
5561 "goto" or "last"). "type" is the opcode. "label" supplies the
5562 parameter determining the target of the op; it is consumed by
5563 this function and becomes part of the constructed op tree.
5564
5565 OP * newLOOPEX(I32 type, OP *label)
5566
5567 newLOOPOP
5568 Constructs, checks, and returns an op tree expressing a loop.
5569 This is only a loop in the control flow through the op tree; it
5570 does not have the heavyweight loop structure that allows
5571 exiting the loop by "last" and suchlike. "flags" gives the
5572 eight bits of "op_flags" for the top-level op, except that some
5573 bits will be set automatically as required. "expr" supplies
5574 the expression controlling loop iteration, and "block" supplies
5575 the body of the loop; they are consumed by this function and
5576 become part of the constructed op tree. "debuggable" is
5577 currently unused and should always be 1.
5578
5579 OP * newLOOPOP(I32 flags, I32 debuggable, OP *expr,
5580 OP *block)
5581
5582 newMETHOP
5583 Constructs, checks, and returns an op of method type with a
5584 method name evaluated at runtime. "type" is the opcode.
5585 "flags" gives the eight bits of "op_flags", except that
5586 "OPf_KIDS" will be set automatically, and, shifted up eight
5587 bits, the eight bits of "op_private", except that the bit with
5588 value 1 is automatically set. "dynamic_meth" supplies an op
5589 which evaluates method name; it is consumed by this function
5590 and become part of the constructed op tree. Supported optypes:
5591 "OP_METHOD".
5592
5593 OP * newMETHOP(I32 type, I32 flags, OP *first)
5594
5595 newMETHOP_named
5596 Constructs, checks, and returns an op of method type with a
5597 constant method name. "type" is the opcode. "flags" gives the
5598 eight bits of "op_flags", and, shifted up eight bits, the eight
5599 bits of "op_private". "const_meth" supplies a constant method
5600 name; it must be a shared COW string. Supported optypes:
5601 "OP_METHOD_NAMED".
5602
5603 OP * newMETHOP_named(I32 type, I32 flags,
5604 SV *const_meth)
5605
5606 newNULLLIST
5607 Constructs, checks, and returns a new "stub" op, which
5608 represents an empty list expression.
5609
5610 OP * newNULLLIST()
5611
5612 newOP Constructs, checks, and returns an op of any base type (any
5613 type that has no extra fields). "type" is the opcode. "flags"
5614 gives the eight bits of "op_flags", and, shifted up eight bits,
5615 the eight bits of "op_private".
5616
5617 OP * newOP(I32 type, I32 flags)
5618
5619 newPADOP
5620 Constructs, checks, and returns an op of any type that involves
5621 a reference to a pad element. "type" is the opcode. "flags"
5622 gives the eight bits of "op_flags". A pad slot is
5623 automatically allocated, and is populated with "sv"; this
5624 function takes ownership of one reference to it.
5625
5626 This function only exists if Perl has been compiled to use
5627 ithreads.
5628
5629 OP * newPADOP(I32 type, I32 flags, SV *sv)
5630
5631 newPMOP Constructs, checks, and returns an op of any pattern matching
5632 type. "type" is the opcode. "flags" gives the eight bits of
5633 "op_flags" and, shifted up eight bits, the eight bits of
5634 "op_private".
5635
5636 OP * newPMOP(I32 type, I32 flags)
5637
5638 newPVOP Constructs, checks, and returns an op of any type that involves
5639 an embedded C-level pointer (PV). "type" is the opcode.
5640 "flags" gives the eight bits of "op_flags". "pv" supplies the
5641 C-level pointer. Depending on the op type, the memory
5642 referenced by "pv" may be freed when the op is destroyed. If
5643 the op is of a freeing type, "pv" must have been allocated
5644 using "PerlMemShared_malloc".
5645
5646 OP * newPVOP(I32 type, I32 flags, char *pv)
5647
5648 newRANGE
5649 Constructs and returns a "range" op, with subordinate "flip"
5650 and "flop" ops. "flags" gives the eight bits of "op_flags" for
5651 the "flip" op and, shifted up eight bits, the eight bits of
5652 "op_private" for both the "flip" and "range" ops, except that
5653 the bit with value 1 is automatically set. "left" and "right"
5654 supply the expressions controlling the endpoints of the range;
5655 they are consumed by this function and become part of the
5656 constructed op tree.
5657
5658 OP * newRANGE(I32 flags, OP *left, OP *right)
5659
5660 newSLICEOP
5661 Constructs, checks, and returns an "lslice" (list slice) op.
5662 "flags" gives the eight bits of "op_flags", except that
5663 "OPf_KIDS" will be set automatically, and, shifted up eight
5664 bits, the eight bits of "op_private", except that the bit with
5665 value 1 or 2 is automatically set as required. "listval" and
5666 "subscript" supply the parameters of the slice; they are
5667 consumed by this function and become part of the constructed op
5668 tree.
5669
5670 OP * newSLICEOP(I32 flags, OP *subscript,
5671 OP *listval)
5672
5673 newSTATEOP
5674 Constructs a state op (COP). The state op is normally a
5675 "nextstate" op, but will be a "dbstate" op if debugging is
5676 enabled for currently-compiled code. The state op is populated
5677 from "PL_curcop" (or "PL_compiling"). If "label" is non-null,
5678 it supplies the name of a label to attach to the state op; this
5679 function takes ownership of the memory pointed at by "label",
5680 and will free it. "flags" gives the eight bits of "op_flags"
5681 for the state op.
5682
5683 If "o" is null, the state op is returned. Otherwise the state
5684 op is combined with "o" into a "lineseq" list op, which is
5685 returned. "o" is consumed by this function and becomes part of
5686 the returned op tree.
5687
5688 OP * newSTATEOP(I32 flags, char *label, OP *o)
5689
5690 newSVOP Constructs, checks, and returns an op of any type that involves
5691 an embedded SV. "type" is the opcode. "flags" gives the eight
5692 bits of "op_flags". "sv" gives the SV to embed in the op; this
5693 function takes ownership of one reference to it.
5694
5695 OP * newSVOP(I32 type, I32 flags, SV *sv)
5696
5697 newUNOP Constructs, checks, and returns an op of any unary type.
5698 "type" is the opcode. "flags" gives the eight bits of
5699 "op_flags", except that "OPf_KIDS" will be set automatically if
5700 required, and, shifted up eight bits, the eight bits of
5701 "op_private", except that the bit with value 1 is automatically
5702 set. "first" supplies an optional op to be the direct child of
5703 the unary op; it is consumed by this function and become part
5704 of the constructed op tree.
5705
5706 OP * newUNOP(I32 type, I32 flags, OP *first)
5707
5708 newUNOP_AUX
5709 Similar to "newUNOP", but creates an "UNOP_AUX" struct instead,
5710 with "op_aux" initialised to "aux"
5711
5712 OP* newUNOP_AUX(I32 type, I32 flags, OP* first,
5713 UNOP_AUX_item *aux)
5714
5715 newWHENOP
5716 Constructs, checks, and returns an op tree expressing a "when"
5717 block. "cond" supplies the test expression, and "block"
5718 supplies the block that will be executed if the test evaluates
5719 to true; they are consumed by this function and become part of
5720 the constructed op tree. "cond" will be interpreted
5721 DWIMically, often as a comparison against $_, and may be null
5722 to generate a "default" block.
5723
5724 OP * newWHENOP(OP *cond, OP *block)
5725
5726 newWHILEOP
5727 Constructs, checks, and returns an op tree expressing a "while"
5728 loop. This is a heavyweight loop, with structure that allows
5729 exiting the loop by "last" and suchlike.
5730
5731 "loop" is an optional preconstructed "enterloop" op to use in
5732 the loop; if it is null then a suitable op will be constructed
5733 automatically. "expr" supplies the loop's controlling
5734 expression. "block" supplies the main body of the loop, and
5735 "cont" optionally supplies a "continue" block that operates as
5736 a second half of the body. All of these optree inputs are
5737 consumed by this function and become part of the constructed op
5738 tree.
5739
5740 "flags" gives the eight bits of "op_flags" for the "leaveloop"
5741 op and, shifted up eight bits, the eight bits of "op_private"
5742 for the "leaveloop" op, except that (in both cases) some bits
5743 will be set automatically. "debuggable" is currently unused
5744 and should always be 1. "has_my" can be supplied as true to
5745 force the loop body to be enclosed in its own scope.
5746
5747 OP * newWHILEOP(I32 flags, I32 debuggable,
5748 LOOP *loop, OP *expr, OP *block,
5749 OP *cont, I32 has_my)
5750
5752 alloccopstash
5753 NOTE: this function is experimental and may change or be
5754 removed without notice.
5755
5756 Available only under threaded builds, this function allocates
5757 an entry in "PL_stashpad" for the stash passed to it.
5758
5759 PADOFFSET alloccopstash(HV *hv)
5760
5761 block_end
5762 Handles compile-time scope exit. "floor" is the savestack
5763 index returned by "block_start", and "seq" is the body of the
5764 block. Returns the block, possibly modified.
5765
5766 OP * block_end(I32 floor, OP *seq)
5767
5768 block_start
5769 Handles compile-time scope entry. Arranges for hints to be
5770 restored on block exit and also handles pad sequence numbers to
5771 make lexical variables scope right. Returns a savestack index
5772 for use with "block_end".
5773
5774 int block_start(int full)
5775
5776 ck_entersub_args_list
5777 Performs the default fixup of the arguments part of an
5778 "entersub" op tree. This consists of applying list context to
5779 each of the argument ops. This is the standard treatment used
5780 on a call marked with "&", or a method call, or a call through
5781 a subroutine reference, or any other call where the callee
5782 can't be identified at compile time, or a call where the callee
5783 has no prototype.
5784
5785 OP * ck_entersub_args_list(OP *entersubop)
5786
5787 ck_entersub_args_proto
5788 Performs the fixup of the arguments part of an "entersub" op
5789 tree based on a subroutine prototype. This makes various
5790 modifications to the argument ops, from applying context up to
5791 inserting "refgen" ops, and checking the number and syntactic
5792 types of arguments, as directed by the prototype. This is the
5793 standard treatment used on a subroutine call, not marked with
5794 "&", where the callee can be identified at compile time and has
5795 a prototype.
5796
5797 "protosv" supplies the subroutine prototype to be applied to
5798 the call. It may be a normal defined scalar, of which the
5799 string value will be used. Alternatively, for convenience, it
5800 may be a subroutine object (a "CV*" that has been cast to
5801 "SV*") which has a prototype. The prototype supplied, in
5802 whichever form, does not need to match the actual callee
5803 referenced by the op tree.
5804
5805 If the argument ops disagree with the prototype, for example by
5806 having an unacceptable number of arguments, a valid op tree is
5807 returned anyway. The error is reflected in the parser state,
5808 normally resulting in a single exception at the top level of
5809 parsing which covers all the compilation errors that occurred.
5810 In the error message, the callee is referred to by the name
5811 defined by the "namegv" parameter.
5812
5813 OP * ck_entersub_args_proto(OP *entersubop,
5814 GV *namegv, SV *protosv)
5815
5816 ck_entersub_args_proto_or_list
5817 Performs the fixup of the arguments part of an "entersub" op
5818 tree either based on a subroutine prototype or using default
5819 list-context processing. This is the standard treatment used
5820 on a subroutine call, not marked with "&", where the callee can
5821 be identified at compile time.
5822
5823 "protosv" supplies the subroutine prototype to be applied to
5824 the call, or indicates that there is no prototype. It may be a
5825 normal scalar, in which case if it is defined then the string
5826 value will be used as a prototype, and if it is undefined then
5827 there is no prototype. Alternatively, for convenience, it may
5828 be a subroutine object (a "CV*" that has been cast to "SV*"),
5829 of which the prototype will be used if it has one. The
5830 prototype (or lack thereof) supplied, in whichever form, does
5831 not need to match the actual callee referenced by the op tree.
5832
5833 If the argument ops disagree with the prototype, for example by
5834 having an unacceptable number of arguments, a valid op tree is
5835 returned anyway. The error is reflected in the parser state,
5836 normally resulting in a single exception at the top level of
5837 parsing which covers all the compilation errors that occurred.
5838 In the error message, the callee is referred to by the name
5839 defined by the "namegv" parameter.
5840
5841 OP * ck_entersub_args_proto_or_list(OP *entersubop,
5842 GV *namegv,
5843 SV *protosv)
5844
5845 cv_const_sv
5846 If "cv" is a constant sub eligible for inlining, returns the
5847 constant value returned by the sub. Otherwise, returns "NULL".
5848
5849 Constant subs can be created with "newCONSTSUB" or as described
5850 in "Constant Functions" in perlsub.
5851
5852 SV* cv_const_sv(const CV *const cv)
5853
5854 cv_get_call_checker
5855 The original form of "cv_get_call_checker_flags", which does
5856 not return checker flags. When using a checker function
5857 returned by this function, it is only safe to call it with a
5858 genuine GV as its "namegv" argument.
5859
5860 void cv_get_call_checker(CV *cv,
5861 Perl_call_checker *ckfun_p,
5862 SV **ckobj_p)
5863
5864 cv_get_call_checker_flags
5865 Retrieves the function that will be used to fix up a call to
5866 "cv". Specifically, the function is applied to an "entersub"
5867 op tree for a subroutine call, not marked with "&", where the
5868 callee can be identified at compile time as "cv".
5869
5870 The C-level function pointer is returned in *ckfun_p, an SV
5871 argument for it is returned in *ckobj_p, and control flags are
5872 returned in *ckflags_p. The function is intended to be called
5873 in this manner:
5874
5875 entersubop = (*ckfun_p)(aTHX_ entersubop, namegv, (*ckobj_p));
5876
5877 In this call, "entersubop" is a pointer to the "entersub" op,
5878 which may be replaced by the check function, and "namegv"
5879 supplies the name that should be used by the check function to
5880 refer to the callee of the "entersub" op if it needs to emit
5881 any diagnostics. It is permitted to apply the check function
5882 in non-standard situations, such as to a call to a different
5883 subroutine or to a method call.
5884
5885 "namegv" may not actually be a GV. If the
5886 "CALL_CHECKER_REQUIRE_GV" bit is clear in *ckflags_p, it is
5887 permitted to pass a CV or other SV instead, anything that can
5888 be used as the first argument to "cv_name". If the
5889 "CALL_CHECKER_REQUIRE_GV" bit is set in *ckflags_p then the
5890 check function requires "namegv" to be a genuine GV.
5891
5892 By default, the check function is
5893 Perl_ck_entersub_args_proto_or_list, the SV parameter is "cv"
5894 itself, and the "CALL_CHECKER_REQUIRE_GV" flag is clear. This
5895 implements standard prototype processing. It can be changed,
5896 for a particular subroutine, by "cv_set_call_checker_flags".
5897
5898 If the "CALL_CHECKER_REQUIRE_GV" bit is set in "gflags" then it
5899 indicates that the caller only knows about the genuine GV
5900 version of "namegv", and accordingly the corresponding bit will
5901 always be set in *ckflags_p, regardless of the check function's
5902 recorded requirements. If the "CALL_CHECKER_REQUIRE_GV" bit is
5903 clear in "gflags" then it indicates the caller knows about the
5904 possibility of passing something other than a GV as "namegv",
5905 and accordingly the corresponding bit may be either set or
5906 clear in *ckflags_p, indicating the check function's recorded
5907 requirements.
5908
5909 "gflags" is a bitset passed into "cv_get_call_checker_flags",
5910 in which only the "CALL_CHECKER_REQUIRE_GV" bit currently has a
5911 defined meaning (for which see above). All other bits should
5912 be clear.
5913
5914 void cv_get_call_checker_flags(
5915 CV *cv, U32 gflags,
5916 Perl_call_checker *ckfun_p, SV **ckobj_p,
5917 U32 *ckflags_p
5918 )
5919
5920 cv_set_call_checker
5921 The original form of "cv_set_call_checker_flags", which passes
5922 it the "CALL_CHECKER_REQUIRE_GV" flag for backward-
5923 compatibility. The effect of that flag setting is that the
5924 check function is guaranteed to get a genuine GV as its
5925 "namegv" argument.
5926
5927 void cv_set_call_checker(CV *cv,
5928 Perl_call_checker ckfun,
5929 SV *ckobj)
5930
5931 cv_set_call_checker_flags
5932 Sets the function that will be used to fix up a call to "cv".
5933 Specifically, the function is applied to an "entersub" op tree
5934 for a subroutine call, not marked with "&", where the callee
5935 can be identified at compile time as "cv".
5936
5937 The C-level function pointer is supplied in "ckfun", an SV
5938 argument for it is supplied in "ckobj", and control flags are
5939 supplied in "ckflags". The function should be defined like
5940 this:
5941
5942 STATIC OP * ckfun(pTHX_ OP *op, GV *namegv, SV *ckobj)
5943
5944 It is intended to be called in this manner:
5945
5946 entersubop = ckfun(aTHX_ entersubop, namegv, ckobj);
5947
5948 In this call, "entersubop" is a pointer to the "entersub" op,
5949 which may be replaced by the check function, and "namegv"
5950 supplies the name that should be used by the check function to
5951 refer to the callee of the "entersub" op if it needs to emit
5952 any diagnostics. It is permitted to apply the check function
5953 in non-standard situations, such as to a call to a different
5954 subroutine or to a method call.
5955
5956 "namegv" may not actually be a GV. For efficiency, perl may
5957 pass a CV or other SV instead. Whatever is passed can be used
5958 as the first argument to "cv_name". You can force perl to pass
5959 a GV by including "CALL_CHECKER_REQUIRE_GV" in the "ckflags".
5960
5961 "ckflags" is a bitset, in which only the
5962 "CALL_CHECKER_REQUIRE_GV" bit currently has a defined meaning
5963 (for which see above). All other bits should be clear.
5964
5965 The current setting for a particular CV can be retrieved by
5966 "cv_get_call_checker_flags".
5967
5968 void cv_set_call_checker_flags(
5969 CV *cv, Perl_call_checker ckfun, SV *ckobj,
5970 U32 ckflags
5971 )
5972
5973 LINKLIST
5974 Given the root of an optree, link the tree in execution order
5975 using the "op_next" pointers and return the first op executed.
5976 If this has already been done, it will not be redone, and
5977 "o->op_next" will be returned. If "o->op_next" is not already
5978 set, "o" should be at least an "UNOP".
5979
5980 OP* LINKLIST(OP *o)
5981
5982 newCONSTSUB
5983 Behaves like "newCONSTSUB_flags", except that "name" is nul-
5984 terminated rather than of counted length, and no flags are set.
5985 (This means that "name" is always interpreted as Latin-1.)
5986
5987 CV * newCONSTSUB(HV *stash, const char *name, SV *sv)
5988
5989 newCONSTSUB_flags
5990 Construct a constant subroutine, also performing some
5991 surrounding jobs. A scalar constant-valued subroutine is
5992 eligible for inlining at compile-time, and in Perl code can be
5993 created by "sub FOO () { 123 }". Other kinds of constant
5994 subroutine have other treatment.
5995
5996 The subroutine will have an empty prototype and will ignore any
5997 arguments when called. Its constant behaviour is determined by
5998 "sv". If "sv" is null, the subroutine will yield an empty
5999 list. If "sv" points to a scalar, the subroutine will always
6000 yield that scalar. If "sv" points to an array, the subroutine
6001 will always yield a list of the elements of that array in list
6002 context, or the number of elements in the array in scalar
6003 context. This function takes ownership of one counted
6004 reference to the scalar or array, and will arrange for the
6005 object to live as long as the subroutine does. If "sv" points
6006 to a scalar then the inlining assumes that the value of the
6007 scalar will never change, so the caller must ensure that the
6008 scalar is not subsequently written to. If "sv" points to an
6009 array then no such assumption is made, so it is ostensibly safe
6010 to mutate the array or its elements, but whether this is really
6011 supported has not been determined.
6012
6013 The subroutine will have "CvFILE" set according to "PL_curcop".
6014 Other aspects of the subroutine will be left in their default
6015 state. The caller is free to mutate the subroutine beyond its
6016 initial state after this function has returned.
6017
6018 If "name" is null then the subroutine will be anonymous, with
6019 its "CvGV" referring to an "__ANON__" glob. If "name" is non-
6020 null then the subroutine will be named accordingly, referenced
6021 by the appropriate glob. "name" is a string of length "len"
6022 bytes giving a sigilless symbol name, in UTF-8 if "flags" has
6023 the "SVf_UTF8" bit set and in Latin-1 otherwise. The name may
6024 be either qualified or unqualified. If the name is unqualified
6025 then it defaults to being in the stash specified by "stash" if
6026 that is non-null, or to "PL_curstash" if "stash" is null. The
6027 symbol is always added to the stash if necessary, with
6028 "GV_ADDMULTI" semantics.
6029
6030 "flags" should not have bits set other than "SVf_UTF8".
6031
6032 If there is already a subroutine of the specified name, then
6033 the new sub will replace the existing one in the glob. A
6034 warning may be generated about the redefinition.
6035
6036 If the subroutine has one of a few special names, such as
6037 "BEGIN" or "END", then it will be claimed by the appropriate
6038 queue for automatic running of phase-related subroutines. In
6039 this case the relevant glob will be left not containing any
6040 subroutine, even if it did contain one before. Execution of
6041 the subroutine will likely be a no-op, unless "sv" was a tied
6042 array or the caller modified the subroutine in some interesting
6043 way before it was executed. In the case of "BEGIN", the
6044 treatment is buggy: the sub will be executed when only half
6045 built, and may be deleted prematurely, possibly causing a
6046 crash.
6047
6048 The function returns a pointer to the constructed subroutine.
6049 If the sub is anonymous then ownership of one counted reference
6050 to the subroutine is transferred to the caller. If the sub is
6051 named then the caller does not get ownership of a reference.
6052 In most such cases, where the sub has a non-phase name, the sub
6053 will be alive at the point it is returned by virtue of being
6054 contained in the glob that names it. A phase-named subroutine
6055 will usually be alive by virtue of the reference owned by the
6056 phase's automatic run queue. A "BEGIN" subroutine may have
6057 been destroyed already by the time this function returns, but
6058 currently bugs occur in that case before the caller gets
6059 control. It is the caller's responsibility to ensure that it
6060 knows which of these situations applies.
6061
6062 CV * newCONSTSUB_flags(HV *stash, const char *name,
6063 STRLEN len, U32 flags, SV *sv)
6064
6065 newXS Used by "xsubpp" to hook up XSUBs as Perl subs. "filename"
6066 needs to be static storage, as it is used directly as CvFILE(),
6067 without a copy being made.
6068
6069 op_append_elem
6070 Append an item to the list of ops contained directly within a
6071 list-type op, returning the lengthened list. "first" is the
6072 list-type op, and "last" is the op to append to the list.
6073 "optype" specifies the intended opcode for the list. If
6074 "first" is not already a list of the right type, it will be
6075 upgraded into one. If either "first" or "last" is null, the
6076 other is returned unchanged.
6077
6078 OP * op_append_elem(I32 optype, OP *first, OP *last)
6079
6080 op_append_list
6081 Concatenate the lists of ops contained directly within two
6082 list-type ops, returning the combined list. "first" and "last"
6083 are the list-type ops to concatenate. "optype" specifies the
6084 intended opcode for the list. If either "first" or "last" is
6085 not already a list of the right type, it will be upgraded into
6086 one. If either "first" or "last" is null, the other is
6087 returned unchanged.
6088
6089 OP * op_append_list(I32 optype, OP *first, OP *last)
6090
6091 OP_CLASS
6092 Return the class of the provided OP: that is, which of the *OP
6093 structures it uses. For core ops this currently gets the
6094 information out of "PL_opargs", which does not always
6095 accurately reflect the type used; in v5.26 onwards, see also
6096 the function "op_class" which can do a better job of
6097 determining the used type.
6098
6099 For custom ops the type is returned from the registration, and
6100 it is up to the registree to ensure it is accurate. The value
6101 returned will be one of the "OA_"* constants from op.h.
6102
6103 U32 OP_CLASS(OP *o)
6104
6105 op_contextualize
6106 Applies a syntactic context to an op tree representing an
6107 expression. "o" is the op tree, and "context" must be
6108 "G_SCALAR", "G_ARRAY", or "G_VOID" to specify the context to
6109 apply. The modified op tree is returned.
6110
6111 OP * op_contextualize(OP *o, I32 context)
6112
6113 op_convert_list
6114 Converts "o" into a list op if it is not one already, and then
6115 converts it into the specified "type", calling its check
6116 function, allocating a target if it needs one, and folding
6117 constants.
6118
6119 A list-type op is usually constructed one kid at a time via
6120 "newLISTOP", "op_prepend_elem" and "op_append_elem". Then
6121 finally it is passed to "op_convert_list" to make it the right
6122 type.
6123
6124 OP * op_convert_list(I32 type, I32 flags, OP *o)
6125
6126 OP_DESC Return a short description of the provided OP.
6127
6128 const char * OP_DESC(OP *o)
6129
6130 op_free Free an op. Only use this when an op is no longer linked to
6131 from any optree.
6132
6133 void op_free(OP *o)
6134
6135 OpHAS_SIBLING
6136 Returns true if "o" has a sibling
6137
6138 bool OpHAS_SIBLING(OP *o)
6139
6140 OpLASTSIB_set
6141 Marks "o" as having no further siblings. On "PERL_OP_PARENT"
6142 builds, marks o as having the specified parent. See also
6143 "OpMORESIB_set" and "OpMAYBESIB_set". For a higher-level
6144 interface, see "op_sibling_splice".
6145
6146 void OpLASTSIB_set(OP *o, OP *parent)
6147
6148 op_linklist
6149 This function is the implementation of the "LINKLIST" macro.
6150 It should not be called directly.
6151
6152 OP* op_linklist(OP *o)
6153
6154 op_lvalue
6155 NOTE: this function is experimental and may change or be
6156 removed without notice.
6157
6158 Propagate lvalue ("modifiable") context to an op and its
6159 children. "type" represents the context type, roughly based on
6160 the type of op that would do the modifying, although "local()"
6161 is represented by "OP_NULL", because it has no op type of its
6162 own (it is signalled by a flag on the lvalue op).
6163
6164 This function detects things that can't be modified, such as
6165 "$x+1", and generates errors for them. For example, "$x+1 = 2"
6166 would cause it to be called with an op of type "OP_ADD" and a
6167 "type" argument of "OP_SASSIGN".
6168
6169 It also flags things that need to behave specially in an lvalue
6170 context, such as "$$x = 5" which might have to vivify a
6171 reference in $x.
6172
6173 OP * op_lvalue(OP *o, I32 type)
6174
6175 OpMAYBESIB_set
6176 Conditionally does "OpMORESIB_set" or "OpLASTSIB_set" depending
6177 on whether "sib" is non-null. For a higher-level interface, see
6178 "op_sibling_splice".
6179
6180 void OpMAYBESIB_set(OP *o, OP *sib, OP *parent)
6181
6182 OpMORESIB_set
6183 Sets the sibling of "o" to the non-zero value "sib". See also
6184 "OpLASTSIB_set" and "OpMAYBESIB_set". For a higher-level
6185 interface, see "op_sibling_splice".
6186
6187 void OpMORESIB_set(OP *o, OP *sib)
6188
6189 OP_NAME Return the name of the provided OP. For core ops this looks up
6190 the name from the op_type; for custom ops from the op_ppaddr.
6191
6192 const char * OP_NAME(OP *o)
6193
6194 op_null Neutralizes an op when it is no longer needed, but is still
6195 linked to from other ops.
6196
6197 void op_null(OP *o)
6198
6199 op_parent
6200 Returns the parent OP of "o", if it has a parent. Returns
6201 "NULL" otherwise. This function is only available on perls
6202 built with "-DPERL_OP_PARENT".
6203
6204 OP* op_parent(OP *o)
6205
6206 op_prepend_elem
6207 Prepend an item to the list of ops contained directly within a
6208 list-type op, returning the lengthened list. "first" is the op
6209 to prepend to the list, and "last" is the list-type op.
6210 "optype" specifies the intended opcode for the list. If "last"
6211 is not already a list of the right type, it will be upgraded
6212 into one. If either "first" or "last" is null, the other is
6213 returned unchanged.
6214
6215 OP * op_prepend_elem(I32 optype, OP *first, OP *last)
6216
6217 op_scope
6218 NOTE: this function is experimental and may change or be
6219 removed without notice.
6220
6221 Wraps up an op tree with some additional ops so that at runtime
6222 a dynamic scope will be created. The original ops run in the
6223 new dynamic scope, and then, provided that they exit normally,
6224 the scope will be unwound. The additional ops used to create
6225 and unwind the dynamic scope will normally be an
6226 "enter"/"leave" pair, but a "scope" op may be used instead if
6227 the ops are simple enough to not need the full dynamic scope
6228 structure.
6229
6230 OP * op_scope(OP *o)
6231
6232 OpSIBLING
6233 Returns the sibling of "o", or "NULL" if there is no sibling
6234
6235 OP* OpSIBLING(OP *o)
6236
6237 op_sibling_splice
6238 A general function for editing the structure of an existing
6239 chain of op_sibling nodes. By analogy with the perl-level
6240 "splice()" function, allows you to delete zero or more
6241 sequential nodes, replacing them with zero or more different
6242 nodes. Performs the necessary op_first/op_last housekeeping on
6243 the parent node and op_sibling manipulation on the children.
6244 The last deleted node will be marked as as the last node by
6245 updating the op_sibling/op_sibparent or op_moresib field as
6246 appropriate.
6247
6248 Note that op_next is not manipulated, and nodes are not freed;
6249 that is the responsibility of the caller. It also won't create
6250 a new list op for an empty list etc; use higher-level functions
6251 like op_append_elem() for that.
6252
6253 "parent" is the parent node of the sibling chain. It may passed
6254 as "NULL" if the splicing doesn't affect the first or last op
6255 in the chain.
6256
6257 "start" is the node preceding the first node to be spliced.
6258 Node(s) following it will be deleted, and ops will be inserted
6259 after it. If it is "NULL", the first node onwards is deleted,
6260 and nodes are inserted at the beginning.
6261
6262 "del_count" is the number of nodes to delete. If zero, no
6263 nodes are deleted. If -1 or greater than or equal to the
6264 number of remaining kids, all remaining kids are deleted.
6265
6266 "insert" is the first of a chain of nodes to be inserted in
6267 place of the nodes. If "NULL", no nodes are inserted.
6268
6269 The head of the chain of deleted ops is returned, or "NULL" if
6270 no ops were deleted.
6271
6272 For example:
6273
6274 action before after returns
6275 ------ ----- ----- -------
6276
6277 P P
6278 splice(P, A, 2, X-Y-Z) | | B-C
6279 A-B-C-D A-X-Y-Z-D
6280
6281 P P
6282 splice(P, NULL, 1, X-Y) | | A
6283 A-B-C-D X-Y-B-C-D
6284
6285 P P
6286 splice(P, NULL, 3, NULL) | | A-B-C
6287 A-B-C-D D
6288
6289 P P
6290 splice(P, B, 0, X-Y) | | NULL
6291 A-B-C-D A-B-X-Y-C-D
6292
6293 For lower-level direct manipulation of "op_sibparent" and
6294 "op_moresib", see "OpMORESIB_set", "OpLASTSIB_set",
6295 "OpMAYBESIB_set".
6296
6297 OP* op_sibling_splice(OP *parent, OP *start,
6298 int del_count, OP* insert)
6299
6300 OP_TYPE_IS
6301 Returns true if the given OP is not a "NULL" pointer and if it
6302 is of the given type.
6303
6304 The negation of this macro, "OP_TYPE_ISNT" is also available as
6305 well as "OP_TYPE_IS_NN" and "OP_TYPE_ISNT_NN" which elide the
6306 NULL pointer check.
6307
6308 bool OP_TYPE_IS(OP *o, Optype type)
6309
6310 OP_TYPE_IS_OR_WAS
6311 Returns true if the given OP is not a NULL pointer and if it is
6312 of the given type or used to be before being replaced by an OP
6313 of type OP_NULL.
6314
6315 The negation of this macro, "OP_TYPE_ISNT_AND_WASNT" is also
6316 available as well as "OP_TYPE_IS_OR_WAS_NN" and
6317 "OP_TYPE_ISNT_AND_WASNT_NN" which elide the "NULL" pointer
6318 check.
6319
6320 bool OP_TYPE_IS_OR_WAS(OP *o, Optype type)
6321
6322 rv2cv_op_cv
6323 Examines an op, which is expected to identify a subroutine at
6324 runtime, and attempts to determine at compile time which
6325 subroutine it identifies. This is normally used during Perl
6326 compilation to determine whether a prototype can be applied to
6327 a function call. "cvop" is the op being considered, normally
6328 an "rv2cv" op. A pointer to the identified subroutine is
6329 returned, if it could be determined statically, and a null
6330 pointer is returned if it was not possible to determine
6331 statically.
6332
6333 Currently, the subroutine can be identified statically if the
6334 RV that the "rv2cv" is to operate on is provided by a suitable
6335 "gv" or "const" op. A "gv" op is suitable if the GV's CV slot
6336 is populated. A "const" op is suitable if the constant value
6337 must be an RV pointing to a CV. Details of this process may
6338 change in future versions of Perl. If the "rv2cv" op has the
6339 "OPpENTERSUB_AMPER" flag set then no attempt is made to
6340 identify the subroutine statically: this flag is used to
6341 suppress compile-time magic on a subroutine call, forcing it to
6342 use default runtime behaviour.
6343
6344 If "flags" has the bit "RV2CVOPCV_MARK_EARLY" set, then the
6345 handling of a GV reference is modified. If a GV was examined
6346 and its CV slot was found to be empty, then the "gv" op has the
6347 "OPpEARLY_CV" flag set. If the op is not optimised away, and
6348 the CV slot is later populated with a subroutine having a
6349 prototype, that flag eventually triggers the warning "called
6350 too early to check prototype".
6351
6352 If "flags" has the bit "RV2CVOPCV_RETURN_NAME_GV" set, then
6353 instead of returning a pointer to the subroutine it returns a
6354 pointer to the GV giving the most appropriate name for the
6355 subroutine in this context. Normally this is just the "CvGV"
6356 of the subroutine, but for an anonymous ("CvANON") subroutine
6357 that is referenced through a GV it will be the referencing GV.
6358 The resulting "GV*" is cast to "CV*" to be returned. A null
6359 pointer is returned as usual if there is no statically-
6360 determinable subroutine.
6361
6362 CV * rv2cv_op_cv(OP *cvop, U32 flags)
6363
6365 packlist
6366 The engine implementing "pack()" Perl function.
6367
6368 void packlist(SV *cat, const char *pat,
6369 const char *patend, SV **beglist,
6370 SV **endlist)
6371
6372 unpackstring
6373 The engine implementing the "unpack()" Perl function.
6374
6375 Using the template "pat..patend", this function unpacks the
6376 string "s..strend" into a number of mortal SVs, which it pushes
6377 onto the perl argument (@_) stack (so you will need to issue a
6378 "PUTBACK" before and "SPAGAIN" after the call to this
6379 function). It returns the number of pushed elements.
6380
6381 The "strend" and "patend" pointers should point to the byte
6382 following the last character of each string.
6383
6384 Although this function returns its values on the perl argument
6385 stack, it doesn't take any parameters from that stack (and thus
6386 in particular there's no need to do a "PUSHMARK" before calling
6387 it, unlike "call_pv" for example).
6388
6389 SSize_t unpackstring(const char *pat,
6390 const char *patend, const char *s,
6391 const char *strend, U32 flags)
6392
6394 CvPADLIST
6395 NOTE: this function is experimental and may change or be
6396 removed without notice.
6397
6398 CV's can have CvPADLIST(cv) set to point to a PADLIST. This is
6399 the CV's scratchpad, which stores lexical variables and opcode
6400 temporary and per-thread values.
6401
6402 For these purposes "formats" are a kind-of CV; eval""s are too
6403 (except they're not callable at will and are always thrown away
6404 after the eval"" is done executing). Require'd files are
6405 simply evals without any outer lexical scope.
6406
6407 XSUBs do not have a "CvPADLIST". "dXSTARG" fetches values from
6408 "PL_curpad", but that is really the callers pad (a slot of
6409 which is allocated by every entersub). Do not get or set
6410 "CvPADLIST" if a CV is an XSUB (as determined by "CvISXSUB()"),
6411 "CvPADLIST" slot is reused for a different internal purpose in
6412 XSUBs.
6413
6414 The PADLIST has a C array where pads are stored.
6415
6416 The 0th entry of the PADLIST is a PADNAMELIST which represents
6417 the "names" or rather the "static type information" for
6418 lexicals. The individual elements of a PADNAMELIST are
6419 PADNAMEs. Future refactorings might stop the PADNAMELIST from
6420 being stored in the PADLIST's array, so don't rely on it. See
6421 "PadlistNAMES".
6422
6423 The CvDEPTH'th entry of a PADLIST is a PAD (an AV) which is the
6424 stack frame at that depth of recursion into the CV. The 0th
6425 slot of a frame AV is an AV which is @_. Other entries are
6426 storage for variables and op targets.
6427
6428 Iterating over the PADNAMELIST iterates over all possible pad
6429 items. Pad slots for targets ("SVs_PADTMP") and GVs end up
6430 having &PL_padname_undef "names", while slots for constants
6431 have &PL_padname_const "names" (see "pad_alloc"). That
6432 &PL_padname_undef and &PL_padname_const are used is an
6433 implementation detail subject to change. To test for them, use
6434 "!PadnamePV(name)" and "PadnamePV(name) && !PadnameLEN(name)",
6435 respectively.
6436
6437 Only "my"/"our" variable slots get valid names. The rest are
6438 op targets/GVs/constants which are statically allocated or
6439 resolved at compile time. These don't have names by which they
6440 can be looked up from Perl code at run time through eval"" the
6441 way "my"/"our" variables can be. Since they can't be looked up
6442 by "name" but only by their index allocated at compile time
6443 (which is usually in "PL_op->op_targ"), wasting a name SV for
6444 them doesn't make sense.
6445
6446 The pad names in the PADNAMELIST have their PV holding the name
6447 of the variable. The "COP_SEQ_RANGE_LOW" and "_HIGH" fields
6448 form a range (low+1..high inclusive) of cop_seq numbers for
6449 which the name is valid. During compilation, these fields may
6450 hold the special value PERL_PADSEQ_INTRO to indicate various
6451 stages:
6452
6453 COP_SEQ_RANGE_LOW _HIGH
6454 ----------------- -----
6455 PERL_PADSEQ_INTRO 0 variable not yet introduced:
6456 { my ($x
6457 valid-seq# PERL_PADSEQ_INTRO variable in scope:
6458 { my ($x);
6459 valid-seq# valid-seq# compilation of scope complete:
6460 { my ($x); .... }
6461
6462 When a lexical var hasn't yet been introduced, it already
6463 exists from the perspective of duplicate declarations, but not
6464 for variable lookups, e.g.
6465
6466 my ($x, $x); # '"my" variable $x masks earlier declaration'
6467 my $x = $x; # equal to my $x = $::x;
6468
6469 For typed lexicals "PadnameTYPE" points at the type stash. For
6470 "our" lexicals, "PadnameOURSTASH" points at the stash of the
6471 associated global (so that duplicate "our" declarations in the
6472 same package can be detected). "PadnameGEN" is sometimes used
6473 to store the generation number during compilation.
6474
6475 If "PadnameOUTER" is set on the pad name, then that slot in the
6476 frame AV is a REFCNT'ed reference to a lexical from "outside".
6477 Such entries are sometimes referred to as 'fake'. In this
6478 case, the name does not use 'low' and 'high' to store a cop_seq
6479 range, since it is in scope throughout. Instead 'high' stores
6480 some flags containing info about the real lexical (is it
6481 declared in an anon, and is it capable of being instantiated
6482 multiple times?), and for fake ANONs, 'low' contains the index
6483 within the parent's pad where the lexical's value is stored, to
6484 make cloning quicker.
6485
6486 If the 'name' is "&" the corresponding entry in the PAD is a CV
6487 representing a possible closure.
6488
6489 Note that formats are treated as anon subs, and are cloned each
6490 time write is called (if necessary).
6491
6492 The flag "SVs_PADSTALE" is cleared on lexicals each time the
6493 "my()" is executed, and set on scope exit. This allows the
6494 "Variable $x is not available" warning to be generated in
6495 evals, such as
6496
6497 { my $x = 1; sub f { eval '$x'} } f();
6498
6499 For state vars, "SVs_PADSTALE" is overloaded to mean 'not yet
6500 initialised', but this internal state is stored in a separate
6501 pad entry.
6502
6503 PADLIST * CvPADLIST(CV *cv)
6504
6505 pad_add_name_pvs
6506 Exactly like "pad_add_name_pvn", but takes a literal string
6507 instead of a string/length pair.
6508
6509 PADOFFSET pad_add_name_pvs("literal string" name,
6510 U32 flags, HV *typestash,
6511 HV *ourstash)
6512
6513 PadARRAY
6514 NOTE: this function is experimental and may change or be
6515 removed without notice.
6516
6517 The C array of pad entries.
6518
6519 SV ** PadARRAY(PAD pad)
6520
6521 pad_findmy_pvs
6522 Exactly like "pad_findmy_pvn", but takes a literal string
6523 instead of a string/length pair.
6524
6525 PADOFFSET pad_findmy_pvs("literal string" name,
6526 U32 flags)
6527
6528 PadlistARRAY
6529 NOTE: this function is experimental and may change or be
6530 removed without notice.
6531
6532 The C array of a padlist, containing the pads. Only subscript
6533 it with numbers >= 1, as the 0th entry is not guaranteed to
6534 remain usable.
6535
6536 PAD ** PadlistARRAY(PADLIST padlist)
6537
6538 PadlistMAX
6539 NOTE: this function is experimental and may change or be
6540 removed without notice.
6541
6542 The index of the last allocated space in the padlist. Note
6543 that the last pad may be in an earlier slot. Any entries
6544 following it will be "NULL" in that case.
6545
6546 SSize_t PadlistMAX(PADLIST padlist)
6547
6548 PadlistNAMES
6549 NOTE: this function is experimental and may change or be
6550 removed without notice.
6551
6552 The names associated with pad entries.
6553
6554 PADNAMELIST * PadlistNAMES(PADLIST padlist)
6555
6556 PadlistNAMESARRAY
6557 NOTE: this function is experimental and may change or be
6558 removed without notice.
6559
6560 The C array of pad names.
6561
6562 PADNAME ** PadlistNAMESARRAY(PADLIST padlist)
6563
6564 PadlistNAMESMAX
6565 NOTE: this function is experimental and may change or be
6566 removed without notice.
6567
6568 The index of the last pad name.
6569
6570 SSize_t PadlistNAMESMAX(PADLIST padlist)
6571
6572 PadlistREFCNT
6573 NOTE: this function is experimental and may change or be
6574 removed without notice.
6575
6576 The reference count of the padlist. Currently this is always
6577 1.
6578
6579 U32 PadlistREFCNT(PADLIST padlist)
6580
6581 PadMAX NOTE: this function is experimental and may change or be
6582 removed without notice.
6583
6584 The index of the last pad entry.
6585
6586 SSize_t PadMAX(PAD pad)
6587
6588 PadnameLEN
6589 NOTE: this function is experimental and may change or be
6590 removed without notice.
6591
6592 The length of the name.
6593
6594 STRLEN PadnameLEN(PADNAME pn)
6595
6596 PadnamelistARRAY
6597 NOTE: this function is experimental and may change or be
6598 removed without notice.
6599
6600 The C array of pad names.
6601
6602 PADNAME ** PadnamelistARRAY(PADNAMELIST pnl)
6603
6604 PadnamelistMAX
6605 NOTE: this function is experimental and may change or be
6606 removed without notice.
6607
6608 The index of the last pad name.
6609
6610 SSize_t PadnamelistMAX(PADNAMELIST pnl)
6611
6612 PadnamelistREFCNT
6613 NOTE: this function is experimental and may change or be
6614 removed without notice.
6615
6616 The reference count of the pad name list.
6617
6618 SSize_t PadnamelistREFCNT(PADNAMELIST pnl)
6619
6620 PadnamelistREFCNT_dec
6621 NOTE: this function is experimental and may change or be
6622 removed without notice.
6623
6624 Lowers the reference count of the pad name list.
6625
6626 void PadnamelistREFCNT_dec(PADNAMELIST pnl)
6627
6628 PadnamePV
6629 NOTE: this function is experimental and may change or be
6630 removed without notice.
6631
6632 The name stored in the pad name struct. This returns "NULL"
6633 for a target slot.
6634
6635 char * PadnamePV(PADNAME pn)
6636
6637 PadnameREFCNT
6638 NOTE: this function is experimental and may change or be
6639 removed without notice.
6640
6641 The reference count of the pad name.
6642
6643 SSize_t PadnameREFCNT(PADNAME pn)
6644
6645 PadnameREFCNT_dec
6646 NOTE: this function is experimental and may change or be
6647 removed without notice.
6648
6649 Lowers the reference count of the pad name.
6650
6651 void PadnameREFCNT_dec(PADNAME pn)
6652
6653 PadnameSV
6654 NOTE: this function is experimental and may change or be
6655 removed without notice.
6656
6657 Returns the pad name as a mortal SV.
6658
6659 SV * PadnameSV(PADNAME pn)
6660
6661 PadnameUTF8
6662 NOTE: this function is experimental and may change or be
6663 removed without notice.
6664
6665 Whether PadnamePV is in UTF-8. Currently, this is always true.
6666
6667 bool PadnameUTF8(PADNAME pn)
6668
6669 pad_new Create a new padlist, updating the global variables for the
6670 currently-compiling padlist to point to the new padlist. The
6671 following flags can be OR'ed together:
6672
6673 padnew_CLONE this pad is for a cloned CV
6674 padnew_SAVE save old globals on the save stack
6675 padnew_SAVESUB also save extra stuff for start of sub
6676
6677 PADLIST * pad_new(int flags)
6678
6679 PL_comppad
6680 NOTE: this function is experimental and may change or be
6681 removed without notice.
6682
6683 During compilation, this points to the array containing the
6684 values part of the pad for the currently-compiling code. (At
6685 runtime a CV may have many such value arrays; at compile time
6686 just one is constructed.) At runtime, this points to the array
6687 containing the currently-relevant values for the pad for the
6688 currently-executing code.
6689
6690 PL_comppad_name
6691 NOTE: this function is experimental and may change or be
6692 removed without notice.
6693
6694 During compilation, this points to the array containing the
6695 names part of the pad for the currently-compiling code.
6696
6697 PL_curpad
6698 NOTE: this function is experimental and may change or be
6699 removed without notice.
6700
6701 Points directly to the body of the "PL_comppad" array. (I.e.,
6702 this is "PadARRAY(PL_comppad)".)
6703
6705 PL_modglobal
6706 "PL_modglobal" is a general purpose, interpreter global HV for
6707 use by extensions that need to keep information on a per-
6708 interpreter basis. In a pinch, it can also be used as a symbol
6709 table for extensions to share data among each other. It is a
6710 good idea to use keys prefixed by the package name of the
6711 extension that owns the data.
6712
6713 HV* PL_modglobal
6714
6715 PL_na A convenience variable which is typically used with "SvPV" when
6716 one doesn't care about the length of the string. It is usually
6717 more efficient to either declare a local variable and use that
6718 instead or to use the "SvPV_nolen" macro.
6719
6720 STRLEN PL_na
6721
6722 PL_opfreehook
6723 When non-"NULL", the function pointed by this variable will be
6724 called each time an OP is freed with the corresponding OP as
6725 the argument. This allows extensions to free any extra
6726 attribute they have locally attached to an OP. It is also
6727 assured to first fire for the parent OP and then for its kids.
6728
6729 When you replace this variable, it is considered a good
6730 practice to store the possibly previously installed hook and
6731 that you recall it inside your own.
6732
6733 Perl_ophook_t PL_opfreehook
6734
6735 PL_peepp
6736 Pointer to the per-subroutine peephole optimiser. This is a
6737 function that gets called at the end of compilation of a Perl
6738 subroutine (or equivalently independent piece of Perl code) to
6739 perform fixups of some ops and to perform small-scale
6740 optimisations. The function is called once for each subroutine
6741 that is compiled, and is passed, as sole parameter, a pointer
6742 to the op that is the entry point to the subroutine. It
6743 modifies the op tree in place.
6744
6745 The peephole optimiser should never be completely replaced.
6746 Rather, add code to it by wrapping the existing optimiser. The
6747 basic way to do this can be seen in "Compile pass 3: peephole
6748 optimization" in perlguts. If the new code wishes to operate
6749 on ops throughout the subroutine's structure, rather than just
6750 at the top level, it is likely to be more convenient to wrap
6751 the "PL_rpeepp" hook.
6752
6753 peep_t PL_peepp
6754
6755 PL_rpeepp
6756 Pointer to the recursive peephole optimiser. This is a
6757 function that gets called at the end of compilation of a Perl
6758 subroutine (or equivalently independent piece of Perl code) to
6759 perform fixups of some ops and to perform small-scale
6760 optimisations. The function is called once for each chain of
6761 ops linked through their "op_next" fields; it is recursively
6762 called to handle each side chain. It is passed, as sole
6763 parameter, a pointer to the op that is at the head of the
6764 chain. It modifies the op tree in place.
6765
6766 The peephole optimiser should never be completely replaced.
6767 Rather, add code to it by wrapping the existing optimiser. The
6768 basic way to do this can be seen in "Compile pass 3: peephole
6769 optimization" in perlguts. If the new code wishes to operate
6770 only on ops at a subroutine's top level, rather than throughout
6771 the structure, it is likely to be more convenient to wrap the
6772 "PL_peepp" hook.
6773
6774 peep_t PL_rpeepp
6775
6776 PL_sv_no
6777 This is the "false" SV. See "PL_sv_yes". Always refer to this
6778 as &PL_sv_no.
6779
6780 SV PL_sv_no
6781
6782 PL_sv_undef
6783 This is the "undef" SV. Always refer to this as &PL_sv_undef.
6784
6785 SV PL_sv_undef
6786
6787 PL_sv_yes
6788 This is the "true" SV. See "PL_sv_no". Always refer to this
6789 as &PL_sv_yes.
6790
6791 SV PL_sv_yes
6792
6793 PL_sv_zero
6794 This readonly SV has a zero numeric value and a "0" string
6795 value. It's similar to "PL_sv_no" except for its string value.
6796 Can be used as a cheap alternative to mXPUSHi(0) for example.
6797 Always refer to this as &PL_sv_zero. Introduced in 5.28.
6798
6799 SV PL_sv_zero
6800
6802 SvRX Convenience macro to get the REGEXP from a SV. This is
6803 approximately equivalent to the following snippet:
6804
6805 if (SvMAGICAL(sv))
6806 mg_get(sv);
6807 if (SvROK(sv))
6808 sv = MUTABLE_SV(SvRV(sv));
6809 if (SvTYPE(sv) == SVt_REGEXP)
6810 return (REGEXP*) sv;
6811
6812 "NULL" will be returned if a REGEXP* is not found.
6813
6814 REGEXP * SvRX(SV *sv)
6815
6816 SvRXOK Returns a boolean indicating whether the SV (or the one it
6817 references) is a REGEXP.
6818
6819 If you want to do something with the REGEXP* later use SvRX
6820 instead and check for NULL.
6821
6822 bool SvRXOK(SV* sv)
6823
6825 dMARK Declare a stack marker variable, "mark", for the XSUB. See
6826 "MARK" and "dORIGMARK".
6827
6828 dMARK;
6829
6830 dORIGMARK
6831 Saves the original stack mark for the XSUB. See "ORIGMARK".
6832
6833 dORIGMARK;
6834
6835 dSP Declares a local copy of perl's stack pointer for the XSUB,
6836 available via the "SP" macro. See "SP".
6837
6838 dSP;
6839
6840 EXTEND Used to extend the argument stack for an XSUB's return values.
6841 Once used, guarantees that there is room for at least "nitems"
6842 to be pushed onto the stack.
6843
6844 void EXTEND(SP, SSize_t nitems)
6845
6846 MARK Stack marker variable for the XSUB. See "dMARK".
6847
6848 mPUSHi Push an integer onto the stack. The stack must have room for
6849 this element. Does not use "TARG". See also "PUSHi",
6850 "mXPUSHi" and "XPUSHi".
6851
6852 void mPUSHi(IV iv)
6853
6854 mPUSHn Push a double onto the stack. The stack must have room for
6855 this element. Does not use "TARG". See also "PUSHn",
6856 "mXPUSHn" and "XPUSHn".
6857
6858 void mPUSHn(NV nv)
6859
6860 mPUSHp Push a string onto the stack. The stack must have room for
6861 this element. The "len" indicates the length of the string.
6862 Does not use "TARG". See also "PUSHp", "mXPUSHp" and "XPUSHp".
6863
6864 void mPUSHp(char* str, STRLEN len)
6865
6866 mPUSHs Push an SV onto the stack and mortalizes the SV. The stack
6867 must have room for this element. Does not use "TARG". See
6868 also "PUSHs" and "mXPUSHs".
6869
6870 void mPUSHs(SV* sv)
6871
6872 mPUSHu Push an unsigned integer onto the stack. The stack must have
6873 room for this element. Does not use "TARG". See also "PUSHu",
6874 "mXPUSHu" and "XPUSHu".
6875
6876 void mPUSHu(UV uv)
6877
6878 mXPUSHi Push an integer onto the stack, extending the stack if
6879 necessary. Does not use "TARG". See also "XPUSHi", "mPUSHi"
6880 and "PUSHi".
6881
6882 void mXPUSHi(IV iv)
6883
6884 mXPUSHn Push a double onto the stack, extending the stack if necessary.
6885 Does not use "TARG". See also "XPUSHn", "mPUSHn" and "PUSHn".
6886
6887 void mXPUSHn(NV nv)
6888
6889 mXPUSHp Push a string onto the stack, extending the stack if necessary.
6890 The "len" indicates the length of the string. Does not use
6891 "TARG". See also "XPUSHp", "mPUSHp" and "PUSHp".
6892
6893 void mXPUSHp(char* str, STRLEN len)
6894
6895 mXPUSHs Push an SV onto the stack, extending the stack if necessary and
6896 mortalizes the SV. Does not use "TARG". See also "XPUSHs" and
6897 "mPUSHs".
6898
6899 void mXPUSHs(SV* sv)
6900
6901 mXPUSHu Push an unsigned integer onto the stack, extending the stack if
6902 necessary. Does not use "TARG". See also "XPUSHu", "mPUSHu"
6903 and "PUSHu".
6904
6905 void mXPUSHu(UV uv)
6906
6907 ORIGMARK
6908 The original stack mark for the XSUB. See "dORIGMARK".
6909
6910 POPi Pops an integer off the stack.
6911
6912 IV POPi
6913
6914 POPl Pops a long off the stack.
6915
6916 long POPl
6917
6918 POPn Pops a double off the stack.
6919
6920 NV POPn
6921
6922 POPp Pops a string off the stack.
6923
6924 char* POPp
6925
6926 POPpbytex
6927 Pops a string off the stack which must consist of bytes i.e.
6928 characters < 256.
6929
6930 char* POPpbytex
6931
6932 POPpx Pops a string off the stack. Identical to POPp. There are two
6933 names for historical reasons.
6934
6935 char* POPpx
6936
6937 POPs Pops an SV off the stack.
6938
6939 SV* POPs
6940
6941 POPu Pops an unsigned integer off the stack.
6942
6943 UV POPu
6944
6945 POPul Pops an unsigned long off the stack.
6946
6947 long POPul
6948
6949 PUSHi Push an integer onto the stack. The stack must have room for
6950 this element. Handles 'set' magic. Uses "TARG", so "dTARGET"
6951 or "dXSTARG" should be called to declare it. Do not call
6952 multiple "TARG"-oriented macros to return lists from XSUB's -
6953 see "mPUSHi" instead. See also "XPUSHi" and "mXPUSHi".
6954
6955 void PUSHi(IV iv)
6956
6957 PUSHMARK
6958 Opening bracket for arguments on a callback. See "PUTBACK" and
6959 perlcall.
6960
6961 void PUSHMARK(SP)
6962
6963 PUSHmortal
6964 Push a new mortal SV onto the stack. The stack must have room
6965 for this element. Does not use "TARG". See also "PUSHs",
6966 "XPUSHmortal" and "XPUSHs".
6967
6968 void PUSHmortal()
6969
6970 PUSHn Push a double onto the stack. The stack must have room for
6971 this element. Handles 'set' magic. Uses "TARG", so "dTARGET"
6972 or "dXSTARG" should be called to declare it. Do not call
6973 multiple "TARG"-oriented macros to return lists from XSUB's -
6974 see "mPUSHn" instead. See also "XPUSHn" and "mXPUSHn".
6975
6976 void PUSHn(NV nv)
6977
6978 PUSHp Push a string onto the stack. The stack must have room for
6979 this element. The "len" indicates the length of the string.
6980 Handles 'set' magic. Uses "TARG", so "dTARGET" or "dXSTARG"
6981 should be called to declare it. Do not call multiple
6982 "TARG"-oriented macros to return lists from XSUB's - see
6983 "mPUSHp" instead. See also "XPUSHp" and "mXPUSHp".
6984
6985 void PUSHp(char* str, STRLEN len)
6986
6987 PUSHs Push an SV onto the stack. The stack must have room for this
6988 element. Does not handle 'set' magic. Does not use "TARG".
6989 See also "PUSHmortal", "XPUSHs", and "XPUSHmortal".
6990
6991 void PUSHs(SV* sv)
6992
6993 PUSHu Push an unsigned integer onto the stack. The stack must have
6994 room for this element. Handles 'set' magic. Uses "TARG", so
6995 "dTARGET" or "dXSTARG" should be called to declare it. Do not
6996 call multiple "TARG"-oriented macros to return lists from
6997 XSUB's - see "mPUSHu" instead. See also "XPUSHu" and
6998 "mXPUSHu".
6999
7000 void PUSHu(UV uv)
7001
7002 PUTBACK Closing bracket for XSUB arguments. This is usually handled by
7003 "xsubpp". See "PUSHMARK" and perlcall for other uses.
7004
7005 PUTBACK;
7006
7007 SP Stack pointer. This is usually handled by "xsubpp". See "dSP"
7008 and "SPAGAIN".
7009
7010 SPAGAIN Refetch the stack pointer. Used after a callback. See
7011 perlcall.
7012
7013 SPAGAIN;
7014
7015 XPUSHi Push an integer onto the stack, extending the stack if
7016 necessary. Handles 'set' magic. Uses "TARG", so "dTARGET" or
7017 "dXSTARG" should be called to declare it. Do not call multiple
7018 "TARG"-oriented macros to return lists from XSUB's - see
7019 "mXPUSHi" instead. See also "PUSHi" and "mPUSHi".
7020
7021 void XPUSHi(IV iv)
7022
7023 XPUSHmortal
7024 Push a new mortal SV onto the stack, extending the stack if
7025 necessary. Does not use "TARG". See also "XPUSHs",
7026 "PUSHmortal" and "PUSHs".
7027
7028 void XPUSHmortal()
7029
7030 XPUSHn Push a double onto the stack, extending the stack if necessary.
7031 Handles 'set' magic. Uses "TARG", so "dTARGET" or "dXSTARG"
7032 should be called to declare it. Do not call multiple
7033 "TARG"-oriented macros to return lists from XSUB's - see
7034 "mXPUSHn" instead. See also "PUSHn" and "mPUSHn".
7035
7036 void XPUSHn(NV nv)
7037
7038 XPUSHp Push a string onto the stack, extending the stack if necessary.
7039 The "len" indicates the length of the string. Handles 'set'
7040 magic. Uses "TARG", so "dTARGET" or "dXSTARG" should be called
7041 to declare it. Do not call multiple "TARG"-oriented macros to
7042 return lists from XSUB's - see "mXPUSHp" instead. See also
7043 "PUSHp" and "mPUSHp".
7044
7045 void XPUSHp(char* str, STRLEN len)
7046
7047 XPUSHs Push an SV onto the stack, extending the stack if necessary.
7048 Does not handle 'set' magic. Does not use "TARG". See also
7049 "XPUSHmortal", "PUSHs" and "PUSHmortal".
7050
7051 void XPUSHs(SV* sv)
7052
7053 XPUSHu Push an unsigned integer onto the stack, extending the stack if
7054 necessary. Handles 'set' magic. Uses "TARG", so "dTARGET" or
7055 "dXSTARG" should be called to declare it. Do not call multiple
7056 "TARG"-oriented macros to return lists from XSUB's - see
7057 "mXPUSHu" instead. See also "PUSHu" and "mPUSHu".
7058
7059 void XPUSHu(UV uv)
7060
7061 XSRETURN
7062 Return from XSUB, indicating number of items on the stack.
7063 This is usually handled by "xsubpp".
7064
7065 void XSRETURN(int nitems)
7066
7067 XSRETURN_EMPTY
7068 Return an empty list from an XSUB immediately.
7069
7070 XSRETURN_EMPTY;
7071
7072 XSRETURN_IV
7073 Return an integer from an XSUB immediately. Uses "XST_mIV".
7074
7075 void XSRETURN_IV(IV iv)
7076
7077 XSRETURN_NO
7078 Return &PL_sv_no from an XSUB immediately. Uses "XST_mNO".
7079
7080 XSRETURN_NO;
7081
7082 XSRETURN_NV
7083 Return a double from an XSUB immediately. Uses "XST_mNV".
7084
7085 void XSRETURN_NV(NV nv)
7086
7087 XSRETURN_PV
7088 Return a copy of a string from an XSUB immediately. Uses
7089 "XST_mPV".
7090
7091 void XSRETURN_PV(char* str)
7092
7093 XSRETURN_UNDEF
7094 Return &PL_sv_undef from an XSUB immediately. Uses
7095 "XST_mUNDEF".
7096
7097 XSRETURN_UNDEF;
7098
7099 XSRETURN_UV
7100 Return an integer from an XSUB immediately. Uses "XST_mUV".
7101
7102 void XSRETURN_UV(IV uv)
7103
7104 XSRETURN_YES
7105 Return &PL_sv_yes from an XSUB immediately. Uses "XST_mYES".
7106
7107 XSRETURN_YES;
7108
7109 XST_mIV Place an integer into the specified position "pos" on the
7110 stack. The value is stored in a new mortal SV.
7111
7112 void XST_mIV(int pos, IV iv)
7113
7114 XST_mNO Place &PL_sv_no into the specified position "pos" on the stack.
7115
7116 void XST_mNO(int pos)
7117
7118 XST_mNV Place a double into the specified position "pos" on the stack.
7119 The value is stored in a new mortal SV.
7120
7121 void XST_mNV(int pos, NV nv)
7122
7123 XST_mPV Place a copy of a string into the specified position "pos" on
7124 the stack. The value is stored in a new mortal SV.
7125
7126 void XST_mPV(int pos, char* str)
7127
7128 XST_mUNDEF
7129 Place &PL_sv_undef into the specified position "pos" on the
7130 stack.
7131
7132 void XST_mUNDEF(int pos)
7133
7134 XST_mYES
7135 Place &PL_sv_yes into the specified position "pos" on the
7136 stack.
7137
7138 void XST_mYES(int pos)
7139
7141 looks_like_number
7142 Test if the content of an SV looks like a number (or is a
7143 number). "Inf" and "Infinity" are treated as numbers (so will
7144 not issue a non-numeric warning), even if your "atof()" doesn't
7145 grok them. Get-magic is ignored.
7146
7147 I32 looks_like_number(SV *const sv)
7148
7149 newRV_noinc
7150 Creates an RV wrapper for an SV. The reference count for the
7151 original SV is not incremented.
7152
7153 SV* newRV_noinc(SV *const tmpRef)
7154
7155 newSV Creates a new SV. A non-zero "len" parameter indicates the
7156 number of bytes of preallocated string space the SV should
7157 have. An extra byte for a trailing "NUL" is also reserved.
7158 ("SvPOK" is not set for the SV even if string space is
7159 allocated.) The reference count for the new SV is set to 1.
7160
7161 In 5.9.3, "newSV()" replaces the older "NEWSV()" API, and drops
7162 the first parameter, x, a debug aid which allowed callers to
7163 identify themselves. This aid has been superseded by a new
7164 build option, "PERL_MEM_LOG" (see "PERL_MEM_LOG" in
7165 perlhacktips). The older API is still there for use in XS
7166 modules supporting older perls.
7167
7168 SV* newSV(const STRLEN len)
7169
7170 newSVhek
7171 Creates a new SV from the hash key structure. It will generate
7172 scalars that point to the shared string table where possible.
7173 Returns a new (undefined) SV if "hek" is NULL.
7174
7175 SV* newSVhek(const HEK *const hek)
7176
7177 newSViv Creates a new SV and copies an integer into it. The reference
7178 count for the SV is set to 1.
7179
7180 SV* newSViv(const IV i)
7181
7182 newSVnv Creates a new SV and copies a floating point value into it.
7183 The reference count for the SV is set to 1.
7184
7185 SV* newSVnv(const NV n)
7186
7187 newSVpv Creates a new SV and copies a string (which may contain "NUL"
7188 ("\0") characters) into it. The reference count for the SV is
7189 set to 1. If "len" is zero, Perl will compute the length using
7190 "strlen()", (which means if you use this option, that "s" can't
7191 have embedded "NUL" characters and has to have a terminating
7192 "NUL" byte).
7193
7194 This function can cause reliability issues if you are likely to
7195 pass in empty strings that are not null terminated, because it
7196 will run strlen on the string and potentially run past valid
7197 memory.
7198
7199 Using "newSVpvn" is a safer alternative for non "NUL"
7200 terminated strings. For string literals use "newSVpvs"
7201 instead. This function will work fine for "NUL" terminated
7202 strings, but if you want to avoid the if statement on whether
7203 to call "strlen" use "newSVpvn" instead (calling "strlen"
7204 yourself).
7205
7206 SV* newSVpv(const char *const s, const STRLEN len)
7207
7208 newSVpvf
7209 Creates a new SV and initializes it with the string formatted
7210 like "sv_catpvf".
7211
7212 SV* newSVpvf(const char *const pat, ...)
7213
7214 newSVpvn
7215 Creates a new SV and copies a string into it, which may contain
7216 "NUL" characters ("\0") and other binary data. The reference
7217 count for the SV is set to 1. Note that if "len" is zero, Perl
7218 will create a zero length (Perl) string. You are responsible
7219 for ensuring that the source buffer is at least "len" bytes
7220 long. If the "s" argument is NULL the new SV will be
7221 undefined.
7222
7223 SV* newSVpvn(const char *const buffer,
7224 const STRLEN len)
7225
7226 newSVpvn_flags
7227 Creates a new SV and copies a string (which may contain "NUL"
7228 ("\0") characters) into it. The reference count for the SV is
7229 set to 1. Note that if "len" is zero, Perl will create a zero
7230 length string. You are responsible for ensuring that the
7231 source string is at least "len" bytes long. If the "s"
7232 argument is NULL the new SV will be undefined. Currently the
7233 only flag bits accepted are "SVf_UTF8" and "SVs_TEMP". If
7234 "SVs_TEMP" is set, then "sv_2mortal()" is called on the result
7235 before returning. If "SVf_UTF8" is set, "s" is considered to
7236 be in UTF-8 and the "SVf_UTF8" flag will be set on the new SV.
7237 "newSVpvn_utf8()" is a convenience wrapper for this function,
7238 defined as
7239
7240 #define newSVpvn_utf8(s, len, u) \
7241 newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0)
7242
7243 SV* newSVpvn_flags(const char *const s,
7244 const STRLEN len,
7245 const U32 flags)
7246
7247 newSVpvn_share
7248 Creates a new SV with its "SvPVX_const" pointing to a shared
7249 string in the string table. If the string does not already
7250 exist in the table, it is created first. Turns on the
7251 "SvIsCOW" flag (or "READONLY" and "FAKE" in 5.16 and earlier).
7252 If the "hash" parameter is non-zero, that value is used;
7253 otherwise the hash is computed. The string's hash can later be
7254 retrieved from the SV with the "SvSHARED_HASH()" macro. The
7255 idea here is that as the string table is used for shared hash
7256 keys these strings will have "SvPVX_const == HeKEY" and hash
7257 lookup will avoid string compare.
7258
7259 SV* newSVpvn_share(const char* s, I32 len, U32 hash)
7260
7261 newSVpvs
7262 Like "newSVpvn", but takes a literal string instead of a
7263 string/length pair.
7264
7265 SV* newSVpvs("literal string" s)
7266
7267 newSVpvs_flags
7268 Like "newSVpvn_flags", but takes a literal string instead of a
7269 string/length pair.
7270
7271 SV* newSVpvs_flags("literal string" s, U32 flags)
7272
7273 newSVpv_share
7274 Like "newSVpvn_share", but takes a "NUL"-terminated string
7275 instead of a string/length pair.
7276
7277 SV* newSVpv_share(const char* s, U32 hash)
7278
7279 newSVpvs_share
7280 Like "newSVpvn_share", but takes a literal string instead of a
7281 string/length pair and omits the hash parameter.
7282
7283 SV* newSVpvs_share("literal string" s)
7284
7285 newSVrv Creates a new SV for the existing RV, "rv", to point to. If
7286 "rv" is not an RV then it will be upgraded to one. If
7287 "classname" is non-null then the new SV will be blessed in the
7288 specified package. The new SV is returned and its reference
7289 count is 1. The reference count 1 is owned by "rv".
7290
7291 SV* newSVrv(SV *const rv,
7292 const char *const classname)
7293
7294 newSVsv Creates a new SV which is an exact duplicate of the original
7295 SV. (Uses "sv_setsv".)
7296
7297 SV* newSVsv(SV *const old)
7298
7299 newSV_type
7300 Creates a new SV, of the type specified. The reference count
7301 for the new SV is set to 1.
7302
7303 SV* newSV_type(const svtype type)
7304
7305 newSVuv Creates a new SV and copies an unsigned integer into it. The
7306 reference count for the SV is set to 1.
7307
7308 SV* newSVuv(const UV u)
7309
7310 sv_2bool
7311 This macro is only used by "sv_true()" or its macro equivalent,
7312 and only if the latter's argument is neither "SvPOK", "SvIOK"
7313 nor "SvNOK". It calls "sv_2bool_flags" with the "SV_GMAGIC"
7314 flag.
7315
7316 bool sv_2bool(SV *const sv)
7317
7318 sv_2bool_flags
7319 This function is only used by "sv_true()" and friends, and
7320 only if the latter's argument is neither "SvPOK", "SvIOK" nor
7321 "SvNOK". If the flags contain "SV_GMAGIC", then it does an
7322 "mg_get()" first.
7323
7324 bool sv_2bool_flags(SV *sv, I32 flags)
7325
7326 sv_2cv Using various gambits, try to get a CV from an SV; in addition,
7327 try if possible to set *st and *gvp to the stash and GV
7328 associated with it. The flags in "lref" are passed to
7329 "gv_fetchsv".
7330
7331 CV* sv_2cv(SV* sv, HV **const st, GV **const gvp,
7332 const I32 lref)
7333
7334 sv_2io Using various gambits, try to get an IO from an SV: the IO slot
7335 if its a GV; or the recursive result if we're an RV; or the IO
7336 slot of the symbol named after the PV if we're a string.
7337
7338 'Get' magic is ignored on the "sv" passed in, but will be
7339 called on "SvRV(sv)" if "sv" is an RV.
7340
7341 IO* sv_2io(SV *const sv)
7342
7343 sv_2iv_flags
7344 Return the integer value of an SV, doing any necessary string
7345 conversion. If "flags" has the "SV_GMAGIC" bit set, does an
7346 "mg_get()" first. Normally used via the "SvIV(sv)" and
7347 "SvIVx(sv)" macros.
7348
7349 IV sv_2iv_flags(SV *const sv, const I32 flags)
7350
7351 sv_2mortal
7352 Marks an existing SV as mortal. The SV will be destroyed
7353 "soon", either by an explicit call to "FREETMPS", or by an
7354 implicit call at places such as statement boundaries.
7355 "SvTEMP()" is turned on which means that the SV's string buffer
7356 can be "stolen" if this SV is copied. See also "sv_newmortal"
7357 and "sv_mortalcopy".
7358
7359 SV* sv_2mortal(SV *const sv)
7360
7361 sv_2nv_flags
7362 Return the num value of an SV, doing any necessary string or
7363 integer conversion. If "flags" has the "SV_GMAGIC" bit set,
7364 does an "mg_get()" first. Normally used via the "SvNV(sv)" and
7365 "SvNVx(sv)" macros.
7366
7367 NV sv_2nv_flags(SV *const sv, const I32 flags)
7368
7369 sv_2pvbyte
7370 Return a pointer to the byte-encoded representation of the SV,
7371 and set *lp to its length. May cause the SV to be downgraded
7372 from UTF-8 as a side-effect.
7373
7374 Usually accessed via the "SvPVbyte" macro.
7375
7376 char* sv_2pvbyte(SV *sv, STRLEN *const lp)
7377
7378 sv_2pvutf8
7379 Return a pointer to the UTF-8-encoded representation of the SV,
7380 and set *lp to its length. May cause the SV to be upgraded to
7381 UTF-8 as a side-effect.
7382
7383 Usually accessed via the "SvPVutf8" macro.
7384
7385 char* sv_2pvutf8(SV *sv, STRLEN *const lp)
7386
7387 sv_2pv_flags
7388 Returns a pointer to the string value of an SV, and sets *lp to
7389 its length. If flags has the "SV_GMAGIC" bit set, does an
7390 "mg_get()" first. Coerces "sv" to a string if necessary.
7391 Normally invoked via the "SvPV_flags" macro. "sv_2pv()" and
7392 "sv_2pv_nomg" usually end up here too.
7393
7394 char* sv_2pv_flags(SV *const sv, STRLEN *const lp,
7395 const I32 flags)
7396
7397 sv_2uv_flags
7398 Return the unsigned integer value of an SV, doing any necessary
7399 string conversion. If "flags" has the "SV_GMAGIC" bit set,
7400 does an "mg_get()" first. Normally used via the "SvUV(sv)" and
7401 "SvUVx(sv)" macros.
7402
7403 UV sv_2uv_flags(SV *const sv, const I32 flags)
7404
7405 sv_backoff
7406 Remove any string offset. You should normally use the
7407 "SvOOK_off" macro wrapper instead.
7408
7409 void sv_backoff(SV *const sv)
7410
7411 sv_bless
7412 Blesses an SV into a specified package. The SV must be an RV.
7413 The package must be designated by its stash (see "gv_stashpv").
7414 The reference count of the SV is unaffected.
7415
7416 SV* sv_bless(SV *const sv, HV *const stash)
7417
7418 sv_catpv
7419 Concatenates the "NUL"-terminated string onto the end of the
7420 string which is in the SV. If the SV has the UTF-8 status set,
7421 then the bytes appended should be valid UTF-8. Handles 'get'
7422 magic, but not 'set' magic. See "sv_catpv_mg".
7423
7424 void sv_catpv(SV *const sv, const char* ptr)
7425
7426 sv_catpvf
7427 Processes its arguments like "sprintf", and appends the
7428 formatted output to an SV. As with "sv_vcatpvfn" called with a
7429 non-null C-style variable argument list, argument reordering is
7430 not supported. If the appended data contains "wide" characters
7431 (including, but not limited to, SVs with a UTF-8 PV formatted
7432 with %s, and characters >255 formatted with %c), the original
7433 SV might get upgraded to UTF-8. Handles 'get' magic, but not
7434 'set' magic. See "sv_catpvf_mg". If the original SV was
7435 UTF-8, the pattern should be valid UTF-8; if the original SV
7436 was bytes, the pattern should be too.
7437
7438 void sv_catpvf(SV *const sv, const char *const pat,
7439 ...)
7440
7441 sv_catpvf_mg
7442 Like "sv_catpvf", but also handles 'set' magic.
7443
7444 void sv_catpvf_mg(SV *const sv,
7445 const char *const pat, ...)
7446
7447 sv_catpvn
7448 Concatenates the string onto the end of the string which is in
7449 the SV. "len" indicates number of bytes to copy. If the SV
7450 has the UTF-8 status set, then the bytes appended should be
7451 valid UTF-8. Handles 'get' magic, but not 'set' magic. See
7452 "sv_catpvn_mg".
7453
7454 void sv_catpvn(SV *dsv, const char *sstr, STRLEN len)
7455
7456 sv_catpvn_flags
7457 Concatenates the string onto the end of the string which is in
7458 the SV. The "len" indicates number of bytes to copy.
7459
7460 By default, the string appended is assumed to be valid UTF-8 if
7461 the SV has the UTF-8 status set, and a string of bytes
7462 otherwise. One can force the appended string to be interpreted
7463 as UTF-8 by supplying the "SV_CATUTF8" flag, and as bytes by
7464 supplying the "SV_CATBYTES" flag; the SV or the string appended
7465 will be upgraded to UTF-8 if necessary.
7466
7467 If "flags" has the "SV_SMAGIC" bit set, will "mg_set" on "dsv"
7468 afterwards if appropriate. "sv_catpvn" and "sv_catpvn_nomg"
7469 are implemented in terms of this function.
7470
7471 void sv_catpvn_flags(SV *const dstr,
7472 const char *sstr,
7473 const STRLEN len,
7474 const I32 flags)
7475
7476 sv_catpvs
7477 Like "sv_catpvn", but takes a literal string instead of a
7478 string/length pair.
7479
7480 void sv_catpvs(SV* sv, "literal string" s)
7481
7482 sv_catpvs_flags
7483 Like "sv_catpvn_flags", but takes a literal string instead of a
7484 string/length pair.
7485
7486 void sv_catpvs_flags(SV* sv, "literal string" s,
7487 I32 flags)
7488
7489 sv_catpvs_mg
7490 Like "sv_catpvn_mg", but takes a literal string instead of a
7491 string/length pair.
7492
7493 void sv_catpvs_mg(SV* sv, "literal string" s)
7494
7495 sv_catpvs_nomg
7496 Like "sv_catpvn_nomg", but takes a literal string instead of a
7497 string/length pair.
7498
7499 void sv_catpvs_nomg(SV* sv, "literal string" s)
7500
7501 sv_catpv_flags
7502 Concatenates the "NUL"-terminated string onto the end of the
7503 string which is in the SV. If the SV has the UTF-8 status set,
7504 then the bytes appended should be valid UTF-8. If "flags" has
7505 the "SV_SMAGIC" bit set, will "mg_set" on the modified SV if
7506 appropriate.
7507
7508 void sv_catpv_flags(SV *dstr, const char *sstr,
7509 const I32 flags)
7510
7511 sv_catpv_mg
7512 Like "sv_catpv", but also handles 'set' magic.
7513
7514 void sv_catpv_mg(SV *const sv, const char *const ptr)
7515
7516 sv_catsv
7517 Concatenates the string from SV "ssv" onto the end of the
7518 string in SV "dsv". If "ssv" is null, does nothing; otherwise
7519 modifies only "dsv". Handles 'get' magic on both SVs, but no
7520 'set' magic. See "sv_catsv_mg" and "sv_catsv_nomg".
7521
7522 void sv_catsv(SV *dstr, SV *sstr)
7523
7524 sv_catsv_flags
7525 Concatenates the string from SV "ssv" onto the end of the
7526 string in SV "dsv". If "ssv" is null, does nothing; otherwise
7527 modifies only "dsv". If "flags" has the "SV_GMAGIC" bit set,
7528 will call "mg_get" on both SVs if appropriate. If "flags" has
7529 the "SV_SMAGIC" bit set, "mg_set" will be called on the
7530 modified SV afterward, if appropriate. "sv_catsv",
7531 "sv_catsv_nomg", and "sv_catsv_mg" are implemented in terms of
7532 this function.
7533
7534 void sv_catsv_flags(SV *const dsv, SV *const ssv,
7535 const I32 flags)
7536
7537 sv_chop Efficient removal of characters from the beginning of the
7538 string buffer. "SvPOK(sv)", or at least "SvPOKp(sv)", must be
7539 true and "ptr" must be a pointer to somewhere inside the string
7540 buffer. "ptr" becomes the first character of the adjusted
7541 string. Uses the "OOK" hack. On return, only "SvPOK(sv)" and
7542 "SvPOKp(sv)" among the "OK" flags will be true.
7543
7544 Beware: after this function returns, "ptr" and SvPVX_const(sv)
7545 may no longer refer to the same chunk of data.
7546
7547 The unfortunate similarity of this function's name to that of
7548 Perl's "chop" operator is strictly coincidental. This function
7549 works from the left; "chop" works from the right.
7550
7551 void sv_chop(SV *const sv, const char *const ptr)
7552
7553 sv_clear
7554 Clear an SV: call any destructors, free up any memory used by
7555 the body, and free the body itself. The SV's head is not
7556 freed, although its type is set to all 1's so that it won't
7557 inadvertently be assumed to be live during global destruction
7558 etc. This function should only be called when "REFCNT" is
7559 zero. Most of the time you'll want to call "sv_free()" (or its
7560 macro wrapper "SvREFCNT_dec") instead.
7561
7562 void sv_clear(SV *const orig_sv)
7563
7564 sv_cmp Compares the strings in two SVs. Returns -1, 0, or 1
7565 indicating whether the string in "sv1" is less than, equal to,
7566 or greater than the string in "sv2". Is UTF-8 and 'use bytes'
7567 aware, handles get magic, and will coerce its args to strings
7568 if necessary. See also "sv_cmp_locale".
7569
7570 I32 sv_cmp(SV *const sv1, SV *const sv2)
7571
7572 sv_cmp_flags
7573 Compares the strings in two SVs. Returns -1, 0, or 1
7574 indicating whether the string in "sv1" is less than, equal to,
7575 or greater than the string in "sv2". Is UTF-8 and 'use bytes'
7576 aware and will coerce its args to strings if necessary. If the
7577 flags has the "SV_GMAGIC" bit set, it handles get magic. See
7578 also "sv_cmp_locale_flags".
7579
7580 I32 sv_cmp_flags(SV *const sv1, SV *const sv2,
7581 const U32 flags)
7582
7583 sv_cmp_locale
7584 Compares the strings in two SVs in a locale-aware manner. Is
7585 UTF-8 and 'use bytes' aware, handles get magic, and will coerce
7586 its args to strings if necessary. See also "sv_cmp".
7587
7588 I32 sv_cmp_locale(SV *const sv1, SV *const sv2)
7589
7590 sv_cmp_locale_flags
7591 Compares the strings in two SVs in a locale-aware manner. Is
7592 UTF-8 and 'use bytes' aware and will coerce its args to strings
7593 if necessary. If the flags contain "SV_GMAGIC", it handles get
7594 magic. See also "sv_cmp_flags".
7595
7596 I32 sv_cmp_locale_flags(SV *const sv1,
7597 SV *const sv2,
7598 const U32 flags)
7599
7600 sv_collxfrm
7601 This calls "sv_collxfrm_flags" with the SV_GMAGIC flag. See
7602 "sv_collxfrm_flags".
7603
7604 char* sv_collxfrm(SV *const sv, STRLEN *const nxp)
7605
7606 sv_collxfrm_flags
7607 Add Collate Transform magic to an SV if it doesn't already have
7608 it. If the flags contain "SV_GMAGIC", it handles get-magic.
7609
7610 Any scalar variable may carry "PERL_MAGIC_collxfrm" magic that
7611 contains the scalar data of the variable, but transformed to
7612 such a format that a normal memory comparison can be used to
7613 compare the data according to the locale settings.
7614
7615 char* sv_collxfrm_flags(SV *const sv,
7616 STRLEN *const nxp,
7617 I32 const flags)
7618
7619 sv_copypv
7620 Copies a stringified representation of the source SV into the
7621 destination SV. Automatically performs any necessary "mg_get"
7622 and coercion of numeric values into strings. Guaranteed to
7623 preserve "UTF8" flag even from overloaded objects. Similar in
7624 nature to "sv_2pv[_flags]" but operates directly on an SV
7625 instead of just the string. Mostly uses "sv_2pv_flags" to do
7626 its work, except when that would lose the UTF-8'ness of the PV.
7627
7628 void sv_copypv(SV *const dsv, SV *const ssv)
7629
7630 sv_copypv_flags
7631 Implementation of "sv_copypv" and "sv_copypv_nomg". Calls get
7632 magic iff flags has the "SV_GMAGIC" bit set.
7633
7634 void sv_copypv_flags(SV *const dsv, SV *const ssv,
7635 const I32 flags)
7636
7637 sv_copypv_nomg
7638 Like "sv_copypv", but doesn't invoke get magic first.
7639
7640 void sv_copypv_nomg(SV *const dsv, SV *const ssv)
7641
7642 sv_dec Auto-decrement of the value in the SV, doing string to numeric
7643 conversion if necessary. Handles 'get' magic and operator
7644 overloading.
7645
7646 void sv_dec(SV *const sv)
7647
7648 sv_dec_nomg
7649 Auto-decrement of the value in the SV, doing string to numeric
7650 conversion if necessary. Handles operator overloading. Skips
7651 handling 'get' magic.
7652
7653 void sv_dec_nomg(SV *const sv)
7654
7655 sv_eq Returns a boolean indicating whether the strings in the two SVs
7656 are identical. Is UTF-8 and 'use bytes' aware, handles get
7657 magic, and will coerce its args to strings if necessary.
7658
7659 I32 sv_eq(SV* sv1, SV* sv2)
7660
7661 sv_eq_flags
7662 Returns a boolean indicating whether the strings in the two SVs
7663 are identical. Is UTF-8 and 'use bytes' aware and coerces its
7664 args to strings if necessary. If the flags has the "SV_GMAGIC"
7665 bit set, it handles get-magic, too.
7666
7667 I32 sv_eq_flags(SV* sv1, SV* sv2, const U32 flags)
7668
7669 sv_force_normal_flags
7670 Undo various types of fakery on an SV, where fakery means "more
7671 than" a string: if the PV is a shared string, make a private
7672 copy; if we're a ref, stop refing; if we're a glob, downgrade
7673 to an "xpvmg"; if we're a copy-on-write scalar, this is the on-
7674 write time when we do the copy, and is also used locally; if
7675 this is a vstring, drop the vstring magic. If "SV_COW_DROP_PV"
7676 is set then a copy-on-write scalar drops its PV buffer (if any)
7677 and becomes "SvPOK_off" rather than making a copy. (Used where
7678 this scalar is about to be set to some other value.) In
7679 addition, the "flags" parameter gets passed to
7680 "sv_unref_flags()" when unreffing. "sv_force_normal" calls
7681 this function with flags set to 0.
7682
7683 This function is expected to be used to signal to perl that
7684 this SV is about to be written to, and any extra book-keeping
7685 needs to be taken care of. Hence, it croaks on read-only
7686 values.
7687
7688 void sv_force_normal_flags(SV *const sv,
7689 const U32 flags)
7690
7691 sv_free Decrement an SV's reference count, and if it drops to zero,
7692 call "sv_clear" to invoke destructors and free up any memory
7693 used by the body; finally, deallocating the SV's head itself.
7694 Normally called via a wrapper macro "SvREFCNT_dec".
7695
7696 void sv_free(SV *const sv)
7697
7698 sv_gets Get a line from the filehandle and store it into the SV,
7699 optionally appending to the currently-stored string. If
7700 "append" is not 0, the line is appended to the SV instead of
7701 overwriting it. "append" should be set to the byte offset that
7702 the appended string should start at in the SV (typically,
7703 "SvCUR(sv)" is a suitable choice).
7704
7705 char* sv_gets(SV *const sv, PerlIO *const fp,
7706 I32 append)
7707
7708 sv_get_backrefs
7709 NOTE: this function is experimental and may change or be
7710 removed without notice.
7711
7712 If "sv" is the target of a weak reference then it returns the
7713 back references structure associated with the sv; otherwise
7714 return "NULL".
7715
7716 When returning a non-null result the type of the return is
7717 relevant. If it is an AV then the elements of the AV are the
7718 weak reference RVs which point at this item. If it is any other
7719 type then the item itself is the weak reference.
7720
7721 See also "Perl_sv_add_backref()", "Perl_sv_del_backref()",
7722 "Perl_sv_kill_backrefs()"
7723
7724 SV* sv_get_backrefs(SV *const sv)
7725
7726 sv_grow Expands the character buffer in the SV. If necessary, uses
7727 "sv_unref" and upgrades the SV to "SVt_PV". Returns a pointer
7728 to the character buffer. Use the "SvGROW" wrapper instead.
7729
7730 char* sv_grow(SV *const sv, STRLEN newlen)
7731
7732 sv_inc Auto-increment of the value in the SV, doing string to numeric
7733 conversion if necessary. Handles 'get' magic and operator
7734 overloading.
7735
7736 void sv_inc(SV *const sv)
7737
7738 sv_inc_nomg
7739 Auto-increment of the value in the SV, doing string to numeric
7740 conversion if necessary. Handles operator overloading. Skips
7741 handling 'get' magic.
7742
7743 void sv_inc_nomg(SV *const sv)
7744
7745 sv_insert
7746 Inserts a string at the specified offset/length within the SV.
7747 Similar to the Perl "substr()" function. Handles get magic.
7748
7749 void sv_insert(SV *const bigstr, const STRLEN offset,
7750 const STRLEN len,
7751 const char *const little,
7752 const STRLEN littlelen)
7753
7754 sv_insert_flags
7755 Same as "sv_insert", but the extra "flags" are passed to the
7756 "SvPV_force_flags" that applies to "bigstr".
7757
7758 void sv_insert_flags(SV *const bigstr,
7759 const STRLEN offset,
7760 const STRLEN len,
7761 const char *little,
7762 const STRLEN littlelen,
7763 const U32 flags)
7764
7765 sv_isa Returns a boolean indicating whether the SV is blessed into the
7766 specified class. This does not check for subtypes; use
7767 "sv_derived_from" to verify an inheritance relationship.
7768
7769 int sv_isa(SV* sv, const char *const name)
7770
7771 sv_isobject
7772 Returns a boolean indicating whether the SV is an RV pointing
7773 to a blessed object. If the SV is not an RV, or if the object
7774 is not blessed, then this will return false.
7775
7776 int sv_isobject(SV* sv)
7777
7778 sv_len Returns the length of the string in the SV. Handles magic and
7779 type coercion and sets the UTF8 flag appropriately. See also
7780 "SvCUR", which gives raw access to the "xpv_cur" slot.
7781
7782 STRLEN sv_len(SV *const sv)
7783
7784 sv_len_utf8
7785 Returns the number of characters in the string in an SV,
7786 counting wide UTF-8 bytes as a single character. Handles magic
7787 and type coercion.
7788
7789 STRLEN sv_len_utf8(SV *const sv)
7790
7791 sv_magic
7792 Adds magic to an SV. First upgrades "sv" to type "SVt_PVMG" if
7793 necessary, then adds a new magic item of type "how" to the head
7794 of the magic list.
7795
7796 See "sv_magicext" (which "sv_magic" now calls) for a
7797 description of the handling of the "name" and "namlen"
7798 arguments.
7799
7800 You need to use "sv_magicext" to add magic to "SvREADONLY" SVs
7801 and also to add more than one instance of the same "how".
7802
7803 void sv_magic(SV *const sv, SV *const obj,
7804 const int how, const char *const name,
7805 const I32 namlen)
7806
7807 sv_magicext
7808 Adds magic to an SV, upgrading it if necessary. Applies the
7809 supplied "vtable" and returns a pointer to the magic added.
7810
7811 Note that "sv_magicext" will allow things that "sv_magic" will
7812 not. In particular, you can add magic to "SvREADONLY" SVs, and
7813 add more than one instance of the same "how".
7814
7815 If "namlen" is greater than zero then a "savepvn" copy of
7816 "name" is stored, if "namlen" is zero then "name" is stored as-
7817 is and - as another special case - if "(name && namlen ==
7818 HEf_SVKEY)" then "name" is assumed to contain an SV* and is
7819 stored as-is with its "REFCNT" incremented.
7820
7821 (This is now used as a subroutine by "sv_magic".)
7822
7823 MAGIC * sv_magicext(SV *const sv, SV *const obj,
7824 const int how,
7825 const MGVTBL *const vtbl,
7826 const char *const name,
7827 const I32 namlen)
7828
7829 sv_mortalcopy
7830 Creates a new SV which is a copy of the original SV (using
7831 "sv_setsv"). The new SV is marked as mortal. It will be
7832 destroyed "soon", either by an explicit call to "FREETMPS", or
7833 by an implicit call at places such as statement boundaries.
7834 See also "sv_newmortal" and "sv_2mortal".
7835
7836 SV* sv_mortalcopy(SV *const oldsv)
7837
7838 sv_newmortal
7839 Creates a new null SV which is mortal. The reference count of
7840 the SV is set to 1. It will be destroyed "soon", either by an
7841 explicit call to "FREETMPS", or by an implicit call at places
7842 such as statement boundaries. See also "sv_mortalcopy" and
7843 "sv_2mortal".
7844
7845 SV* sv_newmortal()
7846
7847 sv_newref
7848 Increment an SV's reference count. Use the "SvREFCNT_inc()"
7849 wrapper instead.
7850
7851 SV* sv_newref(SV *const sv)
7852
7853 sv_pos_b2u
7854 Converts the value pointed to by "offsetp" from a count of
7855 bytes from the start of the string, to a count of the
7856 equivalent number of UTF-8 chars. Handles magic and type
7857 coercion.
7858
7859 Use "sv_pos_b2u_flags" in preference, which correctly handles
7860 strings longer than 2Gb.
7861
7862 void sv_pos_b2u(SV *const sv, I32 *const offsetp)
7863
7864 sv_pos_b2u_flags
7865 Converts "offset" from a count of bytes from the start of the
7866 string, to a count of the equivalent number of UTF-8 chars.
7867 Handles type coercion. "flags" is passed to "SvPV_flags", and
7868 usually should be "SV_GMAGIC|SV_CONST_RETURN" to handle magic.
7869
7870 STRLEN sv_pos_b2u_flags(SV *const sv,
7871 STRLEN const offset, U32 flags)
7872
7873 sv_pos_u2b
7874 Converts the value pointed to by "offsetp" from a count of
7875 UTF-8 chars from the start of the string, to a count of the
7876 equivalent number of bytes; if "lenp" is non-zero, it does the
7877 same to "lenp", but this time starting from the offset, rather
7878 than from the start of the string. Handles magic and type
7879 coercion.
7880
7881 Use "sv_pos_u2b_flags" in preference, which correctly handles
7882 strings longer than 2Gb.
7883
7884 void sv_pos_u2b(SV *const sv, I32 *const offsetp,
7885 I32 *const lenp)
7886
7887 sv_pos_u2b_flags
7888 Converts the offset from a count of UTF-8 chars from the start
7889 of the string, to a count of the equivalent number of bytes; if
7890 "lenp" is non-zero, it does the same to "lenp", but this time
7891 starting from "offset", rather than from the start of the
7892 string. Handles type coercion. "flags" is passed to
7893 "SvPV_flags", and usually should be "SV_GMAGIC|SV_CONST_RETURN"
7894 to handle magic.
7895
7896 STRLEN sv_pos_u2b_flags(SV *const sv, STRLEN uoffset,
7897 STRLEN *const lenp, U32 flags)
7898
7899 sv_pvbyten_force
7900 The backend for the "SvPVbytex_force" macro. Always use the
7901 macro instead.
7902
7903 char* sv_pvbyten_force(SV *const sv, STRLEN *const lp)
7904
7905 sv_pvn_force
7906 Get a sensible string out of the SV somehow. A private
7907 implementation of the "SvPV_force" macro for compilers which
7908 can't cope with complex macro expressions. Always use the
7909 macro instead.
7910
7911 char* sv_pvn_force(SV* sv, STRLEN* lp)
7912
7913 sv_pvn_force_flags
7914 Get a sensible string out of the SV somehow. If "flags" has
7915 the "SV_GMAGIC" bit set, will "mg_get" on "sv" if appropriate,
7916 else not. "sv_pvn_force" and "sv_pvn_force_nomg" are
7917 implemented in terms of this function. You normally want to
7918 use the various wrapper macros instead: see "SvPV_force" and
7919 "SvPV_force_nomg".
7920
7921 char* sv_pvn_force_flags(SV *const sv,
7922 STRLEN *const lp,
7923 const I32 flags)
7924
7925 sv_pvutf8n_force
7926 The backend for the "SvPVutf8x_force" macro. Always use the
7927 macro instead.
7928
7929 char* sv_pvutf8n_force(SV *const sv, STRLEN *const lp)
7930
7931 sv_ref Returns a SV describing what the SV passed in is a reference
7932 to.
7933
7934 dst can be a SV to be set to the description or NULL, in which
7935 case a mortal SV is returned.
7936
7937 If ob is true and the SV is blessed, the description is the
7938 class name, otherwise it is the type of the SV, "SCALAR",
7939 "ARRAY" etc.
7940
7941 SV* sv_ref(SV *dst, const SV *const sv,
7942 const int ob)
7943
7944 sv_reftype
7945 Returns a string describing what the SV is a reference to.
7946
7947 If ob is true and the SV is blessed, the string is the class
7948 name, otherwise it is the type of the SV, "SCALAR", "ARRAY"
7949 etc.
7950
7951 const char* sv_reftype(const SV *const sv, const int ob)
7952
7953 sv_replace
7954 Make the first argument a copy of the second, then delete the
7955 original. The target SV physically takes over ownership of the
7956 body of the source SV and inherits its flags; however, the
7957 target keeps any magic it owns, and any magic in the source is
7958 discarded. Note that this is a rather specialist SV copying
7959 operation; most of the time you'll want to use "sv_setsv" or
7960 one of its many macro front-ends.
7961
7962 void sv_replace(SV *const sv, SV *const nsv)
7963
7964 sv_reset
7965 Underlying implementation for the "reset" Perl function. Note
7966 that the perl-level function is vaguely deprecated.
7967
7968 void sv_reset(const char* s, HV *const stash)
7969
7970 sv_rvunweaken
7971 Unweaken a reference: Clear the "SvWEAKREF" flag on this RV;
7972 remove the backreference to this RV from the array of
7973 backreferences associated with the target SV, increment the
7974 refcount of the target. Silently ignores "undef" and warns on
7975 non-weak references.
7976
7977 SV* sv_rvunweaken(SV *const sv)
7978
7979 sv_rvweaken
7980 Weaken a reference: set the "SvWEAKREF" flag on this RV; give
7981 the referred-to SV "PERL_MAGIC_backref" magic if it hasn't
7982 already; and push a back-reference to this RV onto the array of
7983 backreferences associated with that magic. If the RV is
7984 magical, set magic will be called after the RV is cleared.
7985 Silently ignores "undef" and warns on already-weak references.
7986
7987 SV* sv_rvweaken(SV *const sv)
7988
7989 sv_setiv
7990 Copies an integer into the given SV, upgrading first if
7991 necessary. Does not handle 'set' magic. See also
7992 "sv_setiv_mg".
7993
7994 void sv_setiv(SV *const sv, const IV num)
7995
7996 sv_setiv_mg
7997 Like "sv_setiv", but also handles 'set' magic.
7998
7999 void sv_setiv_mg(SV *const sv, const IV i)
8000
8001 sv_setnv
8002 Copies a double into the given SV, upgrading first if
8003 necessary. Does not handle 'set' magic. See also
8004 "sv_setnv_mg".
8005
8006 void sv_setnv(SV *const sv, const NV num)
8007
8008 sv_setnv_mg
8009 Like "sv_setnv", but also handles 'set' magic.
8010
8011 void sv_setnv_mg(SV *const sv, const NV num)
8012
8013 sv_setpv
8014 Copies a string into an SV. The string must be terminated with
8015 a "NUL" character, and not contain embeded "NUL"'s. Does not
8016 handle 'set' magic. See "sv_setpv_mg".
8017
8018 void sv_setpv(SV *const sv, const char *const ptr)
8019
8020 sv_setpvf
8021 Works like "sv_catpvf" but copies the text into the SV instead
8022 of appending it. Does not handle 'set' magic. See
8023 "sv_setpvf_mg".
8024
8025 void sv_setpvf(SV *const sv, const char *const pat,
8026 ...)
8027
8028 sv_setpvf_mg
8029 Like "sv_setpvf", but also handles 'set' magic.
8030
8031 void sv_setpvf_mg(SV *const sv,
8032 const char *const pat, ...)
8033
8034 sv_setpviv
8035 Copies an integer into the given SV, also updating its string
8036 value. Does not handle 'set' magic. See "sv_setpviv_mg".
8037
8038 void sv_setpviv(SV *const sv, const IV num)
8039
8040 sv_setpviv_mg
8041 Like "sv_setpviv", but also handles 'set' magic.
8042
8043 void sv_setpviv_mg(SV *const sv, const IV iv)
8044
8045 sv_setpvn
8046 Copies a string (possibly containing embedded "NUL" characters)
8047 into an SV. The "len" parameter indicates the number of bytes
8048 to be copied. If the "ptr" argument is NULL the SV will become
8049 undefined. Does not handle 'set' magic. See "sv_setpvn_mg".
8050
8051 void sv_setpvn(SV *const sv, const char *const ptr,
8052 const STRLEN len)
8053
8054 sv_setpvn_mg
8055 Like "sv_setpvn", but also handles 'set' magic.
8056
8057 void sv_setpvn_mg(SV *const sv,
8058 const char *const ptr,
8059 const STRLEN len)
8060
8061 sv_setpvs
8062 Like "sv_setpvn", but takes a literal string instead of a
8063 string/length pair.
8064
8065 void sv_setpvs(SV* sv, "literal string" s)
8066
8067 sv_setpvs_mg
8068 Like "sv_setpvn_mg", but takes a literal string instead of a
8069 string/length pair.
8070
8071 void sv_setpvs_mg(SV* sv, "literal string" s)
8072
8073 sv_setpv_bufsize
8074 Sets the SV to be a string of cur bytes length, with at least
8075 len bytes available. Ensures that there is a null byte at
8076 SvEND. Returns a char * pointer to the SvPV buffer.
8077
8078 char * sv_setpv_bufsize(SV *const sv, const STRLEN cur,
8079 const STRLEN len)
8080
8081 sv_setpv_mg
8082 Like "sv_setpv", but also handles 'set' magic.
8083
8084 void sv_setpv_mg(SV *const sv, const char *const ptr)
8085
8086 sv_setref_iv
8087 Copies an integer into a new SV, optionally blessing the SV.
8088 The "rv" argument will be upgraded to an RV. That RV will be
8089 modified to point to the new SV. The "classname" argument
8090 indicates the package for the blessing. Set "classname" to
8091 "NULL" to avoid the blessing. The new SV will have a reference
8092 count of 1, and the RV will be returned.
8093
8094 SV* sv_setref_iv(SV *const rv,
8095 const char *const classname,
8096 const IV iv)
8097
8098 sv_setref_nv
8099 Copies a double into a new SV, optionally blessing the SV. The
8100 "rv" argument will be upgraded to an RV. That RV will be
8101 modified to point to the new SV. The "classname" argument
8102 indicates the package for the blessing. Set "classname" to
8103 "NULL" to avoid the blessing. The new SV will have a reference
8104 count of 1, and the RV will be returned.
8105
8106 SV* sv_setref_nv(SV *const rv,
8107 const char *const classname,
8108 const NV nv)
8109
8110 sv_setref_pv
8111 Copies a pointer into a new SV, optionally blessing the SV.
8112 The "rv" argument will be upgraded to an RV. That RV will be
8113 modified to point to the new SV. If the "pv" argument is
8114 "NULL", then "PL_sv_undef" will be placed into the SV. The
8115 "classname" argument indicates the package for the blessing.
8116 Set "classname" to "NULL" to avoid the blessing. The new SV
8117 will have a reference count of 1, and the RV will be returned.
8118
8119 Do not use with other Perl types such as HV, AV, SV, CV,
8120 because those objects will become corrupted by the pointer copy
8121 process.
8122
8123 Note that "sv_setref_pvn" copies the string while this copies
8124 the pointer.
8125
8126 SV* sv_setref_pv(SV *const rv,
8127 const char *const classname,
8128 void *const pv)
8129
8130 sv_setref_pvn
8131 Copies a string into a new SV, optionally blessing the SV. The
8132 length of the string must be specified with "n". The "rv"
8133 argument will be upgraded to an RV. That RV will be modified
8134 to point to the new SV. The "classname" argument indicates the
8135 package for the blessing. Set "classname" to "NULL" to avoid
8136 the blessing. The new SV will have a reference count of 1, and
8137 the RV will be returned.
8138
8139 Note that "sv_setref_pv" copies the pointer while this copies
8140 the string.
8141
8142 SV* sv_setref_pvn(SV *const rv,
8143 const char *const classname,
8144 const char *const pv,
8145 const STRLEN n)
8146
8147 sv_setref_pvs
8148 Like "sv_setref_pvn", but takes a literal string instead of a
8149 string/length pair.
8150
8151 SV * sv_setref_pvs("literal string" s)
8152
8153 sv_setref_uv
8154 Copies an unsigned integer into a new SV, optionally blessing
8155 the SV. The "rv" argument will be upgraded to an RV. That RV
8156 will be modified to point to the new SV. The "classname"
8157 argument indicates the package for the blessing. Set
8158 "classname" to "NULL" to avoid the blessing. The new SV will
8159 have a reference count of 1, and the RV will be returned.
8160
8161 SV* sv_setref_uv(SV *const rv,
8162 const char *const classname,
8163 const UV uv)
8164
8165 sv_setsv
8166 Copies the contents of the source SV "ssv" into the destination
8167 SV "dsv". The source SV may be destroyed if it is mortal, so
8168 don't use this function if the source SV needs to be reused.
8169 Does not handle 'set' magic on destination SV. Calls 'get'
8170 magic on source SV. Loosely speaking, it performs a copy-by-
8171 value, obliterating any previous content of the destination.
8172
8173 You probably want to use one of the assortment of wrappers,
8174 such as "SvSetSV", "SvSetSV_nosteal", "SvSetMagicSV" and
8175 "SvSetMagicSV_nosteal".
8176
8177 void sv_setsv(SV *dstr, SV *sstr)
8178
8179 sv_setsv_flags
8180 Copies the contents of the source SV "ssv" into the destination
8181 SV "dsv". The source SV may be destroyed if it is mortal, so
8182 don't use this function if the source SV needs to be reused.
8183 Does not handle 'set' magic. Loosely speaking, it performs a
8184 copy-by-value, obliterating any previous content of the
8185 destination. If the "flags" parameter has the "SV_GMAGIC" bit
8186 set, will "mg_get" on "ssv" if appropriate, else not. If the
8187 "flags" parameter has the "SV_NOSTEAL" bit set then the buffers
8188 of temps will not be stolen. "sv_setsv" and "sv_setsv_nomg"
8189 are implemented in terms of this function.
8190
8191 You probably want to use one of the assortment of wrappers,
8192 such as "SvSetSV", "SvSetSV_nosteal", "SvSetMagicSV" and
8193 "SvSetMagicSV_nosteal".
8194
8195 This is the primary function for copying scalars, and most
8196 other copy-ish functions and macros use this underneath.
8197
8198 void sv_setsv_flags(SV *dstr, SV *sstr,
8199 const I32 flags)
8200
8201 sv_setsv_mg
8202 Like "sv_setsv", but also handles 'set' magic.
8203
8204 void sv_setsv_mg(SV *const dstr, SV *const sstr)
8205
8206 sv_setuv
8207 Copies an unsigned integer into the given SV, upgrading first
8208 if necessary. Does not handle 'set' magic. See also
8209 "sv_setuv_mg".
8210
8211 void sv_setuv(SV *const sv, const UV num)
8212
8213 sv_setuv_mg
8214 Like "sv_setuv", but also handles 'set' magic.
8215
8216 void sv_setuv_mg(SV *const sv, const UV u)
8217
8218 sv_set_undef
8219 Equivalent to "sv_setsv(sv, &PL_sv_undef)", but more efficient.
8220 Doesn't handle set magic.
8221
8222 The perl equivalent is "$sv = undef;". Note that it doesn't
8223 free any string buffer, unlike "undef $sv".
8224
8225 Introduced in perl 5.25.12.
8226
8227 void sv_set_undef(SV *sv)
8228
8229 sv_tainted
8230 Test an SV for taintedness. Use "SvTAINTED" instead.
8231
8232 bool sv_tainted(SV *const sv)
8233
8234 sv_true Returns true if the SV has a true value by Perl's rules. Use
8235 the "SvTRUE" macro instead, which may call "sv_true()" or may
8236 instead use an in-line version.
8237
8238 I32 sv_true(SV *const sv)
8239
8240 sv_unmagic
8241 Removes all magic of type "type" from an SV.
8242
8243 int sv_unmagic(SV *const sv, const int type)
8244
8245 sv_unmagicext
8246 Removes all magic of type "type" with the specified "vtbl" from
8247 an SV.
8248
8249 int sv_unmagicext(SV *const sv, const int type,
8250 MGVTBL *vtbl)
8251
8252 sv_unref_flags
8253 Unsets the RV status of the SV, and decrements the reference
8254 count of whatever was being referenced by the RV. This can
8255 almost be thought of as a reversal of "newSVrv". The "cflags"
8256 argument can contain "SV_IMMEDIATE_UNREF" to force the
8257 reference count to be decremented (otherwise the decrementing
8258 is conditional on the reference count being different from one
8259 or the reference being a readonly SV). See "SvROK_off".
8260
8261 void sv_unref_flags(SV *const ref, const U32 flags)
8262
8263 sv_untaint
8264 Untaint an SV. Use "SvTAINTED_off" instead.
8265
8266 void sv_untaint(SV *const sv)
8267
8268 sv_upgrade
8269 Upgrade an SV to a more complex form. Generally adds a new
8270 body type to the SV, then copies across as much information as
8271 possible from the old body. It croaks if the SV is already in
8272 a more complex form than requested. You generally want to use
8273 the "SvUPGRADE" macro wrapper, which checks the type before
8274 calling "sv_upgrade", and hence does not croak. See also
8275 "svtype".
8276
8277 void sv_upgrade(SV *const sv, svtype new_type)
8278
8279 sv_usepvn_flags
8280 Tells an SV to use "ptr" to find its string value. Normally
8281 the string is stored inside the SV, but sv_usepvn allows the SV
8282 to use an outside string. "ptr" should point to memory that
8283 was allocated by "Newx". It must be the start of a "Newx"-ed
8284 block of memory, and not a pointer to the middle of it (beware
8285 of "OOK" and copy-on-write), and not be from a non-"Newx"
8286 memory allocator like "malloc". The string length, "len", must
8287 be supplied. By default this function will "Renew" (i.e.
8288 realloc, move) the memory pointed to by "ptr", so that pointer
8289 should not be freed or used by the programmer after giving it
8290 to "sv_usepvn", and neither should any pointers from "behind"
8291 that pointer (e.g. ptr + 1) be used.
8292
8293 If "flags & SV_SMAGIC" is true, will call "SvSETMAGIC". If
8294 "flags & SV_HAS_TRAILING_NUL" is true, then "ptr[len]" must be
8295 "NUL", and the realloc will be skipped (i.e. the buffer is
8296 actually at least 1 byte longer than "len", and already meets
8297 the requirements for storing in "SvPVX").
8298
8299 void sv_usepvn_flags(SV *const sv, char* ptr,
8300 const STRLEN len,
8301 const U32 flags)
8302
8303 sv_utf8_decode
8304 NOTE: this function is experimental and may change or be
8305 removed without notice.
8306
8307 If the PV of the SV is an octet sequence in Perl's extended
8308 UTF-8 and contains a multiple-byte character, the "SvUTF8" flag
8309 is turned on so that it looks like a character. If the PV
8310 contains only single-byte characters, the "SvUTF8" flag stays
8311 off. Scans PV for validity and returns FALSE if the PV is
8312 invalid UTF-8.
8313
8314 bool sv_utf8_decode(SV *const sv)
8315
8316 sv_utf8_downgrade
8317 NOTE: this function is experimental and may change or be
8318 removed without notice.
8319
8320 Attempts to convert the PV of an SV from characters to bytes.
8321 If the PV contains a character that cannot fit in a byte, this
8322 conversion will fail; in this case, either returns false or, if
8323 "fail_ok" is not true, croaks.
8324
8325 This is not a general purpose Unicode to byte encoding
8326 interface: use the "Encode" extension for that.
8327
8328 bool sv_utf8_downgrade(SV *const sv,
8329 const bool fail_ok)
8330
8331 sv_utf8_encode
8332 Converts the PV of an SV to UTF-8, but then turns the "SvUTF8"
8333 flag off so that it looks like octets again.
8334
8335 void sv_utf8_encode(SV *const sv)
8336
8337 sv_utf8_upgrade
8338 Converts the PV of an SV to its UTF-8-encoded form. Forces the
8339 SV to string form if it is not already. Will "mg_get" on "sv"
8340 if appropriate. Always sets the "SvUTF8" flag to avoid future
8341 validity checks even if the whole string is the same in UTF-8
8342 as not. Returns the number of bytes in the converted string
8343
8344 This is not a general purpose byte encoding to Unicode
8345 interface: use the Encode extension for that.
8346
8347 STRLEN sv_utf8_upgrade(SV *sv)
8348
8349 sv_utf8_upgrade_flags
8350 Converts the PV of an SV to its UTF-8-encoded form. Forces the
8351 SV to string form if it is not already. Always sets the SvUTF8
8352 flag to avoid future validity checks even if all the bytes are
8353 invariant in UTF-8. If "flags" has "SV_GMAGIC" bit set, will
8354 "mg_get" on "sv" if appropriate, else not.
8355
8356 The "SV_FORCE_UTF8_UPGRADE" flag is now ignored.
8357
8358 Returns the number of bytes in the converted string.
8359
8360 This is not a general purpose byte encoding to Unicode
8361 interface: use the Encode extension for that.
8362
8363 STRLEN sv_utf8_upgrade_flags(SV *const sv,
8364 const I32 flags)
8365
8366 sv_utf8_upgrade_flags_grow
8367 Like "sv_utf8_upgrade_flags", but has an additional parameter
8368 "extra", which is the number of unused bytes the string of "sv"
8369 is guaranteed to have free after it upon return. This allows
8370 the caller to reserve extra space that it intends to fill, to
8371 avoid extra grows.
8372
8373 "sv_utf8_upgrade", "sv_utf8_upgrade_nomg", and
8374 "sv_utf8_upgrade_flags" are implemented in terms of this
8375 function.
8376
8377 Returns the number of bytes in the converted string (not
8378 including the spares).
8379
8380 STRLEN sv_utf8_upgrade_flags_grow(SV *const sv,
8381 const I32 flags,
8382 STRLEN extra)
8383
8384 sv_utf8_upgrade_nomg
8385 Like "sv_utf8_upgrade", but doesn't do magic on "sv".
8386
8387 STRLEN sv_utf8_upgrade_nomg(SV *sv)
8388
8389 sv_vcatpvf
8390 Processes its arguments like "sv_vcatpvfn" called with a non-
8391 null C-style variable argument list, and appends the formatted
8392 output to an SV. Does not handle 'set' magic. See
8393 "sv_vcatpvf_mg".
8394
8395 Usually used via its frontend "sv_catpvf".
8396
8397 void sv_vcatpvf(SV *const sv, const char *const pat,
8398 va_list *const args)
8399
8400 sv_vcatpvfn
8401 void sv_vcatpvfn(SV *const sv, const char *const pat,
8402 const STRLEN patlen,
8403 va_list *const args,
8404 SV **const svargs,
8405 const Size_t sv_count,
8406 bool *const maybe_tainted)
8407
8408 sv_vcatpvfn_flags
8409 Processes its arguments like "vsprintf" and appends the
8410 formatted output to an SV. Uses an array of SVs if the C-style
8411 variable argument list is missing ("NULL"). Argument reordering
8412 (using format specifiers like "%2$d" or "%*2$d") is supported
8413 only when using an array of SVs; using a C-style "va_list"
8414 argument list with a format string that uses argument
8415 reordering will yield an exception.
8416
8417 When running with taint checks enabled, indicates via
8418 "maybe_tainted" if results are untrustworthy (often due to the
8419 use of locales).
8420
8421 If called as "sv_vcatpvfn" or flags has the "SV_GMAGIC" bit
8422 set, calls get magic.
8423
8424 It assumes that pat has the same utf8-ness as sv. It's the
8425 caller's responsibility to ensure that this is so.
8426
8427 Usually used via one of its frontends "sv_vcatpvf" and
8428 "sv_vcatpvf_mg".
8429
8430 void sv_vcatpvfn_flags(SV *const sv,
8431 const char *const pat,
8432 const STRLEN patlen,
8433 va_list *const args,
8434 SV **const svargs,
8435 const Size_t sv_count,
8436 bool *const maybe_tainted,
8437 const U32 flags)
8438
8439 sv_vcatpvf_mg
8440 Like "sv_vcatpvf", but also handles 'set' magic.
8441
8442 Usually used via its frontend "sv_catpvf_mg".
8443
8444 void sv_vcatpvf_mg(SV *const sv,
8445 const char *const pat,
8446 va_list *const args)
8447
8448 sv_vsetpvf
8449 Works like "sv_vcatpvf" but copies the text into the SV instead
8450 of appending it. Does not handle 'set' magic. See
8451 "sv_vsetpvf_mg".
8452
8453 Usually used via its frontend "sv_setpvf".
8454
8455 void sv_vsetpvf(SV *const sv, const char *const pat,
8456 va_list *const args)
8457
8458 sv_vsetpvfn
8459 Works like "sv_vcatpvfn" but copies the text into the SV
8460 instead of appending it.
8461
8462 Usually used via one of its frontends "sv_vsetpvf" and
8463 "sv_vsetpvf_mg".
8464
8465 void sv_vsetpvfn(SV *const sv, const char *const pat,
8466 const STRLEN patlen,
8467 va_list *const args,
8468 SV **const svargs,
8469 const Size_t sv_count,
8470 bool *const maybe_tainted)
8471
8472 sv_vsetpvf_mg
8473 Like "sv_vsetpvf", but also handles 'set' magic.
8474
8475 Usually used via its frontend "sv_setpvf_mg".
8476
8477 void sv_vsetpvf_mg(SV *const sv,
8478 const char *const pat,
8479 va_list *const args)
8480
8482 SVt_INVLIST
8483 Type flag for scalars. See "svtype".
8484
8485 SVt_IV Type flag for scalars. See "svtype".
8486
8487 SVt_NULL
8488 Type flag for scalars. See "svtype".
8489
8490 SVt_NV Type flag for scalars. See "svtype".
8491
8492 SVt_PV Type flag for scalars. See "svtype".
8493
8494 SVt_PVAV
8495 Type flag for arrays. See "svtype".
8496
8497 SVt_PVCV
8498 Type flag for subroutines. See "svtype".
8499
8500 SVt_PVFM
8501 Type flag for formats. See "svtype".
8502
8503 SVt_PVGV
8504 Type flag for typeglobs. See "svtype".
8505
8506 SVt_PVHV
8507 Type flag for hashes. See "svtype".
8508
8509 SVt_PVIO
8510 Type flag for I/O objects. See "svtype".
8511
8512 SVt_PVIV
8513 Type flag for scalars. See "svtype".
8514
8515 SVt_PVLV
8516 Type flag for scalars. See "svtype".
8517
8518 SVt_PVMG
8519 Type flag for scalars. See "svtype".
8520
8521 SVt_PVNV
8522 Type flag for scalars. See "svtype".
8523
8524 SVt_REGEXP
8525 Type flag for regular expressions. See "svtype".
8526
8527 svtype An enum of flags for Perl types. These are found in the file
8528 sv.h in the "svtype" enum. Test these flags with the "SvTYPE"
8529 macro.
8530
8531 The types are:
8532
8533 SVt_NULL
8534 SVt_IV
8535 SVt_NV
8536 SVt_RV
8537 SVt_PV
8538 SVt_PVIV
8539 SVt_PVNV
8540 SVt_PVMG
8541 SVt_INVLIST
8542 SVt_REGEXP
8543 SVt_PVGV
8544 SVt_PVLV
8545 SVt_PVAV
8546 SVt_PVHV
8547 SVt_PVCV
8548 SVt_PVFM
8549 SVt_PVIO
8550
8551 These are most easily explained from the bottom up.
8552
8553 "SVt_PVIO" is for I/O objects, "SVt_PVFM" for formats,
8554 "SVt_PVCV" for subroutines, "SVt_PVHV" for hashes and
8555 "SVt_PVAV" for arrays.
8556
8557 All the others are scalar types, that is, things that can be
8558 bound to a "$" variable. For these, the internal types are
8559 mostly orthogonal to types in the Perl language.
8560
8561 Hence, checking "SvTYPE(sv) < SVt_PVAV" is the best way to see
8562 whether something is a scalar.
8563
8564 "SVt_PVGV" represents a typeglob. If "!SvFAKE(sv)", then it is
8565 a real, incoercible typeglob. If "SvFAKE(sv)", then it is a
8566 scalar to which a typeglob has been assigned. Assigning to it
8567 again will stop it from being a typeglob. "SVt_PVLV"
8568 represents a scalar that delegates to another scalar behind the
8569 scenes. It is used, e.g., for the return value of "substr" and
8570 for tied hash and array elements. It can hold any scalar
8571 value, including a typeglob. "SVt_REGEXP" is for regular
8572 expressions. "SVt_INVLIST" is for Perl core internal use only.
8573
8574 "SVt_PVMG" represents a "normal" scalar (not a typeglob,
8575 regular expression, or delegate). Since most scalars do not
8576 need all the internal fields of a PVMG, we save memory by
8577 allocating smaller structs when possible. All the other types
8578 are just simpler forms of "SVt_PVMG", with fewer internal
8579 fields. "SVt_NULL" can only hold undef. "SVt_IV" can hold
8580 undef, an integer, or a reference. ("SVt_RV" is an alias for
8581 "SVt_IV", which exists for backward compatibility.) "SVt_NV"
8582 can hold any of those or a double. "SVt_PV" can only hold
8583 "undef" or a string. "SVt_PVIV" is a superset of "SVt_PV" and
8584 "SVt_IV". "SVt_PVNV" is similar. "SVt_PVMG" can hold anything
8585 "SVt_PVNV" can hold, but it can, but does not have to, be
8586 blessed or magical.
8587
8589 boolSV Returns a true SV if "b" is a true value, or a false SV if "b"
8590 is 0.
8591
8592 See also "PL_sv_yes" and "PL_sv_no".
8593
8594 SV * boolSV(bool b)
8595
8596 croak_xs_usage
8597 A specialised variant of "croak()" for emitting the usage
8598 message for xsubs
8599
8600 croak_xs_usage(cv, "eee_yow");
8601
8602 works out the package name and subroutine name from "cv", and
8603 then calls "croak()". Hence if "cv" is &ouch::awk, it would
8604 call "croak" as:
8605
8606 Perl_croak(aTHX_ "Usage: %" SVf "::%" SVf "(%s)", "ouch" "awk",
8607 "eee_yow");
8608
8609 void croak_xs_usage(const CV *const cv,
8610 const char *const params)
8611
8612 get_sv Returns the SV of the specified Perl scalar. "flags" are
8613 passed to "gv_fetchpv". If "GV_ADD" is set and the Perl
8614 variable does not exist then it will be created. If "flags" is
8615 zero and the variable does not exist then NULL is returned.
8616
8617 NOTE: the perl_ form of this function is deprecated.
8618
8619 SV* get_sv(const char *name, I32 flags)
8620
8621 newRV_inc
8622 Creates an RV wrapper for an SV. The reference count for the
8623 original SV is incremented.
8624
8625 SV* newRV_inc(SV* sv)
8626
8627 newSVpadname
8628 NOTE: this function is experimental and may change or be
8629 removed without notice.
8630
8631 Creates a new SV containing the pad name.
8632
8633 SV* newSVpadname(PADNAME *pn)
8634
8635 newSVpvn_utf8
8636 Creates a new SV and copies a string (which may contain "NUL"
8637 ("\0") characters) into it. If "utf8" is true, calls
8638 "SvUTF8_on" on the new SV. Implemented as a wrapper around
8639 "newSVpvn_flags".
8640
8641 SV* newSVpvn_utf8(const char* s, STRLEN len,
8642 U32 utf8)
8643
8644 sv_catpvn_nomg
8645 Like "sv_catpvn" but doesn't process magic.
8646
8647 void sv_catpvn_nomg(SV* sv, const char* ptr,
8648 STRLEN len)
8649
8650 sv_catpv_nomg
8651 Like "sv_catpv" but doesn't process magic.
8652
8653 void sv_catpv_nomg(SV* sv, const char* ptr)
8654
8655 sv_catsv_nomg
8656 Like "sv_catsv" but doesn't process magic.
8657
8658 void sv_catsv_nomg(SV* dsv, SV* ssv)
8659
8660 SvCUR Returns the length of the string which is in the SV. See
8661 "SvLEN".
8662
8663 STRLEN SvCUR(SV* sv)
8664
8665 SvCUR_set
8666 Set the current length of the string which is in the SV. See
8667 "SvCUR" and "SvIV_set">.
8668
8669 void SvCUR_set(SV* sv, STRLEN len)
8670
8671 sv_derived_from
8672 Exactly like "sv_derived_from_pv", but doesn't take a "flags"
8673 parameter.
8674
8675 bool sv_derived_from(SV* sv, const char *const name)
8676
8677 sv_derived_from_pv
8678 Exactly like "sv_derived_from_pvn", but takes a nul-terminated
8679 string instead of a string/length pair.
8680
8681 bool sv_derived_from_pv(SV* sv,
8682 const char *const name,
8683 U32 flags)
8684
8685 sv_derived_from_pvn
8686 Returns a boolean indicating whether the SV is derived from the
8687 specified class at the C level. To check derivation at the
8688 Perl level, call "isa()" as a normal Perl method.
8689
8690 Currently, the only significant value for "flags" is SVf_UTF8.
8691
8692 bool sv_derived_from_pvn(SV* sv,
8693 const char *const name,
8694 const STRLEN len, U32 flags)
8695
8696 sv_derived_from_sv
8697 Exactly like "sv_derived_from_pvn", but takes the name string
8698 in the form of an SV instead of a string/length pair.
8699
8700 bool sv_derived_from_sv(SV* sv, SV *namesv,
8701 U32 flags)
8702
8703 sv_does Like "sv_does_pv", but doesn't take a "flags" parameter.
8704
8705 bool sv_does(SV* sv, const char *const name)
8706
8707 sv_does_pv
8708 Like "sv_does_sv", but takes a nul-terminated string instead of
8709 an SV.
8710
8711 bool sv_does_pv(SV* sv, const char *const name,
8712 U32 flags)
8713
8714 sv_does_pvn
8715 Like "sv_does_sv", but takes a string/length pair instead of an
8716 SV.
8717
8718 bool sv_does_pvn(SV* sv, const char *const name,
8719 const STRLEN len, U32 flags)
8720
8721 sv_does_sv
8722 Returns a boolean indicating whether the SV performs a
8723 specific, named role. The SV can be a Perl object or the name
8724 of a Perl class.
8725
8726 bool sv_does_sv(SV* sv, SV* namesv, U32 flags)
8727
8728 SvEND Returns a pointer to the spot just after the last character in
8729 the string which is in the SV, where there is usually a
8730 trailing "NUL" character (even though Perl scalars do not
8731 strictly require it). See "SvCUR". Access the character as
8732 "*(SvEND(sv))".
8733
8734 Warning: If "SvCUR" is equal to "SvLEN", then "SvEND" points to
8735 unallocated memory.
8736
8737 char* SvEND(SV* sv)
8738
8739 SvGAMAGIC
8740 Returns true if the SV has get magic or overloading. If either
8741 is true then the scalar is active data, and has the potential
8742 to return a new value every time it is accessed. Hence you
8743 must be careful to only read it once per user logical operation
8744 and work with that returned value. If neither is true then the
8745 scalar's value cannot change unless written to.
8746
8747 U32 SvGAMAGIC(SV* sv)
8748
8749 SvGROW Expands the character buffer in the SV so that it has room for
8750 the indicated number of bytes (remember to reserve space for an
8751 extra trailing "NUL" character). Calls "sv_grow" to perform
8752 the expansion if necessary. Returns a pointer to the character
8753 buffer. SV must be of type >= "SVt_PV". One alternative is to
8754 call "sv_grow" if you are not sure of the type of SV.
8755
8756 You might mistakenly think that "len" is the number of bytes to
8757 add to the existing size, but instead it is the total size "sv"
8758 should be.
8759
8760 char * SvGROW(SV* sv, STRLEN len)
8761
8762 SvIOK Returns a U32 value indicating whether the SV contains an
8763 integer.
8764
8765 U32 SvIOK(SV* sv)
8766
8767 SvIOK_notUV
8768 Returns a boolean indicating whether the SV contains a signed
8769 integer.
8770
8771 bool SvIOK_notUV(SV* sv)
8772
8773 SvIOK_off
8774 Unsets the IV status of an SV.
8775
8776 void SvIOK_off(SV* sv)
8777
8778 SvIOK_on
8779 Tells an SV that it is an integer.
8780
8781 void SvIOK_on(SV* sv)
8782
8783 SvIOK_only
8784 Tells an SV that it is an integer and disables all other "OK"
8785 bits.
8786
8787 void SvIOK_only(SV* sv)
8788
8789 SvIOK_only_UV
8790 Tells an SV that it is an unsigned integer and disables all
8791 other "OK" bits.
8792
8793 void SvIOK_only_UV(SV* sv)
8794
8795 SvIOKp Returns a U32 value indicating whether the SV contains an
8796 integer. Checks the private setting. Use "SvIOK" instead.
8797
8798 U32 SvIOKp(SV* sv)
8799
8800 SvIOK_UV
8801 Returns a boolean indicating whether the SV contains an integer
8802 that must be interpreted as unsigned. A non-negative integer
8803 whose value is within the range of both an IV and a UV may be
8804 be flagged as either "SvUOK" or "SVIOK".
8805
8806 bool SvIOK_UV(SV* sv)
8807
8808 SvIsCOW Returns a U32 value indicating whether the SV is Copy-On-Write
8809 (either shared hash key scalars, or full Copy On Write scalars
8810 if 5.9.0 is configured for COW).
8811
8812 U32 SvIsCOW(SV* sv)
8813
8814 SvIsCOW_shared_hash
8815 Returns a boolean indicating whether the SV is Copy-On-Write
8816 shared hash key scalar.
8817
8818 bool SvIsCOW_shared_hash(SV* sv)
8819
8820 SvIV Coerces the given SV to IV and returns it. The returned value
8821 in many circumstances will get stored in "sv"'s IV slot, but
8822 not in all cases. (Use "sv_setiv" to make sure it does).
8823
8824 See "SvIVx" for a version which guarantees to evaluate "sv"
8825 only once.
8826
8827 IV SvIV(SV* sv)
8828
8829 SvIV_nomg
8830 Like "SvIV" but doesn't process magic.
8831
8832 IV SvIV_nomg(SV* sv)
8833
8834 SvIV_set
8835 Set the value of the IV pointer in sv to val. It is possible
8836 to perform the same function of this macro with an lvalue
8837 assignment to "SvIVX". With future Perls, however, it will be
8838 more efficient to use "SvIV_set" instead of the lvalue
8839 assignment to "SvIVX".
8840
8841 void SvIV_set(SV* sv, IV val)
8842
8843 SvIVX Returns the raw value in the SV's IV slot, without checks or
8844 conversions. Only use when you are sure "SvIOK" is true. See
8845 also "SvIV".
8846
8847 IV SvIVX(SV* sv)
8848
8849 SvIVx Coerces the given SV to IV and returns it. The returned value
8850 in many circumstances will get stored in "sv"'s IV slot, but
8851 not in all cases. (Use "sv_setiv" to make sure it does).
8852
8853 This form guarantees to evaluate "sv" only once. Only use this
8854 if "sv" is an expression with side effects, otherwise use the
8855 more efficient "SvIV".
8856
8857 IV SvIVx(SV* sv)
8858
8859 SvLEN Returns the size of the string buffer in the SV, not including
8860 any part attributable to "SvOOK". See "SvCUR".
8861
8862 STRLEN SvLEN(SV* sv)
8863
8864 SvLEN_set
8865 Set the size of the string buffer for the SV. See "SvLEN".
8866
8867 void SvLEN_set(SV* sv, STRLEN len)
8868
8869 SvMAGIC_set
8870 Set the value of the MAGIC pointer in "sv" to val. See
8871 "SvIV_set".
8872
8873 void SvMAGIC_set(SV* sv, MAGIC* val)
8874
8875 SvNIOK Returns a U32 value indicating whether the SV contains a
8876 number, integer or double.
8877
8878 U32 SvNIOK(SV* sv)
8879
8880 SvNIOK_off
8881 Unsets the NV/IV status of an SV.
8882
8883 void SvNIOK_off(SV* sv)
8884
8885 SvNIOKp Returns a U32 value indicating whether the SV contains a
8886 number, integer or double. Checks the private setting. Use
8887 "SvNIOK" instead.
8888
8889 U32 SvNIOKp(SV* sv)
8890
8891 SvNOK Returns a U32 value indicating whether the SV contains a
8892 double.
8893
8894 U32 SvNOK(SV* sv)
8895
8896 SvNOK_off
8897 Unsets the NV status of an SV.
8898
8899 void SvNOK_off(SV* sv)
8900
8901 SvNOK_on
8902 Tells an SV that it is a double.
8903
8904 void SvNOK_on(SV* sv)
8905
8906 SvNOK_only
8907 Tells an SV that it is a double and disables all other OK bits.
8908
8909 void SvNOK_only(SV* sv)
8910
8911 SvNOKp Returns a U32 value indicating whether the SV contains a
8912 double. Checks the private setting. Use "SvNOK" instead.
8913
8914 U32 SvNOKp(SV* sv)
8915
8916 SvNV Coerces the given SV to NV and returns it. The returned value
8917 in many circumstances will get stored in "sv"'s NV slot, but
8918 not in all cases. (Use "sv_setnv" to make sure it does).
8919
8920 See "SvNVx" for a version which guarantees to evaluate "sv"
8921 only once.
8922
8923 NV SvNV(SV* sv)
8924
8925 SvNV_nomg
8926 Like "SvNV" but doesn't process magic.
8927
8928 NV SvNV_nomg(SV* sv)
8929
8930 SvNV_set
8931 Set the value of the NV pointer in "sv" to val. See
8932 "SvIV_set".
8933
8934 void SvNV_set(SV* sv, NV val)
8935
8936 SvNVX Returns the raw value in the SV's NV slot, without checks or
8937 conversions. Only use when you are sure "SvNOK" is true. See
8938 also "SvNV".
8939
8940 NV SvNVX(SV* sv)
8941
8942 SvNVx Coerces the given SV to NV and returns it. The returned value
8943 in many circumstances will get stored in "sv"'s NV slot, but
8944 not in all cases. (Use "sv_setnv" to make sure it does).
8945
8946 This form guarantees to evaluate "sv" only once. Only use this
8947 if "sv" is an expression with side effects, otherwise use the
8948 more efficient "SvNV".
8949
8950 NV SvNVx(SV* sv)
8951
8952 SvOK Returns a U32 value indicating whether the value is defined.
8953 This is only meaningful for scalars.
8954
8955 U32 SvOK(SV* sv)
8956
8957 SvOOK Returns a U32 indicating whether the pointer to the string
8958 buffer is offset. This hack is used internally to speed up
8959 removal of characters from the beginning of a "SvPV". When
8960 "SvOOK" is true, then the start of the allocated string buffer
8961 is actually "SvOOK_offset()" bytes before "SvPVX". This offset
8962 used to be stored in "SvIVX", but is now stored within the
8963 spare part of the buffer.
8964
8965 U32 SvOOK(SV* sv)
8966
8967 SvOOK_offset
8968 Reads into "len" the offset from "SvPVX" back to the true start
8969 of the allocated buffer, which will be non-zero if "sv_chop"
8970 has been used to efficiently remove characters from start of
8971 the buffer. Implemented as a macro, which takes the address of
8972 "len", which must be of type "STRLEN". Evaluates "sv" more
8973 than once. Sets "len" to 0 if "SvOOK(sv)" is false.
8974
8975 void SvOOK_offset(SV*sv, STRLEN len)
8976
8977 SvPOK Returns a U32 value indicating whether the SV contains a
8978 character string.
8979
8980 U32 SvPOK(SV* sv)
8981
8982 SvPOK_off
8983 Unsets the PV status of an SV.
8984
8985 void SvPOK_off(SV* sv)
8986
8987 SvPOK_on
8988 Tells an SV that it is a string.
8989
8990 void SvPOK_on(SV* sv)
8991
8992 SvPOK_only
8993 Tells an SV that it is a string and disables all other "OK"
8994 bits. Will also turn off the UTF-8 status.
8995
8996 void SvPOK_only(SV* sv)
8997
8998 SvPOK_only_UTF8
8999 Tells an SV that it is a string and disables all other "OK"
9000 bits, and leaves the UTF-8 status as it was.
9001
9002 void SvPOK_only_UTF8(SV* sv)
9003
9004 SvPOKp Returns a U32 value indicating whether the SV contains a
9005 character string. Checks the private setting. Use "SvPOK"
9006 instead.
9007
9008 U32 SvPOKp(SV* sv)
9009
9010 SvPV Returns a pointer to the string in the SV, or a stringified
9011 form of the SV if the SV does not contain a string. The SV may
9012 cache the stringified version becoming "SvPOK". Handles 'get'
9013 magic. The "len" variable will be set to the length of the
9014 string (this is a macro, so don't use &len). See also "SvPVx"
9015 for a version which guarantees to evaluate "sv" only once.
9016
9017 Note that there is no guarantee that the return value of
9018 "SvPV()" is equal to "SvPVX(sv)", or that "SvPVX(sv)" contains
9019 valid data, or that successive calls to "SvPV(sv)" will return
9020 the same pointer value each time. This is due to the way that
9021 things like overloading and Copy-On-Write are handled. In
9022 these cases, the return value may point to a temporary buffer
9023 or similar. If you absolutely need the "SvPVX" field to be
9024 valid (for example, if you intend to write to it), then see
9025 "SvPV_force".
9026
9027 char* SvPV(SV* sv, STRLEN len)
9028
9029 SvPVbyte
9030 Like "SvPV", but converts "sv" to byte representation first if
9031 necessary.
9032
9033 char* SvPVbyte(SV* sv, STRLEN len)
9034
9035 SvPVbyte_force
9036 Like "SvPV_force", but converts "sv" to byte representation
9037 first if necessary.
9038
9039 char* SvPVbyte_force(SV* sv, STRLEN len)
9040
9041 SvPVbyte_nolen
9042 Like "SvPV_nolen", but converts "sv" to byte representation
9043 first if necessary.
9044
9045 char* SvPVbyte_nolen(SV* sv)
9046
9047 SvPVbytex
9048 Like "SvPV", but converts "sv" to byte representation first if
9049 necessary. Guarantees to evaluate "sv" only once; use the more
9050 efficient "SvPVbyte" otherwise.
9051
9052 char* SvPVbytex(SV* sv, STRLEN len)
9053
9054 SvPVbytex_force
9055 Like "SvPV_force", but converts "sv" to byte representation
9056 first if necessary. Guarantees to evaluate "sv" only once; use
9057 the more efficient "SvPVbyte_force" otherwise.
9058
9059 char* SvPVbytex_force(SV* sv, STRLEN len)
9060
9061 SvPVCLEAR
9062 Ensures that sv is a SVt_PV and that its SvCUR is 0, and that
9063 it is properly null terminated. Equivalent to sv_setpvs(""),
9064 but more efficient.
9065
9066 char * SvPVCLEAR(SV* sv)
9067
9068 SvPV_force
9069 Like "SvPV" but will force the SV into containing a string
9070 ("SvPOK"), and only a string ("SvPOK_only"), by hook or by
9071 crook. You need force if you are going to update the "SvPVX"
9072 directly. Processes get magic.
9073
9074 Note that coercing an arbitrary scalar into a plain PV will
9075 potentially strip useful data from it. For example if the SV
9076 was "SvROK", then the referent will have its reference count
9077 decremented, and the SV itself may be converted to an "SvPOK"
9078 scalar with a string buffer containing a value such as
9079 "ARRAY(0x1234)".
9080
9081 char* SvPV_force(SV* sv, STRLEN len)
9082
9083 SvPV_force_nomg
9084 Like "SvPV_force", but doesn't process get magic.
9085
9086 char* SvPV_force_nomg(SV* sv, STRLEN len)
9087
9088 SvPV_nolen
9089 Like "SvPV" but doesn't set a length variable.
9090
9091 char* SvPV_nolen(SV* sv)
9092
9093 SvPV_nomg
9094 Like "SvPV" but doesn't process magic.
9095
9096 char* SvPV_nomg(SV* sv, STRLEN len)
9097
9098 SvPV_nomg_nolen
9099 Like "SvPV_nolen" but doesn't process magic.
9100
9101 char* SvPV_nomg_nolen(SV* sv)
9102
9103 SvPV_set
9104 This is probably not what you want to use, you probably wanted
9105 "sv_usepvn_flags" or "sv_setpvn" or "sv_setpvs".
9106
9107 Set the value of the PV pointer in "sv" to the Perl allocated
9108 "NUL"-terminated string "val". See also "SvIV_set".
9109
9110 Remember to free the previous PV buffer. There are many things
9111 to check. Beware that the existing pointer may be involved in
9112 copy-on-write or other mischief, so do "SvOOK_off(sv)" and use
9113 "sv_force_normal" or "SvPV_force" (or check the "SvIsCOW" flag)
9114 first to make sure this modification is safe. Then finally, if
9115 it is not a COW, call "SvPV_free" to free the previous PV
9116 buffer.
9117
9118 void SvPV_set(SV* sv, char* val)
9119
9120 SvPVutf8
9121 Like "SvPV", but converts "sv" to UTF-8 first if necessary.
9122
9123 char* SvPVutf8(SV* sv, STRLEN len)
9124
9125 SvPVutf8x
9126 Like "SvPV", but converts "sv" to UTF-8 first if necessary.
9127 Guarantees to evaluate "sv" only once; use the more efficient
9128 "SvPVutf8" otherwise.
9129
9130 char* SvPVutf8x(SV* sv, STRLEN len)
9131
9132 SvPVutf8x_force
9133 Like "SvPV_force", but converts "sv" to UTF-8 first if
9134 necessary. Guarantees to evaluate "sv" only once; use the more
9135 efficient "SvPVutf8_force" otherwise.
9136
9137 char* SvPVutf8x_force(SV* sv, STRLEN len)
9138
9139 SvPVutf8_force
9140 Like "SvPV_force", but converts "sv" to UTF-8 first if
9141 necessary.
9142
9143 char* SvPVutf8_force(SV* sv, STRLEN len)
9144
9145 SvPVutf8_nolen
9146 Like "SvPV_nolen", but converts "sv" to UTF-8 first if
9147 necessary.
9148
9149 char* SvPVutf8_nolen(SV* sv)
9150
9151 SvPVX Returns a pointer to the physical string in the SV. The SV
9152 must contain a string. Prior to 5.9.3 it is not safe to
9153 execute this macro unless the SV's type >= "SVt_PV".
9154
9155 This is also used to store the name of an autoloaded subroutine
9156 in an XS AUTOLOAD routine. See "Autoloading with XSUBs" in
9157 perlguts.
9158
9159 char* SvPVX(SV* sv)
9160
9161 SvPVx A version of "SvPV" which guarantees to evaluate "sv" only
9162 once. Only use this if "sv" is an expression with side
9163 effects, otherwise use the more efficient "SvPV".
9164
9165 char* SvPVx(SV* sv, STRLEN len)
9166
9167 SvREADONLY
9168 Returns true if the argument is readonly, otherwise returns
9169 false. Exposed to to perl code via Internals::SvREADONLY().
9170
9171 U32 SvREADONLY(SV* sv)
9172
9173 SvREADONLY_off
9174 Mark an object as not-readonly. Exactly what this mean depends
9175 on the object type. Exposed to perl code via
9176 Internals::SvREADONLY().
9177
9178 U32 SvREADONLY_off(SV* sv)
9179
9180 SvREADONLY_on
9181 Mark an object as readonly. Exactly what this means depends on
9182 the object type. Exposed to perl code via
9183 Internals::SvREADONLY().
9184
9185 U32 SvREADONLY_on(SV* sv)
9186
9187 SvREFCNT
9188 Returns the value of the object's reference count. Exposed to
9189 perl code via Internals::SvREFCNT().
9190
9191 U32 SvREFCNT(SV* sv)
9192
9193 SvREFCNT_dec
9194 Decrements the reference count of the given SV. "sv" may be
9195 "NULL".
9196
9197 void SvREFCNT_dec(SV* sv)
9198
9199 SvREFCNT_dec_NN
9200 Same as "SvREFCNT_dec", but can only be used if you know "sv"
9201 is not "NULL". Since we don't have to check the NULLness, it's
9202 faster and smaller.
9203
9204 void SvREFCNT_dec_NN(SV* sv)
9205
9206 SvREFCNT_inc
9207 Increments the reference count of the given SV, returning the
9208 SV.
9209
9210 All of the following "SvREFCNT_inc"* macros are optimized
9211 versions of "SvREFCNT_inc", and can be replaced with
9212 "SvREFCNT_inc".
9213
9214 SV* SvREFCNT_inc(SV* sv)
9215
9216 SvREFCNT_inc_NN
9217 Same as "SvREFCNT_inc", but can only be used if you know "sv"
9218 is not "NULL". Since we don't have to check the NULLness, it's
9219 faster and smaller.
9220
9221 SV* SvREFCNT_inc_NN(SV* sv)
9222
9223 SvREFCNT_inc_simple
9224 Same as "SvREFCNT_inc", but can only be used with expressions
9225 without side effects. Since we don't have to store a temporary
9226 value, it's faster.
9227
9228 SV* SvREFCNT_inc_simple(SV* sv)
9229
9230 SvREFCNT_inc_simple_NN
9231 Same as "SvREFCNT_inc_simple", but can only be used if you know
9232 "sv" is not "NULL". Since we don't have to check the NULLness,
9233 it's faster and smaller.
9234
9235 SV* SvREFCNT_inc_simple_NN(SV* sv)
9236
9237 SvREFCNT_inc_simple_void
9238 Same as "SvREFCNT_inc_simple", but can only be used if you
9239 don't need the return value. The macro doesn't need to return
9240 a meaningful value.
9241
9242 void SvREFCNT_inc_simple_void(SV* sv)
9243
9244 SvREFCNT_inc_simple_void_NN
9245 Same as "SvREFCNT_inc", but can only be used if you don't need
9246 the return value, and you know that "sv" is not "NULL". The
9247 macro doesn't need to return a meaningful value, or check for
9248 NULLness, so it's smaller and faster.
9249
9250 void SvREFCNT_inc_simple_void_NN(SV* sv)
9251
9252 SvREFCNT_inc_void
9253 Same as "SvREFCNT_inc", but can only be used if you don't need
9254 the return value. The macro doesn't need to return a
9255 meaningful value.
9256
9257 void SvREFCNT_inc_void(SV* sv)
9258
9259 SvREFCNT_inc_void_NN
9260 Same as "SvREFCNT_inc", but can only be used if you don't need
9261 the return value, and you know that "sv" is not "NULL". The
9262 macro doesn't need to return a meaningful value, or check for
9263 NULLness, so it's smaller and faster.
9264
9265 void SvREFCNT_inc_void_NN(SV* sv)
9266
9267 sv_report_used
9268 Dump the contents of all SVs not yet freed (debugging aid).
9269
9270 void sv_report_used()
9271
9272 SvROK Tests if the SV is an RV.
9273
9274 U32 SvROK(SV* sv)
9275
9276 SvROK_off
9277 Unsets the RV status of an SV.
9278
9279 void SvROK_off(SV* sv)
9280
9281 SvROK_on
9282 Tells an SV that it is an RV.
9283
9284 void SvROK_on(SV* sv)
9285
9286 SvRV Dereferences an RV to return the SV.
9287
9288 SV* SvRV(SV* sv)
9289
9290 SvRV_set
9291 Set the value of the RV pointer in "sv" to val. See
9292 "SvIV_set".
9293
9294 void SvRV_set(SV* sv, SV* val)
9295
9296 sv_setsv_nomg
9297 Like "sv_setsv" but doesn't process magic.
9298
9299 void sv_setsv_nomg(SV* dsv, SV* ssv)
9300
9301 SvSTASH Returns the stash of the SV.
9302
9303 HV* SvSTASH(SV* sv)
9304
9305 SvSTASH_set
9306 Set the value of the STASH pointer in "sv" to val. See
9307 "SvIV_set".
9308
9309 void SvSTASH_set(SV* sv, HV* val)
9310
9311 SvTAINT Taints an SV if tainting is enabled, and if some input to the
9312 current expression is tainted--usually a variable, but possibly
9313 also implicit inputs such as locale settings. "SvTAINT"
9314 propagates that taintedness to the outputs of an expression in
9315 a pessimistic fashion; i.e., without paying attention to
9316 precisely which outputs are influenced by which inputs.
9317
9318 void SvTAINT(SV* sv)
9319
9320 SvTAINTED
9321 Checks to see if an SV is tainted. Returns TRUE if it is,
9322 FALSE if not.
9323
9324 bool SvTAINTED(SV* sv)
9325
9326 SvTAINTED_off
9327 Untaints an SV. Be very careful with this routine, as it
9328 short-circuits some of Perl's fundamental security features.
9329 XS module authors should not use this function unless they
9330 fully understand all the implications of unconditionally
9331 untainting the value. Untainting should be done in the
9332 standard perl fashion, via a carefully crafted regexp, rather
9333 than directly untainting variables.
9334
9335 void SvTAINTED_off(SV* sv)
9336
9337 SvTAINTED_on
9338 Marks an SV as tainted if tainting is enabled.
9339
9340 void SvTAINTED_on(SV* sv)
9341
9342 SvTRUE Returns a boolean indicating whether Perl would evaluate the SV
9343 as true or false. See "SvOK" for a defined/undefined test.
9344 Handles 'get' magic unless the scalar is already "SvPOK",
9345 "SvIOK" or "SvNOK" (the public, not the private flags).
9346
9347 bool SvTRUE(SV* sv)
9348
9349 SvTRUE_nomg
9350 Returns a boolean indicating whether Perl would evaluate the SV
9351 as true or false. See "SvOK" for a defined/undefined test.
9352 Does not handle 'get' magic.
9353
9354 bool SvTRUE_nomg(SV* sv)
9355
9356 SvTYPE Returns the type of the SV. See "svtype".
9357
9358 svtype SvTYPE(SV* sv)
9359
9360 SvUOK Returns a boolean indicating whether the SV contains an integer
9361 that must be interpreted as unsigned. A non-negative integer
9362 whose value is within the range of both an IV and a UV may be
9363 be flagged as either "SvUOK" or "SVIOK".
9364
9365 bool SvUOK(SV* sv)
9366
9367 SvUPGRADE
9368 Used to upgrade an SV to a more complex form. Uses
9369 "sv_upgrade" to perform the upgrade if necessary. See
9370 "svtype".
9371
9372 void SvUPGRADE(SV* sv, svtype type)
9373
9374 SvUTF8 Returns a U32 value indicating the UTF-8 status of an SV. If
9375 things are set-up properly, this indicates whether or not the
9376 SV contains UTF-8 encoded data. You should use this after a
9377 call to "SvPV()" or one of its variants, in case any call to
9378 string overloading updates the internal flag.
9379
9380 If you want to take into account the bytes pragma, use
9381 "DO_UTF8" instead.
9382
9383 U32 SvUTF8(SV* sv)
9384
9385 sv_utf8_upgrade_nomg
9386 Like "sv_utf8_upgrade", but doesn't do magic on "sv".
9387
9388 STRLEN sv_utf8_upgrade_nomg(SV *sv)
9389
9390 SvUTF8_off
9391 Unsets the UTF-8 status of an SV (the data is not changed, just
9392 the flag). Do not use frivolously.
9393
9394 void SvUTF8_off(SV *sv)
9395
9396 SvUTF8_on
9397 Turn on the UTF-8 status of an SV (the data is not changed,
9398 just the flag). Do not use frivolously.
9399
9400 void SvUTF8_on(SV *sv)
9401
9402 SvUV Coerces the given SV to UV and returns it. The returned value
9403 in many circumstances will get stored in "sv"'s UV slot, but
9404 not in all cases. (Use "sv_setuv" to make sure it does).
9405
9406 See "SvUVx" for a version which guarantees to evaluate "sv"
9407 only once.
9408
9409 UV SvUV(SV* sv)
9410
9411 SvUV_nomg
9412 Like "SvUV" but doesn't process magic.
9413
9414 UV SvUV_nomg(SV* sv)
9415
9416 SvUV_set
9417 Set the value of the UV pointer in "sv" to val. See
9418 "SvIV_set".
9419
9420 void SvUV_set(SV* sv, UV val)
9421
9422 SvUVX Returns the raw value in the SV's UV slot, without checks or
9423 conversions. Only use when you are sure "SvIOK" is true. See
9424 also "SvUV".
9425
9426 UV SvUVX(SV* sv)
9427
9428 SvUVx Coerces the given SV to UV and returns it. The returned value
9429 in many circumstances will get stored in "sv"'s UV slot, but
9430 not in all cases. (Use "sv_setuv" to make sure it does).
9431
9432 This form guarantees to evaluate "sv" only once. Only use this
9433 if "sv" is an expression with side effects, otherwise use the
9434 more efficient "SvUV".
9435
9436 UV SvUVx(SV* sv)
9437
9438 SvVOK Returns a boolean indicating whether the SV contains a
9439 v-string.
9440
9441 bool SvVOK(SV* sv)
9442
9444 "Unicode Support" in perlguts has an introduction to this API.
9445
9446 See also "Character classification", and "Character case changing".
9447 Various functions outside this section also work specially with
9448 Unicode. Search for the string "utf8" in this document.
9449
9450 BOM_UTF8
9451 This is a macro that evaluates to a string constant of the
9452 UTF-8 bytes that define the Unicode BYTE ORDER MARK (U+FEFF)
9453 for the platform that perl is compiled on. This allows code to
9454 use a mnemonic for this character that works on both ASCII and
9455 EBCDIC platforms. "sizeof(BOM_UTF8) - 1" can be used to get
9456 its length in bytes.
9457
9458 bytes_cmp_utf8
9459 Compares the sequence of characters (stored as octets) in "b",
9460 "blen" with the sequence of characters (stored as UTF-8) in
9461 "u", "ulen". Returns 0 if they are equal, -1 or -2 if the
9462 first string is less than the second string, +1 or +2 if the
9463 first string is greater than the second string.
9464
9465 -1 or +1 is returned if the shorter string was identical to the
9466 start of the longer string. -2 or +2 is returned if there was
9467 a difference between characters within the strings.
9468
9469 int bytes_cmp_utf8(const U8 *b, STRLEN blen,
9470 const U8 *u, STRLEN ulen)
9471
9472 bytes_from_utf8
9473 NOTE: this function is experimental and may change or be
9474 removed without notice.
9475
9476 Converts a potentially UTF-8 encoded string "s" of length *lenp
9477 into native byte encoding. On input, the boolean *is_utf8p
9478 gives whether or not "s" is actually encoded in UTF-8.
9479
9480 Unlike "utf8_to_bytes" but like "bytes_to_utf8", this is non-
9481 destructive of the input string.
9482
9483 Do nothing if *is_utf8p is 0, or if there are code points in
9484 the string not expressible in native byte encoding. In these
9485 cases, *is_utf8p and *lenp are unchanged, and the return value
9486 is the original "s".
9487
9488 Otherwise, *is_utf8p is set to 0, and the return value is a
9489 pointer to a newly created string containing a downgraded copy
9490 of "s", and whose length is returned in *lenp, updated. The
9491 new string is "NUL"-terminated. The caller is responsible for
9492 arranging for the memory used by this string to get freed.
9493
9494 Upon successful return, the number of variants in the string
9495 can be computed by having saved the value of *lenp before the
9496 call, and subtracting the after-call value of *lenp from it.
9497
9498 U8* bytes_from_utf8(const U8 *s, STRLEN *lenp,
9499 bool *is_utf8p)
9500
9501 bytes_to_utf8
9502 NOTE: this function is experimental and may change or be
9503 removed without notice.
9504
9505 Converts a string "s" of length *lenp bytes from the native
9506 encoding into UTF-8. Returns a pointer to the newly-created
9507 string, and sets *lenp to reflect the new length in bytes. The
9508 caller is responsible for arranging for the memory used by this
9509 string to get freed.
9510
9511 Upon successful return, the number of variants in the string
9512 can be computed by having saved the value of *lenp before the
9513 call, and subtracting it from the after-call value of *lenp.
9514
9515 A "NUL" character will be written after the end of the string.
9516
9517 If you want to convert to UTF-8 from encodings other than the
9518 native (Latin1 or EBCDIC), see "sv_recode_to_utf8"().
9519
9520 U8* bytes_to_utf8(const U8 *s, STRLEN *lenp)
9521
9522 DO_UTF8 Returns a bool giving whether or not the PV in "sv" is to be
9523 treated as being encoded in UTF-8.
9524
9525 You should use this after a call to "SvPV()" or one of its
9526 variants, in case any call to string overloading updates the
9527 internal UTF-8 encoding flag.
9528
9529 bool DO_UTF8(SV* sv)
9530
9531 foldEQ_utf8
9532 Returns true if the leading portions of the strings "s1" and
9533 "s2" (either or both of which may be in UTF-8) are the same
9534 case-insensitively; false otherwise. How far into the strings
9535 to compare is determined by other input parameters.
9536
9537 If "u1" is true, the string "s1" is assumed to be in
9538 UTF-8-encoded Unicode; otherwise it is assumed to be in native
9539 8-bit encoding. Correspondingly for "u2" with respect to "s2".
9540
9541 If the byte length "l1" is non-zero, it says how far into "s1"
9542 to check for fold equality. In other words, "s1"+"l1" will be
9543 used as a goal to reach. The scan will not be considered to be
9544 a match unless the goal is reached, and scanning won't continue
9545 past that goal. Correspondingly for "l2" with respect to "s2".
9546
9547 If "pe1" is non-"NULL" and the pointer it points to is not
9548 "NULL", that pointer is considered an end pointer to the
9549 position 1 byte past the maximum point in "s1" beyond which
9550 scanning will not continue under any circumstances. (This
9551 routine assumes that UTF-8 encoded input strings are not
9552 malformed; malformed input can cause it to read past "pe1").
9553 This means that if both "l1" and "pe1" are specified, and "pe1"
9554 is less than "s1"+"l1", the match will never be successful
9555 because it can never get as far as its goal (and in fact is
9556 asserted against). Correspondingly for "pe2" with respect to
9557 "s2".
9558
9559 At least one of "s1" and "s2" must have a goal (at least one of
9560 "l1" and "l2" must be non-zero), and if both do, both have to
9561 be reached for a successful match. Also, if the fold of a
9562 character is multiple characters, all of them must be matched
9563 (see tr21 reference below for 'folding').
9564
9565 Upon a successful match, if "pe1" is non-"NULL", it will be set
9566 to point to the beginning of the next character of "s1" beyond
9567 what was matched. Correspondingly for "pe2" and "s2".
9568
9569 For case-insensitiveness, the "casefolding" of Unicode is used
9570 instead of upper/lowercasing both the characters, see
9571 <http://www.unicode.org/unicode/reports/tr21/> (Case Mappings).
9572
9573 I32 foldEQ_utf8(const char *s1, char **pe1, UV l1,
9574 bool u1, const char *s2, char **pe2,
9575 UV l2, bool u2)
9576
9577 is_ascii_string
9578 This is a misleadingly-named synonym for
9579 "is_utf8_invariant_string". On ASCII-ish platforms, the name
9580 isn't misleading: the ASCII-range characters are exactly the
9581 UTF-8 invariants. But EBCDIC machines have more invariants
9582 than just the ASCII characters, so "is_utf8_invariant_string"
9583 is preferred.
9584
9585 bool is_ascii_string(const U8* const s, STRLEN len)
9586
9587 is_c9strict_utf8_string
9588 Returns TRUE if the first "len" bytes of string "s" form a
9589 valid UTF-8-encoded string that conforms to Unicode Corrigendum
9590 #9 <http://www.unicode.org/versions/corrigendum9.html>;
9591 otherwise it returns FALSE. If "len" is 0, it will be
9592 calculated using strlen(s) (which means if you use this option,
9593 that "s" can't have embedded "NUL" characters and has to have a
9594 terminating "NUL" byte). Note that all characters being ASCII
9595 constitute 'a valid UTF-8 string'.
9596
9597 This function returns FALSE for strings containing any code
9598 points above the Unicode max of 0x10FFFF or surrogate code
9599 points, but accepts non-character code points per Corrigendum
9600 #9 <http://www.unicode.org/versions/corrigendum9.html>.
9601
9602 See also "is_utf8_invariant_string",
9603 "is_utf8_invariant_string_loc", "is_utf8_string",
9604 "is_utf8_string_flags", "is_utf8_string_loc",
9605 "is_utf8_string_loc_flags", "is_utf8_string_loclen",
9606 "is_utf8_string_loclen_flags", "is_utf8_fixed_width_buf_flags",
9607 "is_utf8_fixed_width_buf_loc_flags",
9608 "is_utf8_fixed_width_buf_loclen_flags",
9609 "is_strict_utf8_string", "is_strict_utf8_string_loc",
9610 "is_strict_utf8_string_loclen", "is_c9strict_utf8_string_loc",
9611 and "is_c9strict_utf8_string_loclen".
9612
9613 bool is_c9strict_utf8_string(const U8 *s, STRLEN len)
9614
9615 is_c9strict_utf8_string_loc
9616 Like "is_c9strict_utf8_string" but stores the location of the
9617 failure (in the case of "utf8ness failure") or the location
9618 "s"+"len" (in the case of "utf8ness success") in the "ep"
9619 pointer.
9620
9621 See also "is_c9strict_utf8_string_loclen".
9622
9623 bool is_c9strict_utf8_string_loc(const U8 *s,
9624 STRLEN len,
9625 const U8 **ep)
9626
9627 is_c9strict_utf8_string_loclen
9628 Like "is_c9strict_utf8_string" but stores the location of the
9629 failure (in the case of "utf8ness failure") or the location
9630 "s"+"len" (in the case of "utf8ness success") in the "ep"
9631 pointer, and the number of UTF-8 encoded characters in the "el"
9632 pointer.
9633
9634 See also "is_c9strict_utf8_string_loc".
9635
9636 bool is_c9strict_utf8_string_loclen(const U8 *s,
9637 STRLEN len,
9638 const U8 **ep,
9639 STRLEN *el)
9640
9641 isC9_STRICT_UTF8_CHAR
9642 Evaluates to non-zero if the first few bytes of the string
9643 starting at "s" and looking no further than "e - 1" are well-
9644 formed UTF-8 that represents some Unicode non-surrogate code
9645 point; otherwise it evaluates to 0. If non-zero, the value
9646 gives how many bytes starting at "s" comprise the code point's
9647 representation. Any bytes remaining before "e", but beyond the
9648 ones needed to form the first code point in "s", are not
9649 examined.
9650
9651 The largest acceptable code point is the Unicode maximum
9652 0x10FFFF. This differs from "isSTRICT_UTF8_CHAR" only in that
9653 it accepts non-character code points. This corresponds to
9654 Unicode Corrigendum #9
9655 <http://www.unicode.org/versions/corrigendum9.html>. which
9656 said that non-character code points are merely discouraged
9657 rather than completely forbidden in open interchange. See
9658 "Noncharacter code points" in perlunicode.
9659
9660 Use "isUTF8_CHAR" to check for Perl's extended UTF-8; and
9661 "isUTF8_CHAR_flags" for a more customized definition.
9662
9663 Use "is_c9strict_utf8_string", "is_c9strict_utf8_string_loc",
9664 and "is_c9strict_utf8_string_loclen" to check entire strings.
9665
9666 STRLEN isC9_STRICT_UTF8_CHAR(const U8 *s, const U8 *e)
9667
9668 is_invariant_string
9669 This is a somewhat misleadingly-named synonym for
9670 "is_utf8_invariant_string". "is_utf8_invariant_string" is
9671 preferred, as it indicates under what conditions the string is
9672 invariant.
9673
9674 bool is_invariant_string(const U8* const s,
9675 STRLEN len)
9676
9677 isSTRICT_UTF8_CHAR
9678 Evaluates to non-zero if the first few bytes of the string
9679 starting at "s" and looking no further than "e - 1" are well-
9680 formed UTF-8 that represents some Unicode code point completely
9681 acceptable for open interchange between all applications;
9682 otherwise it evaluates to 0. If non-zero, the value gives how
9683 many bytes starting at "s" comprise the code point's
9684 representation. Any bytes remaining before "e", but beyond the
9685 ones needed to form the first code point in "s", are not
9686 examined.
9687
9688 The largest acceptable code point is the Unicode maximum
9689 0x10FFFF, and must not be a surrogate nor a non-character code
9690 point. Thus this excludes any code point from Perl's extended
9691 UTF-8.
9692
9693 This is used to efficiently decide if the next few bytes in "s"
9694 is legal Unicode-acceptable UTF-8 for a single character.
9695
9696 Use "isC9_STRICT_UTF8_CHAR" to use the Unicode Corrigendum #9
9697 <http://www.unicode.org/versions/corrigendum9.html> definition
9698 of allowable code points; "isUTF8_CHAR" to check for Perl's
9699 extended UTF-8; and "isUTF8_CHAR_flags" for a more customized
9700 definition.
9701
9702 Use "is_strict_utf8_string", "is_strict_utf8_string_loc", and
9703 "is_strict_utf8_string_loclen" to check entire strings.
9704
9705 STRLEN isSTRICT_UTF8_CHAR(const U8 *s, const U8 *e)
9706
9707 is_strict_utf8_string
9708 Returns TRUE if the first "len" bytes of string "s" form a
9709 valid UTF-8-encoded string that is fully interchangeable by any
9710 application using Unicode rules; otherwise it returns FALSE.
9711 If "len" is 0, it will be calculated using strlen(s) (which
9712 means if you use this option, that "s" can't have embedded
9713 "NUL" characters and has to have a terminating "NUL" byte).
9714 Note that all characters being ASCII constitute 'a valid UTF-8
9715 string'.
9716
9717 This function returns FALSE for strings containing any code
9718 points above the Unicode max of 0x10FFFF, surrogate code
9719 points, or non-character code points.
9720
9721 See also "is_utf8_invariant_string",
9722 "is_utf8_invariant_string_loc", "is_utf8_string",
9723 "is_utf8_string_flags", "is_utf8_string_loc",
9724 "is_utf8_string_loc_flags", "is_utf8_string_loclen",
9725 "is_utf8_string_loclen_flags", "is_utf8_fixed_width_buf_flags",
9726 "is_utf8_fixed_width_buf_loc_flags",
9727 "is_utf8_fixed_width_buf_loclen_flags",
9728 "is_strict_utf8_string_loc", "is_strict_utf8_string_loclen",
9729 "is_c9strict_utf8_string", "is_c9strict_utf8_string_loc", and
9730 "is_c9strict_utf8_string_loclen".
9731
9732 bool is_strict_utf8_string(const U8 *s, STRLEN len)
9733
9734 is_strict_utf8_string_loc
9735 Like "is_strict_utf8_string" but stores the location of the
9736 failure (in the case of "utf8ness failure") or the location
9737 "s"+"len" (in the case of "utf8ness success") in the "ep"
9738 pointer.
9739
9740 See also "is_strict_utf8_string_loclen".
9741
9742 bool is_strict_utf8_string_loc(const U8 *s,
9743 STRLEN len,
9744 const U8 **ep)
9745
9746 is_strict_utf8_string_loclen
9747 Like "is_strict_utf8_string" but stores the location of the
9748 failure (in the case of "utf8ness failure") or the location
9749 "s"+"len" (in the case of "utf8ness success") in the "ep"
9750 pointer, and the number of UTF-8 encoded characters in the "el"
9751 pointer.
9752
9753 See also "is_strict_utf8_string_loc".
9754
9755 bool is_strict_utf8_string_loclen(const U8 *s,
9756 STRLEN len,
9757 const U8 **ep,
9758 STRLEN *el)
9759
9760 is_utf8_fixed_width_buf_flags
9761 Returns TRUE if the fixed-width buffer starting at "s" with
9762 length "len" is entirely valid UTF-8, subject to the
9763 restrictions given by "flags"; otherwise it returns FALSE.
9764
9765 If "flags" is 0, any well-formed UTF-8, as extended by Perl, is
9766 accepted without restriction. If the final few bytes of the
9767 buffer do not form a complete code point, this will return TRUE
9768 anyway, provided that "is_utf8_valid_partial_char_flags"
9769 returns TRUE for them.
9770
9771 If "flags" in non-zero, it can be any combination of the
9772 "UTF8_DISALLOW_foo" flags accepted by "utf8n_to_uvchr", and
9773 with the same meanings.
9774
9775 This function differs from "is_utf8_string_flags" only in that
9776 the latter returns FALSE if the final few bytes of the string
9777 don't form a complete code point.
9778
9779 bool is_utf8_fixed_width_buf_flags(
9780 const U8 * const s, STRLEN len,
9781 const U32 flags
9782 )
9783
9784 is_utf8_fixed_width_buf_loclen_flags
9785 Like "is_utf8_fixed_width_buf_loc_flags" but stores the number
9786 of complete, valid characters found in the "el" pointer.
9787
9788 bool is_utf8_fixed_width_buf_loclen_flags(
9789 const U8 * const s, STRLEN len,
9790 const U8 **ep, STRLEN *el, const U32 flags
9791 )
9792
9793 is_utf8_fixed_width_buf_loc_flags
9794 Like "is_utf8_fixed_width_buf_flags" but stores the location of
9795 the failure in the "ep" pointer. If the function returns TRUE,
9796 *ep will point to the beginning of any partial character at the
9797 end of the buffer; if there is no partial character *ep will
9798 contain "s"+"len".
9799
9800 See also "is_utf8_fixed_width_buf_loclen_flags".
9801
9802 bool is_utf8_fixed_width_buf_loc_flags(
9803 const U8 * const s, STRLEN len,
9804 const U8 **ep, const U32 flags
9805 )
9806
9807 is_utf8_invariant_string
9808 Returns TRUE if the first "len" bytes of the string "s" are the
9809 same regardless of the UTF-8 encoding of the string (or UTF-
9810 EBCDIC encoding on EBCDIC machines); otherwise it returns
9811 FALSE. That is, it returns TRUE if they are UTF-8 invariant.
9812 On ASCII-ish machines, all the ASCII characters and only the
9813 ASCII characters fit this definition. On EBCDIC machines, the
9814 ASCII-range characters are invariant, but so also are the C1
9815 controls.
9816
9817 If "len" is 0, it will be calculated using strlen(s), (which
9818 means if you use this option, that "s" can't have embedded
9819 "NUL" characters and has to have a terminating "NUL" byte).
9820
9821 See also "is_utf8_string", "is_utf8_string_flags",
9822 "is_utf8_string_loc", "is_utf8_string_loc_flags",
9823 "is_utf8_string_loclen", "is_utf8_string_loclen_flags",
9824 "is_utf8_fixed_width_buf_flags",
9825 "is_utf8_fixed_width_buf_loc_flags",
9826 "is_utf8_fixed_width_buf_loclen_flags",
9827 "is_strict_utf8_string", "is_strict_utf8_string_loc",
9828 "is_strict_utf8_string_loclen", "is_c9strict_utf8_string",
9829 "is_c9strict_utf8_string_loc", and
9830 "is_c9strict_utf8_string_loclen".
9831
9832 bool is_utf8_invariant_string(const U8* const s,
9833 STRLEN len)
9834
9835 is_utf8_invariant_string_loc
9836 Like "is_utf8_invariant_string" but upon failure, stores the
9837 location of the first UTF-8 variant character in the "ep"
9838 pointer; if all characters are UTF-8 invariant, this function
9839 does not change the contents of *ep.
9840
9841 bool is_utf8_invariant_string_loc(const U8* const s,
9842 STRLEN len,
9843 const U8 ** ep)
9844
9845 is_utf8_string
9846 Returns TRUE if the first "len" bytes of string "s" form a
9847 valid Perl-extended-UTF-8 string; returns FALSE otherwise. If
9848 "len" is 0, it will be calculated using strlen(s) (which means
9849 if you use this option, that "s" can't have embedded "NUL"
9850 characters and has to have a terminating "NUL" byte). Note
9851 that all characters being ASCII constitute 'a valid UTF-8
9852 string'.
9853
9854 This function considers Perl's extended UTF-8 to be valid.
9855 That means that code points above Unicode, surrogates, and non-
9856 character code points are considered valid by this function.
9857 Use "is_strict_utf8_string", "is_c9strict_utf8_string", or
9858 "is_utf8_string_flags" to restrict what code points are
9859 considered valid.
9860
9861 See also "is_utf8_invariant_string",
9862 "is_utf8_invariant_string_loc", "is_utf8_string_loc",
9863 "is_utf8_string_loclen", "is_utf8_fixed_width_buf_flags",
9864 "is_utf8_fixed_width_buf_loc_flags",
9865 "is_utf8_fixed_width_buf_loclen_flags",
9866
9867 bool is_utf8_string(const U8 *s, STRLEN len)
9868
9869 is_utf8_string_flags
9870 Returns TRUE if the first "len" bytes of string "s" form a
9871 valid UTF-8 string, subject to the restrictions imposed by
9872 "flags"; returns FALSE otherwise. If "len" is 0, it will be
9873 calculated using strlen(s) (which means if you use this option,
9874 that "s" can't have embedded "NUL" characters and has to have a
9875 terminating "NUL" byte). Note that all characters being ASCII
9876 constitute 'a valid UTF-8 string'.
9877
9878 If "flags" is 0, this gives the same results as
9879 "is_utf8_string"; if "flags" is
9880 "UTF8_DISALLOW_ILLEGAL_INTERCHANGE", this gives the same
9881 results as "is_strict_utf8_string"; and if "flags" is
9882 "UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE", this gives the same
9883 results as "is_c9strict_utf8_string". Otherwise "flags" may be
9884 any combination of the "UTF8_DISALLOW_foo" flags understood by
9885 "utf8n_to_uvchr", with the same meanings.
9886
9887 See also "is_utf8_invariant_string",
9888 "is_utf8_invariant_string_loc", "is_utf8_string",
9889 "is_utf8_string_loc", "is_utf8_string_loc_flags",
9890 "is_utf8_string_loclen", "is_utf8_string_loclen_flags",
9891 "is_utf8_fixed_width_buf_flags",
9892 "is_utf8_fixed_width_buf_loc_flags",
9893 "is_utf8_fixed_width_buf_loclen_flags",
9894 "is_strict_utf8_string", "is_strict_utf8_string_loc",
9895 "is_strict_utf8_string_loclen", "is_c9strict_utf8_string",
9896 "is_c9strict_utf8_string_loc", and
9897 "is_c9strict_utf8_string_loclen".
9898
9899 bool is_utf8_string_flags(const U8 *s, STRLEN len,
9900 const U32 flags)
9901
9902 is_utf8_string_loc
9903 Like "is_utf8_string" but stores the location of the failure
9904 (in the case of "utf8ness failure") or the location "s"+"len"
9905 (in the case of "utf8ness success") in the "ep" pointer.
9906
9907 See also "is_utf8_string_loclen".
9908
9909 bool is_utf8_string_loc(const U8 *s,
9910 const STRLEN len,
9911 const U8 **ep)
9912
9913 is_utf8_string_loclen
9914 Like "is_utf8_string" but stores the location of the failure
9915 (in the case of "utf8ness failure") or the location "s"+"len"
9916 (in the case of "utf8ness success") in the "ep" pointer, and
9917 the number of UTF-8 encoded characters in the "el" pointer.
9918
9919 See also "is_utf8_string_loc".
9920
9921 bool is_utf8_string_loclen(const U8 *s, STRLEN len,
9922 const U8 **ep, STRLEN *el)
9923
9924 is_utf8_string_loclen_flags
9925 Like "is_utf8_string_flags" but stores the location of the
9926 failure (in the case of "utf8ness failure") or the location
9927 "s"+"len" (in the case of "utf8ness success") in the "ep"
9928 pointer, and the number of UTF-8 encoded characters in the "el"
9929 pointer.
9930
9931 See also "is_utf8_string_loc_flags".
9932
9933 bool is_utf8_string_loclen_flags(const U8 *s,
9934 STRLEN len,
9935 const U8 **ep,
9936 STRLEN *el,
9937 const U32 flags)
9938
9939 is_utf8_string_loc_flags
9940 Like "is_utf8_string_flags" but stores the location of the
9941 failure (in the case of "utf8ness failure") or the location
9942 "s"+"len" (in the case of "utf8ness success") in the "ep"
9943 pointer.
9944
9945 See also "is_utf8_string_loclen_flags".
9946
9947 bool is_utf8_string_loc_flags(const U8 *s,
9948 STRLEN len,
9949 const U8 **ep,
9950 const U32 flags)
9951
9952 is_utf8_valid_partial_char
9953 Returns 0 if the sequence of bytes starting at "s" and looking
9954 no further than "e - 1" is the UTF-8 encoding, as extended by
9955 Perl, for one or more code points. Otherwise, it returns 1 if
9956 there exists at least one non-empty sequence of bytes that when
9957 appended to sequence "s", starting at position "e" causes the
9958 entire sequence to be the well-formed UTF-8 of some code point;
9959 otherwise returns 0.
9960
9961 In other words this returns TRUE if "s" points to a partial
9962 UTF-8-encoded code point.
9963
9964 This is useful when a fixed-length buffer is being tested for
9965 being well-formed UTF-8, but the final few bytes in it don't
9966 comprise a full character; that is, it is split somewhere in
9967 the middle of the final code point's UTF-8 representation.
9968 (Presumably when the buffer is refreshed with the next chunk of
9969 data, the new first bytes will complete the partial code
9970 point.) This function is used to verify that the final bytes
9971 in the current buffer are in fact the legal beginning of some
9972 code point, so that if they aren't, the failure can be
9973 signalled without having to wait for the next read.
9974
9975 bool is_utf8_valid_partial_char(const U8 * const s,
9976 const U8 * const e)
9977
9978 is_utf8_valid_partial_char_flags
9979 Like "is_utf8_valid_partial_char", it returns a boolean giving
9980 whether or not the input is a valid UTF-8 encoded partial
9981 character, but it takes an extra parameter, "flags", which can
9982 further restrict which code points are considered valid.
9983
9984 If "flags" is 0, this behaves identically to
9985 "is_utf8_valid_partial_char". Otherwise "flags" can be any
9986 combination of the "UTF8_DISALLOW_foo" flags accepted by
9987 "utf8n_to_uvchr". If there is any sequence of bytes that can
9988 complete the input partial character in such a way that a non-
9989 prohibited character is formed, the function returns TRUE;
9990 otherwise FALSE. Non character code points cannot be
9991 determined based on partial character input. But many of the
9992 other possible excluded types can be determined from just the
9993 first one or two bytes.
9994
9995 bool is_utf8_valid_partial_char_flags(
9996 const U8 * const s, const U8 * const e,
9997 const U32 flags
9998 )
9999
10000 isUTF8_CHAR
10001 Evaluates to non-zero if the first few bytes of the string
10002 starting at "s" and looking no further than "e - 1" are well-
10003 formed UTF-8, as extended by Perl, that represents some code
10004 point; otherwise it evaluates to 0. If non-zero, the value
10005 gives how many bytes starting at "s" comprise the code point's
10006 representation. Any bytes remaining before "e", but beyond the
10007 ones needed to form the first code point in "s", are not
10008 examined.
10009
10010 The code point can be any that will fit in a UV on this
10011 machine, using Perl's extension to official UTF-8 to represent
10012 those higher than the Unicode maximum of 0x10FFFF. That means
10013 that this macro is used to efficiently decide if the next few
10014 bytes in "s" is legal UTF-8 for a single character.
10015
10016 Use "isSTRICT_UTF8_CHAR" to restrict the acceptable code points
10017 to those defined by Unicode to be fully interchangeable across
10018 applications; "isC9_STRICT_UTF8_CHAR" to use the Unicode
10019 Corrigendum #9
10020 <http://www.unicode.org/versions/corrigendum9.html> definition
10021 of allowable code points; and "isUTF8_CHAR_flags" for a more
10022 customized definition.
10023
10024 Use "is_utf8_string", "is_utf8_string_loc", and
10025 "is_utf8_string_loclen" to check entire strings.
10026
10027 Note that it is deprecated to use code points higher than what
10028 will fit in an IV. This macro does not raise any warnings for
10029 such code points, treating them as valid.
10030
10031 Note also that a UTF-8 INVARIANT character (i.e. ASCII on non-
10032 EBCDIC machines) is a valid UTF-8 character.
10033
10034 STRLEN isUTF8_CHAR(const U8 *s, const U8 *e)
10035
10036 isUTF8_CHAR_flags
10037 Evaluates to non-zero if the first few bytes of the string
10038 starting at "s" and looking no further than "e - 1" are well-
10039 formed UTF-8, as extended by Perl, that represents some code
10040 point, subject to the restrictions given by "flags"; otherwise
10041 it evaluates to 0. If non-zero, the value gives how many bytes
10042 starting at "s" comprise the code point's representation. Any
10043 bytes remaining before "e", but beyond the ones needed to form
10044 the first code point in "s", are not examined.
10045
10046 If "flags" is 0, this gives the same results as "isUTF8_CHAR";
10047 if "flags" is "UTF8_DISALLOW_ILLEGAL_INTERCHANGE", this gives
10048 the same results as "isSTRICT_UTF8_CHAR"; and if "flags" is
10049 "UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE", this gives the same
10050 results as "isC9_STRICT_UTF8_CHAR". Otherwise "flags" may be
10051 any combination of the "UTF8_DISALLOW_foo" flags understood by
10052 "utf8n_to_uvchr", with the same meanings.
10053
10054 The three alternative macros are for the most commonly needed
10055 validations; they are likely to run somewhat faster than this
10056 more general one, as they can be inlined into your code.
10057
10058 Use "is_utf8_string_flags", "is_utf8_string_loc_flags", and
10059 "is_utf8_string_loclen_flags" to check entire strings.
10060
10061 STRLEN isUTF8_CHAR_flags(const U8 *s, const U8 *e,
10062 const U32 flags)
10063
10064 pv_uni_display
10065 Build to the scalar "dsv" a displayable version of the string
10066 "spv", length "len", the displayable version being at most
10067 "pvlim" bytes long (if longer, the rest is truncated and "..."
10068 will be appended).
10069
10070 The "flags" argument can have "UNI_DISPLAY_ISPRINT" set to
10071 display "isPRINT()"able characters as themselves,
10072 "UNI_DISPLAY_BACKSLASH" to display the "\\[nrfta\\]" as the
10073 backslashed versions (like "\n") ("UNI_DISPLAY_BACKSLASH" is
10074 preferred over "UNI_DISPLAY_ISPRINT" for "\\").
10075 "UNI_DISPLAY_QQ" (and its alias "UNI_DISPLAY_REGEX") have both
10076 "UNI_DISPLAY_BACKSLASH" and "UNI_DISPLAY_ISPRINT" turned on.
10077
10078 The pointer to the PV of the "dsv" is returned.
10079
10080 See also "sv_uni_display".
10081
10082 char* pv_uni_display(SV *dsv, const U8 *spv,
10083 STRLEN len, STRLEN pvlim,
10084 UV flags)
10085
10086 REPLACEMENT_CHARACTER_UTF8
10087 This is a macro that evaluates to a string constant of the
10088 UTF-8 bytes that define the Unicode REPLACEMENT CHARACTER
10089 (U+FFFD) for the platform that perl is compiled on. This
10090 allows code to use a mnemonic for this character that works on
10091 both ASCII and EBCDIC platforms.
10092 "sizeof(REPLACEMENT_CHARACTER_UTF8) - 1" can be used to get its
10093 length in bytes.
10094
10095 sv_cat_decode
10096 "encoding" is assumed to be an "Encode" object, the PV of "ssv"
10097 is assumed to be octets in that encoding and decoding the input
10098 starts from the position which "(PV + *offset)" pointed to.
10099 "dsv" will be concatenated with the decoded UTF-8 string from
10100 "ssv". Decoding will terminate when the string "tstr" appears
10101 in decoding output or the input ends on the PV of "ssv". The
10102 value which "offset" points will be modified to the last input
10103 position on "ssv".
10104
10105 Returns TRUE if the terminator was found, else returns FALSE.
10106
10107 bool sv_cat_decode(SV* dsv, SV *encoding, SV *ssv,
10108 int *offset, char* tstr, int tlen)
10109
10110 sv_recode_to_utf8
10111 "encoding" is assumed to be an "Encode" object, on entry the PV
10112 of "sv" is assumed to be octets in that encoding, and "sv" will
10113 be converted into Unicode (and UTF-8).
10114
10115 If "sv" already is UTF-8 (or if it is not "POK"), or if
10116 "encoding" is not a reference, nothing is done to "sv". If
10117 "encoding" is not an "Encode::XS" Encoding object, bad things
10118 will happen. (See cpan/Encode/encoding.pm and Encode.)
10119
10120 The PV of "sv" is returned.
10121
10122 char* sv_recode_to_utf8(SV* sv, SV *encoding)
10123
10124 sv_uni_display
10125 Build to the scalar "dsv" a displayable version of the scalar
10126 "sv", the displayable version being at most "pvlim" bytes long
10127 (if longer, the rest is truncated and "..." will be appended).
10128
10129 The "flags" argument is as in "pv_uni_display"().
10130
10131 The pointer to the PV of the "dsv" is returned.
10132
10133 char* sv_uni_display(SV *dsv, SV *ssv, STRLEN pvlim,
10134 UV flags)
10135
10136 to_utf8_fold
10137 DEPRECATED! It is planned to remove this function from a
10138 future release of Perl. Do not use it for new code; remove it
10139 from existing code.
10140
10141 Instead use "toFOLD_utf8_safe".
10142
10143 UV to_utf8_fold(const U8 *p, U8* ustrp,
10144 STRLEN *lenp)
10145
10146 to_utf8_lower
10147 DEPRECATED! It is planned to remove this function from a
10148 future release of Perl. Do not use it for new code; remove it
10149 from existing code.
10150
10151 Instead use "toLOWER_utf8_safe".
10152
10153 UV to_utf8_lower(const U8 *p, U8* ustrp,
10154 STRLEN *lenp)
10155
10156 to_utf8_title
10157 DEPRECATED! It is planned to remove this function from a
10158 future release of Perl. Do not use it for new code; remove it
10159 from existing code.
10160
10161 Instead use "toTITLE_utf8_safe".
10162
10163 UV to_utf8_title(const U8 *p, U8* ustrp,
10164 STRLEN *lenp)
10165
10166 to_utf8_upper
10167 DEPRECATED! It is planned to remove this function from a
10168 future release of Perl. Do not use it for new code; remove it
10169 from existing code.
10170
10171 Instead use "toUPPER_utf8_safe".
10172
10173 UV to_utf8_upper(const U8 *p, U8* ustrp,
10174 STRLEN *lenp)
10175
10176 utf8n_to_uvchr
10177 THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED
10178 CIRCUMSTANCES. Most code should use "utf8_to_uvchr_buf"()
10179 rather than call this directly.
10180
10181 Bottom level UTF-8 decode routine. Returns the native code
10182 point value of the first character in the string "s", which is
10183 assumed to be in UTF-8 (or UTF-EBCDIC) encoding, and no longer
10184 than "curlen" bytes; *retlen (if "retlen" isn't NULL) will be
10185 set to the length, in bytes, of that character.
10186
10187 The value of "flags" determines the behavior when "s" does not
10188 point to a well-formed UTF-8 character. If "flags" is 0,
10189 encountering a malformation causes zero to be returned and
10190 *retlen is set so that ("s" + *retlen) is the next possible
10191 position in "s" that could begin a non-malformed character.
10192 Also, if UTF-8 warnings haven't been lexically disabled, a
10193 warning is raised. Some UTF-8 input sequences may contain
10194 multiple malformations. This function tries to find every
10195 possible one in each call, so multiple warnings can be raised
10196 for the same sequence.
10197
10198 Various ALLOW flags can be set in "flags" to allow (and not
10199 warn on) individual types of malformations, such as the
10200 sequence being overlong (that is, when there is a shorter
10201 sequence that can express the same code point; overlong
10202 sequences are expressly forbidden in the UTF-8 standard due to
10203 potential security issues). Another malformation example is
10204 the first byte of a character not being a legal first byte.
10205 See utf8.h for the list of such flags. Even if allowed, this
10206 function generally returns the Unicode REPLACEMENT CHARACTER
10207 when it encounters a malformation. There are flags in utf8.h
10208 to override this behavior for the overlong malformations, but
10209 don't do that except for very specialized purposes.
10210
10211 The "UTF8_CHECK_ONLY" flag overrides the behavior when a non-
10212 allowed (by other flags) malformation is found. If this flag
10213 is set, the routine assumes that the caller will raise a
10214 warning, and this function will silently just set "retlen" to
10215 "-1" (cast to "STRLEN") and return zero.
10216
10217 Note that this API requires disambiguation between successful
10218 decoding a "NUL" character, and an error return (unless the
10219 "UTF8_CHECK_ONLY" flag is set), as in both cases, 0 is
10220 returned, and, depending on the malformation, "retlen" may be
10221 set to 1. To disambiguate, upon a zero return, see if the
10222 first byte of "s" is 0 as well. If so, the input was a "NUL";
10223 if not, the input had an error. Or you can use
10224 "utf8n_to_uvchr_error".
10225
10226 Certain code points are considered problematic. These are
10227 Unicode surrogates, Unicode non-characters, and code points
10228 above the Unicode maximum of 0x10FFFF. By default these are
10229 considered regular code points, but certain situations warrant
10230 special handling for them, which can be specified using the
10231 "flags" parameter. If "flags" contains
10232 "UTF8_DISALLOW_ILLEGAL_INTERCHANGE", all three classes are
10233 treated as malformations and handled as such. The flags
10234 "UTF8_DISALLOW_SURROGATE", "UTF8_DISALLOW_NONCHAR", and
10235 "UTF8_DISALLOW_SUPER" (meaning above the legal Unicode maximum)
10236 can be set to disallow these categories individually.
10237 "UTF8_DISALLOW_ILLEGAL_INTERCHANGE" restricts the allowed
10238 inputs to the strict UTF-8 traditionally defined by Unicode.
10239 Use "UTF8_DISALLOW_ILLEGAL_C9_INTERCHANGE" to use the
10240 strictness definition given by Unicode Corrigendum #9
10241 <http://www.unicode.org/versions/corrigendum9.html>. The
10242 difference between traditional strictness and C9 strictness is
10243 that the latter does not forbid non-character code points.
10244 (They are still discouraged, however.) For more discussion see
10245 "Noncharacter code points" in perlunicode.
10246
10247 The flags "UTF8_WARN_ILLEGAL_INTERCHANGE",
10248 "UTF8_WARN_ILLEGAL_C9_INTERCHANGE", "UTF8_WARN_SURROGATE",
10249 "UTF8_WARN_NONCHAR", and "UTF8_WARN_SUPER" will cause warning
10250 messages to be raised for their respective categories, but
10251 otherwise the code points are considered valid (not
10252 malformations). To get a category to both be treated as a
10253 malformation and raise a warning, specify both the WARN and
10254 DISALLOW flags. (But note that warnings are not raised if
10255 lexically disabled nor if "UTF8_CHECK_ONLY" is also specified.)
10256
10257 Extremely high code points were never specified in any
10258 standard, and require an extension to UTF-8 to express, which
10259 Perl does. It is likely that programs written in something
10260 other than Perl would not be able to read files that contain
10261 these; nor would Perl understand files written by something
10262 that uses a different extension. For these reasons, there is a
10263 separate set of flags that can warn and/or disallow these
10264 extremely high code points, even if other above-Unicode ones
10265 are accepted. They are the "UTF8_WARN_PERL_EXTENDED" and
10266 "UTF8_DISALLOW_PERL_EXTENDED" flags. For more information see
10267 ""UTF8_GOT_PERL_EXTENDED"". Of course "UTF8_DISALLOW_SUPER"
10268 will treat all above-Unicode code points, including these, as
10269 malformations. (Note that the Unicode standard considers
10270 anything above 0x10FFFF to be illegal, but there are standards
10271 predating it that allow up to 0x7FFF_FFFF (2**31 -1))
10272
10273 A somewhat misleadingly named synonym for
10274 "UTF8_WARN_PERL_EXTENDED" is retained for backward
10275 compatibility: "UTF8_WARN_ABOVE_31_BIT". Similarly,
10276 "UTF8_DISALLOW_ABOVE_31_BIT" is usable instead of the more
10277 accurately named "UTF8_DISALLOW_PERL_EXTENDED". The names are
10278 misleading because these flags can apply to code points that
10279 actually do fit in 31 bits. This happens on EBCDIC platforms,
10280 and sometimes when the overlong malformation is also present.
10281 The new names accurately describe the situation in all cases.
10282
10283 All other code points corresponding to Unicode characters,
10284 including private use and those yet to be assigned, are never
10285 considered malformed and never warn.
10286
10287 UV utf8n_to_uvchr(const U8 *s, STRLEN curlen,
10288 STRLEN *retlen, const U32 flags)
10289
10290 utf8n_to_uvchr_error
10291 THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED
10292 CIRCUMSTANCES. Most code should use "utf8_to_uvchr_buf"()
10293 rather than call this directly.
10294
10295 This function is for code that needs to know what the precise
10296 malformation(s) are when an error is found. If you also need
10297 to know the generated warning messages, use
10298 "utf8n_to_uvchr_msgs"() instead.
10299
10300 It is like "utf8n_to_uvchr" but it takes an extra parameter
10301 placed after all the others, "errors". If this parameter is 0,
10302 this function behaves identically to "utf8n_to_uvchr".
10303 Otherwise, "errors" should be a pointer to a "U32" variable,
10304 which this function sets to indicate any errors found. Upon
10305 return, if *errors is 0, there were no errors found.
10306 Otherwise, *errors is the bit-wise "OR" of the bits described
10307 in the list below. Some of these bits will be set if a
10308 malformation is found, even if the input "flags" parameter
10309 indicates that the given malformation is allowed; those
10310 exceptions are noted:
10311
10312 "UTF8_GOT_PERL_EXTENDED"
10313 The input sequence is not standard UTF-8, but a Perl
10314 extension. This bit is set only if the input "flags"
10315 parameter contains either the "UTF8_DISALLOW_PERL_EXTENDED"
10316 or the "UTF8_WARN_PERL_EXTENDED" flags.
10317
10318 Code points above 0x7FFF_FFFF (2**31 - 1) were never
10319 specified in any standard, and so some extension must be
10320 used to express them. Perl uses a natural extension to
10321 UTF-8 to represent the ones up to 2**36-1, and invented a
10322 further extension to represent even higher ones, so that
10323 any code point that fits in a 64-bit word can be
10324 represented. Text using these extensions is not likely to
10325 be portable to non-Perl code. We lump both of these
10326 extensions together and refer to them as Perl extended
10327 UTF-8. There exist other extensions that people have
10328 invented, incompatible with Perl's.
10329
10330 On EBCDIC platforms starting in Perl v5.24, the Perl
10331 extension for representing extremely high code points kicks
10332 in at 0x3FFF_FFFF (2**30 -1), which is lower than on ASCII.
10333 Prior to that, code points 2**31 and higher were simply
10334 unrepresentable, and a different, incompatible method was
10335 used to represent code points between 2**30 and 2**31 - 1.
10336
10337 On both platforms, ASCII and EBCDIC,
10338 "UTF8_GOT_PERL_EXTENDED" is set if Perl extended UTF-8 is
10339 used.
10340
10341 In earlier Perls, this bit was named
10342 "UTF8_GOT_ABOVE_31_BIT", which you still may use for
10343 backward compatibility. That name is misleading, as this
10344 flag may be set when the code point actually does fit in 31
10345 bits. This happens on EBCDIC platforms, and sometimes when
10346 the overlong malformation is also present. The new name
10347 accurately describes the situation in all cases.
10348
10349 "UTF8_GOT_CONTINUATION"
10350 The input sequence was malformed in that the first byte was
10351 a a UTF-8 continuation byte.
10352
10353 "UTF8_GOT_EMPTY"
10354 The input "curlen" parameter was 0.
10355
10356 "UTF8_GOT_LONG"
10357 The input sequence was malformed in that there is some
10358 other sequence that evaluates to the same code point, but
10359 that sequence is shorter than this one.
10360
10361 Until Unicode 3.1, it was legal for programs to accept this
10362 malformation, but it was discovered that this created
10363 security issues.
10364
10365 "UTF8_GOT_NONCHAR"
10366 The code point represented by the input UTF-8 sequence is
10367 for a Unicode non-character code point. This bit is set
10368 only if the input "flags" parameter contains either the
10369 "UTF8_DISALLOW_NONCHAR" or the "UTF8_WARN_NONCHAR" flags.
10370
10371 "UTF8_GOT_NON_CONTINUATION"
10372 The input sequence was malformed in that a non-continuation
10373 type byte was found in a position where only a continuation
10374 type one should be.
10375
10376 "UTF8_GOT_OVERFLOW"
10377 The input sequence was malformed in that it is for a code
10378 point that is not representable in the number of bits
10379 available in an IV on the current platform.
10380
10381 "UTF8_GOT_SHORT"
10382 The input sequence was malformed in that "curlen" is
10383 smaller than required for a complete sequence. In other
10384 words, the input is for a partial character sequence.
10385
10386 "UTF8_GOT_SUPER"
10387 The input sequence was malformed in that it is for a non-
10388 Unicode code point; that is, one above the legal Unicode
10389 maximum. This bit is set only if the input "flags"
10390 parameter contains either the "UTF8_DISALLOW_SUPER" or the
10391 "UTF8_WARN_SUPER" flags.
10392
10393 "UTF8_GOT_SURROGATE"
10394 The input sequence was malformed in that it is for a
10395 -Unicode UTF-16 surrogate code point. This bit is set only
10396 if the input "flags" parameter contains either the
10397 "UTF8_DISALLOW_SURROGATE" or the "UTF8_WARN_SURROGATE"
10398 flags.
10399
10400 To do your own error handling, call this function with the
10401 "UTF8_CHECK_ONLY" flag to suppress any warnings, and then
10402 examine the *errors return.
10403
10404 UV utf8n_to_uvchr_error(const U8 *s, STRLEN curlen,
10405 STRLEN *retlen,
10406 const U32 flags,
10407 U32 * errors)
10408
10409 utf8n_to_uvchr_msgs
10410 NOTE: this function is experimental and may change or be
10411 removed without notice.
10412
10413 THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED
10414 CIRCUMSTANCES. Most code should use "utf8_to_uvchr_buf"()
10415 rather than call this directly.
10416
10417 This function is for code that needs to know what the precise
10418 malformation(s) are when an error is found, and wants the
10419 corresponding warning and/or error messages to be returned to
10420 the caller rather than be displayed. All messages that would
10421 have been displayed if all lexcial warnings are enabled will be
10422 returned.
10423
10424 It is just like "utf8n_to_uvchr_error" but it takes an extra
10425 parameter placed after all the others, "msgs". If this
10426 parameter is 0, this function behaves identically to
10427 "utf8n_to_uvchr_error". Otherwise, "msgs" should be a pointer
10428 to an "AV *" variable, in which this function creates a new AV
10429 to contain any appropriate messages. The elements of the array
10430 are ordered so that the first message that would have been
10431 displayed is in the 0th element, and so on. Each element is a
10432 hash with three key-value pairs, as follows:
10433
10434 "text"
10435 The text of the message as a "SVpv".
10436
10437 "warn_categories"
10438 The warning category (or categories) packed into a "SVuv".
10439
10440 "flag"
10441 A single flag bit associated with this message, in a
10442 "SVuv". The bit corresponds to some bit in the *errors
10443 return value, such as "UTF8_GOT_LONG".
10444
10445 It's important to note that specifying this parameter as non-
10446 null will cause any warnings this function would otherwise
10447 generate to be suppressed, and instead be placed in *msgs. The
10448 caller can check the lexical warnings state (or not) when
10449 choosing what to do with the returned messages.
10450
10451 If the flag "UTF8_CHECK_ONLY" is passed, no warnings are
10452 generated, and hence no AV is created.
10453
10454 The caller, of course, is responsible for freeing any returned
10455 AV.
10456
10457 UV utf8n_to_uvchr_msgs(const U8 *s, STRLEN curlen,
10458 STRLEN *retlen,
10459 const U32 flags,
10460 U32 * errors, AV ** msgs)
10461
10462 utf8n_to_uvuni
10463 Instead use "utf8_to_uvchr_buf", or rarely, "utf8n_to_uvchr".
10464
10465 This function was useful for code that wanted to handle both
10466 EBCDIC and ASCII platforms with Unicode properties, but
10467 starting in Perl v5.20, the distinctions between the platforms
10468 have mostly been made invisible to most code, so this function
10469 is quite unlikely to be what you want. If you do need this
10470 precise functionality, use instead
10471 "NATIVE_TO_UNI(utf8_to_uvchr_buf(...))" or
10472 "NATIVE_TO_UNI(utf8n_to_uvchr(...))".
10473
10474 UV utf8n_to_uvuni(const U8 *s, STRLEN curlen,
10475 STRLEN *retlen, U32 flags)
10476
10477 UTF8SKIP
10478 returns the number of bytes in the UTF-8 encoded character
10479 whose first (perhaps only) byte is pointed to by "s".
10480
10481 STRLEN UTF8SKIP(char* s)
10482
10483 utf8_distance
10484 Returns the number of UTF-8 characters between the UTF-8
10485 pointers "a" and "b".
10486
10487 WARNING: use only if you *know* that the pointers point inside
10488 the same UTF-8 buffer.
10489
10490 IV utf8_distance(const U8 *a, const U8 *b)
10491
10492 utf8_hop
10493 Return the UTF-8 pointer "s" displaced by "off" characters,
10494 either forward or backward.
10495
10496 WARNING: do not use the following unless you *know* "off" is
10497 within the UTF-8 data pointed to by "s" *and* that on entry "s"
10498 is aligned on the first byte of character or just after the
10499 last byte of a character.
10500
10501 U8* utf8_hop(const U8 *s, SSize_t off)
10502
10503 utf8_hop_back
10504 Return the UTF-8 pointer "s" displaced by up to "off"
10505 characters, backward.
10506
10507 "off" must be non-positive.
10508
10509 "s" must be after or equal to "start".
10510
10511 When moving backward it will not move before "start".
10512
10513 Will not exceed this limit even if the string is not valid
10514 "UTF-8".
10515
10516 U8* utf8_hop_back(const U8 *s, SSize_t off,
10517 const U8 *start)
10518
10519 utf8_hop_forward
10520 Return the UTF-8 pointer "s" displaced by up to "off"
10521 characters, forward.
10522
10523 "off" must be non-negative.
10524
10525 "s" must be before or equal to "end".
10526
10527 When moving forward it will not move beyond "end".
10528
10529 Will not exceed this limit even if the string is not valid
10530 "UTF-8".
10531
10532 U8* utf8_hop_forward(const U8 *s, SSize_t off,
10533 const U8 *end)
10534
10535 utf8_hop_safe
10536 Return the UTF-8 pointer "s" displaced by up to "off"
10537 characters, either forward or backward.
10538
10539 When moving backward it will not move before "start".
10540
10541 When moving forward it will not move beyond "end".
10542
10543 Will not exceed those limits even if the string is not valid
10544 "UTF-8".
10545
10546 U8* utf8_hop_safe(const U8 *s, SSize_t off,
10547 const U8 *start, const U8 *end)
10548
10549 UTF8_IS_INVARIANT
10550 Evaluates to 1 if the byte "c" represents the same character
10551 when encoded in UTF-8 as when not; otherwise evaluates to 0.
10552 UTF-8 invariant characters can be copied as-is when converting
10553 to/from UTF-8, saving time.
10554
10555 In spite of the name, this macro gives the correct result if
10556 the input string from which "c" comes is not encoded in UTF-8.
10557
10558 See "UVCHR_IS_INVARIANT" for checking if a UV is invariant.
10559
10560 bool UTF8_IS_INVARIANT(char c)
10561
10562 UTF8_IS_NONCHAR
10563 Evaluates to non-zero if the first few bytes of the string
10564 starting at "s" and looking no further than "e - 1" are well-
10565 formed UTF-8 that represents one of the Unicode non-character
10566 code points; otherwise it evaluates to 0. If non-zero, the
10567 value gives how many bytes starting at "s" comprise the code
10568 point's representation.
10569
10570 bool UTF8_IS_NONCHAR(const U8 *s, const U8 *e)
10571
10572 UTF8_IS_SUPER
10573 Recall that Perl recognizes an extension to UTF-8 that can
10574 encode code points larger than the ones defined by Unicode,
10575 which are 0..0x10FFFF.
10576
10577 This macro evaluates to non-zero if the first few bytes of the
10578 string starting at "s" and looking no further than "e - 1" are
10579 from this UTF-8 extension; otherwise it evaluates to 0. If
10580 non-zero, the value gives how many bytes starting at "s"
10581 comprise the code point's representation.
10582
10583 0 is returned if the bytes are not well-formed extended UTF-8,
10584 or if they represent a code point that cannot fit in a UV on
10585 the current platform. Hence this macro can give different
10586 results when run on a 64-bit word machine than on one with a
10587 32-bit word size.
10588
10589 Note that it is deprecated to have code points that are larger
10590 than what can fit in an IV on the current machine.
10591
10592 bool UTF8_IS_SUPER(const U8 *s, const U8 *e)
10593
10594 UTF8_IS_SURROGATE
10595 Evaluates to non-zero if the first few bytes of the string
10596 starting at "s" and looking no further than "e - 1" are well-
10597 formed UTF-8 that represents one of the Unicode surrogate code
10598 points; otherwise it evaluates to 0. If non-zero, the value
10599 gives how many bytes starting at "s" comprise the code point's
10600 representation.
10601
10602 bool UTF8_IS_SURROGATE(const U8 *s, const U8 *e)
10603
10604 utf8_length
10605 Returns the number of characters in the sequence of
10606 UTF-8-encoded bytes starting at "s" and ending at the byte just
10607 before "e". If <s> and <e> point to the same place, it returns
10608 0 with no warning raised.
10609
10610 If "e < s" or if the scan would end up past "e", it raises a
10611 UTF8 warning and returns the number of valid characters.
10612
10613 STRLEN utf8_length(const U8* s, const U8 *e)
10614
10615 utf8_to_bytes
10616 NOTE: this function is experimental and may change or be
10617 removed without notice.
10618
10619 Converts a string "s" of length *lenp from UTF-8 into native
10620 byte encoding. Unlike "bytes_to_utf8", this over-writes the
10621 original string, and updates *lenp to contain the new length.
10622 Returns zero on failure (leaving "s" unchanged) setting *lenp
10623 to -1.
10624
10625 Upon successful return, the number of variants in the string
10626 can be computed by having saved the value of *lenp before the
10627 call, and subtracting the after-call value of *lenp from it.
10628
10629 If you need a copy of the string, see "bytes_from_utf8".
10630
10631 U8* utf8_to_bytes(U8 *s, STRLEN *lenp)
10632
10633 utf8_to_uvchr
10634 DEPRECATED! It is planned to remove this function from a
10635 future release of Perl. Do not use it for new code; remove it
10636 from existing code.
10637
10638 Returns the native code point of the first character in the
10639 string "s" which is assumed to be in UTF-8 encoding; "retlen"
10640 will be set to the length, in bytes, of that character.
10641
10642 Some, but not all, UTF-8 malformations are detected, and in
10643 fact, some malformed input could cause reading beyond the end
10644 of the input buffer, which is why this function is deprecated.
10645 Use "utf8_to_uvchr_buf" instead.
10646
10647 If "s" points to one of the detected malformations, and UTF8
10648 warnings are enabled, zero is returned and *retlen is set (if
10649 "retlen" isn't "NULL") to -1. If those warnings are off, the
10650 computed value if well-defined (or the Unicode REPLACEMENT
10651 CHARACTER, if not) is silently returned, and *retlen is set (if
10652 "retlen" isn't NULL) so that ("s" + *retlen) is the next
10653 possible position in "s" that could begin a non-malformed
10654 character. See "utf8n_to_uvchr" for details on when the
10655 REPLACEMENT CHARACTER is returned.
10656
10657 UV utf8_to_uvchr(const U8 *s, STRLEN *retlen)
10658
10659 utf8_to_uvchr_buf
10660 Returns the native code point of the first character in the
10661 string "s" which is assumed to be in UTF-8 encoding; "send"
10662 points to 1 beyond the end of "s". *retlen will be set to the
10663 length, in bytes, of that character.
10664
10665 If "s" does not point to a well-formed UTF-8 character and UTF8
10666 warnings are enabled, zero is returned and *retlen is set (if
10667 "retlen" isn't "NULL") to -1. If those warnings are off, the
10668 computed value, if well-defined (or the Unicode REPLACEMENT
10669 CHARACTER if not), is silently returned, and *retlen is set (if
10670 "retlen" isn't "NULL") so that ("s" + *retlen) is the next
10671 possible position in "s" that could begin a non-malformed
10672 character. See "utf8n_to_uvchr" for details on when the
10673 REPLACEMENT CHARACTER is returned.
10674
10675 UV utf8_to_uvchr_buf(const U8 *s, const U8 *send,
10676 STRLEN *retlen)
10677
10678 utf8_to_uvuni_buf
10679 DEPRECATED! It is planned to remove this function from a
10680 future release of Perl. Do not use it for new code; remove it
10681 from existing code.
10682
10683 Only in very rare circumstances should code need to be dealing
10684 in Unicode (as opposed to native) code points. In those few
10685 cases, use "NATIVE_TO_UNI(utf8_to_uvchr_buf(...))" instead. If
10686 you are not absolutely sure this is one of those cases, then
10687 assume it isn't and use plain "utf8_to_uvchr_buf" instead.
10688
10689 Returns the Unicode (not-native) code point of the first
10690 character in the string "s" which is assumed to be in UTF-8
10691 encoding; "send" points to 1 beyond the end of "s". "retlen"
10692 will be set to the length, in bytes, of that character.
10693
10694 If "s" does not point to a well-formed UTF-8 character and UTF8
10695 warnings are enabled, zero is returned and *retlen is set (if
10696 "retlen" isn't NULL) to -1. If those warnings are off, the
10697 computed value if well-defined (or the Unicode REPLACEMENT
10698 CHARACTER, if not) is silently returned, and *retlen is set (if
10699 "retlen" isn't NULL) so that ("s" + *retlen) is the next
10700 possible position in "s" that could begin a non-malformed
10701 character. See "utf8n_to_uvchr" for details on when the
10702 REPLACEMENT CHARACTER is returned.
10703
10704 UV utf8_to_uvuni_buf(const U8 *s, const U8 *send,
10705 STRLEN *retlen)
10706
10707 UVCHR_IS_INVARIANT
10708 Evaluates to 1 if the representation of code point "cp" is the
10709 same whether or not it is encoded in UTF-8; otherwise evaluates
10710 to 0. UTF-8 invariant characters can be copied as-is when
10711 converting to/from UTF-8, saving time. "cp" is Unicode if
10712 above 255; otherwise is platform-native.
10713
10714 bool UVCHR_IS_INVARIANT(UV cp)
10715
10716 UVCHR_SKIP
10717 returns the number of bytes required to represent the code
10718 point "cp" when encoded as UTF-8. "cp" is a native (ASCII or
10719 EBCDIC) code point if less than 255; a Unicode code point
10720 otherwise.
10721
10722 STRLEN UVCHR_SKIP(UV cp)
10723
10724 uvchr_to_utf8
10725 Adds the UTF-8 representation of the native code point "uv" to
10726 the end of the string "d"; "d" should have at least
10727 "UVCHR_SKIP(uv)+1" (up to "UTF8_MAXBYTES+1") free bytes
10728 available. The return value is the pointer to the byte after
10729 the end of the new character. In other words,
10730
10731 d = uvchr_to_utf8(d, uv);
10732
10733 is the recommended wide native character-aware way of saying
10734
10735 *(d++) = uv;
10736
10737 This function accepts any code point from 0.."IV_MAX" as input.
10738 "IV_MAX" is typically 0x7FFF_FFFF in a 32-bit word.
10739
10740 It is possible to forbid or warn on non-Unicode code points, or
10741 those that may be problematic by using "uvchr_to_utf8_flags".
10742
10743 U8* uvchr_to_utf8(U8 *d, UV uv)
10744
10745 uvchr_to_utf8_flags
10746 Adds the UTF-8 representation of the native code point "uv" to
10747 the end of the string "d"; "d" should have at least
10748 "UVCHR_SKIP(uv)+1" (up to "UTF8_MAXBYTES+1") free bytes
10749 available. The return value is the pointer to the byte after
10750 the end of the new character. In other words,
10751
10752 d = uvchr_to_utf8_flags(d, uv, flags);
10753
10754 or, in most cases,
10755
10756 d = uvchr_to_utf8_flags(d, uv, 0);
10757
10758 This is the Unicode-aware way of saying
10759
10760 *(d++) = uv;
10761
10762 If "flags" is 0, this function accepts any code point from
10763 0.."IV_MAX" as input. "IV_MAX" is typically 0x7FFF_FFFF in a
10764 32-bit word.
10765
10766 Specifying "flags" can further restrict what is allowed and not
10767 warned on, as follows:
10768
10769 If "uv" is a Unicode surrogate code point and
10770 "UNICODE_WARN_SURROGATE" is set, the function will raise a
10771 warning, provided UTF8 warnings are enabled. If instead
10772 "UNICODE_DISALLOW_SURROGATE" is set, the function will fail and
10773 return NULL. If both flags are set, the function will both
10774 warn and return NULL.
10775
10776 Similarly, the "UNICODE_WARN_NONCHAR" and
10777 "UNICODE_DISALLOW_NONCHAR" flags affect how the function
10778 handles a Unicode non-character.
10779
10780 And likewise, the "UNICODE_WARN_SUPER" and
10781 "UNICODE_DISALLOW_SUPER" flags affect the handling of code
10782 points that are above the Unicode maximum of 0x10FFFF.
10783 Languages other than Perl may not be able to accept files that
10784 contain these.
10785
10786 The flag "UNICODE_WARN_ILLEGAL_INTERCHANGE" selects all three
10787 of the above WARN flags; and
10788 "UNICODE_DISALLOW_ILLEGAL_INTERCHANGE" selects all three
10789 DISALLOW flags. "UNICODE_DISALLOW_ILLEGAL_INTERCHANGE"
10790 restricts the allowed inputs to the strict UTF-8 traditionally
10791 defined by Unicode. Similarly,
10792 "UNICODE_WARN_ILLEGAL_C9_INTERCHANGE" and
10793 "UNICODE_DISALLOW_ILLEGAL_C9_INTERCHANGE" are shortcuts to
10794 select the above-Unicode and surrogate flags, but not the non-
10795 character ones, as defined in Unicode Corrigendum #9
10796 <http://www.unicode.org/versions/corrigendum9.html>. See
10797 "Noncharacter code points" in perlunicode.
10798
10799 Extremely high code points were never specified in any
10800 standard, and require an extension to UTF-8 to express, which
10801 Perl does. It is likely that programs written in something
10802 other than Perl would not be able to read files that contain
10803 these; nor would Perl understand files written by something
10804 that uses a different extension. For these reasons, there is a
10805 separate set of flags that can warn and/or disallow these
10806 extremely high code points, even if other above-Unicode ones
10807 are accepted. They are the "UNICODE_WARN_PERL_EXTENDED" and
10808 "UNICODE_DISALLOW_PERL_EXTENDED" flags. For more information
10809 see ""UTF8_GOT_PERL_EXTENDED"". Of course
10810 "UNICODE_DISALLOW_SUPER" will treat all above-Unicode code
10811 points, including these, as malformations. (Note that the
10812 Unicode standard considers anything above 0x10FFFF to be
10813 illegal, but there are standards predating it that allow up to
10814 0x7FFF_FFFF (2**31 -1))
10815
10816 A somewhat misleadingly named synonym for
10817 "UNICODE_WARN_PERL_EXTENDED" is retained for backward
10818 compatibility: "UNICODE_WARN_ABOVE_31_BIT". Similarly,
10819 "UNICODE_DISALLOW_ABOVE_31_BIT" is usable instead of the more
10820 accurately named "UNICODE_DISALLOW_PERL_EXTENDED". The names
10821 are misleading because on EBCDIC platforms,these flags can
10822 apply to code points that actually do fit in 31 bits. The new
10823 names accurately describe the situation in all cases.
10824
10825 U8* uvchr_to_utf8_flags(U8 *d, UV uv, UV flags)
10826
10827 uvchr_to_utf8_flags_msgs
10828 NOTE: this function is experimental and may change or be
10829 removed without notice.
10830
10831 THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED
10832 CIRCUMSTANCES.
10833
10834 Most code should use ""uvchr_to_utf8_flags"()" rather than call
10835 this directly.
10836
10837 This function is for code that wants any warning and/or error
10838 messages to be returned to the caller rather than be displayed.
10839 All messages that would have been displayed if all lexcial
10840 warnings are enabled will be returned.
10841
10842 It is just like "uvchr_to_utf8_flags" but it takes an extra
10843 parameter placed after all the others, "msgs". If this
10844 parameter is 0, this function behaves identically to
10845 "uvchr_to_utf8_flags". Otherwise, "msgs" should be a pointer
10846 to an "HV *" variable, in which this function creates a new HV
10847 to contain any appropriate messages. The hash has three key-
10848 value pairs, as follows:
10849
10850 "text"
10851 The text of the message as a "SVpv".
10852
10853 "warn_categories"
10854 The warning category (or categories) packed into a "SVuv".
10855
10856 "flag"
10857 A single flag bit associated with this message, in a
10858 "SVuv". The bit corresponds to some bit in the *errors
10859 return value, such as "UNICODE_GOT_SURROGATE".
10860
10861 It's important to note that specifying this parameter as non-
10862 null will cause any warnings this function would otherwise
10863 generate to be suppressed, and instead be placed in *msgs. The
10864 caller can check the lexical warnings state (or not) when
10865 choosing what to do with the returned messages.
10866
10867 The caller, of course, is responsible for freeing any returned
10868 HV.
10869
10870 U8* uvchr_to_utf8_flags_msgs(U8 *d, UV uv, UV flags,
10871 HV ** msgs)
10872
10873 uvoffuni_to_utf8_flags
10874 THIS FUNCTION SHOULD BE USED IN ONLY VERY SPECIALIZED
10875 CIRCUMSTANCES. Instead, Almost all code should use
10876 "uvchr_to_utf8" or "uvchr_to_utf8_flags".
10877
10878 This function is like them, but the input is a strict Unicode
10879 (as opposed to native) code point. Only in very rare
10880 circumstances should code not be using the native code point.
10881
10882 For details, see the description for "uvchr_to_utf8_flags".
10883
10884 U8* uvoffuni_to_utf8_flags(U8 *d, UV uv,
10885 const UV flags)
10886
10887 uvuni_to_utf8_flags
10888 Instead you almost certainly want to use "uvchr_to_utf8" or
10889 "uvchr_to_utf8_flags".
10890
10891 This function is a deprecated synonym for
10892 "uvoffuni_to_utf8_flags", which itself, while not deprecated,
10893 should be used only in isolated circumstances. These functions
10894 were useful for code that wanted to handle both EBCDIC and
10895 ASCII platforms with Unicode properties, but starting in Perl
10896 v5.20, the distinctions between the platforms have mostly been
10897 made invisible to most code, so this function is quite unlikely
10898 to be what you want.
10899
10900 U8* uvuni_to_utf8_flags(U8 *d, UV uv, UV flags)
10901
10902 valid_utf8_to_uvchr
10903 Like "utf8_to_uvchr_buf", but should only be called when it is
10904 known that the next character in the input UTF-8 string "s" is
10905 well-formed (e.g., it passes "isUTF8_CHAR". Surrogates, non-
10906 character code points, and non-Unicode code points are allowed.
10907
10908 UV valid_utf8_to_uvchr(const U8 *s, STRLEN *retlen)
10909
10911 newXSproto
10912 Used by "xsubpp" to hook up XSUBs as Perl subs. Adds Perl
10913 prototypes to the subs.
10914
10915 XS_APIVERSION_BOOTCHECK
10916 Macro to verify that the perl api version an XS module has been
10917 compiled against matches the api version of the perl
10918 interpreter it's being loaded into.
10919
10920 XS_APIVERSION_BOOTCHECK;
10921
10922 XS_VERSION
10923 The version identifier for an XS module. This is usually
10924 handled automatically by "ExtUtils::MakeMaker". See
10925 "XS_VERSION_BOOTCHECK".
10926
10927 XS_VERSION_BOOTCHECK
10928 Macro to verify that a PM module's $VERSION variable matches
10929 the XS module's "XS_VERSION" variable. This is usually handled
10930 automatically by "xsubpp". See "The VERSIONCHECK: Keyword" in
10931 perlxs.
10932
10933 XS_VERSION_BOOTCHECK;
10934
10936 ckWARN Returns a boolean as to whether or not warnings are enabled for
10937 the warning category "w". If the category is by default
10938 enabled even if not within the scope of "use warnings", instead
10939 use the "ckWARN_d" macro.
10940
10941 bool ckWARN(U32 w)
10942
10943 ckWARN2 Like "ckWARN", but takes two warnings categories as input, and
10944 returns TRUE if either is enabled. If either category is by
10945 default enabled even if not within the scope of "use warnings",
10946 instead use the "ckWARN2_d" macro. The categories must be
10947 completely independent, one may not be subclassed from the
10948 other.
10949
10950 bool ckWARN2(U32 w1, U32 w2)
10951
10952 ckWARN3 Like "ckWARN2", but takes three warnings categories as input,
10953 and returns TRUE if any is enabled. If any of the categories
10954 is by default enabled even if not within the scope of
10955 "use warnings", instead use the "ckWARN3_d" macro. The
10956 categories must be completely independent, one may not be
10957 subclassed from any other.
10958
10959 bool ckWARN3(U32 w1, U32 w2, U32 w3)
10960
10961 ckWARN4 Like "ckWARN3", but takes four warnings categories as input,
10962 and returns TRUE if any is enabled. If any of the categories
10963 is by default enabled even if not within the scope of
10964 "use warnings", instead use the "ckWARN4_d" macro. The
10965 categories must be completely independent, one may not be
10966 subclassed from any other.
10967
10968 bool ckWARN4(U32 w1, U32 w2, U32 w3, U32 w4)
10969
10970 ckWARN_d
10971 Like "ckWARN", but for use if and only if the warning category
10972 is by default enabled even if not within the scope of
10973 "use warnings".
10974
10975 bool ckWARN_d(U32 w)
10976
10977 ckWARN2_d
10978 Like "ckWARN2", but for use if and only if either warning
10979 category is by default enabled even if not within the scope of
10980 "use warnings".
10981
10982 bool ckWARN2_d(U32 w1, U32 w2)
10983
10984 ckWARN3_d
10985 Like "ckWARN3", but for use if and only if any of the warning
10986 categories is by default enabled even if not within the scope
10987 of "use warnings".
10988
10989 bool ckWARN3_d(U32 w1, U32 w2, U32 w3)
10990
10991 ckWARN4_d
10992 Like "ckWARN4", but for use if and only if any of the warning
10993 categories is by default enabled even if not within the scope
10994 of "use warnings".
10995
10996 bool ckWARN4_d(U32 w1, U32 w2, U32 w3, U32 w4)
10997
10998 croak This is an XS interface to Perl's "die" function.
10999
11000 Take a sprintf-style format pattern and argument list. These
11001 are used to generate a string message. If the message does not
11002 end with a newline, then it will be extended with some
11003 indication of the current location in the code, as described
11004 for "mess_sv".
11005
11006 The error message will be used as an exception, by default
11007 returning control to the nearest enclosing "eval", but subject
11008 to modification by a $SIG{__DIE__} handler. In any case, the
11009 "croak" function never returns normally.
11010
11011 For historical reasons, if "pat" is null then the contents of
11012 "ERRSV" ($@) will be used as an error message or object instead
11013 of building an error message from arguments. If you want to
11014 throw a non-string object, or build an error message in an SV
11015 yourself, it is preferable to use the "croak_sv" function,
11016 which does not involve clobbering "ERRSV".
11017
11018 void croak(const char *pat, ...)
11019
11020 croak_no_modify
11021 Exactly equivalent to "Perl_croak(aTHX_ "%s", PL_no_modify)",
11022 but generates terser object code than using "Perl_croak". Less
11023 code used on exception code paths reduces CPU cache pressure.
11024
11025 void croak_no_modify()
11026
11027 croak_sv
11028 This is an XS interface to Perl's "die" function.
11029
11030 "baseex" is the error message or object. If it is a reference,
11031 it will be used as-is. Otherwise it is used as a string, and
11032 if it does not end with a newline then it will be extended with
11033 some indication of the current location in the code, as
11034 described for "mess_sv".
11035
11036 The error message or object will be used as an exception, by
11037 default returning control to the nearest enclosing "eval", but
11038 subject to modification by a $SIG{__DIE__} handler. In any
11039 case, the "croak_sv" function never returns normally.
11040
11041 To die with a simple string message, the "croak" function may
11042 be more convenient.
11043
11044 void croak_sv(SV *baseex)
11045
11046 die Behaves the same as "croak", except for the return type. It
11047 should be used only where the "OP *" return type is required.
11048 The function never actually returns.
11049
11050 OP * die(const char *pat, ...)
11051
11052 die_sv Behaves the same as "croak_sv", except for the return type. It
11053 should be used only where the "OP *" return type is required.
11054 The function never actually returns.
11055
11056 OP * die_sv(SV *baseex)
11057
11058 vcroak This is an XS interface to Perl's "die" function.
11059
11060 "pat" and "args" are a sprintf-style format pattern and
11061 encapsulated argument list. These are used to generate a
11062 string message. If the message does not end with a newline,
11063 then it will be extended with some indication of the current
11064 location in the code, as described for "mess_sv".
11065
11066 The error message will be used as an exception, by default
11067 returning control to the nearest enclosing "eval", but subject
11068 to modification by a $SIG{__DIE__} handler. In any case, the
11069 "croak" function never returns normally.
11070
11071 For historical reasons, if "pat" is null then the contents of
11072 "ERRSV" ($@) will be used as an error message or object instead
11073 of building an error message from arguments. If you want to
11074 throw a non-string object, or build an error message in an SV
11075 yourself, it is preferable to use the "croak_sv" function,
11076 which does not involve clobbering "ERRSV".
11077
11078 void vcroak(const char *pat, va_list *args)
11079
11080 vwarn This is an XS interface to Perl's "warn" function.
11081
11082 "pat" and "args" are a sprintf-style format pattern and
11083 encapsulated argument list. These are used to generate a
11084 string message. If the message does not end with a newline,
11085 then it will be extended with some indication of the current
11086 location in the code, as described for "mess_sv".
11087
11088 The error message or object will by default be written to
11089 standard error, but this is subject to modification by a
11090 $SIG{__WARN__} handler.
11091
11092 Unlike with "vcroak", "pat" is not permitted to be null.
11093
11094 void vwarn(const char *pat, va_list *args)
11095
11096 warn This is an XS interface to Perl's "warn" function.
11097
11098 Take a sprintf-style format pattern and argument list. These
11099 are used to generate a string message. If the message does not
11100 end with a newline, then it will be extended with some
11101 indication of the current location in the code, as described
11102 for "mess_sv".
11103
11104 The error message or object will by default be written to
11105 standard error, but this is subject to modification by a
11106 $SIG{__WARN__} handler.
11107
11108 Unlike with "croak", "pat" is not permitted to be null.
11109
11110 void warn(const char *pat, ...)
11111
11112 warn_sv This is an XS interface to Perl's "warn" function.
11113
11114 "baseex" is the error message or object. If it is a reference,
11115 it will be used as-is. Otherwise it is used as a string, and
11116 if it does not end with a newline then it will be extended with
11117 some indication of the current location in the code, as
11118 described for "mess_sv".
11119
11120 The error message or object will by default be written to
11121 standard error, but this is subject to modification by a
11122 $SIG{__WARN__} handler.
11123
11124 To warn with a simple string message, the "warn" function may
11125 be more convenient.
11126
11127 void warn_sv(SV *baseex)
11128
11130 The following functions have been flagged as part of the public API,
11131 but are currently undocumented. Use them at your own risk, as the
11132 interfaces are subject to change. Functions that are not listed in
11133 this document are not intended for public use, and should NOT be used
11134 under any circumstances.
11135
11136 If you feel you need to use one of these functions, first send email to
11137 perl5-porters@perl.org <mailto:perl5-porters@perl.org>. It may be that
11138 there is a good reason for the function not being documented, and it
11139 should be removed from this list; or it may just be that no one has
11140 gotten around to documenting it. In the latter case, you will be asked
11141 to submit a patch to document the function. Once your patch is
11142 accepted, it will indicate that the interface is stable (unless it is
11143 explicitly marked otherwise) and usable by you.
11144
11145 GetVars
11146 Gv_AMupdate
11147 PerlIO_clearerr
11148 PerlIO_close
11149 PerlIO_context_layers
11150 PerlIO_eof
11151 PerlIO_error
11152 PerlIO_fileno
11153 PerlIO_fill
11154 PerlIO_flush
11155 PerlIO_get_base
11156 PerlIO_get_bufsiz
11157 PerlIO_get_cnt
11158 PerlIO_get_ptr
11159 PerlIO_read
11160 PerlIO_seek
11161 PerlIO_set_cnt
11162 PerlIO_set_ptrcnt
11163 PerlIO_setlinebuf
11164 PerlIO_stderr
11165 PerlIO_stdin
11166 PerlIO_stdout
11167 PerlIO_tell
11168 PerlIO_unread
11169 PerlIO_write
11170 _variant_byte_number
11171 amagic_call
11172 amagic_deref_call
11173 any_dup
11174 atfork_lock
11175 atfork_unlock
11176 av_arylen_p
11177 av_iter_p
11178 block_gimme
11179 call_atexit
11180 call_list
11181 calloc
11182 cast_i32
11183 cast_iv
11184 cast_ulong
11185 cast_uv
11186 ck_warner
11187 ck_warner_d
11188 ckwarn
11189 ckwarn_d
11190 clear_defarray
11191 clone_params_del
11192 clone_params_new
11193 croak_memory_wrap
11194 croak_nocontext
11195 csighandler
11196 cx_dump
11197 cx_dup
11198 cxinc
11199 deb
11200 deb_nocontext
11201 debop
11202 debprofdump
11203 debstack
11204 debstackptrs
11205 delimcpy
11206 despatch_signals
11207 die_nocontext
11208 dirp_dup
11209 do_aspawn
11210 do_binmode
11211 do_close
11212 do_gv_dump
11213 do_gvgv_dump
11214 do_hv_dump
11215 do_join
11216 do_magic_dump
11217 do_op_dump
11218 do_open
11219 do_open9
11220 do_openn
11221 do_pmop_dump
11222 do_spawn
11223 do_spawn_nowait
11224 do_sprintf
11225 do_sv_dump
11226 doing_taint
11227 doref
11228 dounwind
11229 dowantarray
11230 dump_eval
11231 dump_form
11232 dump_indent
11233 dump_mstats
11234 dump_sub
11235 dump_vindent
11236 filter_add
11237 filter_del
11238 filter_read
11239 foldEQ_latin1
11240 form_nocontext
11241 fp_dup
11242 fprintf_nocontext
11243 free_global_struct
11244 free_tmps
11245 get_context
11246 get_mstats
11247 get_op_descs
11248 get_op_names
11249 get_ppaddr
11250 get_vtbl
11251 gp_dup
11252 gp_free
11253 gp_ref
11254 gv_AVadd
11255 gv_HVadd
11256 gv_IOadd
11257 gv_SVadd
11258 gv_add_by_type
11259 gv_autoload4
11260 gv_autoload_pv
11261 gv_autoload_pvn
11262 gv_autoload_sv
11263 gv_check
11264 gv_dump
11265 gv_efullname
11266 gv_efullname3
11267 gv_efullname4
11268 gv_fetchfile
11269 gv_fetchfile_flags
11270 gv_fetchpv
11271 gv_fetchpvn_flags
11272 gv_fetchsv
11273 gv_fullname
11274 gv_fullname3
11275 gv_fullname4
11276 gv_handler
11277 gv_name_set
11278 he_dup
11279 hek_dup
11280 hv_common
11281 hv_common_key_len
11282 hv_delayfree_ent
11283 hv_eiter_p
11284 hv_eiter_set
11285 hv_free_ent
11286 hv_ksplit
11287 hv_name_set
11288 hv_placeholders_get
11289 hv_placeholders_set
11290 hv_rand_set
11291 hv_riter_p
11292 hv_riter_set
11293 ibcmp_utf8
11294 init_global_struct
11295 init_stacks
11296 init_tm
11297 instr
11298 is_lvalue_sub
11299 leave_scope
11300 load_module_nocontext
11301 magic_dump
11302 malloc
11303 markstack_grow
11304 mess_nocontext
11305 mfree
11306 mg_dup
11307 mg_size
11308 mini_mktime
11309 moreswitches
11310 mro_get_from_name
11311 mro_get_private_data
11312 mro_set_mro
11313 mro_set_private_data
11314 my_atof
11315 my_atof2
11316 my_chsize
11317 my_cxt_index
11318 my_cxt_init
11319 my_dirfd
11320 my_exit
11321 my_failure_exit
11322 my_fflush_all
11323 my_fork
11324 my_lstat
11325 my_pclose
11326 my_popen
11327 my_popen_list
11328 my_setenv
11329 my_socketpair
11330 my_stat
11331 my_strftime
11332 newANONATTRSUB
11333 newANONHASH
11334 newANONLIST
11335 newANONSUB
11336 newATTRSUB
11337 newAVREF
11338 newCVREF
11339 newFORM
11340 newGVREF
11341 newGVgen
11342 newGVgen_flags
11343 newHVREF
11344 newHVhv
11345 newIO
11346 newMYSUB
11347 newPROG
11348 newRV
11349 newSUB
11350 newSVREF
11351 newSVpvf_nocontext
11352 new_stackinfo
11353 op_refcnt_lock
11354 op_refcnt_unlock
11355 parser_dup
11356 perl_alloc_using
11357 perl_clone_using
11358 pmop_dump
11359 pop_scope
11360 pregcomp
11361 pregexec
11362 pregfree
11363 pregfree2
11364 printf_nocontext
11365 ptr_table_fetch
11366 ptr_table_free
11367 ptr_table_new
11368 ptr_table_split
11369 ptr_table_store
11370 push_scope
11371 re_compile
11372 re_dup_guts
11373 re_intuit_start
11374 re_intuit_string
11375 realloc
11376 reentrant_free
11377 reentrant_init
11378 reentrant_retry
11379 reentrant_size
11380 ref
11381 reg_named_buff_all
11382 reg_named_buff_exists
11383 reg_named_buff_fetch
11384 reg_named_buff_firstkey
11385 reg_named_buff_nextkey
11386 reg_named_buff_scalar
11387 regdump
11388 regdupe_internal
11389 regexec_flags
11390 regfree_internal
11391 reginitcolors
11392 regnext
11393 repeatcpy
11394 rsignal
11395 rsignal_state
11396 runops_debug
11397 runops_standard
11398 rvpv_dup
11399 safesyscalloc
11400 safesysfree
11401 safesysmalloc
11402 safesysrealloc
11403 save_I16
11404 save_I32
11405 save_I8
11406 save_adelete
11407 save_aelem
11408 save_aelem_flags
11409 save_alloc
11410 save_aptr
11411 save_ary
11412 save_bool
11413 save_clearsv
11414 save_delete
11415 save_destructor
11416 save_destructor_x
11417 save_freeop
11418 save_freepv
11419 save_freesv
11420 save_generic_pvref
11421 save_generic_svref
11422 save_hash
11423 save_hdelete
11424 save_helem
11425 save_helem_flags
11426 save_hints
11427 save_hptr
11428 save_int
11429 save_item
11430 save_iv
11431 save_list
11432 save_long
11433 save_mortalizesv
11434 save_nogv
11435 save_op
11436 save_padsv_and_mortalize
11437 save_pptr
11438 save_pushi32ptr
11439 save_pushptr
11440 save_pushptrptr
11441 save_re_context
11442 save_scalar
11443 save_set_svflags
11444 save_shared_pvref
11445 save_sptr
11446 save_svref
11447 save_vptr
11448 savestack_grow
11449 savestack_grow_cnt
11450 scan_num
11451 scan_vstring
11452 seed
11453 set_context
11454 share_hek
11455 si_dup
11456 ss_dup
11457 stack_grow
11458 start_subparse
11459 str_to_version
11460 sv_2iv
11461 sv_2pv
11462 sv_2uv
11463 sv_catpvf_mg_nocontext
11464 sv_catpvf_nocontext
11465 sv_dup
11466 sv_dup_inc
11467 sv_peek
11468 sv_pvn_nomg
11469 sv_setpvf_mg_nocontext
11470 sv_setpvf_nocontext
11471 sys_init
11472 sys_init3
11473 sys_intern_clear
11474 sys_intern_dup
11475 sys_intern_init
11476 sys_term
11477 taint_env
11478 taint_proper
11479 unlnk
11480 unsharepvn
11481 uvuni_to_utf8
11482 vdeb
11483 vform
11484 vload_module
11485 vnewSVpvf
11486 vwarner
11487 warn_nocontext
11488 warner
11489 warner_nocontext
11490 whichsig
11491 whichsig_pv
11492 whichsig_pvn
11493 whichsig_sv
11494
11496 Until May 1997, this document was maintained by Jeff Okamoto
11497 <okamoto@corp.hp.com>. It is now maintained as part of Perl itself.
11498
11499 With lots of help and suggestions from Dean Roehrich, Malcolm Beattie,
11500 Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil
11501 Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer,
11502 Stephen McCamant, and Gurusamy Sarathy.
11503
11504 API Listing originally by Dean Roehrich <roehrich@cray.com>.
11505
11506 Updated to be autogenerated from comments in the source by Benjamin
11507 Stuhl.
11508
11510 perlguts, perlxs, perlxstut, perlintern
11511
11512
11513
11514perl v5.28.2 2019-04-23 PERLAPI(1)