| 1 |
%\iffalse |
| 2 |
% makedtx.dtx generated using makedtx version 1.3 (c) Nicola Talbot |
| 3 |
% Command line args: |
| 4 |
% -v |
| 5 |
% --macrocode "makedtx\.pl\$" |
| 6 |
% --comment "makedtx\.pl\$" |
| 7 |
% --src "CHANGES\.org\$=>CHANGES.org" |
| 8 |
% --macrocode "CHANGES\.org\$" |
| 9 |
% --comment "CHANGES\.org\$" |
| 10 |
% --src "makedtx-version\.tex\$=>makedtx-version.tex" |
| 11 |
% --macrocode "makedtx-version\.tex\$" |
| 12 |
% --comment "makedtx-version\.tex\$" |
| 13 |
% --src "latexmkrc\.pl\$=>latexmkrc.pl" |
| 14 |
% --macrocode "latexmkrc\.pl\$" |
| 15 |
% --comment "latexmkrc\.pl\$" |
| 16 |
% --src "creatdtx\.sty\$=>creatdtx.sty" |
| 17 |
% --src "makedtx\.pl\$=>makedtx.pl" |
| 18 |
% --doc makedtx.tex |
| 19 |
% "\.pl\$=>\nopreamble\nopostamble" |
| 20 |
% --author |
| 21 |
% "Nicola L.C. Talbot" |
| 22 |
% makedtx |
| 23 |
% --setamble |
| 24 |
% Created on 2026/2/16 0:26 |
| 25 |
%\fi |
| 26 |
%\iffalse |
| 27 |
%<*package> |
| 28 |
%% \CharacterTable |
| 29 |
%% {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 |
| 30 |
%% Lower-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 |
| 31 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 32 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 33 |
%% Dollar \$ Percent \% Ampersand \& |
| 34 |
%% Acute accent \' Left paren \( Right paren \) |
| 35 |
%% Asterisk \* Plus \+ Comma \, |
| 36 |
%% Minus \- Point \. Solidus \/ |
| 37 |
%% Colon \: Semicolon \; Less than \< |
| 38 |
%% Equals \= Greater than \> Question mark \? |
| 39 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 40 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 41 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 42 |
%% Right brace \} Tilde \~} |
| 43 |
%</package> |
| 44 |
%\fi |
| 45 |
% \iffalse |
| 46 |
% Doc-Source file to use with LaTeX2e |
| 47 |
% Copyright (C) 2026 Nicola L.C. Talbot, all rights reserved. |
| 48 |
% \fi |
| 49 |
% \iffalse |
| 50 |
%<*driver> |
| 51 |
\documentclass[a4paper,english]{ltxdoc} |
| 52 |
|
| 53 |
\usepackage[colorlinks, |
| 54 |
bookmarks, |
| 55 |
hyperindex=false, |
| 56 |
bookmarksopen, |
| 57 |
pdfauthor={Nicola Talbot}, |
| 58 |
pdftitle={makedtx : a Perl script to help create a DTX file from source code}]{hyperref} |
| 59 |
|
| 60 |
\usepackage{datetime2} |
| 61 |
\DTMsetstyle{english} |
| 62 |
|
| 63 |
|
| 64 |
\renewcommand*\main[1]{#1} |
| 65 |
\newcommand{\see}[2]{\emph{see} #1} |
| 66 |
\makeatletter |
| 67 |
\def\index@prologue{\section*{Index}} |
| 68 |
\makeatother |
| 69 |
\RecordChanges |
| 70 |
\PageIndex |
| 71 |
\newcommand{\latextohtml}{\LaTeX2HTML} |
| 72 |
\newcommand{\switch}[1]{\texttt{-#1}\index{makedtx switches=\texttt{makedtx} switches>#1=\texttt{-#1}|hdpindex{main}}} |
| 73 |
\newcommand{\ics}[1]{\cs{#1}\SpecialMainIndex{#1}} |
| 74 |
\CheckSum{8} |
| 75 |
|
| 76 |
\newcommand{\PDFLaTeX}{PDF\LaTeX} |
| 77 |
\DTMsavedate{makedtx-date}{2018-02-19} |
| 78 |
|
| 79 |
\input{makedtx-version} |
| 80 |
\begin{document} |
| 81 |
\DocInput{makedtx.dtx} |
| 82 |
\end{document} |
| 83 |
%</driver> |
| 84 |
%\fi |
| 85 |
% |
| 86 |
%\title{makedtx \version : a Perl script to help create a DTX |
| 87 |
%file from source code} |
| 88 |
%\author{Nicola Talbot\\ |
| 89 |
%\url{http://theoval.cmp.uea.ac.uk/~nlct/}} |
| 90 |
%\date{\DTMusedate{makedtx-date}} |
| 91 |
%\maketitle |
| 92 |
% |
| 93 |
%\tableofcontents |
| 94 |
% |
| 95 |
%\begin{abstract} |
| 96 |
%The \texttt{makedtx} bundle is provided to help developers to write |
| 97 |
%the code and documentation in separate files, and then combine them |
| 98 |
%into a single DTX file for distribution. It automatically generates |
| 99 |
%the character table, and also writes the associated installation |
| 100 |
%(.ins) script. |
| 101 |
%\end{abstract} |
| 102 |
% |
| 103 |
%\section{Introduction} |
| 104 |
% |
| 105 |
%\changes{0.9}{2005/02/11}{Initial beta release}% |
| 106 |
%Authors of \LaTeXe\ class files or packages are encouraged to bundle |
| 107 |
%their source and documentation together into a single DTX file. This |
| 108 |
%makes distribution much easier, as users need only download the DTX |
| 109 |
%file and possibly a corresponding installation script (INS file) |
| 110 |
%instead of a multitude of \texttt{.sty}, \texttt{.cls}, \texttt{.def} |
| 111 |
%etc files. However, having the documentation and code bundled |
| 112 |
%together can cause problems if a developer wants to, say, use |
| 113 |
%\texttt{ispell} to spell check the documentation, or convert the |
| 114 |
%documentation to a format other than DVI, PostScript or PDF (such as |
| 115 |
%HTML). |
| 116 |
% |
| 117 |
%Why should I want to convert my documentation to HTML when I can just |
| 118 |
%use \PDFLaTeX? The more general purpose packages that I write (such |
| 119 |
%as \texttt{datetime} and \texttt{glossary}) I upload to CTAN, however |
| 120 |
%most of the packages I write are specific to the School of Computing |
| 121 |
%Sciences at the University of East Anglia, so these I keep on my web |
| 122 |
%site, and as some of the faculty either don't have a PDF plug in or |
| 123 |
%prefer to view HTML rather than PDF documents, I have taken to writing |
| 124 |
%both PDF and HTML versions of my package documentation. However, |
| 125 |
%\latextohtml\ doesn't work on a \texttt{.dtx} file so I used to |
| 126 |
%convert them manually which is fine for one or two small documents, |
| 127 |
%but becomes rather cumbersome as soon as I have large documents or a |
| 128 |
%lot of packages. Therefore I decided to write the documentation |
| 129 |
%separately, and use a Perl script to bundle everything together. It |
| 130 |
%also has the added convenience in that I don't have to keep copying |
| 131 |
%and pasting the character table every time I write a new package, and |
| 132 |
%it saves the laborious task of writing the installation |
| 133 |
%script\footnote{or at least, it's laborious if there are rather a lot |
| 134 |
%of files associated with a package}. |
| 135 |
% |
| 136 |
%This document is structured as follows: Section~\ref{sec:install} |
| 137 |
%describes how to install the \texttt{makedtx} bundle, |
| 138 |
%Section~\ref{sec:makedtx} gives an overview of the \texttt{makedtx.pl} |
| 139 |
%Perl script, Section~\ref{sec:creatdtx} describes the |
| 140 |
%\texttt{creatdtx} package, Section~\ref{sec:examples} illustrates the |
| 141 |
%use of the \texttt{makedtx} bundle with examples and |
| 142 |
%Section~\ref{sec:problems} gives a list of possible errors and their |
| 143 |
%solutions. |
| 144 |
% |
| 145 |
%\section{Installation}\label{sec:install} |
| 146 |
% |
| 147 |
%You need to download both \texttt{makedtx.dtx} and |
| 148 |
%\texttt{makedtx.ins}, and run the installation script through |
| 149 |
%\LaTeX:\par \texttt{latex makedtx.ins} |
| 150 |
% |
| 151 |
%The following files will be created: |
| 152 |
%\begin{description} |
| 153 |
%\item[\texttt{makedtx.pl}] Perl script |
| 154 |
%\item[\texttt{creatdtx.sty}] \LaTeX\ package for use with \texttt{makedtx.pl} |
| 155 |
%\item[\texttt{creatdtx.perl}] Corresponding Perl script for use with LaTeX2HTML |
| 156 |
%\end{description} |
| 157 |
% |
| 158 |
%If you are using UNIX/Linux etc you will need to make |
| 159 |
%\texttt{makedtx.pl} executable using |
| 160 |
%\texttt{chmod}:\par\vspace{6pt}\noindent\texttt{chmod a+x |
| 161 |
%makedtx.pl}\par\vspace{6pt}\noindent and place it somewhere on your |
| 162 |
%path. If \texttt{perl} is located somewhere other than |
| 163 |
%\texttt{/usr/bin/} you will need to edit the first line of |
| 164 |
%\texttt{makedtx.pl}. (If you don't know where \texttt{perl} is |
| 165 |
%located, you can use the command: \texttt{which perl}.) The package |
| 166 |
%\texttt{creatdtx.sty} needs to be placed somewhere on the \LaTeX\ path |
| 167 |
%and \texttt{creatdtx.perl} should be placed in a directory searched by |
| 168 |
%\latextohtml. (See the \latextohtml\ documentation for details.) |
| 169 |
% |
| 170 |
%\section{makedtx.pl}\label{sec:makedtx} |
| 171 |
% |
| 172 |
%The Perl script \texttt{makedtx.pl} has the following syntax:\par |
| 173 |
%\texttt{makedtx.pl} \oarg{options} \switch{src} |
| 174 |
%\texttt{"}\meta{expr1}\verb|=>|\meta{expr2}\texttt{"} |
| 175 |
%\switch{doc} \meta{filename} \meta{basename} |
| 176 |
% |
| 177 |
%\subsection{Compulsory Arguments} |
| 178 |
% |
| 179 |
%The very last argument \meta{basename} is the basename of the |
| 180 |
%\texttt{.dtx} and \texttt{.ins} files you want to create. The |
| 181 |
%\switch{doc} \meta{filename} switch indicates the file containing the |
| 182 |
%documentation and \switch{src} |
| 183 |
%\verb!"!\meta{expr1}\verb+=>+\meta{expr2}\verb'"' indicates the |
| 184 |
%original source file(s), given by \meta{expr1}, and the corresponding |
| 185 |
%file name when it has been extracted from the \texttt{.dtx} file, |
| 186 |
%given by \meta{expr2}. This switch is a little complicated, so it's |
| 187 |
%best described using examples. |
| 188 |
% |
| 189 |
%Suppose you have your documentation in the file \texttt{foodoc.tex}, |
| 190 |
%and the original source code is in the file \texttt{foosrc.sty}. You |
| 191 |
%want to create the files \texttt{foo.dtx} and \texttt{foo.ins}. When |
| 192 |
%you \LaTeX\ \texttt{foo.dtx} you want the documentation as specified |
| 193 |
%in \texttt{foodoc.tex} and when you \LaTeX\ \texttt{foo.ins} you want |
| 194 |
%the file \texttt{foo.sty} to be created, using the code specified in |
| 195 |
%\texttt{foosrc.sty}. You will need to do: |
| 196 |
%\begin{verbatim} |
| 197 |
%makedtx.pl -src "foosrc\.sty=>foo.sty" -doc foodoc.tex foo |
| 198 |
%\end{verbatim} |
| 199 |
% |
| 200 |
%You may have multiple invocations of the \switch{src} switch. For |
| 201 |
%example, suppose you also have the file \texttt{barsrc.sty} which you |
| 202 |
%want to be extracted from the \texttt{.dtx} file as \texttt{bar.sty}, |
| 203 |
%you can do: |
| 204 |
%\begin{verbatim} |
| 205 |
%makedtx.pl -src "foosrc\.sty=>foo.sty" -src "barsrc\.sty=>bar.sty" -doc foodoc.tex foo |
| 206 |
%\end{verbatim} |
| 207 |
%Alternatively, you can use Perl-type regular expressions: |
| 208 |
%\begin{verbatim} |
| 209 |
%makedtx.pl -src "(.*)src\.sty=>\1.sty" -doc foodoc.tex foo |
| 210 |
%\end{verbatim} |
| 211 |
%(Note the use of double quotes to prevent shell expansion.) |
| 212 |
%Appendix~\ref{sec:prex} gives a brief overview of Perl regular |
| 213 |
%expressions for the uninitiated. |
| 214 |
% |
| 215 |
%\subsection{Options} |
| 216 |
% |
| 217 |
%\begin{description} |
| 218 |
%\item[\switch{h} or \switch{help}] Prints on-line help, and exits. |
| 219 |
% |
| 220 |
%\item[\switch{version}] Prints version number, and exits. |
| 221 |
%\changes{0.93}{2007/08/02}{version switch added}% |
| 222 |
% |
| 223 |
%\item[\switch{v}] Uses verbose mode. |
| 224 |
% |
| 225 |
%\item[\switch{dir} \meta{name}] Specifies directory containing source |
| 226 |
%files, as specified by the \switch{src} switch. For example, suppose |
| 227 |
%you have source files \texttt{foo.sty}, \texttt{bar.sty} in the |
| 228 |
%subdirectory \texttt{sourcefiles} you can do: |
| 229 |
%\begin{verbatim} |
| 230 |
%makedtx.pl -dir sourcefiles -src "(.*)\.sty=>\1.sty" -doc foodoc.tex foo |
| 231 |
%\end{verbatim} |
| 232 |
% |
| 233 |
%\item[\switch{op} \meta{character}] sets the Perl pattern matching |
| 234 |
%operator (the default is set to \texttt{=} symbol since the \texttt{/} |
| 235 |
%character is used as the directory divider). |
| 236 |
% |
| 237 |
%\item[\switch{askforoverwrite}] uses \ics{askforoverwritetrue} in |
| 238 |
%the installation script. |
| 239 |
% |
| 240 |
%\item[\switch{noaskforoverwrite}] uses \ics{askforoverwritefalse} |
| 241 |
%in the installation script (default). |
| 242 |
% |
| 243 |
%\item[\switch{noins}] Don't create the installation script |
| 244 |
%(\texttt{.ins} file). This is useful if you want to tweak the file |
| 245 |
%manually and you don't want your modifications overwritten. |
| 246 |
% |
| 247 |
%\item[\switch{preamble} \meta{text}] Set the preamble to |
| 248 |
%\texttt{text}. The default preamble is:\par |
| 249 |
%\changes{0.94}{2007/08/19}{default preamble changed to one |
| 250 |
%conforming with the LPPL}% |
| 251 |
%\begin{ttfamily}\obeylines |
| 252 |
% \meta{basename}.dtx |
| 253 |
% Copyright \meta{date} \meta{author} |
| 254 |
% |
| 255 |
% This work may be distributed and/or modified under the |
| 256 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 257 |
% of this license of (at your option) any later version. |
| 258 |
% The latest version of this license is in |
| 259 |
% http://www.latex-project.org/lppl.txt |
| 260 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 261 |
% version 2005/12/01 or later. |
| 262 |
% |
| 263 |
% This work has the LPPL maintenance status `maintained'. |
| 264 |
% |
| 265 |
% The Current Maintainer of this work is \meta{author}. |
| 266 |
% |
| 267 |
% This work consists of the files \meta{basename}.dtx and |
| 268 |
% \meta{basename}.ins and the derived files \meta{file list}. |
| 269 |
%\end{ttfamily} |
| 270 |
% |
| 271 |
%where \meta{date} is the copyright date, and \meta{author} is the |
| 272 |
%author's name (see below). |
| 273 |
% |
| 274 |
%\textbf{Note that this has been changed as of makedtx v0.94. |
| 275 |
%Older versions of makedtx do not conform to any of the free |
| 276 |
%licenses.} |
| 277 |
% |
| 278 |
%\item[\switch{license} \meta{name}] |
| 279 |
%\changes{0.94}{2007/08/19}{license switch added}% |
| 280 |
%This sets the preamble to |
| 281 |
%the license text for the license \meta{name}. Currently \meta{name} |
| 282 |
%may be either \texttt{lppl} (the default, which produces the |
| 283 |
%default preamble detailed above), \texttt{bsd} or \texttt{gpl}. |
| 284 |
%You may use either \switch{license} or \switch{preamble}, |
| 285 |
%but not both. (If you have used the \switch{preamble} switch, the |
| 286 |
%\switch{license} switch will be ignored.) |
| 287 |
% |
| 288 |
%\item[\switch{postamble} \meta{text}] Set the postamble to |
| 289 |
%\texttt{text}. If this is omitted the \ics{postamble} command is |
| 290 |
%omitted from the installation script. |
| 291 |
% |
| 292 |
%\item[\switch{author} \meta{name}] The author's name (as used in the |
| 293 |
%default preamble). If omitted the user's name is used. |
| 294 |
% |
| 295 |
%\item[\switch{date} \meta{text}] The copyright date (as used in the |
| 296 |
%default preamble). If omitted the current year is used. |
| 297 |
% |
| 298 |
%\item[\switch{stopeventually} \meta{text}] Insert \meta{text} into the |
| 299 |
%argument of \ics{StopEventually}. For example: |
| 300 |
%\verb+-stopeventually "\\PrintIndex"+ will result in the line: |
| 301 |
%\cs{StopEventually}\verb"{\PrintIndex}". If \texttt{makedtx.pl} |
| 302 |
%encounters a \cs{StopEventually} command within the document, |
| 303 |
%this will be used instead. If there is no \cs{StopEventually} |
| 304 |
%command in the document and the \switch{stopeventually} switch is |
| 305 |
%absent \cs{StopEventually}\marg{} will be inserted in the DTX |
| 306 |
%file. |
| 307 |
% |
| 308 |
%\item[\switch{prefinale} \meta{text}] |
| 309 |
%\changes{0.91}{2006/07/21}{prefinale switch added}% |
| 310 |
%Inset \meta{text} immediately prior to \cs{Finale} |
| 311 |
%in the dtx file. |
| 312 |
% |
| 313 |
%\item[\switch{setambles} \texttt{"}\meta{expr}\texttt{=\symbol{62}}\meta{text}\texttt{"}] |
| 314 |
%Sets the pre- and postambles for files matching \meta{expr} within the |
| 315 |
%\cs{file} command in the installation script. To illustrate this, |
| 316 |
%let's suppose you have source files \texttt{foo.sty}, \texttt{bar.sty} |
| 317 |
%and \texttt{foobar.pl} in the subdirectory \texttt{sourcefiles}. |
| 318 |
%Since \texttt{foo.sty} and \texttt{bar.sty} are \LaTeX\ files, they |
| 319 |
%should have pre- and postambles, but \texttt{foobar.pl} is a Perl |
| 320 |
%file, and since the percent symbol (\%) is not a comment character in |
| 321 |
%Perl, there should be no pre- and postambles for this file. Therefore |
| 322 |
%you would need to do something like: |
| 323 |
%\begin{verbatim} |
| 324 |
%makedtx.pl -dir sourcefiles -src "(.*)\.sty=>\1.sty" -src "foobar.pl=>foobar.pl" |
| 325 |
%-setambles "foobar\.pl=>\\nopreamble\\nopostamble" -doc foodoc.tex foo |
| 326 |
%\end{verbatim} |
| 327 |
%(Note that the line is only broken to fit it onto the page, and there |
| 328 |
%should be no line break when entering at the command prompt.) |
| 329 |
% |
| 330 |
%If the argument to \switch{setambles} contains the string |
| 331 |
%\verb"\\nopreamble", the character table will be excluded from the |
| 332 |
%corresponding files. So, in the above example, when you do: |
| 333 |
%\verb"latex foo.ins" the resulting files \texttt{foo.sty} and |
| 334 |
%\texttt{bar.sty} will contain the character table, but |
| 335 |
%\texttt{foobar.pl} won't. (If for some reason you don't want a |
| 336 |
%preamble but you do want the character table included use |
| 337 |
%\verb"\\usepreamble\\empty" instead of \verb'\\nopreamble'. |
| 338 |
%Conversely, if you want a preamble but don't want the character table |
| 339 |
%do something like \verb"\\nopreamble\\usepreamble\\defaultpreamble". |
| 340 |
% |
| 341 |
%Note that the \verb"=>"\meta{text} part is optional. If it is |
| 342 |
%omitted, \meta{text} is assumed to be empty. |
| 343 |
% |
| 344 |
%\item[\switch{macrocode} \texttt{"}\meta{expr}\texttt{"}] If source |
| 345 |
%file matches the Perl regular expression given by \meta{expr}, the |
| 346 |
%source code is inserted into a \texttt{macrocode} environment in the |
| 347 |
%DTX file. |
| 348 |
% |
| 349 |
%Please note that the source code is supposed to be text insensitive to end of line format, as a matter of fact |
| 350 |
%\texttt{makedtx.pl} will convert all end of lines of this source code to LF's. |
| 351 |
% |
| 352 |
%Please note also that only the source files given by the \switch{src} switch are considered, the |
| 353 |
%\switch{macrocode} switch by itself does not cause the source file to be insterted into the DTX file, it only |
| 354 |
%affects \emph{how} it is inserted. |
| 355 |
% |
| 356 |
%\item[\switch{comment} \texttt{"}\meta{expr}\texttt{"}] |
| 357 |
%\changes{0.93}{2007/08/02}{comment switch added}% |
| 358 |
%If the source file matches the Perl regular expression given by |
| 359 |
%\meta{expr}, the source code will be inserted between \cs{iffalse} |
| 360 |
%\cs{fi} commands. The contents of this file will be included in the |
| 361 |
%DTX file, but will be excluded from the documentation. Since this |
| 362 |
%is provided mainly for non-TeX files (such as Perl scripts) the |
| 363 |
%\switch{comment} switch will typically need to be used in conjunction |
| 364 |
%with \switch{macrocode}. |
| 365 |
% |
| 366 |
%\item[\switch{codetitle} \texttt{"}\meta{title}\texttt{"}] |
| 367 |
%\changes{0.93}{2007/08/02}{Added codetitle switch}% |
| 368 |
%This sets the title for the code section. The default is |
| 369 |
%\texttt{The Code}. |
| 370 |
% |
| 371 |
%\item[\switch{nodrivendoc}] |
| 372 |
%\changes{1.3}{2026/02/13}{Added nodrivendoc switch}% |
| 373 |
%This places the documentation body inside the driver block, as is ie.\ without commenting each line with a leading |
| 374 |
%\texttt{\%}, instead of placing it after the driver block as a docstrippable \LaTeX\ code, ie. with inserting a leading |
| 375 |
%\texttt{\%} comment mark into each line. The default is driven documentation body, i.e. this switch not active by |
| 376 |
%default. |
| 377 |
% |
| 378 |
%\item[\switch{drivendoc}] |
| 379 |
%\changes{1.3}{2026/02/13}{Added drivendoc switch}% |
| 380 |
%This is the opposite of the \texttt{-nodrivendoc} switch. This switch is active by default --- ie. documentation body is |
| 381 |
%read by \ics{DocInput} rather than being right in the driver block. |
| 382 |
% |
| 383 |
%\end{description} |
| 384 |
% |
| 385 |
%\section{The creatdtx Package} |
| 386 |
%\label{sec:creatdtx} |
| 387 |
% |
| 388 |
%The documentation source code, as specified using the \switch{doc} |
| 389 |
%switch will typically be a standard \LaTeX\ document using the |
| 390 |
%\texttt{ltxdoc} class file. Unlike the DTX file, there is no |
| 391 |
%\ics{DocInput} command, and the lines do not begin with a percent |
| 392 |
%symbol, which means that the document can be, say, passed to the |
| 393 |
%\latextohtml\ converter, or some other application that would |
| 394 |
%otherwise be confused by a DTX file. The \texttt{creatdtx} package |
| 395 |
%can be used in this document using |
| 396 |
%\begin{verbatim} |
| 397 |
%\usepackage{creatdtx} |
| 398 |
%\end{verbatim} |
| 399 |
%although this package will be not be included in the DTX file by |
| 400 |
%\texttt{makedtx.pl}. There is only one command defined in this |
| 401 |
%package:\ics{ifmakedtx}\marg{dtx text}\marg{non dtx text}. The first |
| 402 |
%argument \meta{dtx text} will be copied to the DTX file by |
| 403 |
%\texttt{makedtx.pl}, but the second argument \meta{non dtx text} |
| 404 |
%won't. However, if you \LaTeX\ the document, the first argument will |
| 405 |
%be ignored, and the second argument will be used. |
| 406 |
% |
| 407 |
%For example, if your code (in \texttt{foodoc.tex}) contains the |
| 408 |
%line:\par\vspace{6pt}\noindent\texttt{\cs{ifmakedtx}\{\}\{\cs{usepackage}\{html\}\}} |
| 409 |
%\par\vspace{6pt}\noindent the \texttt{html} package will only be |
| 410 |
%loaded if you \LaTeX\ \texttt{foodoc.tex}, but not when you \LaTeX\ |
| 411 |
%\texttt{foo.dtx}. |
| 412 |
% |
| 413 |
%The Perl script \texttt{creatdtx.perl} ignores the following commands |
| 414 |
%(and any associated arguments): \ics{OnlyDescription}, |
| 415 |
%\ics{RecordChanges}, \ics{MakeShortVerb}, \ics{DeleteShortVerb}, |
| 416 |
%\ics{DoNotIndex}, \ics{EnableCrossrefs}, \ics{CodelineIndex}, |
| 417 |
%\ics{GetFileInfo}, \ics{PrintChanges}, \ics{changes}, \ics{CheckSum}, |
| 418 |
%\ics{DescribeMacro} and \ics{DescribeEnvironment}. So even if you don't |
| 419 |
%use the \cs{ifmakedtx} command, using the \texttt{creatdtx} package |
| 420 |
%will help ensure that extraneous text does not appear in the HTML |
| 421 |
%document when using \latextohtml. |
| 422 |
% |
| 423 |
%As from version 0.93b, \texttt{creatdtx.perl} also defines the |
| 424 |
%commands \ics{cs}, \ics{marg}, \ics{oarg} and \ics{parg}, since there |
| 425 |
%is no \latextohtml\ implementation of the \texttt{ltxdoc} class file. |
| 426 |
% |
| 427 |
%\section{Examples} |
| 428 |
%\label{sec:examples} |
| 429 |
% |
| 430 |
%Let's first consider a very simple example. Suppose you want to |
| 431 |
%create a package that redefines \cs{today} so that the date is |
| 432 |
%displayed in the form: yyyy-m-d. Let's call this package |
| 433 |
%\texttt{dashdate}. The file \texttt{dashdate.sty} should look |
| 434 |
%something like: |
| 435 |
%\begin{verbatim} |
| 436 |
% % First define package: |
| 437 |
% % \begin{macrocode} |
| 438 |
% \NeedsTeXFormat{LaTeX2e} |
| 439 |
% \ProvidesPackage{dashdate} |
| 440 |
% % \end{macrocode} |
| 441 |
% % Redefine |\today| command: |
| 442 |
% % \begin{macrocode} |
| 443 |
% \renewcommand{\today}{\the\year-\the\month-\the\day} |
| 444 |
% % \end{macrocode} |
| 445 |
%\end{verbatim} |
| 446 |
%Now let's make some (very brief) documentation. Let's call the file, |
| 447 |
%say \texttt{manual.tex}\footnote{Note: if you want to use |
| 448 |
%\latextohtml\ on this document, you will need to use, e.g., |
| 449 |
%\cs{verb}\texttt{!\cs{today}!} instead of |
| 450 |
%\texttt{\symbol{124}\cs{today}\symbol{124}} since it doesn't recognise |
| 451 |
%\ics{MakeShortVerb}.}: |
| 452 |
%\begin{verbatim} |
| 453 |
%\documentclass{ltxdoc} |
| 454 |
%\usepackage{creatdtx} |
| 455 |
% |
| 456 |
%\begin{document} |
| 457 |
%\title{A Sample Package} |
| 458 |
%\author{AN Other} |
| 459 |
%\maketitle |
| 460 |
% |
| 461 |
%The \texttt{dashdate} package redefines |\today| |
| 462 |
%to produce the current date in the form: yyyy-m-d. |
| 463 |
%\end{document} |
| 464 |
%\end{verbatim} |
| 465 |
%Suppose you have saved \texttt{dashdate.sty} and \texttt{manual.tex} |
| 466 |
%in the subdirectory \texttt{source}. You can now create the |
| 467 |
%\texttt{.dtx} and \texttt{.ins} file using the command: |
| 468 |
%\begin{verbatim} |
| 469 |
%makedtx.pl -author "AN Other" -dir source -src "dashdate\.sty=>dashdate.sty" |
| 470 |
%-doc source/manual.tex dashdate |
| 471 |
%\end{verbatim} |
| 472 |
%The file \texttt{dashdate.dtx} is created, and contains the following |
| 473 |
%code: |
| 474 |
%\begin{verbatim} |
| 475 |
% %\iffalse |
| 476 |
% % dashdate.dtx generated using makedtx.pl version 0.9b (c) Nicola Talbot |
| 477 |
% % Command line args: |
| 478 |
% % -dir "source" |
| 479 |
% % -src "dashdate\.sty=>dashdate.sty" |
| 480 |
% % -author "AN Other" |
| 481 |
% % -doc "source/manual.tex" |
| 482 |
% % dashdate |
| 483 |
% % Created on 2005/2/10 22:22 |
| 484 |
% %\fi |
| 485 |
% %\iffalse |
| 486 |
% %<*package> |
| 487 |
% %% \CharacterTable |
| 488 |
% %% {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 |
| 489 |
% %% Lower-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 |
| 490 |
% %% Digits \0\1\2\3\4\5\6\7\8\9 |
| 491 |
% %% Exclamation \! Double quote \" Hash (number) \# |
| 492 |
% %% Dollar \$ Percent \% Ampersand \& |
| 493 |
% %% Acute accent \' Left paren \( Right paren \) |
| 494 |
% %% Asterisk \* Plus \+ Comma \, |
| 495 |
% %% Minus \- Point \. Solidus \/ |
| 496 |
% %% Colon \: Semicolon \; Less than \< |
| 497 |
% %% Equals \= Greater than \> Question mark \? |
| 498 |
% %% Commercial at \@ Left bracket \[ Backslash \\ |
| 499 |
% %% Right bracket \] Circumflex \^ Underscore \_ |
| 500 |
% %% Grave accent \` Left brace \{ Vertical bar \| |
| 501 |
% %% Right brace \} Tilde \~} |
| 502 |
% %</package> |
| 503 |
% %\fi |
| 504 |
% % \iffalse |
| 505 |
% % Doc-Source file to use with LaTeX2e |
| 506 |
% % Copyright (C) 2005 AN Other, all rights reserved. |
| 507 |
% % \fi |
| 508 |
% % \iffalse |
| 509 |
% %<*driver> |
| 510 |
% \documentclass{ltxdoc} |
| 511 |
% |
| 512 |
% \begin{document} |
| 513 |
% \DocInput{dashdate.dtx} |
| 514 |
% \end{document} |
| 515 |
% %</driver> |
| 516 |
% %\fi |
| 517 |
% %\title{A Sample Package} |
| 518 |
% %\author{AN Other} |
| 519 |
% %\maketitle |
| 520 |
% % |
| 521 |
% %The \texttt{dashdate} package redefines "\today" |
| 522 |
% %to produce the current date in the form: yyyy-m-d. |
| 523 |
% %\end{document} |
| 524 |
% % |
| 525 |
% %\StopEventually{} |
| 526 |
% %\section{The Code} |
| 527 |
% %\iffalse |
| 528 |
% % \begin{macrocode} |
| 529 |
% %<*dashdate.sty> |
| 530 |
% % \end{macrocode} |
| 531 |
% %\fi |
| 532 |
% % First define package: |
| 533 |
% % \begin{macrocode} |
| 534 |
% \NeedsTeXFormat{LaTeX2e} |
| 535 |
% \ProvidesPackage{dashdate} |
| 536 |
% % \end{macrocode} |
| 537 |
% % Redefine |\today| command: |
| 538 |
% % \begin{macrocode} |
| 539 |
% \renewcommand{\today}{\the\year-\the\month-\the\day} |
| 540 |
% % \end{macrocode} |
| 541 |
% %\iffalse |
| 542 |
% % \begin{macrocode} |
| 543 |
% %</dashdate.sty> |
| 544 |
% % \end{macrocode} |
| 545 |
% %\fi |
| 546 |
% %\Finale |
| 547 |
% \endinput |
| 548 |
%\end{verbatim} |
| 549 |
%The installation file \texttt{dashdate.ins} looks like: |
| 550 |
%\begin{verbatim} |
| 551 |
% % dashdate.ins generated using makedtx.pl version 0.94b 2007/8/19 22:22 |
| 552 |
% \input docstrip |
| 553 |
% |
| 554 |
% \preamble |
| 555 |
% dashdate.dtx |
| 556 |
% Copyright 2007 AN Other |
| 557 |
% |
| 558 |
% This work may be distributed and/or modified under the |
| 559 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 560 |
% of this license of (at your option) any later version. |
| 561 |
% The latest version of this license is in |
| 562 |
% http://www.latex-project.org/lppl.txt |
| 563 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 564 |
% version 2005/12/01 or later. |
| 565 |
% |
| 566 |
% This work has the LPPL maintenance status `maintained'. |
| 567 |
% |
| 568 |
% The Current Maintainer of this work is AN Other. |
| 569 |
% |
| 570 |
% This work consists of the files dashdate.dtx and |
| 571 |
% dashdate.ins and the derived file dashdate.sty. |
| 572 |
% \endpreamble |
| 573 |
% |
| 574 |
% \askforoverwritefalse |
| 575 |
% |
| 576 |
% \generate{\file{dashdate.sty}{\usepreamble\defaultpreamble |
| 577 |
% \usepostamble\defaultpostamble\from{dashdate.dtx}{dashdate.sty,package}} |
| 578 |
% } |
| 579 |
% |
| 580 |
% \endbatchfile |
| 581 |
%\end{verbatim} |
| 582 |
%Note that the command \verb"\usepackage{creatdtx}" has not been |
| 583 |
%transcribed to \texttt{dashdate.dtx} (although in this simple example |
| 584 |
%it's not really needed). |
| 585 |
% |
| 586 |
%Now let's extend the example: suppose you want to create an analogous |
| 587 |
%Perl script for use with \latextohtml. This will need to be called |
| 588 |
%\texttt{dashdate.perl} and will look something like: |
| 589 |
%\begin{verbatim} |
| 590 |
%package main; |
| 591 |
% |
| 592 |
%sub do_cmd_today{ |
| 593 |
% local($_) = @_; |
| 594 |
% local($today) = &get_date(); |
| 595 |
% $today =~ s|(\d+)/(\d+)/(\d+)|$3-$1-$2|; |
| 596 |
% "$today$_"; |
| 597 |
%} |
| 598 |
% |
| 599 |
%1; |
| 600 |
%\end{verbatim} |
| 601 |
%You will now need to call \texttt{makedtx.pl} as follows: |
| 602 |
%\begin{verbatim} |
| 603 |
%makedtx.pl -author "AN Other" -dir source -src "dashdate\.sty=>dashdate.sty" |
| 604 |
%-src "dashdate\.perl=>dashdate.perl" |
| 605 |
%-setambles "dashdate\.perl=>\\nopreamble\\nopostamble" |
| 606 |
%-macrocode "dashdate\.perl" -doc source/manual.tex dashdate |
| 607 |
%\end{verbatim} |
| 608 |
%(Note that the line is only broken to allow it to fit onto the page, |
| 609 |
%there should be no line break when you enter it on the command line.) |
| 610 |
%Alternatively, you could save typing and do: |
| 611 |
%\begin{verbatim} |
| 612 |
%makedtx.pl -author "AN Other" -dir source -src "dashdate\.(.*)=>dashdate.\1" |
| 613 |
%-setambles "dashdate\.perl=>\\nopreamble\\nopostamble" -macrocode "dashdate\.perl" |
| 614 |
%-doc source/manual.tex dashdate |
| 615 |
%\end{verbatim} |
| 616 |
%Note the use of the \switch{setambles} switch which suppresses the |
| 617 |
%insertion of text at the start and end of the Perl script which would |
| 618 |
%only confuse Perl. Note also the use of the \switch{macrocode} |
| 619 |
%switch. This is not needed for \texttt{dashdate.sty} since it has |
| 620 |
%already been included in the source code, but since \% is not a |
| 621 |
%comment character in Perl, the \texttt{macrocode} environment is not |
| 622 |
%included in the source code, and needs to be added. (If you are |
| 623 |
%unfamiliar with DocStrip and the use of the \texttt{macrocode} |
| 624 |
%environment, I suggest you read either \emph{A guide to |
| 625 |
%\LaTeX}~\cite[Appendix~D]{Kopka98} or \emph{The \LaTeX\ |
| 626 |
%companion}~\cite[Chapter~14]{Goossens93}.) |
| 627 |
% |
| 628 |
%It's likely that you may not want the Perl code to appear in the |
| 629 |
%document, but you still want it included in the DTX file. In addition |
| 630 |
%to the \switch{macrocode} switch, you would then also need to use |
| 631 |
%the \switch{comment} switch: |
| 632 |
%\begin{verbatim} |
| 633 |
%makedtx.pl -author "AN Other" -dir source -src "dashdate\.(.*)=>dashdate.\1" |
| 634 |
%-setambles "dashdate\.perl=>\\nopreamble\\nopostamble" -macrocode "dashdate\.perl" |
| 635 |
%-comment "dashdate\.perl" -doc source/manual.tex dashdate |
| 636 |
%\end{verbatim} |
| 637 |
% |
| 638 |
%As another example, consider the \texttt{datetime} package. Version |
| 639 |
%2.42 of this package has 2 \texttt{.sty} files and 42 \texttt{.def} |
| 640 |
%files. The documentation is written in the file \texttt{manual.tex}, |
| 641 |
%and the \texttt{.sty} and \texttt{.def} files are saved in a |
| 642 |
%subdirectory called \texttt{source}. Since these are the only files |
| 643 |
%in this directory, they can easily be merged into one \texttt{.dtx} |
| 644 |
%file using: |
| 645 |
%\begin{verbatim} |
| 646 |
%makedtx.pl -author "Nicola Talbot" -dir source -src "(.+)\.(.+)=>\1.\2" |
| 647 |
%-doc manual.tex datetime |
| 648 |
%\end{verbatim} |
| 649 |
%This creates the files \texttt{datetime.dtx} and \texttt{datetime.ins} which can then be distributed. The PDF version |
| 650 |
%of the documentation is obtained by doing: |
| 651 |
%\begin{verbatim} |
| 652 |
%pdflatex datetime.dtx |
| 653 |
%\end{verbatim} |
| 654 |
%and the HTML version (\texttt{manual.html}) is obtained by doing: |
| 655 |
%\begin{verbatim} |
| 656 |
%latex2html -split 0 -nonavigation -nofootnode -numbered_footnotes -noinfo manual |
| 657 |
%\end{verbatim} |
| 658 |
%Any minor differences between the HTML and PDF versions are dealt by |
| 659 |
%using \cs{ifmakedtx} in the original file \texttt{manual.tex}. |
| 660 |
% |
| 661 |
%\section{Troubleshooting} |
| 662 |
%\label{sec:problems} |
| 663 |
% |
| 664 |
%The \texttt{makedtx} bundle has only been tested under Linux using |
| 665 |
%Perl v5.6.0. There are no guarantees whether or not it will work on |
| 666 |
%other operating systems or on different versions (in fact, there are |
| 667 |
%no guarantees or warranties at all). |
| 668 |
% |
| 669 |
%\subsection{Known Bugs} |
| 670 |
% |
| 671 |
%It's possible to confuse \texttt{makedtx.pl} by placing either the |
| 672 |
%command \cs{end}\marg{document} or the command \ics{ifmakedtx} in a |
| 673 |
%\cs{verb} command, or by having the \ics{ifmakedtx} command on the same |
| 674 |
%line as \cs{begin}\marg{document}. You will also need to take care |
| 675 |
%about lines beginning with a percent symbol (\%) in the documentation, |
| 676 |
%as this will get converted into a line beginning with \verb"%%" in the |
| 677 |
%\texttt{.dtx} file, which has a special meaning. Either place a space |
| 678 |
%immediately prior the percent symbol, or do \verb"\relax%" if you |
| 679 |
%really don't want the extra space (or place your comment in an |
| 680 |
%\cs{iffalse} \ldots\ \cs{fi} conditional). |
| 681 |
% |
| 682 |
%\subsection{Possible errors encountered using \texttt{makedtx.pl}} |
| 683 |
% |
| 684 |
%Note: be careful to use double quotes around arguments that contain |
| 685 |
%characters that the shell might try interpreting, e.g.\ \verb"*" or |
| 686 |
%\verb'>'. |
| 687 |
% |
| 688 |
%Syntax error messages: |
| 689 |
%\begin{enumerate} |
| 690 |
%\item \texttt{No document source specified (missing -doc)} |
| 691 |
% |
| 692 |
%You must use the \switch{doc} switch. |
| 693 |
% |
| 694 |
%\item \texttt{No source code specified (missing -src)} |
| 695 |
% |
| 696 |
%You must specify at least one \switch{src} switch. |
| 697 |
% |
| 698 |
%\item \texttt{No basename specified} |
| 699 |
% |
| 700 |
%You must specify the basename of the \texttt{.dtx} and \texttt{.ins} files. This should |
| 701 |
%be the last argument passed to \texttt{makedtx.pl}. |
| 702 |
% |
| 703 |
%\item \texttt{-src \ldots\ argument invalid (no output file specified)} |
| 704 |
% |
| 705 |
%You have omitted the \verb"=>" separator in the argument of the |
| 706 |
%\switch{src} switch. |
| 707 |
% |
| 708 |
%\item \texttt{-src argument \ldots\ invalid (too many => specified)} |
| 709 |
% |
| 710 |
%You have used too many \verb"=>" separators in the argument of the |
| 711 |
%\switch{src} switch. (Similarly for the \switch{setambles} switch.) |
| 712 |
%\end{enumerate} |
| 713 |
% |
| 714 |
%\appendix |
| 715 |
% |
| 716 |
%\section{Perl Regular Expressions} |
| 717 |
%\label{sec:prex} |
| 718 |
% |
| 719 |
%This section gives a very brief overview of Perl regular expressions. For more detail, look at the Perl |
| 720 |
%documentation (use \verb"man perlre" for the man page.) |
| 721 |
% |
| 722 |
%\begin{tabular}{ll} |
| 723 |
%\verb'\' & Quote the next character\\ |
| 724 |
%\verb"." & Match any character\\ |
| 725 |
%\verb"|" & Alternation\\ |
| 726 |
%\verb"()" & Grouping\\ |
| 727 |
%\verb"[]" & Character class\\ |
| 728 |
%\verb"*" & Match 0 or more times\\ |
| 729 |
%\verb"+" & Match 1 or more times\\ |
| 730 |
%\verb"?" & Match 1 or 0 times\\ |
| 731 |
%\verb"{n}" & Match exactly \texttt{n} times\\ |
| 732 |
%\verb"{n,}" & Match at least \texttt{n} times\\ |
| 733 |
%\verb"{n,m}" & Match at least \texttt{n} but no more than \texttt{m} times. |
| 734 |
%\end{tabular} |
| 735 |
% |
| 736 |
%In the replacement text, a backslash followed by a number \meta{n} indicates the text from the \meta{n}th group. |
| 737 |
% |
| 738 |
%For example, suppose you have the following files: |
| 739 |
%\begin{verbatim} |
| 740 |
%abcsrc.sty |
| 741 |
%abcsrc.bst |
| 742 |
%abcsrc.perl |
| 743 |
%foosrc.sty |
| 744 |
%foobarsrc.sty |
| 745 |
%\end{verbatim} |
| 746 |
%then if you pass the following switch to \texttt{makedtx.pl}: |
| 747 |
%\begin{itemize} |
| 748 |
%\item \verb'-src "abcsrc\.([styb]+)=>abc.\1"' |
| 749 |
%will be equivalent to: |
| 750 |
%\begin{verbatim} |
| 751 |
%-src "abcsrc.sty=>abc.sty" -src "abcsrc.bst=>abc.bst" |
| 752 |
%\end{verbatim} |
| 753 |
%since \verb'[styb]+' will match one or more of the letters \texttt{styb} (so it will match \texttt{sty} and \texttt{bst}). |
| 754 |
%\verb'\1' indicates the text found in the first group, which in this example will either be \texttt{sty} or \texttt{bst}. |
| 755 |
% |
| 756 |
%\item \verb'-src "abcsrc\.(.+)=>abc.\1"' |
| 757 |
%will be equivalent to: |
| 758 |
%\begin{verbatim} |
| 759 |
%-src "abcsrc.sty=>abc.sty" -src "abcsrc.bst=>abc.bst" -src "abcsrc.perl=>abc.perl" |
| 760 |
%\end{verbatim} |
| 761 |
%Note that a full stop represents any character so \texttt{.+} means any string of length 1 or more, whereas |
| 762 |
%\verb"\." means an actual full stop character. |
| 763 |
% |
| 764 |
%\item \verb'-src "foo(.*)src\.sty=>foo\1.sty"' |
| 765 |
%will be equivalent to: |
| 766 |
%\begin{verbatim} |
| 767 |
%-src "foosrc.sty=>foo.sty" -src "foobarsrc.sty=>foobar.sty" |
| 768 |
%\end{verbatim} |
| 769 |
% |
| 770 |
%\item \verb'-src "(.+)src\.(.+)=>\1.\2"' |
| 771 |
%will be equivalent to |
| 772 |
%\begin{verbatim} |
| 773 |
%-src "abcsrc.sty=>abc.sty" |
| 774 |
%-src "abcsrc.bst=>abc.bst" |
| 775 |
%-src "abcsrc.perl=>abc.perl" |
| 776 |
%-src "foosrc.sty=>foo.sty" |
| 777 |
%-src "foobarsrc.sty=>foobar.sty" |
| 778 |
%\end{verbatim} |
| 779 |
% |
| 780 |
%\end{itemize} |
| 781 |
% |
| 782 |
%\StopEventually{\phantomsection\addcontentsline{toc}{section}{\refname} |
| 783 |
%\csname begin\endcsname{thebibliography}{1} |
| 784 |
%\bibitem{Goossens93} The \LaTeX\ companion. Michel~Goossens, Frank~Mittelbach and Alexander~Samarin. |
| 785 |
%Addison-Wesley 1993. |
| 786 |
% |
| 787 |
%\bibitem{Kopka98} A guide to \LaTeX. Helmut~Kopka and Patrick~W.~Daly. Addison-Wesley 1998. |
| 788 |
%\csname end\endcsname{thebibliography} |
| 789 |
%\PrintChanges |
| 790 |
%\phantomsection\addcontentsline{toc}{section}{Index} |
| 791 |
%\PrintIndex} |
| 792 |
% |
| 793 |
% |
| 794 |
%\section{The Code} |
| 795 |
%\iffalse |
| 796 |
% \begin{macrocode} |
| 797 |
%<*CHANGES.org> |
| 798 |
% \end{macrocode} |
| 799 |
%\fi |
| 800 |
%\iffalse |
| 801 |
% \begin{macrocode} |
| 802 |
* version 1.3 2026/02/15 |
| 803 |
|
| 804 |
+ Add --nodrivendoc switch. |
| 805 |
+ Use strict warnings Perl package, and improve code quality/timeproofness |
| 806 |
consequently. |
| 807 |
+ Optimize output with Perl heredocuments rather than line by line. |
| 808 |
+ Improve Perl argument passing and command line capture |
| 809 |
+ Add Makefile help target |
| 810 |
+ Remove Makefile dependence on sed |
| 811 |
+ BREAKING CHANGE: Fix file name to pre-1.2 name, createdtx.sty -> creatdtx.sty. |
| 812 |
|
| 813 |
* version 1.2 2018/02/19 |
| 814 |
|
| 815 |
+ Under MSW use envvar USERNAME rather than getpwuid for getting |
| 816 |
author default value |
| 817 |
+ Use Perl I/O layers in order to have LF EOL on output, and accept |
| 818 |
both LF and CRLF on input |
| 819 |
+ Create a test bench --- add a testmode option so that date in output |
| 820 |
is fixed and output is comparable to a reference value. |
| 821 |
+ Fix perl warning about escaping { in regexp. |
| 822 |
+ Semi-colonize end of here-documents as recommended in Perl Manual. |
| 823 |
+ Fix --version cli argument, so that version is flushed to stdout |
| 824 |
before script exits. |
| 825 |
+ Automate packaging |
| 826 |
|
| 827 |
|
| 828 |
* version 0.94 (2007/08/19) : |
| 829 |
|
| 830 |
+ Default preamble changed to one which conforms with the |
| 831 |
LaTeX Project Public License (LPPL) |
| 832 |
+ license switch added |
| 833 |
|
| 834 |
* version 0.93 (2007/08/02) : |
| 835 |
|
| 836 |
+ version switch added |
| 837 |
+ comment switch added |
| 838 |
+ codetitle switch added |
| 839 |
|
| 840 |
* version 0.91 (2006/07/21) : |
| 841 |
|
| 842 |
+ prefinale switch added |
| 843 |
|
| 844 |
* version 0.9 (2005/02/11) : |
| 845 |
|
| 846 |
+ Initial beta release |
| 847 |
% \end{macrocode} |
| 848 |
%\fi |
| 849 |
%\iffalse |
| 850 |
% \begin{macrocode} |
| 851 |
%</CHANGES.org> |
| 852 |
% \end{macrocode} |
| 853 |
%\fi |
| 854 |
%\iffalse |
| 855 |
% \begin{macrocode} |
| 856 |
%<*makedtx-version.tex> |
| 857 |
% \end{macrocode} |
| 858 |
%\fi |
| 859 |
%\iffalse |
| 860 |
% \begin{macrocode} |
| 861 |
\newcommand*\version{v1.3} |
| 862 |
% \end{macrocode} |
| 863 |
%\fi |
| 864 |
%\iffalse |
| 865 |
% \begin{macrocode} |
| 866 |
%</makedtx-version.tex> |
| 867 |
% \end{macrocode} |
| 868 |
%\fi |
| 869 |
%\iffalse |
| 870 |
% \begin{macrocode} |
| 871 |
%<*latexmkrc.pl> |
| 872 |
% \end{macrocode} |
| 873 |
%\fi |
| 874 |
%\iffalse |
| 875 |
% \begin{macrocode} |
| 876 |
$dvi_mode = 0; |
| 877 |
$pdf_mode = 1; |
| 878 |
|
| 879 |
@default_files=(); |
| 880 |
foreach $file (glob('makedtx.{dtx,tex}')) |
| 881 |
{ |
| 882 |
if(-e $file){ |
| 883 |
@default_files=($file); |
| 884 |
last; |
| 885 |
} |
| 886 |
} |
| 887 |
|
| 888 |
$clean_ext='glg glo gls hd'; |
| 889 |
|
| 890 |
$makeindex= "makeindex -s gind.ist %O -o %D %S"; |
| 891 |
|
| 892 |
# 1. For glossaries using glossary package --- \changes generatated by the ltxdoc \changes directive |
| 893 |
add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' ); |
| 894 |
sub makeglo2gls { |
| 895 |
system("makeindex -s gglo.ist -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" ); |
| 896 |
} |
| 897 |
% \end{macrocode} |
| 898 |
%\fi |
| 899 |
%\iffalse |
| 900 |
% \begin{macrocode} |
| 901 |
%</latexmkrc.pl> |
| 902 |
% \end{macrocode} |
| 903 |
%\fi |
| 904 |
%\iffalse |
| 905 |
% \begin{macrocode} |
| 906 |
%<*creatdtx.sty> |
| 907 |
% \end{macrocode} |
| 908 |
%\fi |
| 909 |
% \CodelineNumbered |
| 910 |
% This is the code for the \texttt{creatdtx} package. This |
| 911 |
% package should not be used in a .dtx file. |
| 912 |
% First define the package: |
| 913 |
% \begin{macrocode} |
| 914 |
\NeedsTeXFormat{LaTeX2e} |
| 915 |
\ProvidesPackage{creatdtx}[2005/02/11 v0.9b (N.L.C. Talbot)] |
| 916 |
% \end{macrocode} |
| 917 |
% Define \cmd{ifmakedtx}. The first argument will always be ignored by \LaTeX: |
| 918 |
% \begin{macrocode} |
| 919 |
\newcommand{\ifmakedtx}[2]{#2} |
| 920 |
% \end{macrocode} |
| 921 |
% Redefine |\StopEventually| so that it simply prints its argument |
| 922 |
% \begin{macrocode} |
| 923 |
\providecommand{\StopEventually}{} |
| 924 |
\renewcommand{\StopEventually}[1]{#1} |
| 925 |
% \end{macrocode} |
| 926 |
%^^A Local Variables: |
| 927 |
%^^A mode: DocTeX |
| 928 |
%^^A End: |
| 929 |
%\iffalse |
| 930 |
% \begin{macrocode} |
| 931 |
%</creatdtx.sty> |
| 932 |
% \end{macrocode} |
| 933 |
%\fi |
| 934 |
%\iffalse |
| 935 |
% \begin{macrocode} |
| 936 |
%<*makedtx.pl> |
| 937 |
% \end{macrocode} |
| 938 |
%\fi |
| 939 |
%\iffalse |
| 940 |
% \begin{macrocode} |
| 941 |
#! /usr/bin/env perl |
| 942 |
|
| 943 |
# File : makedtx |
| 944 |
# Author : Nicola L. C. Talbot |
| 945 |
# Date : 29 Oct 2004 |
| 946 |
# Last Modified : $Date: 2026-02-15 01:18:48 +0100 (dim., 15 févr. 2026) $ |
| 947 |
# Version : 1.2 $Rev: 106 $ |
| 948 |
|
| 949 |
# usage : makedtx [options] -src <expr>=><expr> -doc <filename> <basename> |
| 950 |
# |
| 951 |
# -h : help message |
| 952 |
# -src <expr>=><expr> : e.g. -src "(foo)src\.(bar)=>$1.$2" will add foosrc.bar to <basename>.dtx to be extracted to foo.bar |
| 953 |
# -doc <filename> : file containing documentation. |
| 954 |
# -prefinale <string> : text to add to dtx file just before \Finale (added to version 0.91b) |
| 955 |
# <basename> : create <basename>.dtx and <basename>.ins |
| 956 |
|
| 957 |
use strict; |
| 958 |
use warnings; |
| 959 |
use Getopt::Long; |
| 960 |
|
| 961 |
my $version = "1.3"; |
| 962 |
|
| 963 |
my $srcdir = "."; |
| 964 |
my $patternop = "="; |
| 965 |
my $verbose = 0; |
| 966 |
my $ins = 1; |
| 967 |
my $testmode = 0; |
| 968 |
my $askforoverwrite = 0; |
| 969 |
my $preamble = ""; |
| 970 |
my $postamble = ""; |
| 971 |
my $author; |
| 972 |
my @comment; |
| 973 |
my @source; |
| 974 |
my @setambles; |
| 975 |
my @macrocode; |
| 976 |
my $docsrc; |
| 977 |
my $drivendoc = 1; |
| 978 |
|
| 979 |
if ($^O =~ m/MSWin/) |
| 980 |
{ |
| 981 |
$author = $ENV{"USERNAME"}; |
| 982 |
if ($author eq ""){ $author = 'Unknown';} |
| 983 |
} |
| 984 |
else |
| 985 |
{ |
| 986 |
$author = (getpwuid($<))[6] || 'Unknown'; |
| 987 |
} |
| 988 |
my $stopeventually = ""; |
| 989 |
my $prefinale = ""; |
| 990 |
my $codetitle = "The Code"; |
| 991 |
my $section = "section"; |
| 992 |
my $license = "lppl"; |
| 993 |
|
| 994 |
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); |
| 995 |
|
| 996 |
$year = $year + 1900; |
| 997 |
my $copyright_date = $year; |
| 998 |
my $creation_date = "$year/" . ($mon+1) . "/$mday $hour:" . ($min<10?"0$min" : $min); |
| 999 |
|
| 1000 |
my @cmdline_args = capture_cmdline(@ARGV); |
| 1001 |
|
| 1002 |
# process command line options |
| 1003 |
# v1.1 added section switch |
| 1004 |
&GetOptions("h|help" => \&help, |
| 1005 |
"v" => \$verbose, |
| 1006 |
"src=s@" => \@source, |
| 1007 |
"doc=s" => \$docsrc, |
| 1008 |
"dir=s" => \$srcdir, |
| 1009 |
"op=s" => \$patternop, |
| 1010 |
"askforoverwrite!" => \$askforoverwrite, |
| 1011 |
"ins!" => \$ins, |
| 1012 |
"preamble=s" => \$preamble, |
| 1013 |
"postamble=s" => \$postamble, |
| 1014 |
"setambles=s@" => \@setambles, |
| 1015 |
"testmode" => \$testmode, |
| 1016 |
"macrocode=s@" => \@macrocode, |
| 1017 |
"author=s" => \$author, |
| 1018 |
"date=s" => \$copyright_date, |
| 1019 |
"stopeventually=s" => \$stopeventually, |
| 1020 |
"prefinale=s" => \$prefinale, |
| 1021 |
"codetitle=s" => \$codetitle, |
| 1022 |
"comment=s@" => \@comment, |
| 1023 |
"drivendoc!" => \$drivendoc, |
| 1024 |
"version" => \&print_version, |
| 1025 |
"license=s" => \$license, |
| 1026 |
"section=s" => \$section |
| 1027 |
) or &syntaxerror(); |
| 1028 |
|
| 1029 |
if($testmode) |
| 1030 |
{ |
| 1031 |
$version = "x.y"; |
| 1032 |
$copyright_date = "YYYY"; |
| 1033 |
$creation_date = "YYYY/MM/DD hh:mm"; |
| 1034 |
} |
| 1035 |
|
| 1036 |
if ($#ARGV != 0) |
| 1037 |
{ |
| 1038 |
print "No basename specified\n"; |
| 1039 |
&syntaxerror(); |
| 1040 |
} |
| 1041 |
|
| 1042 |
my $basename = $ARGV[0]; |
| 1043 |
|
| 1044 |
if ($docsrc eq "") |
| 1045 |
{ |
| 1046 |
print "No document source specified (missing -doc)\n"; |
| 1047 |
&syntaxerror(); |
| 1048 |
} |
| 1049 |
|
| 1050 |
if ($#source == -1) |
| 1051 |
{ |
| 1052 |
print "No source code specified (missing -src)\n"; |
| 1053 |
&syntaxerror(); |
| 1054 |
} |
| 1055 |
|
| 1056 |
open DTX, ">:unix","$basename.dtx" or die "Can't open '$basename.dtx'\n"; |
| 1057 |
|
| 1058 |
if ($verbose) |
| 1059 |
{ |
| 1060 |
print "Documentation source : " . $docsrc . "\n"; |
| 1061 |
} |
| 1062 |
|
| 1063 |
# work out the derived files |
| 1064 |
|
| 1065 |
my @srcdirfile = glob("$srcdir/*"); |
| 1066 |
|
| 1067 |
my @derivedfiles = (); |
| 1068 |
|
| 1069 |
my @outputfiles = (); |
| 1070 |
|
| 1071 |
my $numoutput = 0; |
| 1072 |
|
| 1073 |
foreach my $source (@source) |
| 1074 |
{ |
| 1075 |
my ($infile, $outfile, $remainder) = split /=>/, $source; |
| 1076 |
|
| 1077 |
if ($outfile eq "") |
| 1078 |
{ |
| 1079 |
print "-src $source argument invalid (no output file specified)\n"; |
| 1080 |
|
| 1081 |
&syntaxerror(); |
| 1082 |
} |
| 1083 |
|
| 1084 |
if (defined $remainder) |
| 1085 |
{ |
| 1086 |
print "-src $source argument invalid (too many => specified)\n"; |
| 1087 |
|
| 1088 |
&syntaxerror(); |
| 1089 |
} |
| 1090 |
|
| 1091 |
foreach my $srcdirfile (@srcdirfile) |
| 1092 |
{ |
| 1093 |
my $fileexp = $srcdir . "/" . $infile; |
| 1094 |
|
| 1095 |
$_ = $srcdirfile; |
| 1096 |
|
| 1097 |
my $expr = "s$patternop$fileexp$patternop$outfile$patternop"; |
| 1098 |
|
| 1099 |
if (eval($expr)) |
| 1100 |
{ |
| 1101 |
my $thisoutfile = $_; |
| 1102 |
|
| 1103 |
my $thisinfile = $srcdirfile; |
| 1104 |
|
| 1105 |
$derivedfiles[$numoutput]{'in'} = $thisinfile; |
| 1106 |
$derivedfiles[$numoutput]{'out'} = $thisoutfile; |
| 1107 |
$outputfiles[$numoutput] = $thisoutfile; |
| 1108 |
|
| 1109 |
$numoutput++; |
| 1110 |
} |
| 1111 |
} |
| 1112 |
} |
| 1113 |
|
| 1114 |
if ($preamble eq "") |
| 1115 |
{ |
| 1116 |
if ($license eq "lppl") |
| 1117 |
{ |
| 1118 |
# v1.2 fixed typo in preamble |
| 1119 |
$preamble = <<_END_LICENSE; |
| 1120 |
|
| 1121 |
$basename.dtx |
| 1122 |
Copyright $copyright_date $author |
| 1123 |
|
| 1124 |
This work may be distributed and/or modified under the |
| 1125 |
conditions of the LaTeX Project Public License, either version 1.3 |
| 1126 |
of this license or (at your option) any later version. |
| 1127 |
The latest version of this license is in |
| 1128 |
http://www.latex-project.org/lppl.txt |
| 1129 |
and version 1.3 or later is part of all distributions of LaTeX |
| 1130 |
version 2005/12/01 or later. |
| 1131 |
|
| 1132 |
This work has the LPPL maintenance status `maintained'. |
| 1133 |
|
| 1134 |
The Current Maintainer of this work is $author. |
| 1135 |
|
| 1136 |
_END_LICENSE |
| 1137 |
} |
| 1138 |
elsif ($license eq 'bsd') |
| 1139 |
{ |
| 1140 |
$preamble = <<_END_LICENSE; |
| 1141 |
|
| 1142 |
$basename.dtx |
| 1143 |
Copyright (c) $copyright_date $author |
| 1144 |
All rights reserved. |
| 1145 |
|
| 1146 |
Redistribution and use in source and binary forms, with or without |
| 1147 |
modification, are permitted provided that the following conditions |
| 1148 |
are met: |
| 1149 |
1. Redistributions of source code must retain the above copyright |
| 1150 |
notice, this list of conditions and the following disclaimer. |
| 1151 |
2. Redistributions in binary form must reproduce the above copyright |
| 1152 |
notice, this list of conditions and the following disclaimer in the |
| 1153 |
documentation and/or other materials provided with the distribution. |
| 1154 |
3. The name of the author may not be used to endorse or promote products |
| 1155 |
derived from this software without specific prior written permission. |
| 1156 |
|
| 1157 |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 1158 |
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 1159 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 1160 |
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 1161 |
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 1162 |
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 1163 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 1164 |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 1165 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 1166 |
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 1167 |
|
| 1168 |
_END_LICENSE |
| 1169 |
} |
| 1170 |
elsif ($license eq 'gpl') |
| 1171 |
{ |
| 1172 |
$preamble = <<_END_LICENSE; |
| 1173 |
|
| 1174 |
$basename.dtx |
| 1175 |
Copyright (c) $copyright_date $author |
| 1176 |
|
| 1177 |
This program is free software; you can redistribute it and/or modify |
| 1178 |
it under the terms of the GNU General Public License as published by |
| 1179 |
the Free Software Foundation; either version 2 of the License, or |
| 1180 |
(at your option) any later version. |
| 1181 |
|
| 1182 |
This program is distributed in the hope that it will be useful, |
| 1183 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1184 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1185 |
GNU General Public License for more details. |
| 1186 |
|
| 1187 |
You should have received a copy of the GNU General Public License |
| 1188 |
along with this program; if not, write to the Free Software |
| 1189 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 1190 |
|
| 1191 |
_END_LICENSE |
| 1192 |
} |
| 1193 |
else |
| 1194 |
{ |
| 1195 |
die "Unknown license '$license'\n". |
| 1196 |
"Known licenses: lppl, bsd, gpl"; |
| 1197 |
} |
| 1198 |
|
| 1199 |
$preamble .= " This work consists of the files " |
| 1200 |
. "$basename.dtx and $basename.ins and the derived " |
| 1201 |
. ($numoutput > 1 ? "files" : "file") |
| 1202 |
. " " . join(', ', @outputfiles) . ".\n"; |
| 1203 |
} |
| 1204 |
|
| 1205 |
open DOC, '<:crlf',$docsrc or die "Can't open '$docsrc'\n"; |
| 1206 |
|
| 1207 |
print DTX "\%\\iffalse\n"; |
| 1208 |
print DTX "\% $basename.dtx generated using makedtx version $version (c) Nicola Talbot\n"; |
| 1209 |
print DTX "\% Command line args:\n"; |
| 1210 |
|
| 1211 |
if($testmode){ |
| 1212 |
@cmdline_args = sort @cmdline_args; |
| 1213 |
} |
| 1214 |
foreach my $arg (@cmdline_args){ |
| 1215 |
print DTX "\% ", $arg , "\n"; |
| 1216 |
} |
| 1217 |
|
| 1218 |
print DTX <<__EOF_HEADER |
| 1219 |
\% Created on $creation_date |
| 1220 |
\%\\fi |
| 1221 |
\%\\iffalse |
| 1222 |
\%<*package> |
| 1223 |
\%\% \\CharacterTable |
| 1224 |
\%\% {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 |
| 1225 |
\%\% Lower-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 |
| 1226 |
\%\% Digits \\0\\1\\2\\3\\4\\5\\6\\7\\8\\9 |
| 1227 |
\%\% Exclamation \\! Double quote \\\" Hash (number) \\# |
| 1228 |
\%\% Dollar \\\$ Percent \\\% Ampersand \\& |
| 1229 |
\%\% Acute accent \\\' Left paren \\( Right paren \\) |
| 1230 |
\%\% Asterisk \\* Plus \\+ Comma \\, |
| 1231 |
\%\% Minus \\- Point \\. Solidus \\/ |
| 1232 |
\%\% Colon \\: Semicolon \\; Less than \\< |
| 1233 |
\%\% Equals \\= Greater than \\> Question mark \\? |
| 1234 |
\%\% Commercial at \\\@ Left bracket \\[ Backslash \\\\ |
| 1235 |
\%\% Right bracket \\] Circumflex \\^ Underscore \\_ |
| 1236 |
\%\% Grave accent \\\` Left brace \\{ Vertical bar \\| |
| 1237 |
\%\% Right brace \\} Tilde \\~} |
| 1238 |
\%</package> |
| 1239 |
\%\\fi |
| 1240 |
\% \\iffalse |
| 1241 |
\% Doc-Source file to use with LaTeX2e |
| 1242 |
\% Copyright (C) $copyright_date $author, all rights reserved. |
| 1243 |
\% \\fi |
| 1244 |
\% \\iffalse |
| 1245 |
\%<*driver> |
| 1246 |
__EOF_HEADER |
| 1247 |
; |
| 1248 |
|
| 1249 |
my $stopfound=0; |
| 1250 |
my $indoc=0; |
| 1251 |
|
| 1252 |
while (<DOC>) |
| 1253 |
{ |
| 1254 |
s/\\usepackage\{creatdtx}//; |
| 1255 |
|
| 1256 |
my $restofline = $_; |
| 1257 |
|
| 1258 |
my $beginline = ""; |
| 1259 |
my $line = $restofline; |
| 1260 |
my $group; |
| 1261 |
|
| 1262 |
while ($restofline =~ /(.*)\\ifmakedtx(.*)/) |
| 1263 |
{ |
| 1264 |
$beginline = $1; |
| 1265 |
|
| 1266 |
my $done; |
| 1267 |
|
| 1268 |
($group,$restofline,$done) = &getnextgroup($2); |
| 1269 |
|
| 1270 |
my $startline = $.; |
| 1271 |
|
| 1272 |
while (!$done) |
| 1273 |
{ |
| 1274 |
if (my $nextline = <DOC>) |
| 1275 |
{ |
| 1276 |
$line = $line . $nextline; |
| 1277 |
|
| 1278 |
$restofline = $restofline . $nextline; |
| 1279 |
|
| 1280 |
($group,$restofline,$done) = &getnextgroup($restofline); |
| 1281 |
} |
| 1282 |
else |
| 1283 |
{ |
| 1284 |
die "EOF found whilst scanning first argument to \\ifmakedtx on line $startline\n"; |
| 1285 |
} |
| 1286 |
} |
| 1287 |
|
| 1288 |
# print first arg, ignore second |
| 1289 |
|
| 1290 |
$beginline = $beginline . $group; |
| 1291 |
|
| 1292 |
($group,$restofline,$done) = &getnextgroup($restofline); |
| 1293 |
|
| 1294 |
while (!$done) |
| 1295 |
{ |
| 1296 |
if (my $nextline = <DOC>) |
| 1297 |
{ |
| 1298 |
$line = $line . $nextline; |
| 1299 |
|
| 1300 |
$restofline = $restofline . $nextline; |
| 1301 |
|
| 1302 |
($group,$restofline,$done) = &getnextgroup($restofline); |
| 1303 |
} |
| 1304 |
else |
| 1305 |
{ |
| 1306 |
die "EOF found whilst scanning second argument to \\ifmakedtx on line $startline\n"; |
| 1307 |
} |
| 1308 |
} |
| 1309 |
|
| 1310 |
$line = $restofline; |
| 1311 |
} |
| 1312 |
|
| 1313 |
$line = $beginline . $restofline; |
| 1314 |
|
| 1315 |
if (!$drivendoc && $indoc && $line=~/\\end *\{document}/) { |
| 1316 |
$indoc = 0; |
| 1317 |
last; |
| 1318 |
} |
| 1319 |
|
| 1320 |
print DTX $line; |
| 1321 |
|
| 1322 |
if ($line=~/\\begin\{document}/) |
| 1323 |
{ |
| 1324 |
$indoc = 1; |
| 1325 |
|
| 1326 |
if ($drivendoc) { last; } |
| 1327 |
} |
| 1328 |
} |
| 1329 |
|
| 1330 |
print DTX "\\DocInput{$basename.dtx}\n"; |
| 1331 |
print DTX "\\end{document}\n"; |
| 1332 |
print DTX "\%</driver>\n"; |
| 1333 |
print DTX "\%\\fi\n"; |
| 1334 |
|
| 1335 |
my $inverb=0; |
| 1336 |
|
| 1337 |
if ($drivendoc) { |
| 1338 |
print DTX "\%"; |
| 1339 |
|
| 1340 |
while (<DOC>) |
| 1341 |
{ |
| 1342 |
if (/\\begin\{verbatim}/) |
| 1343 |
{ |
| 1344 |
$inverb=1; |
| 1345 |
} |
| 1346 |
|
| 1347 |
if (/\\end\{verbatim}/) |
| 1348 |
{ |
| 1349 |
$inverb=0; |
| 1350 |
} |
| 1351 |
|
| 1352 |
if (/\\StopEventually/ && ($inverb==0)) |
| 1353 |
{ |
| 1354 |
$stopfound=1; |
| 1355 |
} |
| 1356 |
|
| 1357 |
my $restofline = $_; |
| 1358 |
|
| 1359 |
my $beginline = ""; |
| 1360 |
my $line = $restofline; |
| 1361 |
my $group; |
| 1362 |
|
| 1363 |
while ($restofline =~ /(.*)\\ifmakedtx(.*)/) |
| 1364 |
{ |
| 1365 |
$beginline = $1; |
| 1366 |
|
| 1367 |
my $done; |
| 1368 |
|
| 1369 |
($group,$restofline,$done) = &getnextgroup($2); |
| 1370 |
|
| 1371 |
my $startline = $.; |
| 1372 |
|
| 1373 |
while (!$done) |
| 1374 |
{ |
| 1375 |
if (my $nextline = <DOC>) |
| 1376 |
{ |
| 1377 |
$line = $line . $nextline; |
| 1378 |
|
| 1379 |
$restofline = $restofline . $nextline; |
| 1380 |
|
| 1381 |
($group,$restofline,$done) = &getnextgroup($restofline); |
| 1382 |
} |
| 1383 |
else |
| 1384 |
{ |
| 1385 |
die "EOF found whilst scanning first argument to \\ifmakedtx on line $startline\n"; |
| 1386 |
} |
| 1387 |
} |
| 1388 |
|
| 1389 |
# print first arg, ignore second |
| 1390 |
|
| 1391 |
$beginline = $beginline . $group; |
| 1392 |
|
| 1393 |
($group,$restofline,$done) = &getnextgroup($restofline); |
| 1394 |
|
| 1395 |
while (!$done) |
| 1396 |
{ |
| 1397 |
if (my $nextline = <DOC>) |
| 1398 |
{ |
| 1399 |
$line = $line . $nextline; |
| 1400 |
|
| 1401 |
$restofline = $restofline . $nextline; |
| 1402 |
|
| 1403 |
($group,$restofline,$done) = &getnextgroup($restofline); |
| 1404 |
} |
| 1405 |
else |
| 1406 |
{ |
| 1407 |
die "EOF found whilst scanning second argument to \\ifmakedtx on line $startline\n"; |
| 1408 |
} |
| 1409 |
} |
| 1410 |
|
| 1411 |
$line = $restofline; |
| 1412 |
} |
| 1413 |
|
| 1414 |
$line = $beginline . $restofline; |
| 1415 |
|
| 1416 |
if (($line=~/\\end\{document}/) and not $inverb) |
| 1417 |
{ |
| 1418 |
$indoc=0; |
| 1419 |
|
| 1420 |
$line=~s/\\end\{document}//; |
| 1421 |
} |
| 1422 |
|
| 1423 |
$line=~s/\n/\n\%/mg; |
| 1424 |
|
| 1425 |
print DTX "$line"; |
| 1426 |
} |
| 1427 |
print DTX "\n"; |
| 1428 |
} |
| 1429 |
close DOC; |
| 1430 |
|
| 1431 |
|
| 1432 |
if ($stopfound==0) |
| 1433 |
{ |
| 1434 |
print DTX "\%\\StopEventually{$stopeventually}\n"; |
| 1435 |
} |
| 1436 |
|
| 1437 |
# v1.0 added check |
| 1438 |
if ($codetitle) |
| 1439 |
{ |
| 1440 |
# v1.1 added section |
| 1441 |
print DTX "\%\\$section\{$codetitle\}\n"; |
| 1442 |
} |
| 1443 |
|
| 1444 |
for (my $idx = 0; $idx <= $#derivedfiles; $idx++) |
| 1445 |
{ |
| 1446 |
my $thisinfile = $derivedfiles[$idx]{'in'}; |
| 1447 |
my $thisoutfile = $derivedfiles[$idx]{'out'}; |
| 1448 |
|
| 1449 |
if ($verbose) |
| 1450 |
{ |
| 1451 |
print "$thisinfile -> $thisoutfile\n"; |
| 1452 |
} |
| 1453 |
|
| 1454 |
open SRC, "<:crlf", $thisinfile or die "Can't open $thisinfile\n"; |
| 1455 |
|
| 1456 |
print DTX "\%\\iffalse\n"; |
| 1457 |
print DTX "\% \\begin{macrocode}\n"; |
| 1458 |
print DTX "\%<*$thisoutfile>\n"; |
| 1459 |
print DTX "\% \\end{macrocode}\n"; |
| 1460 |
print DTX "\%\\fi\n"; |
| 1461 |
|
| 1462 |
my $macrocode = 0; |
| 1463 |
my $comment = 0; |
| 1464 |
|
| 1465 |
foreach my $expr (@comment) |
| 1466 |
{ |
| 1467 |
if ($thisoutfile =~ m/$expr/) |
| 1468 |
{ |
| 1469 |
print DTX "\%\\iffalse\n"; |
| 1470 |
|
| 1471 |
$comment = 1; |
| 1472 |
|
| 1473 |
last; |
| 1474 |
} |
| 1475 |
} |
| 1476 |
|
| 1477 |
foreach my $expr (@macrocode) |
| 1478 |
{ |
| 1479 |
if ($thisoutfile =~ m/$expr/) |
| 1480 |
{ |
| 1481 |
print DTX "\% \\begin{macrocode}\n"; |
| 1482 |
|
| 1483 |
$macrocode = 1; |
| 1484 |
|
| 1485 |
last; |
| 1486 |
} |
| 1487 |
} |
| 1488 |
|
| 1489 |
while (<SRC>) |
| 1490 |
{ |
| 1491 |
print DTX "$_"; |
| 1492 |
} |
| 1493 |
|
| 1494 |
if ($macrocode == 1) |
| 1495 |
{ |
| 1496 |
print DTX "\% \\end{macrocode}\n"; |
| 1497 |
} |
| 1498 |
|
| 1499 |
if ($comment == 1) |
| 1500 |
{ |
| 1501 |
print DTX "\%\\fi\n"; |
| 1502 |
} |
| 1503 |
|
| 1504 |
print DTX "\%\\iffalse\n"; |
| 1505 |
print DTX "\% \\begin{macrocode}\n"; |
| 1506 |
print DTX "\%</$thisoutfile>\n"; |
| 1507 |
print DTX "\% \\end{macrocode}\n"; |
| 1508 |
print DTX "\%\\fi\n"; |
| 1509 |
|
| 1510 |
close SRC; |
| 1511 |
} |
| 1512 |
|
| 1513 |
print DTX "\%$prefinale\n" if ($prefinale); |
| 1514 |
print DTX "\%\\Finale\n"; |
| 1515 |
print DTX "\\endinput\n"; |
| 1516 |
|
| 1517 |
close DTX; |
| 1518 |
|
| 1519 |
if ($ins) |
| 1520 |
{ |
| 1521 |
open INS, ">:unix","$basename.ins" or die "Can't open '$basename.ins'\n"; |
| 1522 |
|
| 1523 |
print INS "\% $basename.ins generated using makedtx version $version $creation_date\n"; |
| 1524 |
|
| 1525 |
print INS "\\input docstrip\n\n"; |
| 1526 |
print INS "\\preamble\n"; |
| 1527 |
print INS "$preamble\n"; |
| 1528 |
print INS "\\endpreamble\n\n"; |
| 1529 |
|
| 1530 |
if ($postamble ne "") |
| 1531 |
{ |
| 1532 |
print INS "\\postamble\n"; |
| 1533 |
print INS "$postamble\n"; |
| 1534 |
print INS "\\endpostamble\n\n"; |
| 1535 |
} |
| 1536 |
|
| 1537 |
if ($askforoverwrite) |
| 1538 |
{ |
| 1539 |
print INS "\\askforoverwritetrue\n\n"; |
| 1540 |
} |
| 1541 |
else |
| 1542 |
{ |
| 1543 |
print INS "\\askforoverwritefalse\n\n"; |
| 1544 |
} |
| 1545 |
|
| 1546 |
print INS "\\generate{"; |
| 1547 |
|
| 1548 |
for (my $idx = 0; $idx <= $#derivedfiles; $idx++) |
| 1549 |
{ |
| 1550 |
my $thisinfile = $derivedfiles[$idx]{'in'}; |
| 1551 |
my $thisoutfile = $derivedfiles[$idx]{'out'}; |
| 1552 |
|
| 1553 |
print INS "\\file{$thisoutfile}{"; |
| 1554 |
|
| 1555 |
my $ambleset = 0; |
| 1556 |
my $noamble = 0; |
| 1557 |
|
| 1558 |
foreach my $setamble (@setambles) |
| 1559 |
{ |
| 1560 |
my ($fileexp, $amble, $remainder) = split /=>/, $setamble; |
| 1561 |
|
| 1562 |
if (defined $remainder) |
| 1563 |
{ |
| 1564 |
die "-setambles $setamble argument invalid (too many => specified)\n"; |
| 1565 |
} |
| 1566 |
|
| 1567 |
if ($thisoutfile =~ m/$fileexp/) |
| 1568 |
{ |
| 1569 |
if ($verbose) |
| 1570 |
{ |
| 1571 |
print "$fileexp matches $thisoutfile -> setting \"$amble\"\n"; |
| 1572 |
} |
| 1573 |
|
| 1574 |
print INS $amble; |
| 1575 |
|
| 1576 |
$ambleset = 1; |
| 1577 |
|
| 1578 |
if ($amble =~ m/\\nopreamble/) |
| 1579 |
{ |
| 1580 |
$noamble = 1; |
| 1581 |
} |
| 1582 |
} |
| 1583 |
} |
| 1584 |
|
| 1585 |
if (!$ambleset) |
| 1586 |
{ |
| 1587 |
print INS "\\usepreamble\\defaultpreamble\n\\usepostamble\\defaultpostamble"; |
| 1588 |
} |
| 1589 |
|
| 1590 |
print INS "\\from{$basename.dtx}{$thisoutfile"; |
| 1591 |
|
| 1592 |
if ($noamble == 0) |
| 1593 |
{ |
| 1594 |
# this will add the character table to all files except those that use \nopreamble |
| 1595 |
|
| 1596 |
print INS ",package"; |
| 1597 |
} |
| 1598 |
|
| 1599 |
print INS "}}\n"; |
| 1600 |
} |
| 1601 |
|
| 1602 |
print INS "}\n\n"; |
| 1603 |
|
| 1604 |
print INS "\\endbatchfile\n"; |
| 1605 |
|
| 1606 |
close INS; |
| 1607 |
} |
| 1608 |
|
| 1609 |
sub syntaxerror |
| 1610 |
{ |
| 1611 |
die "Syntax : makedtx [options] <basename>\nUse -h for help\n"; |
| 1612 |
} |
| 1613 |
|
| 1614 |
sub help |
| 1615 |
{ |
| 1616 |
print <<__EOF_HELP |
| 1617 |
makedtx Help |
| 1618 |
|
| 1619 |
Current Version : $version |
| 1620 |
|
| 1621 |
usage : makedtx [options] -src "<expr>=><expr>" -doc <filename> <basename> |
| 1622 |
|
| 1623 |
makedtx can be used to construct a LaTeX2e dtx and ins file from |
| 1624 |
the specified source code. The final command line argument |
| 1625 |
<basename> should be used to specify the basename of the dtx |
| 1626 |
and ins files. |
| 1627 |
|
| 1628 |
-src "<expr1>=><expr2>" |
| 1629 |
The command line switch -src identifies the original source code and the name |
| 1630 |
of the file to which it will utimately be extracted on latexing the ins file |
| 1631 |
<expr1> can be a Perl expression, such as (foo)src.(sty), and <expr2> can |
| 1632 |
a Perl substitution style expression, such as \$1.\$2 |
| 1633 |
Note that double quotes must be used to prevent shell expansion |
| 1634 |
Multiple invocations of -src are permitted |
| 1635 |
See examples below. |
| 1636 |
|
| 1637 |
-doc <filename> |
| 1638 |
The name of the documentation source code. This should be a LaTeX2e document |
| 1639 |
|
| 1640 |
Optional Arguments: |
| 1641 |
|
| 1642 |
-dir <directory> : search for source files in <directory> |
| 1643 |
-op <character> : set the pattern matching operator (default '$patternop') |
| 1644 |
-askforoverwrite : set askforoverwrite switch in INS file to true |
| 1645 |
-noaskforoverwrite : set askforoverwrite switch in INS file to false (default) |
| 1646 |
-preamble <text> : set the preamble. Standard one inserted if omitted |
| 1647 |
-postamble <text> : set the postamble. |
| 1648 |
-setambles "<pattern>=><text>" : set pre- and postambles to <text> if file matches |
| 1649 |
pattern |
| 1650 |
-author <text> : name of author (inserted into standard preamble. User name |
| 1651 |
inserted if omitted) |
| 1652 |
-date <text> : copyright date |
| 1653 |
-ins : create the ins file (default) |
| 1654 |
-noins : don't create the ins file |
| 1655 |
-prefinale <text> : add <text> immediately prior to \\Finale |
| 1656 |
-macrocode <expr> : surround any file which matches <expr> in a macrocode |
| 1657 |
environment |
| 1658 |
-comment <expr> : surround any file which matches <expr> with \\iffalse \\fi pair |
| 1659 |
-codetitle <text> : The title for the documented code section (default: The Code) |
| 1660 |
-section <cs> : The sectioning command to use for the documented code section |
| 1661 |
(default: 'section') |
| 1662 |
-license <license> : use the given license for the preamble. |
| 1663 |
Known licenses: lppl (default), bsd, gpl. |
| 1664 |
-h : help message |
| 1665 |
-nodrivendoc : documentation body is placed in driver block as is rather than |
| 1666 |
being make docstrippable (default: not set). |
| 1667 |
-v : verbose |
| 1668 |
|
| 1669 |
Examples: |
| 1670 |
|
| 1671 |
Example 1: |
| 1672 |
Documenation is in foodoc.tex |
| 1673 |
Source code is in foosrc.sty. The final extracted version should be |
| 1674 |
called foo.sty. The dtx file should be called foo.dtx and the ins file |
| 1675 |
should be called foo.ins |
| 1676 |
|
| 1677 |
makedtx -src "foosrc\\.sty=>foo.sty" -doc foodoc.tex foo |
| 1678 |
|
| 1679 |
Example 2: |
| 1680 |
Documenation is in bardoc.tex |
| 1681 |
Source code is in barsrc.sty. The final extracted version should be |
| 1682 |
called bar.sty. Source code is also in barsrc.bst. The final extracted |
| 1683 |
version should be called bar.bst. The dtx file should be called bar.dtx and |
| 1684 |
the ins file should be called bar.ins |
| 1685 |
|
| 1686 |
makedtx -src "barsrc\\.sty=>bar.sty" -src "barsrc\\.bst=>bar.bst" -doc bardoc.tex bar |
| 1687 |
|
| 1688 |
Or |
| 1689 |
|
| 1690 |
makedtx -src "barsrc\\.(bst|sty)=>bar.\$1" -doc bardoc.tex bar |
| 1691 |
|
| 1692 |
__EOF_HELP |
| 1693 |
; |
| 1694 |
die; |
| 1695 |
} |
| 1696 |
|
| 1697 |
sub print_version |
| 1698 |
{ |
| 1699 |
print "makedtx version $version\n"; |
| 1700 |
exit 0; |
| 1701 |
} |
| 1702 |
|
| 1703 |
sub eatinitialspaces |
| 1704 |
{ |
| 1705 |
my ($STR) = @_; |
| 1706 |
|
| 1707 |
while (substr($STR,0,1) =~ m/\s/) |
| 1708 |
{ |
| 1709 |
$STR = substr($STR,1); |
| 1710 |
} |
| 1711 |
|
| 1712 |
return $STR; |
| 1713 |
} |
| 1714 |
|
| 1715 |
sub getnextgroup |
| 1716 |
{ |
| 1717 |
my($curline) = @_; |
| 1718 |
|
| 1719 |
$curline = &eatinitialspaces($curline); |
| 1720 |
|
| 1721 |
# check to see if current string is blank |
| 1722 |
|
| 1723 |
if ($curline!~/[^\s]+/m) |
| 1724 |
{ |
| 1725 |
return ("","",0); |
| 1726 |
} |
| 1727 |
|
| 1728 |
if ((my $group = substr($curline,0,1)) ne "{") |
| 1729 |
{ |
| 1730 |
# next group hasn't been delimited with braces |
| 1731 |
# return first non-whitespace character |
| 1732 |
|
| 1733 |
$curline = substr($curline,1); |
| 1734 |
|
| 1735 |
# unless it's a backslash, in which case get command name |
| 1736 |
|
| 1737 |
if ($group eq "\\") |
| 1738 |
{ |
| 1739 |
if ($curline=~/([a-zA-Z]+)(^[a-zA-Z].*)/m) |
| 1740 |
{ |
| 1741 |
$group = $1; |
| 1742 |
|
| 1743 |
$curline = $2; |
| 1744 |
} |
| 1745 |
else |
| 1746 |
{ |
| 1747 |
# command is made up of backslash followed by symbol |
| 1748 |
|
| 1749 |
$curline=~/([\W_0-9\s\\])(.*)/m; |
| 1750 |
|
| 1751 |
$group = $1; |
| 1752 |
|
| 1753 |
$curline = $2; |
| 1754 |
} |
| 1755 |
} |
| 1756 |
|
| 1757 |
return ($group,$curline,1); |
| 1758 |
} |
| 1759 |
|
| 1760 |
my $pos=index($curline, "{"); |
| 1761 |
my $startpos=$pos; |
| 1762 |
my $posopen=0; |
| 1763 |
my $posclose=0; |
| 1764 |
|
| 1765 |
my $bracelevel = 1; |
| 1766 |
|
| 1767 |
my $done=0; |
| 1768 |
|
| 1769 |
while (!$done) |
| 1770 |
{ |
| 1771 |
$pos++; |
| 1772 |
|
| 1773 |
$posopen = index($curline, "{", $pos); |
| 1774 |
|
| 1775 |
# check to make sure it's not a \{ |
| 1776 |
|
| 1777 |
while ((substr($curline, $posopen-1,1) eq "\\") and ($posopen > 0)) |
| 1778 |
{ |
| 1779 |
# count how many backlashes come before it. |
| 1780 |
|
| 1781 |
my $i = $posopen-1; |
| 1782 |
|
| 1783 |
my $numbs = 1; |
| 1784 |
|
| 1785 |
while ((substr($curline, $i-1,1) eq "\\") and ($i > 0)) |
| 1786 |
{ |
| 1787 |
$numbs++; |
| 1788 |
$i--; |
| 1789 |
} |
| 1790 |
|
| 1791 |
# is $numbs is odd, we have a \{, otherwise we have \\{ |
| 1792 |
|
| 1793 |
if ($numbs%2 == 0) |
| 1794 |
{ |
| 1795 |
last; |
| 1796 |
} |
| 1797 |
else |
| 1798 |
{ |
| 1799 |
$posopen = index($curline, "{", $posopen+1); |
| 1800 |
} |
| 1801 |
} |
| 1802 |
|
| 1803 |
$posclose= index($curline, "}", $pos); |
| 1804 |
|
| 1805 |
# check to make sure it's not a \} |
| 1806 |
|
| 1807 |
while ((substr($curline, $posclose-1,1) eq "\\") and ($posclose > 0)) |
| 1808 |
{ |
| 1809 |
# count how many backlashes come before it. |
| 1810 |
|
| 1811 |
my $i = $posclose-1; |
| 1812 |
|
| 1813 |
my $numbs = 1; |
| 1814 |
|
| 1815 |
while ((substr($curline, $i-1,1) eq "\\") and ($i > 0)) |
| 1816 |
{ |
| 1817 |
$numbs++; |
| 1818 |
$i--; |
| 1819 |
} |
| 1820 |
|
| 1821 |
# is $numbs is odd, we have a \}, otherwise we have \\} |
| 1822 |
|
| 1823 |
if ($numbs%2 == 0) |
| 1824 |
{ |
| 1825 |
last; |
| 1826 |
} |
| 1827 |
else |
| 1828 |
{ |
| 1829 |
$posclose = index($curline, "}", $posclose+1); |
| 1830 |
} |
| 1831 |
} |
| 1832 |
|
| 1833 |
if (($posopen==-1) and ($posclose==-1)) |
| 1834 |
{ |
| 1835 |
$done=1; |
| 1836 |
} |
| 1837 |
elsif ($posopen==-1) |
| 1838 |
{ |
| 1839 |
$pos=$posclose; |
| 1840 |
|
| 1841 |
$bracelevel--; |
| 1842 |
|
| 1843 |
if ($bracelevel==0) |
| 1844 |
{ |
| 1845 |
my $group = substr($curline, $startpos+1, $pos-$startpos-1); |
| 1846 |
|
| 1847 |
$curline = substr($curline, $pos+1); |
| 1848 |
|
| 1849 |
return ($group,$curline,1); |
| 1850 |
} |
| 1851 |
} |
| 1852 |
elsif ($posclose==-1) |
| 1853 |
{ |
| 1854 |
$pos=$posopen; |
| 1855 |
|
| 1856 |
$bracelevel++; |
| 1857 |
} |
| 1858 |
elsif ($posopen<$posclose) |
| 1859 |
{ |
| 1860 |
$pos=$posopen; |
| 1861 |
|
| 1862 |
$bracelevel++; |
| 1863 |
} |
| 1864 |
elsif ($posclose<$posopen) |
| 1865 |
{ |
| 1866 |
$pos=$posclose; |
| 1867 |
|
| 1868 |
$bracelevel--; |
| 1869 |
|
| 1870 |
if ($bracelevel==0) |
| 1871 |
{ |
| 1872 |
my $group = substr($curline, $startpos+1, $pos-$startpos-1); |
| 1873 |
|
| 1874 |
$curline = substr($curline, $pos+1); |
| 1875 |
|
| 1876 |
return ($group,$curline,1); |
| 1877 |
} |
| 1878 |
} |
| 1879 |
} |
| 1880 |
|
| 1881 |
# closing brace must be on another line |
| 1882 |
|
| 1883 |
return ("", $curline, 0); |
| 1884 |
} |
| 1885 |
|
| 1886 |
sub make_argset { |
| 1887 |
my @args = @_; |
| 1888 |
my @escaped_args = (); |
| 1889 |
|
| 1890 |
while ($#args >= 0) { |
| 1891 |
my $arg = shift @args; |
| 1892 |
# Quoting is needed when the string $arg contains a special character |
| 1893 |
if ($arg =~ m/[`"\\\$ '*]/) { |
| 1894 |
# Precede characters ` " \ and $ by a backslash to quote them |
| 1895 |
$arg =~ s/([`"\\\$])/\\$1/g; |
| 1896 |
# backslash preceded characters w/o a special meaning (ie ` " \ and $) are left unmodified |
| 1897 |
$arg =~ s/\\([^`"\\\$])/$1/g; |
| 1898 |
$arg = "\"$arg\""; |
| 1899 |
} |
| 1900 |
push @escaped_args, $arg; |
| 1901 |
} |
| 1902 |
return join " ", @escaped_args; |
| 1903 |
} |
| 1904 |
|
| 1905 |
sub capture_cmdline |
| 1906 |
{ |
| 1907 |
my @args = @_; |
| 1908 |
my @cmdline_args = (); |
| 1909 |
# number of arguments following option switch, 2 means 1 or more |
| 1910 |
my %options = ( |
| 1911 |
h => 0, |
| 1912 |
help => 0, |
| 1913 |
v => 0, |
| 1914 |
src => 2, |
| 1915 |
doc => 1, |
| 1916 |
dir => 1, |
| 1917 |
op => 1, |
| 1918 |
askforoverwrite => 0, |
| 1919 |
noaskforoverwrite => 0, |
| 1920 |
ins => 0, |
| 1921 |
noins => 0, |
| 1922 |
preamble => 1, |
| 1923 |
postamble => 1, |
| 1924 |
setambles => 2, |
| 1925 |
testmode => 0, |
| 1926 |
macrocode => 2, |
| 1927 |
author => 1, |
| 1928 |
date => 1, |
| 1929 |
stopeventually => 1, |
| 1930 |
prefinale => 1, |
| 1931 |
codetitle => 1, |
| 1932 |
comment => 2, |
| 1933 |
drivendoc => 0, |
| 1934 |
nodrivendoc => 0, |
| 1935 |
version => 0, |
| 1936 |
license => 1, |
| 1937 |
section => 1 |
| 1938 |
); |
| 1939 |
while ($#args >= 0) { |
| 1940 |
my $arg = shift @args; |
| 1941 |
my $switch = $arg =~ s/\A-{1,2}([a-z])/$1/r; |
| 1942 |
unless (exists $options{$switch}) { |
| 1943 |
push @args, $arg; |
| 1944 |
$arg = '--'; |
| 1945 |
} |
| 1946 |
if ($arg eq '--') { |
| 1947 |
while ($#args >= 0) { |
| 1948 |
my @argset = (shift @args); |
| 1949 |
push @cmdline_args, make_argset(@argset); |
| 1950 |
} |
| 1951 |
last; |
| 1952 |
} |
| 1953 |
my $arg_count = $options{$switch}; |
| 1954 |
if ($arg_count == 0) { |
| 1955 |
push @cmdline_args, $arg; |
| 1956 |
} elsif ($arg_count == 1) { |
| 1957 |
$#args >= 0 or die "Missing argument after $arg"; |
| 1958 |
my @argset = ($arg, shift @args); |
| 1959 |
push @cmdline_args, make_argset(@argset); |
| 1960 |
} elsif ($arg_count == 2) { |
| 1961 |
$#args >= 0 or die "Missing argument after $arg"; |
| 1962 |
my @argset = ($arg, shift @args); |
| 1963 |
while ($#args >= 0 and do { |
| 1964 |
$arg = $args[0]; |
| 1965 |
$switch = $arg =~ s/\A-{1,2}([a-z])/$1/r; |
| 1966 |
!exists($options{$switch}); |
| 1967 |
}) { |
| 1968 |
push @argset, (shift @args); |
| 1969 |
} |
| 1970 |
push @cmdline_args, make_argset(@argset); |
| 1971 |
} else { |
| 1972 |
die "INTERNAL"; |
| 1973 |
} |
| 1974 |
} |
| 1975 |
return @cmdline_args; |
| 1976 |
} |
| 1977 |
% \end{macrocode} |
| 1978 |
%\fi |
| 1979 |
%\iffalse |
| 1980 |
% \begin{macrocode} |
| 1981 |
%</makedtx.pl> |
| 1982 |
% \end{macrocode} |
| 1983 |
%\fi |
| 1984 |
%\Finale |
| 1985 |
\endinput |