summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/storecmd
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-10-19 22:27:52 +0000
committerKarl Berry <karl@freefriends.org>2011-10-19 22:27:52 +0000
commit19492a456e1fc5b19603e0d9b96cf10fb5195b52 (patch)
tree831b4f16fc9b665151505e846658e47d536d68cc /Master/texmf-dist/tex/latex/storecmd
parent35f1ce3dcdb68333a18ffee104162b49936c4c26 (diff)
storecmd (19oct11)
git-svn-id: svn://tug.org/texlive/trunk@24331 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/storecmd')
-rw-r--r--Master/texmf-dist/tex/latex/storecmd/storecmd.sty105
1 files changed, 73 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
index 9c8b410740c..79a2d78562b 100644
--- a/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
+++ b/Master/texmf-dist/tex/latex/storecmd/storecmd.sty
@@ -42,7 +42,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\xdef#2{\csliststack{#1\@space}#2\expandcsonce\LTS@tempa}%
}%
}
-\newvariables{if}[stcmd@]{storefile,storecmd,storeescap,global,protected}
+\newvariables{if}[stcmd@]{storefile,storecmd,cmdescap,global,protected}
\robust@def*\stcmd@typeintocontinue{%
\message{^^JType x or X to quit, or <RETURN> to proceed^^J}%
{\endlinechar-1\global\read-1 to\@gtempa}%
@@ -102,13 +102,13 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\if\stcmd@overwrite\else
\ifdefFT{#1}{}{\stcmd@tempa\expandcsonce}%
\fi
- \stcmd@storeescaptrue
+ \stcmd@cmdescaptrue
\gdef#1{}%
}{%
\if\stcmd@overwrite\else
\ifcsndefFT{#1}{}{\stcmd@tempa\noexpandcsn}%
\fi
- \stcmd@storeescapfalse
+ \stcmd@cmdescapfalse
\csn@gdef{#1}{}%
}%
}%
@@ -120,6 +120,18 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\XProcessOptions*\relax
\robust@def*\globalcmd{\stcmd@globaltrue}
\robust@def*\protectedcmd{\stcmd@protectedtrue}
+\robust@def*\stcmd@global@protected{%
+ \ifstcmd@global
+ \stcmd@globalfalse
+ \let\stcmd@tempa\global
+ \else
+ \let\stcmd@tempa\@empty
+ \fi
+ \ifstcmd@protected
+ \stcmd@protectedfalse\protected
+ \fi
+ \stcmd@tempa
+}
\robust@def*\defsavecmd{\cpt@starorlong\stcmd@defsavecmd}
\robust@def*\newsavecmd{\cpt@starorlong\stcmd@newsavecmd}
\robust@def*\renewsavecmd{\cpt@starorlong\stcmd@renewsavecmd}
@@ -135,7 +147,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\ifboolFT{stcmd@storecmd}{}{%
\cptexpanded{%
\stcmd@merge
- \ifstcmd@storeescap
+ \ifstcmd@cmdescap
\expandcsonce\stcmd@storecmd
\else
\noexpandcsn\stcmd@storecmd
@@ -152,16 +164,7 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\fi
}%
\stcmd@savecmd{#1}%
- \ifstcmd@global
- \stcmd@globalfalse
- \let\reserved@a\global
- \else
- \let\reserved@a\@empty
- \fi
- \ifstcmd@protected
- \stcmd@protectedfalse\protected
- \fi
- \reserved@a\l@ngrel@x\def#1%
+ \stcmd@global@protected\l@ngrel@x\def#1%
}
\robust@def*\stcmd@newsavecmd#1{%
\stcmd@savecmd{#1}%
@@ -182,12 +185,20 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\robust@def*\stcmd@newcommand{\cpt@starorlong\stcmd@n@wcommand}
\robust@def*\stcmd@n@wcommand#1{\LTS@testopt{\stcmd@n@wc@mmand#1}0}
\robust@def*\stcmd@n@wc@mmand#1[#2]{%
- \ifnextisbrack{\stcmd@xargdef#1[#2]}{\stcmd@argdef#1[#2]}%
+ \ifnextisbrack{\stcmd@xargdef@a#1{#2}}{\stcmd@argdef@a#1{#2}}%
+}
+\robust@def\stcmd@argdef@a#1#2{%
+ \LTS@testpnopt{\stcmd@argdef@b{#1}{#2}}{}%
+}
+\robust@def\stcmd@argdef@b#1#2(#3)#4{%
+ \def\stcmd@tempd{#3}%
+ \ifcsdefinable#1{\stcmd@yargdef#1\@ne{#2}{#4}}%
}
-\robust@def\stcmd@argdef#1[#2]#3{%
- \ifcsdefinable#1{\stcmd@yargdef#1\@ne{#2}{#3}}%
+\robust@def\stcmd@xargdef@a#1#2[#3]{%
+ \LTS@testpnopt{\stcmd@xargdef@b{#1}{#2}{#3}}{}%
}
-\robust@def\stcmd@xargdef#1[#2][#3]#4{%
+\robust@def\stcmd@xargdef@b#1#2#3(#4)#5{%
+ \def\stcmd@tempd{#4}%
\ifcsdefinable#1{%
\ifstcmd@global\global\fi
\ifstcmd@protected\protected\fi
@@ -195,30 +206,60 @@ $Id: storecmd.sty,v 0.0.1 2011/10/15 09:00:00 Ahmed Musa Exp $
\expandafter\@protected@testopt\expandafter#1%
\csname\string#1\endcsname{#3}%
}%
- \aftercsname\stcmd@yargdef{\string#1}\tw@{#2}{#4}%
+ \aftercsname\stcmd@yargdef{\string#1}\tw@{#2}{#5}%
}%
}
\robust@def\stcmd@yargdef#1#2#3{%
- \ifx#2\tw@
- \def\reserved@b##11{[####1]}%
+ \ifnum#2=\tw@
+ \def\stcmd@tempb##11{[####1]}%
\else
- \let\reserved@b\@gobble
+ \let\stcmd@tempb\@gobble
\fi
\expandafter\stcmd@zargdef\expandafter{\number#3}#1%
}
\robust@def\stcmd@zargdef#1#2{%
- \def\reserved@a##1#1##2##{%
- \ifstcmd@global
- \stcmd@globalfalse
- \let\reserved@a\global
- \else
- \let\reserved@a\@empty
+ \begingroup
+ \def\stcmd@tempa##1#1##2##{%
+ \def\stcmd@tempc{\stcmd@global@protected\l@ngrel@x}%
+ \cptexpandsecond{\expandafter\endgroup\stcmd@tempc
+ \expandafter\def\expandafter#2\stcmd@tempb##1#1}{\elt{#1}}%
+ }%
+ \@tempcnta\z@pt
+ \loop
+ \advance\@tempcnta\@ne
+ \csn@def{d\number\@tempcnta}{}%
+ \ifnum\@tempcnta<9\relax
+ \repeat
+ \ifx\stcmd@tempd\@empty\else
+ \@tempcnta\z@pt
+ \def\do##1##2{%
+ \ifstrcmpTF{##1}\zargdef@nil{}{%
+ \advance\@tempcnta\@ne
+ \ifnum\@tempcnta>#1\relax
+ \stcmd@err{Number of delimiters exceeds
+ number of parameters}\@ehc
+ \fi
+ \ifinsetTF{,##1,}{,1,2,3,4,5,6,7,8,9,}{}{%
+ \stcmd@err{Invalid delimiter syntax:
+ \MsgBrk no digit [1-9] found before delimiter}\@ehc
+ }%
+ \csn@def{d##1}{##2}\do
+ }%
+ }%
+ \expandafter\do\stcmd@tempd\zargdef@nil\zargdef@nil
+ \fi
+ \ifx\stcmd@tempb\@gobble\else
+ \expandafter\ifx\csname d1\endcsname\@empty\else
+ \stcmd@err{Argument one of command \string#2 is
+ \MsgBrk already delimited by '[]'}\@ehc
\fi
- \ifstcmd@protected\stcmd@protectedfalse\protected\fi
- \reserved@a\l@ngrel@x
- \expandafter\def\expandafter#2\reserved@b##1#1%
+ \fi
+ \def\elt##1{\expandcsnonce{d##1}}%
+ \edef\stcmd@tempc{0####1\ifx\stcmd@tempb\@gobble\elt1\fi
+ ####2\elt2####3\elt3####4\elt4####5\elt5####6\elt6%
+ ####7\elt7####8\elt8####9\elt9%
}%
- \reserved@a0##1##2##3##4##5##6##7##8##9###1%
+ \expandafter\stcmd@tempa\stcmd@tempc###1%
}
\endinput