1 # This script takes the output produced from perly.y by byacc and
2 # the perly.fixer shell script (i.e. the perly.c and perly.h built
3 # for Unix systems) and patches them to produce copies containing
4 # appropriate declarations for VMS handling of global symbols.
6 # If it finds that the input files are already patches for VMS,
7 # it just copies the input to the output.
9 # Revised 20-Dec-1996 by Charles Bailey bailey@genetics.upenn.edu
13 push(@ARGV,(qw[ perly.c perly.h vms/perly_c.vms vms/perly_h.vms])[@ARGV..4])
15 ($cinfile,$hinfile,$coutfile,$houtfile) = @ARGV;
17 open C,$cinfile or die "Can't read $cinfile: $!\n";
18 open COUT, ">$coutfile" or die "Can't create $coutfile: $!\n";
20 /* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
23 # "y.tab.c" is illegal as a VMS filename; DECC 5.2/VAX preprocessor
25 if ( s/^#line\s+(\d+)\s+"y.tab.c"/#line $1 "y_tab.c"/ ) { 1; }
26 elsif (/char \*getenv/) {
27 # accomodate old VAXC's macro susbstitution pecularities
28 $_ = "# ifndef getenv\n$_# endif\n";
31 # add the dEXT tag to definitions of global vars, so we'll insert
32 # a globaldef when perly.c is compiled
33 s/^(short|int|YYSTYPE|char \*)\s*yy/dEXT $1 yy/;
40 open H,$hinfile or die "Can't read $hinfile: $!\n";
41 open HOUT, ">$houtfile" or die "Can't create $houtfile: $!\n";
43 /* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
45 $hfixed = 0; # keep -w happy
47 $hfixed = /globalref/ unless $hfixed; # we've already got a fixed copy
48 next if /^extern YYSTYPE yylval/; # we've got a Unix version, and this
49 # is what we want to replace
54 print HOUT <<'EODECL' unless $hfixed;
56 extern YYSTYPE yylval;
58 globalref YYSTYPE yylval;