diff options
author | Karl Berry <karl@freefriends.org> | 2007-10-19 17:56:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-10-19 17:56:01 +0000 |
commit | 0ae062e177340be706279e9275f7c3e2ed4f323a (patch) | |
tree | f28d64d75b976d9d5ffe8f27b456887b39204bea /Master/texmf-dist/source/latex | |
parent | 146ff49cee440098d4918aaf6be7148276c21fc8 (diff) |
perltex 1.5 (15oct07)
git-svn-id: svn://tug.org/texlive/trunk@5238 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/perltex/perltex.dtx | 347 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/perltex/perltex.ins | 4 |
2 files changed, 219 insertions, 132 deletions
diff --git a/Master/texmf-dist/source/latex/perltex/perltex.dtx b/Master/texmf-dist/source/latex/perltex/perltex.dtx index 3bd604e2f81..801a0f8005c 100644 --- a/Master/texmf-dist/source/latex/perltex/perltex.dtx +++ b/Master/texmf-dist/source/latex/perltex/perltex.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment % -% Copyright (C) 2007, Scott Pakin <scott+pt@pakin.org> -% ---------------------------------------------------- +% Copyright (C) 2007 Scott Pakin <scott+pt@pakin.org> +% --------------------------------------------------- % % This file may be distributed and/or modified under the conditions of % the LaTeX Project Public License, either version 1.3c of this license @@ -22,7 +22,7 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{perltex} %<*package> - [2007/09/29 v1.4 LaTeX macros for use with PerlTeX] + [2007/10/13 v1.5 LaTeX macros for use with PerlTeX] %</package> % %<*driver> @@ -34,6 +34,7 @@ \def\plmac@toflag{\jobname.tfpl} \def\plmac@fromflag{\jobname.ffpl} \def\plmac@doneflag{\jobname.dfpl} + \def\plmac@pipe{\jobname.pipe} \makeatother \usepackage{perltex} \usepackage{varioref} @@ -60,7 +61,7 @@ %</driver> % \fi % -% \CheckSum{563} +% \CheckSum{577} % % \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 @@ -449,14 +450,15 @@ % % \subsection*{SYNOPSIS} % perltex -% {\tt [}{\bf {\tt --}help}{\tt ]} -% {\tt [}{\bf {\tt --}latex}={\em program\/}{\tt ]} -% {\tt [}{\bf {\tt --}}{\tt [}{\bf no}{\tt ]}{\bf safe}{\tt ]} -% {\tt [}{\bf {\tt --}permit}={\em feature\/}{\tt ]} -% {\tt [}{\em latex options\/}{\tt ]} +% [\textbf{--help}] +% [\textbf{--latex}=\textit{program}] +% [\textbf{--}[\textbf{no}]\textbf{safe}] +% [\textbf{--permit}=\textit{feature}] +% [\textbf{--makesty}] +% [\textit{latex options}] % % \subsection*{DESCRIPTION} -% \LaTeX{} --- through the underlying \TeX{} typesetting system --- produces +% \LaTeX---through the underlying \TeX{} typesetting system---produces % beautifully typeset documents but has a macro language that is % difficult to program. In particular, support for complex string % manipulation is largely lacking. Perl is a popular general-purpose @@ -465,16 +467,17 @@ % % \bigskip % -% Clearly, Perl's programmability could complement \LaTeX{}'s typesetting -% strengths. {\bf perltex} is the tool that enables a symbiosis between -% the two systems. All a user needs to do is compile a \LaTeX{} document -% using {\bf perltex} instead of {\bf latex}. ({\bf perltex} is actually a -% wrapper for {\bf latex}, so no {\bf latex} functionality is lost.) If the -% document includes a {\tt \char`\\usepackage\{perltex\}} in its preamble, then -% {\tt \char`\\perlnewcommand} and {\tt \char`\\perlrenewcommand} macros will be made -% available. These behave just like \LaTeX{}'s {\tt \char`\\newcommand} and -% {\tt \char`\\renewcommand} except that the macro body contains Perl code instead -% of \LaTeX{} code. +% Clearly, Perl's programmability could complement \LaTeX's typesetting +% strengths. \textbf{perltex} is the tool that enables a symbiosis +% between the two systems. All a user needs to do is compile a \LaTeX\ +% document using \textbf{perltex} instead of \textbf{latex}. +% (\textbf{perltex} is actually a wrapper for \textbf{latex}, so no +% \textbf{latex} functionality is lost.) If the document includes a +% \texttt{\string\usepackage\{perltex\}} in its preamble, then +% \texttt{\string\perlnewcommand} and \texttt{\string\perlrenewcommand} +% macros will be made available. These behave just like \LaTeX's +% \texttt{\string\newcommand} and \texttt{\string\renewcommand} except +% that the macro body contains Perl code instead of \LaTeX\ code. % % \subsection*{OPTIONS}% % \index{OPTIONS} @@ -483,136 +486,174 @@ % % \begin{description} % -% \item[{\bf {\tt --}help}]% -% \index{--help@{\bf {\tt --}help}}% -% \hfil\\ +% +% \item[{\textbf{-{}-help}}] \mbox{} +% % Display basic usage information. % -% \item[{\bf {\tt --}latex}={\em program\/}]% -% \index{--latex=program@{\bf {\tt --}latex}={\em program\/}}% -% \hfil\\ -% Specify a program to use instead of {\bf latex}. For example, -% {\tt --latex=pdf{}latex} would typeset the given document using -% {\bf pdf{}latex} instead of ordinary {\bf latex}. -% -% \item[{\bf {\tt --}}{\tt [}{\bf no}{\tt ]}{\bf safe}]% -% \index{--[no]safe@{\bf {\tt --}}{\tt [}{\bf no}{\tt ]}{\bf safe}}% -% \hfil\\ -% Enable or disable sandboxing. With the default of {\tt --safe}, -% {\bf perltex} executes the code from a {\tt \char`\\perlnewcommand} or -% {\tt \char`\\perlrenewcommand} macro within a protected environment that -% prohibits ``unsafe'' operations such as accessing files or executing -% external programs. Specifying {\tt --nosafe} gives the \LaTeX{} document -% {\em carte blanche\/} to execute any arbitrary Perl code, including that -% which can harm the user's files. See the {\em Safe\/} manpage for more information. -% -% \item[{\bf {\tt --}permit}={\em feature\/}]% -% \index{--permit=feature@{\bf {\tt --}permit}={\em feature\/}}% -% \hfil\\ -% Permit particular Perl operations to be performed. The {\tt --permit} -% option, which can be specified more than once on the command line, -% enables finer-grained control over the {\bf perltex} sandbox. See -% the {\em Opcode\/} manpage for more information. +% +% \item[{\textbf{-{}-latex}=\textit{program}}] \mbox{} +% +% Specify a program to use instead of \textbf{latex}. For example, +% \texttt{--latex=pdflatex} would typeset the given document using +% \textbf{pdflatex} instead of ordinary \textbf{latex}. +% +% +% \item[{\textbf{-{}-}[\textbf{no}]\textbf{safe}}] \mbox{} +% +% Enable or disable sandboxing. With the default of \textbf{-{}-safe}, +% \textbf{perltex} executes the code from a +% \texttt{\string\perlnewcommand} or \texttt{\string\perlrenewcommand} +% macro within a protected environment that prohibits ``unsafe'' +% operations such as accessing files or executing external programs. +% Specifying \textbf{-{}-nosafe} gives the \LaTeX\ document \textit{carte +% blanche} to execute any arbitrary Perl code, including that which can +% harm the user's files. See \emph{Safe} for more information. +% +% +% \item[{\textbf{-{}-permit}=\textit{feature}}] \mbox{} +% +% Permit particular Perl operations to be performed. The +% \textbf{-{}-permit} option, which can be specified more than once on +% the command line, enables finer-grained control over the +% \textbf{perltex} sandbox. See \emph{Opcode} for more information. +% +% +% \item[{\textbf{-{}-makesty}}] \mbox{} +% +% Generate a \LaTeX\ style file called \emph{noperltex.sty}. Replacing +% the document's \texttt{\string\usepackage\{perltex\}} line with +% \texttt{\string\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 \emph{noperltex.sty} is specific to the document +% that produced it. Any changes to the document's \PerlTeX\ macro +% definitions or macro invocations necessitates rerunning +% \textbf{perltex} with the \textbf{-{}-makesty} option. % % \end{description} % % These options are then followed by whatever options are normally -% passed to {\bf latex} (or whatever program was specified with -% {\tt --latex}), including, for instance, the name of the {\em .tex\/} file to -% compile. +% passed to \textbf{latex} (or whatever program was specified with +% \texttt{--latex}), including, for instance, the name of the +% \emph{.tex} file to compile. % % \subsection*{EXAMPLES} -% In its simplest form, {\bf perltex} is run just like {\bf latex}: +% +% In its simplest form, \textbf{perltex} is run just like \textbf{latex}: +% % \begin{verbatim} % perltex myfile.tex % \end{verbatim} % -% To use {\bf pdf{}latex} instead of regular {\bf latex}, use the {\tt --latex} -% option: +% +% To use \textbf{pdflatex} instead of regular \textbf{latex}, use the +% \textbf{-{}-latex} option: +% % \begin{verbatim} % perltex --latex=pdflatex myfile.tex % \end{verbatim} % -% If \LaTeX{} gives a ``{\tt trapped by operation mask}'' error and you -% trust the {\em .tex\/} file you're trying to compile not to execute +% +% If \LaTeX\ gives a ``\texttt{trapped by operation mask}'' error and +% you trust the \emph{.tex} file you're trying to compile not to execute % malicious Perl code (e.g., because you wrote it yourself), you can -% disable {\bf perltex}'s safety mechansisms with {\tt --nosafe}: +% disable \textbf{perltex}'s safety mechansisms with +% \textbf{-{}-nosafe}: +% % \begin{verbatim} % perltex --nosafe myfile.tex % \end{verbatim} % -% The following command gives documents only {\bf perltex}'s default -% permissions ({\tt :browse}) plus the ability to open files and invoke the -% {\tt time} command: +% +% The following command gives documents only \textbf{perltex}'s default +% permissions (\texttt{:browse}) plus the ability to open files and invoke the +% \texttt{time} command: +% % \begin{verbatim} % perltex --permit=:browse --permit=:filesys_open % --permit=time myfile.tex % \end{verbatim} % +% % \subsection*{ENVIRONMENT} -% {\bf perltex} honors the following environment variables: +% +% \textbf{perltex} honors the following environment variables: % % \begin{description} % -% \item[PERLTEX]% -% \index{PERLTEX@PERLTEX}% -% \hfil\\ -% Specify the filename of the \LaTeX{} compiler. The \LaTeX{} compiler -% defaults to ``{\tt latex}''. The {\tt PERLTEX} environment variable -% overrides this default, and the {\tt --latex} command-line option (see -% the {\tt OPTIONS} entry elsewhere in this document) overrides that. +% \item[{PERLTEX}] \mbox{} +% +% Specify the filename of the \LaTeX\ compiler. The \LaTeX\ compiler +% defaults to ``\texttt{latex}''. The \texttt{PERLTEX} environment +% variable overrides this default, and the \textbf{-{}-latex} +% command-line option (see \textsf{OPTIONS}) overrides that. % % \end{description} % +% % \subsection*{FILES} -% While compiling {\em jobname.tex\/}, {\bf perltex} makes use of the following -% files: +% +% While compiling \emph{jobname.tex}, \textbf{perltex} makes use of the +% following files: % % \begin{description} % -% \item[{\em jobname.lgpl\/}]% -% \index{jobname.lgpl@{\em jobname.lgpl\/}}% -% \hfil\\ +% \item[{\emph{jobname.lgpl}}] \mbox{} +% % log file written by Perl; helpful for debugging Perl macros % -% \item[{\em jobname.topl\/}]% -% \index{jobname.topl@{\em jobname.topl\/}}% -% \hfil\\ -% information sent from \LaTeX{} to Perl % -% \item[{\em jobname.frpl\/}]% -% \index{jobname.frpl@{\em jobname.frpl\/}}% -% \hfil\\ -% information sent from Perl to \LaTeX{} +% \item[{\emph{jobname.topl}}] \mbox{} +% +% information sent from \LaTeX\ to Perl +% % -% \item[{\em jobname.tfpl\/}]% -% \index{jobname.tfpl@{\em jobname.tfpl\/}}% -% \hfil\\ -% ``flag'' file whose existence indicates that {\em jobname.topl\/} contains +% \item[{\emph{jobname.frpl}}] \mbox{} +% +% information sent from Perl to \LaTeX\ +% +% +% \item[{\emph{jobname.tfpl}}] \mbox{} +% +% ``flag'' file whose existence indicates that \emph{jobname.topl} contains % valid data % -% \item[{\em jobname.ffpl\/}]% -% \index{jobname.ffpl@{\em jobname.ffpl\/}}% -% \hfil\\ -% ``flag'' file whose existence indicates that {\em jobname.frpl\/} contains +% +% \item[{\emph{jobname.ffpl}}] \mbox{} +% +% ``flag'' file whose existence indicates that \emph{jobname.frpl} contains % valid data % -% \item[{\em jobname.dfpl\/}]% -% \index{jobname.dfpl@{\em jobname.dfpl\/}}% -% \hfil\\ -% ``flag'' file whose existence indicates that {\em jobname.ffpl\/} has been +% +% \item[{\emph{jobname.dfpl}}] \mbox{} +% +% ``flag'' file whose existence indicates that \emph{jobname.ffpl} has been % deleted % +% +% \item[{\emph{noperltex-\#.tex}}] \mbox{} +% +% file generated by \emph{noperltex.sty} for each \PerlTeX\ macro invocation +% % \end{description} % +% % \subsection*{NOTES} -% {\bf perltex}'s sandbox defaults to what the {\em Opcode\/} manpage calls ``{\tt :browse}''. +% +% \textbf{perltex}'s sandbox defaults to what \emph{Opcode} calls +% ``\texttt{:browse}''. +% % % \subsection*{SEE ALSO} -% {\em latex\/}(1), {\em pdf{}latex\/}(1), {\em perl\/}(1), {\em Safe\/}(3pm), {\em Opcode\/}(3pm) +% +% latex(1), pdflatex(1), perl(1), Safe(3pm), Opcode(3pm) +% % % \subsection*{AUTHOR} -% Scott Pakin, {\em scott+pt@pakin.org\/} +% +% Scott Pakin, \textit{scott+pt@pakin.org} +% % % ^^A *********************************** % ^^A * End of generated pod2latex text * @@ -625,7 +666,7 @@ % \section{License agreement} % \label{sec:license} % -% Copyright \textcopyright{} 2007, Scott Pakin \texttt{<scott+pt@pakin.org>} +% Copyright \textcopyright{} 2007 Scott Pakin \texttt{<scott+pt@pakin.org>} % % \providecommand{\url}[1]{\texttt{##1}} % @@ -644,10 +685,9 @@ % % 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 +% final draft; 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, documentation corrections, or feature requests. (The % \texttt{\string\perldo} macro and the \texttt{--makesty} option were % particularly popular requests.) % @@ -783,9 +823,10 @@ % \begin{macro}{\plmac@have@perltextrue} % \begin{macro}{\plmac@have@perltexfalse} % The following block of code checks the existence of each of the -% variables listed in Table~\ref{tbl:variables}. If any variable is not -% defined, \perlmac{} gives an error message and---as we shall see on -% page~\pageref{page:define-dummies}---defines dummy versions of +% variables listed in Table~\ref{tbl:variables} plus |\plmac@pipe|, a +% Unix named pipe used for to improve performance. If any variable is +% not defined, \perlmac{} gives an error message and---as we shall see +% on page~\pageref{page:define-dummies}---defines dummy versions of % |\perl|[|re|]|newcommand| and |\perl|[|re|]|newenvironment|. % \begin{macrocode} \newif\ifplmac@have@perltex @@ -796,6 +837,7 @@ \@ifundefined{plmac@toflag}{\plmac@have@perltexfalse}{} \@ifundefined{plmac@fromflag}{\plmac@have@perltexfalse}{} \@ifundefined{plmac@doneflag}{\plmac@have@perltexfalse}{} +\@ifundefined{plmac@pipe}{\plmac@have@perltexfalse}{} \ifplmac@have@perltex \else \PackageError{perltex}{Document must be compiled using perltex} @@ -1553,11 +1595,23 @@ % For convenience, we use \LaTeXe's |\IfFileExists| macro to check the % file and invoke |\plmac@file@existstrue| or |\plmac@file@existsfalse|, % as appropriate. +% +% As a performance optimization we |\input| a named pipe. This causes +% the |latex| process to relinquish the CPU until the |perltex| process +% writes data (always just ``|\endinput|'') into the named pipe. On +% systems that don't support persistent named pipes (e.g.,~Microsoft +% Windows), |\plmac@pipe| is an ordinary file containing only +% ``|\endinput|''. While reading that file is not guaranteed to +% relinquish the CPU, it should not hurt the performance or correctness +% of the communication protocol between \LaTeX\ and Perl. +% \changes{v1.5}{2007/10/13}{Modified to read from a named pipe before +% checking file existence} % \begin{macrocode} \newif\ifplmac@file@exists % \end{macrocode} % \begin{macrocode} \newcommand{\plmac@await@existence}[1]{% + \input\plmac@pipe \loop \IfFileExists{#1}% {\plmac@file@existstrue}% @@ -1783,7 +1837,7 @@ # # This is a generated file. # -# Copyright (C) 2007, Scott Pakin <scott+pt@pakin.org> +# Copyright (C) 2007 Scott Pakin <scott+pt@pakin.org> # # This file may be distributed and/or modified under the conditions # of the LaTeX Project Public License, either version 1.3c of this @@ -1829,6 +1883,7 @@ use Opcode; use Getopt::Long; use Pod::Usage; use File::Basename; +use Fcntl; use POSIX; use warnings; use strict; @@ -1871,6 +1926,7 @@ my @permittedops; % \begin{perlmacro}{$fromflag} % \begin{perlmacro}{$doneflag} % \begin{perlmacro}{$logfile} +% \begin{perlmacro}{$pipe} % \begin{perlmacro}{$styfile} % \begin{perlmacro}{@macroexpansions} % \begin{perlmacro}{$sandbox} @@ -1887,13 +1943,16 @@ my @permittedops; % 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 -% of the |latex| process. +% writes verbose execution information. |$pipe| is the name of a Unix +% named pipe (or ordinary file on operating systems that lack support +% for persistent named pipes) used to convince the |latex| process to +% yield control of the CPU\@. |$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 of the +% |latex| process. % \begin{macrocode} my $progname = basename $0; my $jobname = "texput"; @@ -1904,6 +1963,7 @@ my $toflag; my $fromflag; my $doneflag; my $logfile; +my $pipe; my $styfile; my @macroexpansions; my $sandbox = new Safe; @@ -1924,6 +1984,7 @@ my $latexpid; % \end{perlmacro} % \end{perlmacro} % \end{perlmacro} +% \end{perlmacro} % % \subsubsection{Command-line conversion} % @@ -1984,7 +2045,8 @@ foreach (1 .. 20) { % % Now that we have the name of the \LaTeX{} job (|$jobname|) we can % assign |$toperl|, |$fromperl|, |$toflag|, |$fromflag|, |$doneflag|, -% and |$logfile| in terms of |$jobname| plus a suitable extension. +% |$logfile|, and |$pipe| in terms of |$jobname| plus a suitable +% extension. % \begin{macrocode} $toperl = $jobname . ".topl"; $fromperl = $jobname . ".frpl"; @@ -1992,6 +2054,7 @@ $toflag = $jobname . ".tfpl"; $fromflag = $jobname . ".ffpl"; $doneflag = $jobname . ".dfpl"; $logfile = $jobname . ".lgpl"; +$pipe = $jobname . ".pipe"; % \end{macrocode} % % We now replace the filename of the |.tex| file passed to \perltex{} @@ -2000,25 +2063,28 @@ $logfile = $jobname . ".lgpl"; % necessary. % \begin{macrocode} $latexcmdline[$firstcmd] = - sprintf '\makeatletter' . '\def%s{%s}' x 6 . '\makeatother%s', + sprintf '\makeatletter' . '\def%s{%s}' x 7 . '\makeatother%s', '\plmac@tag', $separator, '\plmac@tofile', $toperl, '\plmac@fromfile', $fromperl, '\plmac@toflag', $toflag, '\plmac@fromflag', $fromflag, '\plmac@doneflag', $doneflag, + '\plmac@pipe', $pipe, $latexcmdline[$firstcmd]; % \end{macrocode} % % \subsubsection{Launching \LaTeX} % % 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| 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. +% |$fromflag|, |$doneflag|, and |$pipe| files, in case any of these were +% left over from a previous (aborted) run. We also create a log file +% (|$logfile|), a named pipe (|$pipe|)---or a file containing only +% |\endinput| if we can't create a named pipe---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 @@ -2027,7 +2093,7 @@ $latexcmdline[$firstcmd] = % \changes{v1.0a}{2003/08/21}{Made all \texttt{unlink} calls wait for the % file to actually disappear} % \begin{macrocode} -foreach my $file ($toperl, $fromperl, $toflag, $fromflag, $doneflag) { +foreach my $file ($toperl, $fromperl, $toflag, $fromflag, $doneflag, $pipe) { unlink $file while -e $file; } open (LOGFILE, ">$logfile") || die "open(\"$logfile\"): $!\n"; @@ -2036,6 +2102,13 @@ if (defined $styfile) { } % \end{macrocode} % \begin{macrocode} +if (!eval {mkfifo($pipe, 0600)}) { + sysopen PIPE, $pipe, O_WRONLY|O_CREAT, 0755; + print PIPE "\\endinput\n"; + close PIPE; +} +% \end{macrocode} +% \begin{macrocode} defined ($latexpid = fork) || die "fork: $!\n"; unshift @latexcmdline, $latexprog; if (!$latexpid) { @@ -2092,7 +2165,7 @@ while (1) { sleep 0; if (waitpid($latexpid, &WNOHANG)==-1) { foreach my $file ($toperl, $fromperl, $toflag, - $fromflag, $doneflag) { + $fromflag, $doneflag, $pipe) { unlink $file while -e $file; } undef $latexpid; @@ -2322,7 +2395,8 @@ while (1) { % we now write |$result| (which contains either the result of executing % the user's or a |\PackageError|) to the |$fromperl| file, delete % |$toflag|, |$toperl|, and |$doneflag|, and notify \LaTeX{} by touching -% the |$fromflag| file. +% the |$fromflag| file. As a performance optimization, we also write +% |\endinput| into |$pipe| to wake up the |latex| process. % \begin{macrocode} open (FROMPERL, ">$fromperl") || die "open($fromperl): $!\n"; syswrite FROMPERL, $result; @@ -2337,6 +2411,12 @@ while (1) { open (FROMFLAG, ">$fromflag") || die "open($fromflag): $!\n"; close FROMFLAG; % \end{macrocode} +% \begin{macrocode} + if (open (PIPE, ">$pipe")) { + print PIPE "\\endinput\n"; + close PIPE; + } +% \end{macrocode} % % We have to perform one final \LaTeX-to-Perl synchronization step. % Otherwise, a subsequent |\perl|[|re|]|newcommand| would see that @@ -2347,6 +2427,13 @@ while (1) { unlink $fromflag while -e $fromflag; open (DONEFLAG, ">$doneflag") || die "open($doneflag): $!\n"; close DONEFLAG; +% \end{macrocode} +% Again, we awaken the |latex| process, which is blocked on |$pipe|. +% \begin{macrocode} + if (open (PIPE, ">$pipe")) { + print PIPE "\\endinput\n"; + close PIPE; + } } % \end{macrocode} % @@ -2468,7 +2555,7 @@ perltex [B<--latex>=I<program>] [B<-->[B<no>]B<safe>] [B<--permit>=I<feature>] -[B<--makesty] +[B<--makesty>] [I<latex options>] @@ -2511,17 +2598,17 @@ B<pdflatex> instead of ordinary B<latex>. =item B<-->[B<no>]B<safe> -Enable or disable sandboxing. With the default of C<--safe>, +Enable or disable sandboxing. With the default of B<--safe>, B<perltex> executes the code from a C<\perlnewcommand> or C<\perlrenewcommand> macro within a protected environment that prohibits ``unsafe'' operations such as accessing files or executing -external programs. Specifying C<--nosafe> gives the LaTeX document +external programs. Specifying B<--nosafe> gives the LaTeX document I<carte blanche> to execute any arbitrary Perl code, including that which can harm the user's files. See L<Safe> for more information. =item B<--permit>=I<feature> -Permit particular Perl operations to be performed. The C<--permit> +Permit particular Perl operations to be performed. The B<--permit> 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. @@ -2551,7 +2638,7 @@ In its simplest form, B<perltex> is run just like B<latex>: perltex myfile.tex -To use B<pdflatex> instead of regular B<latex>, use the C<--latex> +To use B<pdflatex> instead of regular B<latex>, use the B<--latex> option: perltex --latex=pdflatex myfile.tex @@ -2559,7 +2646,7 @@ option: If LaTeX gives a ``C<trapped by operation mask>'' error and you trust the F<.tex> file you're trying to compile not to execute malicious Perl code (e.g., because you wrote it yourself), you can disable -B<perltex>'s safety mechansisms with C<--nosafe>: +B<perltex>'s safety mechansisms with B<--nosafe>: perltex --nosafe myfile.tex @@ -2581,7 +2668,7 @@ B<perltex> honors the following environment variables: Specify the filename of the LaTeX compiler. The LaTeX compiler defaults to ``C<latex>''. The C<PERLTEX> environment variable -overrides this default, and the C<--latex> command-line option (see +overrides this default, and the B<--latex> command-line option (see L</OPTIONS>) overrides that. =back diff --git a/Master/texmf-dist/source/latex/perltex/perltex.ins b/Master/texmf-dist/source/latex/perltex/perltex.ins index 528c2576e02..256d0e34ed4 100644 --- a/Master/texmf-dist/source/latex/perltex/perltex.ins +++ b/Master/texmf-dist/source/latex/perltex/perltex.ins @@ -1,5 +1,5 @@ %% -%% Copyright (C) 2007, Scott Pakin <scott+pt@pakin.org> +%% Copyright (C) 2007 Scott Pakin <scott+pt@pakin.org> %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3c of this license @@ -21,7 +21,7 @@ This is a generated file. -Copyright (C) 2007, Scott Pakin <scott+pt@pakin.org> +Copyright (C) 2007 Scott Pakin <scott+pt@pakin.org> This file may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3c of this license |