5 ----------------------------------------------------------------------
7 ppport.h -- Perl/Pollution/Portability Version 3.07
9 Automatically created by Devel::PPPort running under
10 perl 5.008006 on Wed Jan 18 07:00:54 2006.
12 Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
13 includes in parts/inc/ instead.
15 Use 'perldoc ppport.h' to view the documentation below.
17 ----------------------------------------------------------------------
25 ppport.h - Perl/Pollution/Portability version 3.07
29 perl ppport.h [options] [source files]
31 Searches current directory for files if no [source files] are given
33 --help show short help
35 --patch=file write one patch file with changes
36 --copy=suffix write changed copies with suffix
37 --diff=program use diff program and options
39 --compat-version=version provide compatibility with Perl version
40 --cplusplus accept C++ comments
42 --quiet don't output anything except fatal errors
43 --nodiag don't show diagnostics
44 --nohints don't show hints
45 --nochanges don't suggest changes
46 --nofilter don't filter input files
48 --strip strip all script and doc functionality from
49 ppport.h (this, obviously, cannot be undone)
51 --list-provided list provided API
52 --list-unsupported list unsupported API
53 --api-info=name show Perl API portability information
57 This version of F<ppport.h> is designed to support operation with Perl
58 installations back to 5.003, and has been tested up to 5.9.3.
64 Display a brief usage summary.
66 =head2 --patch=I<file>
68 If this option is given, a single patch file will be created if
69 any changes are suggested. This requires a working diff program
70 to be installed on your system.
72 =head2 --copy=I<suffix>
74 If this option is given, a copy of each file will be saved with
75 the given suffix that contains the suggested changes. This does
76 not require any external programs.
78 If neither C<--patch> or C<--copy> are given, the default is to
79 simply print the diffs for each file. This requires either
80 C<Text::Diff> or a C<diff> program to be installed.
82 =head2 --diff=I<program>
84 Manually set the diff program and options to use. The default
85 is to use C<Text::Diff>, when installed, and output unified
88 =head2 --compat-version=I<version>
90 Tell F<ppport.h> to check for compatibility with the given
91 Perl version. The default is to check for compatibility with Perl
92 version 5.003. You can use this option to reduce the output
93 of F<ppport.h> if you intend to be backward compatible only
94 down to a certain Perl version.
98 Usually, F<ppport.h> will detect C++ style comments and
99 replace them with C style comments for portability reasons.
100 Using this option instructs F<ppport.h> to leave C++
105 Be quiet. Don't print anything except fatal errors.
109 Don't output any diagnostic messages. Only portability
110 alerts will be printed.
114 Don't output any hints. Hints often contain useful portability
119 Don't suggest any changes. Only give diagnostic output and hints
120 unless these are also deactivated.
124 Don't filter the list of input files. By default, files not looking
125 like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
129 Strip all script and documentation functionality from F<ppport.h>.
130 This reduces the size of F<ppport.h> dramatically and may be useful
131 if you want to include F<ppport.h> in smaller modules without
132 increasing their distribution size too much.
134 =head2 --list-provided
136 Lists the API elements for which compatibility is provided by
137 F<ppport.h>. Also lists if it must be explicitly requested,
138 if it has dependencies, and if there are hints for it.
140 =head2 --list-unsupported
142 Lists the API elements that are known not to be supported by
143 F<ppport.h> and below which version of Perl they probably
144 won't be available or work.
146 =head2 --api-info=I<name>
148 Show portability information for API elements matching I<name>.
149 If I<name> is surrounded by slashes, it is interpreted as a regular
154 In order for a Perl extension (XS) module to be as portable as possible
155 across differing versions of Perl itself, certain steps need to be taken.
161 Including this header is the first major one. This alone will give you
162 access to a large part of the Perl API that hasn't been available in
163 earlier Perl releases. Use
165 perl ppport.h --list-provided
167 to see which API elements are provided by ppport.h.
171 You should avoid using deprecated parts of the API. For example, using
172 global Perl variables without the C<PL_> prefix is deprecated. Also,
173 some API functions used to have a C<perl_> prefix. Using this form is
174 also deprecated. You can safely use the supported API, as F<ppport.h>
175 will provide wrappers for older Perl versions.
179 If you use one of a few functions or variables that were not present in
180 earlier versions of Perl, and that can't be provided using a macro, you
181 have to explicitly request support for these functions by adding one or
182 more C<#define>s in your source code before the inclusion of F<ppport.h>.
184 These functions or variables will be marked C<explicit> in the list shown
185 by C<--list-provided>.
187 Depending on whether you module has a single or multiple files that
188 use such functions or variables, you want either C<static> or global
191 For a C<static> function or variable (used only in a single source
194 #define NEED_function
195 #define NEED_variable
197 For a global function or variable (used in multiple source files),
200 #define NEED_function_GLOBAL
201 #define NEED_variable_GLOBAL
203 Note that you mustn't have more than one global request for the
204 same function or variable in your project.
206 Function / Variable Static Request Global Request
207 -----------------------------------------------------------------------------------------
208 PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL
209 eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL
210 grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL
211 grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL
212 grok_number() NEED_grok_number NEED_grok_number_GLOBAL
213 grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL
214 grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL
215 newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
216 newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL
217 sv_2pv_nolen() NEED_sv_2pv_nolen NEED_sv_2pv_nolen_GLOBAL
218 sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL
219 sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL
220 sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL
221 sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL
222 sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL
223 vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL
225 To avoid namespace conflicts, you can change the namespace of the
226 explicitly exported functions / variables using the C<DPPP_NAMESPACE>
227 macro. Just C<#define> the macro before including C<ppport.h>:
229 #define DPPP_NAMESPACE MyOwnNamespace_
232 The default namespace is C<DPPP_>.
236 The good thing is that most of the above can be checked by running
237 F<ppport.h> on your source code. See the next section for
242 To verify whether F<ppport.h> is needed for your module, whether you
243 should make any changes to your code, and whether any special defines
244 should be used, F<ppport.h> can be run as a Perl script to check your
245 source code. Simply say:
249 The result will usually be a list of patches suggesting changes
250 that should at least be acceptable, if not necessarily the most
251 efficient solution, or a fix for all possible problems.
253 If you know that your XS module uses features only available in
254 newer Perl releases, if you're aware that it uses C++ comments,
255 and if you want all suggestions as a single patch file, you could
256 use something like this:
258 perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
260 If you only want your code to be scanned without any suggestions
263 perl ppport.h --nochanges
265 You can specify a different C<diff> program or options, using
266 the C<--diff> option:
268 perl ppport.h --diff='diff -C 10'
270 This would output context diffs with 10 lines of context.
272 To display portability information for the C<newSVpvn> function,
275 perl ppport.h --api-info=newSVpvn
277 Since the argument to C<--api-info> can be a regular expression,
280 perl ppport.h --api-info=/_nomg$/
282 to display portability information for all C<_nomg> functions or
284 perl ppport.h --api-info=/./
286 to display information for all known API elements.
290 If this version of F<ppport.h> is causing failure during
291 the compilation of this module, please check if newer versions
292 of either this module or C<Devel::PPPort> are available on CPAN
293 before sending a bug report.
295 If F<ppport.h> was generated using the latest version of
296 C<Devel::PPPort> and is causing failure of this module, please
297 file a bug report using the CPAN Request Tracker at L<http://rt.cpan.org/>.
299 Please include the following information:
305 The complete output from running "perl -V"
313 The name and version of the module you were trying to build.
317 A full log of the build that failed.
321 Any other information that you think could be relevant.
325 For the latest version of this code, please get the C<Devel::PPPort>
330 Version 3.x, Copyright (c) 2004-2006, Marcus Holland-Moritz.
332 Version 2.x, Copyright (C) 2001, Paul Marquess.
334 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
336 This program is free software; you can redistribute it and/or
337 modify it under the same terms as Perl itself.
341 See L<Devel::PPPort>.
357 my($ppport) = $0 =~ /([\w.]+)$/;
358 my $LF = '(?:\r\n|[\r\n])'; # line feed
359 my $HS = "[ \t]"; # horizontal whitespace
362 require Getopt::Long;
363 Getopt::Long::GetOptions(\%opt, qw(
364 help quiet diag! filter! hints! changes! cplusplus strip
365 patch=s copy=s diff=s compat-version=s
366 list-provided list-unsupported api-info=s
370 if ($@ and grep /^-/, @ARGV) {
371 usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
372 die "Getopt::Long not found. Please don't use any options.\n";
375 usage() if $opt{help};
376 strip() if $opt{strip};
378 if (exists $opt{'compat-version'}) {
379 my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
381 die "Invalid version number format: '$opt{'compat-version'}'\n";
383 die "Only Perl 5 is supported\n" if $r != 5;
384 die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000;
385 $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
388 $opt{'compat-version'} = 5;
391 # Never use C comments in this file!!!!!
394 my $rccs = quotemeta $ccs;
395 my $rcce = quotemeta $cce;
397 my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
399 ($2 ? ( base => $2 ) : ()),
400 ($3 ? ( todo => $3 ) : ()),
401 (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()),
402 (index($4, 'p') >= 0 ? ( provided => 1 ) : ()),
403 (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()),
405 : die "invalid spec: $_" } qw(
411 CopFILEAV|5.006000||p
412 CopFILEGV_set|5.006000||p
413 CopFILEGV|5.006000||p
414 CopFILESV|5.006000||p
415 CopFILE_set|5.006000||p
417 CopSTASHPV_set|5.006000||p
418 CopSTASHPV|5.006000||p
419 CopSTASH_eq|5.006000||p
420 CopSTASH_set|5.006000||p
428 END_EXTERN_C|5.005000||p
437 GROK_NUMERIC_RADIX|5.007002||p
452 HeSVKEY_force||5.004000|
453 HeSVKEY_set||5.004000|
458 IN_LOCALE_COMPILETIME|5.007002||p
459 IN_LOCALE_RUNTIME|5.007002||p
460 IN_LOCALE|5.007002||p
461 IN_PERL_COMPILETIME|5.008001||p
462 IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
463 IS_NUMBER_INFINITY|5.007002||p
464 IS_NUMBER_IN_UV|5.007002||p
465 IS_NUMBER_NAN|5.007003||p
466 IS_NUMBER_NEG|5.007002||p
467 IS_NUMBER_NOT_INT|5.007002||p
475 MY_CXT_CLONE|5.009002||p
476 MY_CXT_INIT|5.007003||p
498 PAD_COMPNAME_FLAGS|||
499 PAD_COMPNAME_GEN_set|||
501 PAD_COMPNAME_OURSTASH|||
506 PAD_SAVE_SETNULLPAD|||
508 PAD_SET_CUR_NOSAVE|||
512 PERL_BCDVERSION|5.009003||p
513 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
514 PERL_INT_MAX|5.004000||p
515 PERL_INT_MIN|5.004000||p
516 PERL_LONG_MAX|5.004000||p
517 PERL_LONG_MIN|5.004000||p
518 PERL_MAGIC_arylen|5.007002||p
519 PERL_MAGIC_backref|5.007002||p
520 PERL_MAGIC_bm|5.007002||p
521 PERL_MAGIC_collxfrm|5.007002||p
522 PERL_MAGIC_dbfile|5.007002||p
523 PERL_MAGIC_dbline|5.007002||p
524 PERL_MAGIC_defelem|5.007002||p
525 PERL_MAGIC_envelem|5.007002||p
526 PERL_MAGIC_env|5.007002||p
527 PERL_MAGIC_ext|5.007002||p
528 PERL_MAGIC_fm|5.007002||p
529 PERL_MAGIC_glob|5.007002||p
530 PERL_MAGIC_isaelem|5.007002||p
531 PERL_MAGIC_isa|5.007002||p
532 PERL_MAGIC_mutex|5.007002||p
533 PERL_MAGIC_nkeys|5.007002||p
534 PERL_MAGIC_overload_elem|5.007002||p
535 PERL_MAGIC_overload_table|5.007002||p
536 PERL_MAGIC_overload|5.007002||p
537 PERL_MAGIC_pos|5.007002||p
538 PERL_MAGIC_qr|5.007002||p
539 PERL_MAGIC_regdata|5.007002||p
540 PERL_MAGIC_regdatum|5.007002||p
541 PERL_MAGIC_regex_global|5.007002||p
542 PERL_MAGIC_shared_scalar|5.007003||p
543 PERL_MAGIC_shared|5.007003||p
544 PERL_MAGIC_sigelem|5.007002||p
545 PERL_MAGIC_sig|5.007002||p
546 PERL_MAGIC_substr|5.007002||p
547 PERL_MAGIC_sv|5.007002||p
548 PERL_MAGIC_taint|5.007002||p
549 PERL_MAGIC_tiedelem|5.007002||p
550 PERL_MAGIC_tiedscalar|5.007002||p
551 PERL_MAGIC_tied|5.007002||p
552 PERL_MAGIC_utf8|5.008001||p
553 PERL_MAGIC_uvar_elem|5.007003||p
554 PERL_MAGIC_uvar|5.007002||p
555 PERL_MAGIC_vec|5.007002||p
556 PERL_MAGIC_vstring|5.008001||p
557 PERL_QUAD_MAX|5.004000||p
558 PERL_QUAD_MIN|5.004000||p
559 PERL_REVISION|5.006000||p
560 PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
561 PERL_SCAN_DISALLOW_PREFIX|5.007003||p
562 PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
563 PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
564 PERL_SHORT_MAX|5.004000||p
565 PERL_SHORT_MIN|5.004000||p
566 PERL_SIGNALS_UNSAFE_FLAG|5.008001||p
567 PERL_SUBVERSION|5.006000||p
568 PERL_UCHAR_MAX|5.004000||p
569 PERL_UCHAR_MIN|5.004000||p
570 PERL_UINT_MAX|5.004000||p
571 PERL_UINT_MIN|5.004000||p
572 PERL_ULONG_MAX|5.004000||p
573 PERL_ULONG_MIN|5.004000||p
574 PERL_UNUSED_DECL|5.007002||p
575 PERL_UQUAD_MAX|5.004000||p
576 PERL_UQUAD_MIN|5.004000||p
577 PERL_USHORT_MAX|5.004000||p
578 PERL_USHORT_MIN|5.004000||p
579 PERL_VERSION|5.006000||p
584 PL_compiling|5.004050||p
585 PL_copline|5.005000||p
586 PL_curcop|5.004050||p
587 PL_curstash|5.004050||p
588 PL_debstash|5.004050||p
590 PL_diehook|5.004050||p
594 PL_hexdigit|5.005000||p
597 PL_modglobal||5.005000|n
599 PL_no_modify|5.006000||p
601 PL_perl_destruct_level|5.004050||p
602 PL_perldb|5.004050||p
603 PL_ppaddr|5.006000||p
604 PL_rsfp_filters|5.004050||p
607 PL_signals|5.008001||p
608 PL_stack_base|5.004050||p
609 PL_stack_sp|5.004050||p
610 PL_stdingv|5.004050||p
611 PL_sv_arenaroot|5.004050||p
612 PL_sv_no|5.004050||pn
613 PL_sv_undef|5.004050||pn
614 PL_sv_yes|5.004050||pn
615 PL_tainted|5.004050||p
616 PL_tainting|5.004050||p
617 POP_MULTICALL||5.009003|
621 POPpbytex||5.007001|n
631 PUSH_MULTICALL||5.009003|
633 PUSHmortal|5.009002||p
639 PerlIO_clearerr||5.007003|
640 PerlIO_close||5.007003|
641 PerlIO_eof||5.007003|
642 PerlIO_error||5.007003|
643 PerlIO_fileno||5.007003|
644 PerlIO_fill||5.007003|
645 PerlIO_flush||5.007003|
646 PerlIO_get_base||5.007003|
647 PerlIO_get_bufsiz||5.007003|
648 PerlIO_get_cnt||5.007003|
649 PerlIO_get_ptr||5.007003|
650 PerlIO_read||5.007003|
651 PerlIO_seek||5.007003|
652 PerlIO_set_cnt||5.007003|
653 PerlIO_set_ptrcnt||5.007003|
654 PerlIO_setlinebuf||5.007003|
655 PerlIO_stderr||5.007003|
656 PerlIO_stdin||5.007003|
657 PerlIO_stdout||5.007003|
658 PerlIO_tell||5.007003|
659 PerlIO_unread||5.007003|
660 PerlIO_write||5.007003|
669 SAVE_DEFSV|5.004050||p
672 START_EXTERN_C|5.005000||p
673 START_MY_CXT|5.007003||p
691 SvGETMAGIC|5.004050||p
694 SvIOK_notUV||5.006000|
696 SvIOK_only_UV||5.006000|
702 SvIV_nomg|5.009001||p
706 SvIsCOW_shared_hash||5.008003|
711 SvMAGIC_set|5.009003||p
727 SvPOK_only_UTF8||5.006000|
732 SvPVX_const|5.009003||p
733 SvPVX_mutable|5.009003||p
735 SvPV_force_nomg|5.007002||p
737 SvPV_nolen|5.006000||p
738 SvPV_nomg|5.007002||p
740 SvPVbyte_force||5.009002|
741 SvPVbyte_nolen||5.006000|
742 SvPVbytex_force||5.006000|
745 SvPVutf8_force||5.006000|
746 SvPVutf8_nolen||5.006000|
747 SvPVutf8x_force||5.006000|
762 SvSTASH_set|5.009003|5.009003|p
764 SvSetMagicSV_nosteal||5.004000|
765 SvSetMagicSV||5.004000|
766 SvSetSV_nosteal||5.004000|
768 SvTAINTED_off||5.004000|
769 SvTAINTED_on||5.004000|
777 SvUTF8_off||5.006000|
782 SvUV_nomg|5.009001||p
795 XCPT_CATCH|5.009002||p
796 XCPT_RETHROW|5.009002||p
797 XCPT_TRY_END|5.009002||p
798 XCPT_TRY_START|5.009002||p
800 XPUSHmortal|5.009002||p
811 XSRETURN_UV|5.008001||p
821 XS_VERSION_BOOTCHECK|||
823 XSprePUSH|5.006000||p
845 apply_attrs_string||5.006001|
848 atfork_lock||5.007003|n
849 atfork_unlock||5.007003|n
850 av_arylen_p||5.009003|
871 block_gimme||5.004000|
875 boot_core_UNIVERSAL|||
877 bytes_from_utf8||5.007001|
878 bytes_to_utf8||5.006001|
880 call_argv|5.006000||p
881 call_atexit||5.006000|
885 call_method|5.006000||p
892 cast_ulong||5.006000|
894 check_type_and_open|||
954 csighandler||5.009003|n
955 custom_op_desc||5.007003|
956 custom_op_name||5.007003|
959 cv_const_sv||5.004000|
969 dMULTICALL||5.009003|
970 dMY_CXT_SV|5.007003||p
979 dUNDERBAR|5.009002||p
989 debprofdump||5.005000|
991 debstackptrs||5.007003|
998 despatch_signals||5.007001|
1009 do_binmode||5.004050|
1018 do_gv_dump||5.006000|
1019 do_gvgv_dump||5.006000|
1020 do_hv_dump||5.006000|
1025 do_magic_dump||5.006000|
1029 do_op_dump||5.006000|
1034 do_pmop_dump||5.006000|
1044 do_sv_dump||5.006000|
1047 do_trans_complex_utf8|||
1049 do_trans_count_utf8|||
1051 do_trans_simple_utf8|||
1063 doing_taint||5.008001|n
1078 dump_eval||5.006000|
1080 dump_form||5.006000|
1081 dump_indent||5.006000|v
1083 dump_packsubs||5.006000|
1086 dump_vindent||5.006000|
1093 fbm_compile||5.005000|
1094 fbm_instr||5.005000|
1096 feature_is_enabled|||
1105 find_rundefsvoffset||5.009002|
1119 fprintf_nocontext|||vn
1120 free_global_struct|||
1121 free_tied_hv_pool|||
1123 gen_constant_list|||
1125 get_context||5.006000|n
1134 get_op_descs||5.005000|
1135 get_op_names||5.005000|
1137 get_ppaddr||5.006000|
1140 getcwd_sv||5.007002|
1145 grok_bin|5.007003||p
1146 grok_hex|5.007003||p
1147 grok_number|5.007002||p
1148 grok_numeric_radix|5.007002||p
1149 grok_oct|5.007003||p
1155 gv_autoload4||5.004000|
1157 gv_const_sv||5.009003|
1159 gv_efullname3||5.004000|
1160 gv_efullname4||5.006001|
1164 gv_fetchmeth_autoload||5.007003|
1165 gv_fetchmethod_autoload||5.004000|
1168 gv_fetchpvn_flags||5.009002|
1170 gv_fetchsv||5.009002|
1171 gv_fullname3||5.004000|
1172 gv_fullname4||5.006001|
1174 gv_handler||5.007001|
1177 gv_stashpvn|5.006000||p
1184 hv_assert||5.009001|
1186 hv_backreferences_p|||
1187 hv_clear_placeholders||5.009001|
1189 hv_delayfree_ent||5.004000|
1191 hv_delete_ent||5.004000|
1193 hv_eiter_p||5.009003|
1194 hv_eiter_set||5.009003|
1195 hv_exists_ent||5.004000|
1198 hv_fetch_ent||5.004000|
1200 hv_free_ent||5.004000|
1202 hv_iterkeysv||5.004000|
1204 hv_iternext_flags||5.008000|
1209 hv_ksplit||5.004000|
1212 hv_name_set||5.009003|
1214 hv_placeholders_get||5.009003|
1215 hv_placeholders_p||5.009003|
1216 hv_placeholders_set||5.009003|
1217 hv_riter_p||5.009003|
1218 hv_riter_set||5.009003|
1219 hv_scalar||5.009001|
1220 hv_store_ent||5.004000|
1221 hv_store_flags||5.008000|
1224 ibcmp_locale||5.004000|
1225 ibcmp_utf8||5.007003|
1229 incpush_if_exists|||
1232 init_argv_symbols|||
1234 init_global_struct|||
1235 init_i18nl10n||5.006000|
1236 init_i18nl14n||5.006000|
1242 init_postdump_symbols|||
1243 init_predump_symbols|||
1244 init_stacks||5.005000|
1261 is_handle_constructor|||
1262 is_list_assignment|||
1263 is_lvalue_sub||5.007001|
1264 is_uni_alnum_lc||5.006000|
1265 is_uni_alnumc_lc||5.006000|
1266 is_uni_alnumc||5.006000|
1267 is_uni_alnum||5.006000|
1268 is_uni_alpha_lc||5.006000|
1269 is_uni_alpha||5.006000|
1270 is_uni_ascii_lc||5.006000|
1271 is_uni_ascii||5.006000|
1272 is_uni_cntrl_lc||5.006000|
1273 is_uni_cntrl||5.006000|
1274 is_uni_digit_lc||5.006000|
1275 is_uni_digit||5.006000|
1276 is_uni_graph_lc||5.006000|
1277 is_uni_graph||5.006000|
1278 is_uni_idfirst_lc||5.006000|
1279 is_uni_idfirst||5.006000|
1280 is_uni_lower_lc||5.006000|
1281 is_uni_lower||5.006000|
1282 is_uni_print_lc||5.006000|
1283 is_uni_print||5.006000|
1284 is_uni_punct_lc||5.006000|
1285 is_uni_punct||5.006000|
1286 is_uni_space_lc||5.006000|
1287 is_uni_space||5.006000|
1288 is_uni_upper_lc||5.006000|
1289 is_uni_upper||5.006000|
1290 is_uni_xdigit_lc||5.006000|
1291 is_uni_xdigit||5.006000|
1292 is_utf8_alnumc||5.006000|
1293 is_utf8_alnum||5.006000|
1294 is_utf8_alpha||5.006000|
1295 is_utf8_ascii||5.006000|
1296 is_utf8_char_slow|||
1297 is_utf8_char||5.006000|
1298 is_utf8_cntrl||5.006000|
1300 is_utf8_digit||5.006000|
1301 is_utf8_graph||5.006000|
1302 is_utf8_idcont||5.008000|
1303 is_utf8_idfirst||5.006000|
1304 is_utf8_lower||5.006000|
1305 is_utf8_mark||5.006000|
1306 is_utf8_print||5.006000|
1307 is_utf8_punct||5.006000|
1308 is_utf8_space||5.006000|
1309 is_utf8_string_loclen||5.009003|
1310 is_utf8_string_loc||5.008001|
1311 is_utf8_string||5.006001|
1312 is_utf8_upper||5.006000|
1313 is_utf8_xdigit||5.006000|
1325 load_module_nocontext|||vn
1326 load_module||5.006000|v
1329 looks_like_number|||
1339 magic_clear_all_env|||
1343 magic_dump||5.006000|
1345 magic_freearylen_p|||
1360 magic_killbackrefs|||
1365 magic_regdata_cnt|||
1366 magic_regdatum_get|||
1367 magic_regdatum_set|||
1369 magic_set_all_env|||
1373 magic_setcollxfrm|||
1400 matcher_matches_sv|||
1416 mg_length||5.005000|
1421 mini_mktime||5.007002|
1423 mode_from_discipline|||
1445 my_failure_exit||5.004000|
1446 my_fflush_all||5.006000|
1469 my_memcmp||5.004000|n
1472 my_pclose||5.004000|
1473 my_popen_list||5.007001|
1476 my_socketpair||5.007003|n
1477 my_sprintf||5.009003|vn
1479 my_strftime||5.007002|
1485 newANONATTRSUB||5.006000|
1490 newATTRSUB||5.006000|
1495 newCONSTSUB|5.006000||p
1500 newGIVENOP||5.009003|
1521 newRV_inc|5.004000||p
1522 newRV_noinc|5.006000||p
1532 newSVpvf_nocontext|||vn
1533 newSVpvf||5.004000|v
1534 newSVpvn_share||5.007001|
1535 newSVpvn|5.006000||p
1542 newWHENOP||5.009003|
1543 newWHILEOP||5.009003|
1544 newXSproto||5.006000|
1546 new_collate||5.006000|
1548 new_ctype||5.006000|
1551 new_numeric||5.006000|
1552 new_stackinfo||5.005000|
1553 new_version||5.009000|
1558 no_bareword_allowed|||
1562 nothreadhook||5.008000|
1574 op_refcnt_lock||5.009002|
1575 op_refcnt_unlock||5.009002|
1577 pMY_CXT_|5.007003||p
1590 pad_compname_type|||
1593 pad_fixup_inner_anons|||
1605 parse_unicode_opts|||
1609 perl_alloc_using|||n
1611 perl_clone_using|||n
1614 perl_destruct||5.007003|n
1616 perl_parse||5.006000|n
1620 pmop_dump||5.006000|
1628 printf_nocontext|||vn
1637 pv_display||5.006000|
1638 pv_uni_display||5.007003|
1642 re_intuit_start||5.006000|
1643 re_intuit_string||5.006000|
1647 reentrant_retry|||vn
1649 ref_array_or_hash|||
1657 regclass_swash||5.007003|
1663 regexec_flags||5.005000|
1669 reginitcolors||5.006000|
1688 require_pv||5.006000|
1693 rsignal_state||5.004000|
1697 runops_debug||5.005000|
1698 runops_standard||5.005000|
1703 safesyscalloc||5.006000|n
1704 safesysfree||5.006000|n
1705 safesysmalloc||5.006000|n
1706 safesysrealloc||5.006000|n
1711 save_aelem||5.004050|
1712 save_alloc||5.006000|
1715 save_bool||5.008001|
1718 save_destructor_x||5.006000|
1719 save_destructor||5.006000|
1723 save_generic_pvref||5.006001|
1724 save_generic_svref||5.005030|
1728 save_helem||5.004050|
1729 save_hints||5.005000|
1738 save_mortalizesv||5.007001|
1741 save_padsv||5.007001|
1743 save_re_context||5.006000|
1746 save_set_svflags||5.009000|
1747 save_shared_pvref||5.007003|
1750 save_threadsv||5.005000|
1751 save_vptr||5.006000|
1754 savesharedpv||5.007003|
1755 savestack_grow_cnt||5.008001|
1779 scan_version||5.009001|
1780 scan_vstring||5.008001|
1783 screaminstr||5.005000|
1787 set_context||5.006000|n
1789 set_numeric_local||5.006000|
1790 set_numeric_radix||5.006000|
1791 set_numeric_standard||5.006000|
1795 share_hek||5.004000|
1803 sortsv_flags||5.009003|
1808 start_subparse||5.004000|
1809 stashpv_hvname_match||5.009003|
1817 str_to_version||5.006000|
1830 sv_2iuv_non_preserve|||
1831 sv_2iv_flags||5.009001|
1835 sv_2pv_flags||5.007002|
1836 sv_2pv_nolen|5.006000||p
1838 sv_2pvbyte|5.006000||p
1839 sv_2pvutf8_nolen||5.006000|
1840 sv_2pvutf8||5.006000|
1842 sv_2uv_flags||5.009001|
1848 sv_cat_decode||5.008001|
1849 sv_catpv_mg|5.006000||p
1850 sv_catpvf_mg_nocontext|||pvn
1851 sv_catpvf_mg|5.006000|5.004000|pv
1852 sv_catpvf_nocontext|||vn
1853 sv_catpvf||5.004000|v
1854 sv_catpvn_flags||5.007002|
1855 sv_catpvn_mg|5.004050||p
1856 sv_catpvn_nomg|5.007002||p
1859 sv_catsv_flags||5.007002|
1860 sv_catsv_mg|5.004050||p
1861 sv_catsv_nomg|5.007002||p
1867 sv_cmp_locale||5.004000|
1870 sv_compile_2op||5.008001|
1871 sv_copypv||5.007003|
1874 sv_derived_from||5.004000|
1879 sv_force_normal_flags||5.007001|
1880 sv_force_normal||5.006000|
1893 sv_len_utf8||5.006000|
1895 sv_magicext||5.007003|
1901 sv_nolocking||5.007003|
1902 sv_nosharing||5.007003|
1903 sv_nounlocking||5.007003|
1906 sv_pos_b2u||5.006000|
1907 sv_pos_u2b||5.006000|
1908 sv_pvbyten_force||5.006000|
1909 sv_pvbyten||5.006000|
1910 sv_pvbyte||5.006000|
1911 sv_pvn_force_flags||5.007002|
1913 sv_pvn_nomg|5.007003||p
1915 sv_pvutf8n_force||5.006000|
1916 sv_pvutf8n||5.006000|
1917 sv_pvutf8||5.006000|
1919 sv_recode_to_utf8||5.007003|
1926 sv_rvweaken||5.006000|
1927 sv_setiv_mg|5.006000||p
1929 sv_setnv_mg|5.006000||p
1931 sv_setpv_mg|5.006000||p
1932 sv_setpvf_mg_nocontext|||pvn
1933 sv_setpvf_mg|5.006000|5.004000|pv
1934 sv_setpvf_nocontext|||vn
1935 sv_setpvf||5.004000|v
1936 sv_setpviv_mg||5.008001|
1937 sv_setpviv||5.008001|
1938 sv_setpvn_mg|5.006000||p
1945 sv_setref_uv||5.007001|
1947 sv_setsv_flags||5.007002|
1948 sv_setsv_mg|5.006000||p
1949 sv_setsv_nomg|5.007002||p
1951 sv_setuv_mg|5.006000||p
1952 sv_setuv|5.006000||p
1953 sv_tainted||5.004000|
1957 sv_uni_display||5.007003|
1959 sv_unref_flags||5.007001|
1961 sv_untaint||5.004000|
1963 sv_usepvn_mg|5.006000||p
1965 sv_utf8_decode||5.006000|
1966 sv_utf8_downgrade||5.006000|
1967 sv_utf8_encode||5.006000|
1968 sv_utf8_upgrade_flags||5.007002|
1969 sv_utf8_upgrade||5.007001|
1971 sv_vcatpvf_mg|5.006000|5.004000|p
1972 sv_vcatpvfn||5.004000|
1973 sv_vcatpvf|5.006000|5.004000|p
1974 sv_vsetpvf_mg|5.006000|5.004000|p
1975 sv_vsetpvfn||5.004000|
1976 sv_vsetpvf|5.006000|5.004000|p
1979 swash_fetch||5.007002|
1981 swash_init||5.006000|
1987 tmps_grow||5.006000|
1991 to_uni_fold||5.007003|
1992 to_uni_lower_lc||5.006000|
1993 to_uni_lower||5.007003|
1994 to_uni_title_lc||5.006000|
1995 to_uni_title||5.007003|
1996 to_uni_upper_lc||5.006000|
1997 to_uni_upper||5.007003|
1998 to_utf8_case||5.007003|
1999 to_utf8_fold||5.007003|
2000 to_utf8_lower||5.007003|
2002 to_utf8_title||5.007003|
2003 to_utf8_upper||5.007003|
2007 too_few_arguments|||
2008 too_many_arguments|||
2012 unpack_str||5.007003|
2013 unpackstring||5.008001|
2014 unshare_hek_or_pvn|||
2016 unsharepvn||5.004000|
2017 unwind_handler_stack|||
2018 upg_version||5.009000|
2020 utf16_to_utf8_reversed||5.006001|
2021 utf16_to_utf8||5.006001|
2022 utf8_distance||5.006000|
2024 utf8_length||5.007001|
2027 utf8_to_bytes||5.006001|
2028 utf8_to_uvchr||5.007001|
2029 utf8_to_uvuni||5.007001|
2031 utf8n_to_uvuni||5.007001|
2033 uvchr_to_utf8_flags||5.007003|
2035 uvuni_to_utf8_flags||5.007003|
2036 uvuni_to_utf8||5.007001|
2043 vdie_croak_common|||
2049 vload_module||5.006000|
2051 vnewSVpvf|5.006000|5.004000|p
2054 vstringify||5.009000|
2060 warner_nocontext|||vn
2073 if (exists $opt{'list-unsupported'}) {
2075 for $f (sort { lc $a cmp lc $b } keys %API) {
2076 next unless $API{$f}{todo};
2077 print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
2082 # Scan for possible replacement candidates
2084 my(%replace, %need, %hints, %depends);
2090 if (m{^\s*\*\s(.*?)\s*$}) {
2091 $hints{$hint} ||= ''; # suppress warning with older perls
2092 $hints{$hint} .= "$1\n";
2098 $hint = $1 if m{^\s*$rccs\sHint:\s+(\w+)\s*$};
2100 $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
2101 $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
2102 $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
2103 $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
2105 if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
2106 push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
2109 $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
2112 if (exists $opt{'api-info'}) {
2115 my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
2116 for $f (sort { lc $a cmp lc $b } keys %API) {
2117 next unless $f =~ /$match/;
2118 print "\n=== $f ===\n\n";
2120 if ($API{$f}{base} || $API{$f}{todo}) {
2121 my $base = format_version($API{$f}{base} || $API{$f}{todo});
2122 print "Supported at least starting from perl-$base.\n";
2125 if ($API{$f}{provided}) {
2126 my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003";
2127 print "Support by $ppport provided back to perl-$todo.\n";
2128 print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f};
2129 print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f};
2130 print "$hints{$f}" if exists $hints{$f};
2134 print "No portability information available.\n";
2142 print "Found no API matching '$opt{'api-info'}'.\n";
2147 if (exists $opt{'list-provided'}) {
2149 for $f (sort { lc $a cmp lc $b } keys %API) {
2150 next unless $API{$f}{provided};
2152 push @flags, 'explicit' if exists $need{$f};
2153 push @flags, 'depend' if exists $depends{$f};
2154 push @flags, 'hint' if exists $hints{$f};
2155 my $flags = @flags ? ' ['.join(', ', @flags).']' : '';
2162 my @srcext = qw( xs c h cc cpp );
2163 my $srcext = join '|', @srcext;
2167 @files = grep { -f && !exists $seen{$_} } map { glob $_ } @ARGV;
2172 File::Find::find(sub {
2173 $File::Find::name =~ /\.($srcext)$/i
2174 and push @files, $File::Find::name;
2178 @files = map { glob "*.$_" } @srcext;
2182 if (!@ARGV || $opt{filter}) {
2184 my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
2186 my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/\.($srcext)$/i;
2187 push @{ $out ? \@out : \@in }, $_;
2189 if (@ARGV && @out) {
2190 warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
2196 die "No input files given!\n";
2199 my(%files, %global, %revreplace);
2200 %revreplace = reverse %replace;
2202 my $patch_opened = 0;
2204 for $filename (@files) {
2205 unless (open IN, "<$filename") {
2206 warn "Unable to read from $filename: $!\n";
2210 info("Scanning $filename ...");
2212 my $c = do { local $/; <IN> };
2215 my %file = (orig => $c, changes => 0);
2217 # temporarily remove C comments from the code
2223 (?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+
2225 (?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+
2229 \*[^*]*\*+(?:[^$ccs][^*]*\*+)* /
2234 defined $2 and push @ccom, $2;
2235 defined $1 ? $1 : "$ccs$#ccom$cce";
2238 $file{ccom} = \@ccom;
2240 $file{has_inc_ppport} = ($c =~ /#.*include.*\Q$ppport\E/);
2244 for $func (keys %API) {
2246 $match .= "|$revreplace{$func}" if exists $revreplace{$func};
2247 if ($c =~ /\b(?:Perl_)?($match)\b/) {
2248 $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
2249 $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
2250 if (exists $API{$func}{provided}) {
2251 if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
2252 $file{uses}{$func}++;
2253 my @deps = rec_depend($func);
2255 $file{uses_deps}{$func} = \@deps;
2257 $file{uses}{$_} = 0 unless exists $file{uses}{$_};
2260 for ($func, @deps) {
2261 if (exists $need{$_}) {
2262 $file{needs}{$_} = 'static';
2267 if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
2268 if ($c =~ /\b$func\b/) {
2269 $file{uses_todo}{$func}++;
2275 while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
2276 if (exists $need{$2}) {
2277 $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
2280 warning("Possibly wrong #define $1 in $filename");
2284 for (qw(uses needs uses_todo needed_global needed_static)) {
2285 for $func (keys %{$file{$_}}) {
2286 push @{$global{$_}{$func}}, $filename;
2290 $files{$filename} = \%file;
2293 # Globally resolve NEED_'s
2295 for $need (keys %{$global{needs}}) {
2296 if (@{$global{needs}{$need}} > 1) {
2297 my @targets = @{$global{needs}{$need}};
2298 my @t = grep $files{$_}{needed_global}{$need}, @targets;
2299 @targets = @t if @t;
2300 @t = grep /\.xs$/i, @targets;
2301 @targets = @t if @t;
2302 my $target = shift @targets;
2303 $files{$target}{needs}{$need} = 'global';
2304 for (@{$global{needs}{$need}}) {
2305 $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
2310 for $filename (@files) {
2311 exists $files{$filename} or next;
2313 info("=== Analyzing $filename ===");
2315 my %file = %{$files{$filename}};
2317 my $c = $file{code};
2319 for $func (sort keys %{$file{uses_Perl}}) {
2320 if ($API{$func}{varargs}) {
2321 my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
2322 { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
2324 warning("Doesn't pass interpreter argument aTHX to Perl_$func");
2325 $file{changes} += $changes;
2329 warning("Uses Perl_$func instead of $func");
2330 $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
2335 for $func (sort keys %{$file{uses_replace}}) {
2336 warning("Uses $func instead of $replace{$func}");
2337 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2340 for $func (sort keys %{$file{uses}}) {
2341 next unless $file{uses}{$func}; # if it's only a dependency
2342 if (exists $file{uses_deps}{$func}) {
2343 diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
2345 elsif (exists $replace{$func}) {
2346 warning("Uses $func instead of $replace{$func}");
2347 $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
2355 for $func (sort keys %{$file{uses_todo}}) {
2356 warning("Uses $func, which may not be portable below perl ",
2357 format_version($API{$func}{todo}));
2360 for $func (sort keys %{$file{needed_static}}) {
2362 if (not exists $file{uses}{$func}) {
2363 $message = "No need to define NEED_$func if $func is never used";
2365 elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
2366 $message = "No need to define NEED_$func when already needed globally";
2370 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
2374 for $func (sort keys %{$file{needed_global}}) {
2376 if (not exists $global{uses}{$func}) {
2377 $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
2379 elsif (exists $file{needs}{$func}) {
2380 if ($file{needs}{$func} eq 'extern') {
2381 $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
2383 elsif ($file{needs}{$func} eq 'static') {
2384 $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
2389 $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
2393 $file{needs_inc_ppport} = keys %{$file{uses}};
2395 if ($file{needs_inc_ppport}) {
2398 for $func (sort keys %{$file{needs}}) {
2399 my $type = $file{needs}{$func};
2400 next if $type eq 'extern';
2401 my $suffix = $type eq 'global' ? '_GLOBAL' : '';
2402 unless (exists $file{"needed_$type"}{$func}) {
2403 if ($type eq 'global') {
2404 diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
2407 diag("File needs $func, adding static request");
2409 $pp .= "#define NEED_$func$suffix\n";
2413 if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
2418 unless ($file{has_inc_ppport}) {
2419 diag("Needs to include '$ppport'");
2420 $pp .= qq(#include "$ppport"\n)
2424 $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
2425 || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
2426 || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
2427 || ($c =~ s/^/$pp/);
2431 if ($file{has_inc_ppport}) {
2432 diag("No need to include '$ppport'");
2433 $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
2437 # put back in our C comments
2440 my @ccom = @{$file{ccom}};
2441 for $ix (0 .. $#ccom) {
2442 if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
2444 $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
2447 $c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
2452 my $s = $cppc != 1 ? 's' : '';
2453 warning("Uses $cppc C++ style comment$s, which is not portable");
2456 if ($file{changes}) {
2457 if (exists $opt{copy}) {
2458 my $newfile = "$filename$opt{copy}";
2460 error("'$newfile' already exists, refusing to write copy of '$filename'");
2464 if (open F, ">$newfile") {
2465 info("Writing copy of '$filename' with changes to '$newfile'");
2470 error("Cannot open '$newfile' for writing: $!");
2474 elsif (exists $opt{patch} || $opt{changes}) {
2475 if (exists $opt{patch}) {
2476 unless ($patch_opened) {
2477 if (open PATCH, ">$opt{patch}") {
2481 error("Cannot open '$opt{patch}' for writing: $!");
2487 mydiff(\*PATCH, $filename, $c);
2491 info("Suggested changes:");
2492 mydiff(\*STDOUT, $filename, $c);
2496 my $s = $file{changes} == 1 ? '' : 's';
2497 info("$file{changes} potentially required change$s detected");
2505 close PATCH if $patch_opened;
2513 my($file, $str) = @_;
2516 if (exists $opt{diff}) {
2517 $diff = run_diff($opt{diff}, $file, $str);
2520 if (!defined $diff and can_use('Text::Diff')) {
2521 $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
2522 $diff = <<HEADER . $diff;
2528 if (!defined $diff) {
2529 $diff = run_diff('diff -u', $file, $str);
2532 if (!defined $diff) {
2533 $diff = run_diff('diff', $file, $str);
2536 if (!defined $diff) {
2537 error("Cannot generate a diff. Please install Text::Diff or use --copy.");
2547 my($prog, $file, $str) = @_;
2548 my $tmp = 'dppptemp';
2553 while (-e "$tmp.$suf") { $suf++ }
2556 if (open F, ">$tmp") {
2560 if (open F, "$prog $file $tmp |") {
2562 s/\Q$tmp\E/$file.patched/;
2573 error("Cannot open '$tmp' for writing: $!");
2589 return () unless exists $depends{$func};
2590 grep !$seen{$_}++, map { ($_, rec_depend($_)) } @{$depends{$func}};
2597 if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
2598 return ($1, $2, $3);
2600 elsif ($ver !~ /^\d+\.[\d_]+$/) {
2601 die "cannot parse version '$ver'\n";
2605 $ver =~ s/$/000000/;
2607 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2612 if ($r < 5 || ($r == 5 && $v < 6)) {
2614 die "cannot parse version '$ver'\n";
2618 return ($r, $v, $s);
2625 $ver =~ s/$/000000/;
2626 my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
2631 if ($r < 5 || ($r == 5 && $v < 6)) {
2633 die "invalid version '$ver'\n";
2637 $ver = sprintf "%d.%03d", $r, $v;
2638 $s > 0 and $ver .= sprintf "_%02d", $s;
2643 return sprintf "%d.%d.%d", $r, $v, $s;
2648 $opt{quiet} and return;
2654 $opt{quiet} and return;
2655 $opt{diag} and print @_, "\n";
2660 $opt{quiet} and return;
2661 print "*** ", @_, "\n";
2666 print "*** ERROR: ", @_, "\n";
2672 $opt{quiet} and return;
2673 $opt{hints} or return;
2675 exists $hints{$func} or return;
2676 $given_hints{$func}++ and return;
2677 my $hint = $hints{$func};
2679 print " --- hint for $func ---\n", $hint;
2684 my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
2685 my %M = ( 'I' => '*' );
2686 $usage =~ s/^\s*perl\s+\S+/$^X $0/;
2687 $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
2693 See perldoc $0 for details.
2702 my $self = do { local(@ARGV,$/)=($0); <> };
2703 $self =~ s/^$HS+Do NOT edit.*?(?=^-)//ms;
2704 $self =~ s/^SKIP.*(?=^__DATA__)/SKIP
2705 if (\@ARGV && \$ARGV[0] eq '--unstrip') {
2706 eval { require Devel::PPPort };
2707 \$@ and die "Cannot require Devel::PPPort, please install.\\n";
2708 Devel::PPPort::WriteFile(\$0);
2713 Sorry, but this is a stripped version of \$0.
2715 To be able to use its original script and doc functionality,
2716 please try to regenerate this file using:
2723 open OUT, ">$0" or die "cannot strip $0: $!\n";
2732 #ifndef _P_P_PORTABILITY_H_
2733 #define _P_P_PORTABILITY_H_
2735 #ifndef DPPP_NAMESPACE
2736 # define DPPP_NAMESPACE DPPP_
2739 #define DPPP_CAT2(x,y) CAT2(x,y)
2740 #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
2742 #ifndef PERL_REVISION
2743 # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
2744 # define PERL_PATCHLEVEL_H_IMPLICIT
2745 # include <patchlevel.h>
2747 # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
2748 # include <could_not_find_Perl_patchlevel.h>
2750 # ifndef PERL_REVISION
2751 # define PERL_REVISION (5)
2753 # define PERL_VERSION PATCHLEVEL
2754 # define PERL_SUBVERSION SUBVERSION
2755 /* Replace PERL_PATCHLEVEL with PERL_VERSION */
2760 #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
2762 /* It is very unlikely that anyone will try to use this with Perl 6
2763 (or greater), but who knows.
2765 #if PERL_REVISION != 5
2766 # error ppport.h only works with Perl version 5
2767 #endif /* PERL_REVISION != 5 */
2770 # include <limits.h>
2773 #ifndef PERL_UCHAR_MIN
2774 # define PERL_UCHAR_MIN ((unsigned char)0)
2777 #ifndef PERL_UCHAR_MAX
2779 # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
2782 # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
2784 # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
2789 #ifndef PERL_USHORT_MIN
2790 # define PERL_USHORT_MIN ((unsigned short)0)
2793 #ifndef PERL_USHORT_MAX
2795 # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
2798 # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
2801 # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
2803 # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
2809 #ifndef PERL_SHORT_MAX
2811 # define PERL_SHORT_MAX ((short)SHORT_MAX)
2813 # ifdef MAXSHORT /* Often used in <values.h> */
2814 # define PERL_SHORT_MAX ((short)MAXSHORT)
2817 # define PERL_SHORT_MAX ((short)SHRT_MAX)
2819 # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
2825 #ifndef PERL_SHORT_MIN
2827 # define PERL_SHORT_MIN ((short)SHORT_MIN)
2830 # define PERL_SHORT_MIN ((short)MINSHORT)
2833 # define PERL_SHORT_MIN ((short)SHRT_MIN)
2835 # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
2841 #ifndef PERL_UINT_MAX
2843 # define PERL_UINT_MAX ((unsigned int)UINT_MAX)
2846 # define PERL_UINT_MAX ((unsigned int)MAXUINT)
2848 # define PERL_UINT_MAX (~(unsigned int)0)
2853 #ifndef PERL_UINT_MIN
2854 # define PERL_UINT_MIN ((unsigned int)0)
2857 #ifndef PERL_INT_MAX
2859 # define PERL_INT_MAX ((int)INT_MAX)
2861 # ifdef MAXINT /* Often used in <values.h> */
2862 # define PERL_INT_MAX ((int)MAXINT)
2864 # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
2869 #ifndef PERL_INT_MIN
2871 # define PERL_INT_MIN ((int)INT_MIN)
2874 # define PERL_INT_MIN ((int)MININT)
2876 # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
2881 #ifndef PERL_ULONG_MAX
2883 # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
2886 # define PERL_ULONG_MAX ((unsigned long)MAXULONG)
2888 # define PERL_ULONG_MAX (~(unsigned long)0)
2893 #ifndef PERL_ULONG_MIN
2894 # define PERL_ULONG_MIN ((unsigned long)0L)
2897 #ifndef PERL_LONG_MAX
2899 # define PERL_LONG_MAX ((long)LONG_MAX)
2902 # define PERL_LONG_MAX ((long)MAXLONG)
2904 # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
2909 #ifndef PERL_LONG_MIN
2911 # define PERL_LONG_MIN ((long)LONG_MIN)
2914 # define PERL_LONG_MIN ((long)MINLONG)
2916 # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
2921 #if defined(HAS_QUAD) && (defined(convex) || defined(uts))
2922 # ifndef PERL_UQUAD_MAX
2923 # ifdef ULONGLONG_MAX
2924 # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
2926 # ifdef MAXULONGLONG
2927 # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
2929 # define PERL_UQUAD_MAX (~(unsigned long long)0)
2934 # ifndef PERL_UQUAD_MIN
2935 # define PERL_UQUAD_MIN ((unsigned long long)0L)
2938 # ifndef PERL_QUAD_MAX
2939 # ifdef LONGLONG_MAX
2940 # define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
2943 # define PERL_QUAD_MAX ((long long)MAXLONGLONG)
2945 # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
2950 # ifndef PERL_QUAD_MIN
2951 # ifdef LONGLONG_MIN
2952 # define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
2955 # define PERL_QUAD_MIN ((long long)MINLONGLONG)
2957 # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
2963 /* This is based on code from 5.003 perl.h */
2971 # define IV_MIN PERL_INT_MIN
2975 # define IV_MAX PERL_INT_MAX
2979 # define UV_MIN PERL_UINT_MIN
2983 # define UV_MAX PERL_UINT_MAX
2988 # define IVSIZE INTSIZE
2993 # if defined(convex) || defined(uts)
2995 # define IVTYPE long long
2999 # define IV_MIN PERL_QUAD_MIN
3003 # define IV_MAX PERL_QUAD_MAX
3007 # define UV_MIN PERL_UQUAD_MIN
3011 # define UV_MAX PERL_UQUAD_MAX
3014 # ifdef LONGLONGSIZE
3016 # define IVSIZE LONGLONGSIZE
3022 # define IVTYPE long
3026 # define IV_MIN PERL_LONG_MIN
3030 # define IV_MAX PERL_LONG_MAX
3034 # define UV_MIN PERL_ULONG_MIN
3038 # define UV_MAX PERL_ULONG_MAX
3043 # define IVSIZE LONGSIZE
3053 #ifndef PERL_QUAD_MIN
3054 # define PERL_QUAD_MIN IV_MIN
3057 #ifndef PERL_QUAD_MAX
3058 # define PERL_QUAD_MAX IV_MAX
3061 #ifndef PERL_UQUAD_MIN
3062 # define PERL_UQUAD_MIN UV_MIN
3065 #ifndef PERL_UQUAD_MAX
3066 # define PERL_UQUAD_MAX UV_MAX
3071 # define IVTYPE long
3075 # define IV_MIN PERL_LONG_MIN
3079 # define IV_MAX PERL_LONG_MAX
3083 # define UV_MIN PERL_ULONG_MIN
3087 # define UV_MAX PERL_ULONG_MAX
3094 # define IVSIZE LONGSIZE
3096 # define IVSIZE 4 /* A bold guess, but the best we can make. */
3100 # define UVTYPE unsigned IVTYPE
3104 # define UVSIZE IVSIZE
3107 # define sv_setuv(sv, uv) \
3110 if (TeMpUv <= IV_MAX) \
3111 sv_setiv(sv, TeMpUv); \
3113 sv_setnv(sv, (double)TeMpUv); \
3117 # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
3120 # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
3124 # define SvUVX(sv) ((UV)SvIVX(sv))
3128 # define SvUVXx(sv) SvUVX(sv)
3132 # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
3136 # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))
3140 * Always use the SvUVx() macro instead of sv_uv().
3143 # define sv_uv(sv) SvUVx(sv)
3146 # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
3150 # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
3153 # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
3157 # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
3162 # define memNE(s1,s2,l) (memcmp(s1,s2,l))
3166 # define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
3171 # define memNE(s1,s2,l) (bcmp(s1,s2,l))
3175 # define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
3180 # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
3184 # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
3189 # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
3194 # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d)
3199 # define Poison(d,n,t) (void)memset((char*)(d), 0xAB, (n) * sizeof(t))
3202 # define Newx(v,n,t) New(0,v,n,t)
3206 # define Newxc(v,n,t,c) Newc(0,v,n,t,c)
3210 # define Newxz(v,n,t) Newz(0,v,n,t)
3213 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)))
3215 # define PL_DBsingle DBsingle
3216 # define PL_DBsub DBsub
3218 # define PL_compiling compiling
3219 # define PL_copline copline
3220 # define PL_curcop curcop
3221 # define PL_curstash curstash
3222 # define PL_debstash debstash
3223 # define PL_defgv defgv
3224 # define PL_diehook diehook
3225 # define PL_dirty dirty
3226 # define PL_dowarn dowarn
3227 # define PL_errgv errgv
3228 # define PL_hexdigit hexdigit
3229 # define PL_hints hints
3231 # define PL_no_modify no_modify
3232 # define PL_perl_destruct_level perl_destruct_level
3233 # define PL_perldb perldb
3234 # define PL_ppaddr ppaddr
3235 # define PL_rsfp_filters rsfp_filters
3236 # define PL_rsfp rsfp
3237 # define PL_stack_base stack_base
3238 # define PL_stack_sp stack_sp
3239 # define PL_stdingv stdingv
3240 # define PL_sv_arenaroot sv_arenaroot
3241 # define PL_sv_no sv_no
3242 # define PL_sv_undef sv_undef
3243 # define PL_sv_yes sv_yes
3244 # define PL_tainted tainted
3245 # define PL_tainting tainting
3249 #ifndef PERL_UNUSED_DECL
3250 # ifdef HASATTRIBUTE
3251 # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
3252 # define PERL_UNUSED_DECL
3254 # define PERL_UNUSED_DECL __attribute__((unused))
3257 # define PERL_UNUSED_DECL
3261 # define NOOP (void)0
3265 # define dNOOP extern int Perl___notused PERL_UNUSED_DECL
3269 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
3270 # define NVTYPE long double
3272 # define NVTYPE double
3279 # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
3281 # define INT2PTR(any,d) (any)(d)
3283 # if PTRSIZE == LONGSIZE
3284 # define PTRV unsigned long
3286 # define PTRV unsigned
3288 # define INT2PTR(any,d) (any)(PTRV)(d)
3291 # define NUM2PTR(any,d) (any)(PTRV)(d)
3292 # define PTR2IV(p) INT2PTR(IV,p)
3293 # define PTR2UV(p) INT2PTR(UV,p)
3294 # define PTR2NV(p) NUM2PTR(NV,p)
3296 # if PTRSIZE == LONGSIZE
3297 # define PTR2ul(p) (unsigned long)(p)
3299 # define PTR2ul(p) INT2PTR(unsigned long,p)
3302 #endif /* !INT2PTR */
3304 #undef START_EXTERN_C
3308 # define START_EXTERN_C extern "C" {
3309 # define END_EXTERN_C }
3310 # define EXTERN_C extern "C"
3312 # define START_EXTERN_C
3313 # define END_EXTERN_C
3314 # define EXTERN_C extern
3317 #ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
3318 # if defined(__STRICT_ANSI__) && defined(PERL_GCC_PEDANTIC)
3319 # define PERL_GCC_BRACE_GROUPS_FORBIDDEN
3325 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
3326 # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
3329 # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
3330 # define STMT_START if (1)
3331 # define STMT_END else (void)0
3333 # define STMT_START do
3334 # define STMT_END while (0)
3338 # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
3341 /* DEFSV appears first in 5.004_56 */
3343 # define DEFSV GvSV(PL_defgv)
3347 # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
3350 /* Older perls (<=5.003) lack AvFILLp */
3352 # define AvFILLp AvFILL
3355 # define ERRSV get_sv("@",FALSE)
3358 # define newSVpvn(data,len) ((data) \
3359 ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
3363 /* Hint: gv_stashpvn
3364 * This function's backport doesn't support the length parameter, but
3365 * rather ignores it. Portability can only be ensured if the length
3366 * parameter is used for speed reasons, but the length can always be
3367 * correctly computed from the string argument.
3370 # define gv_stashpvn(str,len,create) gv_stashpv(str,create)
3375 # define get_cv perl_get_cv
3379 # define get_sv perl_get_sv
3383 # define get_av perl_get_av
3387 # define get_hv perl_get_hv
3392 # define dUNDERBAR dNOOP
3396 # define UNDERBAR DEFSV
3399 # define dAX I32 ax = MARK - PL_stack_base + 1
3403 # define dITEMS I32 items = SP - MARK
3406 # define dXSTARG SV * targ = sv_newmortal()
3409 # define dAXMARK I32 ax = POPMARK; \
3410 register SV ** const mark = PL_stack_base + ax++
3413 # define XSprePUSH (sp = PL_stack_base + ax - 1)
3416 #if ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 0)))
3418 # define XSRETURN(off) \
3420 PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
3425 #ifndef PERL_SIGNALS_UNSAFE_FLAG
3427 #define PERL_SIGNALS_UNSAFE_FLAG 0x0001
3429 #if defined(NEED_PL_signals)
3430 static U32 DPPP_(my_PL_signals) = PERL_SIGNALS_UNSAFE_FLAG;
3431 #elif defined(NEED_PL_signals_GLOBAL)
3432 U32 DPPP_(my_PL_signals) = PERL_SIGNALS_UNSAFE_FLAG;
3434 extern U32 DPPP_(my_PL_signals);
3436 #define PL_signals DPPP_(my_PL_signals)
3447 # define dTHXa(x) dNOOP
3465 # define dTHXoa(x) dTHXa(x)
3468 # define PUSHmortal PUSHs(sv_newmortal())
3472 # define mPUSHp(p,l) sv_setpvn_mg(PUSHmortal, (p), (l))
3476 # define mPUSHn(n) sv_setnv_mg(PUSHmortal, (NV)(n))
3480 # define mPUSHi(i) sv_setiv_mg(PUSHmortal, (IV)(i))
3484 # define mPUSHu(u) sv_setuv_mg(PUSHmortal, (UV)(u))
3487 # define XPUSHmortal XPUSHs(sv_newmortal())
3491 # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
3495 # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
3499 # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
3503 # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
3508 # define call_sv perl_call_sv
3512 # define call_pv perl_call_pv
3516 # define call_argv perl_call_argv
3520 # define call_method perl_call_method
3523 # define eval_sv perl_eval_sv
3528 /* Replace perl_eval_pv with eval_pv */
3529 /* eval_pv depends on eval_sv */
3532 #if defined(NEED_eval_pv)
3533 static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
3536 extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
3542 #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
3543 #define Perl_eval_pv DPPP_(my_eval_pv)
3545 #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
3548 DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
3551 SV* sv = newSVpv(p, 0);
3554 eval_sv(sv, G_SCALAR);
3561 if (croak_on_error && SvTRUE(GvSV(errgv)))
3562 croak(SvPVx(GvSV(errgv), na));
3570 # define newRV_inc(sv) newRV(sv) /* Replace */
3574 #if defined(NEED_newRV_noinc)
3575 static SV * DPPP_(my_newRV_noinc)(SV *sv);
3578 extern SV * DPPP_(my_newRV_noinc)(SV *sv);
3584 #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
3585 #define Perl_newRV_noinc DPPP_(my_newRV_noinc)
3587 #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
3589 DPPP_(my_newRV_noinc)(SV *sv)
3591 SV *rv = (SV *)newRV(sv);
3598 /* Hint: newCONSTSUB
3599 * Returns a CV* as of perl-5.7.1. This return value is not supported
3603 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
3604 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))) && ((PERL_VERSION != 4) || (PERL_SUBVERSION != 5))
3605 #if defined(NEED_newCONSTSUB)
3606 static void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
3609 extern void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
3615 #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
3616 #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
3618 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
3621 DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv)
3623 U32 oldhints = PL_hints;
3624 HV *old_cop_stash = PL_curcop->cop_stash;
3625 HV *old_curstash = PL_curstash;
3626 line_t oldline = PL_curcop->cop_line;
3627 PL_curcop->cop_line = PL_copline;
3629 PL_hints &= ~HINT_BLOCK_SCOPE;
3631 PL_curstash = PL_curcop->cop_stash = stash;
3635 #if ((PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)))
3637 #elif ((PERL_VERSION == 3) && (PERL_SUBVERSION == 22))
3639 #else /* 5.003_23 onwards */
3640 start_subparse(FALSE, 0),
3643 newSVOP(OP_CONST, 0, newSVpv(name,0)),
3644 newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
3645 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
3648 PL_hints = oldhints;
3649 PL_curcop->cop_stash = old_cop_stash;
3650 PL_curstash = old_curstash;
3651 PL_curcop->cop_line = oldline;
3657 * Boilerplate macros for initializing and accessing interpreter-local
3658 * data from C. All statics in extensions should be reworked to use
3659 * this, if you want to make the extension thread-safe. See ext/re/re.xs
3660 * for an example of the use of these macros.
3662 * Code that uses these macros is responsible for the following:
3663 * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
3664 * 2. Declare a typedef named my_cxt_t that is a structure that contains
3665 * all the data that needs to be interpreter-local.
3666 * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
3667 * 4. Use the MY_CXT_INIT macro such that it is called exactly once
3668 * (typically put in the BOOT: section).
3669 * 5. Use the members of the my_cxt_t structure everywhere as
3671 * 6. Use the dMY_CXT macro (a declaration) in all the functions that
3675 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
3676 defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
3678 #ifndef START_MY_CXT
3680 /* This must appear in all extensions that define a my_cxt_t structure,
3681 * right after the definition (i.e. at file scope). The non-threads
3682 * case below uses it to declare the data as static. */
3683 #define START_MY_CXT
3685 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 68)))
3686 /* Fetches the SV that keeps the per-interpreter data. */
3687 #define dMY_CXT_SV \
3688 SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
3689 #else /* >= perl5.004_68 */
3690 #define dMY_CXT_SV \
3691 SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
3692 sizeof(MY_CXT_KEY)-1, TRUE)
3693 #endif /* < perl5.004_68 */
3695 /* This declaration should be used within all functions that use the
3696 * interpreter-local data. */
3699 my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
3701 /* Creates and zeroes the per-interpreter data.
3702 * (We allocate my_cxtp in a Perl SV so that it will be released when
3703 * the interpreter goes away.) */
3704 #define MY_CXT_INIT \
3706 /* newSV() allocates one more than needed */ \
3707 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
3708 Zero(my_cxtp, 1, my_cxt_t); \
3709 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
3711 /* This macro must be used to access members of the my_cxt_t structure.
3712 * e.g. MYCXT.some_data */
3713 #define MY_CXT (*my_cxtp)
3715 /* Judicious use of these macros can reduce the number of times dMY_CXT
3716 * is used. Use is similar to pTHX, aTHX etc. */
3717 #define pMY_CXT my_cxt_t *my_cxtp
3718 #define pMY_CXT_ pMY_CXT,
3719 #define _pMY_CXT ,pMY_CXT
3720 #define aMY_CXT my_cxtp
3721 #define aMY_CXT_ aMY_CXT,
3722 #define _aMY_CXT ,aMY_CXT
3724 #endif /* START_MY_CXT */
3726 #ifndef MY_CXT_CLONE
3727 /* Clones the per-interpreter data. */
3728 #define MY_CXT_CLONE \
3730 my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
3731 Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
3732 sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
3735 #else /* single interpreter */
3737 #ifndef START_MY_CXT
3739 #define START_MY_CXT static my_cxt_t my_cxt;
3740 #define dMY_CXT_SV dNOOP
3741 #define dMY_CXT dNOOP
3742 #define MY_CXT_INIT NOOP
3743 #define MY_CXT my_cxt
3745 #define pMY_CXT void
3752 #endif /* START_MY_CXT */
3754 #ifndef MY_CXT_CLONE
3755 #define MY_CXT_CLONE NOOP
3761 # if IVSIZE == LONGSIZE
3768 # if IVSIZE == INTSIZE
3779 # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
3780 defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */
3781 # define NVef PERL_PRIeldbl
3782 # define NVff PERL_PRIfldbl
3783 # define NVgf PERL_PRIgldbl
3793 #if defined(NEED_sv_2pv_nolen)
3794 static char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
3797 extern char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
3801 # undef sv_2pv_nolen
3803 #define sv_2pv_nolen(a) DPPP_(my_sv_2pv_nolen)(aTHX_ a)
3804 #define Perl_sv_2pv_nolen DPPP_(my_sv_2pv_nolen)
3806 #if defined(NEED_sv_2pv_nolen) || defined(NEED_sv_2pv_nolen_GLOBAL)
3809 DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv)
3812 return sv_2pv(sv, &n_a);
3817 /* Hint: sv_2pv_nolen
3818 * Use the SvPV_nolen() macro instead of sv_2pv_nolen().
3821 /* SvPV_nolen depends on sv_2pv_nolen */
3822 #define SvPV_nolen(sv) \
3823 ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
3824 ? SvPVX(sv) : sv_2pv_nolen(sv))
3831 * Does not work in perl-5.6.1, ppport.h implements a version
3832 * borrowed from perl-5.7.3.
3835 #if ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 0)))
3837 #if defined(NEED_sv_2pvbyte)
3838 static char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
3841 extern char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
3847 #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
3848 #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
3850 #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
3853 DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp)
3855 sv_utf8_downgrade(sv,0);
3856 return SvPV(sv,*lp);
3862 * Use the SvPVbyte() macro instead of sv_2pvbyte().
3867 /* SvPVbyte depends on sv_2pvbyte */
3868 #define SvPVbyte(sv, lp) \
3869 ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
3870 ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
3876 # define SvPVbyte SvPV
3877 # define sv_2pvbyte sv_2pv
3881 /* sv_2pvbyte_nolen depends on sv_2pv_nolen */
3882 #ifndef sv_2pvbyte_nolen
3883 # define sv_2pvbyte_nolen sv_2pv_nolen
3887 * Always use the SvPV() macro instead of sv_pvn().
3890 # define sv_pvn(sv, len) SvPV(sv, len)
3893 /* Hint: sv_pvn_force
3894 * Always use the SvPV_force() macro instead of sv_pvn_force().
3896 #ifndef sv_pvn_force
3897 # define sv_pvn_force(sv, len) SvPV_force(sv, len)
3900 # define SvMAGIC_set(sv, val) \
3901 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
3902 (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END
3905 #if ((PERL_VERSION < 9) || ((PERL_VERSION == 9) && (PERL_SUBVERSION < 3)))
3907 # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv)))
3910 #ifndef SvPVX_mutable
3911 # define SvPVX_mutable(sv) (0 + SvPVX(sv))
3914 # define SvRV_set(sv, val) \
3915 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
3916 (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END
3921 # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv))
3924 #ifndef SvPVX_mutable
3925 # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv)
3928 # define SvRV_set(sv, val) \
3929 STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
3930 ((sv)->sv_u.svu_rv = (val)); } STMT_END
3935 # define SvSTASH_set(sv, val) \
3936 STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
3937 (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END
3940 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 0)))
3942 # define SvUV_set(sv, val) \
3943 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
3944 (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END
3949 # define SvUV_set(sv, val) \
3950 STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
3951 (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END
3956 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(vnewSVpvf)
3957 #if defined(NEED_vnewSVpvf)
3958 static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
3961 extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
3967 #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
3968 #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
3970 #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
3973 DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
3975 register SV *sv = newSV(0);
3976 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
3983 /* sv_vcatpvf depends on sv_vcatpvfn */
3984 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf)
3985 # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
3988 /* sv_vsetpvf depends on sv_vsetpvfn */
3989 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf)
3990 # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
3993 /* sv_catpvf_mg depends on sv_vcatpvfn, sv_catpvf_mg_nocontext */
3994 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg)
3995 #if defined(NEED_sv_catpvf_mg)
3996 static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
3999 extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4002 #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
4004 #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
4007 DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4010 va_start(args, pat);
4011 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4019 /* sv_catpvf_mg_nocontext depends on sv_vcatpvfn */
4020 #ifdef PERL_IMPLICIT_CONTEXT
4021 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg_nocontext)
4022 #if defined(NEED_sv_catpvf_mg_nocontext)
4023 static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4026 extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4029 #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4030 #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4032 #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
4035 DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4039 va_start(args, pat);
4040 sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4049 #ifndef sv_catpvf_mg
4050 # ifdef PERL_IMPLICIT_CONTEXT
4051 # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
4053 # define sv_catpvf_mg Perl_sv_catpvf_mg
4057 /* sv_vcatpvf_mg depends on sv_vcatpvfn */
4058 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf_mg)
4059 # define sv_vcatpvf_mg(sv, pat, args) \
4061 sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
4066 /* sv_setpvf_mg depends on sv_vsetpvfn, sv_setpvf_mg_nocontext */
4067 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg)
4068 #if defined(NEED_sv_setpvf_mg)
4069 static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4072 extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4075 #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
4077 #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
4080 DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4083 va_start(args, pat);
4084 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4092 /* sv_setpvf_mg_nocontext depends on sv_vsetpvfn */
4093 #ifdef PERL_IMPLICIT_CONTEXT
4094 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg_nocontext)
4095 #if defined(NEED_sv_setpvf_mg_nocontext)
4096 static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4099 extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4102 #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4103 #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4105 #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
4108 DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4112 va_start(args, pat);
4113 sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4122 #ifndef sv_setpvf_mg
4123 # ifdef PERL_IMPLICIT_CONTEXT
4124 # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
4126 # define sv_setpvf_mg Perl_sv_setpvf_mg
4130 /* sv_vsetpvf_mg depends on sv_vsetpvfn */
4131 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf_mg)
4132 # define sv_vsetpvf_mg(sv, pat, args) \
4134 sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
4139 # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
4141 #ifndef PERL_MAGIC_sv
4142 # define PERL_MAGIC_sv '\0'
4145 #ifndef PERL_MAGIC_overload
4146 # define PERL_MAGIC_overload 'A'
4149 #ifndef PERL_MAGIC_overload_elem
4150 # define PERL_MAGIC_overload_elem 'a'
4153 #ifndef PERL_MAGIC_overload_table
4154 # define PERL_MAGIC_overload_table 'c'
4157 #ifndef PERL_MAGIC_bm
4158 # define PERL_MAGIC_bm 'B'
4161 #ifndef PERL_MAGIC_regdata
4162 # define PERL_MAGIC_regdata 'D'
4165 #ifndef PERL_MAGIC_regdatum
4166 # define PERL_MAGIC_regdatum 'd'
4169 #ifndef PERL_MAGIC_env
4170 # define PERL_MAGIC_env 'E'
4173 #ifndef PERL_MAGIC_envelem
4174 # define PERL_MAGIC_envelem 'e'
4177 #ifndef PERL_MAGIC_fm
4178 # define PERL_MAGIC_fm 'f'
4181 #ifndef PERL_MAGIC_regex_global
4182 # define PERL_MAGIC_regex_global 'g'
4185 #ifndef PERL_MAGIC_isa
4186 # define PERL_MAGIC_isa 'I'
4189 #ifndef PERL_MAGIC_isaelem
4190 # define PERL_MAGIC_isaelem 'i'
4193 #ifndef PERL_MAGIC_nkeys
4194 # define PERL_MAGIC_nkeys 'k'
4197 #ifndef PERL_MAGIC_dbfile
4198 # define PERL_MAGIC_dbfile 'L'
4201 #ifndef PERL_MAGIC_dbline
4202 # define PERL_MAGIC_dbline 'l'
4205 #ifndef PERL_MAGIC_mutex
4206 # define PERL_MAGIC_mutex 'm'
4209 #ifndef PERL_MAGIC_shared
4210 # define PERL_MAGIC_shared 'N'
4213 #ifndef PERL_MAGIC_shared_scalar
4214 # define PERL_MAGIC_shared_scalar 'n'
4217 #ifndef PERL_MAGIC_collxfrm
4218 # define PERL_MAGIC_collxfrm 'o'
4221 #ifndef PERL_MAGIC_tied
4222 # define PERL_MAGIC_tied 'P'
4225 #ifndef PERL_MAGIC_tiedelem
4226 # define PERL_MAGIC_tiedelem 'p'
4229 #ifndef PERL_MAGIC_tiedscalar
4230 # define PERL_MAGIC_tiedscalar 'q'
4233 #ifndef PERL_MAGIC_qr
4234 # define PERL_MAGIC_qr 'r'
4237 #ifndef PERL_MAGIC_sig
4238 # define PERL_MAGIC_sig 'S'
4241 #ifndef PERL_MAGIC_sigelem
4242 # define PERL_MAGIC_sigelem 's'
4245 #ifndef PERL_MAGIC_taint
4246 # define PERL_MAGIC_taint 't'
4249 #ifndef PERL_MAGIC_uvar
4250 # define PERL_MAGIC_uvar 'U'
4253 #ifndef PERL_MAGIC_uvar_elem
4254 # define PERL_MAGIC_uvar_elem 'u'
4257 #ifndef PERL_MAGIC_vstring
4258 # define PERL_MAGIC_vstring 'V'
4261 #ifndef PERL_MAGIC_vec
4262 # define PERL_MAGIC_vec 'v'
4265 #ifndef PERL_MAGIC_utf8
4266 # define PERL_MAGIC_utf8 'w'
4269 #ifndef PERL_MAGIC_substr
4270 # define PERL_MAGIC_substr 'x'
4273 #ifndef PERL_MAGIC_defelem
4274 # define PERL_MAGIC_defelem 'y'
4277 #ifndef PERL_MAGIC_glob
4278 # define PERL_MAGIC_glob '*'
4281 #ifndef PERL_MAGIC_arylen
4282 # define PERL_MAGIC_arylen '#'
4285 #ifndef PERL_MAGIC_pos
4286 # define PERL_MAGIC_pos '.'
4289 #ifndef PERL_MAGIC_backref
4290 # define PERL_MAGIC_backref '<'
4293 #ifndef PERL_MAGIC_ext
4294 # define PERL_MAGIC_ext '~'
4297 /* That's the best we can do... */
4298 #ifndef SvPV_force_nomg
4299 # define SvPV_force_nomg SvPV_force
4303 # define SvPV_nomg SvPV
4306 #ifndef sv_catpvn_nomg
4307 # define sv_catpvn_nomg sv_catpvn
4310 #ifndef sv_catsv_nomg
4311 # define sv_catsv_nomg sv_catsv
4314 #ifndef sv_setsv_nomg
4315 # define sv_setsv_nomg sv_setsv
4319 # define sv_pvn_nomg sv_pvn
4323 # define SvIV_nomg SvIV
4327 # define SvUV_nomg SvUV
4331 # define sv_catpv_mg(sv, ptr) \
4334 sv_catpv(TeMpSv,ptr); \
4335 SvSETMAGIC(TeMpSv); \
4339 #ifndef sv_catpvn_mg
4340 # define sv_catpvn_mg(sv, ptr, len) \
4343 sv_catpvn(TeMpSv,ptr,len); \
4344 SvSETMAGIC(TeMpSv); \
4349 # define sv_catsv_mg(dsv, ssv) \
4352 sv_catsv(TeMpSv,ssv); \
4353 SvSETMAGIC(TeMpSv); \
4358 # define sv_setiv_mg(sv, i) \
4361 sv_setiv(TeMpSv,i); \
4362 SvSETMAGIC(TeMpSv); \
4367 # define sv_setnv_mg(sv, num) \
4370 sv_setnv(TeMpSv,num); \
4371 SvSETMAGIC(TeMpSv); \
4376 # define sv_setpv_mg(sv, ptr) \
4379 sv_setpv(TeMpSv,ptr); \
4380 SvSETMAGIC(TeMpSv); \
4384 #ifndef sv_setpvn_mg
4385 # define sv_setpvn_mg(sv, ptr, len) \
4388 sv_setpvn(TeMpSv,ptr,len); \
4389 SvSETMAGIC(TeMpSv); \
4394 # define sv_setsv_mg(dsv, ssv) \
4397 sv_setsv(TeMpSv,ssv); \
4398 SvSETMAGIC(TeMpSv); \
4403 # define sv_setuv_mg(sv, i) \
4406 sv_setuv(TeMpSv,i); \
4407 SvSETMAGIC(TeMpSv); \
4411 #ifndef sv_usepvn_mg
4412 # define sv_usepvn_mg(sv, ptr, len) \
4415 sv_usepvn(TeMpSv,ptr,len); \
4416 SvSETMAGIC(TeMpSv); \
4422 # define CopFILE(c) ((c)->cop_file)
4426 # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
4430 # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
4434 # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
4438 # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
4442 # define CopSTASHPV(c) ((c)->cop_stashpv)
4445 #ifndef CopSTASHPV_set
4446 # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
4450 # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
4453 #ifndef CopSTASH_set
4454 # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
4458 # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
4459 || (CopSTASHPV(c) && HvNAME(hv) \
4460 && strEQ(CopSTASHPV(c), HvNAME(hv)))))
4465 # define CopFILEGV(c) ((c)->cop_filegv)
4468 #ifndef CopFILEGV_set
4469 # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
4473 # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
4477 # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
4481 # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
4485 # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
4489 # define CopSTASH(c) ((c)->cop_stash)
4492 #ifndef CopSTASH_set
4493 # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
4497 # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
4500 #ifndef CopSTASHPV_set
4501 # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
4505 # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
4508 #endif /* USE_ITHREADS */
4509 #ifndef IN_PERL_COMPILETIME
4510 # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling)
4513 #ifndef IN_LOCALE_RUNTIME
4514 # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
4517 #ifndef IN_LOCALE_COMPILETIME
4518 # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
4522 # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
4524 #ifndef IS_NUMBER_IN_UV
4525 # define IS_NUMBER_IN_UV 0x01
4528 #ifndef IS_NUMBER_GREATER_THAN_UV_MAX
4529 # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02
4532 #ifndef IS_NUMBER_NOT_INT
4533 # define IS_NUMBER_NOT_INT 0x04
4536 #ifndef IS_NUMBER_NEG
4537 # define IS_NUMBER_NEG 0x08
4540 #ifndef IS_NUMBER_INFINITY
4541 # define IS_NUMBER_INFINITY 0x10
4544 #ifndef IS_NUMBER_NAN
4545 # define IS_NUMBER_NAN 0x20
4548 /* GROK_NUMERIC_RADIX depends on grok_numeric_radix */
4549 #ifndef GROK_NUMERIC_RADIX
4550 # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
4552 #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
4553 # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02
4556 #ifndef PERL_SCAN_SILENT_ILLDIGIT
4557 # define PERL_SCAN_SILENT_ILLDIGIT 0x04
4560 #ifndef PERL_SCAN_ALLOW_UNDERSCORES
4561 # define PERL_SCAN_ALLOW_UNDERSCORES 0x01
4564 #ifndef PERL_SCAN_DISALLOW_PREFIX
4565 # define PERL_SCAN_DISALLOW_PREFIX 0x02
4568 #ifndef grok_numeric_radix
4569 #if defined(NEED_grok_numeric_radix)
4570 static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
4573 extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
4576 #ifdef grok_numeric_radix
4577 # undef grok_numeric_radix
4579 #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
4580 #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
4582 #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
4584 DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
4586 #ifdef USE_LOCALE_NUMERIC
4587 #ifdef PL_numeric_radix_sv
4588 if (PL_numeric_radix_sv && IN_LOCALE) {
4590 char* radix = SvPV(PL_numeric_radix_sv, len);
4591 if (*sp + len <= send && memEQ(*sp, radix, len)) {
4597 /* older perls don't have PL_numeric_radix_sv so the radix
4598 * must manually be requested from locale.h
4601 dTHR; /* needed for older threaded perls */
4602 struct lconv *lc = localeconv();
4603 char *radix = lc->decimal_point;
4604 if (radix && IN_LOCALE) {
4605 STRLEN len = strlen(radix);
4606 if (*sp + len <= send && memEQ(*sp, radix, len)) {
4612 #endif /* USE_LOCALE_NUMERIC */
4613 /* always try "." if numeric radix didn't match because
4614 * we may have data from different locales mixed */
4615 if (*sp < send && **sp == '.') {
4624 /* grok_number depends on grok_numeric_radix */
4627 #if defined(NEED_grok_number)
4628 static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
4631 extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
4637 #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
4638 #define Perl_grok_number DPPP_(my_grok_number)
4640 #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
4642 DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
4645 const char *send = pv + len;
4646 const UV max_div_10 = UV_MAX / 10;
4647 const char max_mod_10 = UV_MAX % 10;
4652 while (s < send && isSPACE(*s))
4656 } else if (*s == '-') {
4658 numtype = IS_NUMBER_NEG;
4666 /* next must be digit or the radix separator or beginning of infinity */
4668 /* UVs are at least 32 bits, so the first 9 decimal digits cannot
4670 UV value = *s - '0';
4671 /* This construction seems to be more optimiser friendly.
4672 (without it gcc does the isDIGIT test and the *s - '0' separately)
4673 With it gcc on arm is managing 6 instructions (6 cycles) per digit.
4674 In theory the optimiser could deduce how far to unroll the loop
4675 before checking for overflow. */
4677 int digit = *s - '0';
4678 if (digit >= 0 && digit <= 9) {
4679 value = value * 10 + digit;
4682 if (digit >= 0 && digit <= 9) {
4683 value = value * 10 + digit;
4686 if (digit >= 0 && digit <= 9) {
4687 value = value * 10 + digit;
4690 if (digit >= 0 && digit <= 9) {
4691 value = value * 10 + digit;
4694 if (digit >= 0 && digit <= 9) {
4695 value = value * 10 + digit;
4698 if (digit >= 0 && digit <= 9) {
4699 value = value * 10 + digit;
4702 if (digit >= 0 && digit <= 9) {
4703 value = value * 10 + digit;
4706 if (digit >= 0 && digit <= 9) {
4707 value = value * 10 + digit;
4709 /* Now got 9 digits, so need to check
4710 each time for overflow. */
4712 while (digit >= 0 && digit <= 9
4713 && (value < max_div_10
4714 || (value == max_div_10
4715 && digit <= max_mod_10))) {
4716 value = value * 10 + digit;
4722 if (digit >= 0 && digit <= 9
4724 /* value overflowed.
4725 skip the remaining digits, don't
4726 worry about setting *valuep. */
4729 } while (s < send && isDIGIT(*s));
4731 IS_NUMBER_GREATER_THAN_UV_MAX;
4751 numtype |= IS_NUMBER_IN_UV;
4756 if (GROK_NUMERIC_RADIX(&s, send)) {
4757 numtype |= IS_NUMBER_NOT_INT;
4758 while (s < send && isDIGIT(*s)) /* optional digits after the radix */
4762 else if (GROK_NUMERIC_RADIX(&s, send)) {
4763 numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
4764 /* no digits before the radix means we need digits after it */
4765 if (s < send && isDIGIT(*s)) {
4768 } while (s < send && isDIGIT(*s));
4770 /* integer approximation is valid - it's 0. */
4776 } else if (*s == 'I' || *s == 'i') {
4777 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
4778 s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
4779 s++; if (s < send && (*s == 'I' || *s == 'i')) {
4780 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
4781 s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
4782 s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
4783 s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
4787 } else if (*s == 'N' || *s == 'n') {
4788 /* XXX TODO: There are signaling NaNs and quiet NaNs. */
4789 s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
4790 s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
4797 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
4798 numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
4799 } else if (sawnan) {
4800 numtype &= IS_NUMBER_NEG; /* Keep track of sign */
4801 numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
4802 } else if (s < send) {
4803 /* we can have an optional exponent part */
4804 if (*s == 'e' || *s == 'E') {
4805 /* The only flag we keep is sign. Blow away any "it's UV" */
4806 numtype &= IS_NUMBER_NEG;
4807 numtype |= IS_NUMBER_NOT_INT;
4809 if (s < send && (*s == '-' || *s == '+'))
4811 if (s < send && isDIGIT(*s)) {
4814 } while (s < send && isDIGIT(*s));
4820 while (s < send && isSPACE(*s))
4824 if (len == 10 && memEQ(pv, "0 but true", 10)) {
4827 return IS_NUMBER_IN_UV;
4835 * The grok_* routines have been modified to use warn() instead of
4836 * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
4837 * which is why the stack variable has been renamed to 'xdigit'.
4841 #if defined(NEED_grok_bin)
4842 static UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4845 extern UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4851 #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
4852 #define Perl_grok_bin DPPP_(my_grok_bin)
4854 #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
4856 DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
4858 const char *s = start;
4859 STRLEN len = *len_p;
4863 const UV max_div_2 = UV_MAX / 2;
4864 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
4865 bool overflowed = FALSE;
4867 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
4868 /* strip off leading b or 0b.
4869 for compatibility silently suffer "b" and "0b" as valid binary
4876 else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
4883 for (; len-- && *s; s++) {
4885 if (bit == '0' || bit == '1') {
4886 /* Write it in this wonky order with a goto to attempt to get the
4887 compiler to make the common case integer-only loop pretty tight.
4888 With gcc seems to be much straighter code than old scan_bin. */
4891 if (value <= max_div_2) {
4892 value = (value << 1) | (bit - '0');
4895 /* Bah. We're just overflowed. */
4896 warn("Integer overflow in binary number");
4898 value_nv = (NV) value;
4901 /* If an NV has not enough bits in its mantissa to
4902 * represent a UV this summing of small low-order numbers
4903 * is a waste of time (because the NV cannot preserve
4904 * the low-order bits anyway): we could just remember when
4905 * did we overflow and in the end just multiply value_nv by the
4907 value_nv += (NV)(bit - '0');
4910 if (bit == '_' && len && allow_underscores && (bit = s[1])
4911 && (bit == '0' || bit == '1'))
4917 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
4918 warn("Illegal binary digit '%c' ignored", *s);
4922 if ( ( overflowed && value_nv > 4294967295.0)
4924 || (!overflowed && value > 0xffffffff )
4927 warn("Binary number > 0b11111111111111111111111111111111 non-portable");
4934 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
4943 #if defined(NEED_grok_hex)
4944 static UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4947 extern UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
4953 #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
4954 #define Perl_grok_hex DPPP_(my_grok_hex)
4956 #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
4958 DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
4960 const char *s = start;
4961 STRLEN len = *len_p;
4965 const UV max_div_16 = UV_MAX / 16;
4966 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
4967 bool overflowed = FALSE;
4970 if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
4971 /* strip off leading x or 0x.
4972 for compatibility silently suffer "x" and "0x" as valid hex numbers.
4979 else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
4986 for (; len-- && *s; s++) {
4987 xdigit = strchr((char *) PL_hexdigit, *s);
4989 /* Write it in this wonky order with a goto to attempt to get the
4990 compiler to make the common case integer-only loop pretty tight.
4991 With gcc seems to be much straighter code than old scan_hex. */
4994 if (value <= max_div_16) {
4995 value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
4998 warn("Integer overflow in hexadecimal number");
5000 value_nv = (NV) value;
5003 /* If an NV has not enough bits in its mantissa to
5004 * represent a UV this summing of small low-order numbers
5005 * is a waste of time (because the NV cannot preserve
5006 * the low-order bits anyway): we could just remember when
5007 * did we overflow and in the end just multiply value_nv by the
5008 * right amount of 16-tuples. */
5009 value_nv += (NV)((xdigit - PL_hexdigit) & 15);
5012 if (*s == '_' && len && allow_underscores && s[1]
5013 && (xdigit = strchr((char *) PL_hexdigit, s[1])))
5019 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5020 warn("Illegal hexadecimal digit '%c' ignored", *s);
5024 if ( ( overflowed && value_nv > 4294967295.0)
5026 || (!overflowed && value > 0xffffffff )
5029 warn("Hexadecimal number > 0xffffffff non-portable");
5036 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5045 #if defined(NEED_grok_oct)
5046 static UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5049 extern UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5055 #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
5056 #define Perl_grok_oct DPPP_(my_grok_oct)
5058 #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
5060 DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5062 const char *s = start;
5063 STRLEN len = *len_p;
5067 const UV max_div_8 = UV_MAX / 8;
5068 bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5069 bool overflowed = FALSE;
5071 for (; len-- && *s; s++) {
5072 /* gcc 2.95 optimiser not smart enough to figure that this subtraction
5073 out front allows slicker code. */
5074 int digit = *s - '0';
5075 if (digit >= 0 && digit <= 7) {
5076 /* Write it in this wonky order with a goto to attempt to get the
5077 compiler to make the common case integer-only loop pretty tight.
5081 if (value <= max_div_8) {
5082 value = (value << 3) | digit;
5085 /* Bah. We're just overflowed. */
5086 warn("Integer overflow in octal number");
5088 value_nv = (NV) value;
5091 /* If an NV has not enough bits in its mantissa to
5092 * represent a UV this summing of small low-order numbers
5093 * is a waste of time (because the NV cannot preserve
5094 * the low-order bits anyway): we could just remember when
5095 * did we overflow and in the end just multiply value_nv by the
5096 * right amount of 8-tuples. */
5097 value_nv += (NV)digit;
5100 if (digit == ('_' - '0') && len && allow_underscores
5101 && (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
5107 /* Allow \octal to work the DWIM way (that is, stop scanning
5108 * as soon as non-octal characters are seen, complain only iff
5109 * someone seems to want to use the digits eight and nine). */
5110 if (digit == 8 || digit == 9) {
5111 if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5112 warn("Illegal octal digit '%c' ignored", *s);
5117 if ( ( overflowed && value_nv > 4294967295.0)
5119 || (!overflowed && value > 0xffffffff )
5122 warn("Octal number > 037777777777 non-portable");
5129 *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5139 # define dXCPT dJMPENV; int rEtV = 0
5140 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
5141 # define XCPT_TRY_END JMPENV_POP;
5142 # define XCPT_CATCH if (rEtV != 0)
5143 # define XCPT_RETHROW JMPENV_JUMP(rEtV)
5145 # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0
5146 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0)
5147 # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf);
5148 # define XCPT_CATCH if (rEtV != 0)
5149 # define XCPT_RETHROW Siglongjmp(top_env, rEtV)
5153 #endif /* _P_P_PORTABILITY_H_ */
5155 /* End of File ppport.h */