This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
attributes-two.patch also contains a lot of const-ing, hence the
[perl5.git] / ext / Devel / PPPort / PPPort.pm
1 ################################################################################
2 #
3 #  !!!!! Do NOT edit this file directly! -- Edit PPPort_pm.PL instead. !!!!!
4 #
5 ################################################################################
6 #
7 #  Perl/Pollution/Portability
8 #
9 ################################################################################
10 #
11 #  $Revision: 33 $
12 #  $Author: mhx $
13 #  $Date: 2005/01/31 08:10:55 +0100 $
14 #
15 ################################################################################
16 #
17 #  Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
18 #  Version 2.x, Copyright (C) 2001, Paul Marquess.
19 #  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
20 #
21 #  This program is free software; you can redistribute it and/or
22 #  modify it under the same terms as Perl itself.
23 #
24 ################################################################################
25
26 =head1 NAME
27
28 Devel::PPPort - Perl/Pollution/Portability
29
30 =head1 SYNOPSIS
31
32     Devel::PPPort::WriteFile();   # defaults to ./ppport.h
33     Devel::PPPort::WriteFile('someheader.h');
34
35 =head1 DESCRIPTION
36
37 Perl's API has changed over time, gaining new features, new functions,
38 increasing its flexibility, and reducing the impact on the C namespace
39 environment (reduced pollution). The header file written by this module,
40 typically F<ppport.h>, attempts to bring some of the newer Perl API
41 features to older versions of Perl, so that you can worry less about
42 keeping track of old releases, but users can still reap the benefit.
43
44 C<Devel::PPPort> contains a single function, called C<WriteFile>. Its
45 only purpose is to write the F<ppport.h> C header file. This file
46 contains a series of macros and, if explicitly requested, functions that
47 allow XS modules to be built using older versions of Perl. Currently,
48 Perl versions from 5.003 to 5.9.2 are supported.
49
50 This module is used by C<h2xs> to write the file F<ppport.h>. 
51
52 =head2 Why use ppport.h?
53  
54 You should use F<ppport.h> in modern code so that your code will work
55 with the widest range of Perl interpreters possible, without significant
56 additional work.
57
58 You should attempt older code to fully use F<ppport.h>, because the
59 reduced pollution of newer Perl versions is an important thing. It's so
60 important that the old polluting ways of original Perl modules will not be
61 supported very far into the future, and your module will almost certainly
62 break! By adapting to it now, you'll gain compatibility and a sense of
63 having done the electronic ecology some good.
64
65 =head2 How to use ppport.h
66
67 Don't direct the users of your module to download C<Devel::PPPort>.
68 They are most probably no XS writers. Also, don't make F<ppport.h>
69 optional. Rather, just take the most recent copy of F<ppport.h> that
70 you can find (e.g. by generating it with the latest C<Devel::PPPort>
71 release from CPAN), copy it into your project, adjust your project to
72 use it, and distribute the header along with your module. 
73
74 =head2 Running ppport.h
75
76 But F<ppport.h> is more than just a C header. It's also a Perl script
77 that can check your source code. It will suggest hints and portability
78 notes, and can even make suggestions on how to change your code. You
79 can run it like any other Perl program:
80
81     perl ppport.h [options] [files]
82
83 It also has embedded documentation, so you can use
84
85     perldoc ppport.h
86
87 to find out more about how to use it.
88
89 =head1 FUNCTIONS
90
91 =head2 WriteFile
92
93 C<WriteFile> takes one optional argument. When called with one
94 argument, it expects to be passed a filename. When called with
95 no arguments, it defaults to the filename F<ppport.h>.
96
97 The function returns a true value if the file was written successfully.
98 Otherwise it returns a false value.
99
100 =head1 COMPATIBILITY
101
102 F<ppport.h> supports Perl versions from 5.003 to 5.9.2
103 in threaded and non-threaded configurations.
104
105 =head2 Provided Perl compatibility API
106
107 The header file written by this module, typically F<ppport.h>, provides
108 access to the following elements of the Perl API that is not available
109 in older Perl releases:
110
111     _aMY_CXT
112     _pMY_CXT
113     aMY_CXT
114     aMY_CXT_
115     aTHX
116     aTHX_
117     AvFILLp
118     boolSV
119     call_argv
120     call_method
121     call_pv
122     call_sv
123     CopFILE
124     CopFILE_set
125     CopFILEAV
126     CopFILEGV
127     CopFILEGV_set
128     CopFILESV
129     CopSTASH
130     CopSTASH_eq
131     CopSTASH_set
132     CopSTASHPV
133     CopSTASHPV_set
134     CopyD
135     dAX
136     DEFSV
137     dITEMS
138     dMY_CXT
139     dMY_CXT_SV
140     dNOOP
141     dTHR
142     dTHX
143     dTHXa
144     dTHXoa
145     dUNDERBAR
146     dXCPT
147     dXSTARG
148     END_EXTERN_C
149     ERRSV
150     eval_pv
151     eval_sv
152     EXTERN_C
153     get_av
154     get_cv
155     get_hv
156     get_sv
157     grok_bin
158     grok_hex
159     grok_number
160     GROK_NUMERIC_RADIX
161     grok_numeric_radix
162     grok_oct
163     gv_stashpvn
164     IN_LOCALE
165     IN_LOCALE_COMPILETIME
166     IN_LOCALE_RUNTIME
167     IN_PERL_COMPILETIME
168     INT2PTR
169     IS_NUMBER_GREATER_THAN_UV_MAX
170     IS_NUMBER_IN_UV
171     IS_NUMBER_INFINITY
172     IS_NUMBER_NAN
173     IS_NUMBER_NEG
174     IS_NUMBER_NOT_INT
175     IVdf
176     IVSIZE
177     IVTYPE
178     memEQ
179     memNE
180     MoveD
181     mPUSHi
182     mPUSHn
183     mPUSHp
184     mPUSHu
185     mXPUSHi
186     mXPUSHn
187     mXPUSHp
188     mXPUSHu
189     MY_CXT
190     MY_CXT_CLONE
191     MY_CXT_INIT
192     newCONSTSUB
193     newRV_inc
194     newRV_noinc
195     newSVpvn
196     newSVuv
197     NOOP
198     NUM2PTR
199     NVef
200     NVff
201     NVgf
202     NVTYPE
203     PERL_BCDVERSION
204     PERL_GCC_BRACE_GROUPS_FORBIDDEN
205     PERL_INT_MAX
206     PERL_INT_MIN
207     PERL_LONG_MAX
208     PERL_LONG_MIN
209     PERL_MAGIC_arylen
210     PERL_MAGIC_backref
211     PERL_MAGIC_bm
212     PERL_MAGIC_collxfrm
213     PERL_MAGIC_dbfile
214     PERL_MAGIC_dbline
215     PERL_MAGIC_defelem
216     PERL_MAGIC_env
217     PERL_MAGIC_envelem
218     PERL_MAGIC_ext
219     PERL_MAGIC_fm
220     PERL_MAGIC_glob
221     PERL_MAGIC_isa
222     PERL_MAGIC_isaelem
223     PERL_MAGIC_mutex
224     PERL_MAGIC_nkeys
225     PERL_MAGIC_overload
226     PERL_MAGIC_overload_elem
227     PERL_MAGIC_overload_table
228     PERL_MAGIC_pos
229     PERL_MAGIC_qr
230     PERL_MAGIC_regdata
231     PERL_MAGIC_regdatum
232     PERL_MAGIC_regex_global
233     PERL_MAGIC_shared
234     PERL_MAGIC_shared_scalar
235     PERL_MAGIC_sig
236     PERL_MAGIC_sigelem
237     PERL_MAGIC_substr
238     PERL_MAGIC_sv
239     PERL_MAGIC_taint
240     PERL_MAGIC_tied
241     PERL_MAGIC_tiedelem
242     PERL_MAGIC_tiedscalar
243     PERL_MAGIC_utf8
244     PERL_MAGIC_uvar
245     PERL_MAGIC_uvar_elem
246     PERL_MAGIC_vec
247     PERL_MAGIC_vstring
248     PERL_QUAD_MAX
249     PERL_QUAD_MIN
250     PERL_REVISION
251     PERL_SCAN_ALLOW_UNDERSCORES
252     PERL_SCAN_DISALLOW_PREFIX
253     PERL_SCAN_GREATER_THAN_UV_MAX
254     PERL_SCAN_SILENT_ILLDIGIT
255     PERL_SHORT_MAX
256     PERL_SHORT_MIN
257     PERL_SUBVERSION
258     PERL_UCHAR_MAX
259     PERL_UCHAR_MIN
260     PERL_UINT_MAX
261     PERL_UINT_MIN
262     PERL_ULONG_MAX
263     PERL_ULONG_MIN
264     PERL_UNUSED_DECL
265     PERL_UQUAD_MAX
266     PERL_UQUAD_MIN
267     PERL_USHORT_MAX
268     PERL_USHORT_MIN
269     PERL_VERSION
270     PL_compiling
271     PL_copline
272     PL_curcop
273     PL_curstash
274     PL_DBsingle
275     PL_DBsub
276     PL_debstash
277     PL_defgv
278     PL_diehook
279     PL_dirty
280     PL_dowarn
281     PL_errgv
282     PL_hexdigit
283     PL_hints
284     PL_na
285     PL_no_modify
286     PL_perl_destruct_level
287     PL_perldb
288     PL_ppaddr
289     PL_rsfp
290     PL_rsfp_filters
291     PL_stack_base
292     PL_stack_sp
293     PL_stdingv
294     PL_Sv
295     PL_sv_arenaroot
296     PL_sv_no
297     PL_sv_undef
298     PL_sv_yes
299     PL_tainted
300     PL_tainting
301     pMY_CXT
302     pMY_CXT_
303     Poison
304     pTHX
305     pTHX_
306     PTR2IV
307     PTR2NV
308     PTR2ul
309     PTR2UV
310     PTRV
311     PUSHmortal
312     PUSHu
313     SAVE_DEFSV
314     START_EXTERN_C
315     START_MY_CXT
316     STMT_END
317     STMT_START
318     sv_2pv_nolen
319     sv_2pvbyte
320     sv_2uv
321     sv_catpv_mg
322     sv_catpvf_mg
323     sv_catpvf_mg_nocontext
324     sv_catpvn_mg
325     sv_catpvn_nomg
326     sv_catsv_mg
327     sv_catsv_nomg
328     sv_pvn
329     sv_pvn_force
330     sv_pvn_nomg
331     sv_setiv_mg
332     sv_setnv_mg
333     sv_setpv_mg
334     sv_setpvf_mg
335     sv_setpvf_mg_nocontext
336     sv_setpvn_mg
337     sv_setsv_mg
338     sv_setsv_nomg
339     sv_setuv
340     sv_setuv_mg
341     sv_usepvn_mg
342     sv_uv
343     sv_vcatpvf
344     sv_vcatpvf_mg
345     sv_vsetpvf
346     sv_vsetpvf_mg
347     SvGETMAGIC
348     SvIV_nomg
349     SvPV_force_nomg
350     SvPV_nolen
351     SvPV_nomg
352     SvPVbyte
353     SvUV
354     SvUV_nomg
355     SvUVX
356     SvUVx
357     SvUVXx
358     UNDERBAR
359     UVof
360     UVSIZE
361     UVTYPE
362     UVuf
363     UVXf
364     UVxf
365     vnewSVpvf
366     XCPT_CATCH
367     XCPT_RETHROW
368     XCPT_TRY_END
369     XCPT_TRY_START
370     XPUSHmortal
371     XPUSHu
372     XSRETURN_UV
373     XST_mUV
374     ZeroD
375
376 =head2 Perl API not supported by ppport.h
377
378 There is still a big part of the API not supported by F<ppport.h>.
379 Either because it doesn't make sense to back-port that part of the API,
380 or simply because it hasn't been implemented yet. Patches welcome!
381
382 Here's a list of the currently unsupported API, and also the version of
383 Perl below which it is unsupported:
384
385 =over 4
386
387 =item perl 5.9.2
388
389   SvPVbyte_force
390   find_rundefsvoffset
391   gv_fetchpvn_flags
392   gv_fetchsv
393   op_refcnt_lock
394   op_refcnt_unlock
395   savesvpv
396   vnormal
397
398 =item perl 5.9.1
399
400   hv_assert
401   hv_clear_placeholders
402   hv_scalar
403   scan_version
404   sv_2iv_flags
405   sv_2uv_flags
406
407 =item perl 5.9.0
408
409   new_version
410   save_set_svflags
411   upg_version
412   vcmp
413   vnumify
414   vstringify
415
416 =item perl 5.8.3
417
418   SvIsCOW
419   SvIsCOW_shared_hash
420
421 =item perl 5.8.1
422
423   SvVOK
424   doing_taint
425   is_utf8_string_loc
426   packlist
427   save_bool
428   savestack_grow_cnt
429   scan_vstring
430   sv_cat_decode
431   sv_compile_2op
432   sv_setpviv
433   sv_setpviv_mg
434   unpackstring
435
436 =item perl 5.8.0
437
438   hv_iternext_flags
439   hv_store_flags
440   is_utf8_idcont
441   nothreadhook
442
443 =item perl 5.7.3
444
445   PerlIO_clearerr
446   PerlIO_close
447   PerlIO_eof
448   PerlIO_error
449   PerlIO_fileno
450   PerlIO_fill
451   PerlIO_flush
452   PerlIO_get_base
453   PerlIO_get_bufsiz
454   PerlIO_get_cnt
455   PerlIO_get_ptr
456   PerlIO_read
457   PerlIO_seek
458   PerlIO_set_cnt
459   PerlIO_set_ptrcnt
460   PerlIO_setlinebuf
461   PerlIO_stderr
462   PerlIO_stdin
463   PerlIO_stdout
464   PerlIO_tell
465   PerlIO_unread
466   PerlIO_write
467   SvLOCK
468   SvSHARE
469   SvUNLOCK
470   atfork_lock
471   atfork_unlock
472   custom_op_desc
473   custom_op_name
474   deb
475   debstack
476   debstackptrs
477   gv_fetchmeth_autoload
478   ibcmp_utf8
479   my_fork
480   my_socketpair
481   pack_cat
482   perl_destruct
483   pv_uni_display
484   regclass_swash
485   save_shared_pvref
486   savesharedpv
487   sortsv
488   sv_copypv
489   sv_magicext
490   sv_nolocking
491   sv_nosharing
492   sv_nounlocking
493   sv_recode_to_utf8
494   sv_uni_display
495   to_uni_fold
496   to_uni_lower
497   to_uni_title
498   to_uni_upper
499   to_utf8_case
500   to_utf8_fold
501   to_utf8_lower
502   to_utf8_title
503   to_utf8_upper
504   unpack_str
505   uvchr_to_utf8_flags
506   uvuni_to_utf8_flags
507   vdeb
508
509 =item perl 5.7.2
510
511   calloc
512   getcwd_sv
513   init_tm
514   malloc
515   mfree
516   mini_mktime
517   my_atof2
518   my_strftime
519   op_null
520   realloc
521   sv_2pv_flags
522   sv_catpvn_flags
523   sv_catsv_flags
524   sv_pvn_force_flags
525   sv_setsv_flags
526   sv_utf8_upgrade_flags
527   swash_fetch
528
529 =item perl 5.7.1
530
531   POPpbytex
532   SvUOK
533   bytes_from_utf8
534   csighandler
535   despatch_signals
536   do_openn
537   gv_handler
538   is_lvalue_sub
539   my_popen_list
540   newSVpvn_share
541   save_mortalizesv
542   save_padsv
543   scan_num
544   sv_force_normal_flags
545   sv_setref_uv
546   sv_unref_flags
547   sv_utf8_upgrade
548   utf8_length
549   utf8_to_uvchr
550   utf8_to_uvuni
551   utf8n_to_uvchr
552   utf8n_to_uvuni
553   uvchr_to_utf8
554   uvuni_to_utf8
555
556 =item perl 5.6.1
557
558   apply_attrs_string
559   bytes_to_utf8
560   gv_efullname4
561   gv_fullname4
562   is_utf8_string
563   save_generic_pvref
564   utf16_to_utf8
565   utf16_to_utf8_reversed
566   utf8_to_bytes
567
568 =item perl 5.6.0
569
570   SvIOK_UV
571   SvIOK_notUV
572   SvIOK_only_UV
573   SvPOK_only_UTF8
574   SvPVbyte_nolen
575   SvPVbytex
576   SvPVbytex_force
577   SvPVutf8
578   SvPVutf8_force
579   SvPVutf8_nolen
580   SvPVutf8x
581   SvPVutf8x_force
582   SvUTF8
583   SvUTF8_off
584   SvUTF8_on
585   av_delete
586   av_exists
587   call_atexit
588   cast_i32
589   cast_iv
590   cast_ulong
591   cast_uv
592   do_gv_dump
593   do_gvgv_dump
594   do_hv_dump
595   do_magic_dump
596   do_op_dump
597   do_open9
598   do_pmop_dump
599   do_sv_dump
600   dump_all
601   dump_eval
602   dump_form
603   dump_indent
604   dump_packsubs
605   dump_sub
606   dump_vindent
607   get_context
608   get_ppaddr
609   gv_dump
610   init_i18nl10n
611   init_i18nl14n
612   is_uni_alnum
613   is_uni_alnum_lc
614   is_uni_alnumc
615   is_uni_alnumc_lc
616   is_uni_alpha
617   is_uni_alpha_lc
618   is_uni_ascii
619   is_uni_ascii_lc
620   is_uni_cntrl
621   is_uni_cntrl_lc
622   is_uni_digit
623   is_uni_digit_lc
624   is_uni_graph
625   is_uni_graph_lc
626   is_uni_idfirst
627   is_uni_idfirst_lc
628   is_uni_lower
629   is_uni_lower_lc
630   is_uni_print
631   is_uni_print_lc
632   is_uni_punct
633   is_uni_punct_lc
634   is_uni_space
635   is_uni_space_lc
636   is_uni_upper
637   is_uni_upper_lc
638   is_uni_xdigit
639   is_uni_xdigit_lc
640   is_utf8_alnum
641   is_utf8_alnumc
642   is_utf8_alpha
643   is_utf8_ascii
644   is_utf8_char
645   is_utf8_cntrl
646   is_utf8_digit
647   is_utf8_graph
648   is_utf8_idfirst
649   is_utf8_lower
650   is_utf8_mark
651   is_utf8_print
652   is_utf8_punct
653   is_utf8_space
654   is_utf8_upper
655   is_utf8_xdigit
656   load_module
657   magic_dump
658   mess
659   my_atof
660   my_fflush_all
661   newANONATTRSUB
662   newATTRSUB
663   newMYSUB
664   newPADOP
665   newXS
666   newXSproto
667   new_collate
668   new_ctype
669   new_numeric
670   op_dump
671   perl_parse
672   pmop_dump
673   pv_display
674   re_intuit_start
675   re_intuit_string
676   reginitcolors
677   require_pv
678   safesyscalloc
679   safesysfree
680   safesysmalloc
681   safesysrealloc
682   save_I8
683   save_alloc
684   save_destructor
685   save_destructor_x
686   save_re_context
687   save_vptr
688   scan_bin
689   set_context
690   set_numeric_local
691   set_numeric_radix
692   set_numeric_standard
693   str_to_version
694   sv_2pvutf8
695   sv_2pvutf8_nolen
696   sv_force_normal
697   sv_len_utf8
698   sv_pos_b2u
699   sv_pos_u2b
700   sv_pv
701   sv_pvbyte
702   sv_pvbyten
703   sv_pvbyten_force
704   sv_pvutf8
705   sv_pvutf8n
706   sv_pvutf8n_force
707   sv_rvweaken
708   sv_utf8_decode
709   sv_utf8_downgrade
710   sv_utf8_encode
711   swash_init
712   tmps_grow
713   to_uni_lower_lc
714   to_uni_title_lc
715   to_uni_upper_lc
716   utf8_distance
717   utf8_hop
718   vcroak
719   vform
720   vload_module
721   vmess
722   vwarn
723   vwarner
724   warner
725
726 =item perl 5.005_03
727
728   POPpx
729   get_vtbl
730   save_generic_svref
731
732 =item perl 5.005
733
734   PL_modglobal
735   cx_dump
736   debop
737   debprofdump
738   fbm_compile
739   fbm_instr
740   get_op_descs
741   get_op_names
742   init_stacks
743   mg_length
744   mg_size
745   newHVhv
746   new_stackinfo
747   regdump
748   regexec_flags
749   regnext
750   runops_debug
751   runops_standard
752   save_hints
753   save_iv
754   save_threadsv
755   screaminstr
756   sv_iv
757   sv_nv
758   sv_peek
759   sv_true
760
761 =item perl 5.004_05
762
763   do_binmode
764   save_aelem
765   save_helem
766
767 =item perl 5.004_04
768
769   newWHILEOP
770
771 =item perl 5.004
772
773   GIMME_V
774   G_VOID
775   HEf_SVKEY
776   HeHASH
777   HeKEY
778   HeKLEN
779   HePV
780   HeSVKEY
781   HeSVKEY_force
782   HeSVKEY_set
783   HeVAL
784   SvSetMagicSV
785   SvSetMagicSV_nosteal
786   SvSetSV_nosteal
787   SvTAINTED
788   SvTAINTED_off
789   SvTAINTED_on
790   block_gimme
791   call_list
792   cv_const_sv
793   delimcpy
794   do_open
795   form
796   gv_autoload4
797   gv_efullname3
798   gv_fetchmethod_autoload
799   gv_fullname3
800   hv_delayfree_ent
801   hv_delete_ent
802   hv_exists_ent
803   hv_fetch_ent
804   hv_free_ent
805   hv_iterkeysv
806   hv_ksplit
807   hv_store_ent
808   ibcmp_locale
809   my_failure_exit
810   my_memcmp
811   my_pclose
812   my_popen
813   newSVpvf
814   rsignal
815   rsignal_state
816   save_I16
817   save_gp
818   start_subparse
819   sv_catpvf
820   sv_catpvf_mg
821   sv_cmp_locale
822   sv_derived_from
823   sv_gets
824   sv_setpvf
825   sv_setpvf_mg
826   sv_taint
827   sv_tainted
828   sv_untaint
829   sv_vcatpvf
830   sv_vcatpvf_mg
831   sv_vcatpvfn
832   sv_vsetpvf
833   sv_vsetpvf_mg
834   sv_vsetpvfn
835   unsharepvn
836   vnewSVpvf
837
838 =back
839
840 =head1 BUGS
841
842 If you find any bugs, C<Devel::PPPort> doesn't seem to build on your
843 system or any of its tests fail, please use the CPAN Request Tracker
844 at L<http://rt.cpan.org/> to create a ticket for the module.
845
846 =head1 AUTHORS
847
848 =over 2
849
850 =item *
851
852 Version 1.x of Devel::PPPort was written by Kenneth Albanowski.
853
854 =item *
855
856 Version 2.x was ported to the Perl core by Paul Marquess.
857
858 =item *
859
860 Version 3.x was ported back to CPAN by Marcus Holland-Moritz.
861
862 =back
863
864 =head1 COPYRIGHT
865
866 Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
867
868 Version 2.x, Copyright (C) 2001, Paul Marquess.
869
870 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
871
872 This program is free software; you can redistribute it and/or
873 modify it under the same terms as Perl itself.
874
875 =head1 SEE ALSO
876
877 See L<h2xs>, L<ppport.h>.
878
879 =cut
880
881 package Devel::PPPort;
882
883 require DynaLoader;
884 use strict;
885 use vars qw($VERSION @ISA $data);
886
887 $VERSION = do { my @r = '$Snapshot: /Devel-PPPort/3.06 $' =~ /(\d+\.\d+(?:_\d+)?)/; @r ? $r[0] : '9.99' };
888
889 @ISA = qw(DynaLoader);
890
891 bootstrap Devel::PPPort;
892
893 {
894   $data = do { local $/; <DATA> };
895   my $now = localtime;
896   my $pkg = 'Devel::PPPort';
897   $data =~ s/__PERL_VERSION__/$]/g;
898   $data =~ s/__VERSION__/$VERSION/g;
899   $data =~ s/__DATE__/$now/g;
900   $data =~ s/__PKG__/$pkg/g;
901   $data =~ s/^POD\s//gm;
902 }
903
904 sub WriteFile
905 {
906   my $file = shift || 'ppport.h';
907   my $copy = $data;
908   $copy =~ s/\bppport\.h\b/$file/g;
909
910   open F, ">$file" or return undef;
911   print F $copy;
912   close F;
913
914   return 1;
915 }
916
917 1;
918
919 __DATA__
920 #if 0
921 <<'SKIP';
922 #endif
923 /*
924 ----------------------------------------------------------------------
925
926     ppport.h -- Perl/Pollution/Portability Version __VERSION__ 
927    
928     Automatically created by __PKG__ running under
929     perl __PERL_VERSION__ on __DATE__.
930     
931     Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
932     includes in parts/inc/ instead.
933  
934     Use 'perldoc ppport.h' to view the documentation below.
935
936 ----------------------------------------------------------------------
937
938 SKIP
939
940 POD =pod
941 POD 
942 POD =head1 NAME
943 POD 
944 POD ppport.h - Perl/Pollution/Portability version __VERSION__
945 POD 
946 POD =head1 SYNOPSIS
947 POD 
948 POD   perl ppport.h [options] [files]
949 POD 
950 POD   --help                      show short help
951 POD 
952 POD   --patch=file                write one patch file with changes
953 POD   --copy=suffix               write changed copies with suffix
954 POD   --diff=program              use diff program and options
955 POD 
956 POD   --compat-version=version    provide compatibility with Perl version
957 POD   --cplusplus                 accept C++ comments
958 POD 
959 POD   --quiet                     don't output anything except fatal errors
960 POD   --nodiag                    don't show diagnostics
961 POD   --nohints                   don't show hints
962 POD   --nochanges                 don't suggest changes
963 POD 
964 POD   --list-provided             list provided API
965 POD   --list-unsupported          list unsupported API
966 POD   --api-info=name             show Perl API portability information
967 POD 
968 POD =head1 COMPATIBILITY
969 POD 
970 POD This version of F<ppport.h> is designed to support operation with Perl
971 POD installations back to 5.003, and has been tested up to 5.9.2.
972 POD 
973 POD =head1 OPTIONS
974 POD 
975 POD =head2 --help
976 POD 
977 POD Display a brief usage summary.
978 POD 
979 POD =head2 --patch=I<file>
980 POD 
981 POD If this option is given, a single patch file will be created if
982 POD any changes are suggested. This requires a working diff program
983 POD to be installed on your system.
984 POD 
985 POD =head2 --copy=I<suffix>
986 POD 
987 POD If this option is given, a copy of each file will be saved with
988 POD the given suffix that contains the suggested changes. This does
989 POD not require any external programs.
990 POD 
991 POD If neither C<--patch> or C<--copy> are given, the default is to
992 POD simply print the diffs for each file. This requires either
993 POD C<Text::Diff> or a C<diff> program to be installed.
994 POD 
995 POD =head2 --diff=I<program>
996 POD 
997 POD Manually set the diff program and options to use. The default
998 POD is to use C<Text::Diff>, when installed, and output unified
999 POD context diffs.
1000 POD 
1001 POD =head2 --compat-version=I<version>
1002 POD 
1003 POD Tell F<ppport.h> to check for compatibility with the given
1004 POD Perl version. The default is to check for compatibility with Perl
1005 POD version 5.003. You can use this option to reduce the output
1006 POD of F<ppport.h> if you intend to be backward compatible only
1007 POD up to a certain Perl version.
1008 POD 
1009 POD =head2 --cplusplus
1010 POD 
1011 POD Usually, F<ppport.h> will detect C++ style comments and
1012 POD replace them with C style comments for portability reasons.
1013 POD Using this option instructs F<ppport.h> to leave C++
1014 POD comments untouched.
1015 POD 
1016 POD =head2 --quiet
1017 POD 
1018 POD Be quiet. Don't print anything except fatal errors.
1019 POD 
1020 POD =head2 --nodiag
1021 POD 
1022 POD Don't output any diagnostic messages. Only portability
1023 POD alerts will be printed.
1024 POD 
1025 POD =head2 --nohints
1026 POD 
1027 POD Don't output any hints. Hints often contain useful portability
1028 POD notes.
1029 POD 
1030 POD =head2 --nochanges
1031 POD 
1032 POD Don't suggest any changes. Only give diagnostic output and hints
1033 POD unless these are also deactivated.
1034 POD 
1035 POD =head2 --list-provided
1036 POD 
1037 POD Lists the API elements for which compatibility is provided by
1038 POD F<ppport.h>. Also lists if it must be explicitly requested,
1039 POD if it has dependencies, and if there are hints for it.
1040 POD 
1041 POD =head2 --list-unsupported
1042 POD 
1043 POD Lists the API elements that are known not to be supported by
1044 POD F<ppport.h> and below which version of Perl they probably
1045 POD won't be available or work.
1046 POD 
1047 POD =head2 --api-info=I<name>
1048 POD 
1049 POD Show portability information for API elements matching I<name>.
1050 POD If I<name> is surrounded by slashes, it is interpreted as a regular
1051 POD expression.
1052 POD 
1053 POD =head1 DESCRIPTION
1054 POD 
1055 POD In order for a Perl extension (XS) module to be as portable as possible
1056 POD across differing versions of Perl itself, certain steps need to be taken.
1057 POD 
1058 POD =over 4
1059 POD 
1060 POD =item *
1061 POD 
1062 POD Including this header is the first major one. This alone will give you
1063 POD access to a large part of the Perl API that hasn't been available in
1064 POD earlier Perl releases. Use
1065 POD 
1066 POD     perl ppport.h --list-provided
1067 POD 
1068 POD to see which API elements are provided by ppport.h.
1069 POD 
1070 POD =item *
1071 POD 
1072 POD You should avoid using deprecated parts of the API. For example, using
1073 POD global Perl variables without the C<PL_> prefix is deprecated. Also,
1074 POD some API functions used to have a C<perl_> prefix. Using this form is
1075 POD also deprecated. You can safely use the supported API, as F<ppport.h>
1076 POD will provide wrappers for older Perl versions.
1077 POD 
1078 POD =item *
1079 POD 
1080 POD If you use one of a few functions that were not present in earlier
1081 POD versions of Perl, and that can't be provided using a macro, you have
1082 POD to explicitly request support for these functions by adding one or
1083 POD more C<#define>s in your source code before the inclusion of F<ppport.h>.
1084 POD 
1085 POD These functions will be marked C<explicit> in the list shown by
1086 POD C<--list-provided>.
1087 POD 
1088 POD Depending on whether you module has a single or multiple files that
1089 POD use such functions, you want either C<static> or global variants.
1090 POD 
1091 POD For a C<static> function, use:
1092 POD 
1093 POD     #define NEED_function
1094 POD 
1095 POD For a global function, use:
1096 POD 
1097 POD     #define NEED_function_GLOBAL
1098 POD 
1099 POD Note that you mustn't have more than one global request for one
1100 POD function in your project.
1101 POD 
1102 POD     Function                  Static Request               Global Request                    
1103 POD     -----------------------------------------------------------------------------------------
1104 POD     eval_pv()                 NEED_eval_pv                 NEED_eval_pv_GLOBAL               
1105 POD     grok_bin()                NEED_grok_bin                NEED_grok_bin_GLOBAL              
1106 POD     grok_hex()                NEED_grok_hex                NEED_grok_hex_GLOBAL              
1107 POD     grok_number()             NEED_grok_number             NEED_grok_number_GLOBAL           
1108 POD     grok_numeric_radix()      NEED_grok_numeric_radix      NEED_grok_numeric_radix_GLOBAL    
1109 POD     grok_oct()                NEED_grok_oct                NEED_grok_oct_GLOBAL              
1110 POD     newCONSTSUB()             NEED_newCONSTSUB             NEED_newCONSTSUB_GLOBAL           
1111 POD     newRV_noinc()             NEED_newRV_noinc             NEED_newRV_noinc_GLOBAL           
1112 POD     sv_2pv_nolen()            NEED_sv_2pv_nolen            NEED_sv_2pv_nolen_GLOBAL          
1113 POD     sv_2pvbyte()              NEED_sv_2pvbyte              NEED_sv_2pvbyte_GLOBAL            
1114 POD     sv_catpvf_mg()            NEED_sv_catpvf_mg            NEED_sv_catpvf_mg_GLOBAL          
1115 POD     sv_catpvf_mg_nocontext()  NEED_sv_catpvf_mg_nocontext  NEED_sv_catpvf_mg_nocontext_GLOBAL
1116 POD     sv_setpvf_mg()            NEED_sv_setpvf_mg            NEED_sv_setpvf_mg_GLOBAL          
1117 POD     sv_setpvf_mg_nocontext()  NEED_sv_setpvf_mg_nocontext  NEED_sv_setpvf_mg_nocontext_GLOBAL
1118 POD     vnewSVpvf()               NEED_vnewSVpvf               NEED_vnewSVpvf_GLOBAL             
1119 POD 
1120 POD To avoid namespace conflicts, you can change the namespace of the
1121 POD explicitly exported functions using the C<DPPP_NAMESPACE> macro.
1122 POD Just C<#define> the macro before including C<ppport.h>:
1123 POD 
1124 POD     #define DPPP_NAMESPACE MyOwnNamespace_
1125 POD     #include "ppport.h"
1126 POD 
1127 POD The default namespace is C<DPPP_>.
1128 POD 
1129 POD =back
1130 POD 
1131 POD The good thing is that most of the above can be checked by running
1132 POD F<ppport.h> on your source code. See the next section for
1133 POD details.
1134 POD 
1135 POD =head1 EXAMPLES
1136 POD 
1137 POD To verify whether F<ppport.h> is needed for your module, whether you
1138 POD should make any changes to your code, and whether any special defines
1139 POD should be used, F<ppport.h> can be run as a Perl script to check your
1140 POD source code. Simply say:
1141 POD 
1142 POD     perl ppport.h
1143 POD 
1144 POD The result will usually be a list of patches suggesting changes
1145 POD that should at least be acceptable, if not necessarily the most
1146 POD efficient solution, or a fix for all possible problems.
1147 POD 
1148 POD If you know that your XS module uses features only available in
1149 POD newer Perl releases, if you're aware that it uses C++ comments,
1150 POD and if you want all suggestions as a single patch file, you could
1151 POD use something like this:
1152 POD 
1153 POD     perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
1154 POD 
1155 POD If you only want your code to be scanned without any suggestions
1156 POD for changes, use:
1157 POD 
1158 POD     perl ppport.h --nochanges
1159 POD 
1160 POD You can specify a different C<diff> program or options, using
1161 POD the C<--diff> option:
1162 POD 
1163 POD     perl ppport.h --diff='diff -C 10'
1164 POD 
1165 POD This would output context diffs with 10 lines of context.
1166 POD 
1167 POD To display portability information for the C<newSVpvn> function,
1168 POD use:
1169 POD 
1170 POD     perl ppport.h --api-info=newSVpvn
1171 POD 
1172 POD Since the argument to C<--api-info> can be a regular expression,
1173 POD you can use
1174 POD 
1175 POD     perl ppport.h --api-info=/_nomg$/
1176 POD 
1177 POD to display portability information for all C<_nomg> functions or
1178 POD 
1179 POD     perl ppport.h --api-info=/./
1180 POD 
1181 POD to display information for all known API elements.
1182 POD 
1183 POD =head1 BUGS
1184 POD 
1185 POD If this version of F<ppport.h> is causing failure during
1186 POD the compilation of this module, please check if newer versions
1187 POD of either this module or C<Devel::PPPort> are available on CPAN
1188 POD before sending a bug report.
1189 POD 
1190 POD If F<ppport.h> was generated using the latest version of
1191 POD C<Devel::PPPort> and is causing failure of this module, please
1192 POD file a bug report using the CPAN Request Tracker at L<http://rt.cpan.org/>.
1193 POD 
1194 POD Please include the following information:
1195 POD 
1196 POD =over 4
1197 POD 
1198 POD =item 1.
1199 POD 
1200 POD The complete output from running "perl -V"
1201 POD 
1202 POD =item 2.
1203 POD 
1204 POD This file.
1205 POD 
1206 POD =item 3.
1207 POD 
1208 POD The name and version of the module you were trying to build.
1209 POD 
1210 POD =item 4.
1211 POD 
1212 POD A full log of the build that failed.
1213 POD 
1214 POD =item 5.
1215 POD 
1216 POD Any other information that you think could be relevant.
1217 POD 
1218 POD =back
1219 POD 
1220 POD For the latest version of this code, please get the C<Devel::PPPort>
1221 POD module from CPAN.
1222 POD 
1223 POD =head1 COPYRIGHT
1224 POD 
1225 POD Version 3.x, Copyright (c) 2004-2005, Marcus Holland-Moritz.
1226 POD 
1227 POD Version 2.x, Copyright (C) 2001, Paul Marquess.
1228 POD 
1229 POD Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
1230 POD 
1231 POD This program is free software; you can redistribute it and/or
1232 POD modify it under the same terms as Perl itself.
1233 POD 
1234 POD =head1 SEE ALSO
1235 POD 
1236 POD See L<Devel::PPPort>.
1237
1238 =cut
1239
1240 use strict;
1241
1242 my %opt = (
1243   quiet     => 0,
1244   diag      => 1,
1245   hints     => 1,
1246   changes   => 1,
1247   cplusplus => 0,
1248 );
1249
1250 my($ppport) = $0 =~ /([\w.]+)$/;
1251 my $LF = '(?:\r\n|[\r\n])';   # line feed
1252 my $HS = "[ \t]";             # horizontal whitespace
1253
1254 eval {
1255   require Getopt::Long;
1256   Getopt::Long::GetOptions(\%opt, qw(
1257     help quiet diag! hints! changes! cplusplus
1258     patch=s copy=s diff=s compat-version=s
1259     list-provided list-unsupported api-info=s
1260   )) or usage();
1261 };
1262
1263 if ($@ and grep /^-/, @ARGV) {
1264   usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
1265   die "Getopt::Long not found. Please don't use any options.\n";
1266 }
1267
1268 usage() if $opt{help};
1269
1270 if (exists $opt{'compat-version'}) {
1271   my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
1272   if ($@) {
1273     die "Invalid version number format: '$opt{'compat-version'}'\n";
1274   }
1275   die "Only Perl 5 is supported\n" if $r != 5;
1276   die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $v >= 1000;
1277   $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
1278 }
1279 else {
1280   $opt{'compat-version'} = 5;
1281 }
1282
1283 # Never use C comments in this file!!!!!
1284 my $ccs  = '/'.'*';
1285 my $cce  = '*'.'/';
1286 my $rccs = quotemeta $ccs;
1287 my $rcce = quotemeta $cce;
1288
1289 my @files;
1290
1291 if (@ARGV) {
1292   @files = map { glob $_ } @ARGV;
1293 }
1294 else {
1295   eval {
1296     require File::Find;
1297     File::Find::find(sub {
1298       $File::Find::name =~ /\.(xs|c|h|cc)$/i
1299           and push @files, $File::Find::name;
1300     }, '.');
1301   };
1302   if ($@) {
1303     @files = map { glob $_ } qw(*.xs *.c *.h *.cc);
1304   }
1305   my %filter = map { /(.*)\.xs$/ ? ("$1.c" => 1) : () } @files;
1306   @files = grep { !/\b\Q$ppport\E$/i && !exists $filter{$_} } @files;
1307 }
1308
1309 unless (@files) {
1310   die "No input files given!\n";
1311 }
1312
1313 my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
1314                 ? ( $1 => { 
1315                       ($2                  ? ( base     => $2 ) : ()),
1316                       ($3                  ? ( todo     => $3 ) : ()),
1317                       (index($4, 'v') >= 0 ? ( varargs  => 1  ) : ()),
1318                       (index($4, 'p') >= 0 ? ( provided => 1  ) : ()),
1319                       (index($4, 'n') >= 0 ? ( nothxarg => 1  ) : ()),
1320                     } )
1321                 : die "invalid spec: $_" } qw(
1322 AvFILLp|5.004050||p
1323 AvFILL|||
1324 CLASS|||n
1325 CX_CURPAD_SAVE|||
1326 CX_CURPAD_SV|||
1327 CopFILEAV|5.006000||p
1328 CopFILEGV_set|5.006000||p
1329 CopFILEGV|5.006000||p
1330 CopFILESV|5.006000||p
1331 CopFILE_set|5.006000||p
1332 CopFILE|5.006000||p
1333 CopSTASHPV_set|5.006000||p
1334 CopSTASHPV|5.006000||p
1335 CopSTASH_eq|5.006000||p
1336 CopSTASH_set|5.006000||p
1337 CopSTASH|5.006000||p
1338 CopyD|5.009002||p
1339 Copy|||
1340 CvPADLIST|||
1341 CvSTASH|||
1342 CvWEAKOUTSIDE|||
1343 DEFSV|5.004050||p
1344 END_EXTERN_C|5.005000||p
1345 ENTER|||
1346 ERRSV|5.004050||p
1347 EXTEND|||
1348 EXTERN_C|5.005000||p
1349 FREETMPS|||
1350 GIMME_V||5.004000|n
1351 GIMME|||n
1352 GROK_NUMERIC_RADIX|5.007002||p
1353 G_ARRAY|||
1354 G_DISCARD|||
1355 G_EVAL|||
1356 G_NOARGS|||
1357 G_SCALAR|||
1358 G_VOID||5.004000|
1359 GetVars|||
1360 GvSV|||
1361 Gv_AMupdate|||
1362 HEf_SVKEY||5.004000|
1363 HeHASH||5.004000|
1364 HeKEY||5.004000|
1365 HeKLEN||5.004000|
1366 HePV||5.004000|
1367 HeSVKEY_force||5.004000|
1368 HeSVKEY_set||5.004000|
1369 HeSVKEY||5.004000|
1370 HeVAL||5.004000|
1371 HvNAME|||
1372 INT2PTR|5.006000||p
1373 IN_LOCALE_COMPILETIME|5.007002||p
1374 IN_LOCALE_RUNTIME|5.007002||p
1375 IN_LOCALE|5.007002||p
1376 IN_PERL_COMPILETIME|5.008001||p
1377 IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
1378 IS_NUMBER_INFINITY|5.007002||p
1379 IS_NUMBER_IN_UV|5.007002||p
1380 IS_NUMBER_NAN|5.007003||p
1381 IS_NUMBER_NEG|5.007002||p
1382 IS_NUMBER_NOT_INT|5.007002||p
1383 IVSIZE|5.006000||p
1384 IVTYPE|5.006000||p
1385 IVdf|5.006000||p
1386 LEAVE|||
1387 LVRET|||
1388 MARK|||
1389 MY_CXT_CLONE|5.009002||p
1390 MY_CXT_INIT|5.007003||p
1391 MY_CXT|5.007003||p
1392 MoveD|5.009002||p
1393 Move|||
1394 NEWSV|||
1395 NOOP|5.005000||p
1396 NUM2PTR|5.006000||p
1397 NVTYPE|5.006000||p
1398 NVef|5.006001||p
1399 NVff|5.006001||p
1400 NVgf|5.006001||p
1401 Newc|||
1402 Newz|||
1403 New|||
1404 Nullav|||
1405 Nullch|||
1406 Nullcv|||
1407 Nullhv|||
1408 Nullsv|||
1409 ORIGMARK|||
1410 PAD_BASE_SV|||
1411 PAD_CLONE_VARS|||
1412 PAD_COMPNAME_FLAGS|||
1413 PAD_COMPNAME_GEN|||
1414 PAD_COMPNAME_OURSTASH|||
1415 PAD_COMPNAME_PV|||
1416 PAD_COMPNAME_TYPE|||
1417 PAD_RESTORE_LOCAL|||
1418 PAD_SAVE_LOCAL|||
1419 PAD_SAVE_SETNULLPAD|||
1420 PAD_SETSV|||
1421 PAD_SET_CUR_NOSAVE|||
1422 PAD_SET_CUR|||
1423 PAD_SVl|||
1424 PAD_SV|||
1425 PERL_BCDVERSION|5.009002||p
1426 PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
1427 PERL_INT_MAX|5.004000||p
1428 PERL_INT_MIN|5.004000||p
1429 PERL_LONG_MAX|5.004000||p
1430 PERL_LONG_MIN|5.004000||p
1431 PERL_MAGIC_arylen|5.007002||p
1432 PERL_MAGIC_backref|5.007002||p
1433 PERL_MAGIC_bm|5.007002||p
1434 PERL_MAGIC_collxfrm|5.007002||p
1435 PERL_MAGIC_dbfile|5.007002||p
1436 PERL_MAGIC_dbline|5.007002||p
1437 PERL_MAGIC_defelem|5.007002||p
1438 PERL_MAGIC_envelem|5.007002||p
1439 PERL_MAGIC_env|5.007002||p
1440 PERL_MAGIC_ext|5.007002||p
1441 PERL_MAGIC_fm|5.007002||p
1442 PERL_MAGIC_glob|5.007002||p
1443 PERL_MAGIC_isaelem|5.007002||p
1444 PERL_MAGIC_isa|5.007002||p
1445 PERL_MAGIC_mutex|5.007002||p
1446 PERL_MAGIC_nkeys|5.007002||p
1447 PERL_MAGIC_overload_elem|5.007002||p
1448 PERL_MAGIC_overload_table|5.007002||p
1449 PERL_MAGIC_overload|5.007002||p
1450 PERL_MAGIC_pos|5.007002||p
1451 PERL_MAGIC_qr|5.007002||p
1452 PERL_MAGIC_regdata|5.007002||p
1453 PERL_MAGIC_regdatum|5.007002||p
1454 PERL_MAGIC_regex_global|5.007002||p
1455 PERL_MAGIC_shared_scalar|5.007003||p
1456 PERL_MAGIC_shared|5.007003||p
1457 PERL_MAGIC_sigelem|5.007002||p
1458 PERL_MAGIC_sig|5.007002||p
1459 PERL_MAGIC_substr|5.007002||p
1460 PERL_MAGIC_sv|5.007002||p
1461 PERL_MAGIC_taint|5.007002||p
1462 PERL_MAGIC_tiedelem|5.007002||p
1463 PERL_MAGIC_tiedscalar|5.007002||p
1464 PERL_MAGIC_tied|5.007002||p
1465 PERL_MAGIC_utf8|5.008001||p
1466 PERL_MAGIC_uvar_elem|5.007003||p
1467 PERL_MAGIC_uvar|5.007002||p
1468 PERL_MAGIC_vec|5.007002||p
1469 PERL_MAGIC_vstring|5.008001||p
1470 PERL_QUAD_MAX|5.004000||p
1471 PERL_QUAD_MIN|5.004000||p
1472 PERL_REVISION|5.006000||p
1473 PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
1474 PERL_SCAN_DISALLOW_PREFIX|5.007003||p
1475 PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
1476 PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
1477 PERL_SHORT_MAX|5.004000||p
1478 PERL_SHORT_MIN|5.004000||p
1479 PERL_SUBVERSION|5.006000||p
1480 PERL_UCHAR_MAX|5.004000||p
1481 PERL_UCHAR_MIN|5.004000||p
1482 PERL_UINT_MAX|5.004000||p
1483 PERL_UINT_MIN|5.004000||p
1484 PERL_ULONG_MAX|5.004000||p
1485 PERL_ULONG_MIN|5.004000||p
1486 PERL_UNUSED_DECL|5.007002||p
1487 PERL_UQUAD_MAX|5.004000||p
1488 PERL_UQUAD_MIN|5.004000||p
1489 PERL_USHORT_MAX|5.004000||p
1490 PERL_USHORT_MIN|5.004000||p
1491 PERL_VERSION|5.006000||p
1492 PL_DBsingle|||pn
1493 PL_DBsub|||pn
1494 PL_DBtrace|||n
1495 PL_Sv|5.005000||p
1496 PL_compiling|5.004050||p
1497 PL_copline|5.005000||p
1498 PL_curcop|5.004050||p
1499 PL_curstash|5.004050||p
1500 PL_debstash|5.004050||p
1501 PL_defgv|5.004050||p
1502 PL_diehook|5.004050||p
1503 PL_dirty|5.004050||p
1504 PL_dowarn|||pn
1505 PL_errgv|5.004050||p
1506 PL_hexdigit|5.005000||p
1507 PL_hints|5.005000||p
1508 PL_last_in_gv|||n
1509 PL_modglobal||5.005000|n
1510 PL_na|5.004050||pn
1511 PL_no_modify|5.006000||p
1512 PL_ofs_sv|||n
1513 PL_perl_destruct_level|5.004050||p
1514 PL_perldb|5.004050||p
1515 PL_ppaddr|5.006000||p
1516 PL_rsfp_filters|5.004050||p
1517 PL_rsfp|5.004050||p
1518 PL_rs|||n
1519 PL_stack_base|5.004050||p
1520 PL_stack_sp|5.004050||p
1521 PL_stdingv|5.004050||p
1522 PL_sv_arenaroot|5.004050||p
1523 PL_sv_no|5.004050||pn
1524 PL_sv_undef|5.004050||pn
1525 PL_sv_yes|5.004050||pn
1526 PL_tainted|5.004050||p
1527 PL_tainting|5.004050||p
1528 POPi|||n
1529 POPl|||n
1530 POPn|||n
1531 POPpbytex||5.007001|n
1532 POPpx||5.005030|n
1533 POPp|||n
1534 POPs|||n
1535 PTR2IV|5.006000||p
1536 PTR2NV|5.006000||p
1537 PTR2UV|5.006000||p
1538 PTR2ul|5.007001||p
1539 PTRV|5.006000||p
1540 PUSHMARK|||
1541 PUSHi|||
1542 PUSHmortal|5.009002||p
1543 PUSHn|||
1544 PUSHp|||
1545 PUSHs|||
1546 PUSHu|5.004000||p
1547 PUTBACK|||
1548 PerlIO_clearerr||5.007003|
1549 PerlIO_close||5.007003|
1550 PerlIO_eof||5.007003|
1551 PerlIO_error||5.007003|
1552 PerlIO_fileno||5.007003|
1553 PerlIO_fill||5.007003|
1554 PerlIO_flush||5.007003|
1555 PerlIO_get_base||5.007003|
1556 PerlIO_get_bufsiz||5.007003|
1557 PerlIO_get_cnt||5.007003|
1558 PerlIO_get_ptr||5.007003|
1559 PerlIO_read||5.007003|
1560 PerlIO_seek||5.007003|
1561 PerlIO_set_cnt||5.007003|
1562 PerlIO_set_ptrcnt||5.007003|
1563 PerlIO_setlinebuf||5.007003|
1564 PerlIO_stderr||5.007003|
1565 PerlIO_stdin||5.007003|
1566 PerlIO_stdout||5.007003|
1567 PerlIO_tell||5.007003|
1568 PerlIO_unread||5.007003|
1569 PerlIO_write||5.007003|
1570 Poison|5.008000||p
1571 RETVAL|||n
1572 Renewc|||
1573 Renew|||
1574 SAVECLEARSV|||
1575 SAVECOMPPAD|||
1576 SAVEPADSV|||
1577 SAVETMPS|||
1578 SAVE_DEFSV|5.004050||p
1579 SPAGAIN|||
1580 SP|||
1581 START_EXTERN_C|5.005000||p
1582 START_MY_CXT|5.007003||p
1583 STMT_END|||p
1584 STMT_START|||p
1585 ST|||
1586 SVt_IV|||
1587 SVt_NV|||
1588 SVt_PVAV|||
1589 SVt_PVCV|||
1590 SVt_PVHV|||
1591 SVt_PVMG|||
1592 SVt_PV|||
1593 Safefree|||
1594 Slab_Alloc|||
1595 Slab_Free|||
1596 StructCopy|||
1597 SvCUR_set|||
1598 SvCUR|||
1599 SvEND|||
1600 SvGETMAGIC|5.004050||p
1601 SvGROW|||
1602 SvIOK_UV||5.006000|
1603 SvIOK_notUV||5.006000|
1604 SvIOK_off|||
1605 SvIOK_only_UV||5.006000|
1606 SvIOK_only|||
1607 SvIOK_on|||
1608 SvIOKp|||
1609 SvIOK|||
1610 SvIVX|||
1611 SvIV_nomg|5.009001||p
1612 SvIVx|||
1613 SvIV|||
1614 SvIsCOW_shared_hash||5.008003|
1615 SvIsCOW||5.008003|
1616 SvLEN|||
1617 SvLOCK||5.007003|
1618 SvNIOK_off|||
1619 SvNIOKp|||
1620 SvNIOK|||
1621 SvNOK_off|||
1622 SvNOK_only|||
1623 SvNOK_on|||
1624 SvNOKp|||
1625 SvNOK|||
1626 SvNVX|||
1627 SvNVx|||
1628 SvNV|||
1629 SvOK|||
1630 SvOOK|||
1631 SvPOK_off|||
1632 SvPOK_only_UTF8||5.006000|
1633 SvPOK_only|||
1634 SvPOK_on|||
1635 SvPOKp|||
1636 SvPOK|||
1637 SvPVX|||
1638 SvPV_force_nomg|5.007002||p
1639 SvPV_force|||
1640 SvPV_nolen|5.006000||p
1641 SvPV_nomg|5.007002||p
1642 SvPVbyte_force||5.009002|
1643 SvPVbyte_nolen||5.006000|
1644 SvPVbytex_force||5.006000|
1645 SvPVbytex||5.006000|
1646 SvPVbyte|5.006000||p
1647 SvPVutf8_force||5.006000|
1648 SvPVutf8_nolen||5.006000|
1649 SvPVutf8x_force||5.006000|
1650 SvPVutf8x||5.006000|
1651 SvPVutf8||5.006000|
1652 SvPVx|||
1653 SvPV|||
1654 SvREFCNT_dec|||
1655 SvREFCNT_inc|||
1656 SvREFCNT|||
1657 SvROK_off|||
1658 SvROK_on|||
1659 SvROK|||
1660 SvRV|||
1661 SvSETMAGIC|||
1662 SvSHARE||5.007003|
1663 SvSTASH|||
1664 SvSetMagicSV_nosteal||5.004000|
1665 SvSetMagicSV||5.004000|
1666 SvSetSV_nosteal||5.004000|
1667 SvSetSV|||
1668 SvTAINTED_off||5.004000|
1669 SvTAINTED_on||5.004000|
1670 SvTAINTED||5.004000|
1671 SvTAINT|||
1672 SvTRUE|||
1673 SvTYPE|||
1674 SvUNLOCK||5.007003|
1675 SvUOK||5.007001|
1676 SvUPGRADE|||
1677 SvUTF8_off||5.006000|
1678 SvUTF8_on||5.006000|
1679 SvUTF8||5.006000|
1680 SvUVXx|5.004000||p
1681 SvUVX|5.004000||p
1682 SvUV_nomg|5.009001||p
1683 SvUVx|5.004000||p
1684 SvUV|5.004000||p
1685 SvVOK||5.008001|
1686 THIS|||n
1687 UNDERBAR|5.009002||p
1688 UVSIZE|5.006000||p
1689 UVTYPE|5.006000||p
1690 UVXf|5.007001||p
1691 UVof|5.006000||p
1692 UVuf|5.006000||p
1693 UVxf|5.006000||p
1694 XCPT_CATCH|5.009002||p
1695 XCPT_RETHROW|5.009002||p
1696 XCPT_TRY_END|5.009002||p
1697 XCPT_TRY_START|5.009002||p
1698 XPUSHi|||
1699 XPUSHmortal|5.009002||p
1700 XPUSHn|||
1701 XPUSHp|||
1702 XPUSHs|||
1703 XPUSHu|5.004000||p
1704 XSRETURN_EMPTY|||
1705 XSRETURN_IV|||
1706 XSRETURN_NO|||
1707 XSRETURN_NV|||
1708 XSRETURN_PV|||
1709 XSRETURN_UNDEF|||
1710 XSRETURN_UV|5.008001||p
1711 XSRETURN_YES|||
1712 XSRETURN|||
1713 XST_mIV|||
1714 XST_mNO|||
1715 XST_mNV|||
1716 XST_mPV|||
1717 XST_mUNDEF|||
1718 XST_mUV|5.008001||p
1719 XST_mYES|||
1720 XS_VERSION_BOOTCHECK|||
1721 XS_VERSION|||
1722 XS|||
1723 ZeroD|5.009002||p
1724 Zero|||
1725 _aMY_CXT|5.007003||p
1726 _pMY_CXT|5.007003||p
1727 aMY_CXT_|5.007003||p
1728 aMY_CXT|5.007003||p
1729 aTHX_|5.006000||p
1730 aTHX|5.006000||p
1731 add_data|||
1732 allocmy|||
1733 amagic_call|||
1734 any_dup|||
1735 ao|||
1736 append_elem|||
1737 append_list|||
1738 apply_attrs_my|||
1739 apply_attrs_string||5.006001|
1740 apply_attrs|||
1741 apply|||
1742 asIV|||
1743 asUV|||
1744 atfork_lock||5.007003|n
1745 atfork_unlock||5.007003|n
1746 av_clear|||
1747 av_delete||5.006000|
1748 av_exists||5.006000|
1749 av_extend|||
1750 av_fake|||
1751 av_fetch|||
1752 av_fill|||
1753 av_len|||
1754 av_make|||
1755 av_pop|||
1756 av_push|||
1757 av_reify|||
1758 av_shift|||
1759 av_store|||
1760 av_undef|||
1761 av_unshift|||
1762 ax|||n
1763 bad_type|||
1764 bind_match|||
1765 block_end|||
1766 block_gimme||5.004000|
1767 block_start|||
1768 boolSV|5.004000||p
1769 boot_core_PerlIO|||
1770 boot_core_UNIVERSAL|||
1771 boot_core_xsutils|||
1772 bytes_from_utf8||5.007001|
1773 bytes_to_utf8||5.006001|
1774 cache_re|||
1775 call_argv|5.006000||p
1776 call_atexit||5.006000|
1777 call_body|||
1778 call_list_body|||
1779 call_list||5.004000|
1780 call_method|5.006000||p
1781 call_pv|5.006000||p
1782 call_sv|5.006000||p
1783 calloc||5.007002|n
1784 cando|||
1785 cast_i32||5.006000|
1786 cast_iv||5.006000|
1787 cast_ulong||5.006000|
1788 cast_uv||5.006000|
1789 check_uni|||
1790 checkcomma|||
1791 checkposixcc|||
1792 cl_and|||
1793 cl_anything|||
1794 cl_init_zero|||
1795 cl_init|||
1796 cl_is_anything|||
1797 cl_or|||
1798 closest_cop|||
1799 convert|||
1800 cop_free|||
1801 cr_textfilter|||
1802 croak_nocontext|||vn
1803 croak|||v
1804 csighandler||5.007001|n
1805 custom_op_desc||5.007003|
1806 custom_op_name||5.007003|
1807 cv_ckproto|||
1808 cv_clone|||
1809 cv_const_sv||5.004000|
1810 cv_dump|||
1811 cv_undef|||
1812 cx_dump||5.005000|
1813 cx_dup|||
1814 cxinc|||
1815 dAX|5.007002||p
1816 dITEMS|5.007002||p
1817 dMARK|||
1818 dMY_CXT_SV|5.007003||p
1819 dMY_CXT|5.007003||p
1820 dNOOP|5.006000||p
1821 dORIGMARK|||
1822 dSP|||
1823 dTHR|5.004050||p
1824 dTHXa|5.006000||p
1825 dTHXoa|5.006000||p
1826 dTHX|5.006000||p
1827 dUNDERBAR|5.009002||p
1828 dXCPT|5.009002||p
1829 dXSARGS|||
1830 dXSI32|||
1831 dXSTARG|5.006000||p
1832 deb_curcv|||
1833 deb_nocontext|||vn
1834 deb_stack_all|||
1835 deb_stack_n|||
1836 debop||5.005000|
1837 debprofdump||5.005000|
1838 debprof|||
1839 debstackptrs||5.007003|
1840 debstack||5.007003|
1841 deb||5.007003|v
1842 del_he|||
1843 del_sv|||
1844 del_xiv|||
1845 del_xnv|||
1846 del_xpvav|||
1847 del_xpvbm|||
1848 del_xpvcv|||
1849 del_xpvhv|||
1850 del_xpviv|||
1851 del_xpvlv|||
1852 del_xpvmg|||
1853 del_xpvnv|||
1854 del_xpv|||
1855 del_xrv|||
1856 delimcpy||5.004000|
1857 depcom|||
1858 deprecate_old|||
1859 deprecate|||
1860 despatch_signals||5.007001|
1861 die_nocontext|||vn
1862 die_where|||
1863 die|||v
1864 dirp_dup|||
1865 div128|||
1866 djSP|||
1867 do_aexec5|||
1868 do_aexec|||
1869 do_aspawn|||
1870 do_binmode||5.004050|
1871 do_chomp|||
1872 do_chop|||
1873 do_close|||
1874 do_dump_pad|||
1875 do_eof|||
1876 do_exec3|||
1877 do_execfree|||
1878 do_exec|||
1879 do_gv_dump||5.006000|
1880 do_gvgv_dump||5.006000|
1881 do_hv_dump||5.006000|
1882 do_ipcctl|||
1883 do_ipcget|||
1884 do_join|||
1885 do_kv|||
1886 do_magic_dump||5.006000|
1887 do_msgrcv|||
1888 do_msgsnd|||
1889 do_oddball|||
1890 do_op_dump||5.006000|
1891 do_open9||5.006000|
1892 do_openn||5.007001|
1893 do_open||5.004000|
1894 do_pipe|||
1895 do_pmop_dump||5.006000|
1896 do_print|||
1897 do_readline|||
1898 do_seek|||
1899 do_semop|||
1900 do_shmio|||
1901 do_spawn_nowait|||
1902 do_spawn|||
1903 do_sprintf|||
1904 do_sv_dump||5.006000|
1905 do_sysseek|||
1906 do_tell|||
1907 do_trans_complex_utf8|||
1908 do_trans_complex|||
1909 do_trans_count_utf8|||
1910 do_trans_count|||
1911 do_trans_simple_utf8|||
1912 do_trans_simple|||
1913 do_trans|||
1914 do_vecget|||
1915 do_vecset|||
1916 do_vop|||
1917 docatch_body|||
1918 docatch|||
1919 doencodes|||
1920 doeval|||
1921 dofile|||
1922 dofindlabel|||
1923 doform|||
1924 doing_taint||5.008001|n
1925 dooneliner|||
1926 doopen_pm|||
1927 doparseform|||
1928 dopoptoeval|||
1929 dopoptolabel|||
1930 dopoptoloop|||
1931 dopoptosub_at|||
1932 dopoptosub|||
1933 dounwind|||
1934 dowantarray|||
1935 dump_all||5.006000|
1936 dump_eval||5.006000|
1937 dump_fds|||
1938 dump_form||5.006000|
1939 dump_indent||5.006000|v
1940 dump_mstats|||
1941 dump_packsubs||5.006000|
1942 dump_sub||5.006000|
1943 dump_vindent||5.006000|
1944 dumpuntil|||
1945 dup_attrlist|||
1946 emulate_eaccess|||
1947 eval_pv|5.006000||p
1948 eval_sv|5.006000||p
1949 expect_number|||
1950 fbm_compile||5.005000|
1951 fbm_instr||5.005000|
1952 fd_on_nosuid_fs|||
1953 filter_add|||
1954 filter_del|||
1955 filter_gets|||
1956 filter_read|||
1957 find_beginning|||
1958 find_byclass|||
1959 find_in_my_stash|||
1960 find_runcv|||
1961 find_rundefsvoffset||5.009002|
1962 find_script|||
1963 find_uninit_var|||
1964 fold_constants|||
1965 forbid_setid|||
1966 force_ident|||
1967 force_list|||
1968 force_next|||
1969 force_version|||
1970 force_word|||
1971 form_nocontext|||vn
1972 form||5.004000|v
1973 fp_dup|||
1974 fprintf_nocontext|||vn
1975 free_tied_hv_pool|||
1976 free_tmps|||
1977 gen_constant_list|||
1978 get_av|5.006000||p
1979 get_context||5.006000|n
1980 get_cv|5.006000||p
1981 get_db_sub|||
1982 get_debug_opts|||
1983 get_hash_seed|||
1984 get_hv|5.006000||p
1985 get_mstats|||
1986 get_no_modify|||
1987 get_num|||
1988 get_op_descs||5.005000|
1989 get_op_names||5.005000|
1990 get_opargs|||
1991 get_ppaddr||5.006000|
1992 get_sv|5.006000||p
1993 get_vtbl||5.005030|
1994 getcwd_sv||5.007002|
1995 getenv_len|||
1996 gp_dup|||
1997 gp_free|||
1998 gp_ref|||
1999 grok_bin|5.007003||p
2000 grok_hex|5.007003||p
2001 grok_number|5.007002||p
2002 grok_numeric_radix|5.007002||p
2003 grok_oct|5.007003||p
2004 group_end|||
2005 gv_AVadd|||
2006 gv_HVadd|||
2007 gv_IOadd|||
2008 gv_autoload4||5.004000|
2009 gv_check|||
2010 gv_dump||5.006000|
2011 gv_efullname3||5.004000|
2012 gv_efullname4||5.006001|
2013 gv_efullname|||
2014 gv_ename|||
2015 gv_fetchfile|||
2016 gv_fetchmeth_autoload||5.007003|
2017 gv_fetchmethod_autoload||5.004000|
2018 gv_fetchmethod|||
2019 gv_fetchmeth|||
2020 gv_fetchpvn_flags||5.009002|
2021 gv_fetchpv|||
2022 gv_fetchsv||5.009002|
2023 gv_fullname3||5.004000|
2024 gv_fullname4||5.006001|
2025 gv_fullname|||
2026 gv_handler||5.007001|
2027 gv_init_sv|||
2028 gv_init|||
2029 gv_share|||
2030 gv_stashpvn|5.006000||p
2031 gv_stashpv|||
2032 gv_stashsv|||
2033 he_dup|||
2034 hfreeentries|||
2035 hsplit|||
2036 hv_assert||5.009001|
2037 hv_clear_placeholders||5.009001|
2038 hv_clear|||
2039 hv_delayfree_ent||5.004000|
2040 hv_delete_common|||
2041 hv_delete_ent||5.004000|
2042 hv_delete|||
2043 hv_exists_ent||5.004000|
2044 hv_exists|||
2045 hv_fetch_common|||
2046 hv_fetch_ent||5.004000|
2047 hv_fetch|||
2048 hv_free_ent||5.004000|
2049 hv_iterinit|||
2050 hv_iterkeysv||5.004000|
2051 hv_iterkey|||
2052 hv_iternext_flags||5.008000|
2053 hv_iternextsv|||
2054 hv_iternext|||
2055 hv_iterval|||
2056 hv_ksplit||5.004000|
2057 hv_magic_check|||
2058 hv_magic|||
2059 hv_notallowed|||
2060 hv_scalar||5.009001|
2061 hv_store_ent||5.004000|
2062 hv_store_flags||5.008000|
2063 hv_store|||
2064 hv_undef|||
2065 ibcmp_locale||5.004000|
2066 ibcmp_utf8||5.007003|
2067 ibcmp|||
2068 incl_perldb|||
2069 incline|||
2070 incpush|||
2071 ingroup|||
2072 init_argv_symbols|||
2073 init_debugger|||
2074 init_i18nl10n||5.006000|
2075 init_i18nl14n||5.006000|
2076 init_ids|||
2077 init_interp|||
2078 init_lexer|||
2079 init_main_stash|||
2080 init_perllib|||
2081 init_postdump_symbols|||
2082 init_predump_symbols|||
2083 init_stacks||5.005000|
2084 init_tm||5.007002|
2085 instr|||
2086 intro_my|||
2087 intuit_method|||
2088 intuit_more|||
2089 invert|||
2090 io_close|||
2091 isALNUM|||
2092 isALPHA|||
2093 isDIGIT|||
2094 isLOWER|||
2095 isSPACE|||
2096 isUPPER|||
2097 is_an_int|||
2098 is_gv_magical_sv|||
2099 is_gv_magical|||
2100 is_handle_constructor|||
2101 is_lvalue_sub||5.007001|
2102 is_uni_alnum_lc||5.006000|
2103 is_uni_alnumc_lc||5.006000|
2104 is_uni_alnumc||5.006000|
2105 is_uni_alnum||5.006000|
2106 is_uni_alpha_lc||5.006000|
2107 is_uni_alpha||5.006000|
2108 is_uni_ascii_lc||5.006000|
2109 is_uni_ascii||5.006000|
2110 is_uni_cntrl_lc||5.006000|
2111 is_uni_cntrl||5.006000|
2112 is_uni_digit_lc||5.006000|
2113 is_uni_digit||5.006000|
2114 is_uni_graph_lc||5.006000|
2115 is_uni_graph||5.006000|
2116 is_uni_idfirst_lc||5.006000|
2117 is_uni_idfirst||5.006000|
2118 is_uni_lower_lc||5.006000|
2119 is_uni_lower||5.006000|
2120 is_uni_print_lc||5.006000|
2121 is_uni_print||5.006000|
2122 is_uni_punct_lc||5.006000|
2123 is_uni_punct||5.006000|
2124 is_uni_space_lc||5.006000|
2125 is_uni_space||5.006000|
2126 is_uni_upper_lc||5.006000|
2127 is_uni_upper||5.006000|
2128 is_uni_xdigit_lc||5.006000|
2129 is_uni_xdigit||5.006000|
2130 is_utf8_alnumc||5.006000|
2131 is_utf8_alnum||5.006000|
2132 is_utf8_alpha||5.006000|
2133 is_utf8_ascii||5.006000|
2134 is_utf8_char||5.006000|
2135 is_utf8_cntrl||5.006000|
2136 is_utf8_digit||5.006000|
2137 is_utf8_graph||5.006000|
2138 is_utf8_idcont||5.008000|
2139 is_utf8_idfirst||5.006000|
2140 is_utf8_lower||5.006000|
2141 is_utf8_mark||5.006000|
2142 is_utf8_print||5.006000|
2143 is_utf8_punct||5.006000|
2144 is_utf8_space||5.006000|
2145 is_utf8_string_loc||5.008001|
2146 is_utf8_string||5.006001|
2147 is_utf8_upper||5.006000|
2148 is_utf8_xdigit||5.006000|
2149 isa_lookup|||
2150 items|||n
2151 ix|||n
2152 jmaybe|||
2153 keyword|||
2154 leave_scope|||
2155 lex_end|||
2156 lex_start|||
2157 linklist|||
2158 list_assignment|||
2159 listkids|||
2160 list|||
2161 load_module_nocontext|||vn
2162 load_module||5.006000|v
2163 localize|||
2164 looks_like_number|||
2165 lop|||
2166 mPUSHi|5.009002||p
2167 mPUSHn|5.009002||p
2168 mPUSHp|5.009002||p
2169 mPUSHu|5.009002||p
2170 mXPUSHi|5.009002||p
2171 mXPUSHn|5.009002||p
2172 mXPUSHp|5.009002||p
2173 mXPUSHu|5.009002||p
2174 magic_clear_all_env|||
2175 magic_clearenv|||
2176 magic_clearpack|||
2177 magic_clearsig|||
2178 magic_dump||5.006000|
2179 magic_existspack|||
2180 magic_freeovrld|||
2181 magic_freeregexp|||
2182 magic_getarylen|||
2183 magic_getdefelem|||
2184 magic_getglob|||
2185 magic_getnkeys|||
2186 magic_getpack|||
2187 magic_getpos|||
2188 magic_getsig|||
2189 magic_getsubstr|||
2190 magic_gettaint|||
2191 magic_getuvar|||
2192 magic_getvec|||
2193 magic_get|||
2194 magic_killbackrefs|||
2195 magic_len|||
2196 magic_methcall|||
2197 magic_methpack|||
2198 magic_nextpack|||
2199 magic_regdata_cnt|||
2200 magic_regdatum_get|||
2201 magic_regdatum_set|||
2202 magic_scalarpack|||
2203 magic_set_all_env|||
2204 magic_setamagic|||
2205 magic_setarylen|||
2206 magic_setbm|||
2207 magic_setcollxfrm|||
2208 magic_setdbline|||
2209 magic_setdefelem|||
2210 magic_setenv|||
2211 magic_setfm|||
2212 magic_setglob|||
2213 magic_setisa|||
2214 magic_setmglob|||
2215 magic_setnkeys|||
2216 magic_setpack|||
2217 magic_setpos|||
2218 magic_setregexp|||
2219 magic_setsig|||
2220 magic_setsubstr|||
2221 magic_settaint|||
2222 magic_setutf8|||
2223 magic_setuvar|||
2224 magic_setvec|||
2225 magic_set|||
2226 magic_sizepack|||
2227 magic_wipepack|||
2228 magicname|||
2229 malloced_size|||n
2230 malloc||5.007002|n
2231 markstack_grow|||
2232 measure_struct|||
2233 memEQ|5.004000||p
2234 memNE|5.004000||p
2235 mem_collxfrm|||
2236 mess_alloc|||
2237 mess_nocontext|||vn
2238 mess||5.006000|v
2239 method_common|||
2240 mfree||5.007002|n
2241 mg_clear|||
2242 mg_copy|||
2243 mg_dup|||
2244 mg_find|||
2245 mg_free|||
2246 mg_get|||
2247 mg_length||5.005000|
2248 mg_magical|||
2249 mg_set|||
2250 mg_size||5.005000|
2251 mini_mktime||5.007002|
2252 missingterm|||
2253 mode_from_discipline|||
2254 modkids|||
2255 mod|||
2256 more_he|||
2257 more_sv|||
2258 more_xiv|||
2259 more_xnv|||
2260 more_xpvav|||
2261 more_xpvbm|||
2262 more_xpvcv|||
2263 more_xpvhv|||
2264 more_xpviv|||
2265 more_xpvlv|||
2266 more_xpvmg|||
2267 more_xpvnv|||
2268 more_xpv|||
2269 more_xrv|||
2270 moreswitches|||
2271 mul128|||
2272 mulexp10|||n
2273 my_atof2||5.007002|
2274 my_atof||5.006000|
2275 my_attrs|||
2276 my_bcopy|||n
2277 my_betoh16|||n
2278 my_betoh32|||n
2279 my_betoh64|||n
2280 my_betohi|||n
2281 my_betohl|||n
2282 my_betohs|||n
2283 my_bzero|||n
2284 my_chsize|||
2285 my_exit_jump|||
2286 my_exit|||
2287 my_failure_exit||5.004000|
2288 my_fflush_all||5.006000|
2289 my_fork||5.007003|n
2290 my_htobe16|||n
2291 my_htobe32|||n
2292 my_htobe64|||n
2293 my_htobei|||n
2294 my_htobel|||n
2295 my_htobes|||n
2296 my_htole16|||n
2297 my_htole32|||n
2298 my_htole64|||n
2299 my_htolei|||n
2300 my_htolel|||n
2301 my_htoles|||n
2302 my_htonl|||
2303 my_kid|||
2304 my_letoh16|||n
2305 my_letoh32|||n
2306 my_letoh64|||n
2307 my_letohi|||n
2308 my_letohl|||n
2309 my_letohs|||n
2310 my_lstat|||
2311 my_memcmp||5.004000|n
2312 my_memset|||n
2313 my_ntohl|||
2314 my_pclose||5.004000|
2315 my_popen_list||5.007001|
2316 my_popen||5.004000|
2317 my_setenv|||
2318 my_socketpair||5.007003|n
2319 my_stat|||
2320 my_strftime||5.007002|
2321 my_swabn|||n
2322 my_swap|||
2323 my_unexec|||
2324 my|||
2325 newANONATTRSUB||5.006000|
2326 newANONHASH|||
2327 newANONLIST|||
2328 newANONSUB|||
2329 newASSIGNOP|||
2330 newATTRSUB||5.006000|
2331 newAVREF|||
2332 newAV|||
2333 newBINOP|||
2334 newCONDOP|||
2335 newCONSTSUB|5.006000||p
2336 newCVREF|||
2337 newDEFSVOP|||
2338 newFORM|||
2339 newFOROP|||
2340 newGVOP|||
2341 newGVREF|||
2342 newGVgen|||
2343 newHVREF|||
2344 newHVhv||5.005000|
2345 newHV|||
2346 newIO|||
2347 newLISTOP|||
2348 newLOGOP|||
2349 newLOOPEX|||
2350 newLOOPOP|||
2351 newMYSUB||5.006000|
2352 newNULLLIST|||
2353 newOP|||
2354 newPADOP||5.006000|
2355 newPMOP|||
2356 newPROG|||
2357 newPVOP|||
2358 newRANGE|||
2359 newRV_inc|5.004000||p
2360 newRV_noinc|5.006000||p
2361 newRV|||
2362 newSLICEOP|||
2363 newSTATEOP|||
2364 newSUB|||
2365 newSVOP|||
2366 newSVREF|||
2367 newSViv|||
2368 newSVnv|||
2369 newSVpvf_nocontext|||vn
2370 newSVpvf||5.004000|v
2371 newSVpvn_share||5.007001|
2372 newSVpvn|5.006000||p
2373 newSVpv|||
2374 newSVrv|||
2375 newSVsv|||
2376 newSVuv|5.006000||p
2377 newSV|||
2378 newUNOP|||
2379 newWHILEOP||5.004040|
2380 newXSproto||5.006000|
2381 newXS||5.006000|
2382 new_collate||5.006000|
2383 new_constant|||
2384 new_ctype||5.006000|
2385 new_he|||
2386 new_logop|||
2387 new_numeric||5.006000|
2388 new_stackinfo||5.005000|
2389 new_version||5.009000|
2390 new_xiv|||
2391 new_xnv|||
2392 new_xpvav|||
2393 new_xpvbm|||
2394 new_xpvcv|||
2395 new_xpvhv|||
2396 new_xpviv|||
2397 new_xpvlv|||
2398 new_xpvmg|||
2399 new_xpvnv|||
2400 new_xpv|||
2401 new_xrv|||
2402 next_symbol|||
2403 nextargv|||
2404 nextchar|||
2405 ninstr|||
2406 no_bareword_allowed|||
2407 no_fh_allowed|||
2408 no_op|||
2409 not_a_number|||
2410 nothreadhook||5.008000|
2411 nuke_stacks|||
2412 num_overflow|||n
2413 oopsAV|||
2414 oopsCV|||
2415 oopsHV|||
2416 op_clear|||
2417 op_const_sv|||
2418 op_dump||5.006000|
2419 op_free|||
2420 op_null||5.007002|
2421 op_refcnt_lock||5.009002|
2422 op_refcnt_unlock||5.009002|
2423 open_script|||
2424 pMY_CXT_|5.007003||p
2425 pMY_CXT|5.007003||p
2426 pTHX_|5.006000||p
2427 pTHX|5.006000||p
2428 pack_cat||5.007003|
2429 pack_rec|||
2430 package|||
2431 packlist||5.008001|
2432 pad_add_anon|||
2433 pad_add_name|||
2434 pad_alloc|||
2435 pad_block_start|||
2436 pad_check_dup|||
2437 pad_findlex|||
2438 pad_findmy|||
2439 pad_fixup_inner_anons|||
2440 pad_free|||
2441 pad_leavemy|||
2442 pad_new|||
2443 pad_push|||
2444 pad_reset|||
2445 pad_setsv|||
2446 pad_sv|||
2447 pad_swipe|||
2448 pad_tidy|||
2449 pad_undef|||
2450 parse_body|||
2451 parse_unicode_opts|||
2452 path_is_absolute|||
2453 peep|||
2454 pending_ident|||
2455 perl_alloc_using|||n
2456 perl_alloc|||n
2457 perl_clone_using|||n
2458 perl_clone|||n
2459 perl_construct|||n
2460 perl_destruct||5.007003|n
2461 perl_free|||n
2462 perl_parse||5.006000|n
2463 perl_run|||n
2464 pidgone|||
2465 pmflag|||
2466 pmop_dump||5.006000|
2467 pmruntime|||
2468 pmtrans|||
2469 pop_scope|||
2470 pregcomp|||
2471 pregexec|||
2472 pregfree|||
2473 prepend_elem|||
2474 printf_nocontext|||vn
2475 ptr_table_clear|||
2476 ptr_table_fetch|||
2477 ptr_table_free|||
2478 ptr_table_new|||
2479 ptr_table_split|||
2480 ptr_table_store|||
2481 push_scope|||
2482 put_byte|||
2483 pv_display||5.006000|
2484 pv_uni_display||5.007003|
2485 qerror|||
2486 re_croak2|||
2487 re_dup|||
2488 re_intuit_start||5.006000|
2489 re_intuit_string||5.006000|
2490 realloc||5.007002|n
2491 reentrant_free|||
2492 reentrant_init|||
2493 reentrant_retry|||vn
2494 reentrant_size|||
2495 refkids|||
2496 refto|||
2497 ref|||
2498 reg_node|||
2499 reganode|||
2500 regatom|||
2501 regbranch|||
2502 regclass_swash||5.007003|
2503 regclass|||
2504 regcp_set_to|||
2505 regcppop|||
2506 regcppush|||
2507 regcurly|||
2508 regdump||5.005000|
2509 regexec_flags||5.005000|
2510 reghop3|||
2511 reghopmaybe3|||
2512 reghopmaybe|||
2513 reghop|||
2514 reginclass|||
2515 reginitcolors||5.006000|
2516 reginsert|||
2517 regmatch|||
2518 regnext||5.005000|
2519 regoptail|||
2520 regpiece|||
2521 regpposixcc|||
2522 regprop|||
2523 regrepeat_hard|||
2524 regrepeat|||
2525 regtail|||
2526 regtry|||
2527 reguni|||
2528 regwhite|||
2529 reg|||
2530 repeatcpy|||
2531 report_evil_fh|||
2532 report_uninit|||
2533 require_errno|||
2534 require_pv||5.006000|
2535 rninstr|||
2536 rsignal_restore|||
2537 rsignal_save|||
2538 rsignal_state||5.004000|
2539 rsignal||5.004000|
2540 run_body|||
2541 runops_debug||5.005000|
2542 runops_standard||5.005000|
2543 rxres_free|||
2544 rxres_restore|||
2545 rxres_save|||
2546 safesyscalloc||5.006000|n
2547 safesysfree||5.006000|n
2548 safesysmalloc||5.006000|n
2549 safesysrealloc||5.006000|n
2550 same_dirent|||
2551 save_I16||5.004000|
2552 save_I32|||
2553 save_I8||5.006000|
2554 save_aelem||5.004050|
2555 save_alloc||5.006000|
2556 save_aptr|||
2557 save_ary|||
2558 save_bool||5.008001|
2559 save_clearsv|||
2560 save_delete|||
2561 save_destructor_x||5.006000|
2562 save_destructor||5.006000|
2563 save_freeop|||
2564 save_freepv|||
2565 save_freesv|||
2566 save_generic_pvref||5.006001|
2567 save_generic_svref||5.005030|
2568 save_gp||5.004000|
2569 save_hash|||
2570 save_hek_flags|||
2571 save_helem||5.004050|
2572 save_hints||5.005000|
2573 save_hptr|||
2574 save_int|||
2575 save_item|||
2576 save_iv||5.005000|
2577 save_lines|||
2578 save_list|||
2579 save_long|||
2580 save_magic|||
2581 save_mortalizesv||5.007001|
2582 save_nogv|||
2583 save_op|||
2584 save_padsv||5.007001|
2585 save_pptr|||
2586 save_re_context||5.006000|
2587 save_scalar_at|||
2588 save_scalar|||
2589 save_set_svflags||5.009000|
2590 save_shared_pvref||5.007003|
2591 save_sptr|||
2592 save_svref|||
2593 save_threadsv||5.005000|
2594 save_vptr||5.006000|
2595 savepvn|||
2596 savepv|||
2597 savesharedpv||5.007003|
2598 savestack_grow_cnt||5.008001|
2599 savestack_grow|||
2600 savesvpv||5.009002|
2601 sawparens|||
2602 scalar_mod_type|||
2603 scalarboolean|||
2604 scalarkids|||
2605 scalarseq|||
2606 scalarvoid|||
2607 scalar|||
2608 scan_bin||5.006000|
2609 scan_commit|||
2610 scan_const|||
2611 scan_formline|||
2612 scan_heredoc|||
2613 scan_hex|||
2614 scan_ident|||
2615 scan_inputsymbol|||
2616 scan_num||5.007001|
2617 scan_oct|||
2618 scan_pat|||
2619 scan_str|||
2620 scan_subst|||
2621 scan_trans|||
2622 scan_version||5.009001|
2623 scan_vstring||5.008001|
2624 scan_word|||
2625 scope|||
2626 screaminstr||5.005000|
2627 seed|||
2628 set_context||5.006000|n
2629 set_csh|||
2630 set_numeric_local||5.006000|
2631 set_numeric_radix||5.006000|
2632 set_numeric_standard||5.006000|
2633 setdefout|||
2634 setenv_getix|||
2635 share_hek_flags|||
2636 share_hek|||
2637 si_dup|||
2638 sighandler|||n
2639 simplify_sort|||
2640 skipspace|||
2641 sortsv||5.007003|
2642 ss_dup|||
2643 stack_grow|||
2644 start_glob|||
2645 start_subparse||5.004000|
2646 stdize_locale|||
2647 strEQ|||
2648 strGE|||
2649 strGT|||
2650 strLE|||
2651 strLT|||
2652 strNE|||
2653 str_to_version||5.006000|
2654 strnEQ|||
2655 strnNE|||
2656 study_chunk|||
2657 sub_crush_depth|||
2658 sublex_done|||
2659 sublex_push|||
2660 sublex_start|||
2661 sv_2bool|||
2662 sv_2cv|||
2663 sv_2io|||
2664 sv_2iuv_non_preserve|||
2665 sv_2iv_flags||5.009001|
2666 sv_2iv|||
2667 sv_2mortal|||
2668 sv_2nv|||
2669 sv_2pv_flags||5.007002|
2670 sv_2pv_nolen|5.006000||p
2671 sv_2pvbyte_nolen|||
2672 sv_2pvbyte|5.006000||p
2673 sv_2pvutf8_nolen||5.006000|
2674 sv_2pvutf8||5.006000|
2675 sv_2pv|||
2676 sv_2uv_flags||5.009001|
2677 sv_2uv|5.004000||p
2678 sv_add_arena|||
2679 sv_add_backref|||
2680 sv_backoff|||
2681 sv_bless|||
2682 sv_cat_decode||5.008001|
2683 sv_catpv_mg|5.006000||p
2684 sv_catpvf_mg_nocontext|||pvn
2685 sv_catpvf_mg|5.006000|5.004000|pv
2686 sv_catpvf_nocontext|||vn
2687 sv_catpvf||5.004000|v
2688 sv_catpvn_flags||5.007002|
2689 sv_catpvn_mg|5.006000||p
2690 sv_catpvn_nomg|5.007002||p
2691 sv_catpvn|||
2692 sv_catpv|||
2693 sv_catsv_flags||5.007002|
2694 sv_catsv_mg|5.006000||p
2695 sv_catsv_nomg|5.007002||p
2696 sv_catsv|||
2697 sv_chop|||
2698 sv_clean_all|||
2699 sv_clean_objs|||
2700 sv_clear|||
2701 sv_cmp_locale||5.004000|
2702 sv_cmp|||
2703 sv_collxfrm|||
2704 sv_compile_2op||5.008001|
2705 sv_copypv||5.007003|
2706 sv_dec|||
2707 sv_del_backref|||
2708 sv_derived_from||5.004000|
2709 sv_dump|||
2710 sv_dup|||
2711 sv_eq|||
2712 sv_force_normal_flags||5.007001|
2713 sv_force_normal||5.006000|
2714 sv_free2|||
2715 sv_free_arenas|||
2716 sv_free|||
2717 sv_gets||5.004000|
2718 sv_grow|||
2719 sv_inc|||
2720 sv_insert|||
2721 sv_isa|||
2722 sv_isobject|||
2723 sv_iv||5.005000|
2724 sv_len_utf8||5.006000|
2725 sv_len|||
2726 sv_magicext||5.007003|
2727 sv_magic|||
2728 sv_mortalcopy|||
2729 sv_newmortal|||
2730 sv_newref|||
2731 sv_nolocking||5.007003|
2732 sv_nosharing||5.007003|
2733 sv_nounlocking||5.007003|
2734 sv_nv||5.005000|
2735 sv_peek||5.005000|
2736 sv_pos_b2u||5.006000|
2737 sv_pos_u2b||5.006000|
2738 sv_pvbyten_force||5.006000|
2739 sv_pvbyten||5.006000|
2740 sv_pvbyte||5.006000|
2741 sv_pvn_force_flags||5.007002|
2742 sv_pvn_force|||p
2743 sv_pvn_nomg|5.007003||p
2744 sv_pvn|5.006000||p
2745 sv_pvutf8n_force||5.006000|
2746 sv_pvutf8n||5.006000|
2747 sv_pvutf8||5.006000|
2748 sv_pv||5.006000|
2749 sv_recode_to_utf8||5.007003|
2750 sv_reftype|||
2751 sv_release_COW|||
2752 sv_release_IVX|||
2753 sv_replace|||
2754 sv_report_used|||
2755 sv_reset|||
2756 sv_rvweaken||5.006000|
2757 sv_setiv_mg|5.006000||p
2758 sv_setiv|||
2759 sv_setnv_mg|5.006000||p
2760 sv_setnv|||
2761 sv_setpv_mg|5.006000||p
2762 sv_setpvf_mg_nocontext|||pvn
2763 sv_setpvf_mg|5.006000|5.004000|pv
2764 sv_setpvf_nocontext|||vn
2765 sv_setpvf||5.004000|v
2766 sv_setpviv_mg||5.008001|
2767 sv_setpviv||5.008001|
2768 sv_setpvn_mg|5.006000||p
2769 sv_setpvn|||
2770 sv_setpv|||
2771 sv_setref_iv|||
2772 sv_setref_nv|||
2773 sv_setref_pvn|||
2774 sv_setref_pv|||
2775 sv_setref_uv||5.007001|
2776 sv_setsv_cow|||
2777 sv_setsv_flags||5.007002|
2778 sv_setsv_mg|5.006000||p
2779 sv_setsv_nomg|5.007002||p
2780 sv_setsv|||
2781 sv_setuv_mg|5.006000||p
2782 sv_setuv|5.006000||p
2783 sv_tainted||5.004000|
2784 sv_taint||5.004000|
2785 sv_true||5.005000|
2786 sv_unglob|||
2787 sv_uni_display||5.007003|
2788 sv_unmagic|||
2789 sv_unref_flags||5.007001|
2790 sv_unref|||
2791 sv_untaint||5.004000|
2792 sv_upgrade|||
2793 sv_usepvn_mg|5.006000||p
2794 sv_usepvn|||
2795 sv_utf8_decode||5.006000|
2796 sv_utf8_downgrade||5.006000|
2797 sv_utf8_encode||5.006000|
2798 sv_utf8_upgrade_flags||5.007002|
2799 sv_utf8_upgrade||5.007001|
2800 sv_uv|5.006000||p
2801 sv_vcatpvf_mg|5.006000|5.004000|p
2802 sv_vcatpvfn||5.004000|
2803 sv_vcatpvf|5.006000|5.004000|p
2804 sv_vsetpvf_mg|5.006000|5.004000|p
2805 sv_vsetpvfn||5.004000|
2806 sv_vsetpvf|5.006000|5.004000|p
2807 svtype|||
2808 swallow_bom|||
2809 swash_fetch||5.007002|
2810 swash_init||5.006000|
2811 sys_intern_clear|||
2812 sys_intern_dup|||
2813 sys_intern_init|||
2814 taint_env|||
2815 taint_proper|||
2816 tmps_grow||5.006000|
2817 toLOWER|||
2818 toUPPER|||
2819 to_byte_substr|||
2820 to_uni_fold||5.007003|
2821 to_uni_lower_lc||5.006000|
2822 to_uni_lower||5.007003|
2823 to_uni_title_lc||5.006000|
2824 to_uni_title||5.007003|
2825 to_uni_upper_lc||5.006000|
2826 to_uni_upper||5.007003|
2827 to_utf8_case||5.007003|
2828 to_utf8_fold||5.007003|
2829 to_utf8_lower||5.007003|
2830 to_utf8_substr|||
2831 to_utf8_title||5.007003|
2832 to_utf8_upper||5.007003|
2833 tokeq|||
2834 tokereport|||
2835 too_few_arguments|||
2836 too_many_arguments|||
2837 unlnk|||
2838 unpack_rec|||
2839 unpack_str||5.007003|
2840 unpackstring||5.008001|
2841 unshare_hek_or_pvn|||
2842 unshare_hek|||
2843 unsharepvn||5.004000|
2844 upg_version||5.009000|
2845 usage|||
2846 utf16_textfilter|||
2847 utf16_to_utf8_reversed||5.006001|
2848 utf16_to_utf8||5.006001|
2849 utf16rev_textfilter|||
2850 utf8_distance||5.006000|
2851 utf8_hop||5.006000|
2852 utf8_length||5.007001|
2853 utf8_mg_pos_init|||
2854 utf8_mg_pos|||
2855 utf8_to_bytes||5.006001|
2856 utf8_to_uvchr||5.007001|
2857 utf8_to_uvuni||5.007001|
2858 utf8n_to_uvchr||5.007001|
2859 utf8n_to_uvuni||5.007001|
2860 utilize|||
2861 uvchr_to_utf8_flags||5.007003|
2862 uvchr_to_utf8||5.007001|
2863 uvuni_to_utf8_flags||5.007003|
2864 uvuni_to_utf8||5.007001|
2865 validate_suid|||
2866 vcmp||5.009000|
2867 vcroak||5.006000|
2868 vdeb||5.007003|
2869 vdie|||
2870 vform||5.006000|
2871 visit|||
2872 vivify_defelem|||
2873 vivify_ref|||
2874 vload_module||5.006000|
2875 vmess||5.006000|
2876 vnewSVpvf|5.006000|5.004000|p
2877 vnormal||5.009002|
2878 vnumify||5.009000|
2879 vstringify||5.009000|
2880 vwarner||5.006000|
2881 vwarn||5.006000|
2882 wait4pid|||
2883 warn_nocontext|||vn
2884 warner_nocontext|||vn
2885 warner||5.006000|v
2886 warn|||v
2887 watch|||
2888 whichsig|||
2889 write_to_stderr|||
2890 yyerror|||
2891 yylex|||
2892 yyparse|||
2893 yywarn|||
2894 );
2895
2896 if (exists $opt{'list-unsupported'}) {
2897   my $f;
2898   for $f (sort { lc $a cmp lc $b } keys %API) {
2899     next unless $API{$f}{todo};
2900     print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
2901   }
2902   exit 0;
2903 }
2904
2905 # Scan for possible replacement candidates
2906
2907 my(%replace, %need, %hints, %depends);
2908 my $replace = 0;
2909 my $hint = '';
2910
2911 while (<DATA>) {
2912   if ($hint) {
2913     if (m{^\s*\*\s(.*?)\s*$}) {
2914       $hints{$hint} ||= '';  # suppress warning with older perls
2915       $hints{$hint} .= "$1\n";
2916     }
2917     else {
2918       $hint = '';
2919     }
2920   }
2921   $hint = $1 if m{^\s*$rccs\sHint:\s+(\w+)\s*$};
2922
2923   $replace     = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
2924   $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
2925   $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
2926   $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
2927
2928   if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
2929     push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
2930   }
2931
2932   $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
2933 }
2934
2935 if (exists $opt{'api-info'}) {
2936   my $f;
2937   my $count = 0;
2938   my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
2939   for $f (sort { lc $a cmp lc $b } keys %API) {
2940     next unless $f =~ /$match/;
2941     print "\n=== $f ===\n\n";
2942     my $info = 0;
2943     if ($API{$f}{base} || $API{$f}{todo}) {
2944       my $base = format_version($API{$f}{base} || $API{$f}{todo});
2945       print "Supported at least starting from perl-$base.\n";
2946       $info++;
2947     }
2948     if ($API{$f}{provided}) {
2949       my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003";
2950       print "Support by $ppport provided back to perl-$todo.\n";
2951       print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f};
2952       print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f};
2953       print "$hints{$f}" if exists $hints{$f};
2954       $info++;
2955     }
2956     unless ($info) {
2957       print "No portability information available.\n";
2958     }
2959     $count++;
2960   }
2961   if ($count > 0) {
2962     print "\n";
2963   }
2964   else {
2965     print "Found no API matching '$opt{'api-info'}'.\n";
2966   }
2967   exit 0;
2968 }
2969
2970 if (exists $opt{'list-provided'}) {
2971   my $f;
2972   for $f (sort { lc $a cmp lc $b } keys %API) {
2973     next unless $API{$f}{provided};
2974     my @flags;
2975     push @flags, 'explicit' if exists $need{$f};
2976     push @flags, 'depend'   if exists $depends{$f};
2977     push @flags, 'hint'     if exists $hints{$f};
2978     my $flags = @flags ? '  ['.join(', ', @flags).']' : '';
2979     print "$f$flags\n";
2980   }
2981   exit 0;
2982 }
2983
2984 my(%files, %global, %revreplace);
2985 %revreplace = reverse %replace;
2986 my $filename;
2987 my $patch_opened = 0;
2988
2989 for $filename (@files) {
2990   unless (open IN, "<$filename") {
2991     warn "Unable to read from $filename: $!\n";
2992     next;
2993   }
2994
2995   info("Scanning $filename ...");
2996
2997   my $c = do { local $/; <IN> };
2998   close IN;
2999
3000   my %file = (orig => $c, changes => 0);
3001
3002   # temporarily remove C comments from the code
3003   my @ccom;
3004   $c =~ s{
3005     (
3006         [^"'/]+
3007       |
3008         (?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+
3009       |
3010         (?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+
3011     )
3012   |
3013     (/ (?:
3014         \*[^*]*\*+(?:[^$ccs][^*]*\*+)* /
3015         |
3016         /[^\r\n]*
3017       ))
3018   }{
3019     defined $2 and push @ccom, $2;
3020     defined $1 ? $1 : "$ccs$#ccom$cce";
3021   }egsx;
3022
3023   $file{ccom} = \@ccom;
3024   $file{code} = $c;
3025   $file{has_inc_ppport} = ($c =~ /#.*include.*\Q$ppport\E/);
3026
3027   my $func;
3028
3029   for $func (keys %API) {
3030     my $match = $func;
3031     $match .= "|$revreplace{$func}" if exists $revreplace{$func};
3032     if ($c =~ /\b(?:Perl_)?($match)\b/) {
3033       $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
3034       $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
3035       if (exists $API{$func}{provided}) {
3036         if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
3037           $file{uses}{$func}++;
3038           my @deps = rec_depend($func);
3039           if (@deps) {
3040             $file{uses_deps}{$func} = \@deps;
3041             for (@deps) {
3042               $file{uses}{$_} = 0 unless exists $file{uses}{$_};
3043             }
3044           }
3045           for ($func, @deps) {
3046             if (exists $need{$_}) {
3047               $file{needs}{$_} = 'static';
3048             }
3049           }
3050         }
3051       }
3052       if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
3053         if ($c =~ /\b$func\b/) {
3054           $file{uses_todo}{$func}++;
3055         }
3056       }
3057     }
3058   }
3059
3060   while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
3061     if (exists $need{$2}) {
3062       $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
3063     }
3064     else {
3065       warning("Possibly wrong #define $1 in $filename");
3066     }
3067   }
3068
3069   for (qw(uses needs uses_todo needed_global needed_static)) {
3070     for $func (keys %{$file{$_}}) {
3071       push @{$global{$_}{$func}}, $filename;
3072     }
3073   }
3074
3075   $files{$filename} = \%file;
3076 }
3077
3078 # Globally resolve NEED_'s
3079 my $need;
3080 for $need (keys %{$global{needs}}) {
3081   if (@{$global{needs}{$need}} > 1) {
3082     my @targets = @{$global{needs}{$need}};
3083     my @t = grep $files{$_}{needed_global}{$need}, @targets;
3084     @targets = @t if @t;
3085     @t = grep /\.xs$/i, @targets;
3086     @targets = @t if @t;
3087     my $target = shift @targets;
3088     $files{$target}{needs}{$need} = 'global';
3089     for (@{$global{needs}{$need}}) {
3090       $files{$_}{needs}{$need} = 'extern' if $_ ne $target;
3091     }
3092   }
3093 }
3094
3095 for $filename (@files) {
3096   exists $files{$filename} or next;
3097
3098   info("=== Analyzing $filename ===");
3099
3100   my %file = %{$files{$filename}};
3101   my $func;
3102   my $c = $file{code};
3103
3104   for $func (sort keys %{$file{uses_Perl}}) {
3105     if ($API{$func}{varargs}) {
3106       my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
3107                             { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
3108       if ($changes) {
3109         warning("Doesn't pass interpreter argument aTHX to Perl_$func");
3110         $file{changes} += $changes;
3111       }
3112     }
3113     else {
3114       warning("Uses Perl_$func instead of $func");
3115       $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
3116                                 {$func$1(}g);
3117     }
3118   }
3119
3120   for $func (sort keys %{$file{uses_replace}}) {
3121     warning("Uses $func instead of $replace{$func}");
3122     $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
3123   }
3124
3125   for $func (sort keys %{$file{uses}}) {
3126     next unless $file{uses}{$func};   # if it's only a dependency
3127     if (exists $file{uses_deps}{$func}) {
3128       diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
3129     }
3130     elsif (exists $replace{$func}) {
3131       warning("Uses $func instead of $replace{$func}");
3132       $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
3133     }
3134     else {
3135       diag("Uses $func");
3136     }
3137     hint($func);
3138   }
3139
3140   for $func (sort keys %{$file{uses_todo}}) {
3141     warning("Uses $func, which may not be portable below perl ",
3142             format_version($API{$func}{todo}));
3143   }
3144
3145   for $func (sort keys %{$file{needed_static}}) {
3146     my $message = '';
3147     if (not exists $file{uses}{$func}) {
3148       $message = "No need to define NEED_$func if $func is never used";
3149     }
3150     elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
3151       $message = "No need to define NEED_$func when already needed globally";
3152     }
3153     if ($message) {
3154       diag($message);
3155       $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
3156     }
3157   }
3158
3159   for $func (sort keys %{$file{needed_global}}) {
3160     my $message = '';
3161     if (not exists $global{uses}{$func}) {
3162       $message = "No need to define NEED_${func}_GLOBAL if $func is never used";
3163     }
3164     elsif (exists $file{needs}{$func}) {
3165       if ($file{needs}{$func} eq 'extern') {
3166         $message = "No need to define NEED_${func}_GLOBAL when already needed globally";
3167       }
3168       elsif ($file{needs}{$func} eq 'static') {
3169         $message = "No need to define NEED_${func}_GLOBAL when only used in this file";
3170       }
3171     }
3172     if ($message) {
3173       diag($message);
3174       $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
3175     }
3176   }
3177
3178   $file{needs_inc_ppport} = keys %{$file{uses}};
3179
3180   if ($file{needs_inc_ppport}) {
3181     my $pp = '';
3182
3183     for $func (sort keys %{$file{needs}}) {
3184       my $type = $file{needs}{$func};
3185       next if $type eq 'extern';
3186       my $suffix = $type eq 'global' ? '_GLOBAL' : '';
3187       unless (exists $file{"needed_$type"}{$func}) {
3188         if ($type eq 'global') {
3189           diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
3190         }
3191         else {
3192           diag("File needs $func, adding static request");
3193         }
3194         $pp .= "#define NEED_$func$suffix\n";
3195       }
3196     }
3197
3198     if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
3199       $pp = '';
3200       $file{changes}++;
3201     }
3202
3203     unless ($file{has_inc_ppport}) {
3204       diag("Needs to include '$ppport'");
3205       $pp .= qq(#include "$ppport"\n)
3206     }
3207
3208     if ($pp) {
3209       $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
3210                      || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
3211                      || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
3212                      || ($c =~ s/^/$pp/);
3213     }
3214   }
3215   else {
3216     if ($file{has_inc_ppport}) {
3217       diag("No need to include '$ppport'");
3218       $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
3219     }
3220   }
3221
3222   # put back in our C comments
3223   my $ix;
3224   my $cppc = 0;
3225   my @ccom = @{$file{ccom}};
3226   for $ix (0 .. $#ccom) {
3227     if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
3228       $cppc++;
3229       $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
3230     }
3231     else {
3232       $c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
3233     }
3234   }
3235
3236   if ($cppc) {
3237     my $s = $cppc != 1 ? 's' : '';
3238     warning("Uses $cppc C++ style comment$s, which is not portable");
3239   }
3240
3241   if ($file{changes}) {
3242     if (exists $opt{copy}) {
3243       my $newfile = "$filename$opt{copy}";
3244       if (-e $newfile) {
3245         error("'$newfile' already exists, refusing to write copy of '$filename'");
3246       }
3247       else {
3248         local *F;
3249         if (open F, ">$newfile") {
3250           info("Writing copy of '$filename' with changes to '$newfile'");
3251           print F $c;
3252           close F;
3253         }
3254         else {
3255           error("Cannot open '$newfile' for writing: $!");
3256         }
3257       }
3258     }
3259     elsif (exists $opt{patch} || $opt{changes}) {
3260       if (exists $opt{patch}) {
3261         unless ($patch_opened) {
3262           if (open PATCH, ">$opt{patch}") {
3263             $patch_opened = 1;
3264           }
3265           else {
3266             error("Cannot open '$opt{patch}' for writing: $!");
3267             delete $opt{patch};
3268             $opt{changes} = 1;
3269             goto fallback;
3270           }
3271         }
3272         mydiff(\*PATCH, $filename, $c);
3273       }
3274       else {
3275 fallback:
3276         info("Suggested changes:");
3277         mydiff(\*STDOUT, $filename, $c);
3278       }
3279     }
3280     else {
3281       my $s = $file{changes} == 1 ? '' : 's';
3282       info("$file{changes} potentially required change$s detected");
3283     }
3284   }
3285   else {
3286     info("Looks good");
3287   }
3288 }
3289
3290 close PATCH if $patch_opened;
3291
3292 exit 0;
3293
3294
3295 sub mydiff
3296 {
3297   local *F = shift;
3298   my($file, $str) = @_;
3299   my $diff;
3300
3301   if (exists $opt{diff}) {
3302     $diff = run_diff($opt{diff}, $file, $str);
3303   }
3304
3305   if (!defined $diff and can_use('Text::Diff')) {
3306     $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
3307     $diff = <<HEADER . $diff;
3308 --- $file
3309 +++ $file.patched
3310 HEADER
3311   }
3312
3313   if (!defined $diff) {
3314     $diff = run_diff('diff -u', $file, $str);
3315   }
3316
3317   if (!defined $diff) {
3318     $diff = run_diff('diff', $file, $str);
3319   }
3320
3321   if (!defined $diff) {
3322     error("Cannot generate a diff. Please install Text::Diff or use --copy.");
3323     return;
3324   }
3325
3326   print F $diff;
3327
3328 }
3329
3330 sub run_diff
3331 {
3332   my($prog, $file, $str) = @_;
3333   my $tmp = 'dppptemp';
3334   my $suf = 'aaa';
3335   my $diff = '';
3336   local *F;
3337
3338   while (-e "$tmp.$suf") { $suf++ }
3339   $tmp = "$tmp.$suf";
3340
3341   if (open F, ">$tmp") {
3342     print F $str;
3343     close F;
3344
3345     if (open F, "$prog $file $tmp |") {
3346       while (<F>) {
3347         s/\Q$tmp\E/$file.patched/;
3348         $diff .= $_;
3349       }
3350       close F;
3351       unlink $tmp;
3352       return $diff;
3353     }
3354
3355     unlink $tmp;
3356   }
3357   else {
3358     error("Cannot open '$tmp' for writing: $!");
3359   }
3360
3361   return undef;
3362 }
3363
3364 sub can_use
3365 {
3366   eval "use @_;";
3367   return $@ eq '';
3368 }
3369
3370 sub rec_depend
3371 {
3372   my $func = shift;
3373   my %seen;
3374   return () unless exists $depends{$func};
3375   grep !$seen{$_}++, map { ($_, rec_depend($_)) } @{$depends{$func}};
3376 }
3377
3378 sub parse_version
3379 {
3380   my $ver = shift;
3381
3382   if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
3383     return ($1, $2, $3);
3384   }
3385   elsif ($ver !~ /^\d+\.[\d_]+$/) {
3386     die "cannot parse version '$ver'\n";
3387   }
3388
3389   $ver =~ s/_//g;
3390   $ver =~ s/$/000000/;
3391
3392   my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
3393
3394   $v = int $v;
3395   $s = int $s;
3396
3397   if ($r < 5 || ($r == 5 && $v < 6)) {
3398     if ($s % 10) {
3399       die "cannot parse version '$ver'\n";
3400     }
3401   }
3402
3403   return ($r, $v, $s);
3404 }
3405
3406 sub format_version
3407 {
3408   my $ver = shift;
3409
3410   $ver =~ s/$/000000/;
3411   my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
3412
3413   $v = int $v;
3414   $s = int $s;
3415
3416   if ($r < 5 || ($r == 5 && $v < 6)) {
3417     if ($s % 10) {
3418       die "invalid version '$ver'\n";
3419     }
3420     $s /= 10;
3421
3422     $ver = sprintf "%d.%03d", $r, $v;
3423     $s > 0 and $ver .= sprintf "_%02d", $s;
3424
3425     return $ver;
3426   }
3427
3428   return sprintf "%d.%d.%d", $r, $v, $s;
3429 }
3430
3431 sub info
3432 {
3433   $opt{quiet} and return;
3434   print @_, "\n";
3435 }
3436
3437 sub diag
3438 {
3439   $opt{quiet} and return;
3440   $opt{diag} and print @_, "\n";
3441 }
3442
3443 sub warning
3444 {
3445   $opt{quiet} and return;
3446   print "*** ", @_, "\n";
3447 }
3448
3449 sub error
3450 {
3451   print "*** ERROR: ", @_, "\n";
3452 }
3453
3454 my %given_hints;
3455 sub hint
3456 {
3457   $opt{quiet} and return;
3458   $opt{hints} or return;
3459   my $func = shift;
3460   exists $hints{$func} or return;
3461   $given_hints{$func}++ and return;
3462   my $hint = $hints{$func};
3463   $hint =~ s/^/   /mg;
3464   print "   --- hint for $func ---\n", $hint;
3465 }
3466
3467 sub usage
3468 {
3469   my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
3470   my %M = ( 'I' => '*' );
3471   $usage =~ s/^\s*perl\s+\S+/$^X $0/;
3472   $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
3473
3474   print <<ENDUSAGE;
3475
3476 Usage: $usage
3477
3478 See perldoc $0 for details.
3479
3480 ENDUSAGE
3481
3482   exit 2;
3483 }
3484
3485 __DATA__
3486 */
3487
3488 #ifndef _P_P_PORTABILITY_H_
3489 #define _P_P_PORTABILITY_H_
3490
3491 #ifndef DPPP_NAMESPACE
3492 #  define DPPP_NAMESPACE DPPP_
3493 #endif
3494
3495 #define DPPP_CAT2(x,y) CAT2(x,y)
3496 #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
3497
3498 #ifndef PERL_REVISION
3499 #  if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
3500 #    define PERL_PATCHLEVEL_H_IMPLICIT
3501 #    include <patchlevel.h>
3502 #  endif
3503 #  if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
3504 #    include <could_not_find_Perl_patchlevel.h>
3505 #  endif
3506 #  ifndef PERL_REVISION
3507 #    define PERL_REVISION       (5)
3508      /* Replace: 1 */
3509 #    define PERL_VERSION        PATCHLEVEL
3510 #    define PERL_SUBVERSION     SUBVERSION
3511      /* Replace PERL_PATCHLEVEL with PERL_VERSION */
3512      /* Replace: 0 */
3513 #  endif
3514 #endif
3515
3516 #define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
3517
3518 /* It is very unlikely that anyone will try to use this with Perl 6 
3519    (or greater), but who knows.
3520  */
3521 #if PERL_REVISION != 5
3522 #  error ppport.h only works with Perl version 5
3523 #endif /* PERL_REVISION != 5 */
3524
3525 #ifdef I_LIMITS
3526 #  include <limits.h>
3527 #endif
3528
3529 #ifndef PERL_UCHAR_MIN
3530 #  define PERL_UCHAR_MIN ((unsigned char)0)
3531 #endif
3532
3533 #ifndef PERL_UCHAR_MAX
3534 #  ifdef UCHAR_MAX
3535 #    define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
3536 #  else
3537 #    ifdef MAXUCHAR
3538 #      define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
3539 #    else
3540 #      define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
3541 #    endif
3542 #  endif
3543 #endif
3544
3545 #ifndef PERL_USHORT_MIN
3546 #  define PERL_USHORT_MIN ((unsigned short)0)
3547 #endif
3548
3549 #ifndef PERL_USHORT_MAX
3550 #  ifdef USHORT_MAX
3551 #    define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
3552 #  else
3553 #    ifdef MAXUSHORT
3554 #      define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
3555 #    else
3556 #      ifdef USHRT_MAX
3557 #        define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
3558 #      else
3559 #        define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
3560 #      endif
3561 #    endif
3562 #  endif
3563 #endif
3564
3565 #ifndef PERL_SHORT_MAX
3566 #  ifdef SHORT_MAX
3567 #    define PERL_SHORT_MAX ((short)SHORT_MAX)
3568 #  else
3569 #    ifdef MAXSHORT    /* Often used in <values.h> */
3570 #      define PERL_SHORT_MAX ((short)MAXSHORT)
3571 #    else
3572 #      ifdef SHRT_MAX
3573 #        define PERL_SHORT_MAX ((short)SHRT_MAX)
3574 #      else
3575 #        define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
3576 #      endif
3577 #    endif
3578 #  endif
3579 #endif
3580
3581 #ifndef PERL_SHORT_MIN
3582 #  ifdef SHORT_MIN
3583 #    define PERL_SHORT_MIN ((short)SHORT_MIN)
3584 #  else
3585 #    ifdef MINSHORT
3586 #      define PERL_SHORT_MIN ((short)MINSHORT)
3587 #    else
3588 #      ifdef SHRT_MIN
3589 #        define PERL_SHORT_MIN ((short)SHRT_MIN)
3590 #      else
3591 #        define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
3592 #      endif
3593 #    endif
3594 #  endif
3595 #endif
3596
3597 #ifndef PERL_UINT_MAX
3598 #  ifdef UINT_MAX
3599 #    define PERL_UINT_MAX ((unsigned int)UINT_MAX)
3600 #  else
3601 #    ifdef MAXUINT
3602 #      define PERL_UINT_MAX ((unsigned int)MAXUINT)
3603 #    else
3604 #      define PERL_UINT_MAX (~(unsigned int)0)
3605 #    endif
3606 #  endif
3607 #endif
3608
3609 #ifndef PERL_UINT_MIN
3610 #  define PERL_UINT_MIN ((unsigned int)0)
3611 #endif
3612
3613 #ifndef PERL_INT_MAX
3614 #  ifdef INT_MAX
3615 #    define PERL_INT_MAX ((int)INT_MAX)
3616 #  else
3617 #    ifdef MAXINT    /* Often used in <values.h> */
3618 #      define PERL_INT_MAX ((int)MAXINT)
3619 #    else
3620 #      define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
3621 #    endif
3622 #  endif
3623 #endif
3624
3625 #ifndef PERL_INT_MIN
3626 #  ifdef INT_MIN
3627 #    define PERL_INT_MIN ((int)INT_MIN)
3628 #  else
3629 #    ifdef MININT
3630 #      define PERL_INT_MIN ((int)MININT)
3631 #    else
3632 #      define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
3633 #    endif
3634 #  endif
3635 #endif
3636
3637 #ifndef PERL_ULONG_MAX
3638 #  ifdef ULONG_MAX
3639 #    define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
3640 #  else
3641 #    ifdef MAXULONG
3642 #      define PERL_ULONG_MAX ((unsigned long)MAXULONG)
3643 #    else
3644 #      define PERL_ULONG_MAX (~(unsigned long)0)
3645 #    endif
3646 #  endif
3647 #endif
3648
3649 #ifndef PERL_ULONG_MIN
3650 #  define PERL_ULONG_MIN ((unsigned long)0L)
3651 #endif
3652
3653 #ifndef PERL_LONG_MAX
3654 #  ifdef LONG_MAX
3655 #    define PERL_LONG_MAX ((long)LONG_MAX)
3656 #  else
3657 #    ifdef MAXLONG
3658 #      define PERL_LONG_MAX ((long)MAXLONG)
3659 #    else
3660 #      define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
3661 #    endif
3662 #  endif
3663 #endif
3664
3665 #ifndef PERL_LONG_MIN
3666 #  ifdef LONG_MIN
3667 #    define PERL_LONG_MIN ((long)LONG_MIN)
3668 #  else
3669 #    ifdef MINLONG
3670 #      define PERL_LONG_MIN ((long)MINLONG)
3671 #    else
3672 #      define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
3673 #    endif
3674 #  endif
3675 #endif
3676
3677 #if defined(HAS_QUAD) && (defined(convex) || defined(uts))
3678 #  ifndef PERL_UQUAD_MAX
3679 #    ifdef ULONGLONG_MAX
3680 #      define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
3681 #    else
3682 #      ifdef MAXULONGLONG
3683 #        define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
3684 #      else
3685 #        define PERL_UQUAD_MAX (~(unsigned long long)0)
3686 #      endif
3687 #    endif
3688 #  endif
3689
3690 #  ifndef PERL_UQUAD_MIN
3691 #    define PERL_UQUAD_MIN ((unsigned long long)0L)
3692 #  endif
3693
3694 #  ifndef PERL_QUAD_MAX
3695 #    ifdef LONGLONG_MAX
3696 #      define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
3697 #    else
3698 #      ifdef MAXLONGLONG
3699 #        define PERL_QUAD_MAX ((long long)MAXLONGLONG)
3700 #      else
3701 #        define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
3702 #      endif
3703 #    endif
3704 #  endif
3705
3706 #  ifndef PERL_QUAD_MIN
3707 #    ifdef LONGLONG_MIN
3708 #      define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
3709 #    else
3710 #      ifdef MINLONGLONG
3711 #        define PERL_QUAD_MIN ((long long)MINLONGLONG)
3712 #      else
3713 #        define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
3714 #      endif
3715 #    endif
3716 #  endif
3717 #endif
3718
3719 /* This is based on code from 5.003 perl.h */
3720 #ifdef HAS_QUAD
3721 #  ifdef cray
3722 #ifndef IVTYPE
3723 #  define IVTYPE                         int
3724 #endif
3725
3726 #ifndef IV_MIN
3727 #  define IV_MIN                         PERL_INT_MIN
3728 #endif
3729
3730 #ifndef IV_MAX
3731 #  define IV_MAX                         PERL_INT_MAX
3732 #endif
3733
3734 #ifndef UV_MIN
3735 #  define UV_MIN                         PERL_UINT_MIN
3736 #endif
3737
3738 #ifndef UV_MAX
3739 #  define UV_MAX                         PERL_UINT_MAX
3740 #endif
3741
3742 #    ifdef INTSIZE
3743 #ifndef IVSIZE
3744 #  define IVSIZE                         INTSIZE
3745 #endif
3746
3747 #    endif
3748 #  else
3749 #    if defined(convex) || defined(uts)
3750 #ifndef IVTYPE
3751 #  define IVTYPE                         long long
3752 #endif
3753
3754 #ifndef IV_MIN
3755 #  define IV_MIN                         PERL_QUAD_MIN
3756 #endif
3757
3758 #ifndef IV_MAX
3759 #  define IV_MAX                         PERL_QUAD_MAX
3760 #endif
3761
3762 #ifndef UV_MIN
3763 #  define UV_MIN                         PERL_UQUAD_MIN
3764 #endif
3765
3766 #ifndef UV_MAX
3767 #  define UV_MAX                         PERL_UQUAD_MAX
3768 #endif
3769
3770 #      ifdef LONGLONGSIZE
3771 #ifndef IVSIZE
3772 #  define IVSIZE                         LONGLONGSIZE
3773 #endif
3774
3775 #      endif
3776 #    else
3777 #ifndef IVTYPE
3778 #  define IVTYPE                         long
3779 #endif
3780
3781 #ifndef IV_MIN
3782 #  define IV_MIN                         PERL_LONG_MIN
3783 #endif
3784
3785 #ifndef IV_MAX
3786 #  define IV_MAX                         PERL_LONG_MAX
3787 #endif
3788
3789 #ifndef UV_MIN
3790 #  define UV_MIN                         PERL_ULONG_MIN
3791 #endif
3792
3793 #ifndef UV_MAX
3794 #  define UV_MAX                         PERL_ULONG_MAX
3795 #endif
3796
3797 #      ifdef LONGSIZE
3798 #ifndef IVSIZE
3799 #  define IVSIZE                         LONGSIZE
3800 #endif
3801
3802 #      endif
3803 #    endif
3804 #  endif
3805 #ifndef IVSIZE
3806 #  define IVSIZE                         8
3807 #endif
3808
3809 #ifndef PERL_QUAD_MIN
3810 #  define PERL_QUAD_MIN                  IV_MIN
3811 #endif
3812
3813 #ifndef PERL_QUAD_MAX
3814 #  define PERL_QUAD_MAX                  IV_MAX
3815 #endif
3816
3817 #ifndef PERL_UQUAD_MIN
3818 #  define PERL_UQUAD_MIN                 UV_MIN
3819 #endif
3820
3821 #ifndef PERL_UQUAD_MAX
3822 #  define PERL_UQUAD_MAX                 UV_MAX
3823 #endif
3824
3825 #else
3826 #ifndef IVTYPE
3827 #  define IVTYPE                         long
3828 #endif
3829
3830 #ifndef IV_MIN
3831 #  define IV_MIN                         PERL_LONG_MIN
3832 #endif
3833
3834 #ifndef IV_MAX
3835 #  define IV_MAX                         PERL_LONG_MAX
3836 #endif
3837
3838 #ifndef UV_MIN
3839 #  define UV_MIN                         PERL_ULONG_MIN
3840 #endif
3841
3842 #ifndef UV_MAX
3843 #  define UV_MAX                         PERL_ULONG_MAX
3844 #endif
3845
3846 #endif
3847
3848 #ifndef IVSIZE
3849 #  ifdef LONGSIZE
3850 #    define IVSIZE LONGSIZE
3851 #  else
3852 #    define IVSIZE 4 /* A bold guess, but the best we can make. */
3853 #  endif
3854 #endif
3855 #ifndef UVTYPE
3856 #  define UVTYPE                         unsigned IVTYPE
3857 #endif
3858
3859 #ifndef UVSIZE
3860 #  define UVSIZE                         IVSIZE
3861 #endif
3862
3863 #ifndef sv_setuv
3864 #  define sv_setuv(sv, uv)                  \
3865    STMT_START {                             \
3866        UV TeMpUv = uv;                      \
3867        if (TeMpUv <= IV_MAX)                \
3868            sv_setiv(sv, TeMpUv);            \
3869        else                                 \
3870            sv_setnv(sv, (double)TeMpUv);    \
3871    } STMT_END
3872 #endif
3873
3874 #ifndef newSVuv
3875 #  define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
3876 #endif
3877 #ifndef sv_2uv
3878 #  define sv_2uv(sv)                     ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
3879 #endif
3880
3881 #ifndef SvUVX
3882 #  define SvUVX(sv)                      ((UV)SvIVX(sv))
3883 #endif
3884
3885 #ifndef SvUVXx
3886 #  define SvUVXx(sv)                     SvUVX(sv)
3887 #endif
3888
3889 #ifndef SvUV
3890 #  define SvUV(sv)                       (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
3891 #endif
3892
3893 #ifndef SvUVx
3894 #  define SvUVx(sv)                      ((PL_Sv = (sv)), SvUV(PL_Sv))
3895 #endif
3896
3897 /* Hint: sv_uv
3898  * Always use the SvUVx() macro instead of sv_uv().
3899  */
3900 #ifndef sv_uv
3901 #  define sv_uv(sv)                      SvUVx(sv)
3902 #endif
3903 #ifndef XST_mUV
3904 #  define XST_mUV(i,v)                   (ST(i) = sv_2mortal(newSVuv(v))  )
3905 #endif
3906
3907 #ifndef XSRETURN_UV
3908 #  define XSRETURN_UV(v)                 STMT_START { XST_mUV(0,v);  XSRETURN(1); } STMT_END
3909 #endif
3910 #ifndef PUSHu
3911 #  define PUSHu(u)                       STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG;  } STMT_END
3912 #endif
3913
3914 #ifndef XPUSHu
3915 #  define XPUSHu(u)                      STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
3916 #endif
3917
3918 #if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
3919 /* Replace: 1 */
3920 #  define PL_DBsingle               DBsingle
3921 #  define PL_DBsub                  DBsub
3922 #  define PL_Sv                     Sv
3923 #  define PL_compiling              compiling
3924 #  define PL_copline                copline
3925 #  define PL_curcop                 curcop
3926 #  define PL_curstash               curstash
3927 #  define PL_debstash               debstash
3928 #  define PL_defgv                  defgv
3929 #  define PL_diehook                diehook
3930 #  define PL_dirty                  dirty
3931 #  define PL_dowarn                 dowarn
3932 #  define PL_errgv                  errgv
3933 #  define PL_hexdigit               hexdigit
3934 #  define PL_hints                  hints
3935 #  define PL_na                     na
3936 #  define PL_no_modify              no_modify
3937 #  define PL_perl_destruct_level    perl_destruct_level
3938 #  define PL_perldb                 perldb
3939 #  define PL_ppaddr                 ppaddr
3940 #  define PL_rsfp_filters           rsfp_filters
3941 #  define PL_rsfp                   rsfp
3942 #  define PL_stack_base             stack_base
3943 #  define PL_stack_sp               stack_sp
3944 #  define PL_stdingv                stdingv
3945 #  define PL_sv_arenaroot           sv_arenaroot
3946 #  define PL_sv_no                  sv_no
3947 #  define PL_sv_undef               sv_undef
3948 #  define PL_sv_yes                 sv_yes
3949 #  define PL_tainted                tainted
3950 #  define PL_tainting               tainting
3951 /* Replace: 0 */
3952 #endif
3953
3954 #ifndef PERL_UNUSED_DECL
3955 #  ifdef HASATTRIBUTE
3956 #    if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
3957 #      define PERL_UNUSED_DECL
3958 #    else
3959 #      define PERL_UNUSED_DECL __attribute__((unused))
3960 #    endif
3961 #  else
3962 #    define PERL_UNUSED_DECL
3963 #  endif
3964 #endif
3965 #ifndef NOOP
3966 #  define NOOP                           (void)0
3967 #endif
3968
3969 #ifndef dNOOP
3970 #  define dNOOP                          extern int Perl___notused PERL_UNUSED_DECL
3971 #endif
3972
3973 #ifndef NVTYPE
3974 #  if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
3975 #    define NVTYPE long double
3976 #  else
3977 #    define NVTYPE double
3978 #  endif
3979 typedef NVTYPE NV;
3980 #endif
3981
3982 #ifndef INT2PTR
3983
3984 #  if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
3985 #    define PTRV                  UV
3986 #    define INT2PTR(any,d)        (any)(d)
3987 #  else
3988 #    if PTRSIZE == LONGSIZE
3989 #      define PTRV                unsigned long
3990 #    else
3991 #      define PTRV                unsigned
3992 #    endif
3993 #    define INT2PTR(any,d)        (any)(PTRV)(d)
3994 #  endif
3995
3996 #  define NUM2PTR(any,d)  (any)(PTRV)(d)
3997 #  define PTR2IV(p)       INT2PTR(IV,p)
3998 #  define PTR2UV(p)       INT2PTR(UV,p)
3999 #  define PTR2NV(p)       NUM2PTR(NV,p)
4000
4001 #  if PTRSIZE == LONGSIZE
4002 #    define PTR2ul(p)     (unsigned long)(p)
4003 #  else
4004 #    define PTR2ul(p)     INT2PTR(unsigned long,p)        
4005 #  endif
4006
4007 #endif /* !INT2PTR */
4008
4009 #undef START_EXTERN_C
4010 #undef END_EXTERN_C
4011 #undef EXTERN_C
4012 #ifdef __cplusplus
4013 #  define START_EXTERN_C extern "C" {
4014 #  define END_EXTERN_C }
4015 #  define EXTERN_C extern "C"
4016 #else
4017 #  define START_EXTERN_C
4018 #  define END_EXTERN_C
4019 #  define EXTERN_C extern
4020 #endif
4021
4022 #ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
4023 #  if defined(__STRICT_ANSI__) && defined(PERL_GCC_PEDANTIC)
4024 #    define PERL_GCC_BRACE_GROUPS_FORBIDDEN
4025 #  endif
4026 #endif
4027
4028 #undef STMT_START
4029 #undef STMT_END
4030 #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
4031 #  define STMT_START    (void)( /* gcc supports ``({ STATEMENTS; })'' */
4032 #  define STMT_END      )
4033 #else
4034 #  if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
4035 #    define STMT_START  if (1)
4036 #    define STMT_END    else (void)0
4037 #  else
4038 #    define STMT_START  do
4039 #    define STMT_END    while (0)
4040 #  endif
4041 #endif
4042 #ifndef boolSV
4043 #  define boolSV(b)                      ((b) ? &PL_sv_yes : &PL_sv_no)
4044 #endif
4045
4046 /* DEFSV appears first in 5.004_56 */
4047 #ifndef DEFSV
4048 #  define DEFSV                          GvSV(PL_defgv)
4049 #endif
4050
4051 #ifndef SAVE_DEFSV
4052 #  define SAVE_DEFSV                     SAVESPTR(GvSV(PL_defgv))
4053 #endif
4054
4055 /* Older perls (<=5.003) lack AvFILLp */
4056 #ifndef AvFILLp
4057 #  define AvFILLp                        AvFILL
4058 #endif
4059 #ifndef ERRSV
4060 #  define ERRSV                          get_sv("@",FALSE)
4061 #endif
4062 #ifndef newSVpvn
4063 #  define newSVpvn(data,len)             ((data)                                              \
4064                                     ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
4065                                     : newSV(0))
4066 #endif
4067
4068 /* Hint: gv_stashpvn
4069  * This function's backport doesn't support the length parameter, but
4070  * rather ignores it. Portability can only be ensured if the length
4071  * parameter is used for speed reasons, but the length can always be
4072  * correctly computed from the string argument.
4073  */
4074 #ifndef gv_stashpvn
4075 #  define gv_stashpvn(str,len,create)    gv_stashpv(str,create)
4076 #endif
4077
4078 /* Replace: 1 */
4079 #ifndef get_cv
4080 #  define get_cv                         perl_get_cv
4081 #endif
4082
4083 #ifndef get_sv
4084 #  define get_sv                         perl_get_sv
4085 #endif
4086
4087 #ifndef get_av
4088 #  define get_av                         perl_get_av
4089 #endif
4090
4091 #ifndef get_hv
4092 #  define get_hv                         perl_get_hv
4093 #endif
4094
4095 /* Replace: 0 */
4096
4097 #ifdef HAS_MEMCMP
4098 #ifndef memNE
4099 #  define memNE(s1,s2,l)                 (memcmp(s1,s2,l))
4100 #endif
4101
4102 #ifndef memEQ
4103 #  define memEQ(s1,s2,l)                 (!memcmp(s1,s2,l))
4104 #endif
4105
4106 #else
4107 #ifndef memNE
4108 #  define memNE(s1,s2,l)                 (bcmp(s1,s2,l))
4109 #endif
4110
4111 #ifndef memEQ
4112 #  define memEQ(s1,s2,l)                 (!bcmp(s1,s2,l))
4113 #endif
4114
4115 #endif
4116 #ifndef MoveD
4117 #  define MoveD(s,d,n,t)                 memmove((char*)(d),(char*)(s), (n) * sizeof(t))
4118 #endif
4119
4120 #ifndef CopyD
4121 #  define CopyD(s,d,n,t)                 memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
4122 #endif
4123
4124 #ifdef HAS_MEMSET
4125 #ifndef ZeroD
4126 #  define ZeroD(d,n,t)                   memzero((char*)(d), (n) * sizeof(t))
4127 #endif
4128
4129 #else
4130 #ifndef ZeroD
4131 #  define ZeroD(d,n,t)                   ((void)memzero((char*)(d), (n) * sizeof(t)),d)
4132 #endif
4133
4134 #endif
4135 #ifndef Poison
4136 #  define Poison(d,n,t)                  (void)memset((char*)(d), 0xAB, (n) * sizeof(t))
4137 #endif
4138 #ifndef dUNDERBAR
4139 #  define dUNDERBAR                      dNOOP
4140 #endif
4141
4142 #ifndef UNDERBAR
4143 #  define UNDERBAR                       DEFSV
4144 #endif
4145 #ifndef dAX
4146 #  define dAX                            I32 ax = MARK - PL_stack_base + 1
4147 #endif
4148
4149 #ifndef dITEMS
4150 #  define dITEMS                         I32 items = SP - MARK
4151 #endif
4152 #ifndef dXSTARG
4153 #  define dXSTARG                        SV * targ = sv_newmortal()
4154 #endif
4155 #ifndef dTHR
4156 #  define dTHR                           dNOOP
4157 #endif
4158 #ifndef dTHX
4159 #  define dTHX                           dNOOP
4160 #endif
4161
4162 #ifndef dTHXa
4163 #  define dTHXa(x)                       dNOOP
4164 #endif
4165 #ifndef pTHX
4166 #  define pTHX                           void
4167 #endif
4168
4169 #ifndef pTHX_
4170 #  define pTHX_                          
4171 #endif
4172
4173 #ifndef aTHX
4174 #  define aTHX                           
4175 #endif
4176
4177 #ifndef aTHX_
4178 #  define aTHX_                          
4179 #endif
4180 #ifndef dTHXoa
4181 #  define dTHXoa(x)                      dTHXa(x)
4182 #endif
4183 #ifndef PUSHmortal
4184 #  define PUSHmortal                     PUSHs(sv_newmortal())
4185 #endif
4186
4187 #ifndef mPUSHp
4188 #  define mPUSHp(p,l)                    sv_setpvn_mg(PUSHmortal, (p), (l))
4189 #endif
4190
4191 #ifndef mPUSHn
4192 #  define mPUSHn(n)                      sv_setnv_mg(PUSHmortal, (NV)(n))
4193 #endif
4194
4195 #ifndef mPUSHi
4196 #  define mPUSHi(i)                      sv_setiv_mg(PUSHmortal, (IV)(i))
4197 #endif
4198
4199 #ifndef mPUSHu
4200 #  define mPUSHu(u)                      sv_setuv_mg(PUSHmortal, (UV)(u))
4201 #endif
4202 #ifndef XPUSHmortal
4203 #  define XPUSHmortal                    XPUSHs(sv_newmortal())
4204 #endif
4205
4206 #ifndef mXPUSHp
4207 #  define mXPUSHp(p,l)                   STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
4208 #endif
4209
4210 #ifndef mXPUSHn
4211 #  define mXPUSHn(n)                     STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
4212 #endif
4213
4214 #ifndef mXPUSHi
4215 #  define mXPUSHi(i)                     STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
4216 #endif
4217
4218 #ifndef mXPUSHu
4219 #  define mXPUSHu(u)                     STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
4220 #endif
4221
4222 /* Replace: 1 */
4223 #ifndef call_sv
4224 #  define call_sv                        perl_call_sv
4225 #endif
4226
4227 #ifndef call_pv
4228 #  define call_pv                        perl_call_pv
4229 #endif
4230
4231 #ifndef call_argv
4232 #  define call_argv                      perl_call_argv
4233 #endif
4234
4235 #ifndef call_method
4236 #  define call_method                    perl_call_method
4237 #endif
4238 #ifndef eval_sv
4239 #  define eval_sv                        perl_eval_sv
4240 #endif
4241
4242 /* Replace: 0 */
4243
4244 /* Replace perl_eval_pv with eval_pv */
4245 /* eval_pv depends on eval_sv */
4246
4247 #ifndef eval_pv
4248 #if defined(NEED_eval_pv)
4249 static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
4250 static
4251 #else
4252 extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
4253 #endif
4254
4255 #ifdef eval_pv
4256 #  undef eval_pv
4257 #endif
4258 #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
4259 #define Perl_eval_pv DPPP_(my_eval_pv)
4260
4261 #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
4262
4263 SV*
4264 DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
4265 {
4266     dSP;
4267     SV* sv = newSVpv(p, 0);
4268
4269     PUSHMARK(sp);
4270     eval_sv(sv, G_SCALAR);
4271     SvREFCNT_dec(sv);
4272
4273     SPAGAIN;
4274     sv = POPs;
4275     PUTBACK;
4276
4277     if (croak_on_error && SvTRUE(GvSV(errgv)))
4278         croak(SvPVx(GvSV(errgv), na));
4279
4280     return sv;
4281 }
4282
4283 #endif
4284 #endif
4285 #ifndef newRV_inc
4286 #  define newRV_inc(sv)                  newRV(sv)   /* Replace */
4287 #endif
4288
4289 #ifndef newRV_noinc
4290 #if defined(NEED_newRV_noinc)
4291 static SV * DPPP_(my_newRV_noinc)(SV *sv);
4292 static
4293 #else
4294 extern SV * DPPP_(my_newRV_noinc)(SV *sv);
4295 #endif
4296
4297 #ifdef newRV_noinc
4298 #  undef newRV_noinc
4299 #endif
4300 #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
4301 #define Perl_newRV_noinc DPPP_(my_newRV_noinc)
4302
4303 #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
4304 SV *
4305 DPPP_(my_newRV_noinc)(SV *sv)
4306 {
4307   SV *rv = (SV *)newRV(sv);
4308   SvREFCNT_dec(sv);
4309   return rv;
4310 }
4311 #endif
4312 #endif
4313
4314 /* Hint: newCONSTSUB
4315  * Returns a CV* as of perl-5.7.1. This return value is not supported
4316  * by Devel::PPPort.
4317  */
4318
4319 /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
4320 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))) && ((PERL_VERSION != 4) || (PERL_SUBVERSION != 5))
4321 #if defined(NEED_newCONSTSUB)
4322 static void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
4323 static
4324 #else
4325 extern void DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv);
4326 #endif
4327
4328 #ifdef newCONSTSUB
4329 #  undef newCONSTSUB
4330 #endif
4331 #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
4332 #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
4333
4334 #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
4335
4336 void
4337 DPPP_(my_newCONSTSUB)(HV *stash, char *name, SV *sv)
4338 {
4339         U32 oldhints = PL_hints;
4340         HV *old_cop_stash = PL_curcop->cop_stash;
4341         HV *old_curstash = PL_curstash;
4342         line_t oldline = PL_curcop->cop_line;
4343         PL_curcop->cop_line = PL_copline;
4344
4345         PL_hints &= ~HINT_BLOCK_SCOPE;
4346         if (stash)
4347                 PL_curstash = PL_curcop->cop_stash = stash;
4348
4349         newSUB(
4350
4351 #if   ((PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22)))
4352                 start_subparse(),
4353 #elif ((PERL_VERSION == 3) && (PERL_SUBVERSION == 22))
4354                 start_subparse(0),
4355 #else  /* 5.003_23  onwards */
4356                 start_subparse(FALSE, 0),
4357 #endif
4358
4359                 newSVOP(OP_CONST, 0, newSVpv(name,0)),
4360                 newSVOP(OP_CONST, 0, &PL_sv_no),   /* SvPV(&PL_sv_no) == "" -- GMB */
4361                 newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
4362         );
4363
4364         PL_hints = oldhints;
4365         PL_curcop->cop_stash = old_cop_stash;
4366         PL_curstash = old_curstash;
4367         PL_curcop->cop_line = oldline;
4368 }
4369 #endif
4370 #endif
4371
4372 /*
4373  * Boilerplate macros for initializing and accessing interpreter-local
4374  * data from C.  All statics in extensions should be reworked to use
4375  * this, if you want to make the extension thread-safe.  See ext/re/re.xs
4376  * for an example of the use of these macros.
4377  *
4378  * Code that uses these macros is responsible for the following:
4379  * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
4380  * 2. Declare a typedef named my_cxt_t that is a structure that contains
4381  *    all the data that needs to be interpreter-local.
4382  * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
4383  * 4. Use the MY_CXT_INIT macro such that it is called exactly once
4384  *    (typically put in the BOOT: section).
4385  * 5. Use the members of the my_cxt_t structure everywhere as
4386  *    MY_CXT.member.
4387  * 6. Use the dMY_CXT macro (a declaration) in all the functions that
4388  *    access MY_CXT.
4389  */
4390
4391 #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
4392     defined(PERL_CAPI)    || defined(PERL_IMPLICIT_CONTEXT)
4393
4394 #ifndef START_MY_CXT
4395
4396 /* This must appear in all extensions that define a my_cxt_t structure,
4397  * right after the definition (i.e. at file scope).  The non-threads
4398  * case below uses it to declare the data as static. */
4399 #define START_MY_CXT
4400
4401 #if (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
4402 /* Fetches the SV that keeps the per-interpreter data. */
4403 #define dMY_CXT_SV \
4404         SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
4405 #else /* >= perl5.004_68 */
4406 #define dMY_CXT_SV \
4407         SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY,             \
4408                                   sizeof(MY_CXT_KEY)-1, TRUE)
4409 #endif /* < perl5.004_68 */
4410
4411 /* This declaration should be used within all functions that use the
4412  * interpreter-local data. */
4413 #define dMY_CXT \
4414         dMY_CXT_SV;                                                     \
4415         my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
4416
4417 /* Creates and zeroes the per-interpreter data.
4418  * (We allocate my_cxtp in a Perl SV so that it will be released when
4419  * the interpreter goes away.) */
4420 #define MY_CXT_INIT \
4421         dMY_CXT_SV;                                                     \
4422         /* newSV() allocates one more than needed */                    \
4423         my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
4424         Zero(my_cxtp, 1, my_cxt_t);                                     \
4425         sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
4426
4427 /* This macro must be used to access members of the my_cxt_t structure.
4428  * e.g. MYCXT.some_data */
4429 #define MY_CXT          (*my_cxtp)
4430
4431 /* Judicious use of these macros can reduce the number of times dMY_CXT
4432  * is used.  Use is similar to pTHX, aTHX etc. */
4433 #define pMY_CXT         my_cxt_t *my_cxtp
4434 #define pMY_CXT_        pMY_CXT,
4435 #define _pMY_CXT        ,pMY_CXT
4436 #define aMY_CXT         my_cxtp
4437 #define aMY_CXT_        aMY_CXT,
4438 #define _aMY_CXT        ,aMY_CXT
4439
4440 #endif /* START_MY_CXT */
4441
4442 #ifndef MY_CXT_CLONE
4443 /* Clones the per-interpreter data. */
4444 #define MY_CXT_CLONE \
4445         dMY_CXT_SV;                                                     \
4446         my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
4447         Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
4448         sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
4449 #endif
4450
4451 #else /* single interpreter */
4452
4453 #ifndef START_MY_CXT
4454
4455 #define START_MY_CXT    static my_cxt_t my_cxt;
4456 #define dMY_CXT_SV      dNOOP
4457 #define dMY_CXT         dNOOP
4458 #define MY_CXT_INIT     NOOP
4459 #define MY_CXT          my_cxt
4460
4461 #define pMY_CXT         void
4462 #define pMY_CXT_
4463 #define _pMY_CXT
4464 #define aMY_CXT
4465 #define aMY_CXT_
4466 #define _aMY_CXT
4467
4468 #endif /* START_MY_CXT */
4469
4470 #ifndef MY_CXT_CLONE
4471 #define MY_CXT_CLONE    NOOP
4472 #endif
4473
4474 #endif
4475
4476 #ifndef IVdf
4477 #  if IVSIZE == LONGSIZE
4478 #    define     IVdf      "ld"
4479 #    define     UVuf      "lu"
4480 #    define     UVof      "lo"
4481 #    define     UVxf      "lx"
4482 #    define     UVXf      "lX"
4483 #  else
4484 #    if IVSIZE == INTSIZE
4485 #      define   IVdf      "d"
4486 #      define   UVuf      "u"
4487 #      define   UVof      "o"
4488 #      define   UVxf      "x"
4489 #      define   UVXf      "X"
4490 #    endif
4491 #  endif
4492 #endif
4493
4494 #ifndef NVef
4495 #  if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
4496       defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */ 
4497 #    define NVef          PERL_PRIeldbl
4498 #    define NVff          PERL_PRIfldbl
4499 #    define NVgf          PERL_PRIgldbl
4500 #  else
4501 #    define NVef          "e"
4502 #    define NVff          "f"
4503 #    define NVgf          "g"
4504 #  endif
4505 #endif
4506
4507 #ifndef SvPV_nolen
4508
4509 #if defined(NEED_sv_2pv_nolen)
4510 static char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
4511 static
4512 #else
4513 extern char * DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv);
4514 #endif
4515
4516 #ifdef sv_2pv_nolen
4517 #  undef sv_2pv_nolen
4518 #endif
4519 #define sv_2pv_nolen(a) DPPP_(my_sv_2pv_nolen)(aTHX_ a)
4520 #define Perl_sv_2pv_nolen DPPP_(my_sv_2pv_nolen)
4521
4522 #if defined(NEED_sv_2pv_nolen) || defined(NEED_sv_2pv_nolen_GLOBAL)
4523
4524 char *
4525 DPPP_(my_sv_2pv_nolen)(pTHX_ register SV *sv)
4526 {   
4527   STRLEN n_a;
4528   return sv_2pv(sv, &n_a);
4529 }
4530
4531 #endif
4532
4533 /* Hint: sv_2pv_nolen
4534  * Use the SvPV_nolen() macro instead of sv_2pv_nolen().
4535  */
4536
4537 /* SvPV_nolen depends on sv_2pv_nolen */
4538 #define SvPV_nolen(sv) \
4539           ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
4540            ? SvPVX(sv) : sv_2pv_nolen(sv))
4541
4542 #endif
4543
4544 #ifdef SvPVbyte
4545
4546 /* Hint: SvPVbyte
4547  * Does not work in perl-5.6.1, ppport.h implements a version
4548  * borrowed from perl-5.7.3.
4549  */
4550
4551 #if ((PERL_VERSION < 7) || ((PERL_VERSION == 7) && (PERL_SUBVERSION < 0)))
4552
4553 #if defined(NEED_sv_2pvbyte)
4554 static char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
4555 static
4556 #else
4557 extern char * DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp);
4558 #endif
4559
4560 #ifdef sv_2pvbyte
4561 #  undef sv_2pvbyte
4562 #endif
4563 #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
4564 #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
4565
4566 #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
4567
4568 char *
4569 DPPP_(my_sv_2pvbyte)(pTHX_ register SV *sv, STRLEN *lp)
4570 {   
4571   sv_utf8_downgrade(sv,0);
4572   return SvPV(sv,*lp);
4573 }
4574
4575 #endif
4576
4577 /* Hint: sv_2pvbyte
4578  * Use the SvPVbyte() macro instead of sv_2pvbyte().
4579  */
4580
4581 #undef SvPVbyte
4582
4583 /* SvPVbyte depends on sv_2pvbyte */
4584 #define SvPVbyte(sv, lp)                                                \
4585         ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK)                \
4586          ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
4587
4588 #endif
4589
4590 #else
4591
4592 #  define SvPVbyte          SvPV
4593 #  define sv_2pvbyte        sv_2pv
4594
4595 #endif
4596
4597 /* sv_2pvbyte_nolen depends on sv_2pv_nolen */
4598 #ifndef sv_2pvbyte_nolen
4599 #  define sv_2pvbyte_nolen               sv_2pv_nolen
4600 #endif
4601
4602 /* Hint: sv_pvn
4603  * Always use the SvPV() macro instead of sv_pvn().
4604  */
4605 #ifndef sv_pvn
4606 #  define sv_pvn(sv, len)                SvPV(sv, len)
4607 #endif
4608
4609 /* Hint: sv_pvn_force
4610  * Always use the SvPV_force() macro instead of sv_pvn_force().
4611  */
4612 #ifndef sv_pvn_force
4613 #  define sv_pvn_force(sv, len)          SvPV_force(sv, len)
4614 #endif
4615
4616 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(vnewSVpvf)
4617 #if defined(NEED_vnewSVpvf)
4618 static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4619 static
4620 #else
4621 extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
4622 #endif
4623
4624 #ifdef vnewSVpvf
4625 #  undef vnewSVpvf
4626 #endif
4627 #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
4628 #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
4629
4630 #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
4631
4632 SV *
4633 DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
4634 {
4635   register SV *sv = newSV(0);
4636   sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
4637   return sv;
4638 }
4639
4640 #endif
4641 #endif
4642
4643 /* sv_vcatpvf depends on sv_vcatpvfn */
4644 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf)
4645 #  define sv_vcatpvf(sv, pat, args)  sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4646 #endif
4647
4648 /* sv_vsetpvf depends on sv_vsetpvfn */
4649 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf)
4650 #  define sv_vsetpvf(sv, pat, args)  sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
4651 #endif
4652
4653 /* sv_catpvf_mg depends on sv_vcatpvfn, sv_catpvf_mg_nocontext */
4654 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg)
4655 #if defined(NEED_sv_catpvf_mg)
4656 static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4657 static
4658 #else
4659 extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4660 #endif
4661
4662 #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
4663
4664 #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
4665
4666 void
4667 DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4668 {
4669   va_list args;
4670   va_start(args, pat);
4671   sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4672   SvSETMAGIC(sv);
4673   va_end(args);
4674 }
4675
4676 #endif
4677 #endif
4678
4679 /* sv_catpvf_mg_nocontext depends on sv_vcatpvfn */
4680 #ifdef PERL_IMPLICIT_CONTEXT
4681 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_catpvf_mg_nocontext)
4682 #if defined(NEED_sv_catpvf_mg_nocontext)
4683 static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4684 static
4685 #else
4686 extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4687 #endif
4688
4689 #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4690 #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
4691
4692 #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
4693
4694 void
4695 DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4696 {
4697   dTHX;
4698   va_list args;
4699   va_start(args, pat);
4700   sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4701   SvSETMAGIC(sv);
4702   va_end(args);
4703 }
4704
4705 #endif
4706 #endif
4707 #endif
4708
4709 #ifndef sv_catpvf_mg
4710 #  ifdef PERL_IMPLICIT_CONTEXT
4711 #    define sv_catpvf_mg   Perl_sv_catpvf_mg_nocontext
4712 #  else
4713 #    define sv_catpvf_mg   Perl_sv_catpvf_mg
4714 #  endif
4715 #endif
4716
4717 /* sv_vcatpvf_mg depends on sv_vcatpvfn */
4718 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vcatpvf_mg)
4719 #  define sv_vcatpvf_mg(sv, pat, args)                                     \
4720    STMT_START {                                                            \
4721      sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));  \
4722      SvSETMAGIC(sv);                                                       \
4723    } STMT_END
4724 #endif
4725
4726 /* sv_setpvf_mg depends on sv_vsetpvfn, sv_setpvf_mg_nocontext */
4727 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg)
4728 #if defined(NEED_sv_setpvf_mg)
4729 static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4730 static
4731 #else
4732 extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
4733 #endif
4734
4735 #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
4736
4737 #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
4738
4739 void
4740 DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
4741 {
4742   va_list args;
4743   va_start(args, pat);
4744   sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4745   SvSETMAGIC(sv);
4746   va_end(args);
4747 }
4748
4749 #endif
4750 #endif
4751
4752 /* sv_setpvf_mg_nocontext depends on sv_vsetpvfn */
4753 #ifdef PERL_IMPLICIT_CONTEXT
4754 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_setpvf_mg_nocontext)
4755 #if defined(NEED_sv_setpvf_mg_nocontext)
4756 static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4757 static
4758 #else
4759 extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
4760 #endif
4761
4762 #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4763 #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
4764
4765 #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
4766
4767 void
4768 DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
4769 {
4770   dTHX;
4771   va_list args;
4772   va_start(args, pat);
4773   sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
4774   SvSETMAGIC(sv);
4775   va_end(args);
4776 }
4777
4778 #endif
4779 #endif
4780 #endif
4781
4782 #ifndef sv_setpvf_mg
4783 #  ifdef PERL_IMPLICIT_CONTEXT
4784 #    define sv_setpvf_mg   Perl_sv_setpvf_mg_nocontext
4785 #  else
4786 #    define sv_setpvf_mg   Perl_sv_setpvf_mg
4787 #  endif
4788 #endif
4789
4790 /* sv_vsetpvf_mg depends on sv_vsetpvfn */
4791 #if ((PERL_VERSION > 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION >= 0))) && !defined(sv_vsetpvf_mg)
4792 #  define sv_vsetpvf_mg(sv, pat, args)                                     \
4793    STMT_START {                                                            \
4794      sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));  \
4795      SvSETMAGIC(sv);                                                       \
4796    } STMT_END
4797 #endif
4798 #ifndef SvGETMAGIC
4799 #  define SvGETMAGIC(x)                  STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
4800 #endif
4801 #ifndef PERL_MAGIC_sv
4802 #  define PERL_MAGIC_sv                  '\0'
4803 #endif
4804
4805 #ifndef PERL_MAGIC_overload
4806 #  define PERL_MAGIC_overload            'A'
4807 #endif
4808
4809 #ifndef PERL_MAGIC_overload_elem
4810 #  define PERL_MAGIC_overload_elem       'a'
4811 #endif
4812
4813 #ifndef PERL_MAGIC_overload_table
4814 #  define PERL_MAGIC_overload_table      'c'
4815 #endif
4816
4817 #ifndef PERL_MAGIC_bm
4818 #  define PERL_MAGIC_bm                  'B'
4819 #endif
4820
4821 #ifndef PERL_MAGIC_regdata
4822 #  define PERL_MAGIC_regdata             'D'
4823 #endif
4824
4825 #ifndef PERL_MAGIC_regdatum
4826 #  define PERL_MAGIC_regdatum            'd'
4827 #endif
4828
4829 #ifndef PERL_MAGIC_env
4830 #  define PERL_MAGIC_env                 'E'
4831 #endif
4832
4833 #ifndef PERL_MAGIC_envelem
4834 #  define PERL_MAGIC_envelem             'e'
4835 #endif
4836
4837 #ifndef PERL_MAGIC_fm
4838 #  define PERL_MAGIC_fm                  'f'
4839 #endif
4840
4841 #ifndef PERL_MAGIC_regex_global
4842 #  define PERL_MAGIC_regex_global        'g'
4843 #endif
4844
4845 #ifndef PERL_MAGIC_isa
4846 #  define PERL_MAGIC_isa                 'I'
4847 #endif
4848
4849 #ifndef PERL_MAGIC_isaelem
4850 #  define PERL_MAGIC_isaelem             'i'
4851 #endif
4852
4853 #ifndef PERL_MAGIC_nkeys
4854 #  define PERL_MAGIC_nkeys               'k'
4855 #endif
4856
4857 #ifndef PERL_MAGIC_dbfile
4858 #  define PERL_MAGIC_dbfile              'L'
4859 #endif
4860
4861 #ifndef PERL_MAGIC_dbline
4862 #  define PERL_MAGIC_dbline              'l'
4863 #endif
4864
4865 #ifndef PERL_MAGIC_mutex
4866 #  define PERL_MAGIC_mutex               'm'
4867 #endif
4868
4869 #ifndef PERL_MAGIC_shared
4870 #  define PERL_MAGIC_shared              'N'
4871 #endif
4872
4873 #ifndef PERL_MAGIC_shared_scalar
4874 #  define PERL_MAGIC_shared_scalar       'n'
4875 #endif
4876
4877 #ifndef PERL_MAGIC_collxfrm
4878 #  define PERL_MAGIC_collxfrm            'o'
4879 #endif
4880
4881 #ifndef PERL_MAGIC_tied
4882 #  define PERL_MAGIC_tied                'P'
4883 #endif
4884
4885 #ifndef PERL_MAGIC_tiedelem
4886 #  define PERL_MAGIC_tiedelem            'p'
4887 #endif
4888
4889 #ifndef PERL_MAGIC_tiedscalar
4890 #  define PERL_MAGIC_tiedscalar          'q'
4891 #endif
4892
4893 #ifndef PERL_MAGIC_qr
4894 #  define PERL_MAGIC_qr                  'r'
4895 #endif
4896
4897 #ifndef PERL_MAGIC_sig
4898 #  define PERL_MAGIC_sig                 'S'
4899 #endif
4900
4901 #ifndef PERL_MAGIC_sigelem
4902 #  define PERL_MAGIC_sigelem             's'
4903 #endif
4904
4905 #ifndef PERL_MAGIC_taint
4906 #  define PERL_MAGIC_taint               't'
4907 #endif
4908
4909 #ifndef PERL_MAGIC_uvar
4910 #  define PERL_MAGIC_uvar                'U'
4911 #endif
4912
4913 #ifndef PERL_MAGIC_uvar_elem
4914 #  define PERL_MAGIC_uvar_elem           'u'
4915 #endif
4916
4917 #ifndef PERL_MAGIC_vstring
4918 #  define PERL_MAGIC_vstring             'V'
4919 #endif
4920
4921 #ifndef PERL_MAGIC_vec
4922 #  define PERL_MAGIC_vec                 'v'
4923 #endif
4924
4925 #ifndef PERL_MAGIC_utf8
4926 #  define PERL_MAGIC_utf8                'w'
4927 #endif
4928
4929 #ifndef PERL_MAGIC_substr
4930 #  define PERL_MAGIC_substr              'x'
4931 #endif
4932
4933 #ifndef PERL_MAGIC_defelem
4934 #  define PERL_MAGIC_defelem             'y'
4935 #endif
4936
4937 #ifndef PERL_MAGIC_glob
4938 #  define PERL_MAGIC_glob                '*'
4939 #endif
4940
4941 #ifndef PERL_MAGIC_arylen
4942 #  define PERL_MAGIC_arylen              '#'
4943 #endif
4944
4945 #ifndef PERL_MAGIC_pos
4946 #  define PERL_MAGIC_pos                 '.'
4947 #endif
4948
4949 #ifndef PERL_MAGIC_backref
4950 #  define PERL_MAGIC_backref             '<'
4951 #endif
4952
4953 #ifndef PERL_MAGIC_ext
4954 #  define PERL_MAGIC_ext                 '~'
4955 #endif
4956
4957 /* That's the best we can do... */
4958 #ifndef SvPV_force_nomg
4959 #  define SvPV_force_nomg                SvPV_force
4960 #endif
4961
4962 #ifndef SvPV_nomg
4963 #  define SvPV_nomg                      SvPV
4964 #endif
4965
4966 #ifndef sv_catpvn_nomg
4967 #  define sv_catpvn_nomg                 sv_catpvn
4968 #endif
4969
4970 #ifndef sv_catsv_nomg
4971 #  define sv_catsv_nomg                  sv_catsv
4972 #endif
4973
4974 #ifndef sv_setsv_nomg
4975 #  define sv_setsv_nomg                  sv_setsv
4976 #endif
4977
4978 #ifndef sv_pvn_nomg
4979 #  define sv_pvn_nomg                    sv_pvn
4980 #endif
4981
4982 #ifndef SvIV_nomg
4983 #  define SvIV_nomg                      SvIV
4984 #endif
4985
4986 #ifndef SvUV_nomg
4987 #  define SvUV_nomg                      SvUV
4988 #endif
4989
4990 #ifndef sv_catpv_mg
4991 #  define sv_catpv_mg(sv, ptr)          \
4992    STMT_START {                         \
4993      SV *TeMpSv = sv;                   \
4994      sv_catpv(TeMpSv,ptr);              \
4995      SvSETMAGIC(TeMpSv);                \
4996    } STMT_END
4997 #endif
4998
4999 #ifndef sv_catpvn_mg
5000 #  define sv_catpvn_mg(sv, ptr, len)    \
5001    STMT_START {                         \
5002      SV *TeMpSv = sv;                   \
5003      sv_catpvn(TeMpSv,ptr,len);         \
5004      SvSETMAGIC(TeMpSv);                \
5005    } STMT_END
5006 #endif
5007
5008 #ifndef sv_catsv_mg
5009 #  define sv_catsv_mg(dsv, ssv)         \
5010    STMT_START {                         \
5011      SV *TeMpSv = dsv;                  \
5012      sv_catsv(TeMpSv,ssv);              \
5013      SvSETMAGIC(TeMpSv);                \
5014    } STMT_END
5015 #endif
5016
5017 #ifndef sv_setiv_mg
5018 #  define sv_setiv_mg(sv, i)            \
5019    STMT_START {                         \
5020      SV *TeMpSv = sv;                   \
5021      sv_setiv(TeMpSv,i);                \
5022      SvSETMAGIC(TeMpSv);                \
5023    } STMT_END
5024 #endif
5025
5026 #ifndef sv_setnv_mg
5027 #  define sv_setnv_mg(sv, num)          \
5028    STMT_START {                         \
5029      SV *TeMpSv = sv;                   \
5030      sv_setnv(TeMpSv,num);              \
5031      SvSETMAGIC(TeMpSv);                \
5032    } STMT_END
5033 #endif
5034
5035 #ifndef sv_setpv_mg
5036 #  define sv_setpv_mg(sv, ptr)          \
5037    STMT_START {                         \
5038      SV *TeMpSv = sv;                   \
5039      sv_setpv(TeMpSv,ptr);              \
5040      SvSETMAGIC(TeMpSv);                \
5041    } STMT_END
5042 #endif
5043
5044 #ifndef sv_setpvn_mg
5045 #  define sv_setpvn_mg(sv, ptr, len)    \
5046    STMT_START {                         \
5047      SV *TeMpSv = sv;                   \
5048      sv_setpvn(TeMpSv,ptr,len);         \
5049      SvSETMAGIC(TeMpSv);                \
5050    } STMT_END
5051 #endif
5052
5053 #ifndef sv_setsv_mg
5054 #  define sv_setsv_mg(dsv, ssv)         \
5055    STMT_START {                         \
5056      SV *TeMpSv = dsv;                  \
5057      sv_setsv(TeMpSv,ssv);              \
5058      SvSETMAGIC(TeMpSv);                \
5059    } STMT_END
5060 #endif
5061
5062 #ifndef sv_setuv_mg
5063 #  define sv_setuv_mg(sv, i)            \
5064    STMT_START {                         \
5065      SV *TeMpSv = sv;                   \
5066      sv_setuv(TeMpSv,i);                \
5067      SvSETMAGIC(TeMpSv);                \
5068    } STMT_END
5069 #endif
5070
5071 #ifndef sv_usepvn_mg
5072 #  define sv_usepvn_mg(sv, ptr, len)    \
5073    STMT_START {                         \
5074      SV *TeMpSv = sv;                   \
5075      sv_usepvn(TeMpSv,ptr,len);         \
5076      SvSETMAGIC(TeMpSv);                \
5077    } STMT_END
5078 #endif
5079
5080 #ifdef USE_ITHREADS
5081 #ifndef CopFILE
5082 #  define CopFILE(c)                     ((c)->cop_file)
5083 #endif
5084
5085 #ifndef CopFILEGV
5086 #  define CopFILEGV(c)                   (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
5087 #endif
5088
5089 #ifndef CopFILE_set
5090 #  define CopFILE_set(c,pv)              ((c)->cop_file = savepv(pv))
5091 #endif
5092
5093 #ifndef CopFILESV
5094 #  define CopFILESV(c)                   (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
5095 #endif
5096
5097 #ifndef CopFILEAV
5098 #  define CopFILEAV(c)                   (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
5099 #endif
5100
5101 #ifndef CopSTASHPV
5102 #  define CopSTASHPV(c)                  ((c)->cop_stashpv)
5103 #endif
5104
5105 #ifndef CopSTASHPV_set
5106 #  define CopSTASHPV_set(c,pv)           ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
5107 #endif
5108
5109 #ifndef CopSTASH
5110 #  define CopSTASH(c)                    (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
5111 #endif
5112
5113 #ifndef CopSTASH_set
5114 #  define CopSTASH_set(c,hv)             CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
5115 #endif
5116
5117 #ifndef CopSTASH_eq
5118 #  define CopSTASH_eq(c,hv)              ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
5119                                         || (CopSTASHPV(c) && HvNAME(hv) \
5120                                         && strEQ(CopSTASHPV(c), HvNAME(hv)))))
5121 #endif
5122
5123 #else
5124 #ifndef CopFILEGV
5125 #  define CopFILEGV(c)                   ((c)->cop_filegv)
5126 #endif
5127
5128 #ifndef CopFILEGV_set
5129 #  define CopFILEGV_set(c,gv)            ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
5130 #endif
5131
5132 #ifndef CopFILE_set
5133 #  define CopFILE_set(c,pv)              CopFILEGV_set((c), gv_fetchfile(pv))
5134 #endif
5135
5136 #ifndef CopFILESV
5137 #  define CopFILESV(c)                   (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
5138 #endif
5139
5140 #ifndef CopFILEAV
5141 #  define CopFILEAV(c)                   (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
5142 #endif
5143
5144 #ifndef CopFILE
5145 #  define CopFILE(c)                     (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
5146 #endif
5147
5148 #ifndef CopSTASH
5149 #  define CopSTASH(c)                    ((c)->cop_stash)
5150 #endif
5151
5152 #ifndef CopSTASH_set
5153 #  define CopSTASH_set(c,hv)             ((c)->cop_stash = (hv))
5154 #endif
5155
5156 #ifndef CopSTASHPV
5157 #  define CopSTASHPV(c)                  (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
5158 #endif
5159
5160 #ifndef CopSTASHPV_set
5161 #  define CopSTASHPV_set(c,pv)           CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
5162 #endif
5163
5164 #ifndef CopSTASH_eq
5165 #  define CopSTASH_eq(c,hv)              (CopSTASH(c) == (hv))
5166 #endif
5167
5168 #endif /* USE_ITHREADS */
5169 #ifndef IN_PERL_COMPILETIME
5170 #  define IN_PERL_COMPILETIME            (PL_curcop == &PL_compiling)
5171 #endif
5172
5173 #ifndef IN_LOCALE_RUNTIME
5174 #  define IN_LOCALE_RUNTIME              (PL_curcop->op_private & HINT_LOCALE)
5175 #endif
5176
5177 #ifndef IN_LOCALE_COMPILETIME
5178 #  define IN_LOCALE_COMPILETIME          (PL_hints & HINT_LOCALE)
5179 #endif
5180
5181 #ifndef IN_LOCALE
5182 #  define IN_LOCALE                      (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
5183 #endif
5184 #ifndef IS_NUMBER_IN_UV
5185 #  define IS_NUMBER_IN_UV                0x01
5186 #endif
5187
5188 #ifndef IS_NUMBER_GREATER_THAN_UV_MAX
5189 #  define IS_NUMBER_GREATER_THAN_UV_MAX  0x02
5190 #endif
5191
5192 #ifndef IS_NUMBER_NOT_INT
5193 #  define IS_NUMBER_NOT_INT              0x04
5194 #endif
5195
5196 #ifndef IS_NUMBER_NEG
5197 #  define IS_NUMBER_NEG                  0x08
5198 #endif
5199
5200 #ifndef IS_NUMBER_INFINITY
5201 #  define IS_NUMBER_INFINITY             0x10
5202 #endif
5203
5204 #ifndef IS_NUMBER_NAN
5205 #  define IS_NUMBER_NAN                  0x20
5206 #endif
5207
5208 /* GROK_NUMERIC_RADIX depends on grok_numeric_radix */
5209 #ifndef GROK_NUMERIC_RADIX
5210 #  define GROK_NUMERIC_RADIX(sp, send)   grok_numeric_radix(sp, send)
5211 #endif
5212 #ifndef PERL_SCAN_GREATER_THAN_UV_MAX
5213 #  define PERL_SCAN_GREATER_THAN_UV_MAX  0x02
5214 #endif
5215
5216 #ifndef PERL_SCAN_SILENT_ILLDIGIT
5217 #  define PERL_SCAN_SILENT_ILLDIGIT      0x04
5218 #endif
5219
5220 #ifndef PERL_SCAN_ALLOW_UNDERSCORES
5221 #  define PERL_SCAN_ALLOW_UNDERSCORES    0x01
5222 #endif
5223
5224 #ifndef PERL_SCAN_DISALLOW_PREFIX
5225 #  define PERL_SCAN_DISALLOW_PREFIX      0x02
5226 #endif
5227
5228 #ifndef grok_numeric_radix
5229 #if defined(NEED_grok_numeric_radix)
5230 static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5231 static
5232 #else
5233 extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
5234 #endif
5235
5236 #ifdef grok_numeric_radix
5237 #  undef grok_numeric_radix
5238 #endif
5239 #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
5240 #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
5241
5242 #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
5243 bool
5244 DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
5245 {
5246 #ifdef USE_LOCALE_NUMERIC
5247 #ifdef PL_numeric_radix_sv
5248     if (PL_numeric_radix_sv && IN_LOCALE) { 
5249         STRLEN len;
5250         char* radix = SvPV(PL_numeric_radix_sv, len);
5251         if (*sp + len <= send && memEQ(*sp, radix, len)) {
5252             *sp += len;
5253             return TRUE; 
5254         }
5255     }
5256 #else
5257     /* older perls don't have PL_numeric_radix_sv so the radix
5258      * must manually be requested from locale.h
5259      */
5260 #include <locale.h>
5261     dTHR;  /* needed for older threaded perls */
5262     struct lconv *lc = localeconv();
5263     char *radix = lc->decimal_point;
5264     if (radix && IN_LOCALE) { 
5265         STRLEN len = strlen(radix);
5266         if (*sp + len <= send && memEQ(*sp, radix, len)) {
5267             *sp += len;
5268             return TRUE; 
5269         }
5270     }
5271 #endif /* PERL_VERSION */
5272 #endif /* USE_LOCALE_NUMERIC */
5273     /* always try "." if numeric radix didn't match because
5274      * we may have data from different locales mixed */
5275     if (*sp < send && **sp == '.') {
5276         ++*sp;
5277         return TRUE;
5278     }
5279     return FALSE;
5280 }
5281 #endif
5282 #endif
5283
5284 /* grok_number depends on grok_numeric_radix */
5285
5286 #ifndef grok_number
5287 #if defined(NEED_grok_number)
5288 static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5289 static
5290 #else
5291 extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
5292 #endif
5293
5294 #ifdef grok_number
5295 #  undef grok_number
5296 #endif
5297 #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
5298 #define Perl_grok_number DPPP_(my_grok_number)
5299
5300 #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
5301 int
5302 DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
5303 {
5304   const char *s = pv;
5305   const char *send = pv + len;
5306   const UV max_div_10 = UV_MAX / 10;
5307   const char max_mod_10 = UV_MAX % 10;
5308   int numtype = 0;
5309   int sawinf = 0;
5310   int sawnan = 0;
5311
5312   while (s < send && isSPACE(*s))
5313     s++;
5314   if (s == send) {
5315     return 0;
5316   } else if (*s == '-') {
5317     s++;
5318     numtype = IS_NUMBER_NEG;
5319   }
5320   else if (*s == '+')
5321   s++;
5322
5323   if (s == send)
5324     return 0;
5325
5326   /* next must be digit or the radix separator or beginning of infinity */
5327   if (isDIGIT(*s)) {
5328     /* UVs are at least 32 bits, so the first 9 decimal digits cannot
5329        overflow.  */
5330     UV value = *s - '0';
5331     /* This construction seems to be more optimiser friendly.
5332        (without it gcc does the isDIGIT test and the *s - '0' separately)
5333        With it gcc on arm is managing 6 instructions (6 cycles) per digit.
5334        In theory the optimiser could deduce how far to unroll the loop
5335        before checking for overflow.  */
5336     if (++s < send) {
5337       int digit = *s - '0';
5338       if (digit >= 0 && digit <= 9) {
5339         value = value * 10 + digit;
5340         if (++s < send) {
5341           digit = *s - '0';
5342           if (digit >= 0 && digit <= 9) {
5343             value = value * 10 + digit;
5344             if (++s < send) {
5345               digit = *s - '0';
5346               if (digit >= 0 && digit <= 9) {
5347                 value = value * 10 + digit;
5348                 if (++s < send) {
5349                   digit = *s - '0';
5350                   if (digit >= 0 && digit <= 9) {
5351                     value = value * 10 + digit;
5352                     if (++s < send) {
5353                       digit = *s - '0';
5354                       if (digit >= 0 && digit <= 9) {
5355                         value = value * 10 + digit;
5356                         if (++s < send) {
5357                           digit = *s - '0';
5358                           if (digit >= 0 && digit <= 9) {
5359                             value = value * 10 + digit;
5360                             if (++s < send) {
5361                               digit = *s - '0';
5362                               if (digit >= 0 && digit <= 9) {
5363                                 value = value * 10 + digit;
5364                                 if (++s < send) {
5365                                   digit = *s - '0';
5366                                   if (digit >= 0 && digit <= 9) {
5367                                     value = value * 10 + digit;
5368                                     if (++s < send) {
5369                                       /* Now got 9 digits, so need to check
5370                                          each time for overflow.  */
5371                                       digit = *s - '0';
5372                                       while (digit >= 0 && digit <= 9
5373                                              && (value < max_div_10
5374                                                  || (value == max_div_10
5375                                                      && digit <= max_mod_10))) {
5376                                         value = value * 10 + digit;
5377                                         if (++s < send)
5378                                           digit = *s - '0';
5379                                         else
5380                                           break;
5381                                       }
5382                                       if (digit >= 0 && digit <= 9
5383                                           && (s < send)) {
5384                                         /* value overflowed.
5385                                            skip the remaining digits, don't
5386                                            worry about setting *valuep.  */
5387                                         do {
5388                                           s++;
5389                                         } while (s < send && isDIGIT(*s));
5390                                         numtype |=
5391                                           IS_NUMBER_GREATER_THAN_UV_MAX;
5392                                         goto skip_value;
5393                                       }
5394                                     }
5395                                   }
5396                                 }
5397                               }
5398                             }
5399                           }
5400                         }
5401                       }
5402                     }
5403                   }
5404                 }
5405               }
5406             }
5407           }
5408         }
5409       }
5410     }
5411     numtype |= IS_NUMBER_IN_UV;
5412     if (valuep)
5413       *valuep = value;
5414
5415   skip_value:
5416     if (GROK_NUMERIC_RADIX(&s, send)) {
5417       numtype |= IS_NUMBER_NOT_INT;
5418       while (s < send && isDIGIT(*s))  /* optional digits after the radix */
5419         s++;
5420     }
5421   }
5422   else if (GROK_NUMERIC_RADIX(&s, send)) {
5423     numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
5424     /* no digits before the radix means we need digits after it */
5425     if (s < send && isDIGIT(*s)) {
5426       do {
5427         s++;
5428       } while (s < send && isDIGIT(*s));
5429       if (valuep) {
5430         /* integer approximation is valid - it's 0.  */
5431         *valuep = 0;
5432       }
5433     }
5434     else
5435       return 0;
5436   } else if (*s == 'I' || *s == 'i') {
5437     s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5438     s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
5439     s++; if (s < send && (*s == 'I' || *s == 'i')) {
5440       s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5441       s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
5442       s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
5443       s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
5444       s++;
5445     }
5446     sawinf = 1;
5447   } else if (*s == 'N' || *s == 'n') {
5448     /* XXX TODO: There are signaling NaNs and quiet NaNs. */
5449     s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
5450     s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
5451     s++;
5452     sawnan = 1;
5453   } else
5454     return 0;
5455
5456   if (sawinf) {
5457     numtype &= IS_NUMBER_NEG; /* Keep track of sign  */
5458     numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
5459   } else if (sawnan) {
5460     numtype &= IS_NUMBER_NEG; /* Keep track of sign  */
5461     numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
5462   } else if (s < send) {
5463     /* we can have an optional exponent part */
5464     if (*s == 'e' || *s == 'E') {
5465       /* The only flag we keep is sign.  Blow away any "it's UV"  */
5466       numtype &= IS_NUMBER_NEG;
5467       numtype |= IS_NUMBER_NOT_INT;
5468       s++;
5469       if (s < send && (*s == '-' || *s == '+'))
5470         s++;
5471       if (s < send && isDIGIT(*s)) {
5472         do {
5473           s++;
5474         } while (s < send && isDIGIT(*s));
5475       }
5476       else
5477       return 0;
5478     }
5479   }
5480   while (s < send && isSPACE(*s))
5481     s++;
5482   if (s >= send)
5483     return numtype;
5484   if (len == 10 && memEQ(pv, "0 but true", 10)) {
5485     if (valuep)
5486       *valuep = 0;
5487     return IS_NUMBER_IN_UV;
5488   }
5489   return 0;
5490 }
5491 #endif
5492 #endif
5493
5494 /*
5495  * The grok_* routines have been modified to use warn() instead of
5496  * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
5497  * which is why the stack variable has been renamed to 'xdigit'.
5498  */
5499
5500 #ifndef grok_bin
5501 #if defined(NEED_grok_bin)
5502 static UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5503 static
5504 #else
5505 extern UV DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5506 #endif
5507
5508 #ifdef grok_bin
5509 #  undef grok_bin
5510 #endif
5511 #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
5512 #define Perl_grok_bin DPPP_(my_grok_bin)
5513
5514 #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
5515 UV
5516 DPPP_(my_grok_bin)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5517 {
5518     const char *s = start;
5519     STRLEN len = *len_p;
5520     UV value = 0;
5521     NV value_nv = 0;
5522
5523     const UV max_div_2 = UV_MAX / 2;
5524     bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5525     bool overflowed = FALSE;
5526
5527     if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5528         /* strip off leading b or 0b.
5529            for compatibility silently suffer "b" and "0b" as valid binary
5530            numbers. */
5531         if (len >= 1) {
5532             if (s[0] == 'b') {
5533                 s++;
5534                 len--;
5535             }
5536             else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
5537                 s+=2;
5538                 len-=2;
5539             }
5540         }
5541     }
5542
5543     for (; len-- && *s; s++) {
5544         char bit = *s;
5545         if (bit == '0' || bit == '1') {
5546             /* Write it in this wonky order with a goto to attempt to get the
5547                compiler to make the common case integer-only loop pretty tight.
5548                With gcc seems to be much straighter code than old scan_bin.  */
5549           redo:
5550             if (!overflowed) {
5551                 if (value <= max_div_2) {
5552                     value = (value << 1) | (bit - '0');
5553                     continue;
5554                 }
5555                 /* Bah. We're just overflowed.  */
5556                 warn("Integer overflow in binary number");
5557                 overflowed = TRUE;
5558                 value_nv = (NV) value;
5559             }
5560             value_nv *= 2.0;
5561             /* If an NV has not enough bits in its mantissa to
5562              * represent a UV this summing of small low-order numbers
5563              * is a waste of time (because the NV cannot preserve
5564              * the low-order bits anyway): we could just remember when
5565              * did we overflow and in the end just multiply value_nv by the
5566              * right amount. */
5567             value_nv += (NV)(bit - '0');
5568             continue;
5569         }
5570         if (bit == '_' && len && allow_underscores && (bit = s[1])
5571             && (bit == '0' || bit == '1'))
5572             {
5573                 --len;
5574                 ++s;
5575                 goto redo;
5576             }
5577         if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5578             warn("Illegal binary digit '%c' ignored", *s);
5579         break;
5580     }
5581     
5582     if (   ( overflowed && value_nv > 4294967295.0)
5583 #if UVSIZE > 4
5584         || (!overflowed && value > 0xffffffff  )
5585 #endif
5586         ) {
5587         warn("Binary number > 0b11111111111111111111111111111111 non-portable");
5588     }
5589     *len_p = s - start;
5590     if (!overflowed) {
5591         *flags = 0;
5592         return value;
5593     }
5594     *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5595     if (result)
5596         *result = value_nv;
5597     return UV_MAX;
5598 }
5599 #endif
5600 #endif
5601
5602 #ifndef grok_hex
5603 #if defined(NEED_grok_hex)
5604 static UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5605 static
5606 #else
5607 extern UV DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5608 #endif
5609
5610 #ifdef grok_hex
5611 #  undef grok_hex
5612 #endif
5613 #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
5614 #define Perl_grok_hex DPPP_(my_grok_hex)
5615
5616 #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
5617 UV
5618 DPPP_(my_grok_hex)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5619 {
5620     const char *s = start;
5621     STRLEN len = *len_p;
5622     UV value = 0;
5623     NV value_nv = 0;
5624
5625     const UV max_div_16 = UV_MAX / 16;
5626     bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5627     bool overflowed = FALSE;
5628     const char *xdigit;
5629
5630     if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
5631         /* strip off leading x or 0x.
5632            for compatibility silently suffer "x" and "0x" as valid hex numbers.
5633         */
5634         if (len >= 1) {
5635             if (s[0] == 'x') {
5636                 s++;
5637                 len--;
5638             }
5639             else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
5640                 s+=2;
5641                 len-=2;
5642             }
5643         }
5644     }
5645
5646     for (; len-- && *s; s++) {
5647         xdigit = strchr((char *) PL_hexdigit, *s);
5648         if (xdigit) {
5649             /* Write it in this wonky order with a goto to attempt to get the
5650                compiler to make the common case integer-only loop pretty tight.
5651                With gcc seems to be much straighter code than old scan_hex.  */
5652           redo:
5653             if (!overflowed) {
5654                 if (value <= max_div_16) {
5655                     value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
5656                     continue;
5657                 }
5658                 warn("Integer overflow in hexadecimal number");
5659                 overflowed = TRUE;
5660                 value_nv = (NV) value;
5661             }
5662             value_nv *= 16.0;
5663             /* If an NV has not enough bits in its mantissa to
5664              * represent a UV this summing of small low-order numbers
5665              * is a waste of time (because the NV cannot preserve
5666              * the low-order bits anyway): we could just remember when
5667              * did we overflow and in the end just multiply value_nv by the
5668              * right amount of 16-tuples. */
5669             value_nv += (NV)((xdigit - PL_hexdigit) & 15);
5670             continue;
5671         }
5672         if (*s == '_' && len && allow_underscores && s[1]
5673                 && (xdigit = strchr((char *) PL_hexdigit, s[1])))
5674             {
5675                 --len;
5676                 ++s;
5677                 goto redo;
5678             }
5679         if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5680             warn("Illegal hexadecimal digit '%c' ignored", *s);
5681         break;
5682     }
5683     
5684     if (   ( overflowed && value_nv > 4294967295.0)
5685 #if UVSIZE > 4
5686         || (!overflowed && value > 0xffffffff  )
5687 #endif
5688         ) {
5689         warn("Hexadecimal number > 0xffffffff non-portable");
5690     }
5691     *len_p = s - start;
5692     if (!overflowed) {
5693         *flags = 0;
5694         return value;
5695     }
5696     *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5697     if (result)
5698         *result = value_nv;
5699     return UV_MAX;
5700 }
5701 #endif
5702 #endif
5703
5704 #ifndef grok_oct
5705 #if defined(NEED_grok_oct)
5706 static UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5707 static
5708 #else
5709 extern UV DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result);
5710 #endif
5711
5712 #ifdef grok_oct
5713 #  undef grok_oct
5714 #endif
5715 #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
5716 #define Perl_grok_oct DPPP_(my_grok_oct)
5717
5718 #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
5719 UV
5720 DPPP_(my_grok_oct)(pTHX_ char *start, STRLEN *len_p, I32 *flags, NV *result)
5721 {
5722     const char *s = start;
5723     STRLEN len = *len_p;
5724     UV value = 0;
5725     NV value_nv = 0;
5726
5727     const UV max_div_8 = UV_MAX / 8;
5728     bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
5729     bool overflowed = FALSE;
5730
5731     for (; len-- && *s; s++) {
5732          /* gcc 2.95 optimiser not smart enough to figure that this subtraction
5733             out front allows slicker code.  */
5734         int digit = *s - '0';
5735         if (digit >= 0 && digit <= 7) {
5736             /* Write it in this wonky order with a goto to attempt to get the
5737                compiler to make the common case integer-only loop pretty tight.
5738             */
5739           redo:
5740             if (!overflowed) {
5741                 if (value <= max_div_8) {
5742                     value = (value << 3) | digit;
5743                     continue;
5744                 }
5745                 /* Bah. We're just overflowed.  */
5746                 warn("Integer overflow in octal number");
5747                 overflowed = TRUE;
5748                 value_nv = (NV) value;
5749             }
5750             value_nv *= 8.0;
5751             /* If an NV has not enough bits in its mantissa to
5752              * represent a UV this summing of small low-order numbers
5753              * is a waste of time (because the NV cannot preserve
5754              * the low-order bits anyway): we could just remember when
5755              * did we overflow and in the end just multiply value_nv by the
5756              * right amount of 8-tuples. */
5757             value_nv += (NV)digit;
5758             continue;
5759         }
5760         if (digit == ('_' - '0') && len && allow_underscores
5761             && (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
5762             {
5763                 --len;
5764                 ++s;
5765                 goto redo;
5766             }
5767         /* Allow \octal to work the DWIM way (that is, stop scanning
5768          * as soon as non-octal characters are seen, complain only iff
5769          * someone seems to want to use the digits eight and nine). */
5770         if (digit == 8 || digit == 9) {
5771             if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
5772                 warn("Illegal octal digit '%c' ignored", *s);
5773         }
5774         break;
5775     }
5776     
5777     if (   ( overflowed && value_nv > 4294967295.0)
5778 #if UVSIZE > 4
5779         || (!overflowed && value > 0xffffffff  )
5780 #endif
5781         ) {
5782         warn("Octal number > 037777777777 non-portable");
5783     }
5784     *len_p = s - start;
5785     if (!overflowed) {
5786         *flags = 0;
5787         return value;
5788     }
5789     *flags = PERL_SCAN_GREATER_THAN_UV_MAX;
5790     if (result)
5791         *result = value_nv;
5792     return UV_MAX;
5793 }
5794 #endif
5795 #endif
5796
5797 #ifdef NO_XSLOCKS
5798 #  ifdef dJMPENV
5799 #    define dXCPT             dJMPENV; int rEtV = 0
5800 #    define XCPT_TRY_START    JMPENV_PUSH(rEtV); if (rEtV == 0)
5801 #    define XCPT_TRY_END      JMPENV_POP;
5802 #    define XCPT_CATCH        if (rEtV != 0)
5803 #    define XCPT_RETHROW      JMPENV_JUMP(rEtV)
5804 #  else
5805 #    define dXCPT             Sigjmp_buf oldTOP; int rEtV = 0
5806 #    define XCPT_TRY_START    Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0)
5807 #    define XCPT_TRY_END      Copy(oldTOP, top_env, 1, Sigjmp_buf);
5808 #    define XCPT_CATCH        if (rEtV != 0)
5809 #    define XCPT_RETHROW      Siglongjmp(top_env, rEtV)
5810 #  endif
5811 #endif
5812
5813 #endif /* _P_P_PORTABILITY_H_ */
5814
5815 /* End of File ppport.h */