diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/flags.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/oberdiek/flags.dtx | 194 |
1 files changed, 171 insertions, 23 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/flags.dtx b/Master/texmf-dist/source/latex/oberdiek/flags.dtx index 68a354ea2c6..f4d86de9a53 100644 --- a/Master/texmf-dist/source/latex/oberdiek/flags.dtx +++ b/Master/texmf-dist/source/latex/oberdiek/flags.dtx @@ -55,7 +55,7 @@ % %<*ignore> \begingroup - \def\x{LaTeX2e} + \def\x{LaTeX2e}% \expandafter\endgroup \ifcase 0\ifx\install y1\fi\expandafter \ifx\csname processbatchFile\endcsname\relax\else1\fi @@ -66,7 +66,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: flags 2007/02/18 v0.1 Flag setting in bit fields (HO)} +\Msg{* Package: flags 2007/03/07 v0.3 Flag setting in bit fields (HO)} \Msg{************************************************************************} \keepsilent @@ -126,16 +126,16 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{flags.drv}% - [2007/02/18 v0.1 Flag setting in bit fields (HO)] + [2007/03/07 v0.3 Flag setting in bit fields (HO)]% \documentclass{ltxdoc} \usepackage{holtxdoc} \begin{document} - \DocInput{flags.dtx} + \DocInput{flags.dtx}% \end{document} %</driver> % \fi % -% \CheckSum{156} +% \CheckSum{247} % % \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 @@ -156,7 +156,7 @@ and the derived files % \GetFileInfo{flags.drv} % % \title{The \xpackage{flags} package} -% \date{2007/02/18 v0.1} +% \date{2007/03/07 v0.3} % \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}} % % \maketitle @@ -173,6 +173,9 @@ and the derived files % % \subsection{User interface} % +% Flag positions are one-based, thus the flag position must be +% a positive integer. Currently supported range: |1..31| +% % \begin{declcs}{resetflags} \M{fname} % \end{declcs} % The bit field \meta{fname} is cleared. @@ -194,9 +197,26 @@ and the derived files % The bit field \meta{fname} is converted to a decimal number. % The macro is expandible. % +% \begin{declcs}{extractflag} \M{fname} \M{position} +% \end{declcs} +% Extracts the flag setting at bit position \meta{position}. +% \cs{extractflag} expands to |1| if the flag is set and |0| otherwise. +% +% \begin{declcs}{queryflag} \M{fname} \M{position} +% \M{set part} \M{clear part} +% \end{declcs} +% It is a wrapper for \cs{extractflag}. \meta{set part} is called if +% \cs{extractflag} returns |1|. Otherwise \meta{clear part} is executed. +% % \paragraph{Example.} See package \xpackage{bookmark}. % It uses package \xpackage{flags} for its font style options. % +% \subsection{Requirements} +% +% \begin{itemize} +% \item \eTeX\ (\cs{numexpr}) +% \end{itemize} +% % \subsection{ToDo} % % \begin{itemize} @@ -218,7 +238,19 @@ and the derived files %<*package> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{flags}% - [2007/02/18 v0.1 Flag setting in bit fields (HO)] + [2007/03/07 v0.3 Flag setting in bit fields (HO)]% +% \end{macrocode} +% +% \begin{macrocode} +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname numexpr\endcsname\relax + \PackageError{flags}{% + Missing e-TeX, package loading aborted% + }{% + This packages makes heavy use of \string\numexpr.% + }% + \expandafter\endinput +\fi % \end{macrocode} % % \begin{macro}{\resetflags} @@ -260,10 +292,17 @@ and the derived files % \begin{macro}{\setflag} % \begin{macrocode} \newcommand*{\setflag}[2]{% - \expandafter\@setflag\csname flags@#1\expandafter\endcsname - \expandafter{\romannumeral\number\numexpr#2-1\relax000}% + \ifnum#2>\z@ + \expandafter\@setflag\csname flags@#1\expandafter\endcsname + \expandafter{\romannumeral\number\numexpr#2-1\relax000}% + \else + \PackageError{flags}{Position must be a positive number}\@ehc + \fi } \def\@setflag#1#2{% + \ifx#1\relax + \let#1\@empty + \fi \edef#1{% \expandafter\@@setflag\expandafter{#1}{#2}% }% @@ -276,14 +315,14 @@ and the derived files \ifx\\#2\\% 1\@gobble#1% \else - \@car#1\@nil - \expandafter\@@@setflag\expandafter{\@gobble#2}{#1}% + \@@@setflag#1|#2% \fi \fi } -\def\@@@setflag#1#2\fi\fi{% +\def\@@@setflag#1#2|#3#4\fi\fi{% \fi\fi - \expandafter\@@setflag\expandafter{\@cdr#2\@nil}{#1}% + #1% + \@@setflag{#2}{#4}% } % \end{macrocode} % \end{macro} @@ -291,10 +330,17 @@ and the derived files % \begin{macro}{\clearflag} % \begin{macrocode} \newcommand*{\clearflag}[2]{% - \expandafter\@clearflag\csname flags@#1\expandafter\endcsname - \expandafter{\romannumeral\number\numexpr#2-1\relax000}% + \ifnum#2>\z@ + \expandafter\@clearflag\csname flags@#1\expandafter\endcsname + \expandafter{\romannumeral\number\numexpr#2-1\relax000}% + \else + \PackageError{flags}{Position must be a positive number}\@ehc + \fi } \def\@clearflag#1#2{% + \ifx#1\relax + \let#1\@empty + \fi \edef#1{% \expandafter\@@clearflag\expandafter{#1}{#2}% }% @@ -305,14 +351,14 @@ and the derived files \ifx\\#2\\% 0\@gobble#1% \else - \@car#1\@nil - \expandafter\@@@clearflag\expandafter{\@gobble#2}{#1}% + \@@@clearflag#1|#2% \fi \fi } -\def\@@@clearflag#1#2\fi\fi{% +\def\@@@clearflag#1#2|#3#4\fi\fi{% \fi\fi - \expandafter\@@clearflag\expandafter{\@cdr#2\@nil}{#1}% + #1% + \@@clearflag{#2}{#4}% } % \end{macrocode} % \end{macro} @@ -327,18 +373,107 @@ and the derived files } % \end{macrocode} % +% \begin{macro}{\queryflag} +% \begin{macrocode} +\newcommand*{\queryflag}[2]{% + \ifnum\extractflag{#1}{#2}=\@ne + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\extractflag} +% \begin{macrocode} +\newcommand*{\extractflag}[1]{% + \expandafter\@extractflag\csname flags@#1\endcsname +} +\def\@extractflag#1#2{% + \ifx#1\@undefined + 0% + \else + \ifx#1\relax + 0% + \else + \ifx#1\@empty + 0% + \else + \expandafter\expandafter\expandafter\@@extractflag + \expandafter\expandafter\expandafter{% + \expandafter#1\expandafter + }\expandafter{% + \romannumeral\number\numexpr#2-1\relax000% + }% + \fi + \fi + \fi +} +\def\@@extractflag#1#2{% + \ifx\\#1\\% + 0% + \else + \ifx\\#2\\% + \@car#1\@nil + \else + \@@@extractflag#1|#2% + \fi + \fi +} +\def\@@@extractflag#1#2|#3#4\fi\fi{% + \fi\fi + \@@extractflag{#2}{#4}% +} +% \end{macrocode} +% \end{macro} +% % \begin{macrocode} %</package> % \end{macrocode} % \section{Installation} % -% \paragraph{CTAN.} This package is available on +% \subsection{Download} +% +% \paragraph{Package.} This package is available on % CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}: % \begin{description} % \item[\CTAN{macros/latex/contrib/oberdiek/flags.dtx}] The source file. % \item[\CTAN{macros/latex/contrib/oberdiek/flags.pdf}] Documentation. % \end{description} % +% +% \paragraph{Bundle.} All the packages of the bundle `oberdiek' +% are also available in a TDS compliant ZIP archive. There +% the packages are already unpacked and the documentation files +% are generated. The files and directories obey the TDS standard. +% \begin{description} +% \item[\CTAN{macros/latex/contrib/oberdiek/oberdiek-tds.zip}] +% \end{description} +% +% \subsection{Bundle installation} +% +% \paragraph{Unpacking.} Unpack the \xfile{oberdiek-tds.zip} in the +% TDS tree (also known as \xfile{texmf} tree) of your choice. +% Example (linux): +% \begin{quote} +% |unzip oberdiek-tds.zip -d ~/texmf| +% \end{quote} +% +% \paragraph{Script installation.} +% Check the directory \xfile{TDS:scripts/oberdiek/} for +% scripts that need further installation steps. +% Package \xpackage{attachfile2} comes with the Perl script +% \xfile{pdfatfi.pl} that should be installed in such a way +% that it can be called as \texttt{pdfatfi}. +% Example (linux): +% \begin{quote} +% |chmod +x scripts/oberdiek/pdfatfi.pl|\\ +% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/| +% \end{quote} +% +% \subsection{Package installation} +% % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting % \docstrip\ archive. The files are extracted by running the % \xfile{.dtx} through \plainTeX: @@ -369,8 +504,10 @@ and the derived files % TDS installing feature, then some files can already be in the right % place, see the documentation of \docstrip. % -% \paragraph{Refresh file databases.} If your \TeX~distribution -% (\teTeX, \mikTeX, \dots) rely on file databases, you must refresh +% \subsection{Refresh file name databases} +% +% If your \TeX~distribution +% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh % these. For example, \teTeX\ users run \verb|texhash| or % \verb|mktexlsr|. % @@ -422,10 +559,21 @@ and the derived files % \end{quote} % % \begin{History} -% \begin{Version}{2007/02/18 v1.0} +% \begin{Version}{2007/02/18 v0.1} % \item % First version. % \end{Version} +% \begin{Version}{2007/03/07 v0.2} +% \item +% Raise an error if \eTeX\ is not detected. +% \end{Version} +% \begin{Version}{2007/03/31 v0.3} +% \item +% \cs{queryflag} and \cs{extractflag} added. +% \item +% Raise an error if position is not positive in case of +% \cs{setflag} and \cs{clearflag}. +% \end{Version} % \end{History} % % \PrintIndex |