This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
makedef.pl: don't hard-code list of mathoms
authorAaron Crane <arc@cpan.org>
Sun, 7 Dec 2014 15:41:33 +0000 (15:41 +0000)
committerAaron Crane <arc@cpan.org>
Sun, 14 Dec 2014 15:04:38 +0000 (15:04 +0000)
It's easy enough to read the list out of mathoms.c directly, and this should
prevent almost all bugs of the sort that were fixed by
083750a56b7927292a4bf7b1bf64aa26dd2a6858. (Only names that don't begin with
"Perl_" will cause a problem.)

The list of names detected automatically may actually differ slightly from
the hard-coded list; for example, the definition of Perl_huge() is inside
"#if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))",
but the new code in makedef.pl ignores preprocessor conditions. However, the
list is used as names to *skip*, rather than to include, so it's not a
problem if makedef.pl is willing to skip names that it will never be asked
to include.

makedef.pl
mathoms.c

index 38a17f5..0bc3862 100644 (file)
@@ -422,157 +422,18 @@ unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
                         );
 }
 if ($define{'NO_MATHOMS'}) {
-    ++$skip{$_} foreach qw(
-                   ASCII_TO_NEED
-                   NATIVE_TO_NEED
-                   Perl_custom_op_desc
-                   Perl_custom_op_name
-                   Perl_do_aexec
-                   Perl_do_binmode
-                   Perl_do_open
-                   Perl_do_open9
-                   Perl_fprintf_nocontext
-                   Perl_gv_AVadd
-                   Perl_gv_HVadd
-                   Perl_gv_IOadd
-                   Perl_gv_SVadd
-                   Perl_gv_efullname
-                   Perl_gv_efullname3
-                   Perl_gv_fetchmethod
-                   Perl_gv_fullname
-                   Perl_gv_fullname3
-                   Perl_hv_delete
-                   Perl_hv_delete_ent
-                   Perl_hv_exists
-                   Perl_hv_exists_ent
-                   Perl_hv_fetch
-                   Perl_hv_fetch_ent
-                   Perl_hv_iternext
-                   Perl_hv_magic
-                   Perl_hv_store
-                   Perl_hv_store_ent
-                   Perl_hv_store_flags
-                   Perl_init_i18nl14n
-                   Perl_isALNUM_lazy
-                   Perl_isIDFIRST_lazy
-                   Perl_is_uni_alnum
-                   Perl_is_uni_alnum_lc
-                   Perl_is_uni_alnumc
-                   Perl_is_uni_alnumc_lc
-                   Perl_is_uni_alpha
-                   Perl_is_uni_alpha_lc
-                   Perl_is_uni_ascii
-                   Perl_is_uni_ascii_lc
-                   Perl_is_uni_blank
-                   Perl_is_uni_blank_lc
-                   Perl_is_uni_cntrl
-                   Perl_is_uni_cntrl_lc
-                   Perl_is_uni_digit
-                   Perl_is_uni_digit_lc
-                   Perl_is_uni_graph
-                   Perl_is_uni_graph_lc
-                   Perl_is_uni_idfirst
-                   Perl_is_uni_idfirst_lc
-                   Perl_is_uni_lower
-                   Perl_is_uni_lower_lc
-                   Perl_is_uni_print
-                   Perl_is_uni_print_lc
-                   Perl_is_uni_punct
-                   Perl_is_uni_punct_lc
-                   Perl_is_uni_space
-                   Perl_is_uni_space_lc
-                   Perl_is_uni_upper
-                   Perl_is_uni_upper_lc
-                   Perl_is_uni_xdigit
-                   Perl_is_uni_xdigit_lc
-                   Perl_is_utf8_alnum
-                   Perl_is_utf8_alnumc
-                   Perl_is_utf8_alpha
-                   Perl_is_utf8_ascii
-                   Perl_is_utf8_blank
-                   Perl_is_utf8_char
-                   Perl_is_utf8_cntrl
-                   Perl_is_utf8_digit
-                   Perl_is_utf8_graph
-                   Perl_is_utf8_idcont
-                   Perl_is_utf8_idfirst
-                   Perl_is_utf8_lower
-                   Perl_is_utf8_mark
-                   Perl_is_utf8_perl_space
-                   Perl_is_utf8_perl_word
-                   Perl_is_utf8_posix_digit
-                   Perl_is_utf8_print
-                   Perl_is_utf8_punct
-                   Perl_is_utf8_space
-                   Perl_is_utf8_string_loc
-                   Perl_is_utf8_upper
-                   Perl_is_utf8_xdigit
-                   Perl_is_utf8_xidcont
-                   Perl_is_utf8_xidfirst
-                   Perl_my_lstat
-                   Perl_my_stat
-                   Perl_newAV
-                   Perl_newHV
-                   Perl_newIO
-                   Perl_newSUB
-                   Perl_pack_cat
-                   Perl_pad_compname_type
-                   Perl_printf_nocontext
-                   Perl_ref
-                   Perl_save_freeop
-                   Perl_save_freepv
-                   Perl_save_freesv
-                   Perl_save_iv
-                   Perl_save_list
-                   Perl_save_long
-                   Perl_save_mortalizesv
-                   Perl_save_nogv
-                   Perl_save_op
-                   Perl_save_re_context
-                   Perl_sv_2iv
-                   Perl_sv_2pv
-                   Perl_sv_2pv_nolen
-                   Perl_sv_2pvbyte_nolen
-                   Perl_sv_2pvutf8_nolen
-                   Perl_sv_2uv
-                   Perl_sv_catpvn
-                   Perl_sv_catpvn_mg
-                   Perl_sv_catsv
-                   Perl_sv_catsv_mg
-                   Perl_sv_force_normal
-                   Perl_sv_insert
-                   Perl_sv_iv
-                   Perl_sv_mortalcopy
-                   Perl_sv_nolocking
-                   Perl_sv_nounlocking
-                   Perl_sv_nv
-                   Perl_sv_pv
-                   Perl_sv_pvbyte
-                   Perl_sv_pvbyten
-                   Perl_sv_pvn
-                   Perl_sv_pvn_force
-                   Perl_sv_pvn_nomg
-                   Perl_sv_pvutf8
-                   Perl_sv_pvutf8n
-                   Perl_sv_setsv
-                   Perl_sv_taint
-                   Perl_sv_unref
-                   Perl_sv_usepvn
-                   Perl_sv_usepvn_mg
-                   Perl_sv_utf8_upgrade
-                   Perl_sv_uv
-                   Perl_to_uni_lower_lc
-                   Perl_to_uni_title_lc
-                   Perl_to_uni_upper_lc
-                   Perl_to_utf8_fold
-                   Perl_to_utf8_lower
-                   Perl_to_utf8_title
-                   Perl_to_utf8_upper
-                   Perl_unpack_str
-                   Perl_utf8_to_uvchr
-                   Perl_utf8_to_uvuni
-                   Perl_valid_utf8_to_uvuni
-                        );
+    # win32 builds happen in the win32/ subdirectory, but vms builds happen
+    # at the top level, so we need to look in two candidate locations for
+    # the mathoms.c file.
+    my ($file) = grep { -f } qw( mathoms.c ../mathoms.c )
+        or die "No mathoms.c file found in . or ..\n";
+    open my $mathoms, '<', $file
+        or die "Cannot open $file: $!\n";
+    while (<$mathoms>) {
+        ++$skip{$1} if /\A ( NATIVE_TO_NEED
+                           | ASCII_TO_NEED
+                           | Perl_\w+ ) \s* \( /axms;
+    }
 }
 
 unless ($define{'PERL_NEED_APPCTX'}) {
index 5ee91d5..96b3ac3 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -24,7 +24,8 @@
  * versions of Perl.  For binary or source compatibility reasons, though,
  * we cannot completely remove them from the core code.  
  *
- * REMEMBER to update makedef.pl when adding a function to mathoms.c!!!
+ * REMEMBER to update makedef.pl when adding a function to mathoms.c whose
+ * name doesn't begin with "Perl_".
  *
  * SMP - Oct. 24, 2005
  *