summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/perltex/README1
-rw-r--r--Master/texmf-dist/doc/latex/perltex/perltex.pdfbin286842 -> 292838 bytes
-rw-r--r--Master/texmf-dist/source/latex/perltex/perltex.dtx187
-rw-r--r--Master/texmf-dist/tex/latex/perltex/perltex.sty18
4 files changed, 165 insertions, 41 deletions
diff --git a/Master/texmf-dist/doc/latex/perltex/README b/Master/texmf-dist/doc/latex/perltex/README
index b42358d7fb2..7cb298ff64d 100644
--- a/Master/texmf-dist/doc/latex/perltex/README
+++ b/Master/texmf-dist/doc/latex/perltex/README
@@ -1,6 +1,5 @@
+------------------------------------+
| PERLTEX |
- | |
| By Scott Pakin, scott+pt@pakin.org |
+------------------------------------+
diff --git a/Master/texmf-dist/doc/latex/perltex/perltex.pdf b/Master/texmf-dist/doc/latex/perltex/perltex.pdf
index 9f15174fbfd..536ca94a12d 100644
--- a/Master/texmf-dist/doc/latex/perltex/perltex.pdf
+++ b/Master/texmf-dist/doc/latex/perltex/perltex.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/perltex/perltex.dtx b/Master/texmf-dist/source/latex/perltex/perltex.dtx
index c96584b208b..3bd604e2f81 100644
--- a/Master/texmf-dist/source/latex/perltex/perltex.dtx
+++ b/Master/texmf-dist/source/latex/perltex/perltex.dtx
@@ -22,7 +22,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{perltex}
%<*package>
- [2006/06/24 v1.3 LaTeX macros for use with PerlTeX]
+ [2007/09/29 v1.4 LaTeX macros for use with PerlTeX]
%</package>
%
%<*driver>
@@ -60,7 +60,7 @@
%</driver>
% \fi
%
-% \CheckSum{511}
+% \CheckSum{563}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -109,6 +109,7 @@
% \newcommand{\PerlTeX}{Perl\TeX{}} ^^A Name of the complete system
% \newcommand{\perltex}{\texttt{perltex.pl}} ^^A Name of the Perl script
% \newcommand{\perlmac}{\texttt{perltex.sty}} ^^A Name of the LaTeX package
+% \newcommand{\noperlmac}{\texttt{noperltex.sty}} ^^A Name of the alternate LaTeX package
%
% ^^A Define an environment just like macro but for Perl scalars or lists.
% \makeatletter
@@ -628,6 +629,7 @@
%
% \providecommand{\url}[1]{\texttt{##1}}
%
+% \bigskip
% \noindent
% These files may be distributed and/or modified under the conditions of
% the \LaTeX{} Project Public License, either version~1.3c of this
@@ -636,6 +638,19 @@
% version~1.3c or later is part of all distributions of \LaTeX{} version
% 2006/05/20 or later.
%
+%
+% \section*{Acknowledgments}
+% \label{sec:acknowledgments}
+%
+% Thanks to Andrew Mertz for writing the first draft of the code that
+% produces the \PerlTeX-free \noperlmac\ style file and for testing the
+% final draft; to Phil Kitschen~(?) for pointing out an error in the
+% Hilbert-matrix example; and to Andrei Alexandrescu for providing a few
+% bug fixes. Also, thanks to the many people who have sent me fan mail
+% or submitted bug reports or feature requests. (The
+% \texttt{\string\perldo} macro and the \texttt{--makesty} option were
+% particularly popular requests.)
+%
% \PrintChanges
% \PrintIndex
% }
@@ -1672,7 +1687,9 @@
\input\plmac@fromfile\relax
}
% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\plmac@write@perl@i}
% \changes{v1.1}{2004/02/24}{Added a dummy version of the macro to use
% if \texttt{latex} was launched directly, without \perltex}
% The foregoing code represents the ``real'' definition of
@@ -1688,8 +1705,6 @@
% \begin{macrocode}
\else
\newcommand{\plmac@write@perl@i}[1]{\endgroup}
- \AtBeginDocument{%
- \renewcommand{\plmac@write@perl@i}[1]{%
% \end{macrocode}
% \begin{macro}{\plmac@show@placeholder}
% There's really no point in outputting a framed ``Perl\TeX'' when a
@@ -1698,21 +1713,25 @@
% ``D''~(|DEF|), nothing is output. Otherwise, it'll be ``U''~(|USE|)
% and ``Perl\TeX'' will be output.
% \begin{macrocode}
- \def\plmac@show@placeholder##1##2\@empty{%
- \ifx##1D\relax
- \endgroup
- \else
- \endgroup
- \fbox{Perl\TeX}%
- \fi
- }%
+ \gdef\plmac@show@placeholder#1#2\@empty{%
+ \ifx#1D\relax
+ \endgroup
+ \else
+ \endgroup
+ \fbox{Perl\TeX}%
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \renewcommand{\plmac@write@perl@i}[1]{%
\plmac@show@placeholder#1\@empty
}%
}
\fi
% \end{macrocode}
% \end{macro}
-% \end{macro}
%
% \iffalse
%</package>
@@ -1852,21 +1871,25 @@ my @permittedops;
% \begin{perlmacro}{$fromflag}
% \begin{perlmacro}{$doneflag}
% \begin{perlmacro}{$logfile}
+% \begin{perlmacro}{$styfile}
+% \begin{perlmacro}{@macroexpansions}
% \begin{perlmacro}{$sandbox}
% \begin{perlmacro}{$sandbox_eval}
% \begin{perlmacro}{$latexpid}
-% |$progname| is the run-time name of the \perltex{} program. |$jobname|
-% is the base name of the user's |.tex| file, which defaults to the
-% \TeX{} default of |texput|. |@latexcmdline| is the command line to
-% pass to the \LaTeX{} executable. |$toperl| defines the filename used
-% for \LaTeX{}$\rightarrow$Perl communication. |$fromperl| defines the
-% filename used for Perl$\rightarrow$\LaTeX{} communication. |$toflag|
-% is the name of a file that will exist only after \LaTeX{} creates
-% |$tofile|. |$fromflag| is the name of a file that will exist only
-% after Perl creates |$fromfile|. |$doneflag| is the name of a file
-% that will exist only after Perl deletes |$fromflag|. |$logfile| is the
-% name of a log file to which \perltex{} writes verbose execution
-% information. |$sandbox| is a secure sandbox in which to run code that
+% |$progname| is the run-time name of the \perltex{} program.
+% |$jobname| is the base name of the user's |.tex| file, which defaults
+% to the \TeX{} default of |texput|. |@latexcmdline| is the command
+% line to pass to the \LaTeX{} executable. |$toperl| defines the
+% filename used for \LaTeX{}$\rightarrow$Perl communication.
+% |$fromperl| defines the filename used for Perl$\rightarrow$\LaTeX{}
+% communication. |$toflag| is the name of a file that will exist only
+% after \LaTeX{} creates |$tofile|. |$fromflag| is the name of a file
+% that will exist only after Perl creates |$fromfile|. |$doneflag| is
+% the name of a file that will exist only after Perl deletes
+% |$fromflag|. |$logfile| is the name of a log file to which \perltex{}
+% writes verbose execution information. |$styfile| is the string
+% \noperlmac\ if \perltex\ is run with \texttt{--makesty}, otherwise
+% undefined. |$sandbox| is a secure sandbox in which to run code that
% appeared in the \LaTeX{} document. |$sandbox_eval| is a subroutine
% that evalutes a string within |$sandbox| (normally) or outside of all
% sandboxes (if |--nosafe| is specified). |$latexpid| is the process~ID
@@ -1881,6 +1904,8 @@ my $toflag;
my $fromflag;
my $doneflag;
my $logfile;
+my $styfile;
+my @macroexpansions;
my $sandbox = new Safe;
my $sandbox_eval;
my $latexpid;
@@ -1897,6 +1922,8 @@ my $latexpid;
% \end{perlmacro}
% \end{perlmacro}
% \end{perlmacro}
+% \end{perlmacro}
+% \end{perlmacro}
%
% \subsubsection{Command-line conversion}
%
@@ -1915,6 +1942,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);
% \end{macrocode}
%
@@ -1987,10 +2015,10 @@ $latexcmdline[$firstcmd] =
% We start by deleting the |$toperl|, |$fromperl|, |$toflag|,
% |$fromflag|, and |$doneflag| files, in case any of these were left
% over from a previous (aborted) run. We also create a log file,
-% |$logfile|. As |@latexcmdline| contains the complete command line to
-% pass to |latex| we need only |fork| a new process and have the child
-% process overlay itself with |latex|. \perltex{} continues running as
-% the parent.
+% |$logfile| and, if |$styfile| is defined, a \LaTeXe\ style file. As
+% |@latexcmdline| contains the complete command line to pass to |latex|
+% we need only |fork| a new process and have the child process overlay
+% itself with |latex|. \perltex{} continues running as the parent.
%
% Note that here and elsewhere in \perltex, |unlink| is called
% repeatedly until the file is actually deleted. This works around a
@@ -2003,6 +2031,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";
+}
% \end{macrocode}
% \begin{macrocode}
defined ($latexpid = fork) || die "fork: $!\n";
@@ -2224,7 +2255,10 @@ while (1) {
% message for all other errors caused by executing the user's code. For
% clarity of reading both warning and error messages, we elide the
% string ``\texttt{at (eval} \meta{number}\texttt{) line}
-% \meta{number}''.
+% \meta{number}''. Once |$result| is defined---as either the resulting
+% \LaTeX\ code or as a |\PackageError|---we store it in
+% |@macroexpansions| in preparation for writing it to \noperlmac\
+% (when \perltex\ is run with \texttt{--makesty}).
% \begin{macrocode}
undef $_;
my $result;
@@ -2238,7 +2272,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+//;
@@ -2267,6 +2301,7 @@ while (1) {
$helpstring =~ s/\. /.\\space\\space /g;
$result .= "{$helpstring}";
}
+ push @macroexpansions, $result if defined $styfile && $optag eq "USE";
% \end{macrocode}
% \end{perlmacro}
% \end{perlmacro}
@@ -2327,6 +2362,80 @@ END {
kill (9, $latexpid);
exit 1;
}
+
+ if (defined $styfile) {
+% \end{macrocode}
+% \changes{v1.4}{2007/09/29}{Added support for a \texttt{--makesty}
+% option that generates a \PerlTeX-free style file called
+% \texttt{noperltex.sty}}
+% This is the big moment for the \texttt{--makesty} option. We've
+% accumulated the output from each \PerlTeX\ macro invocation into
+% |@macroexpansions|, and now we need to produce a
+% \noperlmac\ file. We start by generating a boilerplate
+% header in which we set up the package and load both \perlmac\ and
+% \texttt{filecontents.sty}.
+% \begin{macrocode}
+ 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}
+
+% Suppress the "Document must be compiled using perltex" error from perltex.
+\let\noperltex@PackageError=\PackageError
+\renewcommand{\PackageError}[3]{}
+\RequirePackage{perltex}
+\let\PackageError=\noperltex@PackageError
+
+% \end{macrocode}
+% \begin{macro}{\plmac@macro@invocation@num}
+% \begin{macro}{\plmac@show@placeholder}
+% \noperlmac\ works by redefining the |\plmac@show@placeholder| macro,
+% which normally outputs a framed ``\PerlTeX'' when \perltex\ isn't
+% running, changing it to input |noperltex-|\meta{number}|.tex| instead
+% (where \meta{number} is the contents of the
+% |\plmac@macro@invocation@num| counter). Each
+% |noperltex-|\meta{number}|.tex| file contains the output from a single
+% invocation of a \PerlTeX-defined macro.
+% \begin{macrocode}
+% Modify \plmac@show@placeholder to input the next noperltex-*.tex file
+% each time a PerlTeX-defined macro is invoked.
+\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
+ ;
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Finally, we need to have \noperlmac\ generate each of the
+% |noperltex-|\meta{number}|.tex| files. For each element of
+% |@macroexpansions| we use one |filecontents| environment to write the
+% macro expansion verbatim to a file.
+% \begin{macrocode}
+ 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;
}
@@ -2359,6 +2468,7 @@ perltex
[B<--latex>=I<program>]
[B<-->[B<no>]B<safe>]
[B<--permit>=I<feature>]
+[B<--makesty]
[I<latex options>]
@@ -2416,6 +2526,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
@@ -2500,6 +2621,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
diff --git a/Master/texmf-dist/tex/latex/perltex/perltex.sty b/Master/texmf-dist/tex/latex/perltex/perltex.sty
index 13c0694abdf..91d13ec61dc 100644
--- a/Master/texmf-dist/tex/latex/perltex/perltex.sty
+++ b/Master/texmf-dist/tex/latex/perltex/perltex.sty
@@ -22,7 +22,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{perltex}
- [2006/06/24 v1.3 LaTeX macros for use with PerlTeX]
+ [2007/09/29 v1.4 LaTeX macros for use with PerlTeX]
\newif\ifplmac@have@perltex
\plmac@have@perltextrue
\@ifundefined{plmac@tag}{\plmac@have@perltexfalse}{}
@@ -233,16 +233,16 @@
}
\else
\newcommand{\plmac@write@perl@i}[1]{\endgroup}
+ \gdef\plmac@show@placeholder#1#2\@empty{%
+ \ifx#1D\relax
+ \endgroup
+ \else
+ \endgroup
+ \fbox{Perl\TeX}%
+ \fi
+ }%
\AtBeginDocument{%
\renewcommand{\plmac@write@perl@i}[1]{%
- \def\plmac@show@placeholder##1##2\@empty{%
- \ifx##1D\relax
- \endgroup
- \else
- \endgroup
- \fbox{Perl\TeX}%
- \fi
- }%
\plmac@show@placeholder#1\@empty
}%
}