summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-10-01 13:36:29 +0000
committerKarl Berry <karl@freefriends.org>2007-10-01 13:36:29 +0000
commitd4e31287b5927fa1b910e3142a9036526a895e85 (patch)
tree74877862dd95a14c4df3845fa82f7c401b7aed25 /Build/source
parent8e3b6f29cc4cf9ed00b93a9458b7bf277883a451 (diff)
perltex update (30sep07)
git-svn-id: svn://tug.org/texlive/trunk@5079 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/texlive/perltex65
1 files changed, 64 insertions, 1 deletions
diff --git a/Build/source/texk/texlive/perltex b/Build/source/texk/texlive/perltex
index f5bc0d1a186..2cd326f5f57 100644
--- a/Build/source/texk/texlive/perltex
+++ b/Build/source/texk/texlive/perltex
@@ -52,6 +52,8 @@ my $toflag;
my $fromflag;
my $doneflag;
my $logfile;
+my $styfile;
+my @macroexpansions;
my $sandbox = new Safe;
my $sandbox_eval;
my $latexpid;
@@ -60,6 +62,7 @@ Getopt::Long::Configure("require_order", "pass_through");
GetOptions("help" => sub {pod2usage(-verbose => 1)},
"latex=s" => \$latexprog,
"safe!" => \$runsafely,
+ "makesty" => sub {$styfile = "noperltex.sty"},
"permit=s" => \@permittedops) || pod2usage(2);
@latexcmdline = @ARGV;
my $firstcmd = 0;
@@ -96,6 +99,9 @@ foreach my $file ($toperl, $fromperl, $toflag, $fromflag, $doneflag) {
unlink $file while -e $file;
}
open (LOGFILE, ">$logfile") || die "open(\"$logfile\"): $!\n";
+if (defined $styfile) {
+ open (STYFILE, ">$styfile") || die "open(\"$styfile\"): $!\n";
+}
defined ($latexpid = fork) || die "fork: $!\n";
unshift @latexcmdline, $latexprog;
if (!$latexpid) {
@@ -173,7 +179,7 @@ while (1) {
print LOGFILE "# ===> $warningmsg\n\n";
}
}
- $result="" if !$result || $optag eq "RUN";
+ $result = "" if !$result || $optag eq "RUN";
if ($@) {
my $msg = $@;
$msg =~ s/at \(eval \d+\) line \d+\W+//;
@@ -202,6 +208,7 @@ while (1) {
$helpstring =~ s/\. /.\\space\\space /g;
$result .= "{$helpstring}";
}
+ push @macroexpansions, $result if defined $styfile && $optag eq "USE";
print LOGFILE "%" x 30, " LATEX RESULT ", "%" x 30, "\n";
print LOGFILE $result, "\n\n";
$result .= '\endinput';
@@ -224,6 +231,46 @@ END {
kill (9, $latexpid);
exit 1;
}
+
+ if (defined $styfile) {
+ print STYFILE <<"STYFILEHEADER1";
+\\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\\ProvidesPackage{noperltex}
+ [2007/09/29 v1.4 Perl-free version of PerlTeX specific to $jobname.tex]
+STYFILEHEADER1
+ ;
+ print STYFILE <<'STYFILEHEADER2';
+\RequirePackage{filecontents}
+
+\let\noperltex@PackageError=\PackageError
+\renewcommand{\PackageError}[3]{}
+\RequirePackage{perltex}
+\let\PackageError=\noperltex@PackageError
+
+\newcount\plmac@macro@invocation@num
+\gdef\plmac@show@placeholder#1#2\@empty{%
+ \ifx#1U\relax
+ \endgroup
+ \advance\plmac@macro@invocation@num by 1\relax
+ \global\plmac@macro@invocation@num=\plmac@macro@invocation@num
+ \input{noperltex-\the\plmac@macro@invocation@num.tex}%
+ \else
+ \endgroup
+ \fi
+}
+STYFILEHEADER2
+ ;
+ foreach my $e (0 .. $#macroexpansions) {
+ print STYFILE "\n";
+ printf STYFILE "%% Invocation #%d\n", 1+$e;
+ printf STYFILE "\\begin{filecontents}{noperltex-%d.tex}\n", 1+$e;
+ print STYFILE $macroexpansions[$e], "\\endinput\n";
+ print STYFILE "\\end{filecontents}\n";
+ }
+ print STYFILE "\\endinput\n";
+ close STYFILE;
+ }
+
exit 0;
}
@@ -240,6 +287,7 @@ perltex
[B<--latex>=I<program>]
[B<-->[B<no>]B<safe>]
[B<--permit>=I<feature>]
+[B<--makesty]
[I<latex options>]
=head1 DESCRIPTION
@@ -295,6 +343,17 @@ option, which can be specified more than once on the command line,
enables finer-grained control over the B<perltex> sandbox. See
L<Opcode> for more information.
+=item B<--makesty>
+
+Generate a LaTeX style file called F<noperltex.sty>. Replacing the
+document's C<\usepackage{perltex}> line with C<\usepackage{noperltex}>
+produces the same output but does not require PerlTeX, making the
+document suitable for distribution to people who do not have PerlTeX
+installed. The disadvantage is that F<noperltex.sty> is specific to
+the document that produced it. Any changes to the document's PerlTeX
+macro definitions or macro invocations necessitates rerunning
+B<perltex> with the B<--makesty> option.
+
=back
These options are then followed by whatever options are normally
@@ -376,6 +435,10 @@ valid data
``flag'' file whose existence indicates that F<jobname.ffpl> has been
deleted
+=item F<noperltex-#.tex>
+
+file generated by F<noperltex.sty> for each PerlTeX macro invocation
+
=back
=head1 NOTES