Commit | Line | Data |
---|---|---|
4633a7c4 LW |
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. | |
5 | # | |
6 | # If it finds that the input files are already patches for VMS, | |
7 | # it just copies the input to the output. | |
8 | # | |
71be2cbc | 9 | # Revised 20-Dec-1996 by Charles Bailey bailey@genetics.upenn.edu |
c07a80fd | 10 | |
71be2cbc | 11 | $VERSION = '1.11'; |
4633a7c4 | 12 | |
71be2cbc | 13 | push(@ARGV,(qw[ perly.c perly.h vms/perly_c.vms vms/perly_h.vms])[@ARGV..4]) |
14 | if @ARGV < 4; | |
4633a7c4 LW |
15 | ($cinfile,$hinfile,$coutfile,$houtfile) = @ARGV; |
16 | ||
17 | open C,$cinfile or die "Can't read $cinfile: $!\n"; | |
18 | open COUT, ">$coutfile" or die "Can't create $coutfile: $!\n"; | |
c07a80fd | 19 | print COUT <<EOH; |
20 | /* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */ | |
21 | EOH | |
4633a7c4 | 22 | while (<C>) { |
c07a80fd | 23 | # "y.tab.c" is illegal as a VMS filename; DECC 5.2/VAX preprocessor |
24 | # doesn't like this. | |
25 | if ( s/^#line\s+(\d+)\s+"y.tab.c"/#line $1 "y_tab.c"/ ) { 1; } | |
26 | else { | |
27 | # add the dEXT tag to definitions of global vars, so we'll insert | |
28 | # a globaldef when perly.c is compiled | |
29 | s/^(short|int|YYSTYPE|char \*)\s*yy/dEXT $1 yy/; | |
4633a7c4 | 30 | } |
4633a7c4 LW |
31 | print COUT; |
32 | } | |
33 | close C; | |
34 | close COUT; | |
35 | ||
36 | open H,$hinfile or die "Can't read $hinfile: $!\n"; | |
37 | open HOUT, ">$houtfile" or die "Can't create $houtfile: $!\n"; | |
c07a80fd | 38 | print HOUT <<EOH; |
39 | /* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */ | |
40 | EOH | |
4633a7c4 LW |
41 | $hfixed = 0; # keep -w happy |
42 | while (<H>) { | |
43 | $hfixed = /globalref/ unless $hfixed; # we've already got a fixed copy | |
44 | next if /^extern YYSTYPE yylval/; # we've got a Unix version, and this | |
45 | # is what we want to replace | |
46 | print HOUT; | |
47 | } | |
48 | close H; | |
49 | ||
50 | print HOUT <<'EODECL' unless $hfixed; | |
51 | #ifndef vax11c | |
52 | extern YYSTYPE yylval; | |
53 | #else | |
54 | globalref YYSTYPE yylval; | |
55 | #endif | |
56 | EODECL | |
57 | ||
58 | close HOUT; |