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