source: trunk/third/perl/vms/vms_yfix.pl @ 14545

Revision 14545, 2.1 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14544, which included commits to RCS files with non-trunk default branches.
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    # Reset the "error" status if an optional lookup fails
32    while (not /^\s+\}/) { print COUT; $_ = <C>; }
33    $_ .= "\telse SETERRNO(0,SS\$_NORMAL);\n";
34  }
35  else {
36    # add the dEXT tag to definitions of global vars, so we'll insert
37    # a globaldef when perly.c is compiled
38    s/^(short|int|YYSTYPE|char \*)\s*yy/dEXT $1 yy/;
39  }
40  print COUT;
41}
42close C;
43close COUT;
44
45open H,$hinfile  or die "Can't read $hinfile: $!\n";
46open HOUT, ">$houtfile" or die "Can't create $houtfile: $!\n";
47print HOUT <<EOH;
48/* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
49EOH
50$hfixed = 0;  # keep -w happy
51while (<H>) {
52  $hfixed = /globalref/ unless $hfixed;  # we've already got a fixed copy
53  next if /^extern YYSTYPE yylval/;  # we've got a Unix version, and this
54                                     # is what we want to replace
55  print HOUT;
56}
57close H;
58
59print HOUT <<'EODECL' unless $hfixed;
60#ifndef vax11c
61  extern YYSTYPE yylval;
62#else
63  globalref YYSTYPE yylval;
64#endif
65EODECL
66
67close HOUT;
Note: See TracBrowser for help on using the repository browser.