This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make the VERSION of File::Spec be 0.86, otherwise File::Temp's
[perl5.git] / vms / vms_yfix.pl
CommitLineData
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#
bd3fa61c 9# Revised 20-Dec-1996 by Charles Bailey bailey@newman.upenn.edu
c07a80fd 10
71be2cbc 11$VERSION = '1.11';
4633a7c4 12
71be2cbc 13push(@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
17open C,$cinfile or die "Can't read $cinfile: $!\n";
18open COUT, ">$coutfile" or die "Can't create $coutfile: $!\n";
c07a80fd 19print COUT <<EOH;
20/* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
21EOH
4633a7c4 22while (<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; }
9607fc9c 26 elsif (/char \*getenv/) {
27 # accomodate old VAXC's macro susbstitution pecularities
28 $_ = "# ifndef getenv\n$_# endif\n";
29 }
61bb5906 30 elsif ( /getenv\("YYDEBUG"\)/ ) {
2ac72d6e
CB
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" . $_;
61bb5906
CB
34 # Reset the "error" status if an optional lookup fails
35 while (not /^\s+\}/) { print COUT; $_ = <C>; }
2ac72d6e 36 $_ .= " else SETERRNO(saved_errno,saved_vaxc_errno);\n }\n";
61bb5906 37 }
c07a80fd 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/;
4633a7c4 42 }
4633a7c4
LW
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";
c07a80fd 50print HOUT <<EOH;
51/* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
52EOH
4633a7c4
LW
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;