fmt_latex2e.pl: Make all filehandles indirect and uppercase.

parent cf583bf3
......@@ -121,7 +121,7 @@ $latex2e->{preASP} = sub {
# ------------------------------------------------------------------
# Translate character entities and escape LaTeX special chars.
# ------------------------------------------------------------------
my ($infile, $outfile) = @_;
my ($INFILE, $OUTFILE) = @_;
# note the conversion of `sdata_dirs' list to an anonymous array to
# make a single argument
......@@ -143,7 +143,7 @@ $latex2e->{preASP} = sub {
# on whether we're in a HEADING or ABSTRACT environment or not
$remove_comment = 0;
while (<$infile>) {
while (<$INFILE>) {
if ( s/^-// ){
chomp;
s/^\\n/ /; # Remove spurious leading \n (not real \\n)
......@@ -151,7 +151,7 @@ $latex2e->{preASP} = sub {
if ($remove_comment){
s/(\s+\\n)+//;
}
print $outfile "-" . $_ . "\n";
print $OUTFILE "-" . $_ . "\n";
} elsif (/^A/) {
/^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/
|| die "bad attribute data: $_\n";
......@@ -172,28 +172,28 @@ $latex2e->{preASP} = sub {
$value = parse_data ($value, $char_maps, $latex2e_escape);
}
}
print $outfile "A$name $type $value\n";
print $OUTFILE "A$name $type $value\n";
} elsif (/^\((VERB|CODE)/) {
print $outfile $_;
print $OUTFILE $_;
# going into VERB/CODE section
$in_verb = 1;
$char_maps = $ascii_char_maps;
} elsif (/^\)(VERB|CODE)/) {
print $outfile $_;
print $OUTFILE $_;
# leaving VERB/CODE section
$in_verb = 0;
$char_maps = $tex_char_maps;
} elsif (/^\((HEADING|ABSTRACT)/) {
print $outfile $_;
print $OUTFILE $_;
# empty lines (comment in sgml source) do harm
# in HEADING or ABSTRACT
$remove_comment = 1;
} elsif (/^\)(HEADING|ABSTRACT)/) {
print $outfile $_;
print $OUTFILE $_;
# leaving HEADING or ABSTRACT section
$remove_comment = 0;
} else {
print $outfile $_;
print $OUTFILE $_;
}
}
};
......@@ -224,7 +224,9 @@ $latex2e->{postASP} = sub
# Take the sgmlsasp output, and make something useful from it.
# ------------------------------------------------------------------
{
my $infile = shift;
my $INFILE = shift;
my $OUTFILE;
my $SGMLFILE;
my $filename = $global->{filename};
my $tmplatexdir = $global->{tmpbase} . "-latex-" . $$ . ".dir";
my $tmplatexnam = $tmplatexdir . "/" . $filename;
......@@ -239,7 +241,8 @@ $latex2e->{postASP} = sub
$ENV{TEXINPUTS} .= ":$main::DataDir";
umask 0077;
mkdir ($tmplatexdir, 0700) || return -1;
mkdir ($tmplatexdir, 0700)
or die "Could not create \"$tmplatexdir\" directory.\n";
#
# check epsfile is specified in source file
......@@ -247,8 +250,8 @@ $latex2e->{postASP} = sub
#
{
my $epsf;
open SGMLFILE, "<$filename.sgml";
while (<SGMLFILE>)
open $SGMLFILE, "<$filename.sgml";
while (<$SGMLFILE>)
{
# for epsfile
if ( s/^\s*<eps\s+file=(.*)>/$1/ )
......@@ -271,13 +274,13 @@ $latex2e->{postASP} = sub
}
}
}
close SGMLFILE;
close $SGMLFILE;
}
{
my $urlid;
my $urlnam;
my $urldef;
while (<$infile>)
while (<$INFILE>)
{
push @texlines, $_;
# for nameurl
......@@ -293,10 +296,11 @@ $latex2e->{postASP} = sub
$urlnum++;
}
}
close $infile;
close $INFILE;
}
open OUTFILE, ">$tmplatexnam.tex";
open ($OUTFILE, "> $tmplatexnam.tex")
or die "fmt_latex2e::postASP: Could not open \"$tmplatexnam.tex\" for write.\n";
# --------------------------------------------------------------------
# Set the correct \documentclass and packages options.
......@@ -317,6 +321,7 @@ $latex2e->{postASP} = sub
$classprefix = "j-";
}
}
# Getting class options
my $classoptions = $global->{papersize} . 'paper';
......@@ -382,19 +387,19 @@ $latex2e->{postASP} = sub
if (/\\nameurl/ && $latex2e->{output} ne "pdf") {
$_ = shift @urlnames;
}
print OUTFILE;
print $OUTFILE $_;
if (/%end-preamble/) {
if ($urlnum && $latex2e->{output} ne "pdf") {
while (defined($urldefines[0])) {
$_ = shift @urldefines;
print OUTFILE;
print $OUTFILE $_;
}
}
}
}
}
close OUTFILE;
close $OUTFILE;
#
# LaTeX, dvips, and assorted cleanups.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment