5 ----------------------------------------------------------------------
7 ppport.h -- Perl/Pollution/Portability Version 3.10
9 Automatically created by Devel::PPPort running under perl 5.009004.
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.10
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.9.4.
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.
83 If neither C<--patch> or C<--copy> are given, the default is to
84 simply print the diffs for each file. This requires either
85 C<Text::Diff> or a C<diff> program to be installed.
87 =head2 --diff=I<program>
89 Manually set the diff program and options to use. The default
90 is to use C<Text::Diff>, when installed, and output unified
93 =head2 --compat-version=I<version>
95 Tell F<ppport.h> to check for compatibility with the given
96 Perl version. The default is to check for compatibility with Perl
97 version 5.003. You can use this option to reduce the output
98 of F<ppport.h> if you intend to be backward compatible only
99 down to a certain Perl version.
103 Usually, F<ppport.h> will detect C++ style comments and
104 replace them with C style comments for portability reasons.
105 Using this option instructs F<ppport.h> to leave C++
110 Be quiet. Don't print anything except fatal errors.
114 Don't output any diagnostic messages. Only portability
115 alerts will be printed.
119 Don't output any hints. Hints often contain useful portability
124 Don't suggest any changes. Only give diagnostic output and hints
125 unless these are also deactivated.
129 Don't filter the list of input files. By default, files not looking
130 like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
134 Strip all script and documentation functionality from F<ppport.h>.
135 This reduces the size of F<ppport.h> dramatically and may be useful
136 if you want to include F<ppport.h> in smaller modules without
137 increasing their distribution size too much.
139 The stripped F<ppport.h> will have a C<--unstrip> option that allows
140 you to undo the stripping, but only if an appropriate C<Devel::PPPort>
143 =head2 --list-provided
145 Lists the API elements for which compatibility is provided by
146 F<ppport.h>. Also lists if it must be explicitly requested,
147 if it has dependencies, and if there are hints for it.
149 =head2 --list-unsupported
151 Lists the API elements that are known not to be supported by
152 F<ppport.h> and below which version of Perl they probably
153 won't be available or work.
155 =head2 --api-info=I<name>
157 Show portability information for API elements matching I<name>.
158 If I<name> is surrounded by slashes, it is interpreted as a regular
163 In order for a Perl extension (XS) module to be as portable as possible
164 across differing versions of Perl itself, certain steps need to be taken.
170 Including this header is the first major one. This alone will give you
171 access to a large part of the Perl API that hasn't been available in
172 earlier Perl releases. Use
174 perl ppport.h --list-provided
176 to see which API elements are provided by ppport.h.
180 You should avoid using deprecated parts of the API. For example, using
181 global Perl variables without the C<PL_> prefix is deprecated. Also,
182 some API functions used to have a C<perl_> prefix. Using this form is
183 also deprecated. You can safely use the supported API, as F<ppport.h>
184 will provide wrappers for older Perl versions.
188 If you use one of a few functions or variables that were not present in
189 earlier versions of Perl, and that can't be provided using a macro, you
190 have to explicitly request support for these functions by adding one or
191 more C<#define>s in your source code before the inclusion of F<ppport.h>.
193 These functions or variables will be marked C<explicit> in the list shown
194 by C<--list-provided>.
196 Depending on whether you module has a single or multiple files that
197 use such functions or variables, you want either C<static> or global
200 For a C<static> function or variable (used only in a single source
203 #define NEED_function
204 #define NEED_variable
206 For a global function or variable (used in multiple source files),
209 #define NEED_function_GLOBAL
210 #define NEED_variable_GLOBAL
212 Note that you mustn't have more than one global request for the
213 same function or variable in your project.
215 Function / Variable Static Request Global Request
216 -----------------------------------------------------------------------------------------
217 PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL
218 eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL
219 grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL
220 grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL
221 grok_number() NEED_grok_number NEED_grok_number_GLOBAL
222 grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL
223 grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL
224 my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL
225 my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL
226 my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL
227 newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
228 newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL
229 sv_2pv_nolen() NEED_sv_2pv_nolen NEED_sv_2pv_nolen_GLOBAL
230 sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL
231 sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL
232 sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL
233 sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL
234 sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL
235 vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL
236 warner() NEED_warner NEED_warner_GLOBAL
238 To avoid namespace conflicts, you can change the namespace of the
239 explicitly exported functions / variables using the C<DPPP_NAMESPACE>
240 macro. Just C<#define> the macro before including C<ppport.h>:
242 #define DPPP_NAMESPACE MyOwnNamespace_
245 The default namespace is C<DPPP_>.
249 The good thing is that most of the above can be checked by running
250 F<ppport.h> on your source code. See the next section for
255 To verify whether F<ppport.h> is needed for your module, whether you
256 should make any changes to your code, and whether any special defines
257 should be used, F<ppport.h> can be run as a Perl script to check your
258 source code. Simply say:
262 The result will usually be a list of patches suggesting changes
263 that should at least be acceptable, if not necessarily the most
264 efficient solution, or a fix for all possible problems.
266 If you know that your XS module uses features only available in
267 newer Perl releases, if you're aware that it uses C++ comments,
268 and if you want all suggestions as a single patch file, you could
269 use something like this:
271 perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
273 If you only want your code to be scanned without any suggestions
276 perl ppport.h --nochanges
278 You can specify a different C<diff> program or options, using
279 the C<--diff> option:
281 perl ppport.h --diff='diff -C 10'
283 This would output context diffs with 10 lines of context.
285 To display portability information for the C<newSVpvn> function,
288 perl ppport.h --api-info=newSVpvn
290 Since the argument to C<--api-info> can be a regular expression,
293 perl ppport.h --api-info=/_nomg$/
295 to display portability information for all C<_nomg> functions or
297 perl ppport.h --api-info=/./
299 to display information for all known API elements.
303 If this version of F<ppport.h> is causing failure during
304 the compilation of this module, please check if newer versions
305 of either this module or C<Devel::PPPort> are available on CPAN
306 before sending a bug report.
308 If F<ppport.h> was generated using the latest version of
309 C<Devel::PPPort> and is causing failure of this module, please
310 file a bug report using the CPAN Request Tracker at L<http://rt.cpan.org/>.
312 Please include the following information:
318 The complete output from running "perl -V"
326 The name and version of the module you were trying to build.
330 A full log of the build that failed.
334 Any other information that you think could be relevant.
338 For the latest version of this code, please get the C<Devel::PPPort>
343 Version 3.x, Copyright (c) 2004-2006, Marcus Holland-Moritz.
345 Version 2.x, Copyright (C) 2001, Paul Marquess.
347 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
349 This program is free software; you can redistribute it and/or
350 modify it under the same terms as Perl itself.
354 See L<Devel::PPPort>.
373 my($ppport) = $0 =~ /([\w.]+)$/;
374 my $LF = '(?:\r\n|[\r\n])'; # line feed
375 my $HS = "[ \t]"; # horizontal whitespace
378 require Getopt::Long;
379 Getopt::Long::GetOptions(\%opt, qw(
380 help quiet diag! filter! hints! changes! cplusplus strip version
381 patch=s copy=s diff=s compat-version=s
382 list-provided list-unsupported api-info=s
386 if ($@ and grep /^-/, @ARGV) {
387 usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
388 die "Getopt::Long not found. Please don't use any options.\n";
392 print "This is $0 $VERSION.\n";
396 usage() if $opt{help};
397 strip() if $opt{strip};
399 if (exists $opt{'compat-version'}) {
400 my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
402 die "Invalid version number format: '$opt{'compat-version'}'\n";
404 die "Only Perl 5 is supported\n" if $r != 5;
405 die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000;
406 $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
409 $opt{'compat-version'} = 5;
412 # Never use C comments in this file!!!!!
415 my $rccs = quotemeta $ccs;
416 my $rcce = quotemeta $cce;
418 my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
420 ($2 ? ( base => $2 ) : ()),
421 ($3 ? ( todo => $3 ) : ()),
422 (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()),
423 (index($4, 'p') >= 0 ? ( provided => 1 ) : ()),
424 (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()),
426 : die "invalid spec: $_" } qw(
432 CopFILEAV|5.006000||p
433 CopFILEGV_set|5.006000||p
434 CopFILEGV|5.006000||p
435 CopFILESV|5.006000||p
436 CopFILE_set|5.006000||p
438 CopSTASHPV_set|5.006000||p
439 CopSTASHPV|5.006000||p
440 CopSTASH_eq|5.006000||p
441 CopSTASH_set|5.006000||p
449 END_EXTERN_C|5.005000||p
458 GROK_NUMERIC_RADIX|5.007002||p
473 HeSVKEY_force||5.004000|
474 HeSVKEY_set||5.004000|
479 IN_LOCALE_COMPILETIME|5.007002||p
480 IN_LOCALE_RUNTIME|5.007002||p
481 IN_LOCALE|5.007002||p
482 IN_PERL_COMPILETIME|5.008001||p
483 IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
484 IS_NUMBER_INFINITY|5.007002||p
485 IS_NUMBER_IN_UV|5.007002||p
486 IS_NUMBER_NAN|5.007003||p
487 IS_NUMBER_NEG|5.007002||p
488 IS_NUMBER_NOT_INT|5.007002||p
496 MY_CXT_CLONE|5.009002||p
497 MY_CXT_INIT|5.007003||p
518 PAD_COMPNAME_FLAGS|||
519 PAD_COMPNAME_GEN_set|||
521 PAD_COMPNAME_OURSTASH|||
526 PAD_SAVE_SETNULLPAD|||
528 PAD_SET_CUR_NOSAVE|||
533 PERL_BCDVERSION|5.009004||p
534 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
535 PERL_INT_MAX|5.004000||p
536 PERL_INT_MIN|5.004000||p
537 PERL_LONG_MAX|5.004000||p
538 PERL_LONG_MIN|5.004000||p
539 PERL_MAGIC_arylen|5.007002||p
540 PERL_MAGIC_backref|5.007002||p
541 PERL_MAGIC_bm|5.007002||p
542 PERL_MAGIC_collxfrm|5.007002||p
543 PERL_MAGIC_dbfile|5.007002||p
544 PERL_MAGIC_dbline|5.007002||p
545 PERL_MAGIC_defelem|5.007002||p
546 PERL_MAGIC_envelem|5.007002||p
547 PERL_MAGIC_env|5.007002||p
548 PERL_MAGIC_ext|5.007002||p
549 PERL_MAGIC_fm|5.007002||p
550 PERL_MAGIC_glob|5.007002||p
551 PERL_MAGIC_isaelem|5.007002||p
552 PERL_MAGIC_isa|5.007002||p
553 PERL_MAGIC_mutex|5.007002||p
554 PERL_MAGIC_nkeys|5.007002||p
555 PERL_MAGIC_overload_elem|5.007002||p
556 PERL_MAGIC_overload_table|5.007002||p
557 PERL_MAGIC_overload|5.007002||p
558 PERL_MAGIC_pos|5.007002||p
559 PERL_MAGIC_qr|5.007002||p
560 PERL_MAGIC_regdata|5.007002||p
561 PERL_MAGIC_regdatum|5.007002||p
562 PERL_MAGIC_regex_global|5.007002||p
563 PERL_MAGIC_shared_scalar|5.007003||p
564 PERL_MAGIC_shared|5.007003||p
565 PERL_MAGIC_sigelem|5.007002||p
566 PERL_MAGIC_sig|5.007002||p
567 PERL_MAGIC_substr|5.007002||p
568 PERL_MAGIC_sv|5.007002||p
569 PERL_MAGIC_taint|5.007002||p
570 PERL_MAGIC_tiedelem|5.007002||p
571 PERL_MAGIC_tiedscalar|5.007002||p
572 PERL_MAGIC_tied|5.007002||p
573 PERL_MAGIC_utf8|5.008001||p
574 PERL_MAGIC_uvar_elem|5.007003||p
575 PERL_MAGIC_uvar|5.007002||p
576 PERL_MAGIC_vec|5.007002||p
577 PERL_MAGIC_vstring|5.008001||p
578 PERL_QUAD_MAX|5.004000||p
579 PERL_QUAD_MIN|5.004000||p
580 PERL_REVISION|5.006000||p
581 PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
582 PERL_SCAN_DISALLOW_PREFIX|5.007003||p
583 PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
584 PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
585 PERL_SHORT_MAX|5.004000||p
586 PERL_SHORT_MIN|5.004000||p
587 PERL_SIGNALS_UNSAFE_FLAG|5.008001||p
588 PERL_SUBVERSION|5.006000||p
589 PERL_UCHAR_MAX|5.004000||p
590 PERL_UCHAR_MIN|5.004000||p
591 PERL_UINT_MAX|5.004000||p
592 PERL_UINT_MIN|5.004000||p
593 PERL_ULONG_MAX|5.004000||p
594 PERL_ULONG_MIN|5.004000||p
595 PERL_UNUSED_ARG|5.009003||p
596 PERL_UNUSED_CONTEXT|5.009004||p
597 PERL_UNUSED_DECL|5.007002||p
598 PERL_UNUSED_VAR|5.007002||p
599 PERL_UQUAD_MAX|5.004000||p
600 PERL_UQUAD_MIN|5.004000||p
601 PERL_USE_GCC_BRACE_GROUPS|5.009004||p
602 PERL_USHORT_MAX|5.004000||p
603 PERL_USHORT_MIN|5.004000||p
604 PERL_VERSION|5.006000||p
609 PL_compiling|5.004050||p
610 PL_copline|5.005000||p
611 PL_curcop|5.004050||p
612 PL_curstash|5.004050||p
613 PL_debstash|5.004050||p
615 PL_diehook|5.004050||p
619 PL_hexdigit|5.005000||p
622 PL_modglobal||5.005000|n
624 PL_no_modify|5.006000||p
626 PL_perl_destruct_level|5.004050||p
627 PL_perldb|5.004050||p
628 PL_ppaddr|5.006000||p
629 PL_rsfp_filters|5.004050||p
632 PL_signals|5.008001||p
633 PL_stack_base|5.004050||p
634 PL_stack_sp|5.004050||p
635 PL_stdingv|5.004050||p
636 PL_sv_arenaroot|5.004050||p
637 PL_sv_no|5.004050||pn
638 PL_sv_undef|5.004050||pn
639 PL_sv_yes|5.004050||pn
640 PL_tainted|5.004050||p
641 PL_tainting|5.004050||p
642 POP_MULTICALL||5.009004|
646 POPpbytex||5.007001|n
656 PUSH_MULTICALL||5.009004|
658 PUSHmortal|5.009002||p
664 PerlIO_clearerr||5.007003|
665 PerlIO_close||5.007003|
666 PerlIO_context_layers||5.009004|
667 PerlIO_eof||5.007003|
668 PerlIO_error||5.007003|
669 PerlIO_fileno||5.007003|
670 PerlIO_fill||5.007003|
671 PerlIO_flush||5.007003|
672 PerlIO_get_base||5.007003|
673 PerlIO_get_bufsiz||5.007003|
674 PerlIO_get_cnt||5.007003|
675 PerlIO_get_ptr||5.007003|
676 PerlIO_read||5.007003|
677 PerlIO_seek||5.007003|
678 PerlIO_set_cnt||5.007003|
679 PerlIO_set_ptrcnt||5.007003|
680 PerlIO_setlinebuf||5.007003|
681 PerlIO_stderr||5.007003|
682 PerlIO_stdin||5.007003|
683 PerlIO_stdout||5.007003|
684 PerlIO_tell||5.007003|
685 PerlIO_unread||5.007003|
686 PerlIO_write||5.007003|
687 Perl_warner_nocontext|5.006000||p
688 Perl_warner|5.006000||p
689 PoisonFree|5.009004||p
690 PoisonNew|5.009004||p
691 PoisonWith|5.009004||p
700 SAVE_DEFSV|5.004050||p
703 START_EXTERN_C|5.005000||p
704 START_MY_CXT|5.007003||p
707 STR_WITH_LEN|5.009003||p
725 SvGETMAGIC|5.004050||p
728 SvIOK_notUV||5.006000|
730 SvIOK_only_UV||5.006000|
736 SvIV_nomg|5.009001||p
740 SvIsCOW_shared_hash||5.008003|
745 SvMAGIC_set|5.009003||p
761 SvPOK_only_UTF8||5.006000|
766 SvPVX_const|5.009003||p
767 SvPVX_mutable|5.009003||p
769 SvPV_force_nomg|5.007002||p
771 SvPV_nolen|5.006000||p
772 SvPV_nomg|5.007002||p
774 SvPVbyte_force||5.009002|
775 SvPVbyte_nolen||5.006000|
776 SvPVbytex_force||5.006000|
779 SvPVutf8_force||5.006000|
780 SvPVutf8_nolen||5.006000|
781 SvPVutf8x_force||5.006000|
787 SvREFCNT_inc_NN|5.009004||p
788 SvREFCNT_inc_simple_NN|5.009004||p
789 SvREFCNT_inc_simple_void_NN|5.009004||p
790 SvREFCNT_inc_simple_void|5.009004||p
791 SvREFCNT_inc_simple|5.009004||p
792 SvREFCNT_inc_void_NN|5.009004||p
793 SvREFCNT_inc_void|5.009004||p
803 SvSTASH_set|5.009003||p
805 SvSetMagicSV_nosteal||5.004000|
806 SvSetMagicSV||5.004000|
807 SvSetSV_nosteal||5.004000|
809 SvTAINTED_off||5.004000|
810 SvTAINTED_on||5.004000|
818 SvUTF8_off||5.006000|
823 SvUV_nomg|5.009001||p
828 SvVSTRING_mg|5.009004||p
838 WARN_AMBIGUOUS|5.006000||p
839 WARN_ASSERTIONS|5.009000||p
840 WARN_BAREWORD|5.006000||p
841 WARN_CLOSED|5.006000||p
842 WARN_CLOSURE|5.006000||p
843 WARN_DEBUGGING|5.006000||p
844 WARN_DEPRECATED|5.006000||p
845 WARN_DIGIT|5.006000||p
846 WARN_EXEC|5.006000||p
847 WARN_EXITING|5.006000||p
848 WARN_GLOB|5.006000||p
849 WARN_INPLACE|5.006000||p
850 WARN_INTERNAL|5.006000||p
852 WARN_LAYER|5.008000||p
853 WARN_MALLOC|5.006000||p
854 WARN_MISC|5.006000||p
855 WARN_NEWLINE|5.006000||p
856 WARN_NUMERIC|5.006000||p
857 WARN_ONCE|5.006000||p
858 WARN_OVERFLOW|5.006000||p
859 WARN_PACK|5.006000||p
860 WARN_PARENTHESIS|5.006000||p
861 WARN_PIPE|5.006000||p
862 WARN_PORTABLE|5.006000||p
863 WARN_PRECEDENCE|5.006000||p
864 WARN_PRINTF|5.006000||p
865 WARN_PROTOTYPE|5.006000||p
867 WARN_RECURSION|5.006000||p
868 WARN_REDEFINE|5.006000||p
869 WARN_REGEXP|5.006000||p
870 WARN_RESERVED|5.006000||p
871 WARN_SEMICOLON|5.006000||p
872 WARN_SEVERE|5.006000||p
873 WARN_SIGNAL|5.006000||p
874 WARN_SUBSTR|5.006000||p
875 WARN_SYNTAX|5.006000||p
876 WARN_TAINT|5.006000||p
877 WARN_THREADS|5.008000||p
878 WARN_UNINITIALIZED|5.006000||p
879 WARN_UNOPENED|5.006000||p
880 WARN_UNPACK|5.006000||p
881 WARN_UNTIE|5.006000||p
882 WARN_UTF8|5.006000||p
883 WARN_VOID|5.006000||p
884 XCPT_CATCH|5.009002||p
885 XCPT_RETHROW|5.009002||p
886 XCPT_TRY_END|5.009002||p
887 XCPT_TRY_START|5.009002||p
889 XPUSHmortal|5.009002||p
900 XSRETURN_UV|5.008001||p
910 XS_VERSION_BOOTCHECK|||
912 XSprePUSH|5.006000||p
936 apply_attrs_string||5.006001|
939 atfork_lock||5.007003|n
940 atfork_unlock||5.007003|n
941 av_arylen_p||5.009003|
962 block_gimme||5.004000|
966 boot_core_UNIVERSAL|||
968 bytes_from_utf8||5.007001|
970 bytes_to_utf8||5.006001|
971 call_argv|5.006000||p
972 call_atexit||5.006000|
974 call_method|5.006000||p
981 cast_ulong||5.006000|
983 check_type_and_open|||
1038 clear_placeholders|||
1043 create_eval_scope|||
1044 croak_nocontext|||vn
1046 csighandler||5.009003|n
1048 custom_op_desc||5.007003|
1049 custom_op_name||5.007003|
1053 cv_const_sv||5.004000|
1063 dMULTICALL||5.009003|
1064 dMY_CXT_SV|5.007003||p
1073 dUNDERBAR|5.009002||p
1084 debprofdump||5.005000|
1086 debstackptrs||5.007003|
1088 debug_start_match|||
1091 delete_eval_scope|||
1095 despatch_signals||5.007001|
1106 do_binmode||5.004050|
1115 do_gv_dump||5.006000|
1116 do_gvgv_dump||5.006000|
1117 do_hv_dump||5.006000|
1122 do_magic_dump||5.006000|
1126 do_op_dump||5.006000|
1132 do_pmop_dump||5.006000|
1143 do_sv_dump||5.006000|
1146 do_trans_complex_utf8|||
1148 do_trans_count_utf8|||
1150 do_trans_simple_utf8|||
1162 doing_taint||5.008001|n
1177 dump_eval||5.006000|
1180 dump_form||5.006000|
1181 dump_indent||5.006000|v
1183 dump_packsubs||5.006000|
1186 dump_trie_interim_list|||
1187 dump_trie_interim_table|||
1189 dump_vindent||5.006000|
1197 fbm_compile||5.005000|
1198 fbm_instr||5.005000|
1200 feature_is_enabled|||
1205 find_array_subscript|||
1208 find_hash_subscript|||
1211 find_rundefsvoffset||5.009002|
1225 fprintf_nocontext|||vn
1226 free_global_struct|||
1227 free_tied_hv_pool|||
1229 gen_constant_list|||
1232 get_context||5.006000|n
1241 get_op_descs||5.005000|
1242 get_op_names||5.005000|
1244 get_ppaddr||5.006000|
1247 getcwd_sv||5.007002|
1256 grok_bin|5.007003||p
1257 grok_hex|5.007003||p
1258 grok_number|5.007002||p
1259 grok_numeric_radix|5.007002||p
1260 grok_oct|5.007003||p
1266 gv_autoload4||5.004000|
1268 gv_const_sv||5.009003|
1270 gv_efullname3||5.004000|
1271 gv_efullname4||5.006001|
1275 gv_fetchmeth_autoload||5.007003|
1276 gv_fetchmethod_autoload||5.004000|
1279 gv_fetchpvn_flags||5.009002|
1281 gv_fetchsv||5.009002|
1282 gv_fullname3||5.004000|
1283 gv_fullname4||5.006001|
1285 gv_handler||5.007001|
1288 gv_name_set||5.009004|
1289 gv_stashpvn|5.004000||p
1290 gv_stashpvs||5.009003|
1297 hv_assert||5.009001|
1299 hv_backreferences_p|||
1300 hv_clear_placeholders||5.009001|
1303 hv_delayfree_ent||5.004000|
1305 hv_delete_ent||5.004000|
1307 hv_eiter_p||5.009003|
1308 hv_eiter_set||5.009003|
1309 hv_exists_ent||5.004000|
1312 hv_fetch_ent||5.004000|
1313 hv_fetchs|5.009003||p
1315 hv_free_ent||5.004000|
1317 hv_iterkeysv||5.004000|
1319 hv_iternext_flags||5.008000|
1324 hv_ksplit||5.004000|
1326 hv_magic_uvar_xkey|||
1328 hv_name_set||5.009003|
1330 hv_placeholders_get||5.009003|
1331 hv_placeholders_p||5.009003|
1332 hv_placeholders_set||5.009003|
1333 hv_riter_p||5.009003|
1334 hv_riter_set||5.009003|
1335 hv_scalar||5.009001|
1336 hv_store_ent||5.004000|
1337 hv_store_flags||5.008000|
1338 hv_stores|5.009004||p
1341 ibcmp_locale||5.004000|
1342 ibcmp_utf8||5.007003|
1346 incpush_if_exists|||
1349 init_argv_symbols|||
1351 init_global_struct|||
1352 init_i18nl10n||5.006000|
1353 init_i18nl14n||5.006000|
1359 init_postdump_symbols|||
1360 init_predump_symbols|||
1361 init_stacks||5.005000|
1378 is_handle_constructor|||n
1379 is_list_assignment|||
1380 is_lvalue_sub||5.007001|
1381 is_uni_alnum_lc||5.006000|
1382 is_uni_alnumc_lc||5.006000|
1383 is_uni_alnumc||5.006000|
1384 is_uni_alnum||5.006000|
1385 is_uni_alpha_lc||5.006000|
1386 is_uni_alpha||5.006000|
1387 is_uni_ascii_lc||5.006000|
1388 is_uni_ascii||5.006000|
1389 is_uni_cntrl_lc||5.006000|
1390 is_uni_cntrl||5.006000|
1391 is_uni_digit_lc||5.006000|
1392 is_uni_digit||5.006000|
1393 is_uni_graph_lc||5.006000|
1394 is_uni_graph||5.006000|
1395 is_uni_idfirst_lc||5.006000|
1396 is_uni_idfirst||5.006000|
1397 is_uni_lower_lc||5.006000|
1398 is_uni_lower||5.006000|
1399 is_uni_print_lc||5.006000|
1400 is_uni_print||5.006000|
1401 is_uni_punct_lc||5.006000|
1402 is_uni_punct||5.006000|
1403 is_uni_space_lc||5.006000|
1404 is_uni_space||5.006000|
1405 is_uni_upper_lc||5.006000|
1406 is_uni_upper||5.006000|
1407 is_uni_xdigit_lc||5.006000|
1408 is_uni_xdigit||5.006000|
1409 is_utf8_alnumc||5.006000|
1410 is_utf8_alnum||5.006000|
1411 is_utf8_alpha||5.006000|
1412 is_utf8_ascii||5.006000|
1413 is_utf8_char_slow|||n
1414 is_utf8_char||5.006000|
1415 is_utf8_cntrl||5.006000|
1417 is_utf8_digit||5.006000|
1418 is_utf8_graph||5.006000|
1419 is_utf8_idcont||5.008000|
1420 is_utf8_idfirst||5.006000|
1421 is_utf8_lower||5.006000|
1422 is_utf8_mark||5.006000|
1423 is_utf8_print||5.006000|
1424 is_utf8_punct||5.006000|
1425 is_utf8_space||5.006000|
1426 is_utf8_string_loclen||5.009003|
1427 is_utf8_string_loc||5.008001|
1428 is_utf8_string||5.006001|
1429 is_utf8_upper||5.006000|
1430 is_utf8_xdigit||5.006000|
1443 load_module_nocontext|||vn
1444 load_module||5.006000|v
1447 looks_like_number|||
1460 magic_clear_all_env|||
1465 magic_dump||5.006000|
1467 magic_freearylen_p|||
1481 magic_killbackrefs|||
1486 magic_regdata_cnt|||
1487 magic_regdatum_get|||
1488 magic_regdatum_set|||
1490 magic_set_all_env|||
1494 magic_setcollxfrm|||
1518 make_trie_failtable|||
1523 matcher_matches_sv|||
1539 mg_length||5.005000|
1544 mini_mktime||5.007002|
1546 mode_from_discipline|||
1570 my_failure_exit||5.004000|
1571 my_fflush_all||5.006000|
1594 my_memcmp||5.004000|n
1597 my_pclose||5.004000|
1598 my_popen_list||5.007001|
1601 my_snprintf|5.009004||pvn
1602 my_socketpair||5.007003|n
1603 my_sprintf||5.009003|vn
1605 my_strftime||5.007002|
1606 my_strlcat|5.009004||pn
1607 my_strlcpy|5.009004||pn
1611 my_vsnprintf||5.009004|n
1614 newANONATTRSUB||5.006000|
1619 newATTRSUB||5.006000|
1624 newCONSTSUB|5.004050||p
1629 newGIVENOP||5.009003|
1653 newRV_inc|5.004000||p
1654 newRV_noinc|5.004000||p
1664 newSVpvf_nocontext|||vn
1665 newSVpvf||5.004000|v
1666 newSVpvn_share||5.007001|
1667 newSVpvn|5.004050||p
1668 newSVpvs_share||5.009003|
1669 newSVpvs|5.009003||p
1677 newWHENOP||5.009003|
1678 newWHILEOP||5.009003|
1679 newXS_flags||5.009004|
1680 newXSproto||5.006000|
1682 new_collate||5.006000|
1684 new_ctype||5.006000|
1687 new_numeric||5.006000|
1688 new_stackinfo||5.005000|
1689 new_version||5.009000|
1690 new_warnings_bitfield|||
1695 no_bareword_allowed|||
1699 nothreadhook||5.008000|
1713 op_refcnt_lock||5.009002|
1714 op_refcnt_unlock||5.009002|
1717 pMY_CXT_|5.007003||p
1721 packWARN|5.007003||p
1731 pad_compname_type|||
1734 pad_fixup_inner_anons|||
1747 parse_unicode_opts|||
1748 path_is_absolute|||n
1751 perl_alloc_using|||n
1753 perl_clone_using|||n
1756 perl_destruct||5.007003|n
1758 perl_parse||5.006000|n
1763 pmop_dump||5.006000|
1774 printf_nocontext|||vn
1784 pv_display||5.006000|
1785 pv_escape||5.009004|
1786 pv_pretty||5.009004|
1787 pv_uni_display||5.007003|
1792 re_intuit_start||5.006000|
1793 re_intuit_string||5.006000|
1797 reentrant_retry|||vn
1799 ref_array_or_hash|||
1800 refcounted_he_chain_2hv|||
1801 refcounted_he_fetch|||
1802 refcounted_he_free|||
1803 refcounted_he_new|||
1804 refcounted_he_value|||
1812 regclass_swash||5.009004|
1818 regexec_flags||5.005000|
1822 reginitcolors||5.006000|
1840 require_pv||5.006000|
1845 rsignal_state||5.004000|
1849 runops_debug||5.005000|
1850 runops_standard||5.005000|
1855 safesyscalloc||5.006000|n
1856 safesysfree||5.006000|n
1857 safesysmalloc||5.006000|n
1858 safesysrealloc||5.006000|n
1863 save_aelem||5.004050|
1864 save_alloc||5.006000|
1867 save_bool||5.008001|
1870 save_destructor_x||5.006000|
1871 save_destructor||5.006000|
1875 save_generic_pvref||5.006001|
1876 save_generic_svref||5.005030|
1880 save_helem||5.004050|
1881 save_hints||5.005000|
1890 save_mortalizesv||5.007001|
1893 save_padsv||5.007001|
1895 save_re_context||5.006000|
1898 save_set_svflags||5.009000|
1899 save_shared_pvref||5.007003|
1902 save_vptr||5.006000|
1906 savesharedpv||5.007003|
1907 savestack_grow_cnt||5.008001|
1931 scan_version||5.009001|
1932 scan_vstring||5.008001|
1935 screaminstr||5.005000|
1940 set_context||5.006000|n
1942 set_numeric_local||5.006000|
1943 set_numeric_radix||5.006000|
1944 set_numeric_standard||5.006000|
1948 share_hek||5.004000|
1959 sortsv_flags||5.009003|
1961 space_join_names_mortal|||
1966 start_subparse||5.004000|
1967 stashpv_hvname_match||5.009004|
1975 str_to_version||5.006000|
1989 sv_2iuv_non_preserve|||
1990 sv_2iv_flags||5.009001|
1994 sv_2pv_flags||5.007002|
1995 sv_2pv_nolen|5.006000||p
1997 sv_2pvbyte|5.006000||p
1998 sv_2pvutf8_nolen||5.006000|
1999 sv_2pvutf8||5.006000|
2001 sv_2uv_flags||5.009001|
2007 sv_cat_decode||5.008001|
2008 sv_catpv_mg|5.004050||p
2009 sv_catpvf_mg_nocontext|||pvn
2010 sv_catpvf_mg|5.006000|5.004000|pv
2011 sv_catpvf_nocontext|||vn
2012 sv_catpvf||5.004000|v
2013 sv_catpvn_flags||5.007002|
2014 sv_catpvn_mg|5.004050||p
2015 sv_catpvn_nomg|5.007002||p
2017 sv_catpvs|5.009003||p
2019 sv_catsv_flags||5.007002|
2020 sv_catsv_mg|5.004050||p
2021 sv_catsv_nomg|5.007002||p
2029 sv_cmp_locale||5.004000|
2032 sv_compile_2op||5.008001|
2033 sv_copypv||5.007003|
2036 sv_derived_from||5.004000|
2042 sv_force_normal_flags||5.007001|
2043 sv_force_normal||5.006000|
2056 sv_len_utf8||5.006000|
2058 sv_magicext||5.007003|
2064 sv_nolocking||5.007003|
2065 sv_nosharing||5.007003|
2069 sv_pos_b2u_forwards|||
2070 sv_pos_b2u_midway|||
2071 sv_pos_b2u||5.006000|
2072 sv_pos_u2b_cached|||
2073 sv_pos_u2b_forwards|||n
2074 sv_pos_u2b_midway|||n
2075 sv_pos_u2b||5.006000|
2076 sv_pvbyten_force||5.006000|
2077 sv_pvbyten||5.006000|
2078 sv_pvbyte||5.006000|
2079 sv_pvn_force_flags||5.007002|
2081 sv_pvn_nomg|5.007003||p
2083 sv_pvutf8n_force||5.006000|
2084 sv_pvutf8n||5.006000|
2085 sv_pvutf8||5.006000|
2087 sv_recode_to_utf8||5.007003|
2094 sv_rvweaken||5.006000|
2095 sv_setiv_mg|5.004050||p
2097 sv_setnv_mg|5.006000||p
2099 sv_setpv_mg|5.004050||p
2100 sv_setpvf_mg_nocontext|||pvn
2101 sv_setpvf_mg|5.006000|5.004000|pv
2102 sv_setpvf_nocontext|||vn
2103 sv_setpvf||5.004000|v
2104 sv_setpviv_mg||5.008001|
2105 sv_setpviv||5.008001|
2106 sv_setpvn_mg|5.004050||p
2108 sv_setpvs|5.009004||p
2114 sv_setref_uv||5.007001|
2116 sv_setsv_flags||5.007002|
2117 sv_setsv_mg|5.004050||p
2118 sv_setsv_nomg|5.007002||p
2120 sv_setuv_mg|5.004050||p
2121 sv_setuv|5.004000||p
2122 sv_tainted||5.004000|
2126 sv_uni_display||5.007003|
2128 sv_unref_flags||5.007001|
2130 sv_untaint||5.004000|
2132 sv_usepvn_flags||5.009004|
2133 sv_usepvn_mg|5.004050||p
2135 sv_utf8_decode||5.006000|
2136 sv_utf8_downgrade||5.006000|
2137 sv_utf8_encode||5.006000|
2138 sv_utf8_upgrade_flags||5.007002|
2139 sv_utf8_upgrade||5.007001|
2141 sv_vcatpvf_mg|5.006000|5.004000|p
2142 sv_vcatpvfn||5.004000|
2143 sv_vcatpvf|5.006000|5.004000|p
2144 sv_vsetpvf_mg|5.006000|5.004000|p
2145 sv_vsetpvfn||5.004000|
2146 sv_vsetpvf|5.006000|5.004000|p
2150 swash_fetch||5.007002|
2152 swash_init||5.006000|
2158 tmps_grow||5.006000|
2162 to_uni_fold||5.007003|
2163 to_uni_lower_lc||5.006000|
2164 to_uni_lower||5.007003|
2165 to_uni_title_lc||5.006000|
2166 to_uni_title||5.007003|
2167 to_uni_upper_lc||5.006000|
2168 to_uni_upper||5.007003|
2169 to_utf8_case||5.007003|
2170 to_utf8_fold||5.007003|
2171 to_utf8_lower||5.007003|
2173 to_utf8_title||5.007003|
2174 to_utf8_upper||5.007003|
2180 too_few_arguments|||
2181 too_many_arguments|||
2185 unpack_str||5.007003|
2186 unpackstring||5.008001|
2187 unshare_hek_or_pvn|||
2189 unsharepvn||5.004000|
2190 unwind_handler_stack|||
2191 upg_version||5.009000|
2193 utf16_to_utf8_reversed||5.006001|
2194 utf16_to_utf8||5.006001|
2195 utf8_distance||5.006000|
2197 utf8_length||5.007001|
2198 utf8_mg_pos_cache_update|||
2199 utf8_to_bytes||5.006001|
2200 utf8_to_uvchr||5.007001|
2201 utf8_to_uvuni||5.007001|
2203 utf8n_to_uvuni||5.007001|
2205 uvchr_to_utf8_flags||5.007003|
2207 uvuni_to_utf8_flags||5.007003|
2208 uvuni_to_utf8||5.007001|
2215 vdie_croak_common|||
2221 vload_module||5.006000|
2223 vnewSVpvf|5.006000|5.004000|p
2226 vstringify||5.009000|
2232 warner_nocontext|||vn
2233 warner|5.006000|5.004000|pv
2253 if (exists $opt{'list-unsupported'}) {
2255 for $f (sort { lc $a cmp lc $b } keys %API) {
2256 next unless $API{$f}{todo};
2257 print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
2262 # Scan for possible replacement candidates
2264 my(%replace, %need, %hints, %depends);
2270 if (m{^\s*\*\s(.*?)\s*$}) {
2271 $hints{$hint} ||= ''; # suppress warning with older perls
2272 $hints{$hint} .= "$1\n";
2278 $hint = $1 if m{^\s*$rccs\sHint:\s+(\w+)\s*$};
2280 $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
2281 $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
2282 $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
2283 $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
2285 if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
2286 push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
2289 $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
2292 if (exists $opt{'api-info'}) {
2295 my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
2296 for $f (sort { lc $a cmp lc $b } keys %API) {
2297 next unless $f =~ /$match/;
2298 print "\n=== $f ===\n\n";
2300 if ($API{$f}{base} || $API{$f}{todo}) {
2301 my $base = format_version($API{$f}{base} || $API{$f}{todo});
2302 print "Supported at least starting from perl-$base.\n";
2305 if ($API{$f}{provided}) {
2306 my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003";
2307 print "Support by $ppport provided back to perl-$todo.\n";
2308 print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f};
2309 print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f};
2310 print "$hints{$f}" if exists $hints{$f};
2314 print "No portability information available.\n";
2322 print "Found no API matching '$opt{'api-info'}'.\n";
2327 if (exists $opt{'list-provided'}) {
2329 for $f (sort { lc $a cmp lc $b } keys %API) {
2330 next unless $API{$f}{provided};
2332 push @flags, 'explicit' if exists $need{$f};
2333 push @flags, 'depend' if exists $depends{$f};
2334 push @flags, 'hint' if exists $hints{$f};
2335 my $flags = @flags ? ' ['.join(', ', @flags).']' : '';
2342 my @srcext = qw( xs c h cc cpp );
2343 my $srcext = join '|', @srcext;
2347 @files = grep { -f && !exists $seen{$_} } map { glob $_ } @ARGV;
2352 File::Find::find(sub {
2353 $File::Find::name =~ /\.($srcext)$/i
2354 and push @files, $File::Find::name;
2358 @files = map { glob "*.$_" } @srcext;
2362 if (!@ARGV || $opt{filter}) {
2364 my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
2366 my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/\.($srcext)$/i;
2367 push @{ $out ? \@out : \@in }, $_;
2369 if (@ARGV && @out) {
2370 warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
2376 die "No input files given!\n";
2379 my(%files, %global, %revreplace);
2380 %revreplace = reverse %replace;
2382 my $patch_opened = 0;
2384 for $filename (@files) {
2385 unless (open IN, "<$filename") {
2386 warn "Unable to read from $filename: $!\n";
2390 info("Scanning $filename ...");
2392 my $c = do { local $/; <IN> };
2395 my %file = (orig => $c, changes => 0);
2397 # temporarily remove C comments from the code
2403 (?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+
2405 (?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+
2409 \*[^*]*\*+(?:[^$ccs][^*]*\*+)* /
2414 defined $2 and push @ccom, $2;
2415 defined $1 ? $1 : "$ccs$#ccom$cce";
2418 $file{ccom} = \@ccom;
2420 $file{has_inc_ppport} = ($c =~ /#.*include.*\Q$ppport\E/);
2424 for $func (keys %API) {
2426 $match .= "|$revreplace{$func}" if exists $revreplace{$func};
2427 if ($c =~ /\b(?:Perl_)?($match)\b/) {
2428 $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
2429 $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
2430 if (exists $API{$func}{provided}) {
2431 if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
2432 $file{uses}{$func}++;
2433 my @deps = rec_depend($func);
2435 $file{uses_deps}{$func} = \@deps;
2437 $file{uses}{$_} = 0 unless exists $file{uses}{$_};
2440 for ($func, @deps) {
2441 if (exists $need{$_}) {
2442 $file{needs}{$_} = 'static';
2447 if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
2448 if ($c =~ /\b$func\b/) {
2449 $file{uses_todo}{$func}++;
2455 while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
2456 if (exists $need{$2}) {
2457 $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
2460 warning("Possibly wrong #define $1 in $filename");
2464 for (qw(uses needs uses_todo needed_global needed_static)) {
2465 for $func (keys %{$file{$_}}) {
2466 push @{$global{$_}{$func}}, $filename;
2470 $files{$filename} = \%file;
2473 # Globally resolve NEED_'s
2475 for $need (keys %{$global{needs}}) {
2476 if (@{$global{needs}{$need}} > 1) {
2477 my @targets = @{$global{needs}{$need}};
2478 my @t = grep $files{$_}{needed_global}{$need}, @targets;
2479 @targets = @t if @t;
2480 @t = grep /\.xs$/i, @targets;
2481 @targets = @t if @t;
2482 my $target = shift @targets;
2483 $files{$target}{needs}{$need} = 'global';
2484 for (@{$global{needs}{$need}}) {
2485 $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
2490 for $filename (@files) {
2491 exists $files{$filename} or next;
2493 info("=== Analyzing $filename ===");
2495 my %file = %{$files{$filename}};
2497 my $c = $file{code};
2499 for $func (sort keys %{$file{uses_Perl}}) {
2500 if ($API{$func}{varargs}) {
2501 my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
2502 { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
2504 warning("Doesn't pass interpreter argument aTHX to Perl_$func");
2505 $file{changes} += $changes;
2509 warning("Uses Perl_$func instead of $func");
2510 $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
2515 for $func (sort keys %{$file{uses_replace}}) {
2516 warning("Uses $func instead of $replace{$func}");
2517 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2520 for $func (sort keys %{$file{uses}}) {
2521 next unless $file{uses}{$func}; # if it's only a dependency
2522 if (exists $file{uses_deps}{$func}) {
2523 diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
2525 elsif (exists $replace{$func}) {
2526 warning("Uses $func instead of $replace{$func}");
2527 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2535 for $func (sort keys %{$file{uses_todo}}) {
2536 warning("Uses $func, which may not be portable below perl ",
2537 format_version($API{$func}{todo}));
2540 for $func (sort keys %{$file{needed_static}}) {
2542 if (not exists $file{uses}{$func}) {
2543 $message = "No need to define NEED_$func if $func is never used";
2545 elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
2546 $message = "No need to define NEED_$func when already needed globally";
2550 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
2554 for $func (sort keys %{$file{needed_global}}) {
2556 if (not exists $global{uses}{$func}) {
2557 $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
2559 elsif (exists $file{needs}{$func}) {
2560 if ($file{needs}{$func} eq 'extern') {
2561 $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
2563 elsif ($file{needs}{$func} eq 'static') {
2564 $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
2569 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
2573 $file{needs_inc_ppport} = keys %{$file{uses}};
2575 if ($file{needs_inc_ppport}) {
2578 for $func (sort keys %{$file{needs}}) {
2579 my $type = $file{needs}{$func};
2580 next if $type eq 'extern';
2581 my $suffix = $type eq 'global' ? '_GLOBAL' : '';
2582 unless (exists $file{"needed_$type"}{$func}) {
2583 if ($type eq 'global') {
2584 diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
2587 diag("File needs $func, adding static request");
2589 $pp .= "#define NEED_$func$suffix\n";
2593 if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
2598 unless ($file{has_inc_ppport}) {
2599 diag("Needs to include '$ppport'");
2600 $pp .= qq(#include "$ppport"\n)
2604 $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
2605 || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
2606 || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
2607 || ($c =~ s/^/$pp/);
2611 if ($file{has_inc_ppport}) {
2612 diag("No need to include '$ppport'");
2613 $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
2617 # put back in our C comments
2620 my @ccom = @{$file{ccom}};
2621 for $ix (0 .. $#ccom) {
2622 if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
2624 $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
2627 $c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
2632 my $s = $cppc != 1 ? 's' : '';
2633 warning("Uses $cppc C++ style comment$s, which is not portable");
2636 if ($file{changes}) {
2637 if (exists $opt{copy}) {
2638 my $newfile = "$filename$opt{copy}";
2640 error("'$newfile' already exists, refusing to write copy of '$filename'");
2644 if (open F, ">$newfile") {
2645 info("Writing copy of '$filename' with changes to '$newfile'");
2650 error("Cannot open '$newfile' for writing: $!");
2654 elsif (exists $opt{patch} || $opt{changes}) {
2655 if (exists $opt{patch}) {
2656 unless ($patch_opened) {
2657 if (open PATCH, ">$opt{patch}") {
2661 error("Cannot open '$opt{patch}' for writing: $!");
2667 mydiff(\*PATCH, $filename, $c);
2671 info("Suggested changes:");
2672 mydiff(\*STDOUT, $filename, $c);
2676 my $s = $file{changes} == 1 ? '' : 's';
2677 info("$file{changes} potentially required change$s detected");
2685 close PATCH if $patch_opened;
2693 my($file, $str) = @_;
2696 if (exists $opt{diff}) {
2697 $diff = run_diff($opt{diff}, $file, $str);
2700 if (!defined $diff and can_use('Text::Diff')) {
2701 $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
2702 $diff = <<HEADER . $diff;
2708 if (!defined $diff) {
2709 $diff = run_diff('diff -u', $file, $str);
2712 if (!defined $diff) {
2713 $diff = run_diff('diff', $file, $str);
2716 if (!defined $diff) {
2717 error("Cannot generate a diff. Please install Text::Diff or use --copy.");
2727 my($prog, $file, $str) = @_;
2728 my $tmp = 'dppptemp';
2733 while (-e "$tmp.$suf") { $suf++ }
2736 if (open F, ">$tmp") {
2740 if (open F, "$prog $file $tmp |") {
2742 s/\Q$tmp\E/$file.patched/;
2753 error("Cannot open '$tmp' for writing: $!");
2769 return () unless exists $depends{$func};
2770 grep !$seen{$_}++, map { ($_, rec_depend($_)) } @{$depends{$func}};
2777 if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
2778 return ($1, $2, $3);
2780 elsif ($ver !~ /^\d+\.[\d_]+$/) {
2781 die "cannot parse version '$ver'\n";
2785 $ver =~ s/$/000000/;
2787 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2792 if ($r < 5 || ($r == 5 && $v < 6)) {
2794 die "cannot parse version '$ver'\n";
2798 return ($r, $v, $s);
2805 $ver =~ s/$/000000/;
2806 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2811 if ($r < 5 || ($r == 5 && $v < 6)) {
2813 die "invalid version '$ver'\n";
2817 $ver = sprintf "%d.%03d", $r, $v;
2818 $s > 0 and $ver .= sprintf "_%02d", $s;
2823 return sprintf "%d.%d.%d", $r, $v, $s;
2828 $opt{quiet} and return;
2834 $opt{quiet} and return;
2835 $opt{diag} and print @_, "\n";
2840 $opt{quiet} and return;
2841 print "*** ", @_, "\n";
2846 print "*** ERROR: ", @_, "\n";
2852 $opt{quiet} and return;
2853 $opt{hints} or return;
2855 exists $hints{$func} or return;
2856 $given_hints{$func}++ and return;
2857 my $hint = $hints{$func};
2859 print " --- hint for $func ---\n", $hint;
2864 my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
2865 my %M = ( 'I' => '*' );
2866 $usage =~ s/^\s*perl\s+\S+/$^X $0/;
2867 $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
2873 See perldoc $0 for details.
2882 my $self = do { local(@ARGV,$/)=($0); <> };
2883 my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms;
2884 $copy =~ s/^(?=\S+)/ /gms;
2885 $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms;
2886 $self =~ s/^SKIP.*(?=^__DATA__)/SKIP
2887 if (\@ARGV && \$ARGV[0] eq '--unstrip') {
2888 eval { require Devel::PPPort };
2889 \$@ and die "Cannot require Devel::PPPort, please install.\\n";
2890 if (\$Devel::PPPort::VERSION < $VERSION) {
2891 die "$0 was originally generated with Devel::PPPort $VERSION.\\n"
2892 . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n"
2893 . "Please install a newer version, or --unstrip will not work.\\n";
2895 Devel::PPPort::WriteFile(\$0);
2900 Sorry, but this is a stripped version of \$0.
2902 To be able to use its original script and doc functionality,
2903 please try to regenerate this file using:
2910 open OUT, ">$0" or die "cannot strip $0: $!\n";
2919 #ifndef _P_P_PORTABILITY_H_
2920 #define _P_P_PORTABILITY_H_
2922 #ifndef DPPP_NAMESPACE
2923 # define DPPP_NAMESPACE DPPP_
2926 #define DPPP_CAT2(x,y) CAT2(x,y)
2927 #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
2929 #ifndef PERL_REVISION
2930 # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
2931 # define PERL_PATCHLEVEL_H_IMPLICIT
2932 # include <patchlevel.h>
2934 # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
2935 # include <could_not_find_Perl_patchlevel.h>
2937 # ifndef PERL_REVISION
2938 # define PERL_REVISION (5)
2940 # define PERL_VERSION PATCHLEVEL
2941 # define PERL_SUBVERSION SUBVERSION
2942 /* Replace PERL_PATCHLEVEL with PERL_VERSION */
2947 #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
2949 /* It is very unlikely that anyone will try to use this with Perl 6
2950 (or greater), but who knows.
2952 #if PERL_REVISION != 5
2953 # error ppport.h only works with Perl version 5
2954 #endif /* PERL_REVISION != 5 */
2957 # include <limits.h>
2960 #ifndef PERL_UCHAR_MIN
2961 # define PERL_UCHAR_MIN ((unsigned char)0)
2964 #ifndef PERL_UCHAR_MAX
2966 # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
2969 # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
2971 # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
2976 #ifndef PERL_USHORT_MIN
2977 # define PERL_USHORT_MIN ((unsigned short)0)
2980 #ifndef PERL_USHORT_MAX
2982 # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
2985 # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
2988 # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
2990 # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
2996 #ifndef PERL_SHORT_MAX
2998 # define PERL_SHORT_MAX ((short)SHORT_MAX)
3000 # ifdef MAXSHORT /* Often used in <values.h> */
3001 # define PERL_SHORT_MAX ((short)MAXSHORT)
3004 # define PERL_SHORT_MAX ((short)SHRT_MAX)
3006 # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
3012 #ifndef PERL_SHORT_MIN
3014 # define PERL_SHORT_MIN ((short)SHORT_MIN)
3017 # define PERL_SHORT_MIN ((short)MINSHORT)
3020 # define PERL_SHORT_MIN ((short)SHRT_MIN)
3022 # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
3028 #ifndef PERL_UINT_MAX
3030 # define PERL_UINT_MAX ((unsigned int)UINT_MAX)
3033 # define PERL_UINT_MAX ((unsigned int)MAXUINT)
3035 # define PERL_UINT_MAX (~(unsigned int)0)
3040 #ifndef PERL_UINT_MIN
3041 # define PERL_UINT_MIN ((unsigned int)0)
3044 #ifndef PERL_INT_MAX
3046 # define PERL_INT_MAX ((int)INT_MAX)
3048 # ifdef MAXINT /* Often used in <values.h> */
3049 # define PERL_INT_MAX ((int)MAXINT)
3051 # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
3056 #ifndef PERL_INT_MIN
3058 # define PERL_INT_MIN ((int)INT_MIN)
3061 # define PERL_INT_MIN ((int)MININT)
3063 # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
3068 #ifndef PERL_ULONG_MAX
3070 # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
3073 # define PERL_ULONG_MAX ((unsigned long)MAXULONG)
3075 # define PERL_ULONG_MAX (~(unsigned long)0)
3080 #ifndef PERL_ULONG_MIN
3081 # define PERL_ULONG_MIN ((unsigned long)0L)
3084 #ifndef PERL_LONG_MAX
3086 # define PERL_LONG_MAX ((long)LONG_MAX)
3089 # define PERL_LONG_MAX ((long)MAXLONG)
3091 # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
3096 #ifndef PERL_LONG_MIN
3098 # define PERL_LONG_MIN ((long)LONG_MIN)
3101 # define PERL_LONG_MIN ((long)MINLONG)
3103 # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
3108 #if defined(HAS_QUAD) && (defined(convex) || defined(uts))
3109 # ifndef PERL_UQUAD_MAX
3110 # ifdef ULONGLONG_MAX
3111 # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
3113 # ifdef MAXULONGLONG
3114 # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
3116 # define PERL_UQUAD_MAX (~(unsigned long long)0)
3121 # ifndef PERL_UQUAD_MIN
3122 # define PERL_UQUAD_MIN ((unsigned long long)0L)
3125 # ifndef PERL_QUAD_MAX
3126 # ifdef LONGLONG_MAX
3127 # define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
3130 # define PERL_QUAD_MAX ((long long)MAXLONGLONG)
3132 # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
3137 # ifndef PERL_QUAD_MIN
3138 # ifdef LONGLONG_MIN
3139 # define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
3142 # define PERL_QUAD_MIN ((long long)MINLONGLONG)
3144 # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
3150 /* This is based on code from 5.003 perl.h */
3158 # define IV_MIN PERL_INT_MIN
3162 # define IV_MAX PERL_INT_MAX
3166 # define UV_MIN PERL_UINT_MIN
3170 # define UV_MAX PERL_UINT_MAX
3175 # define IVSIZE INTSIZE
3180 # if defined(convex) || defined(uts)
3182 # define IVTYPE long long
3186 # define IV_MIN PERL_QUAD_MIN
3190 # define IV_MAX PERL_QUAD_MAX
3194 # define UV_MIN PERL_UQUAD_MIN
3198 # define UV_MAX PERL_UQUAD_MAX
3201 # ifdef LONGLONGSIZE
3203 # define IVSIZE LONGLONGSIZE
3209 # define IVTYPE long
3213 # define IV_MIN PERL_LONG_MIN
3217 # define IV_MAX PERL_LONG_MAX
3221 # define UV_MIN PERL_ULONG_MIN
3225 # define UV_MAX PERL_ULONG_MAX
3230 # define IVSIZE LONGSIZE
3240 #ifndef PERL_QUAD_MIN
3241 # define PERL_QUAD_MIN IV_MIN
3244 #ifndef PERL_QUAD_MAX
3245 # define PERL_QUAD_MAX IV_MAX
3248 #ifndef PERL_UQUAD_MIN
3249 # define PERL_UQUAD_MIN UV_MIN
3252 #ifndef PERL_UQUAD_MAX
3253 # define PERL_UQUAD_MAX UV_MAX
3258 # define IVTYPE long
3262 # define IV_MIN PERL_LONG_MIN
3266 # define IV_MAX PERL_LONG_MAX
3270 # define UV_MIN PERL_ULONG_MIN
3274 # define UV_MAX PERL_ULONG_MAX
3281 # define IVSIZE LONGSIZE
3283 # define IVSIZE 4 /* A bold guess, but the best we can make. */
3287 # define UVTYPE unsigned IVTYPE
3291 # define UVSIZE IVSIZE
3294 # define sv_setuv(sv, uv) \
3297 if (TeMpUv <= IV_MAX) \
3298 sv_setiv(sv, TeMpUv); \
3300 sv_setnv(sv, (double)TeMpUv); \
3304 # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
3307 # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
3311 # define SvUVX(sv) ((UV)SvIVX(sv))
3315 # define SvUVXx(sv) SvUVX(sv)
3319 # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
3323 # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))
3327 * Always use the SvUVx() macro instead of sv_uv().
3330 # define sv_uv(sv) SvUVx(sv)
3333 # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
3337 # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
3340 # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
3344 # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
3349 # define memNE(s1,s2,l) (memcmp(s1,s2,l))
3353 # define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
3358 # define memNE(s1,s2,l) (bcmp(s1,s2,l))
3362 # define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
3367 # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
3371 # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
3376 # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
3381 # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d)
3386 # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t))
3390 # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB)
3394 # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF)
3398 # define Poison(d,n,t) PoisonFree(d,n,t)
3401 # define Newx(v,n,t) New(0,v,n,t)
3405 # define Newxc(v,n,t,c) Newc(0,v,n,t,c)
3409 # define Newxz(v,n,t) Newz(0,v,n,t)
3412 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)))
3414 # define PL_DBsingle DBsingle
3415 # define PL_DBsub DBsub
3417 # define PL_compiling compiling
3418 # define PL_copline copline
3419 # define PL_curcop curcop
3420 # define PL_curstash curstash
3421 # define PL_debstash debstash
3422 # define PL_defgv defgv
3423 # define PL_diehook diehook
3424 # define PL_dirty dirty
3425 # define PL_dowarn dowarn
3426 # define PL_errgv errgv
3427 # define PL_hexdigit hexdigit
3428 # define PL_hints hints
3430 # define PL_no_modify no_modify
3431 # define PL_perl_destruct_level perl_destruct_level
3432 # define PL_perldb perldb
3433 # define PL_ppaddr ppaddr
3434 # define PL_rsfp_filters rsfp_filters
3435 # define PL_rsfp rsfp
3436 # define PL_stack_base stack_base
3437 # define PL_stack_sp stack_sp
3438 # define PL_stdingv stdingv
3439 # define PL_sv_arenaroot sv_arenaroot
3440 # define PL_sv_no sv_no
3441 # define PL_sv_undef sv_undef
3442 # define PL_sv_yes sv_yes
3443 # define PL_tainted tainted
3444 # define PL_tainting tainting
3448 #ifndef PERL_UNUSED_DECL
3449 # ifdef HASATTRIBUTE
3450 # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
3451 # define PERL_UNUSED_DECL
3453 # define PERL_UNUSED_DECL __attribute__((unused))
3456 # define PERL_UNUSED_DECL
3460 #ifndef PERL_UNUSED_ARG
3461 # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
3463 # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
3465 # define PERL_UNUSED_ARG(x) ((void)x)
3469 #ifndef PERL_UNUSED_VAR
3470 # define PERL_UNUSED_VAR(x) ((void)x)
3473 #ifndef PERL_UNUSED_CONTEXT
3474 # ifdef USE_ITHREADS
3475 # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl)
3477 # define PERL_UNUSED_CONTEXT
3481 # define NOOP /*EMPTY*/(void)0
3485 # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL
3489 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
3490 # define NVTYPE long double
3492 # define NVTYPE double
3499 # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
3501 # define INT2PTR(any,d) (any)(d)
3503 # if PTRSIZE == LONGSIZE
3504 # define PTRV unsigned long
3506 # define PTRV unsigned
3508 # define INT2PTR(any,d) (any)(PTRV)(d)
3511 # define NUM2PTR(any,d) (any)(PTRV)(d)
3512 # define PTR2IV(p) INT2PTR(IV,p)
3513 # define PTR2UV(p) INT2PTR(UV,p)
3514 # define PTR2NV(p) NUM2PTR(NV,p)
3516 # if PTRSIZE == LONGSIZE
3517 # define PTR2ul(p) (unsigned long)(p)
3519 # define PTR2ul(p) INT2PTR(unsigned long,p)
3522 #endif /* !INT2PTR */
3524 #undef START_EXTERN_C
3528 # define START_EXTERN_C extern "C" {
3529 # define END_EXTERN_C }
3530 # define EXTERN_C extern "C"
3532 # define START_EXTERN_C
3533 # define END_EXTERN_C
3534 # define EXTERN_C extern
3537 #if defined(PERL_GCC_PEDANTIC)
3538 # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
3539 # define PERL_GCC_BRACE_GROUPS_FORBIDDEN
3543 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
3544 # ifndef PERL_USE_GCC_BRACE_GROUPS
3545 # define PERL_USE_GCC_BRACE_GROUPS
3551 #ifdef PERL_USE_GCC_BRACE_GROUPS
3552 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
3555 # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
3556 # define STMT_START if (1)
3557 # define STMT_END else (void)0
3559 # define STMT_START do
3560 # define STMT_END while (0)
3564 # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
3567 /* DEFSV appears first in 5.004_56 */
3569 # define DEFSV GvSV(PL_defgv)
3573 # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
3576 /* Older perls (<=5.003) lack AvFILLp */
3578 # define AvFILLp AvFILL
3581 # define ERRSV get_sv("@",FALSE)
3584 # define newSVpvn(data,len) ((data) \
3585 ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
3589 /* Hint: gv_stashpvn
3590 * This function's backport doesn't support the length parameter, but
3591 * rather ignores it. Portability can only be ensured if the length
3592 * parameter is used for speed reasons, but the length can always be
3593 * correctly computed from the string argument.
3596 # define gv_stashpvn(str,len,create) gv_stashpv(str,create)
3601 # define get_cv perl_get_cv
3605 # define get_sv perl_get_sv
3609 # define get_av perl_get_av
3613 # define get_hv perl_get_hv
3618 # define dUNDERBAR dNOOP
3622 # define UNDERBAR DEFSV
3625 # define dAX I32 ax = MARK - PL_stack_base + 1
3629 # define dITEMS I32 items = SP - MARK
3632 # define dXSTARG SV * targ = sv_newmortal()
3635 # define dAXMARK I32 ax = POPMARK; \
3636 register SV ** const mark = PL_stack_base + ax++
3639 # define XSprePUSH (sp = PL_stack_base + ax - 1)
3642 #if ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 0)))
3644 # define XSRETURN(off) \
3646 PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
3651 # define PERL_ABS(x) ((x) < 0 ? -(x) : (x))
3660 #ifndef PERL_SIGNALS_UNSAFE_FLAG
3662 #define PERL_SIGNALS_UNSAFE_FLAG 0x0001
3664 #if defined(NEED_PL_signals)
3665 static U32 DPPP_(my_PL_signals) = PERL_SIGNALS_UNSAFE_FLAG;
3666 #elif defined(NEED_PL_signals_GLOBAL)
3667 U32 DPPP_(my_PL_signals) = PERL_SIGNALS_UNSAFE_FLAG;
3669 extern U32 DPPP_(my_PL_signals);
3671 #define PL_signals DPPP_(my_PL_signals)
3682 # define dTHXa(x) dNOOP
3700 # define dTHXoa(x) dTHXa(x)
3703 # define PUSHmortal PUSHs(sv_newmortal())
3707 # define mPUSHp(p,l) sv_setpvn_mg(PUSHmortal, (p), (l))
3711 # define mPUSHn(n) sv_setnv_mg(PUSHmortal, (NV)(n))
3715 # define mPUSHi(i) sv_setiv_mg(PUSHmortal, (IV)(i))
3719 # define mPUSHu(u) sv_setuv_mg(PUSHmortal, (UV)(u))
3722 # define XPUSHmortal XPUSHs(sv_newmortal())
3726 # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
3730 # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
3734 # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
3738 # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
3743 # define call_sv perl_call_sv
3747 # define call_pv perl_call_pv
3751 # define call_argv perl_call_argv
3755 # define call_method perl_call_method
3758 # define eval_sv perl_eval_sv
3763 /* Replace perl_eval_pv with eval_pv */
3764 /* eval_pv depends on eval_sv */
3767 #if defined(NEED_eval_pv)
3768 static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
3771 extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
3777 #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
3778 #define Perl_eval_pv DPPP_(my_eval_pv)
3780 #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
3783 DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
3786 SV* sv = newSVpv(p, 0);
3789 eval_sv(sv, G_SCALAR);
3796 if (croak_on_error && SvTRUE(GvSV(errgv)))
3797 croak(SvPVx(GvSV(errgv), na));
3805 # define newRV_inc(sv) newRV(sv) /* Replace */
3809 #if defined(NEED_newRV_noinc)
3810 static SV * DPPP_(my_newRV_noinc)(SV *sv);
3813 extern SV * DPPP_(my_newRV_noinc)(SV *sv);
3819 #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
3820 #define Perl_newRV_noinc DPPP_(my_newRV_noinc)
3822 #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
3824 DPPP_(my_newRV_noinc)(SV *sv)
3826 SV *rv = (SV *)newRV(sv);
3833 /* Hint: newCONSTSUB
3834 * Returns a CV* as of perl-5.7.1. This return value is not supported
3838 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
3839 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))) && ((PERL_VERSION != 4) || (PERL_SUBVERSION != 5))
3840 #if defined(NEED_newCONSTSUB)
3841 static void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
3844 extern void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
3850 #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
3851 #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
3853 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
3856 DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv)
3858 U32 oldhints = PL_hints;
3859 HV *old_cop_stash = PL_curcop->cop_stash;
3860 HV *old_curstash = PL_curstash;
3861 line_t oldline = PL_curcop->cop_line;
3862 PL_curcop->cop_line = PL_copline;
3864 PL_hints &= ~HINT_BLOCK_SCOPE;
3866 PL_curstash = PL_curcop->cop_stash = stash;
3870 #if ((PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)))
3872 #elif ((PERL_VERSION == 3) && (PERL_SUBVERSION == 22))
3874 #else /* 5.003_23 onwards */
3875 start_subparse(FALSE, 0),
3878 newSVOP(OP_CONST, 0, newSVpv(name,0)),
3879 newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
3880 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
3883 PL_hints = oldhints;
3884 PL_curcop->cop_stash = old_cop_stash;
3885 PL_curstash = old_curstash;
3886 PL_curcop->cop_line = oldline;
3892 * Boilerplate macros for initializing and accessing interpreter-local
3893 * data from C. All statics in extensions should be reworked to use
3894 * this, if you want to make the extension thread-safe. See ext/re/re.xs
3895 * for an example of the use of these macros.
3897 * Code that uses these macros is responsible for the following:
3898 * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
3899 * 2. Declare a typedef named my_cxt_t that is a structure that contains
3900 * all the data that needs to be interpreter-local.
3901 * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
3902 * 4. Use the MY_CXT_INIT macro such that it is called exactly once
3903 * (typically put in the BOOT: section).
3904 * 5. Use the members of the my_cxt_t structure everywhere as
3906 * 6. Use the dMY_CXT macro (a declaration) in all the functions that
3910 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
3911 defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
3913 #ifndef START_MY_CXT
3915 /* This must appear in all extensions that define a my_cxt_t structure,
3916 * right after the definition (i.e. at file scope). The non-threads
3917 * case below uses it to declare the data as static. */
3918 #define START_MY_CXT
3920 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 68)))
3921 /* Fetches the SV that keeps the per-interpreter data. */
3922 #define dMY_CXT_SV \
3923 SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
3924 #else /* >= perl5.004_68 */
3925 #define dMY_CXT_SV \
3926 SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
3927 sizeof(MY_CXT_KEY)-1, TRUE)
3928 #endif /* < perl5.004_68 */
3930 /* This declaration should be used within all functions that use the
3931 * interpreter-local data. */
3934 my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
3936 /* Creates and zeroes the per-interpreter data.
3937 * (We allocate my_cxtp in a Perl SV so that it will be released when
3938 * the interpreter goes away.) */
3939 #define MY_CXT_INIT \
3941 /* newSV() allocates one more than needed */ \
3942 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
3943 Zero(my_cxtp, 1, my_cxt_t); \
3944 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
3946 /* This macro must be used to access members of the my_cxt_t structure.
3947 * e.g. MYCXT.some_data */
3948 #define MY_CXT (*my_cxtp)
3950 /* Judicious use of these macros can reduce the number of times dMY_CXT
3951 * is used. Use is similar to pTHX, aTHX etc. */
3952 #define pMY_CXT my_cxt_t *my_cxtp
3953 #define pMY_CXT_ pMY_CXT,
3954 #define _pMY_CXT ,pMY_CXT
3955 #define aMY_CXT my_cxtp
3956 #define aMY_CXT_ aMY_CXT,
3957 #define _aMY_CXT ,aMY_CXT
3959 #endif /* START_MY_CXT */
3961 #ifndef MY_CXT_CLONE
3962 /* Clones the per-interpreter data. */
3963 #define MY_CXT_CLONE \
3965 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
3966 Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
3967 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
3970 #else /* single interpreter */
3972 #ifndef START_MY_CXT
3974 #define START_MY_CXT static my_cxt_t my_cxt;
3975 #define dMY_CXT_SV dNOOP
3976 #define dMY_CXT dNOOP
3977 #define MY_CXT_INIT NOOP
3978 #define MY_CXT my_cxt
3980 #define pMY_CXT void
3987 #endif /* START_MY_CXT */
3989 #ifndef MY_CXT_CLONE
3990 #define MY_CXT_CLONE NOOP
3996 # if IVSIZE == LONGSIZE
4003 # if IVSIZE == INTSIZE
4014 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
4015 defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */
4016 # define NVef PERL_PRIeldbl
4017 # define NVff PERL_PRIfldbl
4018 # define NVgf PERL_PRIgldbl
4026 #ifndef SvREFCNT_inc
4027 # ifdef PERL_USE_GCC_BRACE_GROUPS
4028 # define SvREFCNT_inc(sv) \
4030 SV * const _sv = (SV*)(sv); \
4032 (SvREFCNT(_sv))++; \
4036 # define SvREFCNT_inc(sv) \
4037 ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL)
4041 #ifndef SvREFCNT_inc_simple
4042 # ifdef PERL_USE_GCC_BRACE_GROUPS
4043 # define SvREFCNT_inc_simple(sv) \
4050 # define SvREFCNT_inc_simple(sv) \
4051 ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL)
4055 #ifndef SvREFCNT_inc_NN
4056 # ifdef PERL_USE_GCC_BRACE_GROUPS
4057 # define SvREFCNT_inc_NN(sv) \
4059 SV * const _sv = (SV*)(sv); \
4064 # define SvREFCNT_inc_NN(sv) \
4065 (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv)
4069 #ifndef SvREFCNT_inc_void
4070 # ifdef PERL_USE_GCC_BRACE_GROUPS
4071 # define SvREFCNT_inc_void(sv) \
4073 SV * const _sv = (SV*)(sv); \
4075 (void)(SvREFCNT(_sv)++); \
4078 # define SvREFCNT_inc_void(sv) \
4079 (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0)
4082 #ifndef SvREFCNT_inc_simple_void
4083 # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END
4086 #ifndef SvREFCNT_inc_simple_NN
4087 # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv))
4090 #ifndef SvREFCNT_inc_void_NN
4091 # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
4094 #ifndef SvREFCNT_inc_simple_void_NN
4095 # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
4100 #if defined(NEED_sv_2pv_nolen)
4101 static char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
4104 extern char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
4108 # undef sv_2pv_nolen
4110 #define sv_2pv_nolen(a) DPPP_(my_sv_2pv_nolen)(aTHX_ a)
4111 #define Perl_sv_2pv_nolen DPPP_(my_sv_2pv_nolen)
4113 #if defined(NEED_sv_2pv_nolen) || defined(NEED_sv_2pv_nolen_GLOBAL)
4116 DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv)
4119 return sv_2pv(sv, &n_a);
4124 /* Hint: sv_2pv_nolen
4125 * Use the SvPV_nolen() macro instead of sv_2pv_nolen().
4128 /* SvPV_nolen depends on sv_2pv_nolen */
4129 #define SvPV_nolen(sv) \
4130 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4131 ? SvPVX(sv) : sv_2pv_nolen(sv))
4138 * Does not work in perl-5.6.1, ppport.h implements a version
4139 * borrowed from perl-5.7.3.
4142 #if ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 0)))
4144 #if defined(NEED_sv_2pvbyte)
4145 static char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
4148 extern char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
4154 #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
4155 #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
4157 #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
4160 DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp)
4162 sv_utf8_downgrade(sv,0);
4163 return SvPV(sv,*lp);
4169 * Use the SvPVbyte() macro instead of sv_2pvbyte().
4174 /* SvPVbyte depends on sv_2pvbyte */
4175 #define SvPVbyte(sv, lp) \
4176 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
4177 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
4183 # define SvPVbyte SvPV
4184 # define sv_2pvbyte sv_2pv
4188 /* sv_2pvbyte_nolen depends on sv_2pv_nolen */
4189 #ifndef sv_2pvbyte_nolen
4190 # define sv_2pvbyte_nolen sv_2pv_nolen
4194 * Always use the SvPV() macro instead of sv_pvn().
4197 # define sv_pvn(sv, len) SvPV(sv, len)
4200 /* Hint: sv_pvn_force
4201 * Always use the SvPV_force() macro instead of sv_pvn_force().
4203 #ifndef sv_pvn_force
4204 # define sv_pvn_force(sv, len) SvPV_force(sv, len)
4207 # define SvMAGIC_set(sv, val) \
4208 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
4209 (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END
4212 #if ((PERL_VERSION < 9) || ((PERL_VERSION == 9) && (PERL_SUBVERSION < 3)))
4214 # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv)))
4217 #ifndef SvPVX_mutable
4218 # define SvPVX_mutable(sv) (0 + SvPVX(sv))
4221 # define SvRV_set(sv, val) \
4222 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
4223 (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END
4228 # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv))
4231 #ifndef SvPVX_mutable
4232 # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv)
4235 # define SvRV_set(sv, val) \
4236 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
4237 ((sv)->sv_u.svu_rv = (val)); } STMT_END
4242 # define SvSTASH_set(sv, val) \
4243 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
4244 (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END
4247 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 0)))
4249 # define SvUV_set(sv, val) \
4250 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
4251 (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END
4256 # define SvUV_set(sv, val) \
4257 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
4258 (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END
4263 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(vnewSVpvf)
4264 #if defined(NEED_vnewSVpvf)
4265 static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4268 extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4274 #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
4275 #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
4277 #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
4280 DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
4282 register SV *sv = newSV(0);
4283 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
4290 /* sv_vcatpvf depends on sv_vcatpvfn */
4291 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf)
4292 # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4295 /* sv_vsetpvf depends on sv_vsetpvfn */
4296 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf)
4297 # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4300 /* sv_catpvf_mg depends on sv_vcatpvfn, sv_catpvf_mg_nocontext */
4301 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg)
4302 #if defined(NEED_sv_catpvf_mg)
4303 static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4306 extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4309 #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
4311 #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
4314 DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4317 va_start(args, pat);
4318 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4326 /* sv_catpvf_mg_nocontext depends on sv_vcatpvfn */
4327 #ifdef PERL_IMPLICIT_CONTEXT
4328 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg_nocontext)
4329 #if defined(NEED_sv_catpvf_mg_nocontext)
4330 static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4333 extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4336 #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4337 #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4339 #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
4342 DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4346 va_start(args, pat);
4347 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4356 #ifndef sv_catpvf_mg
4357 # ifdef PERL_IMPLICIT_CONTEXT
4358 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
4360 # define sv_catpvf_mg Perl_sv_catpvf_mg
4364 /* sv_vcatpvf_mg depends on sv_vcatpvfn */
4365 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf_mg)
4366 # define sv_vcatpvf_mg(sv, pat, args) \
4368 sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
4373 /* sv_setpvf_mg depends on sv_vsetpvfn, sv_setpvf_mg_nocontext */
4374 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg)
4375 #if defined(NEED_sv_setpvf_mg)
4376 static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4379 extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4382 #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
4384 #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
4387 DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4390 va_start(args, pat);
4391 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4399 /* sv_setpvf_mg_nocontext depends on sv_vsetpvfn */
4400 #ifdef PERL_IMPLICIT_CONTEXT
4401 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg_nocontext)
4402 #if defined(NEED_sv_setpvf_mg_nocontext)
4403 static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4406 extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4409 #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4410 #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4412 #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
4415 DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4419 va_start(args, pat);
4420 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4429 #ifndef sv_setpvf_mg
4430 # ifdef PERL_IMPLICIT_CONTEXT
4431 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
4433 # define sv_setpvf_mg Perl_sv_setpvf_mg
4437 /* sv_vsetpvf_mg depends on sv_vsetpvfn */
4438 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf_mg)
4439 # define sv_vsetpvf_mg(sv, pat, args) \
4441 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
4449 #ifndef WARN_CLOSURE
4450 # define WARN_CLOSURE 1
4453 #ifndef WARN_DEPRECATED
4454 # define WARN_DEPRECATED 2
4457 #ifndef WARN_EXITING
4458 # define WARN_EXITING 3
4462 # define WARN_GLOB 4
4470 # define WARN_CLOSED 6
4474 # define WARN_EXEC 7
4478 # define WARN_LAYER 8
4481 #ifndef WARN_NEWLINE
4482 # define WARN_NEWLINE 9
4486 # define WARN_PIPE 10
4489 #ifndef WARN_UNOPENED
4490 # define WARN_UNOPENED 11
4494 # define WARN_MISC 12
4497 #ifndef WARN_NUMERIC
4498 # define WARN_NUMERIC 13
4502 # define WARN_ONCE 14
4505 #ifndef WARN_OVERFLOW
4506 # define WARN_OVERFLOW 15
4510 # define WARN_PACK 16
4513 #ifndef WARN_PORTABLE
4514 # define WARN_PORTABLE 17
4517 #ifndef WARN_RECURSION
4518 # define WARN_RECURSION 18
4521 #ifndef WARN_REDEFINE
4522 # define WARN_REDEFINE 19
4526 # define WARN_REGEXP 20
4530 # define WARN_SEVERE 21
4533 #ifndef WARN_DEBUGGING
4534 # define WARN_DEBUGGING 22
4537 #ifndef WARN_INPLACE
4538 # define WARN_INPLACE 23
4541 #ifndef WARN_INTERNAL
4542 # define WARN_INTERNAL 24
4546 # define WARN_MALLOC 25
4550 # define WARN_SIGNAL 26
4554 # define WARN_SUBSTR 27
4558 # define WARN_SYNTAX 28
4561 #ifndef WARN_AMBIGUOUS
4562 # define WARN_AMBIGUOUS 29
4565 #ifndef WARN_BAREWORD
4566 # define WARN_BAREWORD 30
4570 # define WARN_DIGIT 31
4573 #ifndef WARN_PARENTHESIS
4574 # define WARN_PARENTHESIS 32
4577 #ifndef WARN_PRECEDENCE
4578 # define WARN_PRECEDENCE 33
4582 # define WARN_PRINTF 34
4585 #ifndef WARN_PROTOTYPE
4586 # define WARN_PROTOTYPE 35
4593 #ifndef WARN_RESERVED
4594 # define WARN_RESERVED 37
4597 #ifndef WARN_SEMICOLON
4598 # define WARN_SEMICOLON 38
4602 # define WARN_TAINT 39
4605 #ifndef WARN_THREADS
4606 # define WARN_THREADS 40
4609 #ifndef WARN_UNINITIALIZED
4610 # define WARN_UNINITIALIZED 41
4614 # define WARN_UNPACK 42
4618 # define WARN_UNTIE 43
4622 # define WARN_UTF8 44
4626 # define WARN_VOID 45
4629 #ifndef WARN_ASSERTIONS
4630 # define WARN_ASSERTIONS 46
4633 # define packWARN(a) (a)
4638 # define ckWARN(a) (PL_dowarn & G_WARN_ON)
4640 # define ckWARN(a) PL_dowarn
4644 /* warner depends on vnewSVpvf */
4645 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(warner)
4646 #if defined(NEED_warner)
4647 static void DPPP_(my_warner)(U32 err, const char *pat, ...);
4650 extern void DPPP_(my_warner)(U32 err, const char *pat, ...);
4653 #define Perl_warner DPPP_(my_warner)
4655 #if defined(NEED_warner) || defined(NEED_warner_GLOBAL)
4658 DPPP_(my_warner)(U32 err, const char *pat, ...)
4663 PERL_UNUSED_ARG(err);
4665 va_start(args, pat);
4666 sv = vnewSVpvf(pat, &args);
4669 warn("%s", SvPV_nolen(sv));
4672 #define warner Perl_warner
4674 /* Perl_warner_nocontext depends on warner */
4675 #define Perl_warner_nocontext Perl_warner
4680 /* concatenating with "" ensures that only literal strings are accepted as argument
4681 * note that STR_WITH_LEN() can't be used as argument to macros or functions that
4682 * under some configurations might be macros
4684 #ifndef STR_WITH_LEN
4685 # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1)
4688 # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1)
4692 # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1)
4696 # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1)
4700 # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval)
4704 # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0)
4707 # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
4709 #ifndef PERL_MAGIC_sv
4710 # define PERL_MAGIC_sv '\0'
4713 #ifndef PERL_MAGIC_overload
4714 # define PERL_MAGIC_overload 'A'
4717 #ifndef PERL_MAGIC_overload_elem
4718 # define PERL_MAGIC_overload_elem 'a'
4721 #ifndef PERL_MAGIC_overload_table
4722 # define PERL_MAGIC_overload_table 'c'
4725 #ifndef PERL_MAGIC_bm
4726 # define PERL_MAGIC_bm 'B'
4729 #ifndef PERL_MAGIC_regdata
4730 # define PERL_MAGIC_regdata 'D'
4733 #ifndef PERL_MAGIC_regdatum
4734 # define PERL_MAGIC_regdatum 'd'
4737 #ifndef PERL_MAGIC_env
4738 # define PERL_MAGIC_env 'E'
4741 #ifndef PERL_MAGIC_envelem
4742 # define PERL_MAGIC_envelem 'e'
4745 #ifndef PERL_MAGIC_fm
4746 # define PERL_MAGIC_fm 'f'
4749 #ifndef PERL_MAGIC_regex_global
4750 # define PERL_MAGIC_regex_global 'g'
4753 #ifndef PERL_MAGIC_isa
4754 # define PERL_MAGIC_isa 'I'
4757 #ifndef PERL_MAGIC_isaelem
4758 # define PERL_MAGIC_isaelem 'i'
4761 #ifndef PERL_MAGIC_nkeys
4762 # define PERL_MAGIC_nkeys 'k'
4765 #ifndef PERL_MAGIC_dbfile
4766 # define PERL_MAGIC_dbfile 'L'
4769 #ifndef PERL_MAGIC_dbline
4770 # define PERL_MAGIC_dbline 'l'
4773 #ifndef PERL_MAGIC_mutex
4774 # define PERL_MAGIC_mutex 'm'
4777 #ifndef PERL_MAGIC_shared
4778 # define PERL_MAGIC_shared 'N'
4781 #ifndef PERL_MAGIC_shared_scalar
4782 # define PERL_MAGIC_shared_scalar 'n'
4785 #ifndef PERL_MAGIC_collxfrm
4786 # define PERL_MAGIC_collxfrm 'o'
4789 #ifndef PERL_MAGIC_tied
4790 # define PERL_MAGIC_tied 'P'
4793 #ifndef PERL_MAGIC_tiedelem
4794 # define PERL_MAGIC_tiedelem 'p'
4797 #ifndef PERL_MAGIC_tiedscalar
4798 # define PERL_MAGIC_tiedscalar 'q'
4801 #ifndef PERL_MAGIC_qr
4802 # define PERL_MAGIC_qr 'r'
4805 #ifndef PERL_MAGIC_sig
4806 # define PERL_MAGIC_sig 'S'
4809 #ifndef PERL_MAGIC_sigelem
4810 # define PERL_MAGIC_sigelem 's'
4813 #ifndef PERL_MAGIC_taint
4814 # define PERL_MAGIC_taint 't'
4817 #ifndef PERL_MAGIC_uvar
4818 # define PERL_MAGIC_uvar 'U'
4821 #ifndef PERL_MAGIC_uvar_elem
4822 # define PERL_MAGIC_uvar_elem 'u'
4825 #ifndef PERL_MAGIC_vstring
4826 # define PERL_MAGIC_vstring 'V'
4829 #ifndef PERL_MAGIC_vec
4830 # define PERL_MAGIC_vec 'v'
4833 #ifndef PERL_MAGIC_utf8
4834 # define PERL_MAGIC_utf8 'w'
4837 #ifndef PERL_MAGIC_substr
4838 # define PERL_MAGIC_substr 'x'
4841 #ifndef PERL_MAGIC_defelem
4842 # define PERL_MAGIC_defelem 'y'
4845 #ifndef PERL_MAGIC_glob
4846 # define PERL_MAGIC_glob '*'
4849 #ifndef PERL_MAGIC_arylen
4850 # define PERL_MAGIC_arylen '#'
4853 #ifndef PERL_MAGIC_pos
4854 # define PERL_MAGIC_pos '.'
4857 #ifndef PERL_MAGIC_backref
4858 # define PERL_MAGIC_backref '<'
4861 #ifndef PERL_MAGIC_ext
4862 # define PERL_MAGIC_ext '~'
4865 /* That's the best we can do... */
4866 #ifndef SvPV_force_nomg
4867 # define SvPV_force_nomg SvPV_force
4871 # define SvPV_nomg SvPV
4874 #ifndef sv_catpvn_nomg
4875 # define sv_catpvn_nomg sv_catpvn
4878 #ifndef sv_catsv_nomg
4879 # define sv_catsv_nomg sv_catsv
4882 #ifndef sv_setsv_nomg
4883 # define sv_setsv_nomg sv_setsv
4887 # define sv_pvn_nomg sv_pvn
4891 # define SvIV_nomg SvIV
4895 # define SvUV_nomg SvUV
4899 # define sv_catpv_mg(sv, ptr) \
4902 sv_catpv(TeMpSv,ptr); \
4903 SvSETMAGIC(TeMpSv); \
4907 #ifndef sv_catpvn_mg
4908 # define sv_catpvn_mg(sv, ptr, len) \
4911 sv_catpvn(TeMpSv,ptr,len); \
4912 SvSETMAGIC(TeMpSv); \
4917 # define sv_catsv_mg(dsv, ssv) \
4920 sv_catsv(TeMpSv,ssv); \
4921 SvSETMAGIC(TeMpSv); \
4926 # define sv_setiv_mg(sv, i) \
4929 sv_setiv(TeMpSv,i); \
4930 SvSETMAGIC(TeMpSv); \
4935 # define sv_setnv_mg(sv, num) \
4938 sv_setnv(TeMpSv,num); \
4939 SvSETMAGIC(TeMpSv); \
4944 # define sv_setpv_mg(sv, ptr) \
4947 sv_setpv(TeMpSv,ptr); \
4948 SvSETMAGIC(TeMpSv); \
4952 #ifndef sv_setpvn_mg
4953 # define sv_setpvn_mg(sv, ptr, len) \
4956 sv_setpvn(TeMpSv,ptr,len); \
4957 SvSETMAGIC(TeMpSv); \
4962 # define sv_setsv_mg(dsv, ssv) \
4965 sv_setsv(TeMpSv,ssv); \
4966 SvSETMAGIC(TeMpSv); \
4971 # define sv_setuv_mg(sv, i) \
4974 sv_setuv(TeMpSv,i); \
4975 SvSETMAGIC(TeMpSv); \
4979 #ifndef sv_usepvn_mg
4980 # define sv_usepvn_mg(sv, ptr, len) \
4983 sv_usepvn(TeMpSv,ptr,len); \
4984 SvSETMAGIC(TeMpSv); \
4987 #ifndef SvVSTRING_mg
4988 # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL)
4993 # define CopFILE(c) ((c)->cop_file)
4997 # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
5001 # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
5005 # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
5009 # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
5013 # define CopSTASHPV(c) ((c)->cop_stashpv)
5016 #ifndef CopSTASHPV_set
5017 # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
5021 # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
5024 #ifndef CopSTASH_set
5025 # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
5029 # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
5030 || (CopSTASHPV(c) && HvNAME(hv) \
5031 && strEQ(CopSTASHPV(c), HvNAME(hv)))))
5036 # define CopFILEGV(c) ((c)->cop_filegv)
5039 #ifndef CopFILEGV_set
5040 # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
5044 # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
5048 # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
5052 # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
5056 # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
5060 # define CopSTASH(c) ((c)->cop_stash)
5063 #ifndef CopSTASH_set
5064 # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
5068 # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
5071 #ifndef CopSTASHPV_set
5072 # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
5076 # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
5079 #endif /* USE_ITHREADS */
5080 #ifndef IN_PERL_COMPILETIME
5081 # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling)
5084 #ifndef IN_LOCALE_RUNTIME
5085 # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
5088 #ifndef IN_LOCALE_COMPILETIME
5089 # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
5093 # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
5095 #ifndef IS_NUMBER_IN_UV
5096 # define IS_NUMBER_IN_UV 0x01
5099 #ifndef IS_NUMBER_GREATER_THAN_UV_MAX
5100 # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02
5103 #ifndef IS_NUMBER_NOT_INT
5104 # define IS_NUMBER_NOT_INT 0x04
5107 #ifndef IS_NUMBER_NEG
5108 # define IS_NUMBER_NEG 0x08
5111 #ifndef IS_NUMBER_INFINITY
5112 # define IS_NUMBER_INFINITY 0x10
5115 #ifndef IS_NUMBER_NAN
5116 # define IS_NUMBER_NAN 0x20
5119 /* GROK_NUMERIC_RADIX depends on grok_numeric_radix */
5120 #ifndef GROK_NUMERIC_RADIX
5121 # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
5123 #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
5124 # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02
5127 #ifndef PERL_SCAN_SILENT_ILLDIGIT
5128 # define PERL_SCAN_SILENT_ILLDIGIT 0x04
5131 #ifndef PERL_SCAN_ALLOW_UNDERSCORES
5132 # define PERL_SCAN_ALLOW_UNDERSCORES 0x01
5135 #ifndef PERL_SCAN_DISALLOW_PREFIX
5136 # define PERL_SCAN_DISALLOW_PREFIX 0x02
5139 #ifndef grok_numeric_radix
5140 #if defined(NEED_grok_numeric_radix)
5141 static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5144 extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5147 #ifdef grok_numeric_radix
5148 # undef grok_numeric_radix
5150 #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
5151 #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
5153 #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
5155 DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
5157 #ifdef USE_LOCALE_NUMERIC
5158 #ifdef PL_numeric_radix_sv
5159 if (PL_numeric_radix_sv && IN_LOCALE) {
5161 char* radix = SvPV(PL_numeric_radix_sv, len);
5162 if (*sp + len <= send && memEQ(*sp, radix, len)) {
5168 /* older perls don't have PL_numeric_radix_sv so the radix
5169 * must manually be requested from locale.h
5172 dTHR; /* needed for older threaded perls */
5173 struct lconv *lc = localeconv();
5174 char *radix = lc->decimal_point;
5175 if (radix && IN_LOCALE) {
5176 STRLEN len = strlen(radix);
5177 if (*sp + len <= send && memEQ(*sp, radix, len)) {
5183 #endif /* USE_LOCALE_NUMERIC */
5184 /* always try "." if numeric radix didn't match because
5185 * we may have data from different locales mixed */
5186 if (*sp < send && **sp == '.') {
5195 /* grok_number depends on grok_numeric_radix */
5198 #if defined(NEED_grok_number)
5199 static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5202 extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5208 #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
5209 #define Perl_grok_number DPPP_(my_grok_number)
5211 #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
5213 DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
5216 const char *send = pv + len;
5217 const UV max_div_10 = UV_MAX / 10;
5218 const char max_mod_10 = UV_MAX % 10;
5223 while (s < send && isSPACE(*s))
5227 } else if (*s == '-') {
5229 numtype = IS_NUMBER_NEG;
5237 /* next must be digit or the radix separator or beginning of infinity */
5239 /* UVs are at least 32 bits, so the first 9 decimal digits cannot
5241 UV value = *s - '0';
5242 /* This construction seems to be more optimiser friendly.
5243 (without it gcc does the isDIGIT test and the *s - '0' separately)
5244 With it gcc on arm is managing 6 instructions (6 cycles) per digit.
5245 In theory the optimiser could deduce how far to unroll the loop
5246 before checking for overflow. */
5248 int digit = *s - '0';
5249 if (digit >= 0 && digit <= 9) {
5250 value = value * 10 + digit;
5253 if (digit >= 0 && digit <= 9) {
5254 value = value * 10 + digit;
5257 if (digit >= 0 && digit <= 9) {
5258 value = value * 10 + digit;
5261 if (digit >= 0 && digit <= 9) {
5262 value = value * 10 + digit;
5265 if (digit >= 0 && digit <= 9) {
5266 value = value * 10 + digit;
5269 if (digit >= 0 && digit <= 9) {
5270 value = value * 10 + digit;
5273 if (digit >= 0 && digit <= 9) {
5274 value = value * 10 + digit;
5277 if (digit >= 0 && digit <= 9) {
5278 value = value * 10 + digit;
5280 /* Now got 9 digits, so need to check
5281 each time for overflow. */
5283 while (digit >= 0 && digit <= 9
5284 && (value < max_div_10
5285 || (value == max_div_10
5286 && digit <= max_mod_10))) {
5287 value = value * 10 + digit;
5293 if (digit >= 0 && digit <= 9
5295 /* value overflowed.
5296 skip the remaining digits, don't
5297 worry about setting *valuep. */
5300 } while (s < send && isDIGIT(*s));
5302 IS_NUMBER_GREATER_THAN_UV_MAX;
5322 numtype |= IS_NUMBER_IN_UV;
5327 if (GROK_NUMERIC_RADIX(&s, send)) {
5328 numtype |= IS_NUMBER_NOT_INT;
5329 while (s < send && isDIGIT(*s)) /* optional digits after the radix */
5333 else if (GROK_NUMERIC_RADIX(&s, send)) {
5334 numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
5335 /* no digits before the radix means we need digits after it */
5336 if (s < send && isDIGIT(*s)) {
5339 } while (s < send && isDIGIT(*s));
5341 /* integer approximation is valid - it's 0. */
5347 } else if (*s == 'I' || *s == 'i') {
5348 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5349 s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
5350 s++; if (s < send && (*s == 'I' || *s == 'i')) {
5351 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5352 s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
5353 s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
5354 s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
5358 } else if (*s == 'N' || *s == 'n') {
5359 /* XXX TODO: There are signaling NaNs and quiet NaNs. */
5360 s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
5361 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5368 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
5369 numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
5370 } else if (sawnan) {
5371 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
5372 numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
5373 } else if (s < send) {
5374 /* we can have an optional exponent part */
5375 if (*s == 'e' || *s == 'E') {
5376 /* The only flag we keep is sign. Blow away any "it's UV" */
5377 numtype &= IS_NUMBER_NEG;
5378 numtype |= IS_NUMBER_NOT_INT;
5380 if (s < send && (*s == '-' || *s == '+'))
5382 if (s < send && isDIGIT(*s)) {
5385 } while (s < send && isDIGIT(*s));
5391 while (s < send && isSPACE(*s))
5395 if (len == 10 && memEQ(pv, "0 but true", 10)) {
5398 return IS_NUMBER_IN_UV;
5406 * The grok_* routines have been modified to use warn() instead of
5407 * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
5408 * which is why the stack variable has been renamed to 'xdigit'.
5412 #if defined(NEED_grok_bin)
5413 static UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5416 extern UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5422 #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
5423 #define Perl_grok_bin DPPP_(my_grok_bin)
5425 #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
5427 DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5429 const char *s = start;
5430 STRLEN len = *len_p;
5434 const UV max_div_2 = UV_MAX / 2;
5435 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5436 bool overflowed = FALSE;
5438 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5439 /* strip off leading b or 0b.
5440 for compatibility silently suffer "b" and "0b" as valid binary
5447 else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
5454 for (; len-- && *s; s++) {
5456 if (bit == '0' || bit == '1') {
5457 /* Write it in this wonky order with a goto to attempt to get the
5458 compiler to make the common case integer-only loop pretty tight.
5459 With gcc seems to be much straighter code than old scan_bin. */
5462 if (value <= max_div_2) {
5463 value = (value << 1) | (bit - '0');
5466 /* Bah. We're just overflowed. */
5467 warn("Integer overflow in binary number");
5469 value_nv = (NV) value;
5472 /* If an NV has not enough bits in its mantissa to
5473 * represent a UV this summing of small low-order numbers
5474 * is a waste of time (because the NV cannot preserve
5475 * the low-order bits anyway): we could just remember when
5476 * did we overflow and in the end just multiply value_nv by the
5478 value_nv += (NV)(bit - '0');
5481 if (bit == '_' && len && allow_underscores && (bit = s[1])
5482 && (bit == '0' || bit == '1'))
5488 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5489 warn("Illegal binary digit '%c' ignored", *s);
5493 if ( ( overflowed && value_nv > 4294967295.0)
5495 || (!overflowed && value > 0xffffffff )
5498 warn("Binary number > 0b11111111111111111111111111111111 non-portable");
5505 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5514 #if defined(NEED_grok_hex)
5515 static UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5518 extern UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5524 #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
5525 #define Perl_grok_hex DPPP_(my_grok_hex)
5527 #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
5529 DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5531 const char *s = start;
5532 STRLEN len = *len_p;
5536 const UV max_div_16 = UV_MAX / 16;
5537 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5538 bool overflowed = FALSE;
5541 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5542 /* strip off leading x or 0x.
5543 for compatibility silently suffer "x" and "0x" as valid hex numbers.
5550 else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
5557 for (; len-- && *s; s++) {
5558 xdigit = strchr((char *) PL_hexdigit, *s);
5560 /* Write it in this wonky order with a goto to attempt to get the
5561 compiler to make the common case integer-only loop pretty tight.
5562 With gcc seems to be much straighter code than old scan_hex. */
5565 if (value <= max_div_16) {
5566 value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
5569 warn("Integer overflow in hexadecimal number");
5571 value_nv = (NV) value;
5574 /* If an NV has not enough bits in its mantissa to
5575 * represent a UV this summing of small low-order numbers
5576 * is a waste of time (because the NV cannot preserve
5577 * the low-order bits anyway): we could just remember when
5578 * did we overflow and in the end just multiply value_nv by the
5579 * right amount of 16-tuples. */
5580 value_nv += (NV)((xdigit - PL_hexdigit) & 15);
5583 if (*s == '_' && len && allow_underscores && s[1]
5584 && (xdigit = strchr((char *) PL_hexdigit, s[1])))
5590 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5591 warn("Illegal hexadecimal digit '%c' ignored", *s);
5595 if ( ( overflowed && value_nv > 4294967295.0)
5597 || (!overflowed && value > 0xffffffff )
5600 warn("Hexadecimal number > 0xffffffff non-portable");
5607 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5616 #if defined(NEED_grok_oct)
5617 static UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5620 extern UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5626 #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
5627 #define Perl_grok_oct DPPP_(my_grok_oct)
5629 #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
5631 DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5633 const char *s = start;
5634 STRLEN len = *len_p;
5638 const UV max_div_8 = UV_MAX / 8;
5639 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5640 bool overflowed = FALSE;
5642 for (; len-- && *s; s++) {
5643 /* gcc 2.95 optimiser not smart enough to figure that this subtraction
5644 out front allows slicker code. */
5645 int digit = *s - '0';
5646 if (digit >= 0 && digit <= 7) {
5647 /* Write it in this wonky order with a goto to attempt to get the
5648 compiler to make the common case integer-only loop pretty tight.
5652 if (value <= max_div_8) {
5653 value = (value << 3) | digit;
5656 /* Bah. We're just overflowed. */
5657 warn("Integer overflow in octal number");
5659 value_nv = (NV) value;
5662 /* If an NV has not enough bits in its mantissa to
5663 * represent a UV this summing of small low-order numbers
5664 * is a waste of time (because the NV cannot preserve
5665 * the low-order bits anyway): we could just remember when
5666 * did we overflow and in the end just multiply value_nv by the
5667 * right amount of 8-tuples. */
5668 value_nv += (NV)digit;
5671 if (digit == ('_' - '0') && len && allow_underscores
5672 && (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
5678 /* Allow \octal to work the DWIM way (that is, stop scanning
5679 * as soon as non-octal characters are seen, complain only iff
5680 * someone seems to want to use the digits eight and nine). */
5681 if (digit == 8 || digit == 9) {
5682 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5683 warn("Illegal octal digit '%c' ignored", *s);
5688 if ( ( overflowed && value_nv > 4294967295.0)
5690 || (!overflowed && value > 0xffffffff )
5693 warn("Octal number > 037777777777 non-portable");
5700 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5708 #if !defined(my_snprintf)
5709 #if defined(NEED_my_snprintf)
5710 static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...);
5713 extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...);
5716 #define my_snprintf DPPP_(my_my_snprintf)
5717 #define Perl_my_snprintf DPPP_(my_my_snprintf)
5719 #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL)
5722 DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...)
5727 va_start(ap, format);
5728 #ifdef HAS_VSNPRINTF
5729 retval = vsnprintf(buffer, len, format, ap);
5731 retval = vsprintf(buffer, format, ap);
5734 if (retval >= (int)len)
5735 Perl_croak(aTHX_ "panic: my_snprintf buffer overflow");
5744 # define dXCPT dJMPENV; int rEtV = 0
5745 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
5746 # define XCPT_TRY_END JMPENV_POP;
5747 # define XCPT_CATCH if (rEtV != 0)
5748 # define XCPT_RETHROW JMPENV_JUMP(rEtV)
5750 # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0
5751 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0)
5752 # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf);
5753 # define XCPT_CATCH if (rEtV != 0)
5754 # define XCPT_RETHROW Siglongjmp(top_env, rEtV)
5758 #if !defined(my_strlcat)
5759 #if defined(NEED_my_strlcat)
5760 static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size);
5763 extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size);
5766 #define my_strlcat DPPP_(my_my_strlcat)
5767 #define Perl_my_strlcat DPPP_(my_my_strlcat)
5769 #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL)
5772 DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size)
5774 Size_t used, length, copy;
5777 length = strlen(src);
5778 if (size > 0 && used < size - 1) {
5779 copy = (length >= size - used) ? size - used - 1 : length;
5780 memcpy(dst + used, src, copy);
5781 dst[used + copy] = '\0';
5783 return used + length;
5788 #if !defined(my_strlcpy)
5789 #if defined(NEED_my_strlcpy)
5790 static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size);
5793 extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size);
5796 #define my_strlcpy DPPP_(my_my_strlcpy)
5797 #define Perl_my_strlcpy DPPP_(my_my_strlcpy)
5799 #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL)
5802 DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size)
5804 Size_t length, copy;
5806 length = strlen(src);
5808 copy = (length >= size) ? size - 1 : length;
5809 memcpy(dst, src, copy);
5818 #endif /* _P_P_PORTABILITY_H_ */
5820 /* End of File ppport.h */