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