| 1 | #!/usr/bin/perl -w
|
|---|
| 2 |
|
|---|
| 3 | require 5.003; # keep this compatible, an old perl is all we may have before
|
|---|
| 4 | # we build the new one
|
|---|
| 5 |
|
|---|
| 6 | BEGIN {
|
|---|
| 7 | # Get function prototypes
|
|---|
| 8 | require 'regen_lib.pl';
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | #
|
|---|
| 12 | # See database of global and static function prototypes in embed.fnc
|
|---|
| 13 | # This is used to generate prototype headers under various configurations,
|
|---|
| 14 | # export symbols lists for different platforms, and macros to provide an
|
|---|
| 15 | # implicit interpreter context argument.
|
|---|
| 16 | #
|
|---|
| 17 |
|
|---|
| 18 | sub do_not_edit ($)
|
|---|
| 19 | {
|
|---|
| 20 | my $file = shift;
|
|---|
| 21 |
|
|---|
| 22 | my $years = '1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006';
|
|---|
| 23 |
|
|---|
| 24 | $years =~ s/1999,/1999,\n / if length $years > 40;
|
|---|
| 25 |
|
|---|
| 26 | my $warning = <<EOW;
|
|---|
| 27 | -*- buffer-read-only: t -*-
|
|---|
| 28 |
|
|---|
| 29 | $file
|
|---|
| 30 |
|
|---|
| 31 | Copyright (C) $years, by Larry Wall and others
|
|---|
| 32 |
|
|---|
| 33 | You may distribute under the terms of either the GNU General Public
|
|---|
| 34 | License or the Artistic License, as specified in the README file.
|
|---|
| 35 |
|
|---|
| 36 | !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
|
|---|
| 37 | This file is built by embed.pl from data in embed.fnc, embed.pl,
|
|---|
| 38 | pp.sym, intrpvar.h, perlvars.h and thrdvar.h.
|
|---|
| 39 | Any changes made here will be lost!
|
|---|
| 40 |
|
|---|
| 41 | Edit those files and run 'make regen_headers' to effect changes.
|
|---|
| 42 |
|
|---|
| 43 | EOW
|
|---|
| 44 |
|
|---|
| 45 | $warning .= <<EOW if $file eq 'perlapi.c';
|
|---|
| 46 |
|
|---|
| 47 | Up to the threshold of the door there mounted a flight of twenty-seven
|
|---|
| 48 | broad stairs, hewn by some unknown art of the same black stone. This
|
|---|
| 49 | was the only entrance to the tower.
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | EOW
|
|---|
| 53 |
|
|---|
| 54 | if ($file =~ m:\.[ch]$:) {
|
|---|
| 55 | $warning =~ s:^: * :gm;
|
|---|
| 56 | $warning =~ s: +$::gm;
|
|---|
| 57 | $warning =~ s: :/:;
|
|---|
| 58 | $warning =~ s:$:/:;
|
|---|
| 59 | }
|
|---|
| 60 | else {
|
|---|
| 61 | $warning =~ s:^:# :gm;
|
|---|
| 62 | $warning =~ s: +$::gm;
|
|---|
| 63 | }
|
|---|
| 64 | $warning;
|
|---|
| 65 | } # do_not_edit
|
|---|
| 66 |
|
|---|
| 67 | open IN, "embed.fnc" or die $!;
|
|---|
| 68 |
|
|---|
| 69 | # walk table providing an array of components in each line to
|
|---|
| 70 | # subroutine, printing the result
|
|---|
| 71 | sub walk_table (&@) {
|
|---|
| 72 | my $function = shift;
|
|---|
| 73 | my $filename = shift || '-';
|
|---|
| 74 | my $leader = shift;
|
|---|
| 75 | defined $leader or $leader = do_not_edit ($filename);
|
|---|
| 76 | my $trailer = shift;
|
|---|
| 77 | my $F;
|
|---|
| 78 | local *F;
|
|---|
| 79 | if (ref $filename) { # filehandle
|
|---|
| 80 | $F = $filename;
|
|---|
| 81 | }
|
|---|
| 82 | else {
|
|---|
| 83 | safer_unlink $filename if $filename ne '/dev/null';
|
|---|
| 84 | open F, ">$filename" or die "Can't open $filename: $!";
|
|---|
| 85 | binmode F;
|
|---|
| 86 | $F = \*F;
|
|---|
| 87 | }
|
|---|
| 88 | print $F $leader if $leader;
|
|---|
| 89 | seek IN, 0, 0; # so we may restart
|
|---|
| 90 | while (<IN>) {
|
|---|
| 91 | chomp;
|
|---|
| 92 | next if /^:/;
|
|---|
| 93 | while (s|\\$||) {
|
|---|
| 94 | $_ .= <IN>;
|
|---|
| 95 | chomp;
|
|---|
| 96 | }
|
|---|
| 97 | s/\s+$//;
|
|---|
| 98 | my @args;
|
|---|
| 99 | if (/^\s*(#|$)/) {
|
|---|
| 100 | @args = $_;
|
|---|
| 101 | }
|
|---|
| 102 | else {
|
|---|
| 103 | @args = split /\s*\|\s*/, $_;
|
|---|
| 104 | }
|
|---|
| 105 | my @outs = &{$function}(@args);
|
|---|
| 106 | print $F @outs; # $function->(@args) is not 5.003
|
|---|
| 107 | }
|
|---|
| 108 | print $F $trailer if $trailer;
|
|---|
| 109 | unless (ref $filename) {
|
|---|
| 110 | close $F or die "Error closing $filename: $!";
|
|---|
| 111 | }
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | sub munge_c_files () {
|
|---|
| 115 | my $functions = {};
|
|---|
| 116 | unless (@ARGV) {
|
|---|
| 117 | warn "\@ARGV empty, nothing to do\n";
|
|---|
| 118 | return;
|
|---|
| 119 | }
|
|---|
| 120 | walk_table {
|
|---|
| 121 | if (@_ > 1) {
|
|---|
| 122 | $functions->{$_[2]} = \@_ if $_[@_-1] =~ /\.\.\./;
|
|---|
| 123 | }
|
|---|
| 124 | } '/dev/null', '', '';
|
|---|
| 125 | local $^I = '.bak';
|
|---|
| 126 | while (<>) {
|
|---|
| 127 | # if (/^#\s*include\s+"perl.h"/) {
|
|---|
| 128 | # my $file = uc $ARGV;
|
|---|
|
|---|