diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-10-16 16:02:35 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-10-16 16:02:35 +0000 |
commit | 8261f8eb698db59828f3e3dd7a1ee82976ab259e (patch) | |
tree | 3ea5346f672c31284bdb8657b4e964ff2a29eb4b /overload.pl | |
parent | 20773dcda05c239bb7300f7eed1a0ff4ef022a0a (diff) | |
download | perl-8261f8eb698db59828f3e3dd7a1ee82976ab259e.tar.gz |
PL_AMG_names is only used by gv.c (as far as Google code search can
see), so it can easily be a static variable inside gv.c. This allows
the implementation to be changed in future Perls within the 5.10.x
series.
p4raw-id: //depot/perl@32116
Diffstat (limited to 'overload.pl')
-rw-r--r-- | overload.pl | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/overload.pl b/overload.pl index 295c837102..9def29f429 100644 --- a/overload.pl +++ b/overload.pl @@ -21,14 +21,18 @@ while (<DATA>) { push @names, $name; } -safer_unlink 'overload.h'; +safer_unlink ('overload.h', 'overload.c'); +die "overload.h: $!" unless open(C, ">overload.c"); +binmode C; die "overload.h: $!" unless open(H, ">overload.h"); binmode H; -select H; -print <<'EOF'; + +sub print_header { + my $file = shift; + print <<"EOF"; /* -*- buffer-read-only: t -*- * - * overload.h + * $file * * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall * and others @@ -39,6 +43,15 @@ print <<'EOF'; * !!!!!!! DO NOT EDIT THIS FILE !!!!!!! * This file is built by overload.pl */ +EOF +} + +select C; +print_header('overload.c'); + +select H; +print_header('overload.h'); +print <<'EOF'; enum { EOF @@ -50,12 +63,15 @@ print <<'EOF'; /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */ }; - #define NofAMmeth max_amg_code + +EOF + +print C <<'EOF'; + #define AMG_id2name(id) (PL_AMG_names[id]+1) -#ifdef DOINIT -EXTCONST char * const PL_AMG_names[NofAMmeth] = { +char * const PL_AMG_names[NofAMmeth] = { /* Names kept in the symbol table. fallback => "()", the rest has "(" prepended. The only other place in perl which knows about this convention is AMG_id2name (used for debugging output and @@ -64,14 +80,11 @@ EXTCONST char * const PL_AMG_names[NofAMmeth] = { EOF my $last = pop @names; -print " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names; +print C " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names; -print <<"EOT"; +print C <<"EOT"; "$last" }; -#else -EXTCONST char * PL_AMG_names[NofAMmeth]; -#endif /* def INITAMAGIC */ EOT close H or die $!; |