5 ----------------------------------------------------------------------
7 ppport.h -- Perl/Pollution/Portability Version 3.13
9 Automatically created by Devel::PPPort running under perl 5.010000.
11 Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
12 includes in parts/inc/ instead.
14 Use 'perldoc ppport.h' to view the documentation below.
16 ----------------------------------------------------------------------
24 ppport.h - Perl/Pollution/Portability version 3.13
28 perl ppport.h [options] [source files]
30 Searches current directory for files if no [source files] are given
32 --help show short help
34 --version show version
36 --patch=file write one patch file with changes
37 --copy=suffix write changed copies with suffix
38 --diff=program use diff program and options
40 --compat-version=version provide compatibility with Perl version
41 --cplusplus accept C++ comments
43 --quiet don't output anything except fatal errors
44 --nodiag don't show diagnostics
45 --nohints don't show hints
46 --nochanges don't suggest changes
47 --nofilter don't filter input files
49 --strip strip all script and doc functionality from
52 --list-provided list provided API
53 --list-unsupported list unsupported API
54 --api-info=name show Perl API portability information
58 This version of F<ppport.h> is designed to support operation with Perl
59 installations back to 5.003, and has been tested up to 5.10.0.
65 Display a brief usage summary.
69 Display the version of F<ppport.h>.
71 =head2 --patch=I<file>
73 If this option is given, a single patch file will be created if
74 any changes are suggested. This requires a working diff program
75 to be installed on your system.
77 =head2 --copy=I<suffix>
79 If this option is given, a copy of each file will be saved with
80 the given suffix that contains the suggested changes. This does
81 not require any external programs. Note that this does not
82 automagially add a dot between the original filename and the
83 suffix. If you want the dot, you have to include it in the option
86 If neither C<--patch> or C<--copy> are given, the default is to
87 simply print the diffs for each file. This requires either
88 C<Text::Diff> or a C<diff> program to be installed.
90 =head2 --diff=I<program>
92 Manually set the diff program and options to use. The default
93 is to use C<Text::Diff>, when installed, and output unified
96 =head2 --compat-version=I<version>
98 Tell F<ppport.h> to check for compatibility with the given
99 Perl version. The default is to check for compatibility with Perl
100 version 5.003. You can use this option to reduce the output
101 of F<ppport.h> if you intend to be backward compatible only
102 down to a certain Perl version.
106 Usually, F<ppport.h> will detect C++ style comments and
107 replace them with C style comments for portability reasons.
108 Using this option instructs F<ppport.h> to leave C++
113 Be quiet. Don't print anything except fatal errors.
117 Don't output any diagnostic messages. Only portability
118 alerts will be printed.
122 Don't output any hints. Hints often contain useful portability
123 notes. Warnings will still be displayed.
127 Don't suggest any changes. Only give diagnostic output and hints
128 unless these are also deactivated.
132 Don't filter the list of input files. By default, files not looking
133 like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
137 Strip all script and documentation functionality from F<ppport.h>.
138 This reduces the size of F<ppport.h> dramatically and may be useful
139 if you want to include F<ppport.h> in smaller modules without
140 increasing their distribution size too much.
142 The stripped F<ppport.h> will have a C<--unstrip> option that allows
143 you to undo the stripping, but only if an appropriate C<Devel::PPPort>
146 =head2 --list-provided
148 Lists the API elements for which compatibility is provided by
149 F<ppport.h>. Also lists if it must be explicitly requested,
150 if it has dependencies, and if there are hints or warnings for it.
152 =head2 --list-unsupported
154 Lists the API elements that are known not to be supported by
155 F<ppport.h> and below which version of Perl they probably
156 won't be available or work.
158 =head2 --api-info=I<name>
160 Show portability information for API elements matching I<name>.
161 If I<name> is surrounded by slashes, it is interpreted as a regular
166 In order for a Perl extension (XS) module to be as portable as possible
167 across differing versions of Perl itself, certain steps need to be taken.
173 Including this header is the first major one. This alone will give you
174 access to a large part of the Perl API that hasn't been available in
175 earlier Perl releases. Use
177 perl ppport.h --list-provided
179 to see which API elements are provided by ppport.h.
183 You should avoid using deprecated parts of the API. For example, using
184 global Perl variables without the C<PL_> prefix is deprecated. Also,
185 some API functions used to have a C<perl_> prefix. Using this form is
186 also deprecated. You can safely use the supported API, as F<ppport.h>
187 will provide wrappers for older Perl versions.
191 If you use one of a few functions or variables that were not present in
192 earlier versions of Perl, and that can't be provided using a macro, you
193 have to explicitly request support for these functions by adding one or
194 more C<#define>s in your source code before the inclusion of F<ppport.h>.
196 These functions or variables will be marked C<explicit> in the list shown
197 by C<--list-provided>.
199 Depending on whether you module has a single or multiple files that
200 use such functions or variables, you want either C<static> or global
203 For a C<static> function or variable (used only in a single source
206 #define NEED_function
207 #define NEED_variable
209 For a global function or variable (used in multiple source files),
212 #define NEED_function_GLOBAL
213 #define NEED_variable_GLOBAL
215 Note that you mustn't have more than one global request for the
216 same function or variable in your project.
218 Function / Variable Static Request Global Request
219 -----------------------------------------------------------------------------------------
220 PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL
221 eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL
222 grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL
223 grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL
224 grok_number() NEED_grok_number NEED_grok_number_GLOBAL
225 grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL
226 grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL
227 load_module() NEED_load_module NEED_load_module_GLOBAL
228 my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL
229 my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL
230 my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL
231 newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
232 newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL
233 newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL
234 sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL
235 sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL
236 sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL
237 sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL
238 sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL
239 sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL
240 sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL
241 vload_module() NEED_vload_module NEED_vload_module_GLOBAL
242 vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL
243 warner() NEED_warner NEED_warner_GLOBAL
245 To avoid namespace conflicts, you can change the namespace of the
246 explicitly exported functions / variables using the C<DPPP_NAMESPACE>
247 macro. Just C<#define> the macro before including C<ppport.h>:
249 #define DPPP_NAMESPACE MyOwnNamespace_
252 The default namespace is C<DPPP_>.
256 The good thing is that most of the above can be checked by running
257 F<ppport.h> on your source code. See the next section for
262 To verify whether F<ppport.h> is needed for your module, whether you
263 should make any changes to your code, and whether any special defines
264 should be used, F<ppport.h> can be run as a Perl script to check your
265 source code. Simply say:
269 The result will usually be a list of patches suggesting changes
270 that should at least be acceptable, if not necessarily the most
271 efficient solution, or a fix for all possible problems.
273 If you know that your XS module uses features only available in
274 newer Perl releases, if you're aware that it uses C++ comments,
275 and if you want all suggestions as a single patch file, you could
276 use something like this:
278 perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
280 If you only want your code to be scanned without any suggestions
283 perl ppport.h --nochanges
285 You can specify a different C<diff> program or options, using
286 the C<--diff> option:
288 perl ppport.h --diff='diff -C 10'
290 This would output context diffs with 10 lines of context.
292 If you want to create patched copies of your files instead, use:
294 perl ppport.h --copy=.new
296 To display portability information for the C<newSVpvn> function,
299 perl ppport.h --api-info=newSVpvn
301 Since the argument to C<--api-info> can be a regular expression,
304 perl ppport.h --api-info=/_nomg$/
306 to display portability information for all C<_nomg> functions or
308 perl ppport.h --api-info=/./
310 to display information for all known API elements.
314 If this version of F<ppport.h> is causing failure during
315 the compilation of this module, please check if newer versions
316 of either this module or C<Devel::PPPort> are available on CPAN
317 before sending a bug report.
319 If F<ppport.h> was generated using the latest version of
320 C<Devel::PPPort> and is causing failure of this module, please
321 file a bug report using the CPAN Request Tracker at L<http://rt.cpan.org/>.
323 Please include the following information:
329 The complete output from running "perl -V"
337 The name and version of the module you were trying to build.
341 A full log of the build that failed.
345 Any other information that you think could be relevant.
349 For the latest version of this code, please get the C<Devel::PPPort>
354 Version 3.x, Copyright (c) 2004-2007, Marcus Holland-Moritz.
356 Version 2.x, Copyright (C) 2001, Paul Marquess.
358 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
360 This program is free software; you can redistribute it and/or
361 modify it under the same terms as Perl itself.
365 See L<Devel::PPPort>.
371 # Disable broken TRIE-optimization
372 BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 }
387 my($ppport) = $0 =~ /([\w.]+)$/;
388 my $LF = '(?:\r\n|[\r\n])'; # line feed
389 my $HS = "[ \t]"; # horizontal whitespace
391 # Never use C comments in this file!
394 my $rccs = quotemeta $ccs;
395 my $rcce = quotemeta $cce;
398 require Getopt::Long;
399 Getopt::Long::GetOptions(\%opt, qw(
400 help quiet diag! filter! hints! changes! cplusplus strip version
401 patch=s copy=s diff=s compat-version=s
402 list-provided list-unsupported api-info=s
406 if ($@ and grep /^-/, @ARGV) {
407 usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
408 die "Getopt::Long not found. Please don't use any options.\n";
412 print "This is $0 $VERSION.\n";
416 usage() if $opt{help};
417 strip() if $opt{strip};
419 if (exists $opt{'compat-version'}) {
420 my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
422 die "Invalid version number format: '$opt{'compat-version'}'\n";
424 die "Only Perl 5 is supported\n" if $r != 5;
425 die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000;
426 $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
429 $opt{'compat-version'} = 5;
432 my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
434 ($2 ? ( base => $2 ) : ()),
435 ($3 ? ( todo => $3 ) : ()),
436 (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()),
437 (index($4, 'p') >= 0 ? ( provided => 1 ) : ()),
438 (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()),
440 : die "invalid spec: $_" } qw(
446 CopFILEAV|5.006000||p
447 CopFILEGV_set|5.006000||p
448 CopFILEGV|5.006000||p
449 CopFILESV|5.006000||p
450 CopFILE_set|5.006000||p
452 CopSTASHPV_set|5.006000||p
453 CopSTASHPV|5.006000||p
454 CopSTASH_eq|5.006000||p
455 CopSTASH_set|5.006000||p
463 END_EXTERN_C|5.005000||p
472 GROK_NUMERIC_RADIX|5.007002||p
487 HeSVKEY_force||5.004000|
488 HeSVKEY_set||5.004000|
493 IN_LOCALE_COMPILETIME|5.007002||p
494 IN_LOCALE_RUNTIME|5.007002||p
495 IN_LOCALE|5.007002||p
496 IN_PERL_COMPILETIME|5.008001||p
497 IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
498 IS_NUMBER_INFINITY|5.007002||p
499 IS_NUMBER_IN_UV|5.007002||p
500 IS_NUMBER_NAN|5.007003||p
501 IS_NUMBER_NEG|5.007002||p
502 IS_NUMBER_NOT_INT|5.007002||p
510 MY_CXT_CLONE|5.009002||p
511 MY_CXT_INIT|5.007003||p
532 PAD_COMPNAME_FLAGS|||
533 PAD_COMPNAME_GEN_set|||
535 PAD_COMPNAME_OURSTASH|||
540 PAD_SAVE_SETNULLPAD|||
542 PAD_SET_CUR_NOSAVE|||
547 PERL_BCDVERSION|5.009005||p
548 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
549 PERL_HASH|5.004000||p
550 PERL_INT_MAX|5.004000||p
551 PERL_INT_MIN|5.004000||p
552 PERL_LONG_MAX|5.004000||p
553 PERL_LONG_MIN|5.004000||p
554 PERL_MAGIC_arylen|5.007002||p
555 PERL_MAGIC_backref|5.007002||p
556 PERL_MAGIC_bm|5.007002||p
557 PERL_MAGIC_collxfrm|5.007002||p
558 PERL_MAGIC_dbfile|5.007002||p
559 PERL_MAGIC_dbline|5.007002||p
560 PERL_MAGIC_defelem|5.007002||p
561 PERL_MAGIC_envelem|5.007002||p
562 PERL_MAGIC_env|5.007002||p
563 PERL_MAGIC_ext|5.007002||p
564 PERL_MAGIC_fm|5.007002||p
565 PERL_MAGIC_glob|5.009005||p
566 PERL_MAGIC_isaelem|5.007002||p
567 PERL_MAGIC_isa|5.007002||p
568 PERL_MAGIC_mutex|5.009005||p
569 PERL_MAGIC_nkeys|5.007002||p
570 PERL_MAGIC_overload_elem|5.007002||p
571 PERL_MAGIC_overload_table|5.007002||p
572 PERL_MAGIC_overload|5.007002||p
573 PERL_MAGIC_pos|5.007002||p
574 PERL_MAGIC_qr|5.007002||p
575 PERL_MAGIC_regdata|5.007002||p
576 PERL_MAGIC_regdatum|5.007002||p
577 PERL_MAGIC_regex_global|5.007002||p
578 PERL_MAGIC_shared_scalar|5.007003||p
579 PERL_MAGIC_shared|5.007003||p
580 PERL_MAGIC_sigelem|5.007002||p
581 PERL_MAGIC_sig|5.007002||p
582 PERL_MAGIC_substr|5.007002||p
583 PERL_MAGIC_sv|5.007002||p
584 PERL_MAGIC_taint|5.007002||p
585 PERL_MAGIC_tiedelem|5.007002||p
586 PERL_MAGIC_tiedscalar|5.007002||p
587 PERL_MAGIC_tied|5.007002||p
588 PERL_MAGIC_utf8|5.008001||p
589 PERL_MAGIC_uvar_elem|5.007003||p
590 PERL_MAGIC_uvar|5.007002||p
591 PERL_MAGIC_vec|5.007002||p
592 PERL_MAGIC_vstring|5.008001||p
593 PERL_QUAD_MAX|5.004000||p
594 PERL_QUAD_MIN|5.004000||p
595 PERL_REVISION|5.006000||p
596 PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
597 PERL_SCAN_DISALLOW_PREFIX|5.007003||p
598 PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
599 PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
600 PERL_SHORT_MAX|5.004000||p
601 PERL_SHORT_MIN|5.004000||p
602 PERL_SIGNALS_UNSAFE_FLAG|5.008001||p
603 PERL_SUBVERSION|5.006000||p
604 PERL_UCHAR_MAX|5.004000||p
605 PERL_UCHAR_MIN|5.004000||p
606 PERL_UINT_MAX|5.004000||p
607 PERL_UINT_MIN|5.004000||p
608 PERL_ULONG_MAX|5.004000||p
609 PERL_ULONG_MIN|5.004000||p
610 PERL_UNUSED_ARG|5.009003||p
611 PERL_UNUSED_CONTEXT|5.009004||p
612 PERL_UNUSED_DECL|5.007002||p
613 PERL_UNUSED_VAR|5.007002||p
614 PERL_UQUAD_MAX|5.004000||p
615 PERL_UQUAD_MIN|5.004000||p
616 PERL_USE_GCC_BRACE_GROUPS|5.009004||p
617 PERL_USHORT_MAX|5.004000||p
618 PERL_USHORT_MIN|5.004000||p
619 PERL_VERSION|5.006000||p
620 PL_DBsignal|5.005000||p
625 PL_compiling|5.004050||p
626 PL_copline|5.009005||p
627 PL_curcop|5.004050||p
628 PL_curstash|5.004050||p
629 PL_debstash|5.004050||p
631 PL_diehook|5.004050||p
635 PL_expect|5.009005||p
636 PL_hexdigit|5.005000||p
639 PL_laststatval|5.005000||p
640 PL_modglobal||5.005000|n
642 PL_no_modify|5.006000||p
644 PL_perl_destruct_level|5.004050||p
645 PL_perldb|5.004050||p
646 PL_ppaddr|5.006000||p
647 PL_rsfp_filters|5.004050||p
650 PL_signals|5.008001||p
651 PL_stack_base|5.004050||p
652 PL_stack_sp|5.004050||p
653 PL_statcache|5.005000||p
654 PL_stdingv|5.004050||p
655 PL_sv_arenaroot|5.004050||p
656 PL_sv_no|5.004050||pn
657 PL_sv_undef|5.004050||pn
658 PL_sv_yes|5.004050||pn
659 PL_tainted|5.004050||p
660 PL_tainting|5.004050||p
661 POP_MULTICALL||5.009005|
665 POPpbytex||5.007001|n
675 PUSH_MULTICALL||5.009005|
677 PUSHmortal|5.009002||p
683 PerlIO_clearerr||5.007003|
684 PerlIO_close||5.007003|
685 PerlIO_context_layers||5.009004|
686 PerlIO_eof||5.007003|
687 PerlIO_error||5.007003|
688 PerlIO_fileno||5.007003|
689 PerlIO_fill||5.007003|
690 PerlIO_flush||5.007003|
691 PerlIO_get_base||5.007003|
692 PerlIO_get_bufsiz||5.007003|
693 PerlIO_get_cnt||5.007003|
694 PerlIO_get_ptr||5.007003|
695 PerlIO_read||5.007003|
696 PerlIO_seek||5.007003|
697 PerlIO_set_cnt||5.007003|
698 PerlIO_set_ptrcnt||5.007003|
699 PerlIO_setlinebuf||5.007003|
700 PerlIO_stderr||5.007003|
701 PerlIO_stdin||5.007003|
702 PerlIO_stdout||5.007003|
703 PerlIO_tell||5.007003|
704 PerlIO_unread||5.007003|
705 PerlIO_write||5.007003|
706 Perl_signbit||5.009005|n
707 PoisonFree|5.009004||p
708 PoisonNew|5.009004||p
709 PoisonWith|5.009004||p
718 SAVE_DEFSV|5.004050||p
721 START_EXTERN_C|5.005000||p
722 START_MY_CXT|5.007003||p
725 STR_WITH_LEN|5.009003||p
727 SV_CONST_RETURN|5.009003||p
728 SV_COW_DROP_PV|5.008001||p
729 SV_COW_SHARED_HASH_KEYS|5.009005||p
730 SV_GMAGIC|5.007002||p
731 SV_HAS_TRAILING_NUL|5.009004||p
732 SV_IMMEDIATE_UNREF|5.007001||p
733 SV_MUTABLE_RETURN|5.009003||p
734 SV_NOSTEAL|5.009002||p
735 SV_SMAGIC|5.009003||p
736 SV_UTF8_NO_ENCODING|5.008001||p
754 SvGETMAGIC|5.004050||p
757 SvIOK_notUV||5.006000|
759 SvIOK_only_UV||5.006000|
765 SvIV_nomg|5.009001||p
769 SvIsCOW_shared_hash||5.008003|
774 SvMAGIC_set|5.009003||p
790 SvPOK_only_UTF8||5.006000|
795 SvPVX_const|5.009003||p
796 SvPVX_mutable|5.009003||p
798 SvPV_const|5.009003||p
799 SvPV_flags_const_nolen|5.009003||p
800 SvPV_flags_const|5.009003||p
801 SvPV_flags_mutable|5.009003||p
802 SvPV_flags|5.007002||p
803 SvPV_force_flags_mutable|5.009003||p
804 SvPV_force_flags_nolen|5.009003||p
805 SvPV_force_flags|5.007002||p
806 SvPV_force_mutable|5.009003||p
807 SvPV_force_nolen|5.009003||p
808 SvPV_force_nomg_nolen|5.009003||p
809 SvPV_force_nomg|5.007002||p
811 SvPV_mutable|5.009003||p
812 SvPV_nolen_const|5.009003||p
813 SvPV_nolen|5.006000||p
814 SvPV_nomg_const_nolen|5.009003||p
815 SvPV_nomg_const|5.009003||p
816 SvPV_nomg|5.007002||p
818 SvPVbyte_force||5.009002|
819 SvPVbyte_nolen||5.006000|
820 SvPVbytex_force||5.006000|
823 SvPVutf8_force||5.006000|
824 SvPVutf8_nolen||5.006000|
825 SvPVutf8x_force||5.006000|
831 SvREFCNT_inc_NN|5.009004||p
832 SvREFCNT_inc_simple_NN|5.009004||p
833 SvREFCNT_inc_simple_void_NN|5.009004||p
834 SvREFCNT_inc_simple_void|5.009004||p
835 SvREFCNT_inc_simple|5.009004||p
836 SvREFCNT_inc_void_NN|5.009004||p
837 SvREFCNT_inc_void|5.009004||p
848 SvSHARED_HASH|5.009003||p
850 SvSTASH_set|5.009003||p
852 SvSetMagicSV_nosteal||5.004000|
853 SvSetMagicSV||5.004000|
854 SvSetSV_nosteal||5.004000|
856 SvTAINTED_off||5.004000|
857 SvTAINTED_on||5.004000|
863 SvUOK|5.007001|5.006000|p
865 SvUTF8_off||5.006000|
870 SvUV_nomg|5.009001||p
875 SvVSTRING_mg|5.009004||p
878 UTF8_MAXBYTES|5.009002||p
886 WARN_AMBIGUOUS|5.006000||p
887 WARN_ASSERTIONS|5.009005||p
888 WARN_BAREWORD|5.006000||p
889 WARN_CLOSED|5.006000||p
890 WARN_CLOSURE|5.006000||p
891 WARN_DEBUGGING|5.006000||p
892 WARN_DEPRECATED|5.006000||p
893 WARN_DIGIT|5.006000||p
894 WARN_EXEC|5.006000||p
895 WARN_EXITING|5.006000||p
896 WARN_GLOB|5.006000||p
897 WARN_INPLACE|5.006000||p
898 WARN_INTERNAL|5.006000||p
900 WARN_LAYER|5.008000||p
901 WARN_MALLOC|5.006000||p
902 WARN_MISC|5.006000||p
903 WARN_NEWLINE|5.006000||p
904 WARN_NUMERIC|5.006000||p
905 WARN_ONCE|5.006000||p
906 WARN_OVERFLOW|5.006000||p
907 WARN_PACK|5.006000||p
908 WARN_PARENTHESIS|5.006000||p
909 WARN_PIPE|5.006000||p
910 WARN_PORTABLE|5.006000||p
911 WARN_PRECEDENCE|5.006000||p
912 WARN_PRINTF|5.006000||p
913 WARN_PROTOTYPE|5.006000||p
915 WARN_RECURSION|5.006000||p
916 WARN_REDEFINE|5.006000||p
917 WARN_REGEXP|5.006000||p
918 WARN_RESERVED|5.006000||p
919 WARN_SEMICOLON|5.006000||p
920 WARN_SEVERE|5.006000||p
921 WARN_SIGNAL|5.006000||p
922 WARN_SUBSTR|5.006000||p
923 WARN_SYNTAX|5.006000||p
924 WARN_TAINT|5.006000||p
925 WARN_THREADS|5.008000||p
926 WARN_UNINITIALIZED|5.006000||p
927 WARN_UNOPENED|5.006000||p
928 WARN_UNPACK|5.006000||p
929 WARN_UNTIE|5.006000||p
930 WARN_UTF8|5.006000||p
931 WARN_VOID|5.006000||p
932 XCPT_CATCH|5.009002||p
933 XCPT_RETHROW|5.009002||p
934 XCPT_TRY_END|5.009002||p
935 XCPT_TRY_START|5.009002||p
937 XPUSHmortal|5.009002||p
948 XSRETURN_UV|5.008001||p
958 XS_VERSION_BOOTCHECK|||
960 XSprePUSH|5.006000||p
986 apply_attrs_string||5.006001|
989 atfork_lock||5.007003|n
990 atfork_unlock||5.007003|n
991 av_arylen_p||5.009003|
993 av_create_and_push||5.009005|
994 av_create_and_unshift_one||5.009005|
1014 block_gimme||5.004000|
1018 boot_core_UNIVERSAL|||
1020 boot_core_xsutils|||
1021 bytes_from_utf8||5.007001|
1023 bytes_to_utf8||5.006001|
1024 call_argv|5.006000||p
1025 call_atexit||5.006000|
1026 call_list||5.004000|
1027 call_method|5.006000||p
1034 cast_ulong||5.006000|
1036 check_type_and_open|||
1091 clear_placeholders|||
1096 create_eval_scope|||
1097 croak_nocontext|||vn
1099 csighandler||5.009003|n
1101 custom_op_desc||5.007003|
1102 custom_op_name||5.007003|
1106 cv_const_sv||5.004000|
1116 dMULTICALL||5.009003|
1117 dMY_CXT_SV|5.007003||p
1127 dUNDERBAR|5.009002||p
1138 debprofdump||5.005000|
1140 debstackptrs||5.007003|
1142 debug_start_match|||
1145 delete_eval_scope|||
1149 despatch_signals||5.007001|
1160 do_binmode||5.004050|
1169 do_gv_dump||5.006000|
1170 do_gvgv_dump||5.006000|
1171 do_hv_dump||5.006000|
1176 do_magic_dump||5.006000|
1180 do_op_dump||5.006000|
1186 do_pmop_dump||5.006000|
1197 do_sv_dump||5.006000|
1200 do_trans_complex_utf8|||
1202 do_trans_count_utf8|||
1204 do_trans_simple_utf8|||
1216 doing_taint||5.008001|n
1231 dump_eval||5.006000|
1234 dump_form||5.006000|
1235 dump_indent||5.006000|v
1237 dump_packsubs||5.006000|
1240 dump_trie_interim_list|||
1241 dump_trie_interim_table|||
1243 dump_vindent||5.006000|
1252 fbm_compile||5.005000|
1253 fbm_instr||5.005000|
1255 feature_is_enabled|||
1260 find_and_forget_pmops|||
1261 find_array_subscript|||
1264 find_hash_subscript|||
1266 find_runcv||5.008001|
1267 find_rundefsvoffset||5.009002|
1282 fprintf_nocontext|||vn
1283 free_global_struct|||
1284 free_tied_hv_pool|||
1286 gen_constant_list|||
1289 get_context||5.006000|n
1290 get_cvn_flags||5.009005|
1299 get_op_descs||5.005000|
1300 get_op_names||5.005000|
1302 get_ppaddr||5.006000|
1306 getcwd_sv||5.007002|
1315 grok_bin|5.007003||p
1316 grok_hex|5.007003||p
1317 grok_number|5.007002||p
1318 grok_numeric_radix|5.007002||p
1319 grok_oct|5.007003||p
1325 gv_autoload4||5.004000|
1327 gv_const_sv||5.009003|
1329 gv_efullname3||5.004000|
1330 gv_efullname4||5.006001|
1333 gv_fetchfile_flags||5.009005|
1335 gv_fetchmeth_autoload||5.007003|
1336 gv_fetchmethod_autoload||5.004000|
1339 gv_fetchpvn_flags||5.009002|
1341 gv_fetchsv||5.009002|
1342 gv_fullname3||5.004000|
1343 gv_fullname4||5.006001|
1345 gv_handler||5.007001|
1348 gv_name_set||5.009004|
1349 gv_stashpvn|5.004000||p
1350 gv_stashpvs||5.009003|
1357 hv_assert||5.009005|
1359 hv_backreferences_p|||
1360 hv_clear_placeholders||5.009001|
1363 hv_delayfree_ent||5.004000|
1365 hv_delete_ent||5.004000|
1367 hv_eiter_p||5.009003|
1368 hv_eiter_set||5.009003|
1369 hv_exists_ent||5.004000|
1372 hv_fetch_ent||5.004000|
1373 hv_fetchs|5.009003||p
1375 hv_free_ent||5.004000|
1377 hv_iterkeysv||5.004000|
1379 hv_iternext_flags||5.008000|
1384 hv_ksplit||5.004000|
1386 hv_magic_uvar_xkey|||
1388 hv_name_set||5.009003|
1390 hv_placeholders_get||5.009003|
1391 hv_placeholders_p||5.009003|
1392 hv_placeholders_set||5.009003|
1393 hv_riter_p||5.009003|
1394 hv_riter_set||5.009003|
1395 hv_scalar||5.009001|
1396 hv_store_ent||5.004000|
1397 hv_store_flags||5.008000|
1398 hv_stores|5.009004||p
1401 ibcmp_locale||5.004000|
1402 ibcmp_utf8||5.007003|
1406 incpush_if_exists|||
1409 init_argv_symbols|||
1411 init_global_struct|||
1412 init_i18nl10n||5.006000|
1413 init_i18nl14n||5.006000|
1418 init_postdump_symbols|||
1419 init_predump_symbols|||
1420 init_stacks||5.005000|
1437 is_handle_constructor|||n
1438 is_list_assignment|||
1439 is_lvalue_sub||5.007001|
1440 is_uni_alnum_lc||5.006000|
1441 is_uni_alnumc_lc||5.006000|
1442 is_uni_alnumc||5.006000|
1443 is_uni_alnum||5.006000|
1444 is_uni_alpha_lc||5.006000|
1445 is_uni_alpha||5.006000|
1446 is_uni_ascii_lc||5.006000|
1447 is_uni_ascii||5.006000|
1448 is_uni_cntrl_lc||5.006000|
1449 is_uni_cntrl||5.006000|
1450 is_uni_digit_lc||5.006000|
1451 is_uni_digit||5.006000|
1452 is_uni_graph_lc||5.006000|
1453 is_uni_graph||5.006000|
1454 is_uni_idfirst_lc||5.006000|
1455 is_uni_idfirst||5.006000|
1456 is_uni_lower_lc||5.006000|
1457 is_uni_lower||5.006000|
1458 is_uni_print_lc||5.006000|
1459 is_uni_print||5.006000|
1460 is_uni_punct_lc||5.006000|
1461 is_uni_punct||5.006000|
1462 is_uni_space_lc||5.006000|
1463 is_uni_space||5.006000|
1464 is_uni_upper_lc||5.006000|
1465 is_uni_upper||5.006000|
1466 is_uni_xdigit_lc||5.006000|
1467 is_uni_xdigit||5.006000|
1468 is_utf8_alnumc||5.006000|
1469 is_utf8_alnum||5.006000|
1470 is_utf8_alpha||5.006000|
1471 is_utf8_ascii||5.006000|
1472 is_utf8_char_slow|||n
1473 is_utf8_char||5.006000|
1474 is_utf8_cntrl||5.006000|
1476 is_utf8_digit||5.006000|
1477 is_utf8_graph||5.006000|
1478 is_utf8_idcont||5.008000|
1479 is_utf8_idfirst||5.006000|
1480 is_utf8_lower||5.006000|
1481 is_utf8_mark||5.006000|
1482 is_utf8_print||5.006000|
1483 is_utf8_punct||5.006000|
1484 is_utf8_space||5.006000|
1485 is_utf8_string_loclen||5.009003|
1486 is_utf8_string_loc||5.008001|
1487 is_utf8_string||5.006001|
1488 is_utf8_upper||5.006000|
1489 is_utf8_xdigit||5.006000|
1502 load_module_nocontext|||vn
1503 load_module|5.006000||pv
1506 looks_like_number|||
1519 magic_clear_all_env|||
1524 magic_dump||5.006000|
1526 magic_freearylen_p|||
1540 magic_killbackrefs|||
1545 magic_regdata_cnt|||
1546 magic_regdatum_get|||
1547 magic_regdatum_set|||
1549 magic_set_all_env|||
1553 magic_setcollxfrm|||
1577 make_trie_failtable|||
1582 matcher_matches_sv|||
1598 mg_length||5.005000|
1603 mini_mktime||5.007002|
1605 mode_from_discipline|||
1611 mro_get_linear_isa_c3||5.009005|
1612 mro_get_linear_isa_dfs||5.009005|
1613 mro_get_linear_isa||5.009005|
1614 mro_isa_changed_in|||
1617 mro_method_changed_in||5.009005|
1638 my_failure_exit||5.004000|
1639 my_fflush_all||5.006000|
1662 my_memcmp||5.004000|n
1665 my_pclose||5.004000|
1666 my_popen_list||5.007001|
1669 my_snprintf|5.009004||pvn
1670 my_socketpair||5.007003|n
1671 my_sprintf||5.009003|vn
1673 my_strftime||5.007002|
1674 my_strlcat|5.009004||pn
1675 my_strlcpy|5.009004||pn
1679 my_vsnprintf||5.009004|n
1682 newANONATTRSUB||5.006000|
1687 newATTRSUB||5.006000|
1692 newCONSTSUB|5.004050||p
1697 newGIVENOP||5.009003|
1721 newRV_inc|5.004000||p
1722 newRV_noinc|5.004000||p
1729 newSV_type||5.009005|
1733 newSVpvf_nocontext|||vn
1734 newSVpvf||5.004000|v
1735 newSVpvn_share|5.007001||p
1736 newSVpvn|5.004050||p
1737 newSVpvs_share||5.009003|
1738 newSVpvs|5.009003||p
1746 newWHENOP||5.009003|
1747 newWHILEOP||5.009003|
1748 newXS_flags||5.009004|
1749 newXSproto||5.006000|
1751 new_collate||5.006000|
1753 new_ctype||5.006000|
1756 new_numeric||5.006000|
1757 new_stackinfo||5.005000|
1758 new_version||5.009000|
1759 new_warnings_bitfield|||
1764 no_bareword_allowed|||
1768 nothreadhook||5.008000|
1784 op_refcnt_lock||5.009002|
1785 op_refcnt_unlock||5.009002|
1788 pMY_CXT_|5.007003||p
1792 packWARN|5.007003||p
1802 pad_compname_type|||
1805 pad_fixup_inner_anons|||
1818 parse_unicode_opts|||
1821 path_is_absolute|||n
1823 pending_Slabs_to_ro|||
1824 perl_alloc_using|||n
1826 perl_clone_using|||n
1829 perl_destruct||5.007003|n
1831 perl_parse||5.006000|n
1836 pmop_dump||5.006000|
1847 printf_nocontext|||vn
1848 process_special_blocks|||
1849 ptr_table_clear||5.009005|
1850 ptr_table_fetch||5.009005|
1852 ptr_table_free||5.009005|
1853 ptr_table_new||5.009005|
1854 ptr_table_split||5.009005|
1855 ptr_table_store||5.009005|
1858 pv_display||5.006000|
1859 pv_escape||5.009004|
1860 pv_pretty||5.009004|
1861 pv_uni_display||5.007003|
1864 re_compile||5.009005|
1867 re_intuit_start||5.009005|
1868 re_intuit_string||5.006000|
1869 readpipe_override|||
1873 reentrant_retry|||vn
1875 ref_array_or_hash|||
1876 refcounted_he_chain_2hv|||
1877 refcounted_he_fetch|||
1878 refcounted_he_free|||
1879 refcounted_he_new|||
1880 refcounted_he_value|||
1884 reg_check_named_buff_matched|||
1885 reg_named_buff_all||5.009005|
1886 reg_named_buff_exists||5.009005|
1887 reg_named_buff_fetch||5.009005|
1888 reg_named_buff_firstkey||5.009005|
1889 reg_named_buff_iter|||
1890 reg_named_buff_nextkey||5.009005|
1891 reg_named_buff_scalar||5.009005|
1895 reg_numbered_buff_fetch|||
1896 reg_numbered_buff_length|||
1897 reg_numbered_buff_store|||
1902 reg_stringify||5.009005|
1907 regclass_swash||5.009004|
1915 regexec_flags||5.005000|
1916 regfree_internal||5.009005|
1921 reginitcolors||5.006000|
1938 require_pv||5.006000|
1944 rsignal_state||5.004000|
1948 runops_debug||5.005000|
1949 runops_standard||5.005000|
1954 safesyscalloc||5.006000|n
1955 safesysfree||5.006000|n
1956 safesysmalloc||5.006000|n
1957 safesysrealloc||5.006000|n
1962 save_aelem||5.004050|
1963 save_alloc||5.006000|
1966 save_bool||5.008001|
1969 save_destructor_x||5.006000|
1970 save_destructor||5.006000|
1974 save_generic_pvref||5.006001|
1975 save_generic_svref||5.005030|
1979 save_helem||5.004050|
1980 save_hints||5.005000|
1989 save_mortalizesv||5.007001|
1992 save_padsv||5.007001|
1994 save_re_context||5.006000|
1997 save_set_svflags||5.009000|
1998 save_shared_pvref||5.007003|
2001 save_vptr||5.006000|
2005 savesharedpvn||5.009005|
2006 savesharedpv||5.007003|
2007 savestack_grow_cnt||5.008001|
2031 scan_version||5.009001|
2032 scan_vstring||5.009005|
2035 screaminstr||5.005000|
2040 set_context||5.006000|n
2042 set_numeric_local||5.006000|
2043 set_numeric_radix||5.006000|
2044 set_numeric_standard||5.006000|
2048 share_hek||5.004000|
2060 sortsv_flags||5.009003|
2062 space_join_names_mortal|||
2067 start_subparse||5.004000|
2068 stashpv_hvname_match||5.009005|
2076 str_to_version||5.006000|
2089 sv_2iuv_non_preserve|||
2090 sv_2iv_flags||5.009001|
2094 sv_2pv_flags|5.007002||p
2095 sv_2pv_nolen|5.006000||p
2096 sv_2pvbyte_nolen|5.006000||p
2097 sv_2pvbyte|5.006000||p
2098 sv_2pvutf8_nolen||5.006000|
2099 sv_2pvutf8||5.006000|
2101 sv_2uv_flags||5.009001|
2107 sv_cat_decode||5.008001|
2108 sv_catpv_mg|5.004050||p
2109 sv_catpvf_mg_nocontext|||pvn
2110 sv_catpvf_mg|5.006000|5.004000|pv
2111 sv_catpvf_nocontext|||vn
2112 sv_catpvf||5.004000|v
2113 sv_catpvn_flags||5.007002|
2114 sv_catpvn_mg|5.004050||p
2115 sv_catpvn_nomg|5.007002||p
2117 sv_catpvs|5.009003||p
2119 sv_catsv_flags||5.007002|
2120 sv_catsv_mg|5.004050||p
2121 sv_catsv_nomg|5.007002||p
2129 sv_cmp_locale||5.004000|
2132 sv_compile_2op||5.008001|
2133 sv_copypv||5.007003|
2136 sv_derived_from||5.004000|
2142 sv_force_normal_flags||5.007001|
2143 sv_force_normal||5.006000|
2156 sv_len_utf8||5.006000|
2158 sv_magic_portable|5.009005|5.004000|p
2159 sv_magicext||5.007003|
2165 sv_nolocking||5.007003|
2166 sv_nosharing||5.007003|
2170 sv_pos_b2u_midway|||
2171 sv_pos_b2u||5.006000|
2172 sv_pos_u2b_cached|||
2173 sv_pos_u2b_forwards|||n
2174 sv_pos_u2b_midway|||n
2175 sv_pos_u2b||5.006000|
2176 sv_pvbyten_force||5.006000|
2177 sv_pvbyten||5.006000|
2178 sv_pvbyte||5.006000|
2179 sv_pvn_force_flags|5.007002||p
2181 sv_pvn_nomg|5.007003||p
2183 sv_pvutf8n_force||5.006000|
2184 sv_pvutf8n||5.006000|
2185 sv_pvutf8||5.006000|
2187 sv_recode_to_utf8||5.007003|
2193 sv_rvweaken||5.006000|
2194 sv_setiv_mg|5.004050||p
2196 sv_setnv_mg|5.006000||p
2198 sv_setpv_mg|5.004050||p
2199 sv_setpvf_mg_nocontext|||pvn
2200 sv_setpvf_mg|5.006000|5.004000|pv
2201 sv_setpvf_nocontext|||vn
2202 sv_setpvf||5.004000|v
2203 sv_setpviv_mg||5.008001|
2204 sv_setpviv||5.008001|
2205 sv_setpvn_mg|5.004050||p
2207 sv_setpvs|5.009004||p
2213 sv_setref_uv||5.007001|
2215 sv_setsv_flags||5.007002|
2216 sv_setsv_mg|5.004050||p
2217 sv_setsv_nomg|5.007002||p
2219 sv_setuv_mg|5.004050||p
2220 sv_setuv|5.004000||p
2221 sv_tainted||5.004000|
2225 sv_uni_display||5.007003|
2227 sv_unref_flags||5.007001|
2229 sv_untaint||5.004000|
2231 sv_usepvn_flags||5.009004|
2232 sv_usepvn_mg|5.004050||p
2234 sv_utf8_decode||5.006000|
2235 sv_utf8_downgrade||5.006000|
2236 sv_utf8_encode||5.006000|
2237 sv_utf8_upgrade_flags||5.007002|
2238 sv_utf8_upgrade||5.007001|
2240 sv_vcatpvf_mg|5.006000|5.004000|p
2241 sv_vcatpvfn||5.004000|
2242 sv_vcatpvf|5.006000|5.004000|p
2243 sv_vsetpvf_mg|5.006000|5.004000|p
2244 sv_vsetpvfn||5.004000|
2245 sv_vsetpvf|5.006000|5.004000|p
2250 swash_fetch||5.007002|
2252 swash_init||5.006000|
2258 tmps_grow||5.006000|
2262 to_uni_fold||5.007003|
2263 to_uni_lower_lc||5.006000|
2264 to_uni_lower||5.007003|
2265 to_uni_title_lc||5.006000|
2266 to_uni_title||5.007003|
2267 to_uni_upper_lc||5.006000|
2268 to_uni_upper||5.007003|
2269 to_utf8_case||5.007003|
2270 to_utf8_fold||5.007003|
2271 to_utf8_lower||5.007003|
2273 to_utf8_title||5.007003|
2274 to_utf8_upper||5.007003|
2280 too_few_arguments|||
2281 too_many_arguments|||
2285 unpack_str||5.007003|
2286 unpackstring||5.008001|
2287 unshare_hek_or_pvn|||
2289 unsharepvn||5.004000|
2290 unwind_handler_stack|||
2291 update_debugger_info|||
2292 upg_version||5.009005|
2294 utf16_to_utf8_reversed||5.006001|
2295 utf16_to_utf8||5.006001|
2296 utf8_distance||5.006000|
2298 utf8_length||5.007001|
2299 utf8_mg_pos_cache_update|||
2300 utf8_to_bytes||5.006001|
2301 utf8_to_uvchr||5.007001|
2302 utf8_to_uvuni||5.007001|
2304 utf8n_to_uvuni||5.007001|
2306 uvchr_to_utf8_flags||5.007003|
2308 uvuni_to_utf8_flags||5.007003|
2309 uvuni_to_utf8||5.007001|
2316 vdie_croak_common|||
2322 vload_module|5.006000||p
2324 vnewSVpvf|5.006000|5.004000|p
2327 vstringify||5.009000|
2333 warner_nocontext|||vn
2334 warner|5.006000|5.004000|pv
2354 if (exists $opt{'list-unsupported'}) {
2356 for $f (sort { lc $a cmp lc $b } keys %API) {
2357 next unless $API{$f}{todo};
2358 print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
2363 # Scan for possible replacement candidates
2365 my(%replace, %need, %hints, %warnings, %depends);
2367 my($hint, $define, $function);
2373 / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*)
2374 | "[^"\\]*(?:\\.[^"\\]*)*"
2375 | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx;
2376 grep { exists $API{$_} } $code =~ /(\w+)/mg;
2381 my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings;
2382 if (m{^\s*\*\s(.*?)\s*$}) {
2383 for (@{$hint->[1]}) {
2384 $h->{$_} ||= ''; # suppress warning with older perls
2388 else { undef $hint }
2391 $hint = [$1, [split /,?\s+/, $2]]
2392 if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$};
2395 if ($define->[1] =~ /\\$/) {
2399 if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) {
2400 my @n = find_api($define->[1]);
2401 push @{$depends{$define->[0]}}, @n if @n
2407 $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)};
2411 if (exists $API{$function->[0]}) {
2412 my @n = find_api($function->[1]);
2413 push @{$depends{$function->[0]}}, @n if @n
2418 $function->[1] .= $_;
2422 $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)};
2424 $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
2425 $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
2426 $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
2427 $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
2429 if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
2430 push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
2433 $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
2436 for (values %depends) {
2438 $_ = [sort grep !$s{$_}++, @$_];
2441 if (exists $opt{'api-info'}) {
2444 my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
2445 for $f (sort { lc $a cmp lc $b } keys %API) {
2446 next unless $f =~ /$match/;
2447 print "\n=== $f ===\n\n";
2449 if ($API{$f}{base} || $API{$f}{todo}) {
2450 my $base = format_version($API{$f}{base} || $API{$f}{todo});
2451 print "Supported at least starting from perl-$base.\n";
2454 if ($API{$f}{provided}) {
2455 my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003";
2456 print "Support by $ppport provided back to perl-$todo.\n";
2457 print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f};
2458 print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f};
2459 print "\n$hints{$f}" if exists $hints{$f};
2460 print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f};
2463 print "No portability information available.\n" unless $info;
2466 $count or print "Found no API matching '$opt{'api-info'}'.";
2471 if (exists $opt{'list-provided'}) {
2473 for $f (sort { lc $a cmp lc $b } keys %API) {
2474 next unless $API{$f}{provided};
2476 push @flags, 'explicit' if exists $need{$f};
2477 push @flags, 'depend' if exists $depends{$f};
2478 push @flags, 'hint' if exists $hints{$f};
2479 push @flags, 'warning' if exists $warnings{$f};
2480 my $flags = @flags ? ' ['.join(', ', @flags).']' : '';
2487 my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc );
2488 my $srcext = join '|', map { quotemeta $_ } @srcext;
2495 push @files, $_ unless $seen{$_}++;
2497 else { warn "'$_' is not a file.\n" }
2500 my @new = grep { -f } glob $_
2501 or warn "'$_' does not exist.\n";
2502 push @files, grep { !$seen{$_}++ } @new;
2509 File::Find::find(sub {
2510 $File::Find::name =~ /($srcext)$/i
2511 and push @files, $File::Find::name;
2515 @files = map { glob "*$_" } @srcext;
2519 if (!@ARGV || $opt{filter}) {
2521 my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
2523 my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
2524 push @{ $out ? \@out : \@in }, $_;
2526 if (@ARGV && @out) {
2527 warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
2532 die "No input files given!\n" unless @files;
2534 my(%files, %global, %revreplace);
2535 %revreplace = reverse %replace;
2537 my $patch_opened = 0;
2539 for $filename (@files) {
2540 unless (open IN, "<$filename") {
2541 warn "Unable to read from $filename: $!\n";
2545 info("Scanning $filename ...");
2547 my $c = do { local $/; <IN> };
2550 my %file = (orig => $c, changes => 0);
2552 # Temporarily remove C/XS comments and strings from the code
2556 ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]*
2557 | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* )
2559 | "[^"\\]*(?:\\.[^"\\]*)*"
2560 | '[^'\\]*(?:\\.[^'\\]*)*'
2561 | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) )
2562 }{ defined $2 and push @ccom, $2;
2563 defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex;
2565 $file{ccom} = \@ccom;
2567 $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m;
2571 for $func (keys %API) {
2573 $match .= "|$revreplace{$func}" if exists $revreplace{$func};
2574 if ($c =~ /\b(?:Perl_)?($match)\b/) {
2575 $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
2576 $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
2577 if (exists $API{$func}{provided}) {
2578 $file{uses_provided}{$func}++;
2579 if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
2580 $file{uses}{$func}++;
2581 my @deps = rec_depend($func);
2583 $file{uses_deps}{$func} = \@deps;
2585 $file{uses}{$_} = 0 unless exists $file{uses}{$_};
2588 for ($func, @deps) {
2589 $file{needs}{$_} = 'static' if exists $need{$_};
2593 if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
2594 if ($c =~ /\b$func\b/) {
2595 $file{uses_todo}{$func}++;
2601 while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
2602 if (exists $need{$2}) {
2603 $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
2605 else { warning("Possibly wrong #define $1 in $filename") }
2608 for (qw(uses needs uses_todo needed_global needed_static)) {
2609 for $func (keys %{$file{$_}}) {
2610 push @{$global{$_}{$func}}, $filename;
2614 $files{$filename} = \%file;
2617 # Globally resolve NEED_'s
2619 for $need (keys %{$global{needs}}) {
2620 if (@{$global{needs}{$need}} > 1) {
2621 my @targets = @{$global{needs}{$need}};
2622 my @t = grep $files{$_}{needed_global}{$need}, @targets;
2623 @targets = @t if @t;
2624 @t = grep /\.xs$/i, @targets;
2625 @targets = @t if @t;
2626 my $target = shift @targets;
2627 $files{$target}{needs}{$need} = 'global';
2628 for (@{$global{needs}{$need}}) {
2629 $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
2634 for $filename (@files) {
2635 exists $files{$filename} or next;
2637 info("=== Analyzing $filename ===");
2639 my %file = %{$files{$filename}};
2641 my $c = $file{code};
2644 for $func (sort keys %{$file{uses_Perl}}) {
2645 if ($API{$func}{varargs}) {
2646 unless ($API{$func}{nothxarg}) {
2647 my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
2648 { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
2650 warning("Doesn't pass interpreter argument aTHX to Perl_$func");
2651 $file{changes} += $changes;
2656 warning("Uses Perl_$func instead of $func");
2657 $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
2662 for $func (sort keys %{$file{uses_replace}}) {
2663 warning("Uses $func instead of $replace{$func}");
2664 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2667 for $func (sort keys %{$file{uses_provided}}) {
2668 if ($file{uses}{$func}) {
2669 if (exists $file{uses_deps}{$func}) {
2670 diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
2676 $warnings += hint($func);
2679 unless ($opt{quiet}) {
2680 for $func (sort keys %{$file{uses_todo}}) {
2681 print "*** WARNING: Uses $func, which may not be portable below perl ",
2682 format_version($API{$func}{todo}), ", even with '$ppport'\n";
2687 for $func (sort keys %{$file{needed_static}}) {
2689 if (not exists $file{uses}{$func}) {
2690 $message = "No need to define NEED_$func if $func is never used";
2692 elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
2693 $message = "No need to define NEED_$func when already needed globally";
2697 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
2701 for $func (sort keys %{$file{needed_global}}) {
2703 if (not exists $global{uses}{$func}) {
2704 $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
2706 elsif (exists $file{needs}{$func}) {
2707 if ($file{needs}{$func} eq 'extern') {
2708 $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
2710 elsif ($file{needs}{$func} eq 'static') {
2711 $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
2716 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
2720 $file{needs_inc_ppport} = keys %{$file{uses}};
2722 if ($file{needs_inc_ppport}) {
2725 for $func (sort keys %{$file{needs}}) {
2726 my $type = $file{needs}{$func};
2727 next if $type eq 'extern';
2728 my $suffix = $type eq 'global' ? '_GLOBAL' : '';
2729 unless (exists $file{"needed_$type"}{$func}) {
2730 if ($type eq 'global') {
2731 diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
2734 diag("File needs $func, adding static request");
2736 $pp .= "#define NEED_$func$suffix\n";
2740 if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
2745 unless ($file{has_inc_ppport}) {
2746 diag("Needs to include '$ppport'");
2747 $pp .= qq(#include "$ppport"\n)
2751 $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
2752 || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
2753 || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
2754 || ($c =~ s/^/$pp/);
2758 if ($file{has_inc_ppport}) {
2759 diag("No need to include '$ppport'");
2760 $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
2764 # put back in our C comments
2767 my @ccom = @{$file{ccom}};
2768 for $ix (0 .. $#ccom) {
2769 if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
2771 $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
2774 $c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
2779 my $s = $cppc != 1 ? 's' : '';
2780 warning("Uses $cppc C++ style comment$s, which is not portable");
2783 my $s = $warnings != 1 ? 's' : '';
2784 my $warn = $warnings ? " ($warnings warning$s)" : '';
2785 info("Analysis completed$warn");
2787 if ($file{changes}) {
2788 if (exists $opt{copy}) {
2789 my $newfile = "$filename$opt{copy}";
2791 error("'$newfile' already exists, refusing to write copy of '$filename'");
2795 if (open F, ">$newfile") {
2796 info("Writing copy of '$filename' with changes to '$newfile'");
2801 error("Cannot open '$newfile' for writing: $!");
2805 elsif (exists $opt{patch} || $opt{changes}) {
2806 if (exists $opt{patch}) {
2807 unless ($patch_opened) {
2808 if (open PATCH, ">$opt{patch}") {
2812 error("Cannot open '$opt{patch}' for writing: $!");
2818 mydiff(\*PATCH, $filename, $c);
2822 info("Suggested changes:");
2823 mydiff(\*STDOUT, $filename, $c);
2827 my $s = $file{changes} == 1 ? '' : 's';
2828 info("$file{changes} potentially required change$s detected");
2836 close PATCH if $patch_opened;
2841 sub try_use { eval "use @_;"; return $@ eq '' }
2846 my($file, $str) = @_;
2849 if (exists $opt{diff}) {
2850 $diff = run_diff($opt{diff}, $file, $str);
2853 if (!defined $diff and try_use('Text::Diff')) {
2854 $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
2855 $diff = <<HEADER . $diff;
2861 if (!defined $diff) {
2862 $diff = run_diff('diff -u', $file, $str);
2865 if (!defined $diff) {
2866 $diff = run_diff('diff', $file, $str);
2869 if (!defined $diff) {
2870 error("Cannot generate a diff. Please install Text::Diff or use --copy.");
2879 my($prog, $file, $str) = @_;
2880 my $tmp = 'dppptemp';
2885 while (-e "$tmp.$suf") { $suf++ }
2888 if (open F, ">$tmp") {
2892 if (open F, "$prog $file $tmp |") {
2894 s/\Q$tmp\E/$file.patched/;
2905 error("Cannot open '$tmp' for writing: $!");
2913 my($func, $seen) = @_;
2914 return () unless exists $depends{$func};
2915 $seen = {%{$seen||{}}};
2916 return () if $seen->{$func}++;
2918 grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}};
2925 if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
2926 return ($1, $2, $3);
2928 elsif ($ver !~ /^\d+\.[\d_]+$/) {
2929 die "cannot parse version '$ver'\n";
2933 $ver =~ s/$/000000/;
2935 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2940 if ($r < 5 || ($r == 5 && $v < 6)) {
2942 die "cannot parse version '$ver'\n";
2946 return ($r, $v, $s);
2953 $ver =~ s/$/000000/;
2954 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2959 if ($r < 5 || ($r == 5 && $v < 6)) {
2961 die "invalid version '$ver'\n";
2965 $ver = sprintf "%d.%03d", $r, $v;
2966 $s > 0 and $ver .= sprintf "_%02d", $s;
2971 return sprintf "%d.%d.%d", $r, $v, $s;
2976 $opt{quiet} and return;
2982 $opt{quiet} and return;
2983 $opt{diag} and print @_, "\n";
2988 $opt{quiet} and return;
2989 print "*** ", @_, "\n";
2994 print "*** ERROR: ", @_, "\n";
3001 $opt{quiet} and return;
3004 if (exists $warnings{$func} && !$given_warnings{$func}++) {
3005 my $warn = $warnings{$func};
3006 $warn =~ s!^!*** !mg;
3007 print "*** WARNING: $func\n", $warn;
3010 if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) {
3011 my $hint = $hints{$func};
3013 print " --- hint for $func ---\n", $hint;
3020 my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
3021 my %M = ( 'I' => '*' );
3022 $usage =~ s/^\s*perl\s+\S+/$^X $0/;
3023 $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
3029 See perldoc $0 for details.
3038 my $self = do { local(@ARGV,$/)=($0); <> };
3039 my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms;
3040 $copy =~ s/^(?=\S+)/ /gms;
3041 $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms;
3042 $self =~ s/^SKIP.*(?=^__DATA__)/SKIP
3043 if (\@ARGV && \$ARGV[0] eq '--unstrip') {
3044 eval { require Devel::PPPort };
3045 \$@ and die "Cannot require Devel::PPPort, please install.\\n";
3046 if (\$Devel::PPPort::VERSION < $VERSION) {
3047 die "$0 was originally generated with Devel::PPPort $VERSION.\\n"
3048 . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n"
3049 . "Please install a newer version, or --unstrip will not work.\\n";
3051 Devel::PPPort::WriteFile(\$0);
3056 Sorry, but this is a stripped version of \$0.
3058 To be able to use its original script and doc functionality,
3059 please try to regenerate this file using:
3065 my($pl, $c) = $self =~ /(.*^__DATA__)(.*)/ms;
3067 / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*)
3068 | ( "[^"\\]*(?:\\.[^"\\]*)*"
3069 | '[^'\\]*(?:\\.[^'\\]*)*' )
3070 | ($HS+) }{ defined $2 ? ' ' : ($1 || '') }gsex;
3073 $c =~ s!^\s*#\s*!#!mg;
3076 open OUT, ">$0" or die "cannot strip $0: $!\n";
3077 print OUT "$pl$c\n";
3085 #ifndef _P_P_PORTABILITY_H_
3086 #define _P_P_PORTABILITY_H_
3088 #ifndef DPPP_NAMESPACE
3089 # define DPPP_NAMESPACE DPPP_
3092 #define DPPP_CAT2(x,y) CAT2(x,y)
3093 #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
3095 #ifndef PERL_REVISION
3096 # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
3097 # define PERL_PATCHLEVEL_H_IMPLICIT
3098 # include <patchlevel.h>
3100 # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
3101 # include <could_not_find_Perl_patchlevel.h>
3103 # ifndef PERL_REVISION
3104 # define PERL_REVISION (5)
3106 # define PERL_VERSION PATCHLEVEL
3107 # define PERL_SUBVERSION SUBVERSION
3108 /* Replace PERL_PATCHLEVEL with PERL_VERSION */
3113 #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10))
3114 #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION))
3116 /* It is very unlikely that anyone will try to use this with Perl 6
3117 (or greater), but who knows.
3119 #if PERL_REVISION != 5
3120 # error ppport.h only works with Perl version 5
3121 #endif /* PERL_REVISION != 5 */
3124 # include <limits.h>
3127 #ifndef PERL_UCHAR_MIN
3128 # define PERL_UCHAR_MIN ((unsigned char)0)
3131 #ifndef PERL_UCHAR_MAX
3133 # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
3136 # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
3138 # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
3143 #ifndef PERL_USHORT_MIN
3144 # define PERL_USHORT_MIN ((unsigned short)0)
3147 #ifndef PERL_USHORT_MAX
3149 # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
3152 # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
3155 # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
3157 # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
3163 #ifndef PERL_SHORT_MAX
3165 # define PERL_SHORT_MAX ((short)SHORT_MAX)
3167 # ifdef MAXSHORT /* Often used in <values.h> */
3168 # define PERL_SHORT_MAX ((short)MAXSHORT)
3171 # define PERL_SHORT_MAX ((short)SHRT_MAX)
3173 # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
3179 #ifndef PERL_SHORT_MIN
3181 # define PERL_SHORT_MIN ((short)SHORT_MIN)
3184 # define PERL_SHORT_MIN ((short)MINSHORT)
3187 # define PERL_SHORT_MIN ((short)SHRT_MIN)
3189 # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
3195 #ifndef PERL_UINT_MAX
3197 # define PERL_UINT_MAX ((unsigned int)UINT_MAX)
3200 # define PERL_UINT_MAX ((unsigned int)MAXUINT)
3202 # define PERL_UINT_MAX (~(unsigned int)0)
3207 #ifndef PERL_UINT_MIN
3208 # define PERL_UINT_MIN ((unsigned int)0)
3211 #ifndef PERL_INT_MAX
3213 # define PERL_INT_MAX ((int)INT_MAX)
3215 # ifdef MAXINT /* Often used in <values.h> */
3216 # define PERL_INT_MAX ((int)MAXINT)
3218 # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
3223 #ifndef PERL_INT_MIN
3225 # define PERL_INT_MIN ((int)INT_MIN)
3228 # define PERL_INT_MIN ((int)MININT)
3230 # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
3235 #ifndef PERL_ULONG_MAX
3237 # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
3240 # define PERL_ULONG_MAX ((unsigned long)MAXULONG)
3242 # define PERL_ULONG_MAX (~(unsigned long)0)
3247 #ifndef PERL_ULONG_MIN
3248 # define PERL_ULONG_MIN ((unsigned long)0L)
3251 #ifndef PERL_LONG_MAX
3253 # define PERL_LONG_MAX ((long)LONG_MAX)
3256 # define PERL_LONG_MAX ((long)MAXLONG)
3258 # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
3263 #ifndef PERL_LONG_MIN
3265 # define PERL_LONG_MIN ((long)LONG_MIN)
3268 # define PERL_LONG_MIN ((long)MINLONG)
3270 # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
3275 #if defined(HAS_QUAD) && (defined(convex) || defined(uts))
3276 # ifndef PERL_UQUAD_MAX
3277 # ifdef ULONGLONG_MAX
3278 # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
3280 # ifdef MAXULONGLONG
3281 # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
3283 # define PERL_UQUAD_MAX (~(unsigned long long)0)
3288 # ifndef PERL_UQUAD_MIN
3289 # define PERL_UQUAD_MIN ((unsigned long long)0L)
3292 # ifndef PERL_QUAD_MAX
3293 # ifdef LONGLONG_MAX
3294 # define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
3297 # define PERL_QUAD_MAX ((long long)MAXLONGLONG)
3299 # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
3304 # ifndef PERL_QUAD_MIN
3305 # ifdef LONGLONG_MIN
3306 # define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
3309 # define PERL_QUAD_MIN ((long long)MINLONGLONG)
3311 # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
3317 /* This is based on code from 5.003 perl.h */
3325 # define IV_MIN PERL_INT_MIN
3329 # define IV_MAX PERL_INT_MAX
3333 # define UV_MIN PERL_UINT_MIN
3337 # define UV_MAX PERL_UINT_MAX
3342 # define IVSIZE INTSIZE
3347 # if defined(convex) || defined(uts)
3349 # define IVTYPE long long
3353 # define IV_MIN PERL_QUAD_MIN
3357 # define IV_MAX PERL_QUAD_MAX
3361 # define UV_MIN PERL_UQUAD_MIN
3365 # define UV_MAX PERL_UQUAD_MAX
3368 # ifdef LONGLONGSIZE
3370 # define IVSIZE LONGLONGSIZE
3376 # define IVTYPE long
3380 # define IV_MIN PERL_LONG_MIN
3384 # define IV_MAX PERL_LONG_MAX
3388 # define UV_MIN PERL_ULONG_MIN
3392 # define UV_MAX PERL_ULONG_MAX
3397 # define IVSIZE LONGSIZE
3407 #ifndef PERL_QUAD_MIN
3408 # define PERL_QUAD_MIN IV_MIN
3411 #ifndef PERL_QUAD_MAX
3412 # define PERL_QUAD_MAX IV_MAX
3415 #ifndef PERL_UQUAD_MIN
3416 # define PERL_UQUAD_MIN UV_MIN
3419 #ifndef PERL_UQUAD_MAX
3420 # define PERL_UQUAD_MAX UV_MAX
3425 # define IVTYPE long
3429 # define IV_MIN PERL_LONG_MIN
3433 # define IV_MAX PERL_LONG_MAX
3437 # define UV_MIN PERL_ULONG_MIN
3441 # define UV_MAX PERL_ULONG_MAX
3448 # define IVSIZE LONGSIZE
3450 # define IVSIZE 4 /* A bold guess, but the best we can make. */
3454 # define UVTYPE unsigned IVTYPE
3458 # define UVSIZE IVSIZE
3461 # define sv_setuv(sv, uv) \
3464 if (TeMpUv <= IV_MAX) \
3465 sv_setiv(sv, TeMpUv); \
3467 sv_setnv(sv, (double)TeMpUv); \
3471 # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
3474 # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
3478 # define SvUVX(sv) ((UV)SvIVX(sv))
3482 # define SvUVXx(sv) SvUVX(sv)
3486 # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
3490 # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))
3494 * Always use the SvUVx() macro instead of sv_uv().
3497 # define sv_uv(sv) SvUVx(sv)
3500 #if !defined(SvUOK) && defined(SvIOK_UV)
3501 # define SvUOK(sv) SvIOK_UV(sv)
3504 # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
3508 # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
3511 # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
3515 # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
3520 # define memNE(s1,s2,l) (memcmp(s1,s2,l))
3524 # define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
3529 # define memNE(s1,s2,l) (bcmp(s1,s2,l))
3533 # define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
3538 # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
3542 # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
3547 # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
3552 # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d)
3557 # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t))
3561 # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB)
3565 # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF)
3569 # define Poison(d,n,t) PoisonFree(d,n,t)
3572 # define Newx(v,n,t) New(0,v,n,t)
3576 # define Newxc(v,n,t,c) Newc(0,v,n,t,c)
3580 # define Newxz(v,n,t) Newz(0,v,n,t)
3583 #ifndef PERL_UNUSED_DECL
3584 # ifdef HASATTRIBUTE
3585 # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
3586 # define PERL_UNUSED_DECL
3588 # define PERL_UNUSED_DECL __attribute__((unused))
3591 # define PERL_UNUSED_DECL
3595 #ifndef PERL_UNUSED_ARG
3596 # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
3598 # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
3600 # define PERL_UNUSED_ARG(x) ((void)x)
3604 #ifndef PERL_UNUSED_VAR
3605 # define PERL_UNUSED_VAR(x) ((void)x)
3608 #ifndef PERL_UNUSED_CONTEXT
3609 # ifdef USE_ITHREADS
3610 # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl)
3612 # define PERL_UNUSED_CONTEXT
3616 # define NOOP /*EMPTY*/(void)0
3620 # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL
3624 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
3625 # define NVTYPE long double
3627 # define NVTYPE double
3634 # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
3636 # define INT2PTR(any,d) (any)(d)
3638 # if PTRSIZE == LONGSIZE
3639 # define PTRV unsigned long
3641 # define PTRV unsigned
3643 # define INT2PTR(any,d) (any)(PTRV)(d)
3646 # define NUM2PTR(any,d) (any)(PTRV)(d)
3647 # define PTR2IV(p) INT2PTR(IV,p)
3648 # define PTR2UV(p) INT2PTR(UV,p)
3649 # define PTR2NV(p) NUM2PTR(NV,p)
3651 # if PTRSIZE == LONGSIZE
3652 # define PTR2ul(p) (unsigned long)(p)
3654 # define PTR2ul(p) INT2PTR(unsigned long,p)
3657 #endif /* !INT2PTR */
3659 #undef START_EXTERN_C
3663 # define START_EXTERN_C extern "C" {
3664 # define END_EXTERN_C }
3665 # define EXTERN_C extern "C"
3667 # define START_EXTERN_C
3668 # define END_EXTERN_C
3669 # define EXTERN_C extern
3672 #if defined(PERL_GCC_PEDANTIC)
3673 # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
3674 # define PERL_GCC_BRACE_GROUPS_FORBIDDEN
3678 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
3679 # ifndef PERL_USE_GCC_BRACE_GROUPS
3680 # define PERL_USE_GCC_BRACE_GROUPS
3686 #ifdef PERL_USE_GCC_BRACE_GROUPS
3687 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
3690 # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
3691 # define STMT_START if (1)
3692 # define STMT_END else (void)0
3694 # define STMT_START do
3695 # define STMT_END while (0)
3699 # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
3702 /* DEFSV appears first in 5.004_56 */
3704 # define DEFSV GvSV(PL_defgv)
3708 # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
3711 /* Older perls (<=5.003) lack AvFILLp */
3713 # define AvFILLp AvFILL
3716 # define ERRSV get_sv("@",FALSE)
3719 # define newSVpvn(data,len) ((data) \
3720 ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
3724 /* Hint: gv_stashpvn
3725 * This function's backport doesn't support the length parameter, but
3726 * rather ignores it. Portability can only be ensured if the length
3727 * parameter is used for speed reasons, but the length can always be
3728 * correctly computed from the string argument.
3731 # define gv_stashpvn(str,len,create) gv_stashpv(str,create)
3736 # define get_cv perl_get_cv
3740 # define get_sv perl_get_sv
3744 # define get_av perl_get_av
3748 # define get_hv perl_get_hv
3753 # define dUNDERBAR dNOOP
3757 # define UNDERBAR DEFSV
3760 # define dAX I32 ax = MARK - PL_stack_base + 1
3764 # define dITEMS I32 items = SP - MARK
3767 # define dXSTARG SV * targ = sv_newmortal()
3770 # define dAXMARK I32 ax = POPMARK; \
3771 register SV ** const mark = PL_stack_base + ax++
3774 # define XSprePUSH (sp = PL_stack_base + ax - 1)
3777 #if (PERL_BCDVERSION < 0x5005000)
3779 # define XSRETURN(off) \
3781 PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
3786 # define PERL_ABS(x) ((x) < 0 ? -(x) : (x))
3794 #ifndef UTF8_MAXBYTES
3795 # define UTF8_MAXBYTES UTF8_MAXLEN
3798 # define PERL_HASH(hash,str,len) \
3800 const char *s_PeRlHaSh = str; \
3801 I32 i_PeRlHaSh = len; \
3802 U32 hash_PeRlHaSh = 0; \
3803 while (i_PeRlHaSh--) \
3804 hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
3805 (hash) = hash_PeRlHaSh; \
3809 #ifndef PERL_SIGNALS_UNSAFE_FLAG
3811 #define PERL_SIGNALS_UNSAFE_FLAG 0x0001
3813 #if (PERL_BCDVERSION < 0x5008000)
3814 # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG
3816 # define D_PPP_PERL_SIGNALS_INIT 0
3819 #if defined(NEED_PL_signals)
3820 static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT;
3821 #elif defined(NEED_PL_signals_GLOBAL)
3822 U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT;
3824 extern U32 DPPP_(my_PL_signals);
3826 #define PL_signals DPPP_(my_PL_signals)
3831 * Calling an op via PL_ppaddr requires passing a context argument
3832 * for threaded builds. Since the context argument is different for
3833 * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will
3834 * automatically be defined as the correct argument.
3837 #if (PERL_BCDVERSION <= 0x5005005)
3839 # define PL_ppaddr ppaddr
3840 # define PL_no_modify no_modify
3844 #if (PERL_BCDVERSION <= 0x5004005)
3846 # define PL_DBsignal DBsignal
3847 # define PL_DBsingle DBsingle
3848 # define PL_DBsub DBsub
3849 # define PL_DBtrace DBtrace
3851 # define PL_compiling compiling
3852 # define PL_copline copline
3853 # define PL_curcop curcop
3854 # define PL_curstash curstash
3855 # define PL_debstash debstash
3856 # define PL_defgv defgv
3857 # define PL_diehook diehook
3858 # define PL_dirty dirty
3859 # define PL_dowarn dowarn
3860 # define PL_errgv errgv
3861 # define PL_expect expect
3862 # define PL_hexdigit hexdigit
3863 # define PL_hints hints
3864 # define PL_laststatval laststatval
3866 # define PL_perl_destruct_level perl_destruct_level
3867 # define PL_perldb perldb
3868 # define PL_rsfp_filters rsfp_filters
3869 # define PL_rsfp rsfp
3870 # define PL_stack_base stack_base
3871 # define PL_stack_sp stack_sp
3872 # define PL_statcache statcache
3873 # define PL_stdingv stdingv
3874 # define PL_sv_arenaroot sv_arenaroot
3875 # define PL_sv_no sv_no
3876 # define PL_sv_undef sv_undef
3877 # define PL_sv_yes sv_yes
3878 # define PL_tainted tainted
3879 # define PL_tainting tainting
3883 /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters
3884 * Do not use this variable. It is internal to the perl parser
3885 * and may change or even be removed in the future. Note that
3886 * as of perl 5.9.5 you cannot assign to this variable anymore.
3889 /* TODO: cannot assign to these vars; is it worth fixing? */
3890 #if (PERL_BCDVERSION >= 0x5009005)
3891 # define PL_expect (PL_parser ? PL_parser->expect : 0)
3892 # define PL_copline (PL_parser ? PL_parser->copline : 0)
3893 # define PL_rsfp (PL_parser ? PL_parser->rsfp : (PerlIO *) 0)
3894 # define PL_rsfp_filters (PL_parser ? PL_parser->rsfp_filters : (AV *) 0)
3904 # define dTHXa(x) dNOOP
3922 #if (PERL_BCDVERSION < 0x5006000)
3925 # define aTHXR_ thr,
3933 # define aTHXR_ aTHX_
3937 # define dTHXoa(x) dTHXa(x)
3940 # define PUSHmortal PUSHs(sv_newmortal())
3944 # define mPUSHp(p,l) sv_setpvn_mg(PUSHmortal, (p), (l))
3948 # define mPUSHn(n) sv_setnv_mg(PUSHmortal, (NV)(n))
3952 # define mPUSHi(i) sv_setiv_mg(PUSHmortal, (IV)(i))
3956 # define mPUSHu(u) sv_setuv_mg(PUSHmortal, (UV)(u))
3959 # define XPUSHmortal XPUSHs(sv_newmortal())
3963 # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
3967 # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
3971 # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
3975 # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
3980 # define call_sv perl_call_sv
3984 # define call_pv perl_call_pv
3988 # define call_argv perl_call_argv
3992 # define call_method perl_call_method
3995 # define eval_sv perl_eval_sv
3997 #ifndef PERL_LOADMOD_DENY
3998 # define PERL_LOADMOD_DENY 0x1
4001 #ifndef PERL_LOADMOD_NOIMPORT
4002 # define PERL_LOADMOD_NOIMPORT 0x2
4005 #ifndef PERL_LOADMOD_IMPORT_OPS
4006 # define PERL_LOADMOD_IMPORT_OPS 0x4
4011 /* Replace perl_eval_pv with eval_pv */
4014 #if defined(NEED_eval_pv)
4015 static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
4018 extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
4024 #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
4025 #define Perl_eval_pv DPPP_(my_eval_pv)
4027 #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
4030 DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
4033 SV* sv = newSVpv(p, 0);
4036 eval_sv(sv, G_SCALAR);
4043 if (croak_on_error && SvTRUE(GvSV(errgv)))
4044 croak(SvPVx(GvSV(errgv), na));
4052 #ifndef vload_module
4053 #if defined(NEED_vload_module)
4054 static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args);
4057 extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args);
4061 # undef vload_module
4063 #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d)
4064 #define Perl_vload_module DPPP_(my_vload_module)
4066 #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL)
4069 DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args)
4075 OP * const modname = newSVOP(OP_CONST, 0, name);
4076 /* 5.005 has a somewhat hacky force_normal that doesn't croak on
4077 SvREADONLY() if PL_compling is true. Current perls take care in
4078 ck_require() to correctly turn off SvREADONLY before calling
4079 force_normal_flags(). This seems a better fix than fudging PL_compling
4081 SvREADONLY_off(((SVOP*)modname)->op_sv);
4082 modname->op_private |= OPpCONST_BARE;
4084 veop = newSVOP(OP_CONST, 0, ver);
4088 if (flags & PERL_LOADMOD_NOIMPORT) {
4089 imop = sawparens(newNULLLIST());
4091 else if (flags & PERL_LOADMOD_IMPORT_OPS) {
4092 imop = va_arg(*args, OP*);
4097 sv = va_arg(*args, SV*);
4099 imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv));
4100 sv = va_arg(*args, SV*);
4104 const line_t ocopline = PL_copline;
4105 COP * const ocurcop = PL_curcop;
4106 const int oexpect = PL_expect;
4108 #if (PERL_BCDVERSION >= 0x5004000)
4109 utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0),
4110 veop, modname, imop);
4112 utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(),
4115 PL_expect = oexpect;
4116 PL_copline = ocopline;
4117 PL_curcop = ocurcop;
4125 #if defined(NEED_load_module)
4126 static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...);
4129 extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...);
4135 #define load_module DPPP_(my_load_module)
4136 #define Perl_load_module DPPP_(my_load_module)
4138 #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL)
4141 DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...)
4144 va_start(args, ver);
4145 vload_module(flags, name, ver, &args);
4152 # define newRV_inc(sv) newRV(sv) /* Replace */
4156 #if defined(NEED_newRV_noinc)
4157 static SV * DPPP_(my_newRV_noinc)(SV *sv);
4160 extern SV * DPPP_(my_newRV_noinc)(SV *sv);
4166 #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
4167 #define Perl_newRV_noinc DPPP_(my_newRV_noinc)
4169 #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
4171 DPPP_(my_newRV_noinc)(SV *sv)
4173 SV *rv = (SV *)newRV(sv);
4180 /* Hint: newCONSTSUB
4181 * Returns a CV* as of perl-5.7.1. This return value is not supported
4185 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
4186 #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005)
4187 #if defined(NEED_newCONSTSUB)
4188 static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv);
4191 extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv);
4197 #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
4198 #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
4200 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
4203 DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv)
4205 U32 oldhints = PL_hints;
4206 HV *old_cop_stash = PL_curcop->cop_stash;
4207 HV *old_curstash = PL_curstash;
4208 line_t oldline = PL_curcop->cop_line;
4209 PL_curcop->cop_line = PL_copline;
4211 PL_hints &= ~HINT_BLOCK_SCOPE;
4213 PL_curstash = PL_curcop->cop_stash = stash;
4217 #if (PERL_BCDVERSION < 0x5003022)
4219 #elif (PERL_BCDVERSION == 0x5003022)
4221 #else /* 5.003_23 onwards */
4222 start_subparse(FALSE, 0),
4225 newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)),
4226 newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
4227 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
4230 PL_hints = oldhints;
4231 PL_curcop->cop_stash = old_cop_stash;
4232 PL_curstash = old_curstash;
4233 PL_curcop->cop_line = oldline;
4239 * Boilerplate macros for initializing and accessing interpreter-local
4240 * data from C. All statics in extensions should be reworked to use
4241 * this, if you want to make the extension thread-safe. See ext/re/re.xs
4242 * for an example of the use of these macros.
4244 * Code that uses these macros is responsible for the following:
4245 * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
4246 * 2. Declare a typedef named my_cxt_t that is a structure that contains
4247 * all the data that needs to be interpreter-local.
4248 * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
4249 * 4. Use the MY_CXT_INIT macro such that it is called exactly once
4250 * (typically put in the BOOT: section).
4251 * 5. Use the members of the my_cxt_t structure everywhere as
4253 * 6. Use the dMY_CXT macro (a declaration) in all the functions that
4257 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
4258 defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
4260 #ifndef START_MY_CXT
4262 /* This must appear in all extensions that define a my_cxt_t structure,
4263 * right after the definition (i.e. at file scope). The non-threads
4264 * case below uses it to declare the data as static. */
4265 #define START_MY_CXT
4267 #if (PERL_BCDVERSION < 0x5004068)
4268 /* Fetches the SV that keeps the per-interpreter data. */
4269 #define dMY_CXT_SV \
4270 SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
4271 #else /* >= perl5.004_68 */
4272 #define dMY_CXT_SV \
4273 SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
4274 sizeof(MY_CXT_KEY)-1, TRUE)
4275 #endif /* < perl5.004_68 */
4277 /* This declaration should be used within all functions that use the
4278 * interpreter-local data. */
4281 my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
4283 /* Creates and zeroes the per-interpreter data.
4284 * (We allocate my_cxtp in a Perl SV so that it will be released when
4285 * the interpreter goes away.) */
4286 #define MY_CXT_INIT \
4288 /* newSV() allocates one more than needed */ \
4289 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
4290 Zero(my_cxtp, 1, my_cxt_t); \
4291 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
4293 /* This macro must be used to access members of the my_cxt_t structure.
4294 * e.g. MYCXT.some_data */
4295 #define MY_CXT (*my_cxtp)
4297 /* Judicious use of these macros can reduce the number of times dMY_CXT
4298 * is used. Use is similar to pTHX, aTHX etc. */
4299 #define pMY_CXT my_cxt_t *my_cxtp
4300 #define pMY_CXT_ pMY_CXT,
4301 #define _pMY_CXT ,pMY_CXT
4302 #define aMY_CXT my_cxtp
4303 #define aMY_CXT_ aMY_CXT,
4304 #define _aMY_CXT ,aMY_CXT
4306 #endif /* START_MY_CXT */
4308 #ifndef MY_CXT_CLONE
4309 /* Clones the per-interpreter data. */
4310 #define MY_CXT_CLONE \
4312 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
4313 Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
4314 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
4317 #else /* single interpreter */
4319 #ifndef START_MY_CXT
4321 #define START_MY_CXT static my_cxt_t my_cxt;
4322 #define dMY_CXT_SV dNOOP
4323 #define dMY_CXT dNOOP
4324 #define MY_CXT_INIT NOOP
4325 #define MY_CXT my_cxt
4327 #define pMY_CXT void
4334 #endif /* START_MY_CXT */
4336 #ifndef MY_CXT_CLONE
4337 #define MY_CXT_CLONE NOOP
4343 # if IVSIZE == LONGSIZE
4350 # if IVSIZE == INTSIZE
4361 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
4362 defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */
4363 # define NVef PERL_PRIeldbl
4364 # define NVff PERL_PRIfldbl
4365 # define NVgf PERL_PRIgldbl
4373 #ifndef SvREFCNT_inc
4374 # ifdef PERL_USE_GCC_BRACE_GROUPS
4375 # define SvREFCNT_inc(sv) \
4377 SV * const _sv = (SV*)(sv); \
4379 (SvREFCNT(_sv))++; \
4383 # define SvREFCNT_inc(sv) \
4384 ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL)
4388 #ifndef SvREFCNT_inc_simple
4389 # ifdef PERL_USE_GCC_BRACE_GROUPS
4390 # define SvREFCNT_inc_simple(sv) \
4397 # define SvREFCNT_inc_simple(sv) \
4398 ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL)
4402 #ifndef SvREFCNT_inc_NN
4403 # ifdef PERL_USE_GCC_BRACE_GROUPS
4404 # define SvREFCNT_inc_NN(sv) \
4406 SV * const _sv = (SV*)(sv); \
4411 # define SvREFCNT_inc_NN(sv) \
4412 (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv)
4416 #ifndef SvREFCNT_inc_void
4417 # ifdef PERL_USE_GCC_BRACE_GROUPS
4418 # define SvREFCNT_inc_void(sv) \
4420 SV * const _sv = (SV*)(sv); \
4422 (void)(SvREFCNT(_sv)++); \
4425 # define SvREFCNT_inc_void(sv) \
4426 (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0)
4429 #ifndef SvREFCNT_inc_simple_void
4430 # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END
4433 #ifndef SvREFCNT_inc_simple_NN
4434 # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv))
4437 #ifndef SvREFCNT_inc_void_NN
4438 # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
4441 #ifndef SvREFCNT_inc_simple_void_NN
4442 # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
4445 /* Backwards compatibility stuff... :-( */
4446 #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen)
4447 # define NEED_sv_2pv_flags
4449 #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL)
4450 # define NEED_sv_2pv_flags_GLOBAL
4453 /* Hint: sv_2pv_nolen
4454 * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen().
4456 #ifndef sv_2pv_nolen
4457 # define sv_2pv_nolen(sv) SvPV_nolen(sv)
4463 * Does not work in perl-5.6.1, ppport.h implements a version
4464 * borrowed from perl-5.7.3.
4467 #if (PERL_BCDVERSION < 0x5007000)
4469 #if defined(NEED_sv_2pvbyte)
4470 static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV * sv, STRLEN * lp);
4473 extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV * sv, STRLEN * lp);
4479 #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
4480 #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
4482 #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
4485 DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp)
4487 sv_utf8_downgrade(sv,0);
4488 return SvPV(sv,*lp);
4494 * Use the SvPVbyte() macro instead of sv_2pvbyte().
4499 #define SvPVbyte(sv, lp) \
4500 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
4501 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
4507 # define SvPVbyte SvPV
4508 # define sv_2pvbyte sv_2pv
4511 #ifndef sv_2pvbyte_nolen
4512 # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv)
4516 * Always use the SvPV() macro instead of sv_pvn().
4519 /* Hint: sv_pvn_force
4520 * Always use the SvPV_force() macro instead of sv_pvn_force().
4523 /* If these are undefined, they're not handled by the core anyway */
4524 #ifndef SV_IMMEDIATE_UNREF
4525 # define SV_IMMEDIATE_UNREF 0
4529 # define SV_GMAGIC 0
4532 #ifndef SV_COW_DROP_PV
4533 # define SV_COW_DROP_PV 0
4536 #ifndef SV_UTF8_NO_ENCODING
4537 # define SV_UTF8_NO_ENCODING 0
4541 # define SV_NOSTEAL 0
4544 #ifndef SV_CONST_RETURN
4545 # define SV_CONST_RETURN 0
4548 #ifndef SV_MUTABLE_RETURN
4549 # define SV_MUTABLE_RETURN 0
4553 # define SV_SMAGIC 0
4556 #ifndef SV_HAS_TRAILING_NUL
4557 # define SV_HAS_TRAILING_NUL 0
4560 #ifndef SV_COW_SHARED_HASH_KEYS
4561 # define SV_COW_SHARED_HASH_KEYS 0
4564 #if (PERL_BCDVERSION < 0x5007002)
4566 #if defined(NEED_sv_2pv_flags)
4567 static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
4570 extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
4574 # undef sv_2pv_flags
4576 #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c)
4577 #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags)
4579 #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL)
4582 DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags)
4584 STRLEN n_a = (STRLEN) flags;
4585 return sv_2pv(sv, lp ? lp : &n_a);
4590 #if defined(NEED_sv_pvn_force_flags)
4591 static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
4594 extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
4597 #ifdef sv_pvn_force_flags
4598 # undef sv_pvn_force_flags
4600 #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c)
4601 #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags)
4603 #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL)
4606 DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags)
4608 STRLEN n_a = (STRLEN) flags;
4609 return sv_pvn_force(sv, lp ? lp : &n_a);
4616 # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC)
4619 #ifndef SvPV_mutable
4620 # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC)
4623 # define SvPV_flags(sv, lp, flags) \
4624 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4625 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags))
4627 #ifndef SvPV_flags_const
4628 # define SvPV_flags_const(sv, lp, flags) \
4629 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4630 ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \
4631 (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN))
4633 #ifndef SvPV_flags_const_nolen
4634 # define SvPV_flags_const_nolen(sv, flags) \
4635 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4636 ? SvPVX_const(sv) : \
4637 (const char*) sv_2pv_flags(sv, 0, flags|SV_CONST_RETURN))
4639 #ifndef SvPV_flags_mutable
4640 # define SvPV_flags_mutable(sv, lp, flags) \
4641 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4642 ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \
4643 sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
4646 # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC)
4649 #ifndef SvPV_force_nolen
4650 # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC)
4653 #ifndef SvPV_force_mutable
4654 # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC)
4657 #ifndef SvPV_force_nomg
4658 # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0)
4661 #ifndef SvPV_force_nomg_nolen
4662 # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0)
4664 #ifndef SvPV_force_flags
4665 # define SvPV_force_flags(sv, lp, flags) \
4666 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
4667 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags))
4669 #ifndef SvPV_force_flags_nolen
4670 # define SvPV_force_flags_nolen(sv, flags) \
4671 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
4672 ? SvPVX(sv) : sv_pvn_force_flags(sv, 0, flags))
4674 #ifndef SvPV_force_flags_mutable
4675 # define SvPV_force_flags_mutable(sv, lp, flags) \
4676 ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
4677 ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \
4678 : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
4681 # define SvPV_nolen(sv) \
4682 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4683 ? SvPVX(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC))
4685 #ifndef SvPV_nolen_const
4686 # define SvPV_nolen_const(sv) \
4687 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4688 ? SvPVX_const(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC|SV_CONST_RETURN))
4691 # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0)
4694 #ifndef SvPV_nomg_const
4695 # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0)
4698 #ifndef SvPV_nomg_const_nolen
4699 # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0)
4702 # define SvMAGIC_set(sv, val) \
4703 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
4704 (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END
4707 #if (PERL_BCDVERSION < 0x5009003)
4709 # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv)))
4712 #ifndef SvPVX_mutable
4713 # define SvPVX_mutable(sv) (0 + SvPVX(sv))
4716 # define SvRV_set(sv, val) \
4717 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
4718 (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END
4723 # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv))
4726 #ifndef SvPVX_mutable
4727 # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv)
4730 # define SvRV_set(sv, val) \
4731 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
4732 ((sv)->sv_u.svu_rv = (val)); } STMT_END
4737 # define SvSTASH_set(sv, val) \
4738 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
4739 (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END
4742 #if (PERL_BCDVERSION < 0x5004000)
4744 # define SvUV_set(sv, val) \
4745 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
4746 (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END
4751 # define SvUV_set(sv, val) \
4752 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
4753 (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END
4758 #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf)
4759 #if defined(NEED_vnewSVpvf)
4760 static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4763 extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4769 #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
4770 #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
4772 #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
4775 DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
4777 register SV *sv = newSV(0);
4778 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
4785 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf)
4786 # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4789 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf)
4790 # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4793 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg)
4794 #if defined(NEED_sv_catpvf_mg)
4795 static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4798 extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4801 #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
4803 #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
4806 DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4809 va_start(args, pat);
4810 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4818 #ifdef PERL_IMPLICIT_CONTEXT
4819 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext)
4820 #if defined(NEED_sv_catpvf_mg_nocontext)
4821 static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4824 extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4827 #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4828 #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4830 #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
4833 DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4837 va_start(args, pat);
4838 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4847 /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */
4848 #ifndef sv_catpvf_mg
4849 # ifdef PERL_IMPLICIT_CONTEXT
4850 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
4852 # define sv_catpvf_mg Perl_sv_catpvf_mg
4856 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg)
4857 # define sv_vcatpvf_mg(sv, pat, args) \
4859 sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
4864 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg)
4865 #if defined(NEED_sv_setpvf_mg)
4866 static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4869 extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4872 #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
4874 #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
4877 DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4880 va_start(args, pat);
4881 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4889 #ifdef PERL_IMPLICIT_CONTEXT
4890 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext)
4891 #if defined(NEED_sv_setpvf_mg_nocontext)
4892 static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4895 extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4898 #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4899 #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4901 #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
4904 DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4908 va_start(args, pat);
4909 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4918 /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */
4919 #ifndef sv_setpvf_mg
4920 # ifdef PERL_IMPLICIT_CONTEXT
4921 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
4923 # define sv_setpvf_mg Perl_sv_setpvf_mg
4927 #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg)
4928 # define sv_vsetpvf_mg(sv, pat, args) \
4930 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
4935 #ifndef newSVpvn_share
4937 #if defined(NEED_newSVpvn_share)
4938 static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash);
4941 extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash);
4944 #ifdef newSVpvn_share
4945 # undef newSVpvn_share
4947 #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c)
4948 #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share)
4950 #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL)
4953 DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash)
4959 PERL_HASH(hash, (char*) src, len);
4960 sv = newSVpvn((char *) src, len);
4961 sv_upgrade(sv, SVt_PVIV);
4971 #ifndef SvSHARED_HASH
4972 # define SvSHARED_HASH(sv) (0 + SvUVX(sv))
4978 #ifndef WARN_CLOSURE
4979 # define WARN_CLOSURE 1
4982 #ifndef WARN_DEPRECATED
4983 # define WARN_DEPRECATED 2
4986 #ifndef WARN_EXITING
4987 # define WARN_EXITING 3
4991 # define WARN_GLOB 4
4999 # define WARN_CLOSED 6
5003 # define WARN_EXEC 7
5007 # define WARN_LAYER 8
5010 #ifndef WARN_NEWLINE
5011 # define WARN_NEWLINE 9
5015 # define WARN_PIPE 10
5018 #ifndef WARN_UNOPENED
5019 # define WARN_UNOPENED 11
5023 # define WARN_MISC 12
5026 #ifndef WARN_NUMERIC
5027 # define WARN_NUMERIC 13
5031 # define WARN_ONCE 14
5034 #ifndef WARN_OVERFLOW
5035 # define WARN_OVERFLOW 15
5039 # define WARN_PACK 16
5042 #ifndef WARN_PORTABLE
5043 # define WARN_PORTABLE 17
5046 #ifndef WARN_RECURSION
5047 # define WARN_RECURSION 18
5050 #ifndef WARN_REDEFINE
5051 # define WARN_REDEFINE 19
5055 # define WARN_REGEXP 20
5059 # define WARN_SEVERE 21
5062 #ifndef WARN_DEBUGGING
5063 # define WARN_DEBUGGING 22
5066 #ifndef WARN_INPLACE
5067 # define WARN_INPLACE 23
5070 #ifndef WARN_INTERNAL
5071 # define WARN_INTERNAL 24
5075 # define WARN_MALLOC 25
5079 # define WARN_SIGNAL 26
5083 # define WARN_SUBSTR 27
5087 # define WARN_SYNTAX 28
5090 #ifndef WARN_AMBIGUOUS
5091 # define WARN_AMBIGUOUS 29
5094 #ifndef WARN_BAREWORD
5095 # define WARN_BAREWORD 30
5099 # define WARN_DIGIT 31
5102 #ifndef WARN_PARENTHESIS
5103 # define WARN_PARENTHESIS 32
5106 #ifndef WARN_PRECEDENCE
5107 # define WARN_PRECEDENCE 33
5111 # define WARN_PRINTF 34
5114 #ifndef WARN_PROTOTYPE
5115 # define WARN_PROTOTYPE 35
5122 #ifndef WARN_RESERVED
5123 # define WARN_RESERVED 37
5126 #ifndef WARN_SEMICOLON
5127 # define WARN_SEMICOLON 38
5131 # define WARN_TAINT 39
5134 #ifndef WARN_THREADS
5135 # define WARN_THREADS 40
5138 #ifndef WARN_UNINITIALIZED
5139 # define WARN_UNINITIALIZED 41
5143 # define WARN_UNPACK 42
5147 # define WARN_UNTIE 43
5151 # define WARN_UTF8 44
5155 # define WARN_VOID 45
5158 #ifndef WARN_ASSERTIONS
5159 # define WARN_ASSERTIONS 46
5162 # define packWARN(a) (a)
5167 # define ckWARN(a) (PL_dowarn & G_WARN_ON)
5169 # define ckWARN(a) PL_dowarn
5173 #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner)
5174 #if defined(NEED_warner)
5175 static void DPPP_(my_warner)(U32 err, const char *pat, ...);
5178 extern void DPPP_(my_warner)(U32 err, const char *pat, ...);
5181 #define Perl_warner DPPP_(my_warner)
5183 #if defined(NEED_warner) || defined(NEED_warner_GLOBAL)
5186 DPPP_(my_warner)(U32 err, const char *pat, ...)
5191 PERL_UNUSED_ARG(err);
5193 va_start(args, pat);
5194 sv = vnewSVpvf(pat, &args);
5197 warn("%s", SvPV_nolen(sv));
5200 #define warner Perl_warner
5202 #define Perl_warner_nocontext Perl_warner
5207 /* concatenating with "" ensures that only literal strings are accepted as argument
5208 * note that STR_WITH_LEN() can't be used as argument to macros or functions that
5209 * under some configurations might be macros
5211 #ifndef STR_WITH_LEN
5212 # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1)
5215 # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1)
5219 # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1)
5223 # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1)
5227 # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval)
5231 # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0)
5234 # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
5236 #ifndef PERL_MAGIC_sv
5237 # define PERL_MAGIC_sv '\0'
5240 #ifndef PERL_MAGIC_overload
5241 # define PERL_MAGIC_overload 'A'
5244 #ifndef PERL_MAGIC_overload_elem
5245 # define PERL_MAGIC_overload_elem 'a'
5248 #ifndef PERL_MAGIC_overload_table
5249 # define PERL_MAGIC_overload_table 'c'
5252 #ifndef PERL_MAGIC_bm
5253 # define PERL_MAGIC_bm 'B'
5256 #ifndef PERL_MAGIC_regdata
5257 # define PERL_MAGIC_regdata 'D'
5260 #ifndef PERL_MAGIC_regdatum
5261 # define PERL_MAGIC_regdatum 'd'
5264 #ifndef PERL_MAGIC_env
5265 # define PERL_MAGIC_env 'E'
5268 #ifndef PERL_MAGIC_envelem
5269 # define PERL_MAGIC_envelem 'e'
5272 #ifndef PERL_MAGIC_fm
5273 # define PERL_MAGIC_fm 'f'
5276 #ifndef PERL_MAGIC_regex_global
5277 # define PERL_MAGIC_regex_global 'g'
5280 #ifndef PERL_MAGIC_isa
5281 # define PERL_MAGIC_isa 'I'
5284 #ifndef PERL_MAGIC_isaelem
5285 # define PERL_MAGIC_isaelem 'i'
5288 #ifndef PERL_MAGIC_nkeys
5289 # define PERL_MAGIC_nkeys 'k'
5292 #ifndef PERL_MAGIC_dbfile
5293 # define PERL_MAGIC_dbfile 'L'
5296 #ifndef PERL_MAGIC_dbline
5297 # define PERL_MAGIC_dbline 'l'
5300 #ifndef PERL_MAGIC_mutex
5301 # define PERL_MAGIC_mutex 'm'
5304 #ifndef PERL_MAGIC_shared
5305 # define PERL_MAGIC_shared 'N'
5308 #ifndef PERL_MAGIC_shared_scalar
5309 # define PERL_MAGIC_shared_scalar 'n'
5312 #ifndef PERL_MAGIC_collxfrm
5313 # define PERL_MAGIC_collxfrm 'o'
5316 #ifndef PERL_MAGIC_tied
5317 # define PERL_MAGIC_tied 'P'
5320 #ifndef PERL_MAGIC_tiedelem
5321 # define PERL_MAGIC_tiedelem 'p'
5324 #ifndef PERL_MAGIC_tiedscalar
5325 # define PERL_MAGIC_tiedscalar 'q'
5328 #ifndef PERL_MAGIC_qr
5329 # define PERL_MAGIC_qr 'r'
5332 #ifndef PERL_MAGIC_sig
5333 # define PERL_MAGIC_sig 'S'
5336 #ifndef PERL_MAGIC_sigelem
5337 # define PERL_MAGIC_sigelem 's'
5340 #ifndef PERL_MAGIC_taint
5341 # define PERL_MAGIC_taint 't'
5344 #ifndef PERL_MAGIC_uvar
5345 # define PERL_MAGIC_uvar 'U'
5348 #ifndef PERL_MAGIC_uvar_elem
5349 # define PERL_MAGIC_uvar_elem 'u'
5352 #ifndef PERL_MAGIC_vstring
5353 # define PERL_MAGIC_vstring 'V'
5356 #ifndef PERL_MAGIC_vec
5357 # define PERL_MAGIC_vec 'v'
5360 #ifndef PERL_MAGIC_utf8
5361 # define PERL_MAGIC_utf8 'w'
5364 #ifndef PERL_MAGIC_substr
5365 # define PERL_MAGIC_substr 'x'
5368 #ifndef PERL_MAGIC_defelem
5369 # define PERL_MAGIC_defelem 'y'
5372 #ifndef PERL_MAGIC_glob
5373 # define PERL_MAGIC_glob '*'
5376 #ifndef PERL_MAGIC_arylen
5377 # define PERL_MAGIC_arylen '#'
5380 #ifndef PERL_MAGIC_pos
5381 # define PERL_MAGIC_pos '.'
5384 #ifndef PERL_MAGIC_backref
5385 # define PERL_MAGIC_backref '<'
5388 #ifndef PERL_MAGIC_ext
5389 # define PERL_MAGIC_ext '~'
5392 /* That's the best we can do... */
5393 #ifndef sv_catpvn_nomg
5394 # define sv_catpvn_nomg sv_catpvn
5397 #ifndef sv_catsv_nomg
5398 # define sv_catsv_nomg sv_catsv
5401 #ifndef sv_setsv_nomg
5402 # define sv_setsv_nomg sv_setsv
5406 # define sv_pvn_nomg sv_pvn
5410 # define SvIV_nomg SvIV
5414 # define SvUV_nomg SvUV
5418 # define sv_catpv_mg(sv, ptr) \
5421 sv_catpv(TeMpSv,ptr); \
5422 SvSETMAGIC(TeMpSv); \
5426 #ifndef sv_catpvn_mg
5427 # define sv_catpvn_mg(sv, ptr, len) \
5430 sv_catpvn(TeMpSv,ptr,len); \
5431 SvSETMAGIC(TeMpSv); \
5436 # define sv_catsv_mg(dsv, ssv) \
5439 sv_catsv(TeMpSv,ssv); \
5440 SvSETMAGIC(TeMpSv); \
5445 # define sv_setiv_mg(sv, i) \
5448 sv_setiv(TeMpSv,i); \
5449 SvSETMAGIC(TeMpSv); \
5454 # define sv_setnv_mg(sv, num) \
5457 sv_setnv(TeMpSv,num); \
5458 SvSETMAGIC(TeMpSv); \
5463 # define sv_setpv_mg(sv, ptr) \
5466 sv_setpv(TeMpSv,ptr); \
5467 SvSETMAGIC(TeMpSv); \
5471 #ifndef sv_setpvn_mg
5472 # define sv_setpvn_mg(sv, ptr, len) \
5475 sv_setpvn(TeMpSv,ptr,len); \
5476 SvSETMAGIC(TeMpSv); \
5481 # define sv_setsv_mg(dsv, ssv) \
5484 sv_setsv(TeMpSv,ssv); \
5485 SvSETMAGIC(TeMpSv); \
5490 # define sv_setuv_mg(sv, i) \
5493 sv_setuv(TeMpSv,i); \
5494 SvSETMAGIC(TeMpSv); \
5498 #ifndef sv_usepvn_mg
5499 # define sv_usepvn_mg(sv, ptr, len) \
5502 sv_usepvn(TeMpSv,ptr,len); \
5503 SvSETMAGIC(TeMpSv); \
5506 #ifndef SvVSTRING_mg
5507 # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL)
5510 /* Hint: sv_magic_portable
5511 * This is a compatibility function that is only available with
5512 * Devel::PPPort. It is NOT in the perl core.
5513 * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when
5514 * it is being passed a name pointer with namlen == 0. In that
5515 * case, perl 5.8.0 and later store the pointer, not a copy of it.
5516 * The compatibility can be provided back to perl 5.004. With
5517 * earlier versions, the code will not compile.
5520 #if (PERL_BCDVERSION < 0x5004000)
5522 /* code that uses sv_magic_portable will not compile */
5524 #elif (PERL_BCDVERSION < 0x5008000)
5526 # define sv_magic_portable(sv, obj, how, name, namlen) \
5528 SV *SvMp_sv = (sv); \
5529 char *SvMp_name = (char *) (name); \
5530 I32 SvMp_namlen = (namlen); \
5531 if (SvMp_name && SvMp_namlen == 0) \
5534 sv_magic(SvMp_sv, obj, how, 0, 0); \
5535 mg = SvMAGIC(SvMp_sv); \
5536 mg->mg_len = -42; /* XXX: this is the tricky part */ \
5537 mg->mg_ptr = SvMp_name; \
5541 sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \
5547 # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e)
5553 # define CopFILE(c) ((c)->cop_file)
5557 # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
5561 # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
5565 # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
5569 # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
5573 # define CopSTASHPV(c) ((c)->cop_stashpv)
5576 #ifndef CopSTASHPV_set
5577 # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
5581 # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
5584 #ifndef CopSTASH_set
5585 # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
5589 # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
5590 || (CopSTASHPV(c) && HvNAME(hv) \
5591 && strEQ(CopSTASHPV(c), HvNAME(hv)))))
5596 # define CopFILEGV(c) ((c)->cop_filegv)
5599 #ifndef CopFILEGV_set
5600 # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
5604 # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
5608 # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
5612 # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
5616 # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
5620 # define CopSTASH(c) ((c)->cop_stash)
5623 #ifndef CopSTASH_set
5624 # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
5628 # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
5631 #ifndef CopSTASHPV_set
5632 # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
5636 # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
5639 #endif /* USE_ITHREADS */
5640 #ifndef IN_PERL_COMPILETIME
5641 # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling)
5644 #ifndef IN_LOCALE_RUNTIME
5645 # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
5648 #ifndef IN_LOCALE_COMPILETIME
5649 # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
5653 # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
5655 #ifndef IS_NUMBER_IN_UV
5656 # define IS_NUMBER_IN_UV 0x01
5659 #ifndef IS_NUMBER_GREATER_THAN_UV_MAX
5660 # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02
5663 #ifndef IS_NUMBER_NOT_INT
5664 # define IS_NUMBER_NOT_INT 0x04
5667 #ifndef IS_NUMBER_NEG
5668 # define IS_NUMBER_NEG 0x08
5671 #ifndef IS_NUMBER_INFINITY
5672 # define IS_NUMBER_INFINITY 0x10
5675 #ifndef IS_NUMBER_NAN
5676 # define IS_NUMBER_NAN 0x20
5678 #ifndef GROK_NUMERIC_RADIX
5679 # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
5681 #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
5682 # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02
5685 #ifndef PERL_SCAN_SILENT_ILLDIGIT
5686 # define PERL_SCAN_SILENT_ILLDIGIT 0x04
5689 #ifndef PERL_SCAN_ALLOW_UNDERSCORES
5690 # define PERL_SCAN_ALLOW_UNDERSCORES 0x01
5693 #ifndef PERL_SCAN_DISALLOW_PREFIX
5694 # define PERL_SCAN_DISALLOW_PREFIX 0x02
5697 #ifndef grok_numeric_radix
5698 #if defined(NEED_grok_numeric_radix)
5699 static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5702 extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5705 #ifdef grok_numeric_radix
5706 # undef grok_numeric_radix
5708 #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
5709 #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
5711 #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
5713 DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
5715 #ifdef USE_LOCALE_NUMERIC
5716 #ifdef PL_numeric_radix_sv
5717 if (PL_numeric_radix_sv && IN_LOCALE) {
5719 char* radix = SvPV(PL_numeric_radix_sv, len);
5720 if (*sp + len <= send && memEQ(*sp, radix, len)) {
5726 /* older perls don't have PL_numeric_radix_sv so the radix
5727 * must manually be requested from locale.h
5730 dTHR; /* needed for older threaded perls */
5731 struct lconv *lc = localeconv();
5732 char *radix = lc->decimal_point;
5733 if (radix && IN_LOCALE) {
5734 STRLEN len = strlen(radix);
5735 if (*sp + len <= send && memEQ(*sp, radix, len)) {
5741 #endif /* USE_LOCALE_NUMERIC */
5742 /* always try "." if numeric radix didn't match because
5743 * we may have data from different locales mixed */
5744 if (*sp < send && **sp == '.') {
5754 #if defined(NEED_grok_number)
5755 static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5758 extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5764 #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
5765 #define Perl_grok_number DPPP_(my_grok_number)
5767 #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
5769 DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
5772 const char *send = pv + len;
5773 const UV max_div_10 = UV_MAX / 10;
5774 const char max_mod_10 = UV_MAX % 10;
5779 while (s < send && isSPACE(*s))
5783 } else if (*s == '-') {
5785 numtype = IS_NUMBER_NEG;
5793 /* next must be digit or the radix separator or beginning of infinity */
5795 /* UVs are at least 32 bits, so the first 9 decimal digits cannot
5797 UV value = *s - '0';
5798 /* This construction seems to be more optimiser friendly.
5799 (without it gcc does the isDIGIT test and the *s - '0' separately)
5800 With it gcc on arm is managing 6 instructions (6 cycles) per digit.
5801 In theory the optimiser could deduce how far to unroll the loop
5802 before checking for overflow. */
5804 int digit = *s - '0';
5805 if (digit >= 0 && digit <= 9) {
5806 value = value * 10 + digit;
5809 if (digit >= 0 && digit <= 9) {
5810 value = value * 10 + digit;
5813 if (digit >= 0 && digit <= 9) {
5814 value = value * 10 + digit;
5817 if (digit >= 0 && digit <= 9) {
5818 value = value * 10 + digit;
5821 if (digit >= 0 && digit <= 9) {
5822 value = value * 10 + digit;
5825 if (digit >= 0 && digit <= 9) {
5826 value = value * 10 + digit;
5829 if (digit >= 0 && digit <= 9) {
5830 value = value * 10 + digit;
5833 if (digit >= 0 && digit <= 9) {
5834 value = value * 10 + digit;
5836 /* Now got 9 digits, so need to check
5837 each time for overflow. */
5839 while (digit >= 0 && digit <= 9
5840 && (value < max_div_10
5841 || (value == max_div_10
5842 && digit <= max_mod_10))) {
5843 value = value * 10 + digit;
5849 if (digit >= 0 && digit <= 9
5851 /* value overflowed.
5852 skip the remaining digits, don't
5853 worry about setting *valuep. */
5856 } while (s < send && isDIGIT(*s));
5858 IS_NUMBER_GREATER_THAN_UV_MAX;
5878 numtype |= IS_NUMBER_IN_UV;
5883 if (GROK_NUMERIC_RADIX(&s, send)) {
5884 numtype |= IS_NUMBER_NOT_INT;
5885 while (s < send && isDIGIT(*s)) /* optional digits after the radix */
5889 else if (GROK_NUMERIC_RADIX(&s, send)) {
5890 numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
5891 /* no digits before the radix means we need digits after it */
5892 if (s < send && isDIGIT(*s)) {
5895 } while (s < send && isDIGIT(*s));
5897 /* integer approximation is valid - it's 0. */
5903 } else if (*s == 'I' || *s == 'i') {
5904 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5905 s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
5906 s++; if (s < send && (*s == 'I' || *s == 'i')) {
5907 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5908 s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
5909 s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
5910 s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
5914 } else if (*s == 'N' || *s == 'n') {
5915 /* XXX TODO: There are signaling NaNs and quiet NaNs. */
5916 s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
5917 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5924 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
5925 numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
5926 } else if (sawnan) {
5927 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
5928 numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
5929 } else if (s < send) {
5930 /* we can have an optional exponent part */
5931 if (*s == 'e' || *s == 'E') {
5932 /* The only flag we keep is sign. Blow away any "it's UV" */
5933 numtype &= IS_NUMBER_NEG;
5934 numtype |= IS_NUMBER_NOT_INT;
5936 if (s < send && (*s == '-' || *s == '+'))
5938 if (s < send && isDIGIT(*s)) {
5941 } while (s < send && isDIGIT(*s));
5947 while (s < send && isSPACE(*s))
5951 if (len == 10 && memEQ(pv, "0 but true", 10)) {
5954 return IS_NUMBER_IN_UV;
5962 * The grok_* routines have been modified to use warn() instead of
5963 * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
5964 * which is why the stack variable has been renamed to 'xdigit'.
5968 #if defined(NEED_grok_bin)
5969 static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
5972 extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
5978 #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
5979 #define Perl_grok_bin DPPP_(my_grok_bin)
5981 #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
5983 DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
5985 const char *s = start;
5986 STRLEN len = *len_p;
5990 const UV max_div_2 = UV_MAX / 2;
5991 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5992 bool overflowed = FALSE;
5994 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5995 /* strip off leading b or 0b.
5996 for compatibility silently suffer "b" and "0b" as valid binary
6003 else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
6010 for (; len-- && *s; s++) {
6012 if (bit == '0' || bit == '1') {
6013 /* Write it in this wonky order with a goto to attempt to get the
6014 compiler to make the common case integer-only loop pretty tight.
6015 With gcc seems to be much straighter code than old scan_bin. */
6018 if (value <= max_div_2) {
6019 value = (value << 1) | (bit - '0');
6022 /* Bah. We're just overflowed. */
6023 warn("Integer overflow in binary number");
6025 value_nv = (NV) value;
6028 /* If an NV has not enough bits in its mantissa to
6029 * represent a UV this summing of small low-order numbers
6030 * is a waste of time (because the NV cannot preserve
6031 * the low-order bits anyway): we could just remember when
6032 * did we overflow and in the end just multiply value_nv by the
6034 value_nv += (NV)(bit - '0');
6037 if (bit == '_' && len && allow_underscores && (bit = s[1])
6038 && (bit == '0' || bit == '1'))
6044 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
6045 warn("Illegal binary digit '%c' ignored", *s);
6049 if ( ( overflowed && value_nv > 4294967295.0)
6051 || (!overflowed && value > 0xffffffff )
6054 warn("Binary number > 0b11111111111111111111111111111111 non-portable");
6061 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
6070 #if defined(NEED_grok_hex)
6071 static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
6074 extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
6080 #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
6081 #define Perl_grok_hex DPPP_(my_grok_hex)
6083 #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
6085 DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
6087 const char *s = start;
6088 STRLEN len = *len_p;
6092 const UV max_div_16 = UV_MAX / 16;
6093 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
6094 bool overflowed = FALSE;
6097 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
6098 /* strip off leading x or 0x.
6099 for compatibility silently suffer "x" and "0x" as valid hex numbers.
6106 else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
6113 for (; len-- && *s; s++) {
6114 xdigit = strchr((char *) PL_hexdigit, *s);
6116 /* Write it in this wonky order with a goto to attempt to get the
6117 compiler to make the common case integer-only loop pretty tight.
6118 With gcc seems to be much straighter code than old scan_hex. */
6121 if (value <= max_div_16) {
6122 value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
6125 warn("Integer overflow in hexadecimal number");
6127 value_nv = (NV) value;
6130 /* If an NV has not enough bits in its mantissa to
6131 * represent a UV this summing of small low-order numbers
6132 * is a waste of time (because the NV cannot preserve
6133 * the low-order bits anyway): we could just remember when
6134 * did we overflow and in the end just multiply value_nv by the
6135 * right amount of 16-tuples. */
6136 value_nv += (NV)((xdigit - PL_hexdigit) & 15);
6139 if (*s == '_' && len && allow_underscores && s[1]
6140 && (xdigit = strchr((char *) PL_hexdigit, s[1])))
6146 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
6147 warn("Illegal hexadecimal digit '%c' ignored", *s);
6151 if ( ( overflowed && value_nv > 4294967295.0)
6153 || (!overflowed && value > 0xffffffff )
6156 warn("Hexadecimal number > 0xffffffff non-portable");
6163 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
6172 #if defined(NEED_grok_oct)
6173 static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
6176 extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
6182 #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
6183 #define Perl_grok_oct DPPP_(my_grok_oct)
6185 #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
6187 DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
6189 const char *s = start;
6190 STRLEN len = *len_p;
6194 const UV max_div_8 = UV_MAX / 8;
6195 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
6196 bool overflowed = FALSE;
6198 for (; len-- && *s; s++) {
6199 /* gcc 2.95 optimiser not smart enough to figure that this subtraction
6200 out front allows slicker code. */
6201 int digit = *s - '0';
6202 if (digit >= 0 && digit <= 7) {
6203 /* Write it in this wonky order with a goto to attempt to get the
6204 compiler to make the common case integer-only loop pretty tight.
6208 if (value <= max_div_8) {
6209 value = (value << 3) | digit;
6212 /* Bah. We're just overflowed. */
6213 warn("Integer overflow in octal number");
6215 value_nv = (NV) value;
6218 /* If an NV has not enough bits in its mantissa to
6219 * represent a UV this summing of small low-order numbers
6220 * is a waste of time (because the NV cannot preserve
6221 * the low-order bits anyway): we could just remember when
6222 * did we overflow and in the end just multiply value_nv by the
6223 * right amount of 8-tuples. */
6224 value_nv += (NV)digit;
6227 if (digit == ('_' - '0') && len && allow_underscores
6228 && (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
6234 /* Allow \octal to work the DWIM way (that is, stop scanning
6235 * as soon as non-octal characters are seen, complain only iff
6236 * someone seems to want to use the digits eight and nine). */
6237 if (digit == 8 || digit == 9) {
6238 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
6239 warn("Illegal octal digit '%c' ignored", *s);
6244 if ( ( overflowed && value_nv > 4294967295.0)
6246 || (!overflowed && value > 0xffffffff )
6249 warn("Octal number > 037777777777 non-portable");
6256 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
6264 #if !defined(my_snprintf)
6265 #if defined(NEED_my_snprintf)
6266 static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...);
6269 extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...);
6272 #define my_snprintf DPPP_(my_my_snprintf)
6273 #define Perl_my_snprintf DPPP_(my_my_snprintf)
6275 #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL)
6278 DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...)
6283 va_start(ap, format);
6284 #ifdef HAS_VSNPRINTF
6285 retval = vsnprintf(buffer, len, format, ap);
6287 retval = vsprintf(buffer, format, ap);
6290 if (retval >= (int)len)
6291 Perl_croak(aTHX_ "panic: my_snprintf buffer overflow");
6300 # define dXCPT dJMPENV; int rEtV = 0
6301 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
6302 # define XCPT_TRY_END JMPENV_POP;
6303 # define XCPT_CATCH if (rEtV != 0)
6304 # define XCPT_RETHROW JMPENV_JUMP(rEtV)
6306 # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0
6307 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0)
6308 # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf);
6309 # define XCPT_CATCH if (rEtV != 0)
6310 # define XCPT_RETHROW Siglongjmp(top_env, rEtV)
6314 #if !defined(my_strlcat)
6315 #if defined(NEED_my_strlcat)
6316 static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size);
6319 extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size);
6322 #define my_strlcat DPPP_(my_my_strlcat)
6323 #define Perl_my_strlcat DPPP_(my_my_strlcat)
6325 #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL)
6328 DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size)
6330 Size_t used, length, copy;
6333 length = strlen(src);
6334 if (size > 0 && used < size - 1) {
6335 copy = (length >= size - used) ? size - used - 1 : length;
6336 memcpy(dst + used, src, copy);
6337 dst[used + copy] = '\0';
6339 return used + length;
6344 #if !defined(my_strlcpy)
6345 #if defined(NEED_my_strlcpy)
6346 static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size);
6349 extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size);
6352 #define my_strlcpy DPPP_(my_my_strlcpy)
6353 #define Perl_my_strlcpy DPPP_(my_my_strlcpy)
6355 #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL)
6358 DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size)
6360 Size_t length, copy;
6362 length = strlen(src);
6364 copy = (length >= size) ? size - 1 : length;
6365 memcpy(dst, src, copy);
6374 #endif /* _P_P_PORTABILITY_H_ */
6376 /* End of File ppport.h */