source: vendor/perl/5.8.8/vms/vms_yfix.pl

Last change on this file was 3181, checked in by bird, 18 years ago

perl 5.8.8

File size: 2.4 KB
Line 
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#
9# Revised 20-Dec-1996 by Charles Bailey bailey@newman.upenn.edu
10
11$VERSION = '1.11';
12
13push(@ARGV,(qw[ perly.c perly.h vms/perly_c.vms vms/perly_h.vms])[@ARGV..4])
14 if @ARGV < 4;
15($cinfile,$hinfile,$coutfile,$houtfile) = @ARGV;
16
17open C,$cinfile or die "Can't read $cinfile: $!\n";
18open COUT, ">$coutfile" or die "Can't create $coutfile: $!\n";
19print COUT <<EOH;
20/* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
21EOH
22while (<C>) {
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 elsif (/char \*getenv/) {
27 # accomodate old VAXC's macro susbstitution pecularities
28 $_ = "# ifndef getenv\n$_# endif\n";
29 }
30 elsif ( /getenv\("YYDEBUG"\)/ ) {
31 $_ = " {\n register int saved_errno = errno;\n"
32 . "#ifdef VMS\n register int saved_vaxc_errno = vaxc\$errno;\n"
33 . "#else\n register int saved_vaxc_errno = 0;\n#endif\n" . $_;
34 # Reset the "error" status if an optional lookup fails
35 while (not /^\s+\}/) { print COUT; $_ = <C>; }
36 $_ .= " else SETERRNO(saved_errno,saved_vaxc_errno);\n }\n";
37 }
38 else {
39 # add the dEXT tag to definitions of global vars, so we'll insert
40 # a globaldef when perly.c is compiled
41 s/^(short|int|YYSTYPE|char \*)\s*yy/dEXT $1 yy/;
42 }
43 print COUT;
44}
45close C;
46close COUT;
47
48open H,$hinfile or die "Can't read $hinfile: $!\n";
49open HOUT, ">$houtfile" or die "Can't create $houtfile: $!\n";
50print HOUT <<EOH;
51/* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
52EOH
53$hfixed = 0; # keep -w happy
54while (<H>) {
55 $hfixed = /globalref/ unless $hfixed; # we've already got a fixed copy
56 next if /^extern YYSTYPE yylval/; # we've got a Unix version, and this
57 # is what we want to replace
58 print HOUT;
59}
60close H;
61
62print HOUT <<'EODECL' unless $hfixed;
63#ifndef vax11c
64 extern YYSTYPE yylval;
65#else
66 globalref YYSTYPE yylval;
67#endif
68EODECL
69
70close HOUT;
Note: See TracBrowser for help on using the repository browser.