summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-13 00:01:54 +0000
committerKarl Berry <karl@freefriends.org>2006-01-13 00:01:54 +0000
commit38759755f56e73e1d1c282adbde41d37bad351d5 (patch)
treefb7cc99a1d669279e005cc7c4fa14156ec1dec72 /Master
parentf6f560713b9a163e037747803c63b1ee96439113 (diff)
patchcmd
git-svn-id: svn://tug.org/texlive/trunk@1174 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/tex/latex/patchcmd/patchcmd.sty119
1 files changed, 119 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/patchcmd/patchcmd.sty b/Master/texmf-dist/tex/latex/patchcmd/patchcmd.sty
new file mode 100644
index 00000000000..596992d8f24
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/patchcmd/patchcmd.sty
@@ -0,0 +1,119 @@
+%%
+%% This is file `patchcmd.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% patchcmd.dtx
+%%
+%%% ====================================================================
+%%% @LaTeX-doc-source-file{
+%%% filename = "patchcmd.dtx",
+%%% version = "1.03",
+%%% date = "2000/07/31",
+%%% time = "08:40:39 EDT",
+%%% author = "Michael J Downes",
+%%% email = "mjd@ams.org",
+%%% abstract = "Provides a way to add material at beginning or end of
+%%% a macro's existing definition.",
+%%% checksum = "23183 222 932 7411",
+%%% docstring = "The checksum field, produced by Robert Solovay's
+%%% checksum utility, gives CRC-16 checksum, lines,
+%%% words, and characters.",
+%%% }
+%%% ====================================================================
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{patchcmd}[2000/07/31 v1.03]
+%% Copyright 2000 Michael John Downes
+%% This file has no restrictions on its use, distribution, or sale.
+
+%%\def\wrs{\immediate\write\sixt@@n}
+\newcommand{\patchcommand}[1]{%
+ \expandafter\patchcmd@a\meaning#1??->@\@nil#1%
+}
+\long\def\patchcmd@a#1#2#3->#4#5\@nil#6{%
+%% \wrs{\string#6: [#1] [#2] [#3]->[#4]}%
+ \ifx @#4\relax \patchcmdError#6#1%
+ \expandafter\@gobbletwo % discard the other two arguments
+ \else
+ \if l#2\toks@{\patchcmd@e{}#6}% l in this position means \long
+ \else \toks@{\patchcmd@e*#6}% not \long
+ \fi
+ \patchcmd@b #3@#4#5 ? ? ? \@nil#6%
+ \expandafter\the\expandafter\toks@
+ \fi
+}
+\def\patchcmd@b#1:#2@#3#4 #5#6 #7 #8\@nil#9{%
+%% \wrs{[#1] [#2] [#3] [#4] [#5] [#6] ARG7=[#7] [#8]}%
+ \if \ifx @#7@\expandafter
+ \ifx\csname #6\endcsname#9T\else F\fi\else F\fi T%
+ \toks@\expandafter{\expandafter\patchcommand\csname #6 \endcsname}%
+ \else
+ \ifx @#2@% No arguments
+ \toks@\expandafter{\the\toks@ 0}%
+ \else
+ \patchcmd@c 0#2{\string##}0%
+ \fi
+ \fi
+}
+\def\patchcmd@c#1#2#3{%
+ \if\string###2% % yes it's a # token
+ \ifodd 0#31 % and it's followed by a number
+ \if 0#3\patchcmd@d#1\fi % number=0? then we're done
+ \else \patchcmd@d D% # not a number: must be a delimited arg
+ \fi
+ \else \patchcmd@d D% not a # token: must be a delmited arg
+ \fi
+ \patchcmd@c#3%
+}
+\def\patchcmd@d#1{%
+ \if D#1%
+ \PackageError{patchcmd}{Cannot change a macro that has
+ delimited arguments}\@ehd
+ \else
+ \toks@\expandafter{\the\toks@ #1}%
+ \fi
+ \begingroup
+ \aftergroup\@gobble
+ \let\patchcmd@c\endgroup
+}
+\def\patchcmd@e#1#2#3#4#5{%
+ \begingroup
+ \edef\@##1{%
+ \@temptokena\noexpand\expandafter{%
+ \noexpand#2%
+ \ifnum#3>0 {####1}\ifnum#3>1 {####2}\ifnum#3>2 {####3}%
+ \ifnum#3>3 {####4}\ifnum#3>4 {####5}\ifnum#3>5 {####6}%
+ \ifnum#3>6 {####7}\ifnum#3>7 {####8}\ifnum#3>8 {####9}%
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi
+ ##1%
+ }%
+ }
+ \@{#5}%
+ \edef\@##1{\endgroup
+ \noexpand\renewcommand#1\noexpand#2\ifcase#3 \else [#3]\fi
+ {##1\the\@temptokena}}%
+ \@{#4}%
+%% \show#2%
+}
+\long\def\patchcmdError#1#2{%
+ \begingroup
+ \toks@{Not redefinable}%
+ \ifcat\relax\noexpand#1% Is it a control sequence?
+ \begingroup
+ \let#1=?\ifx ?\relax % Is it "\relax"?
+ \endgroup % accept current value of \toks@
+ \else \endgroup
+ \if\ifx\relax#1u\else #2\fi u%
+ \toks@{Not defined}%
+ \fi
+ \fi
+ \fi
+ \edef\@{\endgroup
+ \noexpand\PackageError{patchcmd}{%
+ \the\toks@: \string#1}\noexpand\@ehd}%
+ \@
+}
+\endinput
+%%
+%% End of file `patchcmd.sty'.